1 // SPDX-License-Identifier: GPL-2.0+
3 * Defines APIs that allow an OS to interact with UEFI firmware to query
4 * information about the boot hart ID.
6 * Copyright (c) 2022, Ventana Micro Systems Inc
9 #define LOG_CATEGORY LOGC_EFI
11 #include <efi_loader.h>
12 #include <efi_variable.h>
14 #include <asm/global_data.h>
15 #include <efi_riscv.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 static const efi_guid_t efi_guid_riscv_boot_protocol = RISCV_EFI_BOOT_PROTOCOL_GUID;
22 * efi_riscv_get_boot_hartid() - return boot hart ID
23 * @this: RISCV_EFI_BOOT_PROTOCOL instance
24 * @boot_hartid: caller allocated memory to return boot hart id
27 static efi_status_t EFIAPI
28 efi_riscv_get_boot_hartid(struct riscv_efi_boot_protocol *this,
29 efi_uintn_t *boot_hartid)
31 EFI_ENTRY("%p, %p", this, boot_hartid);
33 if (this != &riscv_efi_boot_prot || !boot_hartid)
34 return EFI_INVALID_PARAMETER;
36 *boot_hartid = gd->arch.boot_hart;
38 return EFI_EXIT(EFI_SUCCESS);
41 struct riscv_efi_boot_protocol riscv_efi_boot_prot = {
42 .revision = RISCV_EFI_BOOT_PROTOCOL_REVISION,
43 .get_boot_hartid = efi_riscv_get_boot_hartid
47 * efi_riscv_register() - register RISCV_EFI_BOOT_PROTOCOL
51 efi_status_t efi_riscv_register(void)
53 efi_status_t ret = EFI_SUCCESS;
55 ret = efi_add_protocol(efi_root, &efi_guid_riscv_boot_protocol,
56 (void *)&riscv_efi_boot_prot);
57 if (ret != EFI_SUCCESS)
58 log_err("Cannot install RISCV_EFI_BOOT_PROTOCOL\n");