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
Parents
  • 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
Reply
  • 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
Children
No data