summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/i386/pc386/start/start.S
diff options
context:
space:
mode:
authorTill Straumann <strauman@slac.stanford.edu>2009-10-29 03:22:19 +0000
committerTill Straumann <strauman@slac.stanford.edu>2009-10-29 03:22:19 +0000
commit23303c031115e9506952cc1e3f3683b270dc6c0d (patch)
tree1ea111c73e49c307accfd0352336562950c949e5 /c/src/lib/libbsp/i386/pc386/start/start.S
parent2009-10-29 Ralf Corsépius <ralf.corsepius@rtems.org> (diff)
downloadrtems-23303c031115e9506952cc1e3f3683b270dc6c0d.tar.bz2
2009-10-28 Till Straumann <strauman@slac.stanford.edu>
* start/start.S: Make sure initial stack is aligned to CPU_STACK_ALIGNMENT before calling C-code.
Diffstat (limited to '')
-rw-r--r--c/src/lib/libbsp/i386/pc386/start/start.S19
1 files changed, 15 insertions, 4 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/start/start.S b/c/src/lib/libbsp/i386/pc386/start/start.S
index 373c2d7658..ad71ccdf31 100644
--- a/c/src/lib/libbsp/i386/pc386/start/start.S
+++ b/c/src/lib/libbsp/i386/pc386/start/start.S
@@ -42,11 +42,16 @@
*/
#include <rtems/asm.h>
+#include <rtems/score/cpu.h>
/*----------------------------------------------------------------------------+
| Size of heap and stack:
+----------------------------------------------------------------------------*/
+#ifndef CPU_STACK_ALIGNMENT
+#error "Missing header ? CPU_STACK_ALIGNMENT NOT DEFINED"
+#endif
+
.set STACK_SIZE, 0x1000
/*----------------------------------------------------------------------------+
@@ -164,7 +169,8 @@ SYM (_establish_stack):
movl $_end, eax # eax = end of bss/start of heap
addl $STACK_SIZE, eax # make room for stack
- andl $0xffffffc0, eax # align it on 16 byte boundary
+ subl $4, eax # reserve room for arg to 'boot_card'
+ andl $ - CPU_STACK_ALIGNMENT, eax # align SP on CPU_STACK_ALIGNMENT boundary
movl eax, esp # set stack pointer
movl eax, ebp # set base pointer
@@ -197,12 +203,17 @@ SYM (zero_bss):
/*---------------------------------------------------------------------+
| Transfer control to User's Board Support Package
+| Note: at the top we reserved space for the argument
+| so that
+| initial_esp = ( TOS - 4 ) & ~(CPU_STACK_ALIGNMENT-1)
+| this ensures that
+| 1) esp is now aligned
+| 2) there is space for the cmdline pointer which we just
+| may store at *(esp)
+---------------------------------------------------------------------*/
- movl $SYM(_boot_multiboot_cmdline), eax
- pushl eax # cmdline
+ movl $SYM(_boot_multiboot_cmdline), (esp)
call SYM (boot_card)
- addl $4, esp
/*---------------------------------------------------------------------+
| Clean up - we do not know anything about it, so we will