[PATCH] MIPS: start.S stack setup fixup
Antony Pavlov
antonynpavlov at gmail.com
Wed Jul 13 01:27:01 EDT 2011
---
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
More information about the barebox
mailing list