grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC][PATCH 1/2] Factor out EFI detection into its own function


From: dann frazier
Subject: [RFC][PATCH 1/2] Factor out EFI detection into its own function
Date: Tue, 28 Aug 2018 13:33:47 -0600

From: dann frazier <address@hidden>

No functional change. This will let us re-use the code for ARM.

Signed-off-by: dann frazier <address@hidden>
---
 grub-core/osdep/linux/platform.c   | 20 ++++++++++++++++----
 grub-core/osdep/windows/platform.c | 10 ++++++++--
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c
index 775b6c031..d278c299b 100644
--- a/grub-core/osdep/linux/platform.c
+++ b/grub-core/osdep/linux/platform.c
@@ -97,9 +97,9 @@ read_platform_size (void)
   return ret;
 }
 
-const char *
-grub_install_get_default_x86_platform (void)
-{ 
+static int
+is_efi (void)
+{
   /*
      On Linux, we need the efivars kernel modules.
      If no EFI is available this module just does nothing
@@ -114,13 +114,25 @@ grub_install_get_default_x86_platform (void)
   if (is_not_empty_directory ("/sys/firmware/efi"))
     {
       grub_util_info ("...found");
+      return 1;
+    }
+
+  grub_util_info ("... not found.");
+  return 0;
+}
+
+const char *
+grub_install_get_default_x86_platform (void)
+{
+  if (is_efi())
+    {
       if (read_platform_size() == 64)
        return "x86_64-efi";
       else
        return "i386-efi";
     }
 
-  grub_util_info ("... not found. Looking for /proc/device-tree ..");
+  grub_util_info ("Looking for /proc/device-tree ..");
   if (is_not_empty_directory ("/proc/device-tree"))
     {
       grub_util_info ("...found");
diff --git a/grub-core/osdep/windows/platform.c 
b/grub-core/osdep/windows/platform.c
index 912269191..58b322887 100644
--- a/grub-core/osdep/windows/platform.c
+++ b/grub-core/osdep/windows/platform.c
@@ -109,13 +109,19 @@ get_platform (void)
   return;
 }
 
+static int
+is_efi (void)
+{
+  get_platform ();
+  return platform == PLAT_EFI;
+}
+
 const char *
 grub_install_get_default_x86_platform (void)
 { 
   SYSTEM_INFO si;
 
-  get_platform ();
-  if (platform != PLAT_EFI)
+  if (!is_efi())
     return "i386-pc";
 
   /* EFI */
-- 
2.18.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]