mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] MIPS: start.S stack setup fixup
@ 2011-07-13  5:27 Antony Pavlov
  0 siblings, 0 replies; only message in thread
From: Antony Pavlov @ 2011-07-13  5:27 UTC (permalink / raw)
  To: barebox

---
 arch/mips/boot/start.S |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/arch/mips/boot/start.S b/arch/mips/boot/start.S
index 6996b33..2f6fd41 100644
--- a/arch/mips/boot/start.S
+++ b/arch/mips/boot/start.S
@@ -111,9 +111,34 @@ clear_bss:
 	bne	t0, t1, 1b
 	 nop
 
+	/*
+	 * Dominic Sweetman, See MIPS Run, Morgan Kaufmann, 2nd edition, 2006
+	 *
+	 * 11.2.2 Stack Argument Structure in o32
+	 * ...
+	 * At the point where a function is called, sp must be
+	 * eight-byte-aligned, matching the alignment of the largest
+	 * basic types—a long long integer or a floating-point double.
+	 * The eight-byte alignment is not required by 32-bit MIPS integer
+	 * hardware, but it’s essential for compatibility with CPUs with
+	 * 64-bit registers, and thus part of the rules. Subroutines fit
+	 * in with this by always adjusting the stack pointer by a multiple
+	 * of eight.
+	 * ...
+	 * SGI’s n32 and n64 standards call for the stack to be maintained
+	 * with 16-byte alignment.
+	 *
+	 */
+
+#if (STACK_BASE + STACK_SIZE) % 16 != 0
+#error stack pointer must be 16-byte-aligned
+#endif
+
 stack_setup:
 	la	sp, STACK_BASE + STACK_SIZE
-	addiu	sp, -32			# init stack pointer
+
+	/* reserve four 32-bit argument slots */
+	addiu	sp, -16
 
 	la	v0, start_barebox
         jal     v0
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-07-13  5:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13  5:27 [PATCH] MIPS: start.S stack setup fixup Antony Pavlov

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