public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCHv2 1/2] mpc85xx: Initial SP alignment is wrong.
@ 2012-07-23 20:58 Joakim Tjernlund
  2012-07-23 20:58 ` [U-Boot] [PATCHv2 2/2] powerpc: Stack Pointer not properly aligned Joakim Tjernlund
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Joakim Tjernlund @ 2012-07-23 20:58 UTC (permalink / raw)
  To: u-boot

PowerPC mandates SP to be 16 bytes aligned.
Furthermore, a stack frame is added, pointing to the reset vector
which may in the way when gdb is walking the stack because
the reset vector may not accessible depending on emulator settings.
Also use a temp register so gdb doesn't pick up intermediate values.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---

 v2 - Address Scott Wood's comments
 arch/powerpc/cpu/mpc85xx/start.S |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git arch/powerpc/cpu/mpc85xx/start.S arch/powerpc/cpu/mpc85xx/start.S
index 8d66cf1..4973682 100644
--- arch/powerpc/cpu/mpc85xx/start.S
+++ arch/powerpc/cpu/mpc85xx/start.S
@@ -848,18 +848,12 @@ version_string:
 	.globl	_start_cont
 _start_cont:
 	/* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/
-	lis	r1,CONFIG_SYS_INIT_RAM_ADDR at h
-	ori	r1,r1,CONFIG_SYS_INIT_SP_OFFSET at l
-
+	lis	r3,(CONFIG_SYS_INIT_RAM_ADDR)@h
+	ori	r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */
 	li	r0,0
-	stwu	r0,-4(r1)
-	stwu	r0,-4(r1)		/* Terminate call chain */
-
-	stwu	r1,-8(r1)		/* Save back chain and move SP */
-	lis	r0,RESET_VECTOR at h	/* Address of reset vector */
-	ori	r0,r0,RESET_VECTOR at l
-	stwu	r1,-8(r1)		/* Save back chain and move SP */
-	stw	r0,+12(r1)		/* Save return addr (underflow vect) */
+	stw	r0,0(r3)	/* Terminate Back Chain */
+	stw	r0,+4(r3)	/* NULL return address. */
+	mr	r1,r3		/* Transfer to SP(r1) */
 
 	GET_GOT
 	bl	cpu_init_early_f
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-08-23 18:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-23 20:58 [U-Boot] [PATCHv2 1/2] mpc85xx: Initial SP alignment is wrong Joakim Tjernlund
2012-07-23 20:58 ` [U-Boot] [PATCHv2 2/2] powerpc: Stack Pointer not properly aligned Joakim Tjernlund
2012-08-14 20:55   ` Joakim Tjernlund
2012-08-14 20:55 ` [U-Boot] [PATCHv2 1/2] mpc85xx: Initial SP alignment is wrong Joakim Tjernlund
2012-08-14 21:01   ` Scott Wood
2012-08-15  7:05     ` Joakim Tjernlund
2012-08-14 21:28 ` Kumar Gala
2012-08-15  7:10   ` Joakim Tjernlund
2012-08-15 17:13     ` Scott Wood
2012-08-16 23:40       ` Andy Fleming
2012-08-22 21:08 ` Andy Fleming
2012-08-23  7:21   ` Joakim Tjernlund
2012-08-23 16:53     ` Scott Wood
2012-08-23 18:51       ` Joakim Tjernlund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox