]> git.ozlabs.org Git - yaboot.git/commitdiff
The CAS (Client-Architecture Support) call tells firmware what capabilities the
authorPaul Nasrat <pauln@truemesh.com>
Fri, 4 Jan 2008 13:00:19 +0000 (13:00 +0000)
committerPaul Nasrat <pauln@truemesh.com>
Fri, 4 Jan 2008 13:00:19 +0000 (13:00 +0000)
OS has.  These capabilities result in different modes which the device-tree is
configured in, as well as what processor capabilities are presented.  So, if
the capabilities are different from what was previously booted, firmware has to
reboot to reconfigure the device-tree.  The second boot will have the updated
device-tree and we can boot as normal.

When this firmware initiated reboot occurs yaboot will now boot the same kernel
as the previous boot attempt with no action by the user needed.  I have
successfully booted on POWER5 and POWER6 machines using various levels of the
kernel.

Patch from: Mike Wolf <mjw@linux.vnet.ibm.com>

include/prom.h
second/yaboot.c

index 6e4d890c49b0d28ad2f5dcfe88280b5f61be4829..eacee7708c1f9300e87b7cca8db84f01aad0d00a 100644 (file)
@@ -38,6 +38,8 @@ typedef void *phandle;
 #define BOOTDEVSZ               (2048) /* iscsi args can be in excess of 1040 bytes */
 #define TOK_ISCSI               "iscsi"
 #define PROM_CLAIM_MAX_ADDR    0x8000000
 #define BOOTDEVSZ               (2048) /* iscsi args can be in excess of 1040 bytes */
 #define TOK_ISCSI               "iscsi"
 #define PROM_CLAIM_MAX_ADDR    0x8000000
+#define BOOTLASTSZ             1024
+#define FW_NBR_REBOOTSZ                4
 
 struct prom_args;
 typedef int (*prom_entry)(struct prom_args *);
 
 struct prom_args;
 typedef int (*prom_entry)(struct prom_args *);
index 46ab0efca9c00cdf3826d4111c20453dce86c093..5fc1213114d0a651123d1b71cba1eb9b8fb723a6 100644 (file)
@@ -114,6 +114,9 @@ int useconf = 0;
 char bootdevice[BOOTDEVSZ];
 char bootoncelabel[1024];
 char bootargs[1024];
 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;
 char *password = NULL;
 struct boot_fspec_t boot;
 int _machine = _MACH_Pmac;
@@ -674,7 +677,7 @@ int get_params(struct boot_param_t* params)
 
      cmdinit();
 
 
      cmdinit();
 
-     if (first) {
+     if (first && !fw_reboot_cnt) {
          first = 0;
          imagename = bootargs;
          word_split(&imagename, &params->args);
          first = 0;
          imagename = bootargs;
          word_split(&imagename, &params->args);
@@ -689,6 +692,13 @@ int get_params(struct boot_param_t* params)
               timeout = simple_strtol(q, NULL, 0);
      }
 
               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) {
      prom_printf("boot: ");
      c = -1;
      if (timeout != -1) {
@@ -725,7 +735,9 @@ int get_params(struct boot_param_t* params)
          if (!imagename) {
               if (bootoncelabel[0] != 0)
                    imagename = bootoncelabel;
          if (!imagename) {
               if (bootoncelabel[0] != 0)
                    imagename = bootoncelabel;
-              else
+              else if (bootlastlabel[0] != 0)
+                         imagename = bootlastlabel;
+               else
                    imagename = cfg_get_default();
          }
          if (imagename)
                    imagename = cfg_get_default();
          }
          if (imagename)
@@ -786,6 +798,9 @@ int get_params(struct boot_param_t* params)
      if ( useconf && (!imagename || imagename[0] == 0 ))
          imagename = cfg_get_default();
 
      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;
 
      label = 0;
      defdevice = boot.dev;
 
@@ -1676,6 +1691,7 @@ int
 yaboot_main(void)
 {
      char *ptype;
 yaboot_main(void)
 {
      char *ptype;
+     char *endp;
      int conf_given = 0;
      char conf_path[1024];
 
      int conf_given = 0;
      char conf_path[1024];
 
@@ -1686,6 +1702,10 @@ yaboot_main(void)
      DEBUG_F("/chosen/bootargs = %s\n", bootargs);
      prom_get_chosen("bootpath", bootdevice, BOOTDEVSZ);
      DEBUG_F("/chosen/bootpath = %s\n", bootdevice);
      DEBUG_F("/chosen/bootargs = %s\n", bootargs);
      prom_get_chosen("bootpath", bootdevice, BOOTDEVSZ);
      DEBUG_F("/chosen/bootpath = %s\n", bootdevice);
+     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
 
      /* If conf= specified on command line, it overrides
         Usage: conf=device:partition,/path/to/conffile