This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to enter Secure mode

Note: This was originally posted on 29th July 2011 at http://forums.arm.com

Hi all,
I want to use TCM in ARM1176ZJF-S core. It will be accessed in Non-secure world (cause I don't use TrustZone) but by default it's configured as secure TCM. So, it's not visible.  I need to change it to non-secure TCM which is indicated by the NS bit. According to the Ref, if I want to change the NS bit, I need to enter Secure privileged mode first.
My question is how can I enter that mode?
I tried the following, according to ARM1176JZF-S tech ref,

             asm("str     lr,[sp, #-4]!");
             asm("smc     #0");
             asm("mrc     p15, 0, %0, c9, c1, 2" 
                 : "=r" (tcm_secure));
             tcm_secure |= 1;
             asm("mcr     p15, 0, %0, c9, c1, 2"   /* set DTCM NS bit to 1 */
                 :
                 : "r" (tcm_secure));
             asm("movs    pc, lr");
             asm("ldr     lr, [sp, #0]!");


It doesn't work, however. Compiler says SMC is supported.
Please help, TCM troubles me for weeks.

Thanks for any input
Zova
  • Note: This was originally posted on 31st July 2011 at http://forums.arm.com


    The SMC instruction (from a privileged processor mode) will cause the core to trap execution to the exception table in Monitor mode, just like a user-kernel switch using the "SVC" instruction. So you can't just drop an "SMC" inline with your program code, that's not likely to work.

    What does happen when you reach the monitor exception table is entirely down to the monitor mode software which is installed, so I can't help on that bit  =)


    Thanks for your reply.

    I put those code above in a simple driver, so it's from a privileged mode. However, compiler complains about it. Where can I find the exception table, in bootloader? The system use U-boot, and I search across the code, finding only a #define of TZIC (TrustZone Interrupt Controoler) base address.

    Thanks,
    Zova
  • Note: This was originally posted on 31st July 2011 at http://forums.arm.com


    I suppose it would be far easier to just ignore TrustZone and stay in secure world. Why do you bother switching to non-secure at all?

    Kindly
    Marcus


    Thanks Marcus,
    I just want to put some data/code into TCM. It's okay to stay in secure world, but then, if I want to use TCM, I need to set the NS bit (to 0 according to the Tech Ref.) in the page table. Again, I think that's far more difficult for me to do that since MMU setup is done in bootloader and I don't know if there's any way to set that bit after booting has been done.
    All info I've got is:
    1 TCM is configured as Secure TCM
    2. TCM is visible in secure world only when NS bit in crossponding page table is set to zero.
    3. I want to put some code/data in TCM and access it
    4. I got this msg when run the example code in the topic [CLICK ME ]: Unhandled fault: external abort on non-linefetch (0x008) at 0x4001f000 Bus error

    So, in order to be simple and , more important, to be easier for me to go on( I'm a pretty new baby in the embedded world...) I think it's better to goto non-secure world and try to make it accordence to what's descriped in the Ref.

    Thanks,
    Zova
  • Note: This was originally posted on 31st July 2011 at http://forums.arm.com


    It is  also worth noting that the "typical" user model is that the bootstrap  (running in secure) sets up the platform, assigning periphals, TCM, etc  to the correct worlds, and the proceeds with the boot of the higher  levels of the system.

    It is unusual to want to re-partition resources after this point, especially things like TCM, so can't your bootloader do this?


    Thanks isogen74!

    The "typical" user model is really good since it give me a overall pic, which helps me in understanding the booting process.
    The  boot loader is u-boot for s3c6410 board. I do find some TCM  configurations in the code, however, the TCM there seems not the same  TCM descriped in User Manual.
    TCM in uboot consists of one 8K ITCM or  stepping stone, and a 16K D-TCM and they are used for bootstrapping,  and in the UM it's 16K I/D-TCM. So, I guess TCM here is not one that's  used to hold those "performance critical code/data". If I'm wrong, please correct me.

    Thanks,
    Zova
  • Note: This was originally posted on 29th July 2011 at http://forums.arm.com

    The SMC instruction (from a privileged processor mode) will cause the core to trap execution to the exception table in Monitor mode, just like a user-kernel switch using the "SVC" instruction. So you can't just drop an "SMC" inline with your program code, that's not likely to work.

    What does happen when you reach the monitor exception table is entirely down to the monitor mode software which is installed, so I can't help on that bit  =)
  • Note: This was originally posted on 29th July 2011 at http://forums.arm.com

    It is also worth noting that the "typical" user model is that the bootstrap (running in secure) sets up the platform, assigning periphals, TCM, etc to the correct worlds, and the proceeds with the boot of the higher levels of the system.

    It is unusual to want to re-partition resources after this point, especially things like TCM, so can't your bootloader do this?
  • Note: This was originally posted on 29th July 2011 at http://forums.arm.com


    It will be accessed in Non-secure world (cause I don't use TrustZone) but by default it's configured as secure TCM.

    I suppose it would be far easier to just ignore TrustZone and stay in secure world. Why do you bother switching to non-secure at all?

    Kindly
    Marcus