<p dir="ltr">Hi,</p>
<p dir="ltr">r2 is 0x13 before the msr, so I guess new_level must have been 0.</p>
<div class="gmail_quote">On 25 Feb 2013 15:02, "Sebastian Huber" <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 02/25/2013 03:15 PM, Matthew J Fletcher wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sebastian,<br>
<br>
The _Thread_Heir->Registers are ok into the _Context_Switch() call, sp and lr<br>
both sensible.<br>
<br>
At the 'mrs r2, cpsr' line sp is 0x40001b2c (rubbish) and pc sensible.<br>
<br>
In _restore, after the 'ldmia r1, ...' instruction the sp and lr are loaded<br>
with the correct values from _Thread_Heir->Registers.<br>
<br>
Its the 'msr cpsr, r2' messes up the sp and lr<br>
</blockquote>
<br>
Ok, if you load undefined values into the CPSR, then a lot of things may happen. What is the value of r2 before the msr? It should be 0x13.<br>
<br>
I think there is a bug in<br>
<br>
void _CPU_Context_Initialize(<br>
Context_Control *the_context,<br>
void *stack_area_begin,<br>
size_t stack_area_size,<br>
uint32_t new_level,<br>
void (*entry_point)( void ),<br>
bool is_fp<br>
)<br>
{<br>
the_context->register_sp = (uint32_t) stack_area_begin + stack_area_size;<br>
the_context->register_lr = (uint32_t) entry_point;<br>
the_context->register_cpsr = new_level | arm_cpu_mode;<br>
}<br>
<br>
if new_level != 0. Is this the case here?<br>
<br>
-- <br>
Sebastian Huber, embedded brains GmbH<br>
<br>
Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>
Phone : <a href="tel:%2B49%2089%20189%2047%2041-16" value="+4989189474116" target="_blank">+49 89 189 47 41-16</a><br>
Fax : <a href="tel:%2B49%2089%20189%2047%2041-09" value="+4989189474109" target="_blank">+49 89 189 47 41-09</a><br>
E-Mail : <a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-<u></u>brains.de</a><br>
PGP : Public key available on request.<br>
<br>
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
</blockquote></div>