From f78fec5713a53ff7c3c1d2856bb1d96d9f21a7eb Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Sun, 28 Mar 2010 20:18:30 +0000 Subject: [PATCH] Introduce a set of CONFIG_LOADER_* configuration options to allow each architecture to specify the loaders that are to be used. Signed-off-by: Mark Cave-Ayland git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@717 f158a5a8-5612-0410-a976-696ce0be7e32 --- arch/sparc32/boot.c | 41 ++++++++++++++++++++++++ arch/sparc64/boot.c | 24 ++++++++++++++ arch/x86/boot.c | 38 ++++++++++++++++++++++ config/examples/amd64_config.xml | 5 +++ config/examples/cross-ppc_config.xml | 5 +++ config/examples/cross-sparc32_config.xml | 5 +++ config/examples/cross-sparc64_config.xml | 5 +++ config/examples/cross-x86_config.xml | 5 +++ config/examples/ppc_config.xml | 6 +++- config/examples/sparc32_config.xml | 5 +++ config/examples/sparc64_config.xml | 5 +++ config/examples/x86_config.xml | 5 +++ libopenbios/build.xml | 18 +++-------- packages/build.xml | 5 ++- packages/elf-loader.c | 8 ++++- packages/init.c | 12 ++++--- 16 files changed, 169 insertions(+), 23 deletions(-) diff --git a/arch/sparc32/boot.c b/arch/sparc32/boot.c index 38d4d6c..eee7533 100644 --- a/arch/sparc32/boot.c +++ b/arch/sparc32/boot.c @@ -11,6 +11,8 @@ #include "libopenbios/sys_info.h" #include "libopenbios/elf_load.h" #include "libopenbios/aout_load.h" +#include "libopenbios/fcode_load.h" +#include "libopenbios/forth_load.h" #include "openprom.h" #include "boot.h" @@ -33,22 +35,44 @@ static int try_path(const char *path, char *param, const void *romvec) bootpath = pop_fstr_copy(); printk("Trying %s (%s)\n", path, bootpath); +#ifdef CONFIG_LOADER_ELF /* ELF Boot loader */ elf_load(&sys_info, path, param, &boot_notes); feval("state-valid @"); valid = POP(); if (valid) goto start_image; +#endif /* Linux loader (not using Forth) */ linux_load(&sys_info, path, param); +#ifdef CONFIG_LOADER_AOUT /* a.out loader */ aout_load(&sys_info, path); feval("state-valid @"); valid = POP(); if (valid) goto start_image; +#endif + +#ifdef CONFIG_LOADER_FCODE + /* Fcode loader */ + fcode_load(path); + feval("state-valid @"); + valid = POP(); + if (valid) + goto start_image; +#endif + +#ifdef CONFIG_LOADER_FORTH + /* Forth loader */ + forth_load(path); + feval("state-valid @"); + valid = POP(); + if (valid) + goto start_image; +#endif return 0; @@ -78,6 +102,23 @@ start_image: image_retval = entry(romvec, 0, 0, 0, 0); break; + + case 0x10: + /* Start Fcode image */ + printk("Evaluating FCode...\n"); + PUSH(address); + PUSH(1); + fword("byte-load"); + image_retval = 0; + break; + + case 0x11: + /* Start Forth image */ + PUSH(address); + PUSH(size); + fword("eval2"); + image_retval = 0; + break; } printk("Image returned with return value %#x\n", image_retval); diff --git a/arch/sparc64/boot.c b/arch/sparc64/boot.c index fa40e2b..d4817a2 100644 --- a/arch/sparc64/boot.c +++ b/arch/sparc64/boot.c @@ -11,6 +11,7 @@ #include "libopenbios/elf_load.h" #include "libopenbios/aout_load.h" #include "libopenbios/fcode_load.h" +#include "libopenbios/forth_load.h" #include "boot.h" struct sys_info sys_info; @@ -28,29 +29,44 @@ static int try_path(const char *path, char *param) ucell valid, address, type, size; int image_retval = 0; +#ifdef CONFIG_LOADER_ELF /* ELF Boot loader */ elf_load(&sys_info, path, param, &boot_notes); feval("state-valid @"); valid = POP(); if (valid) goto start_image; +#endif /* Linux loader (not using Forth) */ linux_load(&sys_info, path, param); +#ifdef CONFIG_LOADER_AOUT /* a.out loader */ aout_load(&sys_info, path); feval("state-valid @"); valid = POP(); if (valid) goto start_image; +#endif +#ifdef CONFIG_LOADER_FCODE /* Fcode loader */ fcode_load(path); feval("state-valid @"); valid = POP(); if (valid) goto start_image; +#endif + +#ifdef CONFIG_LOADER_FORTH + /* Forth loader */ + forth_load(path); + feval("state-valid @"); + valid = POP(); + if (valid) + goto start_image; +#endif return 0; @@ -85,6 +101,14 @@ start_image: fword("byte-load"); image_retval = 0; break; + + case 0x11: + /* Start Forth image */ + PUSH(address); + PUSH(size); + fword("eval2"); + image_retval = 0; + break; } printk("Image returned with return value %#x\n", image_retval); diff --git a/arch/x86/boot.c b/arch/x86/boot.c index 0a45c5b..ecb0d5d 100644 --- a/arch/x86/boot.c +++ b/arch/x86/boot.c @@ -13,6 +13,8 @@ #include "libc/diskio.h" #include "libopenbios/sys_info.h" #include "libopenbios/elf_load.h" +#include "libopenbios/aout_load.h" +#include "libopenbios/fcode_load.h" #include "libopenbios/forth_load.h" #include "boot.h" @@ -24,22 +26,44 @@ static int try_path(const char *path, char *param) ucell valid, address, type, size; int image_retval = 0;; +#ifdef CONFIG_LOADER_ELF /* ELF Boot loader */ elf_load(&sys_info, path, param, &boot_notes); feval("state-valid @"); valid = POP(); if (valid) goto start_image; +#endif /* Linux loader (not using Forth) */ linux_load(&sys_info, path, param); +#ifdef CONFIG_LOADER_AOUT + /* a.out loader */ + aout_load(&sys_info, path); + feval("state-valid @"); + valid = POP(); + if (valid) + goto start_image; +#endif + +#ifdef CONFIG_LOADER_FCODE + /* Fcode loader */ + fcode_load(path); + feval("state-valid @"); + valid = POP(); + if (valid) + goto start_image; +#endif + +#ifdef CONFIG_LOADER_FORTH /* Forth loader */ forth_load(path); feval("state-valid @"); valid = POP(); if (valid) goto start_image; +#endif return 0; @@ -61,6 +85,20 @@ start_image: image_retval = start_elf(address, (uint32_t)NULL); break; + case 0x5: + /* Start a.out image */ + image_retval = start_elf(address, (uint32_t)NULL); + break; + + case 0x10: + /* Start Fcode image */ + printk("Evaluating FCode...\n"); + PUSH(address); + PUSH(1); + fword("byte-load"); + image_retval = 0; + break; + case 0x11: /* Start Forth image */ PUSH(address); diff --git a/config/examples/amd64_config.xml b/config/examples/amd64_config.xml index c5f3c86..4130915 100644 --- a/config/examples/amd64_config.xml +++ b/config/examples/amd64_config.xml @@ -35,6 +35,11 @@