mirror of https://github.com/xemu-project/xemu.git
hw/riscv/boot.c: Introduce riscv_find_firmware()
Rename previous riscv_find_firmware() to riscv_find_bios(), and introduce a new riscv_find_firmware() to implement the first half part of the work done in riscv_find_and_load_firmware(). This new API is helpful for machine that wants to know the final chosen firmware file name but does not want to load it. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20221229091828.1945072-12-bmeng@tinylab.org> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
9d3f7108bc
commit
8f6196266e
|
@ -84,11 +84,11 @@ const char *riscv_default_firmware_name(RISCVHartArrayState *harts)
|
||||||
return RISCV64_BIOS_BIN;
|
return RISCV64_BIOS_BIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *riscv_find_firmware(const char *firmware_filename)
|
static char *riscv_find_bios(const char *bios_filename)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware_filename);
|
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_filename);
|
||||||
if (filename == NULL) {
|
if (filename == NULL) {
|
||||||
if (!qtest_enabled()) {
|
if (!qtest_enabled()) {
|
||||||
/*
|
/*
|
||||||
|
@ -97,8 +97,8 @@ static char *riscv_find_firmware(const char *firmware_filename)
|
||||||
* running QEMU test will complain hence let's suppress the error
|
* running QEMU test will complain hence let's suppress the error
|
||||||
* report for QEMU testing.
|
* report for QEMU testing.
|
||||||
*/
|
*/
|
||||||
error_report("Unable to load the RISC-V firmware \"%s\"",
|
error_report("Unable to find the RISC-V BIOS \"%s\"",
|
||||||
firmware_filename);
|
bios_filename);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,24 +106,35 @@ static char *riscv_find_firmware(const char *firmware_filename)
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *riscv_find_firmware(const char *firmware_filename,
|
||||||
|
const char *default_machine_firmware)
|
||||||
|
{
|
||||||
|
char *filename = NULL;
|
||||||
|
|
||||||
|
if ((!firmware_filename) || (!strcmp(firmware_filename, "default"))) {
|
||||||
|
/*
|
||||||
|
* The user didn't specify -bios, or has specified "-bios default".
|
||||||
|
* That means we are going to load the OpenSBI binary included in
|
||||||
|
* the QEMU source.
|
||||||
|
*/
|
||||||
|
filename = riscv_find_bios(default_machine_firmware);
|
||||||
|
} else if (strcmp(firmware_filename, "none")) {
|
||||||
|
filename = riscv_find_bios(firmware_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
target_ulong riscv_find_and_load_firmware(MachineState *machine,
|
target_ulong riscv_find_and_load_firmware(MachineState *machine,
|
||||||
const char *default_machine_firmware,
|
const char *default_machine_firmware,
|
||||||
hwaddr firmware_load_addr,
|
hwaddr firmware_load_addr,
|
||||||
symbol_fn_t sym_cb)
|
symbol_fn_t sym_cb)
|
||||||
{
|
{
|
||||||
char *firmware_filename = NULL;
|
char *firmware_filename;
|
||||||
target_ulong firmware_end_addr = firmware_load_addr;
|
target_ulong firmware_end_addr = firmware_load_addr;
|
||||||
|
|
||||||
if ((!machine->firmware) || (!strcmp(machine->firmware, "default"))) {
|
firmware_filename = riscv_find_firmware(machine->firmware,
|
||||||
/*
|
default_machine_firmware);
|
||||||
* The user didn't specify -bios, or has specified "-bios default".
|
|
||||||
* That means we are going to load the OpenSBI binary included in
|
|
||||||
* the QEMU source.
|
|
||||||
*/
|
|
||||||
firmware_filename = riscv_find_firmware(default_machine_firmware);
|
|
||||||
} else if (strcmp(machine->firmware, "none")) {
|
|
||||||
firmware_filename = riscv_find_firmware(machine->firmware);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firmware_filename) {
|
if (firmware_filename) {
|
||||||
/* If not "none" load the firmware */
|
/* If not "none" load the firmware */
|
||||||
|
|
|
@ -38,6 +38,8 @@ target_ulong riscv_find_and_load_firmware(MachineState *machine,
|
||||||
hwaddr firmware_load_addr,
|
hwaddr firmware_load_addr,
|
||||||
symbol_fn_t sym_cb);
|
symbol_fn_t sym_cb);
|
||||||
const char *riscv_default_firmware_name(RISCVHartArrayState *harts);
|
const char *riscv_default_firmware_name(RISCVHartArrayState *harts);
|
||||||
|
char *riscv_find_firmware(const char *firmware_filename,
|
||||||
|
const char *default_machine_firmware);
|
||||||
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,
|
||||||
symbol_fn_t sym_cb);
|
symbol_fn_t sym_cb);
|
||||||
|
|
Loading…
Reference in New Issue