arch/riscv: Remove opensbi submodule includes

Currently we include a header file from the opensbi submodule.
That causes some issues, since we merge outside code with our own.
Most recently there have been made attempts to make the coreboot
codebase C23 ready. The code that we include from opensbi however causes
the build to fail, since it is not C23 ready.

This patch effectivily detaches the coreboot codebase from the opensbi
codebase and just copies the structure and definitions that we need from
opensbi into coreboot.

Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Change-Id: I9d8f85ee805bbbf2627ef419685440b37c15f906
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83641
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Maximilian Brune
2024-07-25 00:12:21 +02:00
committed by Felix Held
parent 7dae497495
commit 07f0131116
2 changed files with 34 additions and 23 deletions

View File

@@ -180,7 +180,6 @@ cbfs-files-y += $(OPENSBI_CBFS)
check-ramstage-overlap-files += $(OPENSBI_CBFS)
CPPFLAGS_common += -I$(OPENSBI_SOURCE)/include
ramstage-y += opensbi.c
endif #CONFIG_RISCV_OPENSBI

View File

@@ -1,13 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* OpenSBI wants to make its own definitions for some of our compiler.h macros. */
#undef __packed
#undef __noreturn
#undef __aligned
#include <sbi/fw_dynamic.h>
#include <arch/boot.h>
/* DO NOT INCLUDE COREBOOT HEADERS HERE */
#include <arch/encoding.h>
#include <stdint.h>
#include <stddef.h>
#define FW_DYNAMIC_INFO_VERSION_2 2
#define FW_DYNAMIC_INFO_MAGIC_VALUE 0x4942534f // "OSBI"
/*
* structure passed to OpenSBI as 3rd argument
* NOTE: This structure may need to be updated when the OpenSBI submodule is updated.
*/
static struct __packed fw_dynamic_info {
unsigned long magic; // magic value "OSBI"
unsigned long version; // version number (2)
unsigned long next_addr; // Next booting stage address (payload address)
unsigned long next_mode; // Next booting stage mode (usually supervisor mode)
unsigned long options; // options for OpenSBI library
unsigned long boot_hart; // usually CONFIG_RISCV_WORKING_HARTID
} info;
void run_opensbi(const int hart_id,
const void *fdt,
@@ -15,21 +27,21 @@ void run_opensbi(const int hart_id,
const void *payload,
const int payload_mode)
{
struct fw_dynamic_info info = {
.magic = FW_DYNAMIC_INFO_MAGIC_VALUE,
.version = FW_DYNAMIC_INFO_VERSION_MAX,
.next_mode = payload_mode,
.next_addr = (uintptr_t)payload,
.options = 0,
.boot_hart = CONFIG_OPENSBI_FW_DYNAMIC_BOOT_HART,
};
info.magic = FW_DYNAMIC_INFO_MAGIC_VALUE,
info.version = FW_DYNAMIC_INFO_VERSION_2,
info.next_mode = payload_mode,
info.next_addr = (uintptr_t)payload,
info.options = 0,
info.boot_hart = CONFIG_OPENSBI_FW_DYNAMIC_BOOT_HART,
csr_write(mepc, opensbi);
write_csr(mepc, opensbi); // set program counter to OpenSBI (jumped to with mret)
asm volatile (
"mv a0, %0\n\t"
"mv a1, %1\n\t"
"mv a2, %2\n\t"
"mret" :
: "r"(hart_id), "r"(fdt), "r"(&info)
: "a0", "a1", "a2");
"mv a0, %0\n\t"
"mv a1, %1\n\t"
"mv a2, %2\n\t"
"mret"
:
: "r"(hart_id), "r"(fdt), "r"(&info)
: "a0", "a1", "a2"
);
}