From a025a2e6539f255729fcc9c2d900017c163d7ff6 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 2 Apr 2010 13:29:12 +0000 Subject: [PATCH] Since the original boot code had been previously refactored to make use of saved-program-state, we can take the existing code and with only slight modification use it as a C implementation of the go word. Signed-off-by: Mark Cave-Ayland git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@727 f158a5a8-5612-0410-a976-696ce0be7e32 --- arch/sparc32/boot.c | 24 ++++++++++++++++-------- arch/sparc32/boot.h | 3 ++- arch/sparc64/boot.c | 18 +++++++++++++----- arch/sparc64/boot.h | 3 ++- arch/x86/boot.c | 16 ++++++++++++---- arch/x86/boot.h | 3 ++- 6 files changed, 47 insertions(+), 20 deletions(-) diff --git a/arch/sparc32/boot.c b/arch/sparc32/boot.c index eee7533..8296759 100644 --- a/arch/sparc32/boot.c +++ b/arch/sparc32/boot.c @@ -22,13 +22,14 @@ uint32_t kernel_size; uint32_t qemu_cmdline; uint32_t cmdline_size; char boot_device; +static const void *romvec; static int (*entry)(const void *romvec_ptr, int p2, int p3, int p4, int p5); -static int try_path(const char *path, char *param, const void *romvec) + +static int try_path(const char *path, char *param) { void *boot_notes = NULL; - ucell valid, address, type, size; - int image_retval = 0; + ucell valid; push_str(path); fword("pathres-resolve-aliases"); @@ -78,6 +79,16 @@ static int try_path(const char *path, char *param, const void *romvec) start_image: + go(); + return -1; +} + + +void go(void) +{ + ucell address, type, size; + int image_retval = 0; + /* Get the entry point and the type (see forth/debugging/client.fs) */ feval("saved-program-state >sps.entry @"); address = POP(); @@ -122,8 +133,6 @@ start_image: } printk("Image returned with return value %#x\n", image_retval); - - return -1; } @@ -132,7 +141,6 @@ void boot(void) char *path = pop_fstr_copy(), *param, altpath[256]; const char *oldpath = path; int unit = 0; - const void *romvec; int result; if(!path) { @@ -209,7 +217,7 @@ void boot(void) else printk("without parameters.\n"); - result = try_path(path, param, romvec); + result = try_path(path, param); if (!result) { push_str(path); PUSH(':'); @@ -218,7 +226,7 @@ void boot(void) POP(); POP(); - try_path(altpath, param, romvec); + try_path(altpath, param); } printk("Unsupported image format\n"); diff --git a/arch/sparc32/boot.h b/arch/sparc32/boot.h index fd8bf75..19612c5 100644 --- a/arch/sparc32/boot.h +++ b/arch/sparc32/boot.h @@ -19,7 +19,8 @@ void *init_openprom(void); // boot.c extern struct sys_info sys_info; extern const char *bootpath; -void boot(void); +extern void boot(void); +extern void go(void); // sys_info.c extern unsigned int qemu_mem_size; diff --git a/arch/sparc64/boot.c b/arch/sparc64/boot.c index d4817a2..84a072d 100644 --- a/arch/sparc64/boot.c +++ b/arch/sparc64/boot.c @@ -26,8 +26,7 @@ extern int sparc64_of_client_interface( int *params ); static int try_path(const char *path, char *param) { void *boot_notes = NULL; - ucell valid, address, type, size; - int image_retval = 0; + ucell valid; #ifdef CONFIG_LOADER_ELF /* ELF Boot loader */ @@ -72,6 +71,16 @@ static int try_path(const char *path, char *param) start_image: + go(); + return -1; +} + + +void go(void) +{ + ucell address, type, size; + int image_retval = 0; + /* Get the entry point and the type (see forth/debugging/client.fs) */ feval("saved-program-state >sps.entry @"); address = POP(); @@ -85,7 +94,7 @@ start_image: switch (type) { case 0x0: /* Start ELF boot image */ - image_retval = start_elf(address, (uint64_t)boot_notes); + image_retval = start_elf(address, (uint64_t)NULL); break; case 0x5: @@ -112,10 +121,9 @@ start_image: } printk("Image returned with return value %#x\n", image_retval); - - return -1; } + void boot(void) { char *path=pop_fstr_copy(), *param; diff --git a/arch/sparc64/boot.h b/arch/sparc64/boot.h index 0495141..301331b 100644 --- a/arch/sparc64/boot.h +++ b/arch/sparc64/boot.h @@ -21,7 +21,8 @@ extern uint64_t kernel_size; extern uint64_t qemu_cmdline; extern uint64_t cmdline_size; extern char boot_device; -void boot(void); +extern void boot(void); +extern void go(void); // sys_info.c extern uint64_t qemu_mem_size; diff --git a/arch/x86/boot.c b/arch/x86/boot.c index ecb0d5d..8baea58 100644 --- a/arch/x86/boot.c +++ b/arch/x86/boot.c @@ -23,8 +23,7 @@ struct sys_info sys_info; static int try_path(const char *path, char *param) { void *boot_notes = NULL; - ucell valid, address, type, size; - int image_retval = 0;; + ucell valid; #ifdef CONFIG_LOADER_ELF /* ELF Boot loader */ @@ -69,6 +68,16 @@ static int try_path(const char *path, char *param) start_image: + go(); + return -1; +} + + +void go(void) +{ + ucell address, type, size; + int image_retval = 0; + /* Get the entry point and the type (see forth/debugging/client.fs) */ feval("saved-program-state >sps.entry @"); address = POP(); @@ -109,10 +118,9 @@ start_image: } printk("Image returned with return value %#x\n", image_retval); - - return -1; } + void boot(void) { char *path=pop_fstr_copy(), *param; diff --git a/arch/x86/boot.h b/arch/x86/boot.h index 0488ce4..5e8f2c4 100644 --- a/arch/x86/boot.h +++ b/arch/x86/boot.h @@ -15,4 +15,5 @@ unsigned int start_elf(unsigned long entry_point, unsigned long param); /* boot.c */ extern struct sys_info sys_info; -void boot(void); +extern void boot(void); +extern void go(void);