From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zvh2e-00038w-Jk for mharc-grub-devel@gnu.org; Mon, 09 Nov 2015 02:39:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvbH8-0002SI-A5 for grub-devel@gnu.org; Sun, 08 Nov 2015 20:29:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvbH5-0002zC-0q for grub-devel@gnu.org; Sun, 08 Nov 2015 20:29:38 -0500 Received: from e24smtp01.br.ibm.com ([32.104.18.85]:47619) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvbH4-0002z3-Jv for grub-devel@gnu.org; Sun, 08 Nov 2015 20:29:34 -0500 Received: from /spool/local by e24smtp01.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 8 Nov 2015 23:29:30 -0200 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp01.br.ibm.com (10.172.0.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 8 Nov 2015 23:29:29 -0200 X-Helo: d24dlp01.br.ibm.com X-MailFrom: pfsmorigo@linux.vnet.ibm.com X-RcptTo: grub-devel@gnu.org Received: from d24relay01.br.ibm.com (d24relay01.br.ibm.com [9.8.31.16]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 441373520079 for ; Sun, 8 Nov 2015 20:28:17 -0500 (EST) Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay01.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tA91TwPT999600 for ; Sun, 8 Nov 2015 23:29:58 -0200 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tA91TQDr008132 for ; Sun, 8 Nov 2015 23:29:27 -0200 Received: from london.ltc.br.ibm.com ([9.8.9.89]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tA91TPKg008124; Sun, 8 Nov 2015 23:29:26 -0200 From: Paulo Flabiano Smorigo To: The development of GNU GRUB Subject: [PATCH v2] ofdisk: add sas disks to the device list Date: Sun, 8 Nov 2015 23:29:10 -0200 Message-Id: <1447032550-8854-1-git-send-email-pfsmorigo@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15110901-1524-0000-0000-0000040B0A72 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.104.18.85 X-Mailman-Approved-At: Mon, 09 Nov 2015 02:39:04 -0500 Cc: arvidjaar@gmail.com, Paulo Flabiano Smorigo X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2015 01:29:39 -0000 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