All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve McIntyre <93sam@debian.org>
To: grub-devel@gnu.org
Cc: Steve McIntyre <93sam@debian.org>
Subject: [PATCH] grub-install: check for arm-efi as a default target
Date: Mon, 11 Feb 2019 02:42:34 +0000	[thread overview]
Message-ID: <20190211024234.6975-1-93sam@debian.org> (raw)

Much like on x86, we can work out if the system is running on top of
EFI firmware. If so, return "arm-efi". If not, fall back to
"arm-uboot" as previously.

Heavily inspired by the existing code for x86.

Signed-off-by: Steve McIntyre <93sam@debian.org>
---
 grub-core/osdep/basic/platform.c |  6 ++++++
 grub-core/osdep/linux/platform.c | 24 ++++++++++++++++++++++++
 include/grub/util/install.h      |  3 +++
 util/grub-install.c              |  2 +-
 4 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/grub-core/osdep/basic/platform.c b/grub-core/osdep/basic/platform.c
index 4b5502aeb..a7dafd85a 100644
--- a/grub-core/osdep/basic/platform.c
+++ b/grub-core/osdep/basic/platform.c
@@ -19,6 +19,12 @@
 #include <grub/util/install.h>
 
 const char *
+grub_install_get_default_arm_platform (void)
+{
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 { 
   return "i386-pc";
diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c
index 775b6c031..a3f9e9d28 100644
--- a/grub-core/osdep/linux/platform.c
+++ b/grub-core/osdep/linux/platform.c
@@ -98,6 +98,30 @@ read_platform_size (void)
 }
 
 const char *
+grub_install_get_default_arm_platform (void)
+{
+  /*
+     On Linux, we need the efivars kernel modules.
+     If no EFI is available this module just does nothing
+     besides a small hello and if we detect efi we'll load it
+     anyway later. So it should be safe to
+     try to load it here.
+   */
+  grub_util_exec_redirect_all ((const char * []){ "modprobe", "efivars", NULL },
+			       NULL, NULL, "/dev/null");
+
+  grub_util_info ("Looking for /sys/firmware/efi ..");
+  if (is_not_empty_directory ("/sys/firmware/efi"))
+    {
+      grub_util_info ("...found");
+      return "arm-efi";
+    }
+
+  grub_util_info ("... not found");
+  return "arm-uboot";
+}
+
+const char *
 grub_install_get_default_x86_platform (void)
 { 
   /*
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
index af2bf65d7..80a51fcb1 100644
--- a/include/grub/util/install.h
+++ b/include/grub/util/install.h
@@ -209,6 +209,9 @@ void
 grub_install_create_envblk_file (const char *name);
 
 const char *
+grub_install_get_default_arm_platform (void);
+
+const char *
 grub_install_get_default_x86_platform (void);
 
 int
diff --git a/util/grub-install.c b/util/grub-install.c
index 4a0a66168..1d68cc5bb 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -319,7 +319,7 @@ get_default_platform (void)
 #elif defined (__ia64__)
    return "ia64-efi";
 #elif defined (__arm__)
-   return "arm-uboot";
+   return grub_install_get_default_arm_platform ();
 #elif defined (__aarch64__)
    return "arm64-efi";
 #elif defined (__amd64__) || defined (__x86_64__) || defined (__i386__)
-- 
2.11.0



             reply	other threads:[~2019-02-11  2:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-11  2:42 Steve McIntyre [this message]
2019-02-20 23:47 ` [PATCH] grub-install: check for arm-efi as a default target Steve McIntyre
2019-02-21 11:41 ` Leif Lindholm
2019-02-21 14:23   ` dann frazier
2019-02-21 14:53     ` Steve McIntyre
2019-02-21 15:01       ` Leif Lindholm
2019-02-21 15:23       ` dann frazier
2019-02-21 14:42   ` Steve McIntyre
2019-02-21 14:46   ` Steve McIntyre
2019-02-21 15:04     ` Leif Lindholm
2019-02-21 15:31       ` Daniel Kiper
2019-02-26 13:27         ` Leif Lindholm
2019-02-26 14:55           ` Daniel Kiper
2019-02-26 15:41             ` Steve McIntyre

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=20190211024234.6975-1-93sam@debian.org \
    --to=93sam@debian.org \
    --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.