This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Exception vector table and SVC calls

Other Parts Discussed in Thread: AM3359

Hello support team,

I am using a StarterWare example to test switching between User Mode and System Mode.
Therfore I call CPUSwitchToUserMode() and CPUSwitchToPrivilegedMode().
The function CPUSwitchToPrivilegedMode() raises an exception with the SWI instruction. Then I observe a very strange behavior. The CPU jumps to the SVC_Handler function, defined in exceptionhandler.asm, but the code is not executed. Instead the CPU jumps right back to the caller. So the CPU remains in User Mode (10000). It's not possible to switch back into System Mode (11111). Unfortunately there is no example in the StarterWare, where these functions are used.

If I have to use the security extension to switch between unsecure state and secure state, independent exception vector tables are required. In the StarterWare the unsecure vector table is set in startup.c. If somebody ever used these functions, I would like to know the results.

(I use the CCS5.5 with a Beaglebone black and AM3359)

Thanks in advance,
Stephan

  • Hi Stephan,

    Can you check the SWI number being passed in the CPUSwitchToPrivilegedMode API. If the number is 1 then can you change it to 458752 and test the code.

    Regards

    Anant Pai

  • Hello Anant,

    at the beginning of my main I call:

    asm(" mrs r0, CPSR\n\t"
    " bic r0, r0, #0x0F\n\t"
    " orr r0, r0, #0x10\n\t "
    " msr CPSR_c, r0");

    Now the CPU is in user-mode (10000).

    asm(" SWI #458752");

    The SWI throws an exception and jumps to the SVC_handler. PC is 0x4030FC08 and the Mode is 10011. The CP15_VECTOR_BASE_ADDRESS is 0x403FC00 (like monitor base behind). But the code of SVC_Handler is not exceuted. It jumps back to main and the mode remains at 10000.

    I suppose there is any setting in the control registers missing, which permits the execution in the current (secure) mode.

    Regards,
    Stephan