From: Eric Snowberg <eric.snowberg@oracle.com>
To: grub-devel@gnu.org
Cc: Eric Snowberg <eric.snowberg@oracle.com>
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 [thread overview]
Message-ID: <355c5c9696211f9244aa29e2292f709aafca09a0.1467232725.git.eric.snowberg@oracle.com> (raw)
In-Reply-To: <cover.1467232724.git.eric.snowberg@oracle.com>
In-Reply-To: <cover.1467232724.git.eric.snowberg@oracle.com>
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 <eric.snowberg@oracle.com>
---
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
next prev parent reply other threads:[~2016-06-29 21:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-29 21:43 [PATCH 00/15] Add missing SPARC support Eric Snowberg
2016-06-29 21:43 ` [PATCH 01/15] sparc64: fix OF path names for sun4v systems Eric Snowberg
2016-06-29 21:43 ` [PATCH 02/15] sparc64: Add blocklist GPT support for SPARC Eric Snowberg
2017-05-10 22:42 ` Vladimir 'phcoder' Serbinenko
2017-05-10 23:20 ` Eric Snowberg
2017-05-11 0:37 ` Vladimir 'phcoder' Serbinenko
2017-05-11 0:40 ` Vladimir 'phcoder' Serbinenko
2017-05-11 2:05 ` Eric Snowberg
2016-06-29 21:43 ` [PATCH 03/15] grub-install: fix memory leak Eric Snowberg
2016-06-29 21:43 ` [PATCH 04/15] sparc64: Use the correct disk name in core.img Eric Snowberg
2016-06-29 21:43 ` [PATCH 05/15] ieee1275: fix segfault in grub-ofpathname Eric Snowberg
2016-06-29 21:43 ` [PATCH 06/15] ieee1275: add nvme support within ofpath Eric Snowberg
2016-06-29 21:43 ` [PATCH 07/15] ofdisk: memory corruption fix Eric Snowberg
2016-06-29 21:43 ` [PATCH 08/15] ofdisk: move open logic Eric Snowberg
2016-06-29 21:43 ` [PATCH 09/15] ieee1275: ofdisk - don't continue to query block-size after we have it Eric Snowberg
2016-06-29 21:43 ` [PATCH 10/15] ofdisk: refactor open logic Eric Snowberg
2016-06-29 21:43 ` [PATCH 11/15] sparc64: boot performance improvements Eric Snowberg
2016-06-29 21:43 ` [PATCH 12/15] ofdisk: only add aliases that exist Eric Snowberg
2016-06-29 21:43 ` Eric Snowberg [this message]
2016-06-29 21:43 ` [PATCH 14/15] parser: Remove escape from the state transitions Eric Snowberg
2016-06-29 21:43 ` [PATCH 15/15] sparc64: ignore hypervisor reboot memory block device Eric Snowberg
2016-07-01 6:52 ` [PATCH 00/15] Add missing SPARC support Daniel Kiper
2016-07-26 10:24 ` Daniel Kiper
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=355c5c9696211f9244aa29e2292f709aafca09a0.1467232725.git.eric.snowberg@oracle.com \
--to=eric.snowberg@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).