From f439b47ed6e987306c7de6d9c3be11de04935377 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sat, 23 Dec 2023 22:29:47 +0100 Subject: [PATCH] boot/grub2: add RISC-V 64bit EFI support Grub can be built as a RISC-V UEFI application since commit [1]. This commit was first included in grub version 2.04. This commit enables this support. [1] https://git.savannah.gnu.org/gitweb/?p=grub.git;a=commitdiff;h=f1957dc8a3347278a095bc8f44197662559a8ba3 Signed-off-by: Julien Olivain Signed-off-by: Yann E. MORIN --- boot/grub2/Config.in | 10 ++++++++++ boot/grub2/grub2.mk | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/boot/grub2/Config.in b/boot/grub2/Config.in index f05f33ccc7..7c235e96f7 100644 --- a/boot/grub2/Config.in +++ b/boot/grub2/Config.in @@ -4,6 +4,7 @@ config BR2_TARGET_GRUB2_ARCH_SUPPORTS default y if BR2_x86_64 default y if BR2_arm default y if BR2_aarch64 + default y if BR2_RISCV_64 depends on BR2_USE_MMU config BR2_TARGET_GRUB2 @@ -102,6 +103,15 @@ config BR2_TARGET_GRUB2_ARM64_EFI Aarch64 platform and you want to boot Grub 2 as an EFI application. +config BR2_TARGET_GRUB2_RISCV64_EFI + bool "riscv64-efi" + depends on BR2_RISCV_64 + select BR2_TARGET_GRUB2_HAS_EFI_BOOT + help + Select this option if the platform you're targetting is a + 64bit RISC-V platform and you want to boot Grub 2 as an EFI + application. + if BR2_TARGET_GRUB2_HAS_LEGACY_BOOT comment "Options for the x86 legacy BIOS or ARM U-Boot support" diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk index 4430aebd59..6d0d71c47d 100644 --- a/boot/grub2/grub2.mk +++ b/boot/grub2/grub2.mk @@ -93,6 +93,15 @@ GRUB2_BUILTIN_CONFIG_arm64-efi = $(GRUB2_BUILTIN_CONFIG_EFI) GRUB2_BUILTIN_MODULES_arm64-efi = $(GRUB2_BUILTIN_MODULES_EFI) GRUB2_TUPLES-$(BR2_TARGET_GRUB2_ARM64_EFI) += arm64-efi +GRUB2_IMAGE_riscv64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootriscv64.efi +GRUB2_CFG_riscv64-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg +GRUB2_PREFIX_riscv64-efi = /EFI/BOOT +GRUB2_TARGET_riscv64-efi = riscv64 +GRUB2_PLATFORM_riscv64-efi = efi +GRUB2_BUILTIN_CONFIG_riscv64-efi = $(GRUB2_BUILTIN_CONFIG_EFI) +GRUB2_BUILTIN_MODULES_riscv64-efi = $(GRUB2_BUILTIN_MODULES_EFI) +GRUB2_TUPLES-$(BR2_TARGET_GRUB2_RISCV64_EFI) += riscv64-efi + # Grub2 is kind of special: it considers CC, LD and so on to be the # tools to build the host programs and uses TARGET_CC, TARGET_CFLAGS, # TARGET_CPPFLAGS, TARGET_LDFLAGS to build the bootloader itself.