ARM (Thumb Mode) _CPU_Context_switch_arm

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Feb 26 08:42:16 UTC 2013


On 02/25/2013 09:45 PM, Joel Sherrill wrote:
> On 2/25/2013 2:14 PM, Matthew J Fletcher wrote:
>> Joel,
>>
>> _CPU_Context_Initialize in cpu.c uses a hardcoded (to 0x13, not even
>> using a #define) arm_cpu_mode variable to define the cpsr.
>>
>> #define ARM_PSR_M_SVC 0x13
>>
>> from cpu.h might be a good start.
>>
>> Although i just noticed the changelog,... oops.
>>
>> 2008-04-17    Joel Sherrill <joel.sherrill at oarcorp.com>
>>
>>     * cpu.c: Add arm_cpu_mode so ARM BSP can overrid default value for cpsr.
>>
>> Maybe if this was an extern and the BSP defined the variable and
>> initialised it it would be easier to notice. I never thought of looking
>> in cpu.c for places to modify.
>>
> Wow! I don't remember that change at all. It doesn't even sound like the
> way I would normally solve this problem. :(
>
> Sebastian.. do you remember this?

I always wondered why we have this arm_cpu_mode variable.

>
> is there a better way to accomplish this?

I would simply remove this and use:

void _CPU_Context_Initialize(
   Context_Control *the_context,
   uint32_t *stack_base,
   uint32_t size,
   uint32_t new_level,
   void *entry_point,
   bool is_fp
)
{
   the_context->register_sp = (uint32_t) stack_base + size ;
   the_context->register_lr = (uint32_t) entry_point;
   the_context->register_cpsr = new_level | ARM_PSR_M_SVC;
}

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the users mailing list