This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Powerpc stack initialization
- From: "David POUTY" <david dot pouty at com2gether dot net>
- To: <ecos-patches at sources dot redhat dot com>
- Date: Mon, 12 Jan 2004 15:56:03 +0100
- Subject: Powerpc stack initialization
I think there's a bug in stack initialization for PowerPC plateform in
file vectors.S:
- During '_start' a stack frame is created at the stack base for calls
to C code.
- In function 'cyg_hal_default_exception_vsr' 2 stacks frame are created
(a null frame and one for C code) on the stack before calling the
interrupt handler.
If CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK is defined to use
the same stack for interrupt and threads then the stack is corrupted
because there is only one frame free at the stack base.
There's no problem if CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
is not defined because the 2 frames are created on the stack top.
So I propose the following patch:
Index: vectors.S
===================================================================
RCS file:
/cvs/ecos/ecos/packages/hal/powerpc/arch/current/src/vectors.S,v
retrieving revision 1.32
diff -u -r1.32 vectors.S
--- vectors.S 8 Dec 2003 14:26:03 -0000 1.32
+++ vectors.S 12 Jan 2004 14:20:33 -0000
@@ -371,7 +371,10 @@
stw r0,0(sp) # clear back chain
stw r0,8(sp) # zero return pc
stwu sp,-CYGARC_PPC_STACK_FRAME_SIZE(sp) # create new stack
frame
-
+#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
+ stwu sp,-CYGARC_PPC_STACK_FRAME_SIZE(sp) # create new stack
frame
+#endif
+
# Variant HALs may need to do something special before we
continue
bl hal_variant_init
____________________________
David POUTY