From: Alistair Francis <alistair23@gmail.com>
To: Bin Meng <bmeng@tinylab.org>
Cc: Alistair Francis <Alistair.Francis@wdc.com>,
qemu-devel@nongnu.org,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
Bin Meng <bin.meng@windriver.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
qemu-riscv@nongnu.org
Subject: Re: [PATCH 11/12] hw/riscv/boot.c: Introduce riscv_find_firmware()
Date: Wed, 28 Dec 2022 14:35:56 +1000 [thread overview]
Message-ID: <CAKmqyKPBQ98YN6HA3kREW2QWovU5FZJAva29__6RwLz3auOLSA@mail.gmail.com> (raw)
In-Reply-To: <20221227064812.1903326-12-bmeng@tinylab.org>
On Tue, Dec 27, 2022 at 4:55 PM Bin Meng <bmeng@tinylab.org> wrote:
>
> 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: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
>
> include/hw/riscv/boot.h | 2 ++
> hw/riscv/boot.c | 39 +++++++++++++++++++++++++--------------
> 2 files changed, 27 insertions(+), 14 deletions(-)
>
> diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
> index 60cf320c88..b273ab22f7 100644
> --- a/include/hw/riscv/boot.h
> +++ b/include/hw/riscv/boot.h
> @@ -38,6 +38,8 @@ target_ulong riscv_find_and_load_firmware(MachineState *machine,
> hwaddr firmware_load_addr,
> symbol_fn_t sym_cb);
> 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,
> hwaddr firmware_load_addr,
> symbol_fn_t sym_cb);
> diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
> index e1a544b1d9..98b80af51b 100644
> --- a/hw/riscv/boot.c
> +++ b/hw/riscv/boot.c
> @@ -84,11 +84,11 @@ const char *riscv_default_firmware_name(RISCVHartArrayState *harts)
> return RISCV64_BIOS_BIN;
> }
>
> -static char *riscv_find_firmware(const char *firmware_filename)
> +static char *riscv_find_bios(const char *bios_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 (!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
> * report for QEMU testing.
> */
> - error_report("Unable to load the RISC-V firmware \"%s\"",
> - firmware_filename);
> + error_report("Unable to find the RISC-V BIOS \"%s\"",
> + bios_filename);
> exit(1);
> }
> }
> @@ -106,25 +106,36 @@ static char *riscv_find_firmware(const char *firmware_filename)
> return filename;
> }
>
> -target_ulong riscv_find_and_load_firmware(MachineState *machine,
> - const char *default_machine_firmware,
> - hwaddr firmware_load_addr,
> - symbol_fn_t sym_cb)
> +char *riscv_find_firmware(const char *firmware_filename,
> + const char *default_machine_firmware)
> {
> - char *firmware_filename = NULL;
> - target_ulong firmware_end_addr = firmware_load_addr;
> + char *filename = NULL;
>
> - if ((!machine->firmware) || (!strcmp(machine->firmware, "default"))) {
> + 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.
> */
> - firmware_filename = riscv_find_firmware(default_machine_firmware);
> - } else if (strcmp(machine->firmware, "none")) {
> - firmware_filename = riscv_find_firmware(machine->firmware);
> + 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,
> + const char *default_machine_firmware,
> + hwaddr firmware_load_addr,
> + symbol_fn_t sym_cb)
> +{
> + char *firmware_filename;
> + target_ulong firmware_end_addr = firmware_load_addr;
> +
> + firmware_filename = riscv_find_firmware(machine->firmware,
> + default_machine_firmware);
> +
> if (firmware_filename) {
> /* If not "none" load the firmware */
> firmware_end_addr = riscv_load_firmware(firmware_filename,
> --
> 2.34.1
>
>
next prev parent reply other threads:[~2022-12-28 4:37 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-27 6:48 [PATCH 00/12] hw/riscv: Improve Spike HTIF emulation fidelity Bin Meng
2022-12-27 6:48 ` [PATCH 01/12] hw/char: riscv_htif: Avoid using magic numbers Bin Meng
2022-12-27 17:28 ` Daniel Henrique Barboza
2022-12-28 3:31 ` Alistair Francis
2022-12-27 6:48 ` [PATCH 02/12] hw/char: riscv_htif: Drop {to, from}host_size in HTIFState Bin Meng
2022-12-27 17:29 ` [PATCH 02/12] hw/char: riscv_htif: Drop {to,from}host_size " Daniel Henrique Barboza
2022-12-28 3:32 ` [PATCH 02/12] hw/char: riscv_htif: Drop {to, from}host_size " Alistair Francis
2022-12-27 6:48 ` [PATCH 03/12] hw/char: riscv_htif: Drop useless assignment of memory region Bin Meng
2022-12-27 17:30 ` Daniel Henrique Barboza
2022-12-28 3:33 ` Alistair Francis
2022-12-27 6:48 ` [PATCH 04/12] hw/char: riscv_htif: Use conventional 's' for HTIFState Bin Meng
2022-12-27 17:32 ` Daniel Henrique Barboza
2022-12-28 3:35 ` Alistair Francis
2022-12-27 6:48 ` [PATCH 05/12] hw/char: riscv_htif: Move registers from CPUArchState to HTIFState Bin Meng
2022-12-27 17:33 ` Daniel Henrique Barboza
2022-12-28 4:19 ` Alistair Francis
2022-12-27 6:48 ` [PATCH 06/12] hw/char: riscv_htif: Remove forward declarations for non-existent variables Bin Meng
2022-12-27 17:35 ` Daniel Henrique Barboza
2022-12-28 4:22 ` Alistair Francis
2022-12-27 6:48 ` [PATCH 07/12] hw/char: riscv_htif: Support console output via proxy syscall Bin Meng
2022-12-27 17:37 ` Daniel Henrique Barboza
2022-12-28 4:30 ` Alistair Francis
2022-12-27 6:48 ` [PATCH 08/12] hw/riscv: spike: Remove the out-of-date comments Bin Meng
2022-12-27 17:37 ` Daniel Henrique Barboza
2022-12-28 4:30 ` Alistair Francis
2022-12-27 6:48 ` [PATCH 09/12] hw/riscv/boot.c: make riscv_find_firmware() static Bin Meng
2022-12-27 6:48 ` [PATCH 10/12] hw/riscv/boot.c: introduce riscv_default_firmware_name() Bin Meng
2022-12-27 6:48 ` [PATCH 11/12] hw/riscv/boot.c: Introduce riscv_find_firmware() Bin Meng
2022-12-27 17:40 ` Daniel Henrique Barboza
2022-12-28 4:35 ` Alistair Francis [this message]
2022-12-27 6:48 ` [PATCH 12/12] hw/riscv: spike: Decouple create_fdt() dependency to ELF loading Bin Meng
2022-12-27 14:33 ` Daniel Henrique Barboza
2022-12-27 17:51 ` [PATCH 00/12] hw/riscv: Improve Spike HTIF emulation fidelity Daniel Henrique Barboza
2022-12-28 3:58 ` Bin Meng
2022-12-28 4:21 ` Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKmqyKPBQ98YN6HA3kREW2QWovU5FZJAva29__6RwLz3auOLSA@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=Alistair.Francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=bmeng@tinylab.org \
--cc=dbarboza@ventanamicro.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).