Aaron Durbin (adurbin@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5300
-gerrit
commit 6e301c3e0d4fbd9044fbe6914cf9b420d86b48f3 Author: Aaron Durbin adurbin@chromium.org Date: Mon Feb 24 22:27:39 2014 -0600
coreboot: introduce arch_payload_run()
The selfboot() function relied on global variables within the selfboot.c compilation unit. Now that the bounce buffer is a part of struct payload use a new architecture-specific arch_payload_run() function for jumping to the payload. selfboot() can then be removed.
Change-Id: Icec74942e94599542148561b3311ce5096ac5ea5 Signed-off-by: Aaron Durbin adurbin@chromium.org --- src/arch/armv7/boot.c | 7 ++++--- src/arch/armv7/include/arch/stages.h | 1 - src/arch/x86/boot/boot.c | 18 ++++++++++++------ src/arch/x86/include/arch/stages.h | 1 - src/include/payload_loader.h | 4 +++- src/lib/loaders/load_and_run_payload.c | 2 +- src/lib/selfboot.c | 7 ------- 7 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/arch/armv7/boot.c b/src/arch/armv7/boot.c index 6774802..d872a79 100644 --- a/src/arch/armv7/boot.c +++ b/src/arch/armv7/boot.c @@ -19,9 +19,10 @@
#include <console/console.h> #include <arch/stages.h> +#include <payload_loader.h>
-void jmp_to_elf_entry(void *entry, unsigned long buffer, unsigned long size) +void arch_payload_run(const struct payload *payload) { - printk(BIOS_SPEW, "entry = %p\n", entry); - stage_exit(entry); + printk(BIOS_SPEW, "entry = %p\n", payload->entry); + stage_exit(payload->entry); } diff --git a/src/arch/armv7/include/arch/stages.h b/src/arch/armv7/include/arch/stages.h index 3fd54b9..671c02b 100644 --- a/src/arch/armv7/include/arch/stages.h +++ b/src/arch/armv7/include/arch/stages.h @@ -24,6 +24,5 @@ extern void main(void);
void stage_entry(void) __attribute__((section(".text.stage_entry.armv7"))); void stage_exit(void *); -void jmp_to_elf_entry(void *entry, unsigned long buffer, unsigned long size);
#endif diff --git a/src/arch/x86/boot/boot.c b/src/arch/x86/boot/boot.c index 3ef46a5..29070a0 100644 --- a/src/arch/x86/boot/boot.c +++ b/src/arch/x86/boot/boot.c @@ -1,12 +1,12 @@ #include <console/console.h> #include <arch/stages.h> +#include <payload_loader.h> #include <ip_checksum.h> #include <string.h>
-#if CONFIG_RELOCATABLE_RAMSTAGE /* When the ramstage is relocatable the elf loading ensures an elf image cannot * be loaded over the ramstage code. */ -void jmp_to_elf_entry(void *entry, unsigned long unused1, unsigned long unused2) +static void jmp_payload_no_bounce_buffer(void *entry) { /* Jump to kernel */ __asm__ __volatile__( @@ -22,8 +22,8 @@ void jmp_to_elf_entry(void *entry, unsigned long unused1, unsigned long unused2) "r" (entry) ); } -#else -void jmp_to_elf_entry(void *entry, unsigned long buffer, unsigned long size) + +static void jmp_payload(void *entry, unsigned long buffer, unsigned long size) { extern unsigned char _ram_seg, _eram_seg; unsigned long lb_start, lb_size; @@ -122,6 +122,12 @@ void jmp_to_elf_entry(void *entry, unsigned long buffer, unsigned long size) "ri"(0), "ri" (0) ); } -#endif /* CONFIG_RELOCATABLE_RAMSTAGE */ -
+void arch_payload_run(const struct payload *payload) +{ + if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE)) + jmp_payload_no_bounce_buffer(payload->entry); + else + jmp_payload(payload->entry, (uintptr_t)payload->bounce.data, + payload->bounce.size); +} diff --git a/src/arch/x86/include/arch/stages.h b/src/arch/x86/include/arch/stages.h index 91d0db6..4eae698 100644 --- a/src/arch/x86/include/arch/stages.h +++ b/src/arch/x86/include/arch/stages.h @@ -23,7 +23,6 @@ #include <arch/cpu.h>
void asmlinkage copy_and_run(void); -void jmp_to_elf_entry(void *entry, unsigned long buffer, unsigned long size);
static inline void stage_exit(void *entry) { diff --git a/src/include/payload_loader.h b/src/include/payload_loader.h index 73b28bf..4948afb 100644 --- a/src/include/payload_loader.h +++ b/src/include/payload_loader.h @@ -44,6 +44,9 @@ struct payload *payload_load(void); /* Run the loaded payload. */ void payload_run(const struct payload *payload);
+/* architecture specific function to run payload. */ +void arch_payload_run(const struct payload *payload); + /* Payload loading operations. */ struct payload_loader_ops { const char *name; @@ -57,6 +60,5 @@ struct payload_loader_ops { /* Defined in src/lib/selfboot.c */ struct lb_memory; void *selfload(struct lb_memory *mem, struct payload *payload); -void selfboot(void *entry);
#endif /* PAYLOAD_LOADER_H */ diff --git a/src/lib/loaders/load_and_run_payload.c b/src/lib/loaders/load_and_run_payload.c index f18b57b..3e1eafb 100644 --- a/src/lib/loaders/load_and_run_payload.c +++ b/src/lib/loaders/load_and_run_payload.c @@ -93,5 +93,5 @@ void payload_run(const struct payload *payload) */ checkstack(_estack, 0);
- selfboot(payload->entry); + arch_payload_run(payload); } diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c index ba07480..6dc3a75 100644 --- a/src/lib/selfboot.c +++ b/src/lib/selfboot.c @@ -19,7 +19,6 @@ */
#include <arch/byteorder.h> -#include <arch/stages.h> #include <console/console.h> #include <cpu/cpu.h> #include <boot/coreboot_tables.h> @@ -526,9 +525,3 @@ void *selfload(struct lb_memory *mem, struct payload *payload) out: return NULL; } - -void selfboot(void *entry) -{ - /* Jump to kernel */ - jmp_to_elf_entry(entry, bounce_buffer, bounce_size); -}