]> git.ozlabs.org Git - yaboot.git/blobdiff - second/yaboot.c
Pegasos and partition numbering
[yaboot.git] / second / yaboot.c
index 4ade0776383399d486a0c517a4fed507847ea0fe..d6e8017bae35b01be0ab916ae0eef588b8a3472f 100644 (file)
@@ -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;
@@ -178,6 +181,7 @@ yaboot_start (unsigned long r3, unsigned long r4, unsigned long r5)
 {
      int result;
      void* malloc_base = NULL;
+     unsigned long addr;
      prom_handle root;
 
      /* OF seems to do it, but I'm not very confident */
@@ -196,7 +200,10 @@ yaboot_start (unsigned long r3, unsigned long r4, unsigned long r5)
      prom_init ((prom_entry) r5);
 
      /* Allocate some memory for malloc'ator */
-     malloc_base = prom_claim((void *)MALLOCADDR, MALLOCSIZE, 0);
+     for (addr = MALLOCADDR; addr <= MALLOCADDR * 16 ;addr+=0x100000) {
+         malloc_base = prom_claim((void *)addr, MALLOCSIZE, 0);
+         if (malloc_base != (void *)-1) break;
+     }
      if (malloc_base == (void *)-1) {
          prom_printf("Can't claim malloc buffer (%d bytes at 0x%08x)\n",
                      MALLOCSIZE, MALLOCADDR);
@@ -219,7 +226,10 @@ yaboot_start (unsigned long r3, unsigned long r4, unsigned long r5)
      root = prom_finddevice("/");
      if (root != 0) {
          static char model[256];
-         if (prom_getprop(root, "device_type", model, 256 ) > 0 &&
+         if (prom_getprop(root, "CODEGEN,vendor", model, 256) > 0 &&
+             !strncmp("bplan", model, 5))
+              _machine = _MACH_bplan;
+         else if (prom_getprop(root, "device_type", model, 256 ) > 0 &&
              !strncmp("chrp", model, 4))
               _machine = _MACH_chrp;
          else {
@@ -455,7 +465,7 @@ static int load_my_config_file(struct boot_fspec_t *orig_fspec)
      struct bootp_packet *packet;
      int rc = 0;
      struct boot_fspec_t fspec = *orig_fspec;
-     char *cfgpath = (_machine == _MACH_chrp) ? "/etc/" : "";
+     char *cfgpath = (_machine == _MACH_chrp || _machine == _MACH_bplan) ? "/etc/" : "";
      int flen;
      int minlen;
 
@@ -667,7 +677,7 @@ int get_params(struct boot_param_t* params)
 
      cmdinit();
 
-     if (first) {
+     if (first && !fw_reboot_cnt) {
          first = 0;
          imagename = bootargs;
          word_split(&imagename, &params->args);
@@ -682,6 +692,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) {
@@ -718,7 +735,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)
@@ -779,6 +798,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;
 
@@ -1669,6 +1691,7 @@ int
 yaboot_main(void)
 {
      char *ptype;
+     char *endp;
      int conf_given = 0;
      char conf_path[1024];
 
@@ -1679,6 +1702,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
@@ -1722,11 +1750,13 @@ yaboot_main(void)
          prom_printf("%s: Unable to parse\n", bootdevice);
          return -1;
      }
+     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)
+         if (_machine == _MACH_chrp || _machine == _MACH_bplan)
              boot.file = "/etc/";
          else if (strlen(boot.file)) {
              if (!strncmp(boot.file, "\\\\", 2))