grub2/grub-2.00-ppc-hints.patch
2012-06-06 11:22:51 -04:00

158 lines
4.4 KiB
Diff

From 1f1ddb93b57618a20b2adf7096ca1b21e2d252cc Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@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@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@gmail.com>
+
+ * util/ieee1275/ofpath.c (of_path_of_scsi): Fix wrong format specifier.
+
+2012-06-04 Vladimir Serbinenko <phcoder@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@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