summaryrefslogtreecommitdiffstats
path: root/payloads
diff options
context:
space:
mode:
authorMaximilian Brune <maximilian.brune@9elements.com>2023-05-05 15:10:24 +0200
committerFelix Held <felix-coreboot@felixheld.de>2023-05-24 11:49:51 +0000
commit9d475bf6de63f4e05bba39e4771e0d32c07c0c9b (patch)
tree715cafa4621b060250b79cc9a890df603f90c804 /payloads
parent00d9107e02b0327ae16eb2b08605d9942ae0ab18 (diff)
downloadcoreboot-9d475bf6de63f4e05bba39e4771e0d32c07c0c9b.tar.gz
coreboot-9d475bf6de63f4e05bba39e4771e0d32c07c0c9b.tar.bz2
coreboot-9d475bf6de63f4e05bba39e4771e0d32c07c0c9b.zip
libpayload/arch/x86: Update API handling of CBTABLE handoff
The payload API of coreboot described in https://www.coreboot.org/Payload_API does not reflect the current handoff mechanism to hand the coreboot tables off. Therefore the arguments supplied by coreboot (cbtable) will currently never be parsed correctly and libpayload has to search for the coreboot tables by iterating through memory. This patch removes the old payload API implementation and just takes the coreboot table pointer from the first argument on the stack. Tested: started prodrive/atlas with coreinfo payload Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: I51fb0cfc81043cbfe3fc9c8ea0776add2d6a42b2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74965 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/arch/arm/main.c7
-rw-r--r--payloads/libpayload/arch/arm64/main.c7
-rw-r--r--payloads/libpayload/arch/x86/coreboot.c8
-rw-r--r--payloads/libpayload/arch/x86/head.S19
4 files changed, 12 insertions, 29 deletions
diff --git a/payloads/libpayload/arch/arm/main.c b/payloads/libpayload/arch/arm/main.c
index 434d946031b3..8f663e5c2b87 100644
--- a/payloads/libpayload/arch/arm/main.c
+++ b/payloads/libpayload/arch/arm/main.c
@@ -29,11 +29,6 @@
#include <exception.h>
#include <libpayload.h>
-int main_argc; /**< The argc value to pass to main() */
-
-/** The argv value to pass to main() */
-char *main_argv[MAX_ARGC_COUNT];
-
/**
* This is our C entry function - set up the system
* and jump into the payload entry point.
@@ -63,7 +58,7 @@ void start_main(void)
* In the future we may care about the return value.
*/
- (void) main(main_argc, (main_argc != 0) ? main_argv : NULL);
+ (void) main(0, NULL);
/*
* Returning here will go to the _leave function to return
diff --git a/payloads/libpayload/arch/arm64/main.c b/payloads/libpayload/arch/arm64/main.c
index 374c8b18e27d..2d599f8ef6e2 100644
--- a/payloads/libpayload/arch/arm64/main.c
+++ b/payloads/libpayload/arch/arm64/main.c
@@ -30,11 +30,6 @@
#include <libpayload.h>
#include <arch/mmu.h>
-int main_argc; /**< The argc value to pass to main() */
-
-/** The argv value to pass to main() */
-char *main_argv[MAX_ARGC_COUNT];
-
/*
* Func: pre_sysinfo_scan_mmu_setup
* Desc: We need to setup and enable MMU before we can go to scan coreboot
@@ -125,7 +120,7 @@ void start_main(void)
* In the future we may care about the return value.
*/
- (void) main(main_argc, (main_argc != 0) ? main_argv : NULL);
+ (void) main(0, NULL);
/*
* Returning here will go to the _leave function to return
diff --git a/payloads/libpayload/arch/x86/coreboot.c b/payloads/libpayload/arch/x86/coreboot.c
index cad13963ec49..ea4b8e51a586 100644
--- a/payloads/libpayload/arch/x86/coreboot.c
+++ b/payloads/libpayload/arch/x86/coreboot.c
@@ -59,6 +59,9 @@ int cb_parse_arch_specific(struct cb_record *rec, struct sysinfo_t *info)
return 1;
}
+/* This pointer gets set in head.S and is passed in from coreboot. */
+void *cb_header_ptr;
+
int get_coreboot_info(struct sysinfo_t *info)
{
int ret;
@@ -67,7 +70,10 @@ int get_coreboot_info(struct sysinfo_t *info)
* an invalid value. */
info->x86_rom_var_mtrr_index = -1;
- ret = cb_parse_header(phys_to_virt(0x00000000), 0x1000, info);
+ ret = cb_parse_header(cb_header_ptr, 1, info);
+
+ if (ret)
+ ret = cb_parse_header(phys_to_virt(0x00000000), 0x1000, info);
if (ret)
ret = cb_parse_header(phys_to_virt(0x000f0000), 0x1000, info);
diff --git a/payloads/libpayload/arch/x86/head.S b/payloads/libpayload/arch/x86/head.S
index 1052b8c94d88..87d0037a08fc 100644
--- a/payloads/libpayload/arch/x86/head.S
+++ b/payloads/libpayload/arch/x86/head.S
@@ -55,11 +55,6 @@ 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.
@@ -72,18 +67,10 @@ _init:
movl %eax, loader_eax
movl %ebx, loader_ebx
- /* Copy argv[] and argc as demanded by the Payload API,
- * see https://www.coreboot.org/Payload_API and exec.S.
- */
- cmpl $CB_MAGIC_VALUE, CB_MAGIC(%esp)
- jne 1f
-
- movl CB_ARGV(%esp), %eax
- movl %eax, main_argv
+ /* save pointer to coreboot tables */
+ movl 4(%esp), %eax
+ movl %eax, cb_header_ptr
- 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