* 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>.
This commit is contained in:
parent
81f6ef0e2d
commit
bf293dece0
2 changed files with 80 additions and 19 deletions
|
@ -1,3 +1,11 @@
|
|||
2012-06-06 Vladimir Serbinenko <phcoder@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@gmail.com>
|
||||
|
||||
* util/grub-mkimage.c: Disable -Wcast-align.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue