riscv/stand: pass boot hart in loader metadata
Use the RISCV_EFI_BOOT_PROTOCOL to fetch the boot hart ID, and communicate this to the kernel via new metadata field (MODINFOMD_BOOT_HART). If the boot hart is not found this way, fall back to the (now deprecated) device-tree method. The assumption that a hart ID can be represented with a 32-bit unsigned integer is unchanged in the kernel, but from the loader we pass the full 64-bit value. This ensures that this API won't need to change in the future, should the wider value become necessary. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48887
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) 2001 Benno Rice <benno@FreeBSD.org>
|
||||
* Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2024 The FreeBSD Foundation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -40,6 +41,28 @@
|
||||
#include "bootstrap.h"
|
||||
#include "loader_efi.h"
|
||||
|
||||
static void
|
||||
riscv_set_boot_hart(struct preloaded_file *fp)
|
||||
{
|
||||
EFI_GUID riscvboot = RISCV_EFI_BOOT_PROTOCOL_GUID;
|
||||
RISCV_EFI_BOOT_PROTOCOL *proto;
|
||||
EFI_STATUS status = 0;
|
||||
uint64_t boot_hartid = ULONG_MAX;
|
||||
|
||||
status = BS->LocateProtocol(&riscvboot, NULL, (void **)&proto);
|
||||
if (EFI_ERROR(status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
status = proto->GetBootHartId(proto, &boot_hartid);
|
||||
if (EFI_ERROR(status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
file_addmetadata(fp, MODINFOMD_BOOT_HARTID, sizeof(boot_hartid),
|
||||
&boot_hartid);
|
||||
}
|
||||
|
||||
static int
|
||||
__elfN(exec)(struct preloaded_file *fp)
|
||||
{
|
||||
@@ -52,6 +75,8 @@ __elfN(exec)(struct preloaded_file *fp)
|
||||
if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
|
||||
return (EFTYPE);
|
||||
|
||||
riscv_set_boot_hart(fp);
|
||||
|
||||
e = (Elf_Ehdr *)&fmp->md_data;
|
||||
|
||||
efi_time_fini();
|
||||
|
||||
Reference in New Issue
Block a user