Q about stack alignment on PowerPC.

Joel Sherrill joel.sherrill at OARcorp.com
Mon Sep 25 12:57:55 UTC 2000


Eric V... question for you are the bottom...

Sergei Organov wrote:
> 
> Joel Sherrill <joel.sherrill at OARcorp.com> writes:
> 
> [...]
> 
> > I would think it should be something like this to be correct:
> >
> >  sp = ((unsigned32) stack_base + size) & ~CPU_STACK_ALIGNMENT;
> >  sp -= CPU_MINIMUM_STACK_FRAME_SIZE;
> >
> > CPU_STACK_ALIGNMENT has to be a power of 2.  The stack grows down
> > so the "&" is just going to lower the top of the stack 0-15 bytes.
> >
> > If this works for you, please send a real patch back and let me know.
> 
> The right code is, I believe,
> 
>   sp = ((unsigned32) stack_base + size) & ~(CPU_STACK_ALIGNMENT - 1);
>   sp -= CPU_MINIMUM_STACK_FRAME_SIZE;
> 
> Unfortunately, I can't quickly check this on latest RTEMS. It works for RTEMS
> 3.0 though. 

I can get this simply a change in by hand.

> Due to the same reason I can't send a patch relative to reasonably
> recent RTEMS sources.

The ppc code has moved around a lot since 3.6.0.  
 
> BTW, does the latest RTEMS use dedicated interrupt stack on PowerPC? If so,
> where the stack pointer is initialized? There was a separate peace of code in
> earlier versions of RTEMS, but I can't find it in the latest snapshot.

The old_exception_code clearly still uses a software interrupt stack.
See c/src/lib/libcpu/powerpc/old_exception_processing/cpu.c and search
for _CPU_Install_interrupt_stack.

I cannot find the equivalent code in the new exception processing. Eric
V,
does the new exception code on the PPC use a software interrupt stack?  


> BR,
> Sergei.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985



More information about the users mailing list