efi_loader: Enable RISCV_EFI_BOOT_PROTOCOL support
This adds support for new RISCV_EFI_BOOT_PROTOCOL to communicate the boot hart ID to bootloader/kernel on RISC-V UEFI platforms. The specification of the protocol is hosted at: https://github.com/riscv-non-isa/riscv-uefi Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
parent
9e63786e2b
commit
1ccf87165e
@ -438,6 +438,10 @@ struct efi_runtime_services {
|
|||||||
EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
|
EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \
|
||||||
0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
|
0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f)
|
||||||
|
|
||||||
|
#define RISCV_EFI_BOOT_PROTOCOL_GUID \
|
||||||
|
EFI_GUID(0xccd15fec, 0x6f73, 0x4eec, 0x83, \
|
||||||
|
0x95, 0x3e, 0x69, 0xe4, 0xb9, 0x40, 0xbf)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct efi_configuration_table - EFI Configuration Table
|
* struct efi_configuration_table - EFI Configuration Table
|
||||||
*
|
*
|
||||||
|
@ -527,6 +527,8 @@ efi_status_t efi_disk_register(void);
|
|||||||
efi_status_t efi_rng_register(void);
|
efi_status_t efi_rng_register(void);
|
||||||
/* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
|
/* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
|
||||||
efi_status_t efi_tcg2_register(void);
|
efi_status_t efi_tcg2_register(void);
|
||||||
|
/* Called by efi_init_obj_list() to install RISCV_EFI_BOOT_PROTOCOL */
|
||||||
|
efi_status_t efi_riscv_register(void);
|
||||||
/* Called by efi_init_obj_list() to do initial measurement */
|
/* Called by efi_init_obj_list() to do initial measurement */
|
||||||
efi_status_t efi_tcg2_do_initial_measurement(void);
|
efi_status_t efi_tcg2_do_initial_measurement(void);
|
||||||
/* measure the pe-coff image, extend PCR and add Event Log */
|
/* measure the pe-coff image, extend PCR and add Event Log */
|
||||||
|
24
include/efi_riscv.h
Normal file
24
include/efi_riscv.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||||
|
/*
|
||||||
|
* RISCV_EFI_BOOT_PROTOCOL
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 Ventana Micro Systems Inc
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <efi_api.h>
|
||||||
|
|
||||||
|
#define RISCV_EFI_BOOT_PROTOCOL_REVISION 0x00010000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct riscv_efi_boot_protocol - RISCV_EFI_BOOT_PROTOCOL
|
||||||
|
* @revision: Version of the protocol implemented
|
||||||
|
* @get_boot_hartid: Get the boot hart ID
|
||||||
|
*/
|
||||||
|
struct riscv_efi_boot_protocol {
|
||||||
|
u64 revision;
|
||||||
|
|
||||||
|
efi_status_t (EFIAPI * get_boot_hartid) (struct riscv_efi_boot_protocol *this,
|
||||||
|
efi_uintn_t *boot_hartid);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct riscv_efi_boot_protocol riscv_efi_boot_prot;
|
@ -369,4 +369,14 @@ config EFI_ESRT
|
|||||||
help
|
help
|
||||||
Enabling this option creates the ESRT UEFI system table.
|
Enabling this option creates the ESRT UEFI system table.
|
||||||
|
|
||||||
|
config EFI_RISCV_BOOT_PROTOCOL
|
||||||
|
bool "RISCV_EFI_BOOT_PROTOCOL support"
|
||||||
|
default y
|
||||||
|
depends on RISCV
|
||||||
|
help
|
||||||
|
The EFI_RISCV_BOOT_PROTOCOL is used to transfer the boot hart ID
|
||||||
|
to the next boot stage. It should be enabled as it is meant to
|
||||||
|
replace the transfer via the device-tree. The latter is not
|
||||||
|
possible on systems using ACPI.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -62,6 +62,7 @@ obj-$(CONFIG_GENERATE_ACPI_TABLE) += efi_acpi.o
|
|||||||
obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
|
obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
|
||||||
obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
|
obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
|
||||||
obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
|
obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
|
||||||
|
obj-$(CONFIG_EFI_RISCV_BOOT_PROTOCOL) += efi_riscv.o
|
||||||
obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
|
obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o
|
||||||
obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
|
obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o
|
||||||
|
|
||||||
|
60
lib/efi_loader/efi_riscv.c
Normal file
60
lib/efi_loader/efi_riscv.c
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
/*
|
||||||
|
* Defines APIs that allow an OS to interact with UEFI firmware to query
|
||||||
|
* information about the boot hart ID.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022, Ventana Micro Systems Inc
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LOG_CATEGORY LOGC_EFI
|
||||||
|
#include <common.h>
|
||||||
|
#include <efi_loader.h>
|
||||||
|
#include <efi_variable.h>
|
||||||
|
#include <log.h>
|
||||||
|
#include <asm/global_data.h>
|
||||||
|
#include <efi_riscv.h>
|
||||||
|
|
||||||
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
|
static const efi_guid_t efi_guid_riscv_boot_protocol = RISCV_EFI_BOOT_PROTOCOL_GUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* efi_riscv_get_boot_hartid() - return boot hart ID
|
||||||
|
* @this: RISCV_EFI_BOOT_PROTOCOL instance
|
||||||
|
* @boot_hartid: caller allocated memory to return boot hart id
|
||||||
|
* Return: status code
|
||||||
|
*/
|
||||||
|
static efi_status_t EFIAPI
|
||||||
|
efi_riscv_get_boot_hartid(struct riscv_efi_boot_protocol *this,
|
||||||
|
efi_uintn_t *boot_hartid)
|
||||||
|
{
|
||||||
|
EFI_ENTRY("%p, %p", this, boot_hartid);
|
||||||
|
|
||||||
|
if (this != &riscv_efi_boot_prot || !boot_hartid)
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
*boot_hartid = gd->arch.boot_hart;
|
||||||
|
|
||||||
|
return EFI_EXIT(EFI_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct riscv_efi_boot_protocol riscv_efi_boot_prot = {
|
||||||
|
.revision = RISCV_EFI_BOOT_PROTOCOL_REVISION,
|
||||||
|
.get_boot_hartid = efi_riscv_get_boot_hartid
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* efi_riscv_register() - register RISCV_EFI_BOOT_PROTOCOL
|
||||||
|
*
|
||||||
|
* Return: status code
|
||||||
|
*/
|
||||||
|
efi_status_t efi_riscv_register(void)
|
||||||
|
{
|
||||||
|
efi_status_t ret = EFI_SUCCESS;
|
||||||
|
|
||||||
|
ret = efi_add_protocol(efi_root, &efi_guid_riscv_boot_protocol,
|
||||||
|
(void *)&riscv_efi_boot_prot);
|
||||||
|
if (ret != EFI_SUCCESS)
|
||||||
|
log_err("Cannot install RISCV_EFI_BOOT_PROTOCOL\n");
|
||||||
|
return ret;
|
||||||
|
}
|
@ -247,6 +247,12 @@ efi_status_t efi_init_obj_list(void)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_EFI_RISCV_BOOT_PROTOCOL)) {
|
||||||
|
ret = efi_riscv_register();
|
||||||
|
if (ret != EFI_SUCCESS)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Secure boot */
|
/* Secure boot */
|
||||||
ret = efi_init_secure_boot();
|
ret = efi_init_secure_boot();
|
||||||
if (ret != EFI_SUCCESS)
|
if (ret != EFI_SUCCESS)
|
||||||
|
Loading…
Reference in New Issue
Block a user