u-boot/lib/efi_loader/efi_riscv.c
Tom Rini c38cb227d3 efi_loader: Remove <common.h>
We largely do not need <common.h> in these files, so drop it. The only
exception here is that efi_freestanding.c needs <linux/types.h> and had
been getting that via <common.h>.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-12-21 08:54:37 -05:00

59 lines
1.5 KiB
C

// 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 <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_EXIT(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;
}