X-Git-Url: http://git.ozlabs.org/?p=yaboot.git;a=blobdiff_plain;f=second%2Fyaboot.c;h=66f288b82aea9eaff21c59ed1fd3bf52c26224b5;hp=8323bfd5aafabd5964e062fbf65ddf99bc10ba6c;hb=a9e02f948a7e3f8ada87e07a0c1a382805ad15c6;hpb=66ffb9d32d2acb3613594ef492d341b5bacf02e5 diff --git a/second/yaboot.c b/second/yaboot.c index 8323bfd..66f288b 100644 --- a/second/yaboot.c +++ b/second/yaboot.c @@ -114,6 +114,9 @@ int useconf = 0; char bootdevice[BOOTDEVSZ]; char bootoncelabel[1024]; char bootargs[1024]; +char bootlastlabel[BOOTLASTSZ] = {0}; +char fw_nbr_reboots[FW_NBR_REBOOTSZ] = {0}; +long fw_reboot_cnt = 0; char *password = NULL; struct boot_fspec_t boot; int _machine = _MACH_Pmac; @@ -297,6 +300,7 @@ void print_message_file(char *filename) } strncpy(msgpath, filename, sizeof(msgpath)); + msgfile = boot; /* Copy all the original paramters */ if (!parse_device_path(msgpath, defdev, defpart, "/etc/yaboot.msg", &msgfile)) { prom_printf("%s: Unable to parse\n", msgpath); goto done; @@ -467,6 +471,8 @@ static int load_my_config_file(struct boot_fspec_t *orig_fspec) int minlen; packet = prom_get_netinfo(); + if (!packet) + goto out; /* * First, try to match on mac address with the hardware type @@ -674,7 +680,7 @@ int get_params(struct boot_param_t* params) cmdinit(); - if (first) { + if (first && !fw_reboot_cnt) { first = 0; imagename = bootargs; word_split(&imagename, ¶ms->args); @@ -689,6 +695,13 @@ int get_params(struct boot_param_t* params) timeout = simple_strtol(q, NULL, 0); } + /* If this is a reboot due to FW detecting CAS changes then + * set timeout to 1. The last kernel booted will be booted + * again automatically. It should seem seamless to the user + */ + if (fw_reboot_cnt) + timeout = 1; + prom_printf("boot: "); c = -1; if (timeout != -1) { @@ -725,7 +738,9 @@ int get_params(struct boot_param_t* params) if (!imagename) { if (bootoncelabel[0] != 0) imagename = bootoncelabel; - else + else if (bootlastlabel[0] != 0) + imagename = bootlastlabel; + else imagename = cfg_get_default(); } if (imagename) @@ -786,6 +801,9 @@ int get_params(struct boot_param_t* params) if ( useconf && (!imagename || imagename[0] == 0 )) imagename = cfg_get_default(); + /* write the imagename out so it can be reused on reboot if necessary */ + prom_set_options("boot-last-label", imagename, strlen(imagename)); + label = 0; defdevice = boot.dev; @@ -973,6 +991,7 @@ int get_params(struct boot_param_t* params) if (!label && password) check_password ("To boot a custom image you must enter the password."); + params->kernel = boot; /* Copy all the original paramters */ if (!parse_device_path(imagepath, defdevice, defpart, "/vmlinux", ¶ms->kernel)) { prom_printf("%s: Unable to parse\n", imagepath); @@ -994,6 +1013,7 @@ int get_params(struct boot_param_t* params) strncpy(initrdpath, p, 1024); DEBUG_F("Parsing initrd path <%s>\n", initrdpath); + params->rd = boot; /* Copy all the original paramters */ if (!parse_device_path(initrdpath, defdevice, defpart, "/root.bin", ¶ms->rd)) { prom_printf("%s: Unable to parse\n", imagepath); @@ -1004,6 +1024,7 @@ int get_params(struct boot_param_t* params) if (p && *p) { DEBUG_F("Parsing sysmap path <%s>\n", p); strncpy(sysmappath, p, 1024); + params->sysmap = boot; /* Copy all the original paramters */ if (!parse_device_path(sysmappath, defdevice, defpart, "/boot/System.map", ¶ms->sysmap)) { prom_printf("%s: Unable to parse\n", imagepath); @@ -1591,7 +1612,7 @@ is_elf64(loadinfo_t *loadinfo) e->e_ident[EI_MAG3] == ELFMAG3 && e->e_ident[EI_CLASS] == ELFCLASS64 && e->e_ident[EI_DATA] == ELFDATA2MSB && - e->e_type == ET_EXEC && + (e->e_type == ET_EXEC || e->e_type == ET_DYN) && e->e_machine == EM_PPC64); } @@ -1676,6 +1697,7 @@ int yaboot_main(void) { char *ptype; + char *endp; int conf_given = 0; char conf_path[1024]; @@ -1686,6 +1708,11 @@ yaboot_main(void) DEBUG_F("/chosen/bootargs = %s\n", bootargs); prom_get_chosen("bootpath", bootdevice, BOOTDEVSZ); DEBUG_F("/chosen/bootpath = %s\n", bootdevice); + if (prom_get_options("ibm,client-architecture-support-reboot",fw_nbr_reboots, FW_NBR_REBOOTSZ) == -1 ) + prom_get_options("ibm,fw-nbr-reboots",fw_nbr_reboots, FW_NBR_REBOOTSZ); + fw_reboot_cnt = simple_strtol(fw_nbr_reboots,&endp,10); + if (fw_reboot_cnt > 0L) + prom_get_options("boot-last-label", bootlastlabel, BOOTLASTSZ); /* If conf= specified on command line, it overrides Usage: conf=device:partition,/path/to/conffile @@ -1729,13 +1756,13 @@ yaboot_main(void) prom_printf("%s: Unable to parse\n", bootdevice); return -1; } - if (_machine == _MACH_bplan) + if (_machine == _MACH_bplan && !conf_given) boot.part++; DEBUG_F("After parse_device_path: dev=%s, part=%d, file=%s\n", boot.dev, boot.part, boot.file); if (!conf_given) { - if (_machine == _MACH_chrp || machine == _MACH_bplan) + if (_machine == _MACH_chrp || _machine == _MACH_bplan) boot.file = "/etc/"; else if (strlen(boot.file)) { if (!strncmp(boot.file, "\\\\", 2))