Author: mcayland Date: Sun Aug 1 17:13:48 2010 New Revision: 828 URL: http://tracker.coreboot.org/trac/openbios/changeset/828
Log: Rework the OpenBIOS internals so that boot, load and init-program now all use the unified libopenbios loader code with improved IEEE-1275 spec compliance.
This patch implements the following:
1) Fix bootpath/bootargs handling so that default values are read from NVRAM, and allow multiple space-separated values to be specified. 2) With correct bootargs handling in place, move the ELF loader over to the new libopenbios unified loaders. 3) Remove all the loader code from all architecture directories sine we don't need it anymore. 4) Simplify the boot word so it invokes platform-specific code where required, then calls load and go as per the specification.
Tested on all my available images for SPARC32, SPARC64 and PPC, and compile-tested on x86.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c trunk/openbios-devel/arch/ppc/qemu/main.c trunk/openbios-devel/arch/sparc32/boot.c trunk/openbios-devel/arch/sparc32/boot.h trunk/openbios-devel/arch/sparc32/openbios.c trunk/openbios-devel/arch/sparc64/boot.c trunk/openbios-devel/arch/sparc64/linux_load.c trunk/openbios-devel/arch/sparc64/openbios.c trunk/openbios-devel/arch/x86/boot.c trunk/openbios-devel/forth/admin/userboot.fs trunk/openbios-devel/forth/debugging/client.fs trunk/openbios-devel/include/libopenbios/elf_load.h trunk/openbios-devel/include/libopenbios/sys_info.h trunk/openbios-devel/libopenbios/elf_load.c trunk/openbios-devel/libopenbios/load.c
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/init.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/ppc/qemu/init.c Sun Aug 1 17:13:48 2010 (r828) @@ -527,7 +527,7 @@ uint64_t ram_size; const struct cpudef *cpu; char buf[64], qemu_uuid[16]; - const char *stdin_path, *stdout_path; + const char *stdin_path, *stdout_path, *boot_path; uint32_t temp = 0;
ofmem_t *ofmem = ofmem_arch_get_private(); @@ -721,14 +721,17 @@ uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE); switch (boot_device) { case 'c': - push_str("hd:"); + boot_path = "hd"; break; default: case 'd': - push_str("cd:"); + boot_path = "cd"; break; }
+ /* Setup default boot devices */ + snprintf(buf, sizeof(buf), "%s:,\\:tbxi %s:,\ppc\bootinfo.txt", boot_path, boot_path); + push_str(buf); fword("encode-string"); push_str("boot-device"); fword("property"); @@ -737,16 +740,6 @@ push_str("/chosen"); fword("find-device");
- /* bootpath/bootargs should be set to NVRAM default */ - fword("boot-device"); - fword("encode-string"); - push_str("bootpath"); - fword("property"); - fword("boot-args"); - fword("encode-string"); - push_str("bootargs"); - fword("property"); - push_str(stdin_path); fword("open-dev"); fword("encode-int");
Modified: trunk/openbios-devel/arch/ppc/qemu/main.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/main.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/ppc/qemu/main.c Sun Aug 1 17:13:48 2010 (r828) @@ -39,16 +39,9 @@ #define ELF_DPRINTF(fmt, args...) SUBSYS_DPRINTF("ELF", fmt, ##args) #define NEWWORLD_DPRINTF(fmt, args...) SUBSYS_DPRINTF("NEWWORLD", fmt, ##args)
-static void -load(const char *path, const char *param) -{ - char buffer[1024]; - if (param) - sprintf(buffer, "load %s %s", path, param); - else - sprintf(buffer, "load %s", path); - feval(buffer); -} +struct sys_info sys_info; +void *elf_boot_notes = NULL; +
static char * get_device( const char *path ) @@ -115,6 +108,7 @@ return filename; }
+ static void encode_bootpath( const char *spec, const char *args ) { @@ -123,6 +117,9 @@ char *filename, *directory; int partition;
+ if (spec) + return; + filename = get_filename(spec, &directory); partition = get_partition(spec); if (partition == -1) @@ -138,28 +135,6 @@ set_property( chosen_ph, "bootargs", args, strlen(args)+1 ); }
-/************************************************************************/ -/* qemu booting */ -/************************************************************************/ -static void -try_path(const char *device, const char* filename, const char *param) -{ - char path[1024]; - - if (filename) - snprintf(path, sizeof(path), "%s%s", device, filename); - else - snprintf(path, sizeof(path), "%s", device); - - ELF_DPRINTF("Trying %s %s\n", path, param); - - load(path, param); - update_nvram(); - ELF_DPRINTF("Transfering control to %s %s\n", - path, param); - feval("go"); -} - #define OLDWORLD_BOOTCODE_BASEADDR (0x3f4000)
static void @@ -203,46 +178,6 @@ return; }
-static void -newworld_boot( void ) -{ - static const char * const chrp_path[] = { "\\:tbxi", - "ppc\bootinfo.txt", - NULL - }; - char *path = pop_fstr_copy(), *param; - int i; - - param = strchr(path, ' '); - if (param) { - *param = 0; - param++; - } - - if (!path) { - NEWWORLD_DPRINTF("Entering boot, no path\n"); - - /* No path specified, so grab defaults from /chosen */ - push_str("bootpath"); - push_str("/chosen"); - fword("(find-dev)"); - POP(); - fword("get-package-property"); - POP(); - path = pop_fstr_copy(); - - for (i = 0; chrp_path[i]; i++) - try_path(path, chrp_path[i], param); - - } else { - NEWWORLD_DPRINTF("Entering boot, path %s\n", path); - try_path(path, NULL, param); - for (i = 0; chrp_path[i]; i++) - try_path(path, chrp_path[i], param); - } - printk("*** Boot failure! No secondary bootloader specified ***\n"); -} - static void check_preloaded_kernel(void) { unsigned long kernel_image, kernel_size; @@ -281,8 +216,10 @@ if (boot_device == 'm') { check_preloaded_kernel(); } + if (boot_device == 'c') { oldworld_boot(); } - newworld_boot(); + + update_nvram(); }
Modified: trunk/openbios-devel/arch/sparc32/boot.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -9,10 +9,6 @@ #include "libc/diskio.h" #include "libc/vsprintf.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 "openprom.h" #include "boot.h" #include "context.h" @@ -22,76 +18,16 @@ uint32_t qemu_cmdline; uint32_t cmdline_size; char boot_device; -static const void *romvec; - -static int try_path(const char *path, char *param) -{ - void *boot_notes = NULL; - ucell valid; - ihandle_t dev; - - push_str(path); - fword("pathres-resolve-aliases"); - bootpath = pop_fstr_copy(); - printk("Trying %s (%s)\n", path, bootpath); - - /* Open device used by this path */ - dev = open_dev(path); - -#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, dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - -#ifdef CONFIG_LOADER_FCODE - /* Fcode loader */ - fcode_load(dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - -#ifdef CONFIG_LOADER_FORTH - /* Forth loader */ - forth_load(dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - - close_dev(dev); - - return 0; - - -start_image: - go(); - return -1; -} - +void *elf_boot_notes = NULL; +const void *romvec;
void go(void) { ucell address, type, size; - int image_retval = 0; + int image_retval = 0, proplen, unit, part; + phandle_t chosen; + char *prop, *id, bootid; + static char bootpathbuf[128], bootargsbuf[128], buf[128];
/* Get the entry point and the type (see forth/debugging/client.fs) */ feval("saved-program-state >sps.entry @"); @@ -101,6 +37,80 @@ feval("saved-program-state >sps.file-size @"); size = POP();
+ /* SPARC32 is slightly unusual in that before invoking any loaders, a romvec array + needs to be set up to pass certain parameters using a C struct. Hence this section + extracts the relevant boot information and places it in obp_arg. */ + + /* Get the name of the selected boot device, along with the device and unit number */ + chosen = find_dev("/chosen"); + prop = get_property(chosen, "bootpath", &proplen); + strncpy(bootpathbuf, prop, proplen); + prop = get_property(chosen, "bootargs", &proplen); + strncpy(bootargsbuf, prop, proplen); + + /* Set bootpath pointer used in romvec table to the bootpath */ + bootpath = bootpathbuf; + + if (!strcmp(bootpathbuf, "cdrom") || !strcmp(bootpathbuf, "disk")) { + + /* Controller currently always 0 */ + obp_arg.boot_dev_ctrl = 0; + + /* Grab the device and unit number string (in form unit,partition) */ + push_str(bootpathbuf); + feval("pathres-resolve-aliases ascii @ right-split 2drop"); + id = pop_fstr_copy(); + + /* A bit hacky, but we have no atoi() function */ + unit = id[0] - '0'; + part = id[2] - '0'; + + obp_arg.boot_dev_unit = unit; + obp_arg.dev_partition = part; + + /* Generate the "oldpath" + FIXME: hardcoding this looks almost definitely wrong. + With sd(0,2,0):b we get to see the solaris kernel though */ + if (!strcmp(bootpathbuf, "disk")) + bootid = 'd'; + else + bootid = 'b'; + + snprintf(buf, sizeof(buf), "sd(0,%d,%d):%c", unit, part, bootid); + + obp_arg.boot_dev[0] = buf[0]; + obp_arg.boot_dev[1] = buf[1]; + obp_arg.argv[0] = buf; + obp_arg.argv[1] = bootargsbuf; + + } else if (!strcmp(bootpathbuf, "floppy")) { + + obp_arg.boot_dev_ctrl = 0; + obp_arg.boot_dev_unit = 0; + obp_arg.dev_partition = 0; + + strcpy(buf, "fd()"); + + obp_arg.boot_dev[0] = buf[0]; + obp_arg.boot_dev[1] = buf[1]; + obp_arg.argv[0] = buf; + obp_arg.argv[1] = bootargsbuf; + + } else if (!strcmp(bootpathbuf, "net")) { + + obp_arg.boot_dev_ctrl = 0; + obp_arg.boot_dev_unit = 0; + obp_arg.dev_partition = 0; + + strcpy(buf, "le()"); + + obp_arg.boot_dev[0] = buf[0]; + obp_arg.boot_dev[1] = buf[1]; + obp_arg.argv[0] = buf; + obp_arg.argv[1] = bootargsbuf; + + } + printk("\nJumping to entry point " FMT_ucellx " for type " FMT_ucellx "...\n", address, type);
switch (type) { @@ -149,89 +159,9 @@
void boot(void) { - char *path = pop_fstr_copy(), *param, altpath[256]; - const char *oldpath = path; - int unit = 0; - int result; - - if(!path) { - /* No path specified, so grab defaults from firmware */ - switch (boot_device) { - case 'a': - path = strdup("/obio/SUNW,fdtwo"); - oldpath = "fd()"; - break; - case 'c': - path = strdup("disk"); - oldpath = "sd(0,0,0):d"; - break; - default: - case 'd': - path = strdup("cdrom"); - // FIXME: hardcoding this looks almost definitely wrong. - // With sd(0,2,0):b we get to see the solaris kernel though - //oldpath = "sd(0,2,0):d"; - oldpath = "sd(0,2,0):b"; - unit = 2; - break; - case 'n': - path = strdup("net"); - oldpath = "le()"; - break; - } - } - - obp_arg.boot_dev_ctrl = 0; - obp_arg.boot_dev_unit = unit; - obp_arg.dev_partition = 0; - obp_arg.boot_dev[0] = oldpath[0]; - obp_arg.boot_dev[1] = oldpath[1]; - obp_arg.argv[0] = oldpath; - obp_arg.argv[1] = (void *)(long)qemu_cmdline; - - param = strchr(path, ' '); - if(param) { - *param = '\0'; - param++; - } else if (cmdline_size) { - param = (char *)qemu_cmdline; - } else { - push_str("boot-args"); - push_str("/options"); - fword("(find-dev)"); - POP(); - fword("get-package-property"); - POP(); - param = pop_fstr_copy(); - obp_arg.argv[1] = param; - } - - romvec = init_openprom(); - + /* Boot preloaded kernel */ if (kernel_size) { printk("[sparc] Kernel already loaded\n"); start_elf(kernel_image, (unsigned long)romvec); } - - printk("[sparc] Booting file '%s' ", path); - if (param) - printk("with parameters '%s'\n", param); - else - printk("without parameters.\n"); - - result = try_path(path, param); - if (!result) { - push_str(path); - PUSH(':'); - fword("left-split"); - snprintf(altpath, sizeof(altpath), "%s:d", pop_fstr_copy()); - POP(); - POP(); - - try_path(altpath, param); - } - - printk("Unsupported image format\n"); - - free(path); }
Modified: trunk/openbios-devel/arch/sparc32/boot.h ============================================================================== --- trunk/openbios-devel/arch/sparc32/boot.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/boot.h Sun Aug 1 17:13:48 2010 (r828) @@ -30,6 +30,7 @@
// romvec.c extern struct linux_arguments_v0 obp_arg; +extern const void *romvec;
// openbios.c extern int qemu_machine_type;
Modified: trunk/openbios-devel/arch/sparc32/openbios.c ============================================================================== --- trunk/openbios-devel/arch/sparc32/openbios.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/openbios.c Sun Aug 1 17:13:48 2010 (r828) @@ -133,6 +133,9 @@ static void arch_init( void ) { + static char cmdline[128]; + int size; + openbios_init(); modules_init(); ob_init_mmu(); @@ -151,23 +154,57 @@ #endif device_end();
- /* Set up other properties */ - push_str("/chosen"); - fword("find-device"); + kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE); + if (kernel_size) + kernel_image = fw_cfg_read_i32(FW_CFG_KERNEL_ADDR); + + size = fw_cfg_read_i32(FW_CFG_CMDLINE_SIZE); + if (size) { + fw_cfg_read(FW_CFG_CMDLINE_DATA, cmdline, size); + } + cmdline[size] = '\0'; + qemu_cmdline = (uint32_t)cmdline; + + boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE); + + /* Initialiase openprom romvec */ + romvec = init_openprom(); + + /* Setup nvram variables */ + push_str("/options"); + fword("find-device"); + + switch (boot_device) { + case 'a': + push_str("floppy"); + break; + case 'c': + push_str("disk"); + break; + default: + case 'd': + push_str("cdrom"); + break; + case 'n': + push_str("net"); + break; + }
- /* bootpath/bootargs should be set to NVRAM default */ - fword("boot-device"); fword("encode-string"); - push_str("bootpath"); + push_str("boot-device"); fword("property"); - fword("boot-args"); + + push_str(""); fword("encode-string"); - push_str("bootargs"); + push_str("boot-file"); fword("property");
- boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE); + /* Set up other properties */ + push_str("/chosen"); + fword("find-device");
bind_func("platform-boot", boot ); + bind_func("(go)", go ); }
int openbios(void)
Modified: trunk/openbios-devel/arch/sparc64/boot.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -8,10 +8,6 @@ #include "libc/diskio.h" #include "libc/vsprintf.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"
uint64_t kernel_image; @@ -19,68 +15,10 @@ uint64_t qemu_cmdline; uint64_t cmdline_size; char boot_device; -void *boot_notes = NULL; +void *elf_boot_notes = NULL; extern int sparc64_of_client_interface( int *params );
-static int try_path(const char *path, char *param) -{ - ucell valid; - ihandle_t dev; - - /* Open device used by this path */ - dev = open_dev(path); - -#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, dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - -#ifdef CONFIG_LOADER_FCODE - /* Fcode loader */ - fcode_load(dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - -#ifdef CONFIG_LOADER_FORTH - /* Forth loader */ - forth_load(dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - - close_dev(dev); - - return 0; - - -start_image: - go(); - return -1; -} - - void go(void) { ucell address, type, size; @@ -99,7 +37,7 @@ switch (type) { case 0x0: /* Start ELF boot image */ - image_retval = start_elf(address, (uint64_t)&boot_notes); + image_retval = start_elf(address, (uint64_t)&elf_boot_notes); break;
case 0x1: @@ -136,19 +74,23 @@
void boot(void) { - char *path=pop_fstr_copy(), *param; - char altpath[256]; - int result; + char *path, *param;
+ /* Copy the incoming path */ + fword("2dup"); + path = pop_fstr_copy(); + + /* Boot preloaded kernel */ if (kernel_size) { void (*entry)(unsigned long p1, unsigned long p2, unsigned long p3, - unsigned long p4, unsigned long p5);; + unsigned long p4, unsigned long p5);
printk("[sparc64] Kernel already loaded\n"); entry = (void *) (unsigned long)kernel_image; entry(0, 0, 0, 0, (unsigned long)&sparc64_of_client_interface); }
+ /* Invoke Linux directly -- probably not supported */ if(!path) { /* No path specified, so grab defaults from /chosen */ push_str("bootpath"); @@ -175,20 +117,9 @@ POP(); param = pop_fstr_copy(); } - - printk("[sparc64] Booting file '%s' ", path); - if (param) - printk("with parameters '%s'\n", param); - else - printk("without parameters.\n"); - - result = try_path(path, param); - if (!result) { - snprintf(altpath, sizeof(altpath), "%s:f", path); - try_path(altpath, param); - } - - printk("Unsupported image format\n"); + + /* Invoke platform-specific Linux loader */ + linux_load(&sys_info, path, param);
free(path); }
Modified: trunk/openbios-devel/arch/sparc64/linux_load.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/linux_load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/linux_load.c Sun Aug 1 17:13:48 2010 (r828) @@ -618,6 +618,12 @@ return LOADER_NOT_SUPPORT; }
+ debug("[sparc64] Booting kernel '%s' ", file); + if (cmdline) + debug("with parameters '%s'\n", cmdline); + else + debug("without parameters.\n"); + params = phys_to_virt(LINUX_PARAM_LOC); init_linux_params(params, &hdr); set_memory_size(params, info);
Modified: trunk/openbios-devel/arch/sparc64/openbios.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/openbios.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/openbios.c Sun Aug 1 17:13:48 2010 (r828) @@ -374,7 +374,6 @@ { uint32_t size = 0; const struct cpudef *cpu; - const char *bootpath; char buf[256]; uint32_t temp; uint64_t ram_size; @@ -492,34 +491,15 @@ push_str("boot-device"); fword("property");
- /* Set up other properties */ - push_str("/chosen"); - fword("find-device"); - - if (boot_device == 'c') - bootpath = "disk:a"; - else - bootpath = "cdrom:a"; - push_str(bootpath); - fword("encode-string"); - push_str("bootpath"); - fword("property"); - - /* bootpath/bootargs should be set to NVRAM default */ - fword("boot-device"); - fword("encode-string"); - push_str("bootpath"); - fword("property"); - fword("boot-args"); - fword("encode-string"); - push_str("bootargs"); - fword("property"); - push_str(obio_cmdline); fword("encode-string"); - push_str("bootargs"); + push_str("boot-file"); fword("property");
+ /* Set up other properties */ + push_str("/chosen"); + fword("find-device"); + if (fw_cfg_read_i16(FW_CFG_NOGRAPHIC)) { stdin_path = stdout_path = "ttya"; } else {
Modified: trunk/openbios-devel/arch/x86/boot.c ============================================================================== --- trunk/openbios-devel/arch/x86/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/x86/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -12,71 +12,9 @@ #include "arch/common/nvram.h" #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"
-void *boot_notes = NULL; - -static int try_path(const char *path, char *param) -{ - ucell valid; - ihandle_t dev; - - /* Open device used by this path */ - dev = open_dev(path); - -#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, dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - -#ifdef CONFIG_LOADER_FCODE - /* Fcode loader */ - fcode_load(dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - -#ifdef CONFIG_LOADER_FORTH - /* Forth loader */ - forth_load(dev); - feval("state-valid @"); - valid = POP(); - if (valid) - goto start_image; -#endif - - close_dev(dev); - - return 0; - - -start_image: - go(); - return -1; -} - +void *elf_boot_notes = NULL;
void go(void) { @@ -133,24 +71,6 @@
void boot(void) { - char *path=pop_fstr_copy(), *param; - - if(!path) { - printk("[x86] Booting default not supported.\n"); - return; - } - - param = strchr(path, ' '); - if(param) { - *param = '\0'; - param++; - } - - printk("[x86] Booting file '%s' with parameters '%s'\n",path, param); - - try_path(path, param); - - printk("Unsupported image format\n"); - - free(path); + /* No platform-specific boot code */ + return; }
Modified: trunk/openbios-devel/forth/admin/userboot.fs ============================================================================== --- trunk/openbios-devel/forth/admin/userboot.fs Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/forth/admin/userboot.fs Sun Aug 1 17:13:48 2010 (r828) @@ -1,16 +1,15 @@ \ 7.4.3.5 User commands for booting
-: boot ( "{param-text}<cr>" -- ) - (encode-bootpath) +: boot ( "{param-text}<cr>" -- ) + (encode-bootpath) \ Setup bootpath/bootargs s" platform-boot" $find if - execute - else - 2drop - cr ." Booting " type cr - ." ... not supported on this system." cr + execute \ Execute platform-specific boot code then + $load \ load and go + go ;
+ \ : diagnostic-mode? ( -- diag? ) \ ;
Modified: trunk/openbios-devel/forth/debugging/client.fs ============================================================================== --- trunk/openbios-devel/forth/debugging/client.fs Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/forth/debugging/client.fs Sun Aug 1 17:13:48 2010 (r828) @@ -58,24 +58,55 @@ : (encode-bootpath) ( "{params}<cr>" -- bootpath-str bootpath-len) \ Parse the current input buffer of a load/boot command and set both \ the bootargs and bootpath properties as appropriate. - bl parse dup if - 2dup encode-string - " /chosen" (find-dev) if - " bootpath" rot (property) - then - then - linefeed parse dup if - encode-string - " /chosen" (find-dev) if - " bootargs" rot (property) - then - else + cr + + \ bootpath + bl parse dup 0= if + + \ None specified. As per IEEE-1275 specification, search through each value + \ in boot-device and use the first that returns a valid ihandle on open. + s" boot-device" $find drop execute + bl left-split + begin + dup + while + 2dup s" Trying " type type s" ..." type cr + 2dup open-dev ?dup if + close-dev + 2swap drop 0 \ Fake end of string so we exit loop + else + 2drop + bl left-split + then + repeat 2drop + else + 0 0 2swap \ Fake (empty) parse string + then + + \ Set the bootpath property + 2dup encode-string + " /chosen" (find-dev) if + " bootpath" rot (property) + then + + \ bootargs + linefeed parse dup 0= if + \ None specified, use default from nvram + 2drop s" boot-file" $find drop execute then + + \ Set the bootargs property + encode-string + " /chosen" (find-dev) if + " bootargs" rot (property) + then + + \ Remove the remaining string + 2swap 2drop ;
-: load ( "{params}<cr>" -- ) - (encode-bootpath) +: $load ( devstr len ) open-dev ( ihandle ) dup 0= if drop @@ -89,6 +120,11 @@ init-program ;
+: load ( "{params}<cr>" -- ) + (encode-bootpath) + $load +; + : dir ( "{paths}<cr>" -- ) linefeed parse split-path-device
Modified: trunk/openbios-devel/include/libopenbios/elf_load.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/elf_load.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/include/libopenbios/elf_load.h Sun Aug 1 17:13:48 2010 (r828) @@ -21,7 +21,7 @@ #include "asm/elf.h" #include "libopenbios/sys_info.h"
-extern int elf_load(struct sys_info *info, const char *filename, const char *cmdline, void **boot_notes); +extern int elf_load(struct sys_info *info, ihandle_t dev, const char *cmdline, void **boot_notes); extern void elf_init_program(void); extern int is_elf(Elf_ehdr *ehdr); extern int find_elf(Elf_ehdr *ehdr);
Modified: trunk/openbios-devel/include/libopenbios/sys_info.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/sys_info.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/include/libopenbios/sys_info.h Sun Aug 1 17:13:48 2010 (r828) @@ -22,6 +22,7 @@ unsigned long *dict_end; };
+extern void *elf_boot_notes; extern struct sys_info sys_info;
void collect_elfboot_info(struct sys_info *info);
Modified: trunk/openbios-devel/libopenbios/elf_load.c ============================================================================== --- trunk/openbios-devel/libopenbios/elf_load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/libopenbios/elf_load.c Sun Aug 1 17:13:48 2010 (r828) @@ -368,7 +368,7 @@ }
int -elf_load(struct sys_info *info, const char *filename, const char *cmdline, void **boot_notes) +elf_load(struct sys_info *info, ihandle_t dev, const char *cmdline, void **boot_notes) { Elf_ehdr ehdr; Elf_phdr *phdr = NULL; @@ -382,7 +382,7 @@ /* Mark the saved-program-state as invalid */ feval("0 state-valid !");
- fd = open_io(filename); + fd = open_ih(dev); if (!fd) goto out;
Modified: trunk/openbios-devel/libopenbios/load.c ============================================================================== --- trunk/openbios-devel/libopenbios/load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/libopenbios/load.c Sun Aug 1 17:13:48 2010 (r828) @@ -20,6 +20,10 @@ #include "libopenbios/sys_info.h" #include "libopenbios/load.h"
+#ifdef CONFIG_LOADER_ELF +#include "libopenbios/elf_load.h" +#endif + #ifdef CONFIG_LOADER_AOUT #include "libopenbios/aout_load.h" #endif @@ -38,6 +42,21 @@ void load(ihandle_t dev) { /* Invoke the loaders on the specified device */ + char *param; + +#ifdef CONFIG_LOADER_ELF + + /* Grab the boot arguments */ + push_str("bootargs"); + push_str("/chosen"); + fword("(find-dev)"); + POP(); + fword("get-package-property"); + POP(); + param = pop_fstr_copy(); + + elf_load(&sys_info, dev, param, &elf_boot_notes); +#endif
#ifdef CONFIG_LOADER_AOUT aout_load(&sys_info, dev);
On Sun, Aug 1, 2010 at 3:13 PM, repository service svn@openbios.org wrote:
Author: mcayland Date: Sun Aug 1 17:13:48 2010 New Revision: 828 URL: http://tracker.coreboot.org/trac/openbios/changeset/828
Log: Rework the OpenBIOS internals so that boot, load and init-program now all use the unified libopenbios loader code with improved IEEE-1275 spec compliance.
This patch implements the following:
- Fix bootpath/bootargs handling so that default values are read from NVRAM, and allow multiple space-separated values to be
specified. 2) With correct bootargs handling in place, move the ELF loader over to the new libopenbios unified loaders. 3) Remove all the loader code from all architecture directories sine we don't need it anymore. 4) Simplify the boot word so it invokes platform-specific code where required, then calls load and go as per the specification.
Tested on all my available images for SPARC32, SPARC64 and PPC, and compile-tested on x86.
This actually breaks NetBSD. For example 5.0.1 should work like this (r827): Configuration device id QEMU version 1 machine id 32 UUID: 00000000-0000-0000-0000-000000000000 CPUs: 1 x FMI,MB86904 Welcome to OpenBIOS v1.0 built on Aug 2 2010 20:59 Type 'help' for detailed information [sparc] Booting file 'cdrom' with parameters '' Trying cdrom (/iommu/sbus/espdma/esp/sd@2,0) Not a bootable ELF image Not a Linux kernel image Not a bootable a.out image Trying cdrom:d (/iommu/sbus/espdma/esp/sd@2,0:d) Not a bootable ELF image Not a Linux kernel image Loading a.out image... Loaded 65536 bytes entry point is 0x4000
Jumping to entry point 00004000 for type 00000005... switching to new context:
NetBSD/sparc Secondary Boot, Revision 1.15 (builds@b8.netbsd.org, Thu Jul 30 00:08:01 UTC 2009)
Booting netbsd 1724008+846700+210280=0x2b7208 OBP version 3, revision 2.25 (plugin rev 2) Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. All rights reserved. Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved.
NetBSD 5.0.1 (INSTALL) #0: Thu Jul 30 00:20:16 UTC 2009 builds@b8.netbsd.org:/home/builds/ab/netbsd-5-0-1-RELEASE/sparc/200907292356Z-obj/home/builds/ab/netbsd-5-0-1-RELEASE/src/sys/arch/sparc/compile/INSTALL total memory = 127 MB avail memory = 121 MB bootpath: /iommu0/sbus0/espdma0/esp0/sd@2,0:d mainbus0 (root): SUNW,SPARCstation-5: hostid 80000000 cpu0 at mainbus0: MB86907 @ 170 MHz, L64804 FPU cpu0: 16K instruction (32 b/l), 8K data (16 b/l), 512K external (32 b/l): cache enabled obio0 at mainbus0 clock0 at obio0 slot 0 offset 0x200000: mk48t08 timer0 at obio0 slot 0 offset 0xd00000: delay constant 1, frequency = 2000000 Hz zs0 at obio0 slot 0 offset 0x100000 level 12 softpri 6 zstty0 at zs0 channel 0 (console i/o) zstty1 at zs0 channel 1 zs1 at obio0 slot 0 offset 0x0 level 12 softpri 6 kbd0 at zs1 channel 0: baud rate 76800 ms0 at zs1 channel 1: baud rate 76800 slavioconfig at obio0 slot 0 offset 0x800000 not configured fdc0 at obio0 slot 0 offset 0x400000 level 11: no drives attached auxreg0 at obio0 slot 0 offset 0x900000 power0 at obio0 slot 0 offset 0x910000 level 2 iommu0 at mainbus0 addr 0x10000000: version 0x5/0x0, page-size 4096, range 64MB sbus0 at iommu0: clock = 21.250 MHz tcx0 at sbus0 slot 3 offset 0x800000 level 5 (ipl 9): SUNW,tcx, 1024 x 768, id 0, rev 0, sense 0 tcx0: attached to /dev/fb0 dma0 at sbus0 slot 5 offset 0x8400000: DMA rev 2 esp0 at dma0 slot 5 offset 0x8800000 level 4: ESP200, 40MHz, SCSI ID 7 scsibus0 at esp0: 8 targets, 8 luns per target ledma0 at sbus0 slot 5 offset 0x8400010: DMA rev 2 le0 at ledma0 slot 5 offset 0x8c00000 level 6: address 52:54:00:12:34:56 le0: 8 receive buffers, 2 transmit buffers SUNW,CS4231 at sbus0 slot 4 offset 0xc000000 level 5 (ipl 9) not configured power-management at sbus0 slot 4 offset 0xa000000 not configured scsibus0: waiting 2 seconds for devices to settle... cd0 at scsibus0 target 2 lun 0: <QEMU, QEMU CD-ROM, 0.12> cdrom removable root on md0a dumps on md0b root file system type: ffs WARNING: clock gained 369 days WARNING: CHECK AND RESET THE DATE! Welcome to the NetBSD/sparc microroot setup utility.
We've just completed the first stage of a two-stage procedure to load a fully functional NetBSD installation environment on your machine. In the second stage which is to follow now, a set of additional installation utilities must be load from your NetBSD/sparc installation medium.
This procedure supports one of the following media:
1) cdrom 2) tape 3) floppy
But with r828, I get: Configuration device id QEMU version 1 machine id 32 UUID: 00000000-0000-0000-0000-000000000000 CPUs: 1 x FMI,MB86904 Welcome to OpenBIOS v1.0 built on Aug 2 2010 20:59 Type 'help' for detailed information
Trying cdrom... Not a bootable ELF image Not a bootable a.out image No valid state has been set by load or init-program
0 > boot cdrom:d Not a bootable ELF image Loading a.out image... Loaded 65536 bytes entry point is 0x4000
Jumping to entry point 00004000 for type 00000005... switching to new context:
NetBSD/sparc Secondary Boot, Revision 1.15 (builds@b8.netbsd.org, Thu Jul 30 00:08:01 UTC 2009)
Booting netbsd 1724008+846700+210280=0x2b7208 OBP version 3, revision 2.25 (plugin rev 2) Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. All rights reserved. Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved.
NetBSD 5.0.1 (INSTALL) #0: Thu Jul 30 00:20:16 UTC 2009 builds@b8.netbsd.org:/home/builds/ab/netbsd-5-0-1-RELEASE/sparc/200907292356Z-obj/home/builds/ab/netbsd-5-0-1-RELEASE/src/sys/arch/sparc/compile/INSTALL total memory = 127 MB avail memory = 121 MB bootpath: data fault: pc=0xf01651c8 addr=0x0 sfsr=126<PERR=0,LVL=1,AT=1,FT=1,FAV,OW> panic: kernel fault halted
halt, power off
There are two regressions: cdrom:d is not used and bootpath pointer seems to point to nowhere when NetBSD tries to use it.
I don't see pathres-resolve-aliases being used, maybe that's a part of the problem.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c trunk/openbios-devel/arch/ppc/qemu/main.c trunk/openbios-devel/arch/sparc32/boot.c trunk/openbios-devel/arch/sparc32/boot.h trunk/openbios-devel/arch/sparc32/openbios.c trunk/openbios-devel/arch/sparc64/boot.c trunk/openbios-devel/arch/sparc64/linux_load.c trunk/openbios-devel/arch/sparc64/openbios.c trunk/openbios-devel/arch/x86/boot.c trunk/openbios-devel/forth/admin/userboot.fs trunk/openbios-devel/forth/debugging/client.fs trunk/openbios-devel/include/libopenbios/elf_load.h trunk/openbios-devel/include/libopenbios/sys_info.h trunk/openbios-devel/libopenbios/elf_load.c trunk/openbios-devel/libopenbios/load.c
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c
--- trunk/openbios-devel/arch/ppc/qemu/init.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/ppc/qemu/init.c Sun Aug 1 17:13:48 2010 (r828) @@ -527,7 +527,7 @@ uint64_t ram_size; const struct cpudef *cpu; char buf[64], qemu_uuid[16];
- const char *stdin_path, *stdout_path;
- const char *stdin_path, *stdout_path, *boot_path;
uint32_t temp = 0;
ofmem_t *ofmem = ofmem_arch_get_private(); @@ -721,14 +721,17 @@ uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE); switch (boot_device) { case 'c':
- push_str("hd:");
- boot_path = "hd";
break; default: case 'd':
- push_str("cd:");
- boot_path = "cd";
break; }
- /* Setup default boot devices */
- snprintf(buf, sizeof(buf), "%s:,\\:tbxi %s:,\ppc\bootinfo.txt", boot_path, boot_path);
- push_str(buf);
fword("encode-string"); push_str("boot-device"); fword("property"); @@ -737,16 +740,6 @@ push_str("/chosen"); fword("find-device");
- /* bootpath/bootargs should be set to NVRAM default */
- fword("boot-device");
- fword("encode-string");
- push_str("bootpath");
- fword("property");
- fword("boot-args");
- fword("encode-string");
- push_str("bootargs");
- fword("property");
push_str(stdin_path); fword("open-dev"); fword("encode-int");
Modified: trunk/openbios-devel/arch/ppc/qemu/main.c
--- trunk/openbios-devel/arch/ppc/qemu/main.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/ppc/qemu/main.c Sun Aug 1 17:13:48 2010 (r828) @@ -39,16 +39,9 @@ #define ELF_DPRINTF(fmt, args...) SUBSYS_DPRINTF("ELF", fmt, ##args) #define NEWWORLD_DPRINTF(fmt, args...) SUBSYS_DPRINTF("NEWWORLD", fmt, ##args)
-static void -load(const char *path, const char *param) -{
- char buffer[1024];
- if (param)
- sprintf(buffer, "load %s %s", path, param);
- else
- sprintf(buffer, "load %s", path);
- feval(buffer);
-} +struct sys_info sys_info; +void *elf_boot_notes = NULL;
static char * get_device( const char *path ) @@ -115,6 +108,7 @@ return filename; }
static void encode_bootpath( const char *spec, const char *args ) { @@ -123,6 +117,9 @@ char *filename, *directory; int partition;
- if (spec)
- return;
filename = get_filename(spec, &directory); partition = get_partition(spec); if (partition == -1) @@ -138,28 +135,6 @@ set_property( chosen_ph, "bootargs", args, strlen(args)+1 ); }
-/************************************************************************/ -/* qemu booting */ -/************************************************************************/ -static void -try_path(const char *device, const char* filename, const char *param) -{
- char path[1024];
- if (filename)
- snprintf(path, sizeof(path), "%s%s", device, filename);
- else
- snprintf(path, sizeof(path), "%s", device);
- ELF_DPRINTF("Trying %s %s\n", path, param);
- load(path, param);
- update_nvram();
- ELF_DPRINTF("Transfering control to %s %s\n",
- path, param);
- feval("go");
-}
#define OLDWORLD_BOOTCODE_BASEADDR (0x3f4000)
static void @@ -203,46 +178,6 @@ return; }
-static void -newworld_boot( void ) -{
- static const char * const chrp_path[] = { "\\:tbxi",
- "ppc\bootinfo.txt",
- NULL
- };
- char *path = pop_fstr_copy(), *param;
- int i;
- param = strchr(path, ' ');
- if (param) {
- *param = 0;
- param++;
- }
- if (!path) {
- NEWWORLD_DPRINTF("Entering boot, no path\n");
- /* No path specified, so grab defaults from /chosen */
- push_str("bootpath");
- push_str("/chosen");
- fword("(find-dev)");
- POP();
- fword("get-package-property");
- POP();
- path = pop_fstr_copy();
- for (i = 0; chrp_path[i]; i++)
- try_path(path, chrp_path[i], param);
- } else {
- NEWWORLD_DPRINTF("Entering boot, path %s\n", path);
- try_path(path, NULL, param);
- for (i = 0; chrp_path[i]; i++)
- try_path(path, chrp_path[i], param);
- }
- printk("*** Boot failure! No secondary bootloader specified ***\n");
-}
static void check_preloaded_kernel(void) { unsigned long kernel_image, kernel_size; @@ -281,8 +216,10 @@ if (boot_device == 'm') { check_preloaded_kernel(); }
if (boot_device == 'c') { oldworld_boot(); }
- newworld_boot();
- update_nvram();
}
Modified: trunk/openbios-devel/arch/sparc32/boot.c
--- trunk/openbios-devel/arch/sparc32/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -9,10 +9,6 @@ #include "libc/diskio.h" #include "libc/vsprintf.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 "openprom.h" #include "boot.h" #include "context.h" @@ -22,76 +18,16 @@ uint32_t qemu_cmdline; uint32_t cmdline_size; char boot_device; -static const void *romvec;
-static int try_path(const char *path, char *param) -{
- void *boot_notes = NULL;
- ucell valid;
- ihandle_t dev;
- push_str(path);
- fword("pathres-resolve-aliases");
- bootpath = pop_fstr_copy();
- printk("Trying %s (%s)\n", path, bootpath);
- /* Open device used by this path */
- dev = open_dev(path);
-#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, dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FCODE
- /* Fcode loader */
- fcode_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FORTH
- /* Forth loader */
- forth_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
- close_dev(dev);
- return 0;
-start_image:
- go();
- return -1;
-}
+void *elf_boot_notes = NULL; +const void *romvec;
void go(void) { ucell address, type, size;
- int image_retval = 0;
- int image_retval = 0, proplen, unit, part;
- phandle_t chosen;
- char *prop, *id, bootid;
- static char bootpathbuf[128], bootargsbuf[128], buf[128];
/* Get the entry point and the type (see forth/debugging/client.fs) */ feval("saved-program-state >sps.entry @"); @@ -101,6 +37,80 @@ feval("saved-program-state >sps.file-size @"); size = POP();
- /* SPARC32 is slightly unusual in that before invoking any loaders, a romvec array
- needs to be set up to pass certain parameters using a C struct. Hence this section
- extracts the relevant boot information and places it in obp_arg. */
- /* Get the name of the selected boot device, along with the device and unit number */
- chosen = find_dev("/chosen");
- prop = get_property(chosen, "bootpath", &proplen);
- strncpy(bootpathbuf, prop, proplen);
- prop = get_property(chosen, "bootargs", &proplen);
- strncpy(bootargsbuf, prop, proplen);
- /* Set bootpath pointer used in romvec table to the bootpath */
- bootpath = bootpathbuf;
- if (!strcmp(bootpathbuf, "cdrom") || !strcmp(bootpathbuf, "disk")) {
- /* Controller currently always 0 */
- obp_arg.boot_dev_ctrl = 0;
- /* Grab the device and unit number string (in form unit,partition) */
- push_str(bootpathbuf);
- feval("pathres-resolve-aliases ascii @ right-split 2drop");
- id = pop_fstr_copy();
- /* A bit hacky, but we have no atoi() function */
- unit = id[0] - '0';
- part = id[2] - '0';
- obp_arg.boot_dev_unit = unit;
- obp_arg.dev_partition = part;
- /* Generate the "oldpath"
- FIXME: hardcoding this looks almost definitely wrong.
- With sd(0,2,0):b we get to see the solaris kernel though */
- if (!strcmp(bootpathbuf, "disk"))
- bootid = 'd';
- else
- bootid = 'b';
- snprintf(buf, sizeof(buf), "sd(0,%d,%d):%c", unit, part, bootid);
- obp_arg.boot_dev[0] = buf[0];
- obp_arg.boot_dev[1] = buf[1];
- obp_arg.argv[0] = buf;
- obp_arg.argv[1] = bootargsbuf;
- } else if (!strcmp(bootpathbuf, "floppy")) {
- obp_arg.boot_dev_ctrl = 0;
- obp_arg.boot_dev_unit = 0;
- obp_arg.dev_partition = 0;
- strcpy(buf, "fd()");
- obp_arg.boot_dev[0] = buf[0];
- obp_arg.boot_dev[1] = buf[1];
- obp_arg.argv[0] = buf;
- obp_arg.argv[1] = bootargsbuf;
- } else if (!strcmp(bootpathbuf, "net")) {
- obp_arg.boot_dev_ctrl = 0;
- obp_arg.boot_dev_unit = 0;
- obp_arg.dev_partition = 0;
- strcpy(buf, "le()");
- obp_arg.boot_dev[0] = buf[0];
- obp_arg.boot_dev[1] = buf[1];
- obp_arg.argv[0] = buf;
- obp_arg.argv[1] = bootargsbuf;
- }
printk("\nJumping to entry point " FMT_ucellx " for type " FMT_ucellx "...\n", address, type);
switch (type) { @@ -149,89 +159,9 @@
void boot(void) {
- char *path = pop_fstr_copy(), *param, altpath[256];
- const char *oldpath = path;
- int unit = 0;
- int result;
- if(!path) {
- /* No path specified, so grab defaults from firmware */
- switch (boot_device) {
- case 'a':
- path = strdup("/obio/SUNW,fdtwo");
- oldpath = "fd()";
- break;
- case 'c':
- path = strdup("disk");
- oldpath = "sd(0,0,0):d";
- break;
- default:
- case 'd':
- path = strdup("cdrom");
- // FIXME: hardcoding this looks almost definitely wrong.
- // With sd(0,2,0):b we get to see the solaris kernel though
- //oldpath = "sd(0,2,0):d";
- oldpath = "sd(0,2,0):b";
- unit = 2;
- break;
- case 'n':
- path = strdup("net");
- oldpath = "le()";
- break;
- }
- }
- obp_arg.boot_dev_ctrl = 0;
- obp_arg.boot_dev_unit = unit;
- obp_arg.dev_partition = 0;
- obp_arg.boot_dev[0] = oldpath[0];
- obp_arg.boot_dev[1] = oldpath[1];
- obp_arg.argv[0] = oldpath;
- obp_arg.argv[1] = (void *)(long)qemu_cmdline;
- param = strchr(path, ' ');
- if(param) {
- *param = '\0';
- param++;
- } else if (cmdline_size) {
- param = (char *)qemu_cmdline;
- } else {
- push_str("boot-args");
- push_str("/options");
- fword("(find-dev)");
- POP();
- fword("get-package-property");
- POP();
- param = pop_fstr_copy();
- obp_arg.argv[1] = param;
- }
- romvec = init_openprom();
- /* Boot preloaded kernel */
if (kernel_size) { printk("[sparc] Kernel already loaded\n"); start_elf(kernel_image, (unsigned long)romvec); }
- printk("[sparc] Booting file '%s' ", path);
- if (param)
- printk("with parameters '%s'\n", param);
- else
- printk("without parameters.\n");
- result = try_path(path, param);
- if (!result) {
- push_str(path);
- PUSH(':');
- fword("left-split");
- snprintf(altpath, sizeof(altpath), "%s:d", pop_fstr_copy());
- POP();
- POP();
- try_path(altpath, param);
- }
- printk("Unsupported image format\n");
- free(path);
}
Modified: trunk/openbios-devel/arch/sparc32/boot.h
--- trunk/openbios-devel/arch/sparc32/boot.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/boot.h Sun Aug 1 17:13:48 2010 (r828) @@ -30,6 +30,7 @@
// romvec.c extern struct linux_arguments_v0 obp_arg; +extern const void *romvec;
// openbios.c extern int qemu_machine_type;
Modified: trunk/openbios-devel/arch/sparc32/openbios.c
--- trunk/openbios-devel/arch/sparc32/openbios.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/openbios.c Sun Aug 1 17:13:48 2010 (r828) @@ -133,6 +133,9 @@ static void arch_init( void ) {
- static char cmdline[128];
- int size;
openbios_init(); modules_init(); ob_init_mmu(); @@ -151,23 +154,57 @@ #endif device_end();
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
- kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE);
- if (kernel_size)
- kernel_image = fw_cfg_read_i32(FW_CFG_KERNEL_ADDR);
- size = fw_cfg_read_i32(FW_CFG_CMDLINE_SIZE);
- if (size) {
- fw_cfg_read(FW_CFG_CMDLINE_DATA, cmdline, size);
- }
- cmdline[size] = '\0';
- qemu_cmdline = (uint32_t)cmdline;
- boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
- /* Initialiase openprom romvec */
- romvec = init_openprom();
- /* Setup nvram variables */
- push_str("/options");
- fword("find-device");
- switch (boot_device) {
- case 'a':
- push_str("floppy");
- break;
- case 'c':
- push_str("disk");
- break;
- default:
- case 'd':
- push_str("cdrom");
- break;
- case 'n':
- push_str("net");
- break;
- }
- /* bootpath/bootargs should be set to NVRAM default */
- fword("boot-device");
fword("encode-string");
- push_str("bootpath");
- push_str("boot-device");
fword("property");
- fword("boot-args");
- push_str("");
fword("encode-string");
- push_str("bootargs");
- push_str("boot-file");
fword("property");
- boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
bind_func("platform-boot", boot );
- bind_func("(go)", go );
}
int openbios(void)
Modified: trunk/openbios-devel/arch/sparc64/boot.c
--- trunk/openbios-devel/arch/sparc64/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -8,10 +8,6 @@ #include "libc/diskio.h" #include "libc/vsprintf.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"
uint64_t kernel_image; @@ -19,68 +15,10 @@ uint64_t qemu_cmdline; uint64_t cmdline_size; char boot_device; -void *boot_notes = NULL; +void *elf_boot_notes = NULL; extern int sparc64_of_client_interface( int *params );
-static int try_path(const char *path, char *param) -{
- ucell valid;
- ihandle_t dev;
- /* Open device used by this path */
- dev = open_dev(path);
-#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, dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FCODE
- /* Fcode loader */
- fcode_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FORTH
- /* Forth loader */
- forth_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
- close_dev(dev);
- return 0;
-start_image:
- go();
- return -1;
-}
void go(void) { ucell address, type, size; @@ -99,7 +37,7 @@ switch (type) { case 0x0: /* Start ELF boot image */
- image_retval = start_elf(address, (uint64_t)&boot_notes);
- image_retval = start_elf(address, (uint64_t)&elf_boot_notes);
break;
case 0x1: @@ -136,19 +74,23 @@
void boot(void) {
- char *path=pop_fstr_copy(), *param;
- char altpath[256];
- int result;
char *path, *param;
/* Copy the incoming path */
fword("2dup");
path = pop_fstr_copy();
/* Boot preloaded kernel */
if (kernel_size) { void (*entry)(unsigned long p1, unsigned long p2, unsigned long p3,
- unsigned long p4, unsigned long p5);;
- unsigned long p4, unsigned long p5);
printk("[sparc64] Kernel already loaded\n"); entry = (void *) (unsigned long)kernel_image; entry(0, 0, 0, 0, (unsigned long)&sparc64_of_client_interface); }
- /* Invoke Linux directly -- probably not supported */
if(!path) { /* No path specified, so grab defaults from /chosen */ push_str("bootpath"); @@ -175,20 +117,9 @@ POP(); param = pop_fstr_copy(); }
- printk("[sparc64] Booting file '%s' ", path);
- if (param)
- printk("with parameters '%s'\n", param);
- else
- printk("without parameters.\n");
- result = try_path(path, param);
- if (!result) {
- snprintf(altpath, sizeof(altpath), "%s:f", path);
- try_path(altpath, param);
- }
- printk("Unsupported image format\n");
- /* Invoke platform-specific Linux loader */
- linux_load(&sys_info, path, param);
free(path); }
Modified: trunk/openbios-devel/arch/sparc64/linux_load.c
--- trunk/openbios-devel/arch/sparc64/linux_load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/linux_load.c Sun Aug 1 17:13:48 2010 (r828) @@ -618,6 +618,12 @@ return LOADER_NOT_SUPPORT; }
- debug("[sparc64] Booting kernel '%s' ", file);
- if (cmdline)
- debug("with parameters '%s'\n", cmdline);
- else
- debug("without parameters.\n");
params = phys_to_virt(LINUX_PARAM_LOC); init_linux_params(params, &hdr); set_memory_size(params, info);
Modified: trunk/openbios-devel/arch/sparc64/openbios.c
--- trunk/openbios-devel/arch/sparc64/openbios.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/openbios.c Sun Aug 1 17:13:48 2010 (r828) @@ -374,7 +374,6 @@ { uint32_t size = 0; const struct cpudef *cpu;
- const char *bootpath;
char buf[256]; uint32_t temp; uint64_t ram_size; @@ -492,34 +491,15 @@ push_str("boot-device"); fword("property");
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
- if (boot_device == 'c')
- bootpath = "disk:a";
- else
- bootpath = "cdrom:a";
- push_str(bootpath);
- fword("encode-string");
- push_str("bootpath");
- fword("property");
- /* bootpath/bootargs should be set to NVRAM default */
- fword("boot-device");
- fword("encode-string");
- push_str("bootpath");
- fword("property");
- fword("boot-args");
- fword("encode-string");
- push_str("bootargs");
- fword("property");
push_str(obio_cmdline); fword("encode-string");
- push_str("bootargs");
- push_str("boot-file");
fword("property");
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
if (fw_cfg_read_i16(FW_CFG_NOGRAPHIC)) { stdin_path = stdout_path = "ttya"; } else {
Modified: trunk/openbios-devel/arch/x86/boot.c
--- trunk/openbios-devel/arch/x86/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/x86/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -12,71 +12,9 @@ #include "arch/common/nvram.h" #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"
-void *boot_notes = NULL;
-static int try_path(const char *path, char *param) -{
- ucell valid;
- ihandle_t dev;
- /* Open device used by this path */
- dev = open_dev(path);
-#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, dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FCODE
- /* Fcode loader */
- fcode_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FORTH
- /* Forth loader */
- forth_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
- close_dev(dev);
- return 0;
-start_image:
- go();
- return -1;
-}
+void *elf_boot_notes = NULL;
void go(void) { @@ -133,24 +71,6 @@
void boot(void) {
- char *path=pop_fstr_copy(), *param;
- if(!path) {
- printk("[x86] Booting default not supported.\n");
- return;
- }
- param = strchr(path, ' ');
- if(param) {
- *param = '\0';
- param++;
- }
- printk("[x86] Booting file '%s' with parameters '%s'\n",path, param);
- try_path(path, param);
- printk("Unsupported image format\n");
- free(path);
- /* No platform-specific boot code */
- return;
}
Modified: trunk/openbios-devel/forth/admin/userboot.fs
--- trunk/openbios-devel/forth/admin/userboot.fs Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/forth/admin/userboot.fs Sun Aug 1 17:13:48 2010 (r828) @@ -1,16 +1,15 @@ \ 7.4.3.5 User commands for booting
-: boot ( "{param-text}<cr>" -- )
- (encode-bootpath)
+: boot ( "{param-text}<cr>" -- )
- (encode-bootpath) \ Setup bootpath/bootargs
s" platform-boot" $find if
- execute
- else
- 2drop
- cr ." Booting " type cr
- ." ... not supported on this system." cr
- execute \ Execute platform-specific boot code
then
- $load \ load and go
- go
;
\ : diagnostic-mode? ( -- diag? ) \ ;
Modified: trunk/openbios-devel/forth/debugging/client.fs
--- trunk/openbios-devel/forth/debugging/client.fs Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/forth/debugging/client.fs Sun Aug 1 17:13:48 2010 (r828) @@ -58,24 +58,55 @@ : (encode-bootpath) ( "{params}<cr>" -- bootpath-str bootpath-len) \ Parse the current input buffer of a load/boot command and set both \ the bootargs and bootpath properties as appropriate.
- bl parse dup if
- 2dup encode-string
- " /chosen" (find-dev) if
- " bootpath" rot (property)
- then
- then
- linefeed parse dup if
- encode-string
- " /chosen" (find-dev) if
- " bootargs" rot (property)
- then
- else
- cr
- \ bootpath
- bl parse dup 0= if
- \ None specified. As per IEEE-1275 specification, search through each value
- \ in boot-device and use the first that returns a valid ihandle on open.
- s" boot-device" $find drop execute
- bl left-split
- begin
- dup
- while
- 2dup s" Trying " type type s" ..." type cr
- 2dup open-dev ?dup if
- close-dev
- 2swap drop 0 \ Fake end of string so we exit loop
- else
- 2drop
- bl left-split
- then
- repeat
2drop
- else
- 0 0 2swap \ Fake (empty) parse string
- then
- \ Set the bootpath property
- 2dup encode-string
- " /chosen" (find-dev) if
- " bootpath" rot (property)
- then
- \ bootargs
- linefeed parse dup 0= if
- \ None specified, use default from nvram
- 2drop s" boot-file" $find drop execute
then
- \ Set the bootargs property
- encode-string
- " /chosen" (find-dev) if
- " bootargs" rot (property)
- then
- \ Remove the remaining string
- 2swap 2drop
;
-: load ( "{params}<cr>" -- )
- (encode-bootpath)
+: $load ( devstr len ) open-dev ( ihandle ) dup 0= if drop @@ -89,6 +120,11 @@ init-program ;
+: load ( "{params}<cr>" -- )
- (encode-bootpath)
- $load
+;
: dir ( "{paths}<cr>" -- ) linefeed parse split-path-device
Modified: trunk/openbios-devel/include/libopenbios/elf_load.h
--- trunk/openbios-devel/include/libopenbios/elf_load.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/include/libopenbios/elf_load.h Sun Aug 1 17:13:48 2010 (r828) @@ -21,7 +21,7 @@ #include "asm/elf.h" #include "libopenbios/sys_info.h"
-extern int elf_load(struct sys_info *info, const char *filename, const char *cmdline, void **boot_notes); +extern int elf_load(struct sys_info *info, ihandle_t dev, const char *cmdline, void **boot_notes); extern void elf_init_program(void); extern int is_elf(Elf_ehdr *ehdr); extern int find_elf(Elf_ehdr *ehdr);
Modified: trunk/openbios-devel/include/libopenbios/sys_info.h
--- trunk/openbios-devel/include/libopenbios/sys_info.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/include/libopenbios/sys_info.h Sun Aug 1 17:13:48 2010 (r828) @@ -22,6 +22,7 @@ unsigned long *dict_end; };
+extern void *elf_boot_notes; extern struct sys_info sys_info;
void collect_elfboot_info(struct sys_info *info);
Modified: trunk/openbios-devel/libopenbios/elf_load.c
--- trunk/openbios-devel/libopenbios/elf_load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/libopenbios/elf_load.c Sun Aug 1 17:13:48 2010 (r828) @@ -368,7 +368,7 @@ }
int -elf_load(struct sys_info *info, const char *filename, const char *cmdline, void **boot_notes) +elf_load(struct sys_info *info, ihandle_t dev, const char *cmdline, void **boot_notes) { Elf_ehdr ehdr; Elf_phdr *phdr = NULL; @@ -382,7 +382,7 @@ /* Mark the saved-program-state as invalid */ feval("0 state-valid !");
- fd = open_io(filename);
- fd = open_ih(dev);
if (!fd) goto out;
Modified: trunk/openbios-devel/libopenbios/load.c
--- trunk/openbios-devel/libopenbios/load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/libopenbios/load.c Sun Aug 1 17:13:48 2010 (r828) @@ -20,6 +20,10 @@ #include "libopenbios/sys_info.h" #include "libopenbios/load.h"
+#ifdef CONFIG_LOADER_ELF +#include "libopenbios/elf_load.h" +#endif
#ifdef CONFIG_LOADER_AOUT #include "libopenbios/aout_load.h" #endif @@ -38,6 +42,21 @@ void load(ihandle_t dev) { /* Invoke the loaders on the specified device */
- char *param;
+#ifdef CONFIG_LOADER_ELF
- /* Grab the boot arguments */
- push_str("bootargs");
- push_str("/chosen");
- fword("(find-dev)");
- POP();
- fword("get-package-property");
- POP();
- param = pop_fstr_copy();
- elf_load(&sys_info, dev, param, &elf_boot_notes);
+#endif
#ifdef CONFIG_LOADER_AOUT aout_load(&sys_info, dev);
-- OpenBIOS http://openbios.org/ Mailinglist: http://lists.openbios.org/mailman/listinfo Free your System - May the Forth be with you
On Tue, Aug 3, 2010 at 4:13 PM, Blue Swirl blauwirbel@gmail.com wrote:
On Sun, Aug 1, 2010 at 3:13 PM, repository service svn@openbios.org wrote:
Author: mcayland Date: Sun Aug 1 17:13:48 2010 New Revision: 828 URL: http://tracker.coreboot.org/trac/openbios/changeset/828
Log: Rework the OpenBIOS internals so that boot, load and init-program now all use the unified libopenbios loader code with improved IEEE-1275 spec compliance.
This patch implements the following:
- Fix bootpath/bootargs handling so that default values are read from NVRAM, and allow multiple space-separated values to be
specified. 2) With correct bootargs handling in place, move the ELF loader over to the new libopenbios unified loaders. 3) Remove all the loader code from all architecture directories sine we don't need it anymore. 4) Simplify the boot word so it invokes platform-specific code where required, then calls load and go as per the specification.
Tested on all my available images for SPARC32, SPARC64 and PPC, and compile-tested on x86.
In addition, the command line set with -append is broken: qemu-system-sparc -kernel sparc-test/vmlinux-2.6.11+tcx -append 'root=/dev/ram' -initrd sparc-test/linux.img -L . -nographic Configuration device id QEMU version 1 machine id 32 UUID: 00000000-0000-0000-0000-000000000000 CPUs: 1 x FMI,MB86904 Welcome to OpenBIOS v1.0 built on Aug 2 2010 20:59 Type 'help' for detailed information
Trying disk... [sparc] Kernel already loaded switching to new context: PROMLIB: obio_ranges 1 Booting Linux... PROMLIB: Sun Boot Prom Version 3 Revision 2 Linux version 2.6.11 (test@host) (gcc version 2.95.4 20010319 (prerelease)) #3 Tue Mar 15 18:21:10 UTC 2005 ARCH: SUN4M TYPE: SPARCstation 5 Ethernet address: 52:54:0:12:34:56 Boot time fixup v1.6. 4/Mar/98 Jakub Jelinek (jj@ultra.linux.cz). Patching kernel for srmmu[Fujitsu TurboSparc]/iommu Power off control detected. Built 1 zonelists Kernel command line: ELF PID hash table entries: 512 (order: 9, 8192 bytes) Console: colour dummy device 80x25 Dentry cache hash table entries: 16384 (order: 4, 65536 bytes) Inode-cache hash table entries: 8192 (order: 3, 32768 bytes) Memory: 119836k/130144k available (1848k kernel code, 10144k reserved, 496k data, 156k init, 0k highmem) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) checking if image is initramfs...it isn't (bad gzip magic numbers); looks like an initrd Freeing initrd memory: 4096k freed NET: Registered protocol family 16 SCSI subsystem initialized IOMMU: impl 0 vers 5 table 0xf0b40000[262144 B] map [65536 b] sbus0: Clock 21.1250 MHz dma0: Revision 2 dma1: Revision 2 ioremap: done with statics, switching to malloc apc: power management initialized Initializing Cryptographic API Console: switching to colour frame buffer device 128x48 tcx: SUNW,tcx at 0:50800000, 8-bit only lp: driver loaded but no devices found zs2 at 0xfd018004 (irq = 44) is a SunZilog zs3 at 0xfd018000 (irq = 44) is a SunZilog Console: ttyS0 (SunZilog zs0) ttyS0 at MMIO 0x0 (irq = 44) is a SunZilog ttyS1 at MMIO 0x0 (irq = 44) is a SunZilog io scheduler noop registered Floppy drive(s): fd0 is 1.44M reset set in interrupt, calling f01396a0 floppy0: no floppy controllers found RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize loop: loaded (max 8 devices) sunlance.c:v2.02 24/Aug/03 Miguel de Icaza (miguel@nuclecu.unam.mx) SunLance: using auto-carrier-detection. eth0: LANCE 52:54:00:12:34:56 esp0: IRQ 36 SCSI ID 7 Clk 40MHz CCYC=25000 CCF=8 TOut 167 NCR53C9XF(espfast) ESP: Total of 1 ESP hosts found, 1 actually in use. scsi0 : Sparc ESP100A-FAST Vendor: QEMU Model: QEMU CD-ROM Rev: 0.12 Type: CD-ROM ANSI SCSI revision: 05 sr0: scsi3-mmc drive: 16x/50x cd/rw xa/form2 cdda tray Uniform CD-ROM driver Revision: 3.20 Attached scsi generic sg0 at scsi0, channel 0, id 2, lun 0, type 5 mice: PS/2 mouse device common for all mice input: Sun Mouse on zs/serio1 NET: Registered protocol family 2 IP: routing cache hash table of 1024 buckets, 8Kbytes TCP established hash table entries: 4096 (order: 3, 32768 bytes) TCP bind hash table entries: 4096 (order: 3, 32768 bytes) TCP: Hash tables configured (established 4096 bind 4096) NET: Registered protocol family 1 NET: Registered protocol family 17 RAMDISK: ext2 filesystem found at block 0 RAMDISK: Loading 4096KiB [1 disk] into ram disk... done. EXT2-fs warning: checktime reached, running e2fsck is recommended VFS: Mounted root (ext2 filesystem). Root-NFS: No NFS server available, giving up. Unable to handle kernel NULL pointer dereference tsk->{mm,active_mm}->context = ffffffff tsk->{mm,active_mm}->pgd = fc000000 |/ ____ |/ "@'/ ,. `@" /_| __/ |_\ __U_/ swapper(1): Oops [#1] PSR: 040010c7 PC: f0109538 NPC: f010953c Y: 00000000 Not tainted PC: <tty_wakeup+0x4/0x64> %G: f0bf0c60 f079d4bc 00000001 044010e2 f0034854 00000000 f05ee000 00000001 %O: 00000ff0 00000ff0 f0216800 f0216ab8 f027e768 f7f02d40 f05ef6c0 f002f4e4 RPC: <call_console_drivers+0x148/0x158> %L: 040010c0 f0109534 f0109538 00000001 00000000 00000000 f05ee000 0000000a %I: 00000000 f079d4a0 00000fbf f05efc30 0000000a ffffffff f05ef728 f01224a0 Caller[f01224a0]: uart_tasklet_action+0x8/0x18 Caller[f00348b8]: tasklet_action+0x74/0xbc Caller[f00344f8]: Letext+0x4c/0xd0 Caller[f00345b8]: do_softirq+0x3c/0x54 Caller[f0034698]: irq_exit+0x3c/0x4c Caller[f0012bc8]: handler_irq+0x9c/0xac Caller[f0010398]: patch_handler_irq+0x0/0x24 Caller[f002f4e4]: call_console_drivers+0x148/0x158 Caller[f002f8a0]: release_console_sem+0x48/0xdc Caller[f002f768]: vprintk+0x148/0x164 Caller[f002f610]: printk+0x1c/0x2c Caller[f0265a28]: video_setup+0x0/0x14c Caller[f0265a58]: video_setup+0x30/0x14c Caller[f0265d6c]: rand_initialize+0x14/0x124 Caller[f0252914]: inflate_block+0x130/0x154 Caller[f0252ac4]: gunzip+0x14/0x748 Caller[f0255768]: inflate_dynamic+0x5e8/0x64c Caller[f02558c0]: inflate_block+0xf4/0x144 Caller[f0252cc8]: gunzip+0x218/0x748 Caller[f00100fc]: init+0x54/0xfc Caller[f0014a4c]: kernel_thread+0x34/0x50 Caller[f001002c]: rest_init+0x10/0x28 Caller[f0251ed8]: inflate_stored+0x104/0x1fc Caller[f0251790]: huft_build+0x40c/0x55c Caller[f02510a8]: rd_load_image+0x100/0x314 Instruction DUMP: 81c7e008 81e80000 9de3bf98 <d00620bc> 808a2020 02800010 90062940 7ffffe9a 90100018 Kernel panic - not syncing: Aiee, killing interrupt handler! <0>Press L1-A to return to the boot prom
This is wrong: 'Kernel command line: ELF', it should be 'Kernel command line: root=/dev/ram'.
2010/8/3 Blue Swirl blauwirbel@gmail.com:
On Sun, Aug 1, 2010 at 3:13 PM, repository service svn@openbios.org wrote:
Author: mcayland Date: Sun Aug 1 17:13:48 2010 New Revision: 828 URL: http://tracker.coreboot.org/trac/openbios/changeset/828
Log: Rework the OpenBIOS internals so that boot, load and init-program now all use the unified libopenbios loader code with improved IEEE-1275 spec compliance.
This patch implements the following:
- Fix bootpath/bootargs handling so that default values are read from NVRAM, and allow multiple space-separated values to be
specified. 2) With correct bootargs handling in place, move the ELF loader over to the new libopenbios unified loaders. 3) Remove all the loader code from all architecture directories sine we don't need it anymore. 4) Simplify the boot word so it invokes platform-specific code where required, then calls load and go as per the specification.
Tested on all my available images for SPARC32, SPARC64 and PPC, and compile-tested on x86.
This actually breaks NetBSD. For example 5.0.1 should work like this (r827): Configuration device id QEMU version 1 machine id 32 UUID: 00000000-0000-0000-0000-000000000000 CPUs: 1 x FMI,MB86904 Welcome to OpenBIOS v1.0 built on Aug 2 2010 20:59 Type 'help' for detailed information [sparc] Booting file 'cdrom' with parameters '' Trying cdrom (/iommu/sbus/espdma/esp/sd@2,0) Not a bootable ELF image Not a Linux kernel image Not a bootable a.out image Trying cdrom:d (/iommu/sbus/espdma/esp/sd@2,0:d)
Is this correct? In the OBP cdrom is an alias to the slice d (of the sd@6,0, but it's less important).
Not a bootable ELF image Not a Linux kernel image Loading a.out image... Loaded 65536 bytes entry point is 0x4000
Jumping to entry point 00004000 for type 00000005... switching to new context:
NetBSD/sparc Secondary Boot, Revision 1.15 (builds@b8.netbsd.org, Thu Jul 30 00:08:01 UTC 2009)
Booting netbsd 1724008+846700+210280=0x2b7208 OBP version 3, revision 2.25 (plugin rev 2) Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. All rights reserved. Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved.
NetBSD 5.0.1 (INSTALL) #0: Thu Jul 30 00:20:16 UTC 2009 builds@b8.netbsd.org:/home/builds/ab/netbsd-5-0-1-RELEASE/sparc/200907292356Z-obj/home/builds/ab/netbsd-5-0-1-RELEASE/src/sys/arch/sparc/compile/INSTALL total memory = 127 MB avail memory = 121 MB bootpath: /iommu0/sbus0/espdma0/esp0/sd@2,0:d mainbus0 (root): SUNW,SPARCstation-5: hostid 80000000 cpu0 at mainbus0: MB86907 @ 170 MHz, L64804 FPU cpu0: 16K instruction (32 b/l), 8K data (16 b/l), 512K external (32 b/l): cache enabled obio0 at mainbus0 clock0 at obio0 slot 0 offset 0x200000: mk48t08 timer0 at obio0 slot 0 offset 0xd00000: delay constant 1, frequency = 2000000 Hz zs0 at obio0 slot 0 offset 0x100000 level 12 softpri 6 zstty0 at zs0 channel 0 (console i/o) zstty1 at zs0 channel 1 zs1 at obio0 slot 0 offset 0x0 level 12 softpri 6 kbd0 at zs1 channel 0: baud rate 76800 ms0 at zs1 channel 1: baud rate 76800 slavioconfig at obio0 slot 0 offset 0x800000 not configured fdc0 at obio0 slot 0 offset 0x400000 level 11: no drives attached auxreg0 at obio0 slot 0 offset 0x900000 power0 at obio0 slot 0 offset 0x910000 level 2 iommu0 at mainbus0 addr 0x10000000: version 0x5/0x0, page-size 4096, range 64MB sbus0 at iommu0: clock = 21.250 MHz tcx0 at sbus0 slot 3 offset 0x800000 level 5 (ipl 9): SUNW,tcx, 1024 x 768, id 0, rev 0, sense 0 tcx0: attached to /dev/fb0 dma0 at sbus0 slot 5 offset 0x8400000: DMA rev 2 esp0 at dma0 slot 5 offset 0x8800000 level 4: ESP200, 40MHz, SCSI ID 7 scsibus0 at esp0: 8 targets, 8 luns per target ledma0 at sbus0 slot 5 offset 0x8400010: DMA rev 2 le0 at ledma0 slot 5 offset 0x8c00000 level 6: address 52:54:00:12:34:56 le0: 8 receive buffers, 2 transmit buffers SUNW,CS4231 at sbus0 slot 4 offset 0xc000000 level 5 (ipl 9) not configured power-management at sbus0 slot 4 offset 0xa000000 not configured scsibus0: waiting 2 seconds for devices to settle... cd0 at scsibus0 target 2 lun 0: <QEMU, QEMU CD-ROM, 0.12> cdrom removable root on md0a dumps on md0b root file system type: ffs WARNING: clock gained 369 days WARNING: CHECK AND RESET THE DATE! Welcome to the NetBSD/sparc microroot setup utility.
We've just completed the first stage of a two-stage procedure to load a fully functional NetBSD installation environment on your machine. In the second stage which is to follow now, a set of additional installation utilities must be load from your NetBSD/sparc installation medium.
This procedure supports one of the following media:
- cdrom
- tape
- floppy
But with r828, I get: Configuration device id QEMU version 1 machine id 32 UUID: 00000000-0000-0000-0000-000000000000 CPUs: 1 x FMI,MB86904 Welcome to OpenBIOS v1.0 built on Aug 2 2010 20:59 Type 'help' for detailed information
Trying cdrom... Not a bootable ELF image Not a bootable a.out image No valid state has been set by load or init-program
0 > boot cdrom:d Not a bootable ELF image Loading a.out image... Loaded 65536 bytes entry point is 0x4000
Jumping to entry point 00004000 for type 00000005... switching to new context:
NetBSD/sparc Secondary Boot, Revision 1.15 (builds@b8.netbsd.org, Thu Jul 30 00:08:01 UTC 2009)
Booting netbsd 1724008+846700+210280=0x2b7208 OBP version 3, revision 2.25 (plugin rev 2) Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. All rights reserved. Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved.
NetBSD 5.0.1 (INSTALL) #0: Thu Jul 30 00:20:16 UTC 2009 builds@b8.netbsd.org:/home/builds/ab/netbsd-5-0-1-RELEASE/sparc/200907292356Z-obj/home/builds/ab/netbsd-5-0-1-RELEASE/src/sys/arch/sparc/compile/INSTALL total memory = 127 MB avail memory = 121 MB bootpath: data fault: pc=0xf01651c8 addr=0x0 sfsr=126<PERR=0,LVL=1,AT=1,FT=1,FAV,OW> panic: kernel fault halted
halt, power off
There are two regressions: cdrom:d is not used and bootpath pointer seems to point to nowhere when NetBSD tries to use it.
I don't see pathres-resolve-aliases being used, maybe that's a part of the problem.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c trunk/openbios-devel/arch/ppc/qemu/main.c trunk/openbios-devel/arch/sparc32/boot.c trunk/openbios-devel/arch/sparc32/boot.h trunk/openbios-devel/arch/sparc32/openbios.c trunk/openbios-devel/arch/sparc64/boot.c trunk/openbios-devel/arch/sparc64/linux_load.c trunk/openbios-devel/arch/sparc64/openbios.c trunk/openbios-devel/arch/x86/boot.c trunk/openbios-devel/forth/admin/userboot.fs trunk/openbios-devel/forth/debugging/client.fs trunk/openbios-devel/include/libopenbios/elf_load.h trunk/openbios-devel/include/libopenbios/sys_info.h trunk/openbios-devel/libopenbios/elf_load.c trunk/openbios-devel/libopenbios/load.c
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c
--- trunk/openbios-devel/arch/ppc/qemu/init.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/ppc/qemu/init.c Sun Aug 1 17:13:48 2010 (r828) @@ -527,7 +527,7 @@ uint64_t ram_size; const struct cpudef *cpu; char buf[64], qemu_uuid[16];
- const char *stdin_path, *stdout_path;
- const char *stdin_path, *stdout_path, *boot_path;
uint32_t temp = 0;
ofmem_t *ofmem = ofmem_arch_get_private(); @@ -721,14 +721,17 @@ uint16_t boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE); switch (boot_device) { case 'c':
- push_str("hd:");
- boot_path = "hd";
break; default: case 'd':
- push_str("cd:");
- boot_path = "cd";
break; }
- /* Setup default boot devices */
- snprintf(buf, sizeof(buf), "%s:,\\:tbxi %s:,\ppc\bootinfo.txt", boot_path, boot_path);
- push_str(buf);
fword("encode-string"); push_str("boot-device"); fword("property"); @@ -737,16 +740,6 @@ push_str("/chosen"); fword("find-device");
- /* bootpath/bootargs should be set to NVRAM default */
- fword("boot-device");
- fword("encode-string");
- push_str("bootpath");
- fword("property");
- fword("boot-args");
- fword("encode-string");
- push_str("bootargs");
- fword("property");
push_str(stdin_path); fword("open-dev"); fword("encode-int");
Modified: trunk/openbios-devel/arch/ppc/qemu/main.c
--- trunk/openbios-devel/arch/ppc/qemu/main.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/ppc/qemu/main.c Sun Aug 1 17:13:48 2010 (r828) @@ -39,16 +39,9 @@ #define ELF_DPRINTF(fmt, args...) SUBSYS_DPRINTF("ELF", fmt, ##args) #define NEWWORLD_DPRINTF(fmt, args...) SUBSYS_DPRINTF("NEWWORLD", fmt, ##args)
-static void -load(const char *path, const char *param) -{
- char buffer[1024];
- if (param)
- sprintf(buffer, "load %s %s", path, param);
- else
- sprintf(buffer, "load %s", path);
- feval(buffer);
-} +struct sys_info sys_info; +void *elf_boot_notes = NULL;
static char * get_device( const char *path ) @@ -115,6 +108,7 @@ return filename; }
static void encode_bootpath( const char *spec, const char *args ) { @@ -123,6 +117,9 @@ char *filename, *directory; int partition;
- if (spec)
- return;
filename = get_filename(spec, &directory); partition = get_partition(spec); if (partition == -1) @@ -138,28 +135,6 @@ set_property( chosen_ph, "bootargs", args, strlen(args)+1 ); }
-/************************************************************************/ -/* qemu booting */ -/************************************************************************/ -static void -try_path(const char *device, const char* filename, const char *param) -{
- char path[1024];
- if (filename)
- snprintf(path, sizeof(path), "%s%s", device, filename);
- else
- snprintf(path, sizeof(path), "%s", device);
- ELF_DPRINTF("Trying %s %s\n", path, param);
- load(path, param);
- update_nvram();
- ELF_DPRINTF("Transfering control to %s %s\n",
- path, param);
- feval("go");
-}
#define OLDWORLD_BOOTCODE_BASEADDR (0x3f4000)
static void @@ -203,46 +178,6 @@ return; }
-static void -newworld_boot( void ) -{
- static const char * const chrp_path[] = { "\\:tbxi",
- "ppc\bootinfo.txt",
- NULL
- };
- char *path = pop_fstr_copy(), *param;
- int i;
- param = strchr(path, ' ');
- if (param) {
- *param = 0;
- param++;
- }
- if (!path) {
- NEWWORLD_DPRINTF("Entering boot, no path\n");
- /* No path specified, so grab defaults from /chosen */
- push_str("bootpath");
- push_str("/chosen");
- fword("(find-dev)");
- POP();
- fword("get-package-property");
- POP();
- path = pop_fstr_copy();
- for (i = 0; chrp_path[i]; i++)
- try_path(path, chrp_path[i], param);
- } else {
- NEWWORLD_DPRINTF("Entering boot, path %s\n", path);
- try_path(path, NULL, param);
- for (i = 0; chrp_path[i]; i++)
- try_path(path, chrp_path[i], param);
- }
- printk("*** Boot failure! No secondary bootloader specified ***\n");
-}
static void check_preloaded_kernel(void) { unsigned long kernel_image, kernel_size; @@ -281,8 +216,10 @@ if (boot_device == 'm') { check_preloaded_kernel(); }
if (boot_device == 'c') { oldworld_boot(); }
- newworld_boot();
- update_nvram();
}
Modified: trunk/openbios-devel/arch/sparc32/boot.c
--- trunk/openbios-devel/arch/sparc32/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -9,10 +9,6 @@ #include "libc/diskio.h" #include "libc/vsprintf.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 "openprom.h" #include "boot.h" #include "context.h" @@ -22,76 +18,16 @@ uint32_t qemu_cmdline; uint32_t cmdline_size; char boot_device; -static const void *romvec;
-static int try_path(const char *path, char *param) -{
- void *boot_notes = NULL;
- ucell valid;
- ihandle_t dev;
- push_str(path);
- fword("pathres-resolve-aliases");
- bootpath = pop_fstr_copy();
- printk("Trying %s (%s)\n", path, bootpath);
- /* Open device used by this path */
- dev = open_dev(path);
-#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, dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FCODE
- /* Fcode loader */
- fcode_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FORTH
- /* Forth loader */
- forth_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
- close_dev(dev);
- return 0;
-start_image:
- go();
- return -1;
-}
+void *elf_boot_notes = NULL; +const void *romvec;
void go(void) { ucell address, type, size;
- int image_retval = 0;
- int image_retval = 0, proplen, unit, part;
- phandle_t chosen;
- char *prop, *id, bootid;
- static char bootpathbuf[128], bootargsbuf[128], buf[128];
/* Get the entry point and the type (see forth/debugging/client.fs) */ feval("saved-program-state >sps.entry @"); @@ -101,6 +37,80 @@ feval("saved-program-state >sps.file-size @"); size = POP();
- /* SPARC32 is slightly unusual in that before invoking any loaders, a romvec array
- needs to be set up to pass certain parameters using a C struct. Hence this section
- extracts the relevant boot information and places it in obp_arg. */
- /* Get the name of the selected boot device, along with the device and unit number */
- chosen = find_dev("/chosen");
- prop = get_property(chosen, "bootpath", &proplen);
- strncpy(bootpathbuf, prop, proplen);
- prop = get_property(chosen, "bootargs", &proplen);
- strncpy(bootargsbuf, prop, proplen);
- /* Set bootpath pointer used in romvec table to the bootpath */
- bootpath = bootpathbuf;
- if (!strcmp(bootpathbuf, "cdrom") || !strcmp(bootpathbuf, "disk")) {
- /* Controller currently always 0 */
- obp_arg.boot_dev_ctrl = 0;
- /* Grab the device and unit number string (in form unit,partition) */
- push_str(bootpathbuf);
- feval("pathres-resolve-aliases ascii @ right-split 2drop");
- id = pop_fstr_copy();
- /* A bit hacky, but we have no atoi() function */
- unit = id[0] - '0';
- part = id[2] - '0';
- obp_arg.boot_dev_unit = unit;
- obp_arg.dev_partition = part;
- /* Generate the "oldpath"
- FIXME: hardcoding this looks almost definitely wrong.
- With sd(0,2,0):b we get to see the solaris kernel though */
- if (!strcmp(bootpathbuf, "disk"))
- bootid = 'd';
- else
- bootid = 'b';
- snprintf(buf, sizeof(buf), "sd(0,%d,%d):%c", unit, part, bootid);
- obp_arg.boot_dev[0] = buf[0];
- obp_arg.boot_dev[1] = buf[1];
- obp_arg.argv[0] = buf;
- obp_arg.argv[1] = bootargsbuf;
- } else if (!strcmp(bootpathbuf, "floppy")) {
- obp_arg.boot_dev_ctrl = 0;
- obp_arg.boot_dev_unit = 0;
- obp_arg.dev_partition = 0;
- strcpy(buf, "fd()");
- obp_arg.boot_dev[0] = buf[0];
- obp_arg.boot_dev[1] = buf[1];
- obp_arg.argv[0] = buf;
- obp_arg.argv[1] = bootargsbuf;
- } else if (!strcmp(bootpathbuf, "net")) {
- obp_arg.boot_dev_ctrl = 0;
- obp_arg.boot_dev_unit = 0;
- obp_arg.dev_partition = 0;
- strcpy(buf, "le()");
- obp_arg.boot_dev[0] = buf[0];
- obp_arg.boot_dev[1] = buf[1];
- obp_arg.argv[0] = buf;
- obp_arg.argv[1] = bootargsbuf;
- }
printk("\nJumping to entry point " FMT_ucellx " for type " FMT_ucellx "...\n", address, type);
switch (type) { @@ -149,89 +159,9 @@
void boot(void) {
- char *path = pop_fstr_copy(), *param, altpath[256];
- const char *oldpath = path;
- int unit = 0;
- int result;
- if(!path) {
- /* No path specified, so grab defaults from firmware */
- switch (boot_device) {
- case 'a':
- path = strdup("/obio/SUNW,fdtwo");
- oldpath = "fd()";
- break;
- case 'c':
- path = strdup("disk");
- oldpath = "sd(0,0,0):d";
- break;
- default:
- case 'd':
- path = strdup("cdrom");
- // FIXME: hardcoding this looks almost definitely wrong.
- // With sd(0,2,0):b we get to see the solaris kernel though
- //oldpath = "sd(0,2,0):d";
- oldpath = "sd(0,2,0):b";
- unit = 2;
- break;
- case 'n':
- path = strdup("net");
- oldpath = "le()";
- break;
- }
- }
- obp_arg.boot_dev_ctrl = 0;
- obp_arg.boot_dev_unit = unit;
- obp_arg.dev_partition = 0;
- obp_arg.boot_dev[0] = oldpath[0];
- obp_arg.boot_dev[1] = oldpath[1];
- obp_arg.argv[0] = oldpath;
- obp_arg.argv[1] = (void *)(long)qemu_cmdline;
- param = strchr(path, ' ');
- if(param) {
- *param = '\0';
- param++;
- } else if (cmdline_size) {
- param = (char *)qemu_cmdline;
- } else {
- push_str("boot-args");
- push_str("/options");
- fword("(find-dev)");
- POP();
- fword("get-package-property");
- POP();
- param = pop_fstr_copy();
- obp_arg.argv[1] = param;
- }
- romvec = init_openprom();
- /* Boot preloaded kernel */
if (kernel_size) { printk("[sparc] Kernel already loaded\n"); start_elf(kernel_image, (unsigned long)romvec); }
- printk("[sparc] Booting file '%s' ", path);
- if (param)
- printk("with parameters '%s'\n", param);
- else
- printk("without parameters.\n");
- result = try_path(path, param);
- if (!result) {
- push_str(path);
- PUSH(':');
- fword("left-split");
- snprintf(altpath, sizeof(altpath), "%s:d", pop_fstr_copy());
- POP();
- POP();
- try_path(altpath, param);
- }
- printk("Unsupported image format\n");
- free(path);
}
Modified: trunk/openbios-devel/arch/sparc32/boot.h
--- trunk/openbios-devel/arch/sparc32/boot.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/boot.h Sun Aug 1 17:13:48 2010 (r828) @@ -30,6 +30,7 @@
// romvec.c extern struct linux_arguments_v0 obp_arg; +extern const void *romvec;
// openbios.c extern int qemu_machine_type;
Modified: trunk/openbios-devel/arch/sparc32/openbios.c
--- trunk/openbios-devel/arch/sparc32/openbios.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc32/openbios.c Sun Aug 1 17:13:48 2010 (r828) @@ -133,6 +133,9 @@ static void arch_init( void ) {
- static char cmdline[128];
- int size;
openbios_init(); modules_init(); ob_init_mmu(); @@ -151,23 +154,57 @@ #endif device_end();
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
- kernel_size = fw_cfg_read_i32(FW_CFG_KERNEL_SIZE);
- if (kernel_size)
- kernel_image = fw_cfg_read_i32(FW_CFG_KERNEL_ADDR);
- size = fw_cfg_read_i32(FW_CFG_CMDLINE_SIZE);
- if (size) {
- fw_cfg_read(FW_CFG_CMDLINE_DATA, cmdline, size);
- }
- cmdline[size] = '\0';
- qemu_cmdline = (uint32_t)cmdline;
- boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
- /* Initialiase openprom romvec */
- romvec = init_openprom();
- /* Setup nvram variables */
- push_str("/options");
- fword("find-device");
- switch (boot_device) {
- case 'a':
- push_str("floppy");
- break;
- case 'c':
- push_str("disk");
- break;
- default:
- case 'd':
- push_str("cdrom");
- break;
- case 'n':
- push_str("net");
- break;
- }
- /* bootpath/bootargs should be set to NVRAM default */
- fword("boot-device");
fword("encode-string");
- push_str("bootpath");
- push_str("boot-device");
fword("property");
- fword("boot-args");
- push_str("");
fword("encode-string");
- push_str("bootargs");
- push_str("boot-file");
fword("property");
- boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
bind_func("platform-boot", boot );
- bind_func("(go)", go );
}
int openbios(void)
Modified: trunk/openbios-devel/arch/sparc64/boot.c
--- trunk/openbios-devel/arch/sparc64/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -8,10 +8,6 @@ #include "libc/diskio.h" #include "libc/vsprintf.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"
uint64_t kernel_image; @@ -19,68 +15,10 @@ uint64_t qemu_cmdline; uint64_t cmdline_size; char boot_device; -void *boot_notes = NULL; +void *elf_boot_notes = NULL; extern int sparc64_of_client_interface( int *params );
-static int try_path(const char *path, char *param) -{
- ucell valid;
- ihandle_t dev;
- /* Open device used by this path */
- dev = open_dev(path);
-#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, dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FCODE
- /* Fcode loader */
- fcode_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FORTH
- /* Forth loader */
- forth_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
- close_dev(dev);
- return 0;
-start_image:
- go();
- return -1;
-}
void go(void) { ucell address, type, size; @@ -99,7 +37,7 @@ switch (type) { case 0x0: /* Start ELF boot image */
- image_retval = start_elf(address, (uint64_t)&boot_notes);
- image_retval = start_elf(address, (uint64_t)&elf_boot_notes);
break;
case 0x1: @@ -136,19 +74,23 @@
void boot(void) {
- char *path=pop_fstr_copy(), *param;
- char altpath[256];
- int result;
char *path, *param;
/* Copy the incoming path */
fword("2dup");
path = pop_fstr_copy();
/* Boot preloaded kernel */
if (kernel_size) { void (*entry)(unsigned long p1, unsigned long p2, unsigned long p3,
- unsigned long p4, unsigned long p5);;
- unsigned long p4, unsigned long p5);
printk("[sparc64] Kernel already loaded\n"); entry = (void *) (unsigned long)kernel_image; entry(0, 0, 0, 0, (unsigned long)&sparc64_of_client_interface); }
- /* Invoke Linux directly -- probably not supported */
if(!path) { /* No path specified, so grab defaults from /chosen */ push_str("bootpath"); @@ -175,20 +117,9 @@ POP(); param = pop_fstr_copy(); }
- printk("[sparc64] Booting file '%s' ", path);
- if (param)
- printk("with parameters '%s'\n", param);
- else
- printk("without parameters.\n");
- result = try_path(path, param);
- if (!result) {
- snprintf(altpath, sizeof(altpath), "%s:f", path);
- try_path(altpath, param);
- }
- printk("Unsupported image format\n");
- /* Invoke platform-specific Linux loader */
- linux_load(&sys_info, path, param);
free(path); }
Modified: trunk/openbios-devel/arch/sparc64/linux_load.c
--- trunk/openbios-devel/arch/sparc64/linux_load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/linux_load.c Sun Aug 1 17:13:48 2010 (r828) @@ -618,6 +618,12 @@ return LOADER_NOT_SUPPORT; }
- debug("[sparc64] Booting kernel '%s' ", file);
- if (cmdline)
- debug("with parameters '%s'\n", cmdline);
- else
- debug("without parameters.\n");
params = phys_to_virt(LINUX_PARAM_LOC); init_linux_params(params, &hdr); set_memory_size(params, info);
Modified: trunk/openbios-devel/arch/sparc64/openbios.c
--- trunk/openbios-devel/arch/sparc64/openbios.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/sparc64/openbios.c Sun Aug 1 17:13:48 2010 (r828) @@ -374,7 +374,6 @@ { uint32_t size = 0; const struct cpudef *cpu;
- const char *bootpath;
char buf[256]; uint32_t temp; uint64_t ram_size; @@ -492,34 +491,15 @@ push_str("boot-device"); fword("property");
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
- if (boot_device == 'c')
- bootpath = "disk:a";
- else
- bootpath = "cdrom:a";
- push_str(bootpath);
- fword("encode-string");
- push_str("bootpath");
- fword("property");
- /* bootpath/bootargs should be set to NVRAM default */
- fword("boot-device");
- fword("encode-string");
- push_str("bootpath");
- fword("property");
- fword("boot-args");
- fword("encode-string");
- push_str("bootargs");
- fword("property");
push_str(obio_cmdline); fword("encode-string");
- push_str("bootargs");
- push_str("boot-file");
fword("property");
- /* Set up other properties */
- push_str("/chosen");
- fword("find-device");
if (fw_cfg_read_i16(FW_CFG_NOGRAPHIC)) { stdin_path = stdout_path = "ttya"; } else {
Modified: trunk/openbios-devel/arch/x86/boot.c
--- trunk/openbios-devel/arch/x86/boot.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/arch/x86/boot.c Sun Aug 1 17:13:48 2010 (r828) @@ -12,71 +12,9 @@ #include "arch/common/nvram.h" #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"
-void *boot_notes = NULL;
-static int try_path(const char *path, char *param) -{
- ucell valid;
- ihandle_t dev;
- /* Open device used by this path */
- dev = open_dev(path);
-#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, dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FCODE
- /* Fcode loader */
- fcode_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
-#ifdef CONFIG_LOADER_FORTH
- /* Forth loader */
- forth_load(dev);
- feval("state-valid @");
- valid = POP();
- if (valid)
- goto start_image;
-#endif
- close_dev(dev);
- return 0;
-start_image:
- go();
- return -1;
-}
+void *elf_boot_notes = NULL;
void go(void) { @@ -133,24 +71,6 @@
void boot(void) {
- char *path=pop_fstr_copy(), *param;
- if(!path) {
- printk("[x86] Booting default not supported.\n");
- return;
- }
- param = strchr(path, ' ');
- if(param) {
- *param = '\0';
- param++;
- }
- printk("[x86] Booting file '%s' with parameters '%s'\n",path, param);
- try_path(path, param);
- printk("Unsupported image format\n");
- free(path);
- /* No platform-specific boot code */
- return;
}
Modified: trunk/openbios-devel/forth/admin/userboot.fs
--- trunk/openbios-devel/forth/admin/userboot.fs Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/forth/admin/userboot.fs Sun Aug 1 17:13:48 2010 (r828) @@ -1,16 +1,15 @@ \ 7.4.3.5 User commands for booting
-: boot ( "{param-text}<cr>" -- )
- (encode-bootpath)
+: boot ( "{param-text}<cr>" -- )
- (encode-bootpath) \ Setup bootpath/bootargs
s" platform-boot" $find if
- execute
- else
- 2drop
- cr ." Booting " type cr
- ." ... not supported on this system." cr
- execute \ Execute platform-specific boot code
then
- $load \ load and go
- go
;
\ : diagnostic-mode? ( -- diag? ) \ ;
Modified: trunk/openbios-devel/forth/debugging/client.fs
--- trunk/openbios-devel/forth/debugging/client.fs Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/forth/debugging/client.fs Sun Aug 1 17:13:48 2010 (r828) @@ -58,24 +58,55 @@ : (encode-bootpath) ( "{params}<cr>" -- bootpath-str bootpath-len) \ Parse the current input buffer of a load/boot command and set both \ the bootargs and bootpath properties as appropriate.
- bl parse dup if
- 2dup encode-string
- " /chosen" (find-dev) if
- " bootpath" rot (property)
- then
- then
- linefeed parse dup if
- encode-string
- " /chosen" (find-dev) if
- " bootargs" rot (property)
- then
- else
- cr
- \ bootpath
- bl parse dup 0= if
- \ None specified. As per IEEE-1275 specification, search through each value
- \ in boot-device and use the first that returns a valid ihandle on open.
- s" boot-device" $find drop execute
- bl left-split
- begin
- dup
- while
- 2dup s" Trying " type type s" ..." type cr
- 2dup open-dev ?dup if
- close-dev
- 2swap drop 0 \ Fake end of string so we exit loop
- else
- 2drop
- bl left-split
- then
- repeat
2drop
- else
- 0 0 2swap \ Fake (empty) parse string
- then
- \ Set the bootpath property
- 2dup encode-string
- " /chosen" (find-dev) if
- " bootpath" rot (property)
- then
- \ bootargs
- linefeed parse dup 0= if
- \ None specified, use default from nvram
- 2drop s" boot-file" $find drop execute
then
- \ Set the bootargs property
- encode-string
- " /chosen" (find-dev) if
- " bootargs" rot (property)
- then
- \ Remove the remaining string
- 2swap 2drop
;
-: load ( "{params}<cr>" -- )
- (encode-bootpath)
+: $load ( devstr len ) open-dev ( ihandle ) dup 0= if drop @@ -89,6 +120,11 @@ init-program ;
+: load ( "{params}<cr>" -- )
- (encode-bootpath)
- $load
+;
: dir ( "{paths}<cr>" -- ) linefeed parse split-path-device
Modified: trunk/openbios-devel/include/libopenbios/elf_load.h
--- trunk/openbios-devel/include/libopenbios/elf_load.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/include/libopenbios/elf_load.h Sun Aug 1 17:13:48 2010 (r828) @@ -21,7 +21,7 @@ #include "asm/elf.h" #include "libopenbios/sys_info.h"
-extern int elf_load(struct sys_info *info, const char *filename, const char *cmdline, void **boot_notes); +extern int elf_load(struct sys_info *info, ihandle_t dev, const char *cmdline, void **boot_notes); extern void elf_init_program(void); extern int is_elf(Elf_ehdr *ehdr); extern int find_elf(Elf_ehdr *ehdr);
Modified: trunk/openbios-devel/include/libopenbios/sys_info.h
--- trunk/openbios-devel/include/libopenbios/sys_info.h Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/include/libopenbios/sys_info.h Sun Aug 1 17:13:48 2010 (r828) @@ -22,6 +22,7 @@ unsigned long *dict_end; };
+extern void *elf_boot_notes; extern struct sys_info sys_info;
void collect_elfboot_info(struct sys_info *info);
Modified: trunk/openbios-devel/libopenbios/elf_load.c
--- trunk/openbios-devel/libopenbios/elf_load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/libopenbios/elf_load.c Sun Aug 1 17:13:48 2010 (r828) @@ -368,7 +368,7 @@ }
int -elf_load(struct sys_info *info, const char *filename, const char *cmdline, void **boot_notes) +elf_load(struct sys_info *info, ihandle_t dev, const char *cmdline, void **boot_notes) { Elf_ehdr ehdr; Elf_phdr *phdr = NULL; @@ -382,7 +382,7 @@ /* Mark the saved-program-state as invalid */ feval("0 state-valid !");
- fd = open_io(filename);
- fd = open_ih(dev);
if (!fd) goto out;
Modified: trunk/openbios-devel/libopenbios/load.c
--- trunk/openbios-devel/libopenbios/load.c Sun Aug 1 16:37:04 2010 (r827) +++ trunk/openbios-devel/libopenbios/load.c Sun Aug 1 17:13:48 2010 (r828) @@ -20,6 +20,10 @@ #include "libopenbios/sys_info.h" #include "libopenbios/load.h"
+#ifdef CONFIG_LOADER_ELF +#include "libopenbios/elf_load.h" +#endif
#ifdef CONFIG_LOADER_AOUT #include "libopenbios/aout_load.h" #endif @@ -38,6 +42,21 @@ void load(ihandle_t dev) { /* Invoke the loaders on the specified device */
- char *param;
+#ifdef CONFIG_LOADER_ELF
- /* Grab the boot arguments */
- push_str("bootargs");
- push_str("/chosen");
- fword("(find-dev)");
- POP();
- fword("get-package-property");
- POP();
- param = pop_fstr_copy();
- elf_load(&sys_info, dev, param, &elf_boot_notes);
+#endif
#ifdef CONFIG_LOADER_AOUT aout_load(&sys_info, dev);
-- OpenBIOS http://openbios.org/ Mailinglist: http://lists.openbios.org/mailman/listinfo Free your System - May the Forth be with you
-- OpenBIOS http://openbios.org/ Mailinglist: http://lists.openbios.org/mailman/listinfo Free your System - May the Forth be with you