Author: mcayland Date: Sun Mar 28 22:18:30 2010 New Revision: 717 URL: http://tracker.coreboot.org/trac/openbios/changeset/717
Log: 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 mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/sparc32/boot.c trunk/openbios-devel/arch/sparc64/boot.c trunk/openbios-devel/arch/x86/boot.c trunk/openbios-devel/config/examples/amd64_config.xml trunk/openbios-devel/config/examples/cross-ppc_config.xml trunk/openbios-devel/config/examples/cross-sparc32_config.xml trunk/openbios-devel/config/examples/cross-sparc64_config.xml trunk/openbios-devel/config/examples/cross-x86_config.xml trunk/openbios-devel/config/examples/ppc_config.xml trunk/openbios-devel/config/examples/sparc32_config.xml trunk/openbios-devel/config/examples/sparc64_config.xml trunk/openbios-devel/config/examples/x86_config.xml trunk/openbios-devel/libopenbios/build.xml trunk/openbios-devel/packages/build.xml trunk/openbios-devel/packages/elf-loader.c trunk/openbios-devel/packages/init.c
Modified: trunk/openbios-devel/arch/sparc32/boot.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/boot.c Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/arch/sparc32/boot.c Sun Mar 28 22:18:30 2010 (r717) @@ -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 @@ 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 @@ 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);
Modified: trunk/openbios-devel/arch/sparc64/boot.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/boot.c Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/arch/sparc64/boot.c Sun Mar 28 22:18:30 2010 (r717) @@ -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 @@ 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 @@ 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);
Modified: trunk/openbios-devel/arch/x86/boot.c ============================================================================== --- trunk/openbios-devel/arch/x86/boot.c Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/arch/x86/boot.c Sun Mar 28 22:18:30 2010 (r717) @@ -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 @@ 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 @@ 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);
Modified: trunk/openbios-devel/config/examples/amd64_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/amd64_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/amd64_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -35,6 +35,11 @@ <option name="CONFIG_DEBLOCKER" type="boolean" value="true"/> <option name="CONFIG_FONT_8X8" type="boolean" value="true"/> <option name="CONFIG_FONT_8X16" type="boolean" value="false"/> + <option name="CONFIG_LOADER_AOUT" type="boolean" value="false"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="false"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="false"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/config/examples/cross-ppc_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/cross-ppc_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/cross-ppc_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -40,6 +40,11 @@ <option name="CONFIG_VGA_WIDTH" type="integer" value="800"/> <option name="CONFIG_VGA_HEIGHT" type="integer" value="600"/> <option name="CONFIG_VGA_DEPTH" type="integer" value="8"/> + <option name="CONFIG_LOADER_AOUT" type="boolean" value="false"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="false"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="true"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/config/examples/cross-sparc32_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/cross-sparc32_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/cross-sparc32_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -41,6 +41,11 @@ <option name="CONFIG_DEBLOCKER" type="boolean" value="true"/> <option name="CONFIG_FONT_8X8" type="boolean" value="true"/> <option name="CONFIG_FONT_8X16" type="boolean" value="false"/> + <option name="CONFIG_LOADER_AOUT" type="boolean" value="true"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="false"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="false"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/config/examples/cross-sparc64_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/cross-sparc64_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/cross-sparc64_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -41,6 +41,11 @@ <option name="CONFIG_FONT_8X16" type="boolean" value="false"/> <option name="CONFIG_OFMEM" type="boolean" value="true"/> <option name="CONFIG_OFMEM_MALLOC_ALIGN" type="integer" value="8"/> + <option name="CONFIG_LOADER_AOUT" type="boolean" value="true"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="false"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="false"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/config/examples/cross-x86_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/cross-x86_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/cross-x86_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -36,6 +36,11 @@ <option name="CONFIG_DEBLOCKER" type="boolean" value="true"/> <option name="CONFIG_FONT_8X8" type="boolean" value="true"/> <option name="CONFIG_FONT_8X16" type="boolean" value="false"/> + <option name="CONFIG_LOADER_AOUT" type="boolean" value="false"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="true"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="false"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/config/examples/ppc_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/ppc_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/ppc_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -40,7 +40,11 @@ <option name="CONFIG_VGA_WIDTH" type="integer" value="800"/> <option name="CONFIG_VGA_HEIGHT" type="integer" value="600"/> <option name="CONFIG_VGA_DEPTH" type="integer" value="8"/> - + <option name="CONFIG_LOADER_AOUT" type="boolean" value="false"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="false"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="true"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/config/examples/sparc32_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/sparc32_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/sparc32_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -41,6 +41,11 @@ <option name="CONFIG_DEBLOCKER" type="boolean" value="true"/> <option name="CONFIG_FONT_8X8" type="boolean" value="true"/> <option name="CONFIG_FONT_8X16" type="boolean" value="false"/> + <option name="CONFIG_LOADER_AOUT" type="boolean" value="true"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="false"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="false"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/config/examples/sparc64_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/sparc64_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/sparc64_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -41,6 +41,11 @@ <option name="CONFIG_FONT_8X16" type="boolean" value="false"/> <option name="CONFIG_OFMEM" type="boolean" value="true"/> <option name="CONFIG_OFMEM_MALLOC_ALIGN" type="integer" value="8"/> + <option name="CONFIG_LOADER_AOUT" type="boolean" value="true"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="false"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="false"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/config/examples/x86_config.xml ============================================================================== --- trunk/openbios-devel/config/examples/x86_config.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/config/examples/x86_config.xml Sun Mar 28 22:18:30 2010 (r717) @@ -36,6 +36,11 @@ <option name="CONFIG_DEBLOCKER" type="boolean" value="true"/> <option name="CONFIG_FONT_8X8" type="boolean" value="true"/> <option name="CONFIG_FONT_8X16" type="boolean" value="false"/> + <option name="CONFIG_LOADER_AOUT" type="boolean" value="false"/> + <option name="CONFIG_LOADER_ELF" type="boolean" value="true"/> + <option name="CONFIG_LOADER_FCODE" type="boolean" value="false"/> + <option name="CONFIG_LOADER_FORTH" type="boolean" value="true"/> + <option name="CONFIG_LOADER_XCOFF" type="boolean" value="false"/>
<!-- Filesystem Configuration --> <option name="CONFIG_DISK_LABEL" type="boolean" value="true"/>
Modified: trunk/openbios-devel/libopenbios/build.xml ============================================================================== --- trunk/openbios-devel/libopenbios/build.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/libopenbios/build.xml Sun Mar 28 22:18:30 2010 (r717) @@ -1,24 +1,16 @@ <build>
<library name="openbios" type="static" target="target"> - <object source="aout_load.c" condition="SPARC32"/> - <object source="aout_load.c" condition="SPARC64"/> + <object source="aout_load.c" condition="LOADER_AOUT"/> <object source="bindings.c"/> <object source="client.c"/> <object source="console_common.c"/> - <object source="elf_info.c" condition="X86"/> - <object source="elf_info.c" condition="AMD64"/> - <object source="elf_info.c" condition="SPARC32"/> - <object source="elf_info.c" condition="SPARC64"/> - <object source="elf_info.c" condition="PPC"/> - <object source="elf_load.c" condition="X86"/> - <object source="elf_load.c" condition="SPARC32"/> - <object source="elf_load.c" condition="SPARC64"/> - <object source="elf_load.c" condition="AMD64"/> + <object source="elf_info.c" /> + <object source="elf_load.c" condition="LOADER_ELF"/> <object source="font_8x8.c" condition="FONT_8X8"/> <object source="font_8x16.c" condition="FONT_8X16"/> - <object source="fcode_load.c" condition="SPARC64"/> - <object source="forth_load.c" condition="X86"/> + <object source="fcode_load.c" condition="LOADER_FCODE"/> + <object source="forth_load.c" condition="LOADER_FORTH"/> <object source="ipchecksum.c"/> <object source="linuxbios_info.c" condition="LINUXBIOS"/> <object source="ofmem_common.c" condition="OFMEM"/>
Modified: trunk/openbios-devel/packages/build.xml ============================================================================== --- trunk/openbios-devel/packages/build.xml Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/packages/build.xml Sun Mar 28 22:18:30 2010 (r717) @@ -5,8 +5,7 @@ <object source="cmdline.c" condition="CMDLINE"/> <object source="deblocker.c" condition="DEBLOCKER"/> <object source="disk-label.c" condition="DISK_LABEL"/> - <object source="elf-loader.c" condition="PPC"/> - <object source="elf-loader.c" condition="SPARC64"/> + <object source="elf-loader.c" condition="LOADER_ELF"/> <object source="init.c"/> <object source="mac-parts.c" condition="MAC_PARTS"/> <object source="misc-files.c" condition="FS"/> @@ -14,7 +13,7 @@ <object source="pc-parts.c" condition="PC_PARTS"/> <object source="sun-parts.c" condition="SUN_PARTS"/> <object source="video.c"/> - <object source="xcoff-loader.c" condition="PPC"/> + <object source="xcoff-loader.c" condition="LOADER_XCOFF"/> </library>
<dictionary name="openbios" target="forth">
Modified: trunk/openbios-devel/packages/elf-loader.c ============================================================================== --- trunk/openbios-devel/packages/elf-loader.c Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/packages/elf-loader.c Sun Mar 28 22:18:30 2010 (r717) @@ -49,6 +49,7 @@ Elf_phdr *phdr; size_t size; char *addr; + cell tmp;
feval("0 state-valid !");
@@ -67,11 +68,16 @@ size = MIN(phdr[i].p_filesz, phdr[i].p_memsz); if (!size) continue; +#if 0 if( ofmem_claim( phdr[i].p_vaddr, phdr[i].p_memsz, 0 ) == -1 ) { printk("Claim failed!\n"); return; } - addr = (char*)phdr[i].p_vaddr; +#endif + /* Workaround for archs where sizeof(int) != pointer size */ + tmp = phdr[i].p_vaddr; + addr = (char *)tmp; + memcpy(addr, base + phdr[i].p_offset, size); #ifdef CONFIG_PPC flush_icache_range( addr, addr + size );
Modified: trunk/openbios-devel/packages/init.c ============================================================================== --- trunk/openbios-devel/packages/init.c Sat Mar 27 14:20:54 2010 (r716) +++ trunk/openbios-devel/packages/init.c Sun Mar 28 22:18:30 2010 (r717) @@ -42,12 +42,14 @@ #ifdef CONFIG_SUN_PARTS sunparts_init(); #endif -#ifdef CONFIG_PPC - elf_loader_init(); +#ifdef CONFIG_LOADER_XCOFF xcoff_loader_init(); - bootinfo_loader_init(); #endif -#ifdef CONFIG_SPARC64 +#ifdef CONFIG_LOADER_ELF elf_loader_init(); #endif +#ifdef CONFIG_PPC + bootinfo_loader_init(); +#endif + }