6b2dd0f731
Signed-off-by: Peter Jones <pjones@redhat.com>
101 lines
3.4 KiB
Diff
101 lines
3.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Eric Snowberg <eric.snowberg@oracle.com>
|
|
Date: Thu, 8 Mar 2018 20:42:22 -0800
|
|
Subject: [PATCH] ieee1275: split up grub_machine_get_bootlocation
|
|
|
|
Split up some of the functionality in grub_machine_get_bootlocation into
|
|
grub_ieee1275_get_boot_dev. This will allow for code reuse in a follow on
|
|
patch.
|
|
|
|
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/kern/ieee1275/init.c | 20 ++------------------
|
|
grub-core/kern/ieee1275/openfw.c | 27 +++++++++++++++++++++++++++
|
|
include/grub/ieee1275/ieee1275.h | 2 ++
|
|
3 files changed, 31 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
|
|
index 12590225eca..62dfb8a3bad 100644
|
|
--- a/grub-core/kern/ieee1275/init.c
|
|
+++ b/grub-core/kern/ieee1275/init.c
|
|
@@ -94,28 +94,12 @@ void
|
|
grub_machine_get_bootlocation (char **device, char **path)
|
|
{
|
|
char *bootpath;
|
|
- grub_ssize_t bootpath_size;
|
|
char *filename;
|
|
char *type;
|
|
|
|
- if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
|
|
- &bootpath_size)
|
|
- || bootpath_size <= 0)
|
|
- {
|
|
- /* Should never happen. */
|
|
- grub_printf ("/chosen/bootpath property missing!\n");
|
|
- return;
|
|
- }
|
|
-
|
|
- bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64);
|
|
+ bootpath = grub_ieee1275_get_boot_dev ();
|
|
if (! bootpath)
|
|
- {
|
|
- grub_print_error ();
|
|
- return;
|
|
- }
|
|
- grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
|
|
- (grub_size_t) bootpath_size + 1, 0);
|
|
- bootpath[bootpath_size] = '\0';
|
|
+ return;
|
|
|
|
/* Transform an OF device path to a GRUB path. */
|
|
|
|
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
|
|
index ddb778340e4..62929d983bf 100644
|
|
--- a/grub-core/kern/ieee1275/openfw.c
|
|
+++ b/grub-core/kern/ieee1275/openfw.c
|
|
@@ -561,3 +561,30 @@ grub_ieee1275_canonicalise_devname (const char *path)
|
|
return NULL;
|
|
}
|
|
|
|
+char *
|
|
+grub_ieee1275_get_boot_dev (void)
|
|
+{
|
|
+ char *bootpath;
|
|
+ grub_ssize_t bootpath_size;
|
|
+
|
|
+ if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath",
|
|
+ &bootpath_size)
|
|
+ || bootpath_size <= 0)
|
|
+ {
|
|
+ /* Should never happen. */
|
|
+ grub_printf ("/chosen/bootpath property missing!\n");
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64);
|
|
+ if (! bootpath)
|
|
+ {
|
|
+ grub_print_error ();
|
|
+ return NULL;
|
|
+ }
|
|
+ grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath,
|
|
+ (grub_size_t) bootpath_size + 1, 0);
|
|
+ bootpath[bootpath_size] = '\0';
|
|
+
|
|
+ return bootpath;
|
|
+}
|
|
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
|
|
index d0dc2746ead..8868f3a756f 100644
|
|
--- a/include/grub/ieee1275/ieee1275.h
|
|
+++ b/include/grub/ieee1275/ieee1275.h
|
|
@@ -253,6 +253,8 @@ void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *al
|
|
void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath,
|
|
struct grub_ieee1275_devalias *alias);
|
|
|
|
+char *EXPORT_FUNC(grub_ieee1275_get_boot_dev) (void);
|
|
+
|
|
#define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));)
|
|
|
|
#define FOR_IEEE1275_DEVCHILDREN(devpath, alias) for (grub_ieee1275_children_first ((devpath), &(alias)); \
|