summaryrefslogtreecommitdiffstats
path: root/c
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
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 'c')
-rw-r--r--c/src/lib/libbsp/i386/pc386/ChangeLog7
-rw-r--r--c/src/lib/libbsp/i386/pc386/start/start.S19
2 files changed, 21 insertions, 5 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/ChangeLog b/c/src/lib/libbsp/i386/pc386/ChangeLog
index 31803f5503..9cf87179a7 100644
--- a/c/src/lib/libbsp/i386/pc386/ChangeLog
+++ b/c/src/lib/libbsp/i386/pc386/ChangeLog
@@ -1,4 +1,9 @@
-2009-12-27 Till Straumann <strauman@slac.stanford.edu>
+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.
+
+2009-10-27 Till Straumann <strauman@slac.stanford.edu>
* include/bsp.h, console/console.c: Provide weak-alias
hook so that the application may choose the console.
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