Some RTEMS Questions

Ed Sutter esutter at lucent.com
Fri Jul 8 16:47:22 UTC 2005


Keith,
Thanks much for your feedback. I can't explain why enabling the
PPC_USE_SPRG fixes something for us; however, it appears to have done
the trick.  This is apparently just the opposite of what you said you
did, so obviously we must have slightly different environments.  You
mentioned that in your case, the content of the SPRG registers were
scrogged.  Looking at the code, the problem *may* be because 'i' is
not volatile...

void _CPU_Initialize(
   rtems_cpu_table  *cpu_table,
   void      (*thread_dispatch)      /* ignored on this CPU */
)
{
#if (PPC_USE_SPRG)
   int i;
#endif

...

#if (PPC_USE_SPRG)
   i = (int)&_CPU_IRQ_info;
   asm volatile("mtspr 0x113, %0" : "=r" (i) : "0" (i)); /* SPRG 3 */
#endif

...

#if (PPC_USE_SPRG)
   i = _CPU_IRQ_info.msr_initial;
   asm volatile("mtspr 0x112, %0" : "=r" (i) : "0" (i)); /* SPRG 2 */
#endif

...
}


I'm no compiler guru, so this is just a hunch.  Note that the only use
of 'i' is within the asm() statements.  Is it possible that the compiler
is ignoring the use of 'i' within those statements and as a result it
optimizes the two "i = xxx" assignment lines out because it thinks 'i' isn't
being used?  I can't test this because it works without the volatile for
me; however, you may want to try making 'i' volatile and seeing if that
makes this work for you.  If it does, (actually even if it doesn't), this
is probably a good thing to change in the cpu.c file.

Comments anyone?

Ed Sutter



More information about the users mailing list