Skip to content

Commit

Permalink
riscv: Add a helper routine for finding firmware
Browse files Browse the repository at this point in the history
This adds a helper routine for finding firmware. It is currently
used only for "-bios default" case.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
  • Loading branch information
lbmeng authored and palmer-dabbelt committed Sep 17, 2019
1 parent ddf7813 commit 751f8f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
22 changes: 15 additions & 7 deletions hw/riscv/boot.c
Expand Up @@ -69,13 +69,7 @@ void riscv_find_and_load_firmware(MachineState *machine,
* so then in the future we can make "-bios default" the default option
* if no -bios option is set without breaking anything.
*/
firmware_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
default_machine_firmware);
if (firmware_filename == NULL) {
error_report("Unable to load the default RISC-V firmware \"%s\"",
default_machine_firmware);
exit(1);
}
firmware_filename = riscv_find_firmware(default_machine_firmware);
} else {
firmware_filename = machine->firmware;
}
Expand All @@ -90,6 +84,20 @@ void riscv_find_and_load_firmware(MachineState *machine,
}
}

char *riscv_find_firmware(const char *firmware_filename)
{
char *filename;

filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware_filename);
if (filename == NULL) {
error_report("Unable to load the RISC-V firmware \"%s\"",
firmware_filename);
exit(1);
}

return filename;
}

target_ulong riscv_load_firmware(const char *firmware_filename,
hwaddr firmware_load_addr)
{
Expand Down
1 change: 1 addition & 0 deletions include/hw/riscv/boot.h
Expand Up @@ -25,6 +25,7 @@
void riscv_find_and_load_firmware(MachineState *machine,
const char *default_machine_firmware,
hwaddr firmware_load_addr);
char *riscv_find_firmware(const char *firmware_filename);
target_ulong riscv_load_firmware(const char *firmware_filename,
hwaddr firmware_load_addr);
target_ulong riscv_load_kernel(const char *kernel_filename);
Expand Down

0 comments on commit 751f8f4

Please sign in to comment.