mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
UPSTREAM: libpayload: x86/head - implement argc/argv handling
Implement the argc/argv passing as described in coreboots payload API:
http://www.coreboot.org/Payload_API
While at it, give the code some love by not needlessly trashing register
values.
BUG=none
BRANCH=none
TEST=none
Change-Id: If49874b1ac1c7359816f4ec02c5380c32101fa1a
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Id: d2f16cac74
Original-Change-Id: Ib830f2c67b631b7216843203cefd55d9bb780d83
Original-Signed-off-by: Mathias Krause <minipli@googlemail.com>
Original-Reviewed-on: https://review.coreboot.org/18336
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Original-Tested-by: build bot (Jenkins)
Reviewed-on: https://chromium-review.googlesource.com/444817
This commit is contained in:
parent
98efca1d93
commit
c958bb42a0
1 changed files with 23 additions and 18 deletions
|
@ -28,7 +28,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.code32
|
.code32
|
||||||
.global _entry, _leave
|
.global _entry
|
||||||
.text
|
.text
|
||||||
.align 4
|
.align 4
|
||||||
|
|
||||||
|
@ -55,6 +55,11 @@ mb_header:
|
||||||
.long _end
|
.long _end
|
||||||
.long _init
|
.long _init
|
||||||
|
|
||||||
|
#define CB_MAGIC_VALUE 0x12345678
|
||||||
|
#define CB_MAGIC 0x04
|
||||||
|
#define CB_ARGV 0x08
|
||||||
|
#define CB_ARGC 0x10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function saves off the previous stack and switches us to our
|
* This function saves off the previous stack and switches us to our
|
||||||
* own execution environment.
|
* own execution environment.
|
||||||
|
@ -63,34 +68,34 @@ _init:
|
||||||
/* No interrupts, please. */
|
/* No interrupts, please. */
|
||||||
cli
|
cli
|
||||||
|
|
||||||
/* There is a bunch of stuff missing here to take arguments on the stack
|
|
||||||
* See http://www.coreboot.org/Payload_API and exec.S.
|
|
||||||
*/
|
|
||||||
/* Store current stack pointer. */
|
|
||||||
movl %esp, %esi
|
|
||||||
|
|
||||||
/* Store EAX and EBX */
|
/* Store EAX and EBX */
|
||||||
movl %eax, loader_eax
|
movl %eax, loader_eax
|
||||||
movl %ebx, loader_ebx
|
movl %ebx, loader_ebx
|
||||||
|
|
||||||
/* Setup new stack. */
|
/* Copy argv[] and argc as demanded by the Payload API,
|
||||||
movl $_stack, %ebx
|
* see http://www.coreboot.org/Payload_API and exec.S.
|
||||||
|
*/
|
||||||
|
cmpl $CB_MAGIC_VALUE, CB_MAGIC(%esp)
|
||||||
|
jne 1f
|
||||||
|
|
||||||
movl %ebx, %esp
|
movl CB_ARGV(%esp), %eax
|
||||||
|
movl %eax, main_argv
|
||||||
|
|
||||||
/* Save old stack pointer. */
|
movl CB_ARGC(%esp), %eax
|
||||||
pushl %esi
|
movl %eax, main_argc
|
||||||
|
1:
|
||||||
|
/* Store current stack pointer and set up new stack. */
|
||||||
|
movl %esp, %eax
|
||||||
|
movl $_stack, %esp
|
||||||
|
pushl %eax
|
||||||
|
|
||||||
/* Let's rock. */
|
/* Let's rock. */
|
||||||
call start_main
|
call start_main
|
||||||
|
|
||||||
/* %eax has the return value - pass it on unmolested */
|
/* %eax has the return value - pass it on unmolested */
|
||||||
_leave:
|
_leave:
|
||||||
/* Get old stack pointer. */
|
|
||||||
popl %ebx
|
|
||||||
|
|
||||||
/* Restore old stack. */
|
/* Restore old stack. */
|
||||||
movl %ebx, %esp
|
popl %esp
|
||||||
|
|
||||||
/* Return to the original context. */
|
/* Return to the original context. */
|
||||||
ret
|
ret
|
||||||
|
|
Loading…
Add table
Reference in a new issue