From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1bINIf-0003n9-QF for mharc-grub-devel@gnu.org; Wed, 29 Jun 2016 17:45:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bINIb-0003GT-0k for grub-devel@gnu.org; Wed, 29 Jun 2016 17:45:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bINIY-0006GU-OA for grub-devel@gnu.org; Wed, 29 Jun 2016 17:45:32 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:22830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bINIY-0006GA-FB for grub-devel@gnu.org; Wed, 29 Jun 2016 17:45:30 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u5TLjTOe024345 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 29 Jun 2016 21:45:29 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u5TLjT0R012348 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 29 Jun 2016 21:45:29 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u5TLjQl4005534 for ; Wed, 29 Jun 2016 21:45:28 GMT Received: from ca-qasparc20.us.oracle.com (/10.147.24.73) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 29 Jun 2016 14:45:26 -0700 From: Eric Snowberg To: grub-devel@gnu.org Cc: Eric Snowberg Subject: [PATCH 13/15] sparc64: add disks that don't have a devalias to the device list Date: Wed, 29 Jun 2016 14:43:26 -0700 Message-Id: <355c5c9696211f9244aa29e2292f709aafca09a0.1467232725.git.eric.snowberg@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2016 21:45:36 -0000 Add ability for grub2 to be capable of booting from a disk that does not have a device alias. This patch will find all disks in the system and add them to the device list. Signed-off-by: Eric Snowberg --- grub-core/disk/ieee1275/ofdisk.c | 144 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 144 insertions(+), 0 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 42d038c..17d082b 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -376,6 +376,150 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) grub_free (table); grub_free (buf); } + else if (grub_strcmp (alias->type, "scsi-2") == 0) + { + grub_ieee1275_ihandle_t ihandle; + grub_ssize_t result; + char *buf, *bufptr; + grub_uint8_t tgt; + + buf = grub_malloc (grub_strlen (alias->path) + + sizeof ("/disk@00")); + if (!buf) + return; + + bufptr = grub_stpcpy (buf, alias->path); + ihandle = ofdisk_hba_open (alias->path); + + if (ihandle == 0) + { + grub_free (buf); + return; + } + + for (tgt = 0; tgt <= 0xf; tgt++) + { + if (grub_ieee1275_set_address(ihandle, tgt, 0) == 0) + if (grub_ieee1275_no_data_command (ihandle, &ofdisk_tur, + &result) == 0) + if (result == 0) + { + grub_snprintf (bufptr, sizeof ("/disk@00"), + "/disk@%" PRIxGRUB_UINT32_T, tgt); + dev_iterate_real (buf, buf); + } + } + + grub_free (buf); + return; + } + else if (grub_strcmp (alias->type, "scsi-sas") == 0) + { + grub_ieee1275_ihandle_t ihandle; + grub_uint32_t address_cells = 2; + grub_ieee1275_phandle_t root; + grub_ssize_t result; + char *buf, *bufptr; + + buf = grub_malloc (grub_strlen (alias->path) + + sizeof ("/disk@p1100")); + + if (!buf) + return; + + bufptr = grub_stpcpy (buf, alias->path); + bufptr = grub_stpcpy (bufptr, "/disk@"); + ihandle = ofdisk_hba_open (alias->path); + + if (ihandle == 0) + { + grub_free (buf); + return; + } + + grub_ieee1275_finddevice (alias->path, &root); + grub_ieee1275_get_integer_property (root, "#address-cells", &address_cells, + sizeof address_cells, 0); + if (address_cells == 2) + { + grub_uint8_t tgt; + + for (tgt = 0; tgt < 0xf; tgt++) + { + if (grub_ieee1275_set_address(ihandle, tgt, 0) == 0) + if (grub_ieee1275_no_data_command (ihandle, &ofdisk_tur, + &result) == 0) + if (result == 0) + { + grub_snprintf (bufptr, sizeof ("p1100"), + "%" PRIxGRUB_UINT32_T, tgt); + dev_iterate_real (buf, buf); + } + } + } + else if (address_cells == 4) + { + grub_uint16_t exp; + grub_uint8_t phy; + + for (exp = 0; exp <= 0x100; exp+=0x100) + for (phy = 0; phy < 0xff; phy++) + { + grub_snprintf (bufptr, sizeof ("p1100"), + "p%" PRIxGRUB_UINT32_T, exp | phy); + if (grub_ieee1275_set_sas_address (ihandle, bufptr, 0) == 0) + if (grub_ieee1275_no_data_command (ihandle, &ofdisk_tur, + &result) == 0) + if (result == 0) + dev_iterate_real (buf, buf); + } + } + grub_free (buf); + return; + } + else if (grub_strcmp (alias->type, "nvme") == 0) + { + char *buf; + + buf = grub_malloc (IEEE1275_MAX_PATH_LEN); + + if (!buf) + return; + + grub_snprintf (buf, IEEE1275_MAX_PATH_LEN, "%s/disk@1", alias->path); + dev_iterate_real (buf, buf); + grub_free (buf); + return; + } + else if (grub_strcmp (alias->type, "scsi-usb") == 0) + { + grub_ieee1275_ihandle_t ihandle; + grub_ssize_t result; + + ihandle = ofdisk_hba_open (alias->path); + + if (ihandle == 0) + return; + + if (grub_ieee1275_set_address (ihandle, 0, 0) == 0) + if (grub_ieee1275_no_data_command (ihandle, &ofdisk_tur, &result) == 0) + if (result == 0) + { + char *buf, *bufptr; + + buf = grub_malloc (grub_strlen (alias->path) + + sizeof ("/disk@0")); + + if (!buf) + return; + + bufptr = grub_stpcpy (buf, alias->path); + grub_snprintf (bufptr, sizeof ("/disk@0"), "/disk@0"); + dev_iterate_real (buf, buf); + grub_free (buf); + } + return; + } if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS) && grub_strcmp (alias->type, "block") == 0) -- 1.7.1