From patchwork Mon Feb 11 02:42:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve McIntyre <93sam@debian.org> X-Patchwork-Id: 157966 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2113446jaa; Sun, 10 Feb 2019 18:43:35 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia7923N2ji93UAVIEnqSnBRfnkLHJuRRjfpX3PGd7fKAPWul2J9v5z5nN/sriYbIAnXqosN X-Received: by 2002:a1c:7dd7:: with SMTP id y206mr2267364wmc.123.1549853015843; Sun, 10 Feb 2019 18:43:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549853015; cv=none; d=google.com; s=arc-20160816; b=yXw+dHHEG92NQP48fcvKceFZsaIK+nO1I0WX0/tkigEyClgQwLiOtI+VdUQylxKTeI OOxdcGu55+z+G3SYCQbrsEpnl2iAhj/wNhDRx6+SNQOorMP1VUfYzrCR8NRt8sREFxSS 7WAgK67nhCtUoWznllh2hitx3vEmQTsNftEahKogkdWtjb8y18Brm7cjSmO7x+jKXH0p cCXTcvmp+bITw3V5S/G8BTciKUQumfaH0byM8goxshhmAG/XhJKMr1xL4o30eON5eUyj DQWoz8O7DiCyXAHQ+rOljyW+nTEXM2gz5pad3hE+pO9BQKAgScq/SJtjI9S/BnilbKZx 2lIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from; bh=IISyC7c+sM03/FXVvxNlrzNQJkMff8NZpxNZ/+0Qlqk=; b=nHKHQ4nwVR/kfEfwvXrNCeIvvjYx00WumCCuEnz8nCv0/TM2e44L20ZNYGJ7FiJ9nh g/CQvkdoKz07Rk1uO9KewrVcVx6qfrmkUvYTSCb4t5kLeWO5epu8rGGRhroAG5uNp4yQ SkbgPIGyMK+H5ykMxJ1D1ERbnIomxURT3O+3C314gEKJIwSpjfd8+UPaUbspozcctY02 hoLEk9FAsoF9BKkUdv/b/i/ojCL072V6CgH/KyL8WgsBU5JXP58/NHlpPLKgR+x4UQ66 pAv4yKiGt8DIlDyJYyJ1C+XaZnjJn24CDtIxNWNFmFU5HFLtO7sJO8SrAvXRoE10jjEZ wUEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b1si6618134wrj.176.2019.02.10.18.43.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 10 Feb 2019 18:43:35 -0800 (PST) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Received: from localhost ([127.0.0.1]:43100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gt1ZG-000274-TX for patch@linaro.org; Sun, 10 Feb 2019 21:43:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gt1ZB-00026z-KD for grub-devel@gnu.org; Sun, 10 Feb 2019 21:43:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gt1Z6-0006n8-6m for grub-devel@gnu.org; Sun, 10 Feb 2019 21:43:27 -0500 Received: from cheddar.halon.org.uk ([93.93.131.118]:42034) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gt1Z2-0006gm-56 for grub-devel@gnu.org; Sun, 10 Feb 2019 21:43:22 -0500 Received: from bsmtp by cheddar.halon.org.uk with local-bsmtp (Exim 4.89) (envelope-from ) id 1gt1Yt-0000zZ-GT; Mon, 11 Feb 2019 02:43:11 +0000 Received: from steve by tack.einval.org with local (Exim 4.89) (envelope-from ) id 1gt1YS-0001q2-0j; Mon, 11 Feb 2019 02:42:44 +0000 From: Steve McIntyre <93sam@debian.org> To: grub-devel@gnu.org Subject: [PATCH] grub-install: check for arm-efi as a default target Date: Mon, 11 Feb 2019 02:42:34 +0000 Message-Id: <20190211024234.6975-1-93sam@debian.org> X-Mailer: git-send-email 2.11.0 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: , Reply-To: The development of GNU GRUB Cc: Steve McIntyre <93sam@debian.org> MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" 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(-) -- 2.11.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel 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__)