summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlaus Schnass <dev@stuffit.at>2008-03-31 21:02:29 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2008-03-31 21:02:29 +0000
commit2c6b33ce3e2eb287e6a0b25d46b96ba7876fe17a (patch)
tree51cb8c11da0d703657e7b16974b79f973ebb99d7
parentab5b3e0d985cdfb0d882f52b73a77c6f551918f3 (diff)
downloadcoreboot-staging-2c6b33ce3e2eb287e6a0b25d46b96ba7876fe17a.zip
coreboot-staging-2c6b33ce3e2eb287e6a0b25d46b96ba7876fe17a.tar.gz
Libpayload fixes to prevent triple-faults when running in QEMU.
Let the linker figure out the correct address and just CALL the start_main entry point. Signed-off-by: Klaus Schnass <dev@stuffit.at> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3204 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--payloads/libpayload/i386/head.S29
-rw-r--r--payloads/libpayload/i386/main.c18
2 files changed, 19 insertions, 28 deletions
diff --git a/payloads/libpayload/i386/head.S b/payloads/libpayload/i386/head.S
index e05cb3e..e548329 100644
--- a/payloads/libpayload/i386/head.S
+++ b/payloads/libpayload/i386/head.S
@@ -50,31 +50,26 @@ _init:
/* No interrupts, please. */
cli
- /* Get the current stack pointer. */
+ /* Store current stack pointer. */
movl %esp, %esi
+ /* Setup new stack. */
movl _istack, %ebx
- /* lret needs %cs in the stack, so copy it over. */
- movw %cs, 4(%ebx)
+ movl (%ebx), %esp
- /*
- * Exchange the current stack pointer for the one in the initial
- * stack (which happens to be the new stack pointer).
- */
- xchgl %esi, 16(%ebx)
-
- /* Set the new stack pointer. */
- movl %esi, %esp
-
- /* Return into the main entry function and go. */
- lret
+ /* Save old stack pointer. */
+ pushl %esi
+ /* Let's rock. */
+ call start_main
+
_leave:
- movl _istack, %ebx
+ /* Get old stack pointer. */
+ popl %ebx
- /* Restore the stack pointer from the storage area. */
- movl 16(%ebx), %esp
+ /* Restore old stack. */
+ movl %esp, %ebx
/* Return to the original context. */
lret
diff --git a/payloads/libpayload/i386/main.c b/payloads/libpayload/i386/main.c
index 066e2a2..a167218 100644
--- a/payloads/libpayload/i386/main.c
+++ b/payloads/libpayload/i386/main.c
@@ -36,17 +36,12 @@
* stack we store the original stack pointer from the calling application.
*/
-static void start_main(void);
extern void _leave(void);
static struct {
- uint32_t eip[2];
- uint32_t raddr[2];
uint32_t esp;
-} initial_stack __attribute__ ((section(".istack"))) = {
- { (uint32_t) start_main, 0 },
- { (uint32_t) _leave, 0 },
- (uint32_t) & initial_stack,
+} initial_stack __attribute__ ((section(".istack"))) = {
+ (uint32_t) &initial_stack,
};
void *_istack = &initial_stack;
@@ -55,7 +50,7 @@ void *_istack = &initial_stack;
* This is our C entry function - set up the system
* and jump into the payload entry point.
*/
-static void start_main(void)
+void start_main(void)
{
extern int main(void);
@@ -70,9 +65,10 @@ static void start_main(void)
* user gets control goes here.
*/
- /* Go to the entry point. */
-
- /* In the future we may care about the return value. */
+ /*
+ * Go to the entry point.
+ * In the future we may care about the return value.
+ */
(void) main();
/*
OpenPOWER on IntegriCloud