From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: arvidjaar@gmail.com,
Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Subject: [PATCH v2] ofdisk: add sas disks to the device list
Date: Sun, 8 Nov 2015 23:29:10 -0200 [thread overview]
Message-ID: <1447032550-8854-1-git-send-email-pfsmorigo@linux.vnet.ibm.com> (raw)
All SAS disks attached will be added to the device list. This is the second
version of a patch that I send a while ago [1].
[1] https://lists.gnu.org/archive/html/grub-devel/2015-08/msg00000.html
---
grub-core/disk/ieee1275/ofdisk.c | 76 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
index 297f058..afec9ba 100644
--- a/grub-core/disk/ieee1275/ofdisk.c
+++ b/grub-core/disk/ieee1275/ofdisk.c
@@ -260,6 +260,82 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
grub_free (buf);
return;
}
+ else if (grub_strcmp (alias->type, "sas_ioa") == 0)
+ {
+ /* The method returns the number of disks and a table where
+ * each ID is 64-bit long. Example of sas paths:
+ * /pci@80000002000001f/pci1014,034A@0/sas/disk@c05db70800
+ * /pci@80000002000001f/pci1014,034A@0/sas/disk@a05db70800
+ * /pci@80000002000001f/pci1014,034A@0/sas/disk@805db70800 */
+
+ struct sas_children
+ {
+ struct grub_ieee1275_common_hdr common;
+ grub_ieee1275_cell_t method;
+ grub_ieee1275_cell_t ihandle;
+ grub_ieee1275_cell_t max;
+ grub_ieee1275_cell_t table;
+ grub_ieee1275_cell_t catch_result;
+ grub_ieee1275_cell_t nentries;
+ }
+ args;
+ char *buf, *bufptr, *table;
+ unsigned i;
+ grub_uint32_t table_size;
+ grub_ieee1275_ihandle_t ihandle;
+
+ buf = grub_malloc (grub_strlen (alias->path)
+ + sizeof ("/disk@7766554433221100"));
+ if (!buf)
+ return;
+
+ /* 64 entries should be enough */
+ table_size = sizeof (grub_uint64_t) * 64;
+ table = grub_malloc (table_size);
+
+ if (!table)
+ {
+ grub_free (buf);
+ return;
+ }
+
+ bufptr = grub_stpcpy (buf, alias->path);
+
+ if (grub_ieee1275_open (alias->path, &ihandle))
+ {
+ grub_free (buf);
+ grub_free (table);
+ return;
+ }
+
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 2);
+ args.method = (grub_ieee1275_cell_t) "get-sas-children";
+ args.ihandle = ihandle;
+ args.max = table_size;
+ args.table = (grub_ieee1275_cell_t) table;
+ args.catch_result = 0;
+ args.nentries = 0;
+
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+ {
+ grub_ieee1275_close (ihandle);
+ grub_free (table);
+ grub_free (buf);
+ return;
+ }
+
+ grub_uint64_t *ptr;
+ for (i = 0; i < args.nentries; i++)
+ {
+ ptr = (grub_uint64_t *) (table + sizeof (grub_uint64_t) * i);
+ grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr);
+ dev_iterate_real (buf, buf);
+ }
+
+ grub_ieee1275_close (ihandle);
+ grub_free (table);
+ grub_free (buf);
+ }
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS)
&& grub_strcmp (alias->type, "block") == 0)
--
2.1.0
next reply other threads:[~2015-11-09 7:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-09 1:29 Paulo Flabiano Smorigo [this message]
2015-11-09 4:18 ` [PATCH v2] ofdisk: add sas disks to the device list Andrei Borzenkov
2015-11-09 11:49 ` Paulo Flabiano Smorigo
2015-11-09 12:01 ` Vladimir 'phcoder' Serbinenko
2015-11-09 16:43 ` Paulo Flabiano Smorigo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447032550-8854-1-git-send-email-pfsmorigo@linux.vnet.ibm.com \
--to=pfsmorigo@linux.vnet.ibm.com \
--cc=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.