Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gwbaJ-0006Cl-DY for mharc-grub-devel@gnu.org; Wed, 20 Feb 2019 18:47:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <93sam@debian.org>) id 1gwbaG-0006CL-Gx for grub-devel@gnu.org; Wed, 20 Feb 2019 18:47:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <93sam@debian.org>) id 1gwbaC-0000hu-Qp for grub-devel@gnu.org; Wed, 20 Feb 2019 18:47:22 -0500 Received: from cheddar.halon.org.uk ([93.93.131.118]:54422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <93sam@debian.org>) id 1gwbaC-0000B4-Hb for grub-devel@gnu.org; Wed, 20 Feb 2019 18:47:20 -0500 Received: from bsmtp by cheddar.halon.org.uk with local-bsmtp (Exim 4.89) (envelope-from <93sam@debian.org>) id 1gwba3-0004zW-QH for grub-devel@gnu.org; Wed, 20 Feb 2019 23:47:11 +0000 Received: from steve by tack.einval.org with local (Exim 4.89) (envelope-from <93sam@debian.org>) id 1gwbZy-0005e9-Ch for grub-devel@gnu.org; Wed, 20 Feb 2019 23:47:06 +0000 Date: Wed, 20 Feb 2019 23:47:06 +0000 From: Steve McIntyre <93sam@debian.org> To: grub-devel@gnu.org Subject: Re: [PATCH] grub-install: check for arm-efi as a default target Message-ID: <20190220234658.ilty7kkquccw3apg@tack.einval.com> References: <20190211024234.6975-1-93sam@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190211024234.6975-1-93sam@debian.org> X-attached: none User-Agent: NeoMutt/20170113 (1.7.2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 93.93.131.118 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: Wed, 20 Feb 2019 23:47:25 -0000 Ping? On Mon, Feb 11, 2019 at 02:42:34AM +0000, Steve McIntyre wrote: >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 > > 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 > > -- Steve McIntyre, Cambridge, UK. steve@einval.com "I used to be the first kid on the block wanting a cranial implant, now I want to be the first with a cranial firewall. " -- Charlie Stross