[En-Nut-Discussion] arm port (RFC: Changing ARM mode)

Alain M. alainm at pobox.com
Tue Jan 13 23:54:23 CET 2009


Rocendo Bracamontes del toro escreveu:
> On Tue, Jan 13, 2009 at 2:26 PM, Adam Dybkowski <adybkows at wp.pl> wrote:
> 
>> Alain M. wrote:
>>
>>>>   void NutSleep (uint32_t ms)
>>>>    {
>>>>        ENTRY_KERNEL_MODE(); // change mode to supervisor when applicable
>>>>
>>>>       ..... code execute at kernel level here ....
>>>>
>>>>        EXIT_KERNEL_MODE(); exit supervisor mode, enter user mode when
>>>> applicable
>>>>   }
>>> I am no expert in the matter, but in my undertanding this is not very
>>> good. The problem is that SWI is a CALL, not a command has one parameter
>>> for the function and parametters have to be fetch from the user stack.
>>> This calls for an entire different achitecture.
>> I think this is not a real problem because SWI call works similar to
>> interrupt - CPU suddenly jumps to address 0x08, switches to Supervisor
>> and ARM mode (if it was in Thumb). The SWI handler could extract the
>> return address and jump there in priviledged Supervisor mode (extra
>> bonus: own system stack) or switch into System mode (the same as User
>> mode but priviledged). EXIT_KERNEL_MODE will be much easier because we
>> have only to switch to User mode (restore CPSR as it was before
>> ENTRY_KERNEL_MODE), without using SWI to do it.
> 
>  Agree ...

It will probably work with ARM7, but it looks more like a hack...
But it will not work anymore on Cortex...

Alain




More information about the En-Nut-Discussion mailing list