diff options
author | Maximilian Brune <maximilian.brune@9elements.com> | 2024-07-25 00:12:21 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-07-26 13:05:41 +0000 |
commit | 07f013111654ccb6e8fdb71d697d11f892910c1e (patch) | |
tree | b55c0eb2467a78cbc08cf13132573e5f234d1eb3 | |
parent | 7dae497495a822fb1bb5d8c4a73eff78494d80b3 (diff) |
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>
-rw-r--r-- | src/arch/riscv/Makefile.mk | 1 | ||||
-rw-r--r-- | src/arch/riscv/opensbi.c | 56 |
2 files changed, 34 insertions, 23 deletions
diff --git a/src/arch/riscv/Makefile.mk b/src/arch/riscv/Makefile.mk index d5defea0e7..6754c2202d 100644 --- a/src/arch/riscv/Makefile.mk +++ b/src/arch/riscv/Makefile.mk @@ -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 diff --git a/src/arch/riscv/opensbi.c b/src/arch/riscv/opensbi.c index bf26b2279e..36f2951559 100644 --- a/src/arch/riscv/opensbi.c +++ b/src/arch/riscv/opensbi.c @@ -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" + ); } |