From 6eb367e8ca2799f1ebfaeaa0fe69fe79c1aea884 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko 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 . Reviewed by: Coleen . --- 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 + + * grub-core/disk/ieee1275/ofdisk.c (scan): Support vscsi on IBM + machines. + Tested by: Paulo Flabiano Smorigo. + Crucial information about API supplied by: Coleen . + Reviewed by: Coleen . + 2012-06-05 Vladimir Serbinenko * 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