hw/riscv: Add optional symbol callback ptr to riscv_load_kernel()
This patch adds an optional function pointer, "sym_cb", to
riscv_load_kernel() which provides the possibility to access the symbol
table during kernel loading.
The pointer is ignored, if supplied with Image or uImage file.
The Spike board requires the access to locate the HTIF symbols.
Fixes: 0ac24d56c5
("hw/riscv: Split out the boot functions")
Buglink: https://bugs.launchpad.net/qemu/+bug/1835827
Signed-off-by: Siwei Zhuang <siwei.zhuang@data61.csiro.au>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
This commit is contained in:
parent
9c0fb20c4b
commit
6478dd745d
|
@ -114,12 +114,13 @@ target_ulong riscv_load_firmware(const char *firmware_filename,
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
target_ulong riscv_load_kernel(const char *kernel_filename)
|
target_ulong riscv_load_kernel(const char *kernel_filename, symbol_fn_t sym_cb)
|
||||||
{
|
{
|
||||||
uint64_t kernel_entry, kernel_high;
|
uint64_t kernel_entry, kernel_high;
|
||||||
|
|
||||||
if (load_elf(kernel_filename, NULL, NULL, NULL,
|
if (load_elf_ram_sym(kernel_filename, NULL, NULL, NULL,
|
||||||
&kernel_entry, NULL, &kernel_high, 0, EM_RISCV, 1, 0) > 0) {
|
&kernel_entry, NULL, &kernel_high, 0,
|
||||||
|
EM_RISCV, 1, 0, NULL, true, sym_cb) > 0) {
|
||||||
return kernel_entry;
|
return kernel_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ static void riscv_sifive_e_init(MachineState *machine)
|
||||||
memmap[SIFIVE_E_MROM].base, &address_space_memory);
|
memmap[SIFIVE_E_MROM].base, &address_space_memory);
|
||||||
|
|
||||||
if (machine->kernel_filename) {
|
if (machine->kernel_filename) {
|
||||||
riscv_load_kernel(machine->kernel_filename);
|
riscv_load_kernel(machine->kernel_filename, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -344,7 +344,8 @@ static void riscv_sifive_u_init(MachineState *machine)
|
||||||
memmap[SIFIVE_U_DRAM].base);
|
memmap[SIFIVE_U_DRAM].base);
|
||||||
|
|
||||||
if (machine->kernel_filename) {
|
if (machine->kernel_filename) {
|
||||||
uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename);
|
uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (machine->initrd_filename) {
|
if (machine->initrd_filename) {
|
||||||
hwaddr start;
|
hwaddr start;
|
||||||
|
|
|
@ -184,7 +184,7 @@ static void spike_board_init(MachineState *machine)
|
||||||
mask_rom);
|
mask_rom);
|
||||||
|
|
||||||
if (machine->kernel_filename) {
|
if (machine->kernel_filename) {
|
||||||
riscv_load_kernel(machine->kernel_filename);
|
riscv_load_kernel(machine->kernel_filename, htif_symbol_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset vector */
|
/* reset vector */
|
||||||
|
@ -273,7 +273,7 @@ static void spike_v1_10_0_board_init(MachineState *machine)
|
||||||
mask_rom);
|
mask_rom);
|
||||||
|
|
||||||
if (machine->kernel_filename) {
|
if (machine->kernel_filename) {
|
||||||
riscv_load_kernel(machine->kernel_filename);
|
riscv_load_kernel(machine->kernel_filename, htif_symbol_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset vector */
|
/* reset vector */
|
||||||
|
@ -359,7 +359,7 @@ static void spike_v1_09_1_board_init(MachineState *machine)
|
||||||
mask_rom);
|
mask_rom);
|
||||||
|
|
||||||
if (machine->kernel_filename) {
|
if (machine->kernel_filename) {
|
||||||
riscv_load_kernel(machine->kernel_filename);
|
riscv_load_kernel(machine->kernel_filename, htif_symbol_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset vector */
|
/* reset vector */
|
||||||
|
|
|
@ -479,7 +479,8 @@ static void riscv_virt_board_init(MachineState *machine)
|
||||||
memmap[VIRT_DRAM].base);
|
memmap[VIRT_DRAM].base);
|
||||||
|
|
||||||
if (machine->kernel_filename) {
|
if (machine->kernel_filename) {
|
||||||
uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename);
|
uint64_t kernel_entry = riscv_load_kernel(machine->kernel_filename,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (machine->initrd_filename) {
|
if (machine->initrd_filename) {
|
||||||
hwaddr start;
|
hwaddr start;
|
||||||
|
|
|
@ -28,7 +28,8 @@ void riscv_find_and_load_firmware(MachineState *machine,
|
||||||
char *riscv_find_firmware(const char *firmware_filename);
|
char *riscv_find_firmware(const char *firmware_filename);
|
||||||
target_ulong riscv_load_firmware(const char *firmware_filename,
|
target_ulong riscv_load_firmware(const char *firmware_filename,
|
||||||
hwaddr firmware_load_addr);
|
hwaddr firmware_load_addr);
|
||||||
target_ulong riscv_load_kernel(const char *kernel_filename);
|
target_ulong riscv_load_kernel(const char *kernel_filename,
|
||||||
|
symbol_fn_t sym_cb);
|
||||||
hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
|
hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
|
||||||
uint64_t kernel_entry, hwaddr *start);
|
uint64_t kernel_entry, hwaddr *start);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue