Received: from list by lists.gnu.org with archive (Exim 4.71) id 1fujlU-0002YA-26 for mharc-grub-devel@gnu.org; Tue, 28 Aug 2018 15:35:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fujlR-0002Wq-OC for grub-devel@gnu.org; Tue, 28 Aug 2018 15:34:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fujlO-0001ex-CY for grub-devel@gnu.org; Tue, 28 Aug 2018 15:34:57 -0400 Received: from complete.lackof.org ([198.49.126.79]:56358) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fujlO-0001cH-2d for grub-devel@gnu.org; Tue, 28 Aug 2018 15:34:54 -0400 Received: from localhost (c-107-2-141-103.hsd1.co.comcast.net [107.2.141.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by complete.lackof.org (Postfix) with ESMTPSA id C865833E008F; Tue, 28 Aug 2018 13:34:52 -0600 (MDT) From: dann frazier To: grub-devel@gnu.org, Leif Lindholm Subject: [RFC][PATCH 1/2] Factor out EFI detection into its own function Date: Tue, 28 Aug 2018 13:33:47 -0600 Message-Id: <20180828193348.31676-2-dann.frazier@canonical.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180828193348.31676-1-dann.frazier@canonical.com> References: <20180828193348.31676-1-dann.frazier@canonical.com> X-Virus-Scanned: clamav-milter 0.100.1 at complete.lackof.org X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 198.49.126.79 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Aug 2018 19:34:59 -0000 From: dann frazier No functional change. This will let us re-use the code for ARM. Signed-off-by: dann frazier --- 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