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

Adam Dybkowski adybkows at wp.pl
Tue Jan 13 22:26:10 CET 2009


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.

-- 
Adam Dybkowski
		adybkows at wp.pl
		http://dybkowski.net/



More information about the En-Nut-Discussion mailing list