]> git.proxmox.com Git - grub2.git/commitdiff
grub-install: Check for arm-efi as a default target
authorSteve McIntyre <93sam@debian.org>
Mon, 11 Feb 2019 02:42:34 +0000 (02:42 +0000)
committerSteve McIntyre <93sam@debian.org>
Tue, 25 Jun 2019 09:11:12 +0000 (10:11 +0100)
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>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=082fd84d525f8d6602f892160b77c0a948308a78
Bug-Debian: https://bugs.debian.org/922104
Last-Update: 2019-02-26

Patch-Name: grub-install-arm-default-target.patch

Gbp-Pq: Name grub-install-arm-default-target.patch

grub-core/osdep/basic/platform.c
grub-core/osdep/linux/platform.c
include/grub/util/install.h
util/grub-install.c

index 2ab907976356a7cd0a98a61557ca9195e3dfc42a..6c293ed2d0caa9df10d54c9746b8d5246e1989bb 100644 (file)
 
 #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)
 { 
index 9805c36d43b2189c418c29deb6db748f2fde4556..54a9b9eccc72fea7f97c51640976cb0e6dbb9342 100644 (file)
@@ -100,6 +100,28 @@ read_platform_size (void)
   return ret;
 }
 
+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)
 { 
index 3fd46ec30e6d033a472c9bcb646bd486ebbd18cc..5783cc4bc69a5ceb65ffc9cc9f8e38ee8bfb3a8b 100644 (file)
@@ -204,6 +204,9 @@ grub_util_get_target_dirname (const struct grub_install_image_target_desc *t);
 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);
 
index 81b648efc284b292c33d346aa2e7da3a1e1aff64..55491589fdeee5c62815c9493d375f885988396d 100644 (file)
@@ -348,7 +348,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__)