1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <arch/encoding.h>
8 #define FW_DYNAMIC_INFO_VERSION_2 2
9 #define FW_DYNAMIC_INFO_MAGIC_VALUE 0x4942534f // "OSBI"
12 * structure passed to OpenSBI as 3rd argument
13 * NOTE: This structure may need to be updated when the OpenSBI submodule is updated.
15 static struct __packed fw_dynamic_info
{
16 unsigned long magic
; // magic value "OSBI"
17 unsigned long version
; // version number (2)
18 unsigned long next_addr
; // Next booting stage address (payload address)
19 unsigned long next_mode
; // Next booting stage mode (usually supervisor mode)
20 unsigned long options
; // options for OpenSBI library
21 unsigned long boot_hart
; // usually CONFIG_RISCV_WORKING_HARTID
24 void run_opensbi(const int hart_id
,
28 const int payload_mode
)
30 info
.magic
= FW_DYNAMIC_INFO_MAGIC_VALUE
,
31 info
.version
= FW_DYNAMIC_INFO_VERSION_2
,
32 info
.next_mode
= payload_mode
,
33 info
.next_addr
= (uintptr_t)payload
,
35 info
.boot_hart
= CONFIG_OPENSBI_FW_DYNAMIC_BOOT_HART
,
37 write_csr(mepc
, opensbi
); // set program counter to OpenSBI (jumped to with mret)
44 : "r"(hart_id
), "r"(fdt
), "r"(&info
)