]> git.proxmox.com Git - grub2.git/commitdiff
Port yaboot logic for various powerpc machine types
authorColin Watson <cjwatson@debian.org>
Tue, 28 Jan 2014 14:40:02 +0000 (14:40 +0000)
committerColin Watson <cjwatson@debian.org>
Mon, 31 Mar 2014 14:18:14 +0000 (15:18 +0100)
Some powerpc machines require not updating the NVRAM, and some require
adding a CHRP note.  This can be handled by existing grub-install
command-line options, but it's friendlier to detect this automatically.

Forwarded: no
Last-Update: 2014-01-28

Patch-Name: install_powerpc_machtypes.patch

grub-core/osdep/basic/platform.c
grub-core/osdep/linux/platform.c
grub-core/osdep/windows/platform.c
include/grub/util/install.h
util/grub-install.c

index 4b5502aeb73e2b763fcc097ee144e6959bf33430..2ab907976356a7cd0a98a61557ca9195e3dfc42a 100644 (file)
@@ -24,3 +24,8 @@ grub_install_get_default_x86_platform (void)
   return "i386-pc";
 }
 
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+  return "generic";
+}
index 175da72bcb0bda5f4ca7949bf7d21601204d1989..185f971bade140e37da32dfc77a517b03c21a0e4 100644 (file)
@@ -24,6 +24,7 @@
 #include <grub/emu/misc.h>
 #include <sys/types.h>
 #include <dirent.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -108,3 +109,66 @@ grub_install_get_default_x86_platform (void)
   grub_util_info ("... not found");
   return "i386-pc";
 }
+
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+  FILE *fp;
+  char *buf = NULL;
+  size_t len = 0;
+  const char *machtype = "generic";
+
+  fp = grub_util_fopen ("/proc/cpuinfo", "r");
+  if (! fp)
+    return machtype;
+
+  while (getline (&buf, &len, fp) > 0)
+    {
+      if (strncmp (buf, "pmac-generation",
+                  sizeof ("pmac-generation") - 1) == 0)
+       {
+         if (strstr (buf, "NewWorld"))
+           {
+             machtype = "pmac_newworld";
+             break;
+           }
+         if (strstr (buf, "OldWorld"))
+           {
+             machtype = "pmac_oldworld";
+             break;
+           }
+       }
+
+      if (strncmp (buf, "motherboard", sizeof ("motherboard") - 1) == 0 &&
+         strstr (buf, "AAPL"))
+       {
+         machtype = "pmac_oldworld";
+         break;
+       }
+
+      if (strncmp (buf, "machine", sizeof ("machine") - 1) == 0 &&
+         strstr (buf, "CHRP IBM"))
+       {
+         machtype = "chrp_ibm";
+         break;
+       }
+
+      if (strncmp (buf, "platform", sizeof ("platform") - 1) == 0)
+       {
+         if (strstr (buf, "Maple"))
+           {
+             machtype = "maple";
+             break;
+           }
+         if (strstr (buf, "Cell"))
+           {
+             machtype = "cell";
+             break;
+           }
+       }
+    }
+
+  free (buf);
+  fclose (fp);
+  return machtype;
+}
index f2b9d714329c56c887d98bfbd7d53803e7640bb3..cf2e39c79946ae66f09c828996e354e6799a9cbf 100644 (file)
@@ -128,6 +128,12 @@ grub_install_get_default_x86_platform (void)
     return "i386-efi";
 }
 
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+  return "generic";
+}
+
 static void *
 get_efi_variable (const wchar_t *varname, ssize_t *len)
 {
index bc987aadc165bfdd85bf39ed1fad603f0d95b1eb..2de6c9069fc6e915014df34cbaf6b98bbef5a094 100644 (file)
@@ -204,6 +204,9 @@ grub_install_create_envblk_file (const char *name);
 const char *
 grub_install_get_default_x86_platform (void);
 
+const char *
+grub_install_get_default_powerpc_machtype (void);
+
 void
 grub_install_register_efi (grub_device_t efidir_grub_dev,
                           const char *efifile_path,
index 1f27b65fb81a0d39c80e763af2be141efcf9d3bb..01170d3be597110d396362a72a91c98f406a61be 100644 (file)
@@ -58,6 +58,7 @@ static char *target;
 static int removable = 0;
 static int recheck = 0;
 static int update_nvram = 1;
+static int chrp_note = 0;
 static char *install_device = NULL;
 static char *debug_image = NULL;
 static char *rootdir = NULL;
@@ -1143,7 +1144,21 @@ main (int argc, char *argv[])
 
   if (platform == GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
     {
+      const char *machtype = grub_install_get_default_powerpc_machtype ();
       int is_guess = 0;
+
+      if (strcmp (machtype, "pmac_oldworld") == 0)
+       update_nvram = 0;
+      else if (strcmp (machtype, "chrp_ibm") == 0)
+       {
+         update_nvram = 0;
+         chrp_note = 1;
+       }
+      else if (strcmp (machtype, "cell") == 0)
+       update_nvram = 0;
+      else if (strcmp (machtype, "generic") == 0)
+       update_nvram = 0;
+
       if (!macppcdir)
        {
          char *d;
@@ -1613,7 +1628,7 @@ main (int argc, char *argv[])
                                /* output */ imgfile,
                                /* memdisk */ NULL,
                                have_load_cfg ? load_cfg : NULL,
-                               /* image target */ mkimage_target, 0);
+                               /* image target */ mkimage_target, chrp_note);
   /* Backward-compatibility kludges.  */
   switch (platform)
     {