diff options
author | Mathias Krause <minipli@googlemail.com> | 2017-02-11 22:47:04 +0100 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-02-17 17:29:40 +0100 |
commit | d2f16cac749065e373b0558c850a8d9d2254c700 (patch) | |
tree | d2a749da3f1d5548c8f5f6384b771364bd105bb0 /payloads/libpayload | |
parent | 57dc93c967f45167f09e7817266ebb4f3dbda62a (diff) | |
download | coreboot-d2f16cac749065e373b0558c850a8d9d2254c700.tar.xz |
libpayload: x86/head - implement argc/argv handling
Implement the argc/argv passing as described in coreboot’s payload API:
http://www.coreboot.org/Payload_API
While at it, give the code some love by not needlessly trashing register
values.
Change-Id: Ib830f2c67b631b7216843203cefd55d9bb780d83
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Reviewed-on: https://review.coreboot.org/18336
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins)
Diffstat (limited to 'payloads/libpayload')
-rw-r--r-- | payloads/libpayload/arch/x86/head.S | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/payloads/libpayload/arch/x86/head.S b/payloads/libpayload/arch/x86/head.S index fa9bb7374f..94a4d41167 100644 --- a/payloads/libpayload/arch/x86/head.S +++ b/payloads/libpayload/arch/x86/head.S @@ -28,7 +28,7 @@ */ .code32 - .global _entry, _leave + .global _entry .text .align 4 @@ -55,6 +55,11 @@ mb_header: .long _end .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 * own execution environment. @@ -63,34 +68,34 @@ _init: /* No interrupts, please. */ 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 */ - movl %eax,loader_eax - movl %ebx,loader_ebx + movl %eax, loader_eax + movl %ebx, loader_ebx - /* Setup new stack. */ - movl $_stack, %ebx + /* Copy argv[] and argc as demanded by the Payload API, + * 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. */ - pushl %esi + movl CB_ARGC(%esp), %eax + 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. */ call start_main /* %eax has the return value - pass it on unmolested */ _leave: - /* Get old stack pointer. */ - popl %ebx - /* Restore old stack. */ - movl %ebx, %esp + popl %esp /* Return to the original context. */ ret |