[grub2/f17: 26/27] Add IBM PPC fixes.

Peter Jones pjones at fedoraproject.org
Wed Jun 6 15:24:00 UTC 2012


commit fc6558ce1a41dea4b775820ef0e26863b92f5405
Author: Peter Jones <pjones at redhat.com>
Date:   Wed Jun 6 11:08:26 2012 -0400

    Add IBM PPC fixes.

 grub-2.00-ppc-hints.patch                |  157 +++++++++++++++++++++++++++++
 grub-2.00-support-vscsi-on-ibm-ppc.patch |  162 ++++++++++++++++++++++++++++++
 grub2.spec                               |    7 +-
 3 files changed, 325 insertions(+), 1 deletions(-)
---
diff --git a/grub-2.00-ppc-hints.patch b/grub-2.00-ppc-hints.patch
new file mode 100644
index 0000000..448a637
--- /dev/null
+++ b/grub-2.00-ppc-hints.patch
@@ -0,0 +1,157 @@
+From 1f1ddb93b57618a20b2adf7096ca1b21e2d252cc Mon Sep 17 00:00:00 2001
+From: Vladimir Serbinenko <phcoder at gmail.com>
+Date: Wed, 6 Jun 2012 11:12:12 -0400
+Subject: [PATCH] Fixes for IBM PPC ieee1275 support.
+
+---
+ ChangeLog              |   17 +++++++++++++++++
+ util/grub-probe.c      |   19 ++++++++++++++-----
+ util/ieee1275/ofpath.c |   39 +++++++++++++++++++++++++++++++++------
+ 3 files changed, 64 insertions(+), 11 deletions(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index e00c07c..4568bdb 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,20 @@
++2012-06-05  Vladimir Serbinenko  <phcoder at gmail.com>
++
++	* util/grub-probe.c (escape_of_path): Don't add ieee1275/.
++	(probe): Add ieee1275 to OFW devices.
++
++2012-06-04  Vladimir Serbinenko  <phcoder at gmail.com>
++
++	* util/ieee1275/ofpath.c (of_path_of_scsi): Fix wrong format specifier.
++
++2012-06-04  Vladimir Serbinenko  <phcoder at gmail.com>
++
++	Handle IBM OFW path.
++
++	* util/ieee1275/ofpath.c (find_obppath): Use devspec if obppath isn't
++	available.
++	(of_path_of_scsi): Handle vdevice.
++
+ 2012-05-24  Peter Jones <pjones at redhat.com>
+ 
+ 	* grub-core/Makefile.core.def: add efifwsetup module
+diff --git a/util/grub-probe.c b/util/grub-probe.c
+index 8beb1bc..4db259b 100644
+--- a/util/grub-probe.c
++++ b/util/grub-probe.c
+@@ -157,11 +157,10 @@ escape_of_path (const char *orig_path)
+   if (!strchr (orig_path, ','))
+     return (char *) xstrdup (orig_path);
+ 
+-  new_path = xmalloc (strlen (orig_path) * 2 + sizeof ("ieee1275/"));
++  new_path = xmalloc (strlen (orig_path) * 2 + 1);
+ 
+   p = orig_path;
+-  grub_strcpy (new_path, "ieee1275/");
+-  d = new_path + sizeof ("ieee1275/") - 1;
++  d = new_path;
+   while ((c = *p++) != '\0')
+     {
+       if (c == ',')
+@@ -499,9 +498,14 @@ probe (const char *path, char **device_names, char delim)
+ 
+ 	  if (ofpath)
+ 	    {
++	      char *tmp = xmalloc (strlen (ofpath) + sizeof ("ieee1275/"));
++	      char *p;
++	      p = stpcpy (tmp, "ieee1275/");
++	      strcpy (p, ofpath);
+ 	      printf ("--hint-ieee1275='");
+-	      print_full_name (ofpath, dev);
++	      print_full_name (tmp, dev);
+ 	      printf ("' ");
++	      free (tmp);
+ 	    }
+ 
+ 	  biosname = guess_bios_drive (*curdev);
+@@ -611,7 +615,12 @@ probe (const char *path, char **device_names, char delim)
+ 
+ 	  if (ofpath)
+ 	    {
+-	      print_full_name (ofpath, dev);
++	      char *tmp = xmalloc (strlen (ofpath) + sizeof ("ieee1275/"));
++	      char *p;
++	      p = stpcpy (tmp, "ieee1275/");
++	      strcpy (p, ofpath);
++	      print_full_name (tmp, dev);
++	      free (tmp);
+ 	      putchar (delim);
+ 	    }
+ 
+diff --git a/util/ieee1275/ofpath.c b/util/ieee1275/ofpath.c
+index 03baced..c7f7cdf 100644
+--- a/util/ieee1275/ofpath.c
++++ b/util/ieee1275/ofpath.c
+@@ -65,7 +65,9 @@ grub_util_info (const char *fmt, ...)
+   fputc ('\n', stderr);
+ }
+ 
++#define grub_util_warn grub_util_info
+ #define _(x) x
++#define xstrdup strdup
+ #endif
+ 
+ static void
+@@ -120,6 +122,12 @@ find_obppath (const char *sysfs_path_orig)
+       fd = open(path, O_RDONLY);
+       if (fd < 0 || fstat (fd, &st) < 0)
+ 	{
++	  snprintf(path, path_size, "%s/devspec", sysfs_path);
++	  fd = open(path, O_RDONLY);
++	}
++
++      if (fd < 0 || fstat (fd, &st) < 0)
++	{
+ 	  kill_trailing_dir(sysfs_path);
+ 	  if (!strcmp(sysfs_path, "/sys"))
+ 	    {
+@@ -391,17 +399,36 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev
+     disk_name = "disk";
+ 
+   digit_string = trailing_digits (device);
+-  if (*digit_string == '\0')
++  if (strncmp (of_path, "/vdevice/", sizeof ("/vdevice/") - 1) == 0)
+     {
+-      snprintf(disk, sizeof (disk), "/%s@%x,%d", disk_name, tgt, lun);
++      unsigned long id = 0x8000 | (tgt << 8) | (bus << 5) | lun;
++      if (*digit_string == '\0')
++	{
++	  snprintf(disk, sizeof (disk), "/%s@%04lx000000000000", disk_name, id);
++	}
++      else
++	{
++	  int part;
++
++	  sscanf(digit_string, "%d", &part);
++	  snprintf(disk, sizeof (disk),
++		   "/%s@%04lx000000000000:%c", disk_name, id, 'a' + (part - 1));
++	}
+     }
+   else
+     {
+-      int part;
++      if (*digit_string == '\0')
++	{
++	  snprintf(disk, sizeof (disk), "/%s@%x,%d", disk_name, tgt, lun);
++	}
++      else
++	{
++	  int part;
+ 
+-      sscanf(digit_string, "%d", &part);
+-      snprintf(disk, sizeof (disk),
+-	       "/%s@%x,%d:%c", disk_name, tgt, lun, 'a' + (part - 1));
++	  sscanf(digit_string, "%d", &part);
++	  snprintf(disk, sizeof (disk),
++		   "/%s@%x,%d:%c", disk_name, tgt, lun, 'a' + (part - 1));
++	}
+     }
+   strcat(of_path, disk);
+   return of_path;
+-- 
+1.7.10.2
+
diff --git a/grub-2.00-support-vscsi-on-ibm-ppc.patch b/grub-2.00-support-vscsi-on-ibm-ppc.patch
new file mode 100644
index 0000000..c571058
--- /dev/null
+++ b/grub-2.00-support-vscsi-on-ibm-ppc.patch
@@ -0,0 +1,162 @@
+From 6eb367e8ca2799f1ebfaeaa0fe69fe79c1aea884 Mon Sep 17 00:00:00 2001
+From: Vladimir Serbinenko <phcoder at gmail.com>
+Date: Tue, 6 Dec 2005 15:22:29 +0000
+Subject: [PATCH] Support vscsi on IBM machines.
+
+Support vscsi on IBM machines.
+Tested by: Paulo Flabiano Smorigo.
+Crucial information about API supplied by: Coleen <Last name unknown>.
+Reviewed by: Coleen <Last name unknown>.
+---
+ ChangeLog                        |    8 ++++
+ grub-core/disk/ieee1275/ofdisk.c |   91 ++++++++++++++++++++++++++++++--------
+ 2 files changed, 80 insertions(+), 19 deletions(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index 4568bdb..6765e38 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,11 @@
++2012-06-06  Vladimir Serbinenko  <phcoder at gmail.com>
++
++	* grub-core/disk/ieee1275/ofdisk.c (scan): Support vscsi on IBM
++	machines.
++	Tested by: Paulo Flabiano Smorigo.
++	Crucial information about API supplied by: Coleen <Last name unknown>.
++	Reviewed by: Coleen <Last name unknown>.
++
+ 2012-06-05  Vladimir Serbinenko  <phcoder at gmail.com>
+ 
+ 	* util/grub-probe.c (escape_of_path): Don't add ieee1275/.
+diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
+index 6b734f7..eb3ff4f 100644
+--- a/grub-core/disk/ieee1275/ofdisk.c
++++ b/grub-core/disk/ieee1275/ofdisk.c
+@@ -115,33 +115,28 @@ ofdisk_hash_add (char *devpath, char *curcan)
+ static void
+ scan (void)
+ {
+-  auto int dev_iterate_real (struct grub_ieee1275_devalias *alias,
+-			     int use_name);
++  auto int dev_iterate_real (const char *name, const char *path);
+ 
+-  int dev_iterate_real (struct grub_ieee1275_devalias *alias, int use_name)
++  int dev_iterate_real (const char *name, const char *path)
+     {
+       struct ofdisk_hash_ent *op;
+ 
++      grub_dprintf ("disk", "disk name = %s, path = %s\n", name,
++		    path);
+ 
+-      if (grub_strcmp (alias->type, "block") != 0)
+-	return 0;
+-
+-      grub_dprintf ("disk", "disk name = %s, path = %s\n", alias->name,
+-		    alias->path);
+-
+-      op = ofdisk_hash_find (alias->path);
++      op = ofdisk_hash_find (path);
+       if (!op)
+ 	{
+-	  char *name = grub_strdup (use_name ? alias->name : alias->path);
+-	  char *can = grub_strdup (alias->path);
+-	  if (!name || !can)
++	  char *name_dup = grub_strdup (name);
++	  char *can = grub_strdup (path);
++	  if (!name_dup || !can)
+ 	    {
+ 	      grub_errno = GRUB_ERR_NONE;
+-	      grub_free (name);
++	      grub_free (name_dup);
+ 	      grub_free (can);
+ 	      return 0;
+ 	    }
+-	  op = ofdisk_hash_add (name, can);
++	  op = ofdisk_hash_add (name_dup, can);
+ 	}
+       return 0;
+     }
+@@ -149,18 +144,76 @@ scan (void)
+   auto int dev_iterate_alias (struct grub_ieee1275_devalias *alias);
+   int dev_iterate_alias (struct grub_ieee1275_devalias *alias)
+   {
+-    return dev_iterate_real (alias, 1);
++    if (grub_strcmp (alias->type, "block") != 0)
++      return 0;
++    return dev_iterate_real (alias->name, alias->path);
+   }
+ 
+   auto int dev_iterate (struct grub_ieee1275_devalias *alias);
+   int dev_iterate (struct grub_ieee1275_devalias *alias)
+   {
+-    return dev_iterate_real (alias, 0);
++    if (grub_strcmp (alias->type, "vscsi") == 0)
++      {
++	static grub_ieee1275_ihandle_t ihandle;
++	struct set_color_args
++	{
++	  struct grub_ieee1275_common_hdr common;
++	  grub_ieee1275_cell_t method;
++	  grub_ieee1275_cell_t ihandle;
++	  grub_ieee1275_cell_t catch_result;
++	  grub_ieee1275_cell_t nentries;
++	  grub_ieee1275_cell_t table;
++	}
++	args;
++	char *buf, *bufptr;
++	unsigned i;
++
++	if (grub_ieee1275_open (alias->path, &ihandle))
++	  return 0;
++
++	INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
++	args.method = (grub_ieee1275_cell_t) "vscsi-report-luns";
++	args.ihandle = ihandle;
++	args.table = 0;
++	args.nentries = 0;
++
++	if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
++	  {
++	    grub_ieee1275_close (ihandle);
++	    return 0;
++	  }
++
++	buf = grub_malloc (grub_strlen (alias->path) + 32);
++	if (!buf)
++	  return 0;
++	bufptr = grub_stpcpy (buf, alias->path);
++
++	for (i = 0; i < args.nentries; i++)
++	  {
++	    grub_uint64_t *ptr;
++
++	    ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i);
++	    while (*ptr)
++	      {
++		grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
++		if (dev_iterate_real (buf, buf))
++		  return 1;
++	      }
++	  }
++	grub_ieee1275_close (ihandle);
++	grub_free (buf);
++	return 0;
++      }
++
++    if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS)
++	&& grub_strcmp (alias->type, "block") == 0)
++      return dev_iterate_real (alias->path, alias->path);
++
++    return grub_children_iterate (alias->path, dev_iterate);
+   }
+ 
+   grub_devalias_iterate (dev_iterate_alias);
+-  if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS))
+-    grub_ieee1275_devices_iterate (dev_iterate);
++  grub_children_iterate ("/", dev_iterate);
+ }
+ 
+ static int
+-- 
+1.7.10.2
+
diff --git a/grub2.spec b/grub2.spec
index cf28ae9..9a18cdb 100644
--- a/grub2.spec
+++ b/grub2.spec
@@ -39,7 +39,7 @@
 Name:           grub2
 Epoch:          1
 Version:        2.0
-Release:        0.33.beta6%{?dist}
+Release:        0.34.beta6%{?dist}
 Summary:        Bootloader with support for Linux, Multiboot and more
 
 Group:          System Environment/Base
@@ -59,6 +59,8 @@ Patch11:	grub-2.00-Add-fwsetup.patch
 Patch14:	grub-2.00-ignore-gnulib-gets-stupidity.patch
 Patch15:	grub-2.00-linux-mbr.patch
 Patch16:	grub-2.00-no-huge-video.patch
+Patch17:	grub-2.00-ppc-hints.patch
+Patch18:	grub-2.00-support-vscsi-on-ibm-ppc.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -384,6 +386,9 @@ fi
 %doc grub-%{tarversion}/themes/starfield/COPYING.CC-BY-SA-3.0
 
 %changelog
+* Wed Jun 06 2012 Peter Jones <pjones at redhat.com> - 2.0-0.34.beta6
+- Add IBM PPC fixes.
+
 * Mon Jun 04 2012 Peter Jones <pjones at redhat.com> - 2.0-0.33.beta6
 - Update to beta6.
 - Various fixes from mads.


More information about the scm-commits mailing list