Skip to contentSkip to conversation

remove bios_name variable

PATCH In review Paolo Bonzini 11 participants 52 messages Oct 26, 2020 – Oct 27, 2020 Arm/versatile express platform

lore
Share & tools
lore
#0 lore raw

cover remove bios_name variable

The bios_name variable is mostly a duplicate of machine->firmware. Only three cases need some care (i386, digic and rx), everything else is mechanical.

Paolo Bonzini (15):
alpha: remove bios_name
digic: stash firmware into DigicState
arm: remove bios_name
hppa: remove bios_name
i386: remove bios_name
lm32: remove bios_name
m68k: remove bios_name
mips: remove bios_name
moxie: remove bios_name
ppc: remove bios_name
rx: move BIOS load from MCU to board
s390: remove bios_name
sh4: remove bios_name
sparc: remove bios_name
vl: remove bios_name

 hw/alpha/dp264.c           |  2 +-
 hw/arm/cubieboard.c        |  2 +-
 hw/arm/digic_boards.c      |  5 +++--
 hw/arm/highbank.c          |  8 ++++----
 hw/arm/npcm7xx_boards.c    |  5 +----
 hw/arm/orangepi.c          |  2 +-
 hw/arm/sbsa-ref.c          |  2 ++
 hw/arm/vexpress.c          |  8 ++++----
 hw/arm/virt.c              |  2 ++
 hw/hppa/machine.c          |  3 +--
 hw/i386/microvm.c          |  7 +++----
 hw/i386/pc_sysfw.c         |  4 ++--
 hw/i386/x86.c              | 10 ++++------
 hw/lm32/milkymist.c        |  4 +---
 hw/m68k/mcf5208.c          | 10 +++++-----
 hw/m68k/next-cube.c        |  4 +---
 hw/m68k/q800.c             |  4 +---
 hw/mips/fuloong2e.c        |  6 +++---
 hw/mips/jazz.c             |  6 +++---
 hw/mips/malta.c            |  6 +++---
 hw/mips/mipssim.c          |  6 +++---
 hw/mips/r4k.c              |  4 +---
 hw/moxie/moxiesim.c        |  6 +++---
 hw/ppc/e500.c              |  4 ++--
 hw/ppc/mac_newworld.c      |  4 +---
 hw/ppc/mac_oldworld.c      |  4 +---
 hw/ppc/pnv.c               |  5 +----
 hw/ppc/ppc405_boards.c     |  6 ++----
 hw/ppc/prep.c              |  4 +---
 hw/ppc/spapr.c             |  4 +---
 hw/rx/rx-gdbsim.c          |  7 +++++++
 hw/rx/rx62n.c              |  9 ---------
 hw/s390x/ipl.c             |  8 ++------
 hw/s390x/s390-virtio-ccw.c |  3 ++-
 hw/sh4/shix.c              |  3 +--
 hw/sparc/leon3.c           |  4 +---
 hw/sparc/sun4m.c           |  2 +-
 hw/sparc64/sun4u.c         |  2 +-
 include/hw/arm/digic.h     |  1 +
 include/hw/i386/x86.h      |  3 ++-
 include/sysemu/sysemu.h    |  1 -
 softmmu/vl.c               |  2 --
 42 files changed, 80 insertions(+), 112 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/15 alpha: remove bios_name

Cc Richard Henderson <[email protected]>
---
 hw/alpha/dp264.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/alpha/dp264.c +1 -1
index 4d24518d1d..c4d407a9f1 100644
@@ -107,7 +107,7 @@ static void clipper_init(MachineState *machine)
        but one explicitly written for the emulation, we might as
        well load it directly from and ELF image.  */
     palcode_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
-                                bios_name ? bios_name : "palcode-clipper");
+                                      machine->firmware ?: "palcode-clipper");
     if (palcode_filename == NULL) {
         error_report("no palcode provided");
         exit(1);
Signature · 1 line
2.26.2
#4 lore raw

PATCH 2/15 digic: stash firmware into DigicState

In reply to Paolo Bonzini

Prepare for removing bios_name.

---
 hw/arm/digic_boards.c  | 5 +++--
 include/hw/arm/digic.h | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)
hw/arm/digic_boards.c +3 -2
index d5524d3e72..d320b54c44 100644
@@ -55,6 +55,7 @@ static void digic4_board_init(MachineState *machine, DigicBoard *board)
     DigicState *s = DIGIC(object_new(TYPE_DIGIC));
     MachineClass *mc = MACHINE_GET_CLASS(machine);
 
+    s->firmware = machine->firmware;
     if (machine->ram_size != mc->default_ram_size) {
         char *sz = size_to_str(mc->default_ram_size);
         error_report("Invalid RAM size, should be %s", sz);
@@ -91,8 +92,8 @@ static void digic_load_rom(DigicState *s, hwaddr addr,
         return;
     }
 
-    if (bios_name) {
-        filename = bios_name;
+    if (s->firmware) {
+        filename = s->firmware;
     } else {
         filename = def_filename;
     }
include/hw/arm/digic.h +1 -0
index 8f2735c284..421dae937e 100644
@@ -36,6 +36,7 @@ struct DigicState {
 
     ARMCPU cpu;
 
+    const char *firmware;
     DigicTimerState timer[DIGIC4_NB_TIMERS];
     DigicUartState uart;
 };
Signature · 1 line
2.26.2
#5 lore raw

Re: [PATCH 02/15] digic: stash firmware into DigicState

Quoted 23 lines · Paolo Bonzini

Prepare for removing bios_name.

---
 hw/arm/digic_boards.c  | 5 +++--
 include/hw/arm/digic.h | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)
hw/arm/digic_boards.c +1 -0
index d5524d3e72..d320b54c44 100644
@@ -55,6 +55,7 @@ static void digic4_board_init(MachineState *machine, DigicBoard *board)
     DigicState *s = DIGIC(object_new(TYPE_DIGIC));
     MachineClass *mc = MACHINE_GET_CLASS(machine);
 
+    s->firmware = machine->firmware;
     if (machine->ram_size != mc->default_ram_size) {
         char *sz = size_to_str(mc->default_ram_size);
         error_report("Invalid RAM size, should be %s", sz);

hw/arm/digic_boards.c static void digic_load_rom(DigicState *s, hwaddr addr, · line 99

Quoted 10 lines
hw/arm/digic_boards.c +2 -2
@@ -91,8 +92,8 @@ static void digic_load_rom(DigicState *s, hwaddr addr,
         return;
     }
 
-    if (bios_name) {
-        filename = bios_name;
+    if (s->firmware) {
+        filename = s->firmware;
     } else {
         filename = def_filename;
     }

The existing code is a little odd, because if the user passes -bios then we use it in both the add_rom0 and add_rom1 callbacks; however this ends up not mattering for the moment because the only supported Digic board has just the rom1 and no rom0.

Anyway, rather than stashing the firmware filename in the DigicState, you could lift the "decide whether to use machine->firmware or the def_filename" choice up to the callsites in digic4_board_init():

    if (board->add_rom0) {
        board->add_rom0(s, DIGIC4_ROM0_BASE,
                        machine->firmware ?: board->rom0_def_filename);
    }

(and similarly for rom1).

Then you can delete the

    if (bios_name) {
        filename = bios_name;
    } else {
        filename = def_filename;
    }

block from digic_load_rom() and rename the arguments of digic_load_rom() and digic4_add_k8p3215uqb_rom() to just "filename" rather than "def_filename".

Doing it that way avoids passing things around that we don't need to, and makes it clear in the digic4_board_init() code that we're doing something a bit suspect in possibly using the machine->firmware file twice -- if we ever need to fix that bug then it'll be a simple change to the logic in that one function.

thanks
-- PMM

#6 lore raw

Re: [PATCH 02/15] digic: stash firmware into DigicState

Quoted 21 lines · Peter Maydell

Anyway, rather than stashing the firmware filename in the DigicState, you could lift the "decide whether to use machine->firmware or the def_filename" choice up to the callsites in digic4_board_init():

    if (board->add_rom0) {
        board->add_rom0(s, DIGIC4_ROM0_BASE,
                        machine->firmware ?: board->rom0_def_filename);
    }

(and similarly for rom1).

Then you can delete the

    if (bios_name) {
        filename = bios_name;
    } else {
        filename = def_filename;
    }

block from digic_load_rom() and rename the arguments of digic_load_rom() and digic4_add_k8p3215uqb_rom() to just "filename" rather than "def_filename".

Quoted 6 lines

Doing it that way avoids passing things around that we don't need to, and makes it clear in the digic4_board_init() code that we're doing something a bit suspect in possibly using the machine->firmware file twice -- if we ever need to fix that bug then it'll be a simple change to the logic in that one function.

Much better indeed, thanks!

Paolo

#7 lore raw

PATCH 3/15 arm: remove bios_name

In reply to Paolo Bonzini

Get the firmware name from the MachineState object.

---
 hw/arm/cubieboard.c     | 2 +-
 hw/arm/highbank.c       | 8 ++++----
 hw/arm/npcm7xx_boards.c | 5 +----
 hw/arm/orangepi.c       | 2 +-
 hw/arm/sbsa-ref.c       | 2 ++
 hw/arm/vexpress.c       | 8 ++++----
 hw/arm/virt.c           | 2 ++
 7 files changed, 15 insertions(+), 14 deletions(-)
hw/arm/cubieboard.c +1 -1
index 1c6c792eb6..9d0d728180 100644
@@ -40,7 +40,7 @@ static void cubieboard_init(MachineState *machine)
     DeviceState *carddev;
 
     /* BIOS is not supported by this board */
-    if (bios_name) {
+    if (machine->firmware) {
         error_report("BIOS not supported for this machine");
         exit(1);
     }
hw/arm/highbank.c +4 -4
index da0510d7ce..8c18971790 100644
@@ -295,16 +295,16 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
     memory_region_init_ram(sysram, NULL, "highbank.sysram", 0x8000,
                            &error_fatal);
     memory_region_add_subregion(sysmem, 0xfff88000, sysram);
-    if (bios_name != NULL) {
-        sysboot_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+    if (machine->firmware != NULL) {
+        sysboot_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware);
         if (sysboot_filename != NULL) {
             if (load_image_targphys(sysboot_filename, 0xfff88000, 0x8000) < 0) {
-                error_report("Unable to load %s", bios_name);
+                error_report("Unable to load %s", machine->firmware);
                 exit(1);
             }
             g_free(sysboot_filename);
         } else {
-            error_report("Unable to find %s", bios_name);
+            error_report("Unable to find %s", machine->firmware);
             exit(1);
         }
     }
hw/arm/npcm7xx_boards.c +1 -4
index 79e2e2744c..9821013bc6 100644
@@ -33,13 +33,10 @@ static const char npcm7xx_default_bootrom[] = "npcm7xx_bootrom.bin";
 
 static void npcm7xx_load_bootrom(MachineState *machine, NPCM7xxState *soc)
 {
+    const char *bios_name = machine->firmware ?: npcm7xx_default_bootrom;
     g_autofree char *filename = NULL;
     int ret;
 
-    if (!bios_name) {
-        bios_name = npcm7xx_default_bootrom;
-    }
-
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (!filename) {
         error_report("Could not find ROM image '%s'", bios_name);
hw/arm/orangepi.c +1 -1
index 17a568a2b4..d6306dfdda 100644
@@ -41,7 +41,7 @@ static void orangepi_init(MachineState *machine)
     DeviceState *carddev;
 
     /* BIOS is not supported by this board */
-    if (bios_name) {
+    if (machine->firmware) {
         error_report("BIOS not supported for this machine");
         exit(1);
     }
hw/arm/sbsa-ref.c +2 -0
index 01863510d0..8372ed901d 100644
@@ -294,6 +294,7 @@ static bool sbsa_firmware_init(SBSAMachineState *sms,
                                MemoryRegion *sysmem,
                                MemoryRegion *secure_sysmem)
 {
+    const char *bios_name;
     int i;
     BlockBackend *pflash_blk0;
 
@@ -307,6 +308,7 @@ static bool sbsa_firmware_init(SBSAMachineState *sms,
 
     pflash_blk0 = pflash_cfi01_get_blk(sms->flash[0]);
 
+    bios_name = MACHINE(sms)->firmware;
     if (bios_name) {
         char *fname;
         MemoryRegion *mr;
hw/arm/vexpress.c +4 -4
index 531f3a122a..1adb663d77 100644
@@ -560,7 +560,7 @@ static void vexpress_common_init(MachineState *machine)
     /*
      * If a bios file was provided, attempt to map it into memory
      */
-    if (bios_name) {
+    if (machine->firmware) {
         char *fn;
         int image_size;
 
@@ -570,16 +570,16 @@ static void vexpress_common_init(MachineState *machine)
                          "but you cannot use both options at once");
             exit(1);
         }
-        fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+        fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware);
         if (!fn) {
-            error_report("Could not find ROM image '%s'", bios_name);
+            error_report("Could not find ROM image '%s'", machine->firmware);
             exit(1);
         }
         image_size = load_image_targphys(fn, map[VE_NORFLASH0],
                                          VEXPRESS_FLASH_SIZE);
         g_free(fn);
         if (image_size < 0) {
-            error_report("Could not load ROM image '%s'", bios_name);
+            error_report("Could not load ROM image '%s'", machine->firmware);
             exit(1);
         }
     }
hw/arm/virt.c +2 -0
index e465a988d6..5c7e3d18db 100644
@@ -1047,6 +1047,7 @@ static bool virt_firmware_init(VirtMachineState *vms,
                                MemoryRegion *secure_sysmem)
 {
     int i;
+    const char *bios_name;
     BlockBackend *pflash_blk0;
 
     /* Map legacy -drive if=pflash to machine properties */
@@ -1059,6 +1060,7 @@ static bool virt_firmware_init(VirtMachineState *vms,
 
     pflash_blk0 = pflash_cfi01_get_blk(vms->flash[0]);
 
+    bios_name = MACHINE(vms)->firmware;
     if (bios_name) {
         char *fname;
         MemoryRegion *mr;
Signature · 1 line
2.26.2
#9 lore raw

PATCH 4/15 hppa: remove bios_name

In reply to Paolo Bonzini
Cc Richard Henderson <[email protected]>
---
 hw/hppa/machine.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/hppa/machine.c +1 -2
index d5164457ee..5e745d5ea9 100644
@@ -213,8 +213,7 @@ static void machine_hppa_init(MachineState *machine)
        but one explicitly written for the emulation, we might as
        well load it directly from an ELF image.  */
     firmware_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
-                                       bios_name ? bios_name :
-                                       "hppa-firmware.img");
+                                       machine->firmware ?: "hppa-firmware.img");
     if (firmware_filename == NULL) {
         error_report("no firmware provided");
         exit(1);
Signature · 1 line
2.26.2
#12 lore raw

PATCH 5/15 i386: remove bios_name

In reply to Paolo Bonzini
---
 hw/i386/microvm.c     |  7 +++----
 hw/i386/pc_sysfw.c    |  4 ++--
 hw/i386/x86.c         | 10 ++++------
 include/hw/i386/x86.h |  3 ++-
 4 files changed, 11 insertions(+), 13 deletions(-)
hw/i386/microvm.c +3 -4
index 5428448b70..6cda3014d6 100644
@@ -154,6 +154,7 @@ static void create_gpex(MicrovmMachineState *mms)
 
 static void microvm_devices_init(MicrovmMachineState *mms)
 {
+    const char *default_firmware;
     X86MachineState *x86ms = X86_MACHINE(mms);
     ISABus *isa_bus;
     ISADevice *rtc_state;
@@ -259,12 +260,10 @@ static void microvm_devices_init(MicrovmMachineState *mms)
         serial_hds_isa_init(isa_bus, 0, 1);
     }
 
-    if (bios_name == NULL) {
-        bios_name = x86_machine_is_acpi_enabled(x86ms)
+    default_firmware = x86_machine_is_acpi_enabled(x86ms)
             ? MICROVM_BIOS_FILENAME
             : MICROVM_QBOOT_FILENAME;
-    }
-    x86_bios_rom_init(get_system_memory(), true);
+    x86_bios_rom_init(MACHINE(mms), default_firmware, get_system_memory(), true);
 }
 
 static void microvm_memory_init(MicrovmMachineState *mms)
hw/i386/pc_sysfw.c +2 -2
index b6c0822fe3..0187f0a934 100644
@@ -222,7 +222,7 @@ void pc_system_firmware_init(PCMachineState *pcms,
     BlockBackend *pflash_blk[ARRAY_SIZE(pcms->flash)];
 
     if (!pcmc->pci_enabled) {
-        x86_bios_rom_init(rom_memory, true);
+        x86_bios_rom_init(MACHINE(pcms), "bios.bin", rom_memory, true);
         return;
     }
 
@@ -243,7 +243,7 @@ void pc_system_firmware_init(PCMachineState *pcms,
 
     if (!pflash_blk[0]) {
         /* Machine property pflash0 not set, use ROM mode */
-        x86_bios_rom_init(rom_memory, false);
+        x86_bios_rom_init(MACHINE(pcms), "bios.bin", rom_memory, false);
     } else {
         if (kvm_enabled() && !kvm_readonly_mem_enabled()) {
             /*
hw/i386/x86.c +4 -6
index 5944fc44ed..836d388248 100644
@@ -54,8 +54,6 @@
 #include CONFIG_DEVICES
 #include "kvm_i386.h"
 
-#define BIOS_FILENAME "bios.bin"
-
 /* Physical Address of PVH entry point read from kernel ELF NOTE */
 static size_t pvh_start_addr;
 
@@ -1051,17 +1049,17 @@ void x86_load_linux(X86MachineState *x86ms,
     nb_option_roms++;
 }
 
-void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
+void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
+                       MemoryRegion *rom_memory, bool isapc_ram_fw)
 {
+    const char *bios_name;
     char *filename;
     MemoryRegion *bios, *isa_bios;
     int bios_size, isa_bios_size;
     int ret;
 
     /* BIOS load */
-    if (bios_name == NULL) {
-        bios_name = BIOS_FILENAME;
-    }
+    bios_name = ms->firmware ?: default_firmware;
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (filename) {
         bios_size = get_image_size(filename);
include/hw/i386/x86.h +2 -1
index bfa9cb2a25..e92ddeaed1 100644
@@ -101,7 +101,8 @@ void x86_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
 void x86_cpu_unplug_cb(HotplugHandler *hotplug_dev,
                        DeviceState *dev, Error **errp);
 
-void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw);
+void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
+                       MemoryRegion *rom_memory, bool isapc_ram_fw);
 
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
Signature · 1 line
2.26.2
#14 lore raw

PATCH 6/15 lm32: remove bios_name

In reply to Paolo Bonzini
---
 hw/lm32/milkymist.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
hw/lm32/milkymist.c +1 -3
index 9f8fe9fef1..c5d3d77a2b 100644
@@ -108,6 +108,7 @@ static void
 milkymist_init(MachineState *machine)
 {
     MachineClass *mc = MACHINE_GET_CLASS(machine);
+    const char *bios_name = machine->firmware ? BIOS_FILENAME:
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
@@ -162,9 +163,6 @@ milkymist_init(MachineState *machine)
     }
 
     /* load bios rom */
-    if (bios_name == NULL) {
-        bios_name = BIOS_FILENAME;
-    }
     bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 
     if (bios_filename) {
Signature · 1 line
2.26.2
#16 lore raw

Re: [PATCH 06/15] lm32: remove bios_name

In reply to Paolo Bonzini
Quoted 11 lines · Paolo Bonzini
---
  hw/lm32/milkymist.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
hw/lm32/milkymist.c +0 -0
index 9f8fe9fef1..c5d3d77a2b 100644

hw/lm32/milkymist.c static void · line 111

Quoted 4 lines
hw/lm32/milkymist.c +1 -0
@@ -108,6 +108,7 @@ static void
  milkymist_init(MachineState *machine)
  {
      MachineClass *mc = MACHINE_GET_CLASS(machine);
+    const char *bios_name = machine->firmware ? BIOS_FILENAME:

Does that build?

Quoted 14 lines
hw/lm32/milkymist.c +0 -3
      const char *kernel_filename = machine->kernel_filename;
      const char *kernel_cmdline = machine->kernel_cmdline;
      const char *initrd_filename = machine->initrd_filename;
@@ -162,9 +163,6 @@ milkymist_init(MachineState *machine)
      }
 
      /* load bios rom */
-    if (bios_name == NULL) {
-        bios_name = BIOS_FILENAME;
-    }
      bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 
      if (bios_filename) {
#17 lore raw

PATCH 7/15 m68k: remove bios_name

In reply to Paolo Bonzini
---
 hw/m68k/mcf5208.c   | 10 +++++-----
 hw/m68k/next-cube.c |  4 +---
 hw/m68k/q800.c      |  4 +---
 3 files changed, 7 insertions(+), 11 deletions(-)
hw/m68k/mcf5208.c +5 -5
index d310a98e7b..7c8ca5ddf6 100644
@@ -301,17 +301,17 @@ static void mcf5208evb_init(MachineState *machine)
     /* 0xfc0a8000 SDRAM controller.  */
 
     /* Load firmware */
-    if (bios_name) {
+    if (machine->firmware) {
         char *fn;
         uint8_t *ptr;
 
-        fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+        fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware);
         if (!fn) {
-            error_report("Could not find ROM image '%s'", bios_name);
+            error_report("Could not find ROM image '%s'", machine->firmware);
             exit(1);
         }
         if (load_image_targphys(fn, 0x0, ROM_SIZE) < 8) {
-            error_report("Could not load ROM image '%s'", bios_name);
+            error_report("Could not load ROM image '%s'", machine->firmware);
             exit(1);
         }
         g_free(fn);
@@ -323,7 +323,7 @@ static void mcf5208evb_init(MachineState *machine)
 
     /* Load kernel.  */
     if (!kernel_filename) {
-        if (qtest_enabled() || bios_name) {
+        if (qtest_enabled() || machine->firmware) {
             return;
         }
         error_report("Kernel image must be specified");
hw/m68k/next-cube.c +1 -3
index e7045980b7..37bc35dfa4 100644
@@ -868,6 +868,7 @@ static void next_cube_init(MachineState *machine)
     MemoryRegion *bmapm1 = g_new(MemoryRegion, 1);
     MemoryRegion *bmapm2 = g_new(MemoryRegion, 1);
     MemoryRegion *sysmem = get_system_memory();
+    const char *bios_name = machine->firmware ?: ROM_FILE;
     NeXTState *ns = NEXT_MACHINE(machine);
     DeviceState *dev;
 
@@ -924,9 +925,6 @@ static void next_cube_init(MachineState *machine)
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x0200e000);
 
     /* Load ROM here */
-    if (bios_name == NULL) {
-        bios_name = ROM_FILE;
-    }
     /* still not sure if the rom should also be mapped at 0x0*/
     memory_region_init_rom(rom, NULL, "next.rom", 0x20000, &error_fatal);
     memory_region_add_subregion(sysmem, 0x01000000, rom);
hw/m68k/q800.c +1 -3
index ce4b47c3e3..6ebcddcfb2 100644
@@ -167,6 +167,7 @@ static void q800_init(MachineState *machine)
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
+    const char *bios_name = machine->firmware ?: MACROM_FILENAME;
     hwaddr parameters_base;
     CPUState *cs;
     DeviceState *dev;
@@ -400,9 +401,6 @@ static void q800_init(MachineState *machine)
         rom = g_malloc(sizeof(*rom));
         memory_region_init_rom(rom, NULL, "m68k_mac.rom", MACROM_SIZE,
                                &error_abort);
-        if (bios_name == NULL) {
-            bios_name = MACROM_FILENAME;
-        }
         filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
         memory_region_add_subregion(get_system_memory(), MACROM_ADDR, rom);
 
Signature · 1 line
2.26.2
Acked-by on v1 7/15
#21 lore raw

Re: [PATCH 07/15] m68k: remove bios_name

In reply to Paolo Bonzini

Le 26/10/2020 à 15:30, Paolo Bonzini a écrit :

Quoted 35 lines
---
 hw/m68k/mcf5208.c   | 10 +++++-----
 hw/m68k/next-cube.c |  4 +---
 hw/m68k/q800.c      |  4 +---
 3 files changed, 7 insertions(+), 11 deletions(-)
hw/m68k/mcf5208.c +4 -4
index d310a98e7b..7c8ca5ddf6 100644
@@ -301,17 +301,17 @@ static void mcf5208evb_init(MachineState *machine)
     /* 0xfc0a8000 SDRAM controller.  */
 
     /* Load firmware */
-    if (bios_name) {
+    if (machine->firmware) {
         char *fn;
         uint8_t *ptr;
 
-        fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+        fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware);
         if (!fn) {
-            error_report("Could not find ROM image '%s'", bios_name);
+            error_report("Could not find ROM image '%s'", machine->firmware);
             exit(1);
         }
         if (load_image_targphys(fn, 0x0, ROM_SIZE) < 8) {
-            error_report("Could not load ROM image '%s'", bios_name);
+            error_report("Could not load ROM image '%s'", machine->firmware);
             exit(1);
         }
         g_free(fn);

hw/m68k/mcf5208.c static void mcf5208evb_init(MachineState *machine) · line 329

Quoted 8 lines
hw/m68k/mcf5208.c +1 -1
@@ -323,7 +323,7 @@ static void mcf5208evb_init(MachineState *machine)
 
     /* Load kernel.  */
     if (!kernel_filename) {
-        if (qtest_enabled() || bios_name) {
+        if (qtest_enabled() || machine->firmware) {
             return;
         }
         error_report("Kernel image must be specified");

Why do you do differently for mcf5208 than the others?

    const char *bios_name = machine->firmware;

and no other changes?

With or without this:

Quoted 45 lines
hw/m68k/next-cube.c +1 -3
index e7045980b7..37bc35dfa4 100644
@@ -868,6 +868,7 @@ static void next_cube_init(MachineState *machine)
     MemoryRegion *bmapm1 = g_new(MemoryRegion, 1);
     MemoryRegion *bmapm2 = g_new(MemoryRegion, 1);
     MemoryRegion *sysmem = get_system_memory();
+    const char *bios_name = machine->firmware ?: ROM_FILE;
     NeXTState *ns = NEXT_MACHINE(machine);
     DeviceState *dev;
 
@@ -924,9 +925,6 @@ static void next_cube_init(MachineState *machine)
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x0200e000);
 
     /* Load ROM here */
-    if (bios_name == NULL) {
-        bios_name = ROM_FILE;
-    }
     /* still not sure if the rom should also be mapped at 0x0*/
     memory_region_init_rom(rom, NULL, "next.rom", 0x20000, &error_fatal);
     memory_region_add_subregion(sysmem, 0x01000000, rom);
hw/m68k/q800.c +1 -3
index ce4b47c3e3..6ebcddcfb2 100644
@@ -167,6 +167,7 @@ static void q800_init(MachineState *machine)
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
+    const char *bios_name = machine->firmware ?: MACROM_FILENAME;
     hwaddr parameters_base;
     CPUState *cs;
     DeviceState *dev;
@@ -400,9 +401,6 @@ static void q800_init(MachineState *machine)
         rom = g_malloc(sizeof(*rom));
         memory_region_init_rom(rom, NULL, "m68k_mac.rom", MACROM_SIZE,
                                &error_abort);
-        if (bios_name == NULL) {
-            bios_name = MACROM_FILENAME;
-        }
         filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
         memory_region_add_subregion(get_system_memory(), MACROM_ADDR, rom);
 
#22 lore raw

Re: [PATCH 07/15] m68k: remove bios_name

Quoted 7 lines · Laurent Vivier

hw/m68k/mcf5208.c static void mcf5208evb_init(MachineState *machine) · line 329

Quoted 7 lines
     /* Load kernel.  */
     if (!kernel_filename) {
hw/m68k/mcf5208.c +1 -1
-        if (qtest_enabled() || bios_name) {
+        if (qtest_enabled() || machine->firmware) {
             return;
         }
         error_report("Kernel image must be specified");
Quoted 5 lines

Why do you do differently for mcf5208 than the others?

    const char *bios_name = machine->firmware;

and no other changes?

because in this case you can use machine->firmware, I'm keeping bios_name for the cases where machine->firmware cannot be used directly (e.g. there is a default).

Paolo

#23 lore raw

PATCH 8/15 mips: remove bios_name

In reply to Paolo Bonzini
Cc Philippe Mathieu-Daudé <[email protected]>
---
 hw/mips/fuloong2e.c | 6 +++---
 hw/mips/jazz.c      | 6 +++---
 hw/mips/malta.c     | 6 +++---
 hw/mips/mipssim.c   | 6 +++---
 hw/mips/r4k.c       | 4 +---
 5 files changed, 13 insertions(+), 15 deletions(-)
hw/mips/fuloong2e.c +3 -3
index a9e0c2f8d3..25b679011f 100644
@@ -338,7 +338,7 @@ static void mips_fuloong2e_init(MachineState *machine)
         write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);
     } else {
         filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
-                                  bios_name ?: FULOONG_BIOSNAME);
+                                  machine->firmware ?: FULOONG_BIOSNAME);
         if (filename) {
             bios_size = load_image_targphys(filename, 0x1fc00000LL,
                                             BIOS_SIZE);
@@ -348,8 +348,8 @@ static void mips_fuloong2e_init(MachineState *machine)
         }
 
         if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
-            bios_name && !qtest_enabled()) {
-            error_report("Could not load MIPS bios '%s'", bios_name);
+            machine->firmware && !qtest_enabled()) {
+            error_report("Could not load MIPS bios '%s'", machine->firmware);
             exit(1);
         }
     }
hw/mips/jazz.c +3 -3
index 71448f72ac..aa95c6a3d3 100644
@@ -218,7 +218,7 @@ static void mips_jazz_init(MachineState *machine,
     memory_region_add_subregion(address_space, 0xfff00000LL, bios2);
 
     /* load the BIOS image. */
-    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name ?: BIOS_FILENAME);
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware ?: BIOS_FILENAME);
     if (filename) {
         bios_size = load_image_targphys(filename, 0xfff00000LL,
                                         MAGNUM_BIOS_SIZE);
@@ -227,8 +227,8 @@ static void mips_jazz_init(MachineState *machine,
         bios_size = -1;
     }
     if ((bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE)
-        && bios_name && !qtest_enabled()) {
-        error_report("Could not load MIPS bios '%s'", bios_name);
+        && machine->firmware && !qtest_enabled()) {
+        error_report("Could not load MIPS bios '%s'", machine->firmware);
         exit(1);
     }
 
hw/mips/malta.c +3 -3
index 9d1a3b50b7..ef369945d1 100644
@@ -1333,7 +1333,7 @@ void mips_malta_init(MachineState *machine)
         if (!dinfo) {
             /* Load a BIOS image. */
             filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
-                                      bios_name ?: BIOS_FILENAME);
+                                      machine->firmware ?: BIOS_FILENAME);
             if (filename) {
                 bios_size = load_image_targphys(filename, FLASH_ADDRESS,
                                                 BIOS_SIZE);
@@ -1342,8 +1342,8 @@ void mips_malta_init(MachineState *machine)
                 bios_size = -1;
             }
             if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
-                bios_name && !qtest_enabled()) {
-                error_report("Could not load MIPS bios '%s'", bios_name);
+                machine->firmware && !qtest_enabled()) {
+                error_report("Could not load MIPS bios '%s'", machine->firmware);
                 exit(1);
             }
         }
hw/mips/mipssim.c +3 -3
index aaa62a0f4b..cc9b0934b3 100644
@@ -177,7 +177,7 @@ mips_mipssim_init(MachineState *machine)
     /* Map the BIOS / boot exception handler. */
     memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios);
     /* Load a BIOS / boot exception handler image. */
-    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name ?: BIOS_FILENAME);
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware ?: BIOS_FILENAME);
     if (filename) {
         bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE);
         g_free(filename);
@@ -185,9 +185,9 @@ mips_mipssim_init(MachineState *machine)
         bios_size = -1;
     }
     if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
-        bios_name && !qtest_enabled()) {
+        machine->firmware && !qtest_enabled()) {
         /* Bail out if we have neither a kernel image nor boot vector code. */
-        error_report("Could not load MIPS bios '%s'", bios_name);
+        error_report("Could not load MIPS bios '%s'", machine->firmware);
         exit(1);
     } else {
         /* We have a boot vector start address. */
hw/mips/r4k.c +1 -3
index 3830854342..b27be138a4 100644
@@ -168,6 +168,7 @@ static const int sector_len = 32 * KiB;
 static
 void mips_r4k_init(MachineState *machine)
 {
+    const char *bios_name = machine->firmware ?: BIOS_FILENAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
@@ -221,9 +222,6 @@ void mips_r4k_init(MachineState *machine)
      * run.
      */
 
-    if (bios_name == NULL) {
-        bios_name = BIOS_FILENAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (filename) {
         bios_size = get_image_size(filename);
Signature · 1 line
2.26.2
Reviewed-by on v1 8/15
#25 lore raw

Re: [PATCH 08/15] mips: remove bios_name

In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini
Cc Philippe Mathieu-Daudé <[email protected]>
---
 hw/mips/fuloong2e.c | 6 +++---
 hw/mips/jazz.c      | 6 +++---
 hw/mips/malta.c     | 6 +++---
 hw/mips/mipssim.c   | 6 +++---
 hw/mips/r4k.c       | 4 +---
 5 files changed, 13 insertions(+), 15 deletions(-)

...

hw/mips/r4k.c static const int sector_len = 32 * KiB; · line 171

Quoted 9 lines
hw/mips/r4k.c +1 -0
index 3830854342..b27be138a4 100644
@@ -168,6 +168,7 @@ static const int sector_len = 32 * KiB;
 static
 void mips_r4k_init(MachineState *machine)
 {
+    const char *bios_name = machine->firmware ?: BIOS_FILENAME;

Don't we have a "redefinition of global variable" warning here?

Anyway,

Quoted 14 lines
hw/mips/r4k.c +0 -3
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
@@ -221,9 +222,6 @@ void mips_r4k_init(MachineState *machine)
      * run.
      */
 
-    if (bios_name == NULL) {
-        bios_name = BIOS_FILENAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (filename) {
         bios_size = get_image_size(filename);
#26 lore raw

PATCH 9/15 moxie: remove bios_name

In reply to Paolo Bonzini
---
 hw/moxie/moxiesim.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/moxie/moxiesim.c +3 -3
index a765e9f6be..d07d504c0d 100644
@@ -133,9 +133,9 @@ static void moxiesim_init(MachineState *machine)
         loader_params.initrd_filename = initrd_filename;
         load_kernel(cpu, &loader_params);
     }
-    if (bios_name) {
-        if (load_image_targphys(bios_name, FIRMWARE_BASE, FIRMWARE_SIZE) < 0) {
-            error_report("Failed to load firmware '%s'", bios_name);
+    if (machine->firmware) {
+        if (load_image_targphys(machine->firmware, FIRMWARE_BASE, FIRMWARE_SIZE) < 0) {
+            error_report("Failed to load firmware '%s'", machine->firmware);
         }
     }
 
Signature · 1 line
2.26.2
#28 lore raw

PATCH 10/15 ppc: remove bios_name

In reply to Paolo Bonzini
---
 hw/ppc/e500.c          | 4 ++--
 hw/ppc/mac_newworld.c  | 4 +---
 hw/ppc/mac_oldworld.c  | 4 +---
 hw/ppc/pnv.c           | 5 +----
 hw/ppc/ppc405_boards.c | 6 ++----
 hw/ppc/prep.c          | 4 +---
 hw/ppc/spapr.c         | 4 +---
 7 files changed, 9 insertions(+), 22 deletions(-)
hw/ppc/e500.c +2 -2
index ae39b9358e..153a74c98c 100644
@@ -1035,7 +1035,7 @@ void ppce500_init(MachineState *machine)
      * -kernel to users but allows them to run through u-boot as well.
      */
     kernel_as_payload = false;
-    if (bios_name == NULL) {
+    if (machine->firmware == NULL) {
         if (machine->kernel_filename) {
             payload_name = machine->kernel_filename;
             kernel_as_payload = true;
@@ -1043,7 +1043,7 @@ void ppce500_init(MachineState *machine)
             payload_name = "u-boot.e500";
         }
     } else {
-        payload_name = bios_name;
+        payload_name = machine->firmware;
     }
 
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, payload_name);
hw/ppc/mac_newworld.c +1 -3
index f9a1cc8944..61c63819df 100644
@@ -109,6 +109,7 @@ static void ppc_core99_reset(void *opaque)
 static void ppc_core99_init(MachineState *machine)
 {
     ram_addr_t ram_size = machine->ram_size;
+    const char *bios_name = machine->firmware ?: PROM_FILENAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
@@ -161,9 +162,6 @@ static void ppc_core99_init(MachineState *machine)
                            &error_fatal);
     memory_region_add_subregion(get_system_memory(), PROM_BASE, bios);
 
-    if (!bios_name) {
-        bios_name = PROM_FILENAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (filename) {
         /* Load OpenBIOS (ELF) */
hw/ppc/mac_oldworld.c +1 -3
index 6c59aa5601..11623e8e67 100644
@@ -83,6 +83,7 @@ static void ppc_heathrow_reset(void *opaque)
 static void ppc_heathrow_init(MachineState *machine)
 {
     ram_addr_t ram_size = machine->ram_size;
+    const char *bios_name = machine->firmware ?: PROM_FILENAME;
     const char *boot_device = machine->boot_order;
     PowerPCCPU *cpu = NULL;
     CPUPPCState *env = NULL;
@@ -130,9 +131,6 @@ static void ppc_heathrow_init(MachineState *machine)
                            &error_fatal);
     memory_region_add_subregion(get_system_memory(), PROM_BASE, bios);
 
-    if (!bios_name) {
-        bios_name = PROM_FILENAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (filename) {
         /* Load OpenBIOS (ELF) */
hw/ppc/pnv.c +1 -4
index d9e52873ea..f2b1ee83d3 100644
@@ -713,6 +713,7 @@ static void pnv_chip_power10_pic_print_info(PnvChip *chip, Monitor *mon)
 
 static void pnv_init(MachineState *machine)
 {
+    const char *bios_name = machine->firmware ?: FW_FILE_NAME;
     PnvMachineState *pnv = PNV_MACHINE(machine);
     MachineClass *mc = MACHINE_GET_CLASS(machine);
     char *fw_filename;
@@ -739,10 +740,6 @@ static void pnv_init(MachineState *machine)
     pnv->pnor = PNV_PNOR(dev);
 
     /* load skiboot firmware  */
-    if (bios_name == NULL) {
-        bios_name = FW_FILE_NAME;
-    }
-
     fw_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (!fw_filename) {
         error_report("Could not find OPAL firmware '%s'", bios_name);
hw/ppc/ppc405_boards.c +2 -4
index 4687715b15..c867e46330 100644
@@ -141,6 +141,7 @@ static void ref405ep_fpga_init(MemoryRegion *sysmem, uint32_t base)
 static void ref405ep_init(MachineState *machine)
 {
     MachineClass *mc = MACHINE_GET_CLASS(machine);
+    const char *bios_name = machine->firmware ?: BIOS_FILENAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
@@ -206,8 +207,6 @@ static void ref405ep_init(MachineState *machine)
         memory_region_init_rom(bios, NULL, "ef405ep.bios", BIOS_SIZE,
                                &error_fatal);
 
-        if (bios_name == NULL)
-            bios_name = BIOS_FILENAME;
         filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
         if (filename) {
             bios_size = load_image_size(filename,
@@ -425,6 +424,7 @@ static void taihu_cpld_init(MemoryRegion *sysmem, uint32_t base)
 static void taihu_405ep_init(MachineState *machine)
 {
     MachineClass *mc = MACHINE_GET_CLASS(machine);
+    const char *bios_name = machine->firmware ?: BIOS_FILENAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     char *filename;
@@ -475,8 +475,6 @@ static void taihu_405ep_init(MachineState *machine)
     } else
 #endif
     {
-        if (bios_name == NULL)
-            bios_name = BIOS_FILENAME;
         bios = g_new(MemoryRegion, 1);
         memory_region_init_rom(bios, NULL, "taihu_405ep.bios", BIOS_SIZE,
                                &error_fatal);
hw/ppc/prep.c +1 -3
index 4a0cb434a6..c6b9d1ddcb 100644
@@ -237,6 +237,7 @@ static int prep_set_cmos_checksum(DeviceState *dev, void *opaque)
 
 static void ibm_40p_init(MachineState *machine)
 {
+    const char *bios_name = machine->firmware ?: "openbios-ppc";
     CPUPPCState *env = NULL;
     uint16_t cmos_checksum;
     PowerPCCPU *cpu;
@@ -271,9 +272,6 @@ static void ibm_40p_init(MachineState *machine)
 
     /* PCI host */
     dev = qdev_new("raven-pcihost");
-    if (!bios_name) {
-        bios_name = "openbios-ppc";
-    }
     qdev_prop_set_string(dev, "bios-name", bios_name);
     qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
     pcihost = SYS_BUS_DEVICE(dev);
hw/ppc/spapr.c +1 -3
index 63315f2d0f..667d59e5ad 100644
@@ -2647,6 +2647,7 @@ static void spapr_machine_init(MachineState *machine)
     SpaprMachineState *spapr = SPAPR_MACHINE(machine);
     SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
     MachineClass *mc = MACHINE_GET_CLASS(machine);
+    const char *bios_name = machine->firmware ?: FW_FILE_NAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     PCIHostState *phb;
@@ -2970,9 +2971,6 @@ static void spapr_machine_init(MachineState *machine)
         }
     }
 
-    if (bios_name == NULL) {
-        bios_name = FW_FILE_NAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (!filename) {
         error_report("Could not find LPAR firmware '%s'", bios_name);
Signature · 1 line
2.26.2
Acked-by on v1 10/15
#30 lore raw

Re: [PATCH 10/15] ppc: remove bios_name

In reply to Paolo Bonzini
Quoted 2 lines · Paolo Bonzini
Quoted 181 lines
---
 hw/ppc/e500.c          | 4 ++--
 hw/ppc/mac_newworld.c  | 4 +---
 hw/ppc/mac_oldworld.c  | 4 +---
 hw/ppc/pnv.c           | 5 +----
 hw/ppc/ppc405_boards.c | 6 ++----
 hw/ppc/prep.c          | 4 +---
 hw/ppc/spapr.c         | 4 +---
 7 files changed, 9 insertions(+), 22 deletions(-)
hw/ppc/e500.c +2 -2
index ae39b9358e..153a74c98c 100644
@@ -1035,7 +1035,7 @@ void ppce500_init(MachineState *machine)
      * -kernel to users but allows them to run through u-boot as well.
      */
     kernel_as_payload = false;
-    if (bios_name == NULL) {
+    if (machine->firmware == NULL) {
         if (machine->kernel_filename) {
             payload_name = machine->kernel_filename;
             kernel_as_payload = true;
@@ -1043,7 +1043,7 @@ void ppce500_init(MachineState *machine)
             payload_name = "u-boot.e500";
         }
     } else {
-        payload_name = bios_name;
+        payload_name = machine->firmware;
     }
 
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, payload_name);
hw/ppc/mac_newworld.c +1 -3
index f9a1cc8944..61c63819df 100644
@@ -109,6 +109,7 @@ static void ppc_core99_reset(void *opaque)
 static void ppc_core99_init(MachineState *machine)
 {
     ram_addr_t ram_size = machine->ram_size;
+    const char *bios_name = machine->firmware ?: PROM_FILENAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
@@ -161,9 +162,6 @@ static void ppc_core99_init(MachineState *machine)
                            &error_fatal);
     memory_region_add_subregion(get_system_memory(), PROM_BASE, bios);
 
-    if (!bios_name) {
-        bios_name = PROM_FILENAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (filename) {
         /* Load OpenBIOS (ELF) */
hw/ppc/mac_oldworld.c +1 -3
index 6c59aa5601..11623e8e67 100644
@@ -83,6 +83,7 @@ static void ppc_heathrow_reset(void *opaque)
 static void ppc_heathrow_init(MachineState *machine)
 {
     ram_addr_t ram_size = machine->ram_size;
+    const char *bios_name = machine->firmware ?: PROM_FILENAME;
     const char *boot_device = machine->boot_order;
     PowerPCCPU *cpu = NULL;
     CPUPPCState *env = NULL;
@@ -130,9 +131,6 @@ static void ppc_heathrow_init(MachineState *machine)
                            &error_fatal);
     memory_region_add_subregion(get_system_memory(), PROM_BASE, bios);
 
-    if (!bios_name) {
-        bios_name = PROM_FILENAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (filename) {
         /* Load OpenBIOS (ELF) */
hw/ppc/pnv.c +1 -4
index d9e52873ea..f2b1ee83d3 100644
@@ -713,6 +713,7 @@ static void pnv_chip_power10_pic_print_info(PnvChip *chip, Monitor *mon)
 
 static void pnv_init(MachineState *machine)
 {
+    const char *bios_name = machine->firmware ?: FW_FILE_NAME;
     PnvMachineState *pnv = PNV_MACHINE(machine);
     MachineClass *mc = MACHINE_GET_CLASS(machine);
     char *fw_filename;
@@ -739,10 +740,6 @@ static void pnv_init(MachineState *machine)
     pnv->pnor = PNV_PNOR(dev);
 
     /* load skiboot firmware  */
-    if (bios_name == NULL) {
-        bios_name = FW_FILE_NAME;
-    }
-
     fw_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (!fw_filename) {
         error_report("Could not find OPAL firmware '%s'", bios_name);
hw/ppc/ppc405_boards.c +2 -4
index 4687715b15..c867e46330 100644
@@ -141,6 +141,7 @@ static void ref405ep_fpga_init(MemoryRegion *sysmem, uint32_t base)
 static void ref405ep_init(MachineState *machine)
 {
     MachineClass *mc = MACHINE_GET_CLASS(machine);
+    const char *bios_name = machine->firmware ?: BIOS_FILENAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
@@ -206,8 +207,6 @@ static void ref405ep_init(MachineState *machine)
         memory_region_init_rom(bios, NULL, "ef405ep.bios", BIOS_SIZE,
                                &error_fatal);
 
-        if (bios_name == NULL)
-            bios_name = BIOS_FILENAME;
         filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
         if (filename) {
             bios_size = load_image_size(filename,
@@ -425,6 +424,7 @@ static void taihu_cpld_init(MemoryRegion *sysmem, uint32_t base)
 static void taihu_405ep_init(MachineState *machine)
 {
     MachineClass *mc = MACHINE_GET_CLASS(machine);
+    const char *bios_name = machine->firmware ?: BIOS_FILENAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     char *filename;
@@ -475,8 +475,6 @@ static void taihu_405ep_init(MachineState *machine)
     } else
 #endif
     {
-        if (bios_name == NULL)
-            bios_name = BIOS_FILENAME;
         bios = g_new(MemoryRegion, 1);
         memory_region_init_rom(bios, NULL, "taihu_405ep.bios", BIOS_SIZE,
                                &error_fatal);
hw/ppc/prep.c +1 -3
index 4a0cb434a6..c6b9d1ddcb 100644
@@ -237,6 +237,7 @@ static int prep_set_cmos_checksum(DeviceState *dev, void *opaque)
 
 static void ibm_40p_init(MachineState *machine)
 {
+    const char *bios_name = machine->firmware ?: "openbios-ppc";
     CPUPPCState *env = NULL;
     uint16_t cmos_checksum;
     PowerPCCPU *cpu;
@@ -271,9 +272,6 @@ static void ibm_40p_init(MachineState *machine)
 
     /* PCI host */
     dev = qdev_new("raven-pcihost");
-    if (!bios_name) {
-        bios_name = "openbios-ppc";
-    }
     qdev_prop_set_string(dev, "bios-name", bios_name);
     qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE);
     pcihost = SYS_BUS_DEVICE(dev);
hw/ppc/spapr.c +1 -3
index 63315f2d0f..667d59e5ad 100644
@@ -2647,6 +2647,7 @@ static void spapr_machine_init(MachineState *machine)
     SpaprMachineState *spapr = SPAPR_MACHINE(machine);
     SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine);
     MachineClass *mc = MACHINE_GET_CLASS(machine);
+    const char *bios_name = machine->firmware ?: FW_FILE_NAME;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     PCIHostState *phb;
@@ -2970,9 +2971,6 @@ static void spapr_machine_init(MachineState *machine)
         }
     }
 
-    if (bios_name == NULL) {
-        bios_name = FW_FILE_NAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (!filename) {
         error_report("Could not find LPAR firmware '%s'", bios_name);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#31 lore raw

PATCH 11/15 rx: move BIOS load from MCU to board

In reply to Paolo Bonzini

The ROM loader state is global and not part of the MCU, and the BIOS is in machine->firmware. So just like the kernel case, load it in the board.

Cc Philippe Mathieu-Daudé <[email protected]>
---
 hw/rx/rx-gdbsim.c | 7 +++++++
 hw/rx/rx62n.c     | 9 ---------
 2 files changed, 7 insertions(+), 9 deletions(-)
hw/rx/rx-gdbsim.c +7 -0
index 417ec0564b..040006c1c5 100644
@@ -142,6 +142,13 @@ static void rx_gdbsim_init(MachineState *machine)
             /* Set dtb address to R1 */
             RX_CPU(first_cpu)->env.regs[1] = SDRAM_BASE + dtb_offset;
         }
+    } else {
+        if (machine->firmware) {
+            rom_add_file_fixed(machine->firmware, RX62N_CFLASH_BASE, 0);
+        } else if (!qtest_enabled()) {
+            error_report("No bios or kernel specified");
+            exit(1);
+        }
     }
 }
 
hw/rx/rx62n.c +0 -9
index 6eb4eea700..17ec73fc7b 100644
@@ -245,15 +245,6 @@ static void rx62n_realize(DeviceState *dev, Error **errp)
                            rxc->rom_flash_size, &error_abort);
     memory_region_add_subregion(s->sysmem, RX62N_CFLASH_BASE, &s->c_flash);
 
-    if (!s->kernel) {
-        if (bios_name) {
-            rom_add_file_fixed(bios_name, RX62N_CFLASH_BASE, 0);
-        }  else if (!qtest_enabled()) {
-            error_report("No bios or kernel specified");
-            exit(1);
-        }
-    }
-
     /* Initialize CPU */
     object_initialize_child(OBJECT(s), "cpu", &s->cpu, TYPE_RX62N_CPU);
     qdev_realize(DEVICE(&s->cpu), NULL, &error_abort);
Signature · 1 line
2.26.2
#32 lore raw

Re: [PATCH 11/15] rx: move BIOS load from MCU to board

Quoted 36 lines · Paolo Bonzini

The ROM loader state is global and not part of the MCU, and the BIOS is in machine->firmware. So just like the kernel case, load it in the board.

Cc Philippe Mathieu-Daudé <[email protected]>
---
 hw/rx/rx-gdbsim.c | 7 +++++++
 hw/rx/rx62n.c     | 9 ---------
 2 files changed, 7 insertions(+), 9 deletions(-)
hw/rx/rx-gdbsim.c +7 -0
index 417ec0564b..040006c1c5 100644
@@ -142,6 +142,13 @@ static void rx_gdbsim_init(MachineState *machine)
             /* Set dtb address to R1 */
             RX_CPU(first_cpu)->env.regs[1] = SDRAM_BASE + dtb_offset;
         }
+    } else {
+        if (machine->firmware) {
+            rom_add_file_fixed(machine->firmware, RX62N_CFLASH_BASE, 0);
+        } else if (!qtest_enabled()) {
+            error_report("No bios or kernel specified");
+            exit(1);
+        }
     }
 }
 
hw/rx/rx62n.c +0 -0
index 6eb4eea700..17ec73fc7b 100644
@@ -245,15 +245,6 @@ static void rx62n_realize(DeviceState *dev, Error **errp)
                            rxc->rom_flash_size, &error_abort);
     memory_region_add_subregion(s->sysmem, RX62N_CFLASH_BASE, &s->c_flash);

hw/rx/rx62n.c static void rx62n_realize(DeviceState *dev, Error **errp) · line 256

Quoted 10 lines
hw/rx/rx62n.c +0 -9
 
-    if (!s->kernel) {
-        if (bios_name) {
-            rom_add_file_fixed(bios_name, RX62N_CFLASH_BASE, 0);
-        }  else if (!qtest_enabled()) {
-            error_report("No bios or kernel specified");
-            exit(1);
-        }
-    }
-

I'm confused because on the face of it these are two different models. I'll defer to the domain expert on this one.

Signature · 1 line
Alex Bennée
#33 lore raw

Re: [PATCH 11/15] rx: move BIOS load from MCU to board

Quoted 40 lines · Alex Bennée
Quoted 37 lines · Paolo Bonzini

The ROM loader state is global and not part of the MCU, and the BIOS is in machine->firmware. So just like the kernel case, load it in the board.

Cc Philippe Mathieu-Daudé <[email protected]>
---
 hw/rx/rx-gdbsim.c | 7 +++++++
 hw/rx/rx62n.c     | 9 ---------
 2 files changed, 7 insertions(+), 9 deletions(-)
hw/rx/rx-gdbsim.c +7 -0
index 417ec0564b..040006c1c5 100644
@@ -142,6 +142,13 @@ static void rx_gdbsim_init(MachineState *machine)
             /* Set dtb address to R1 */
             RX_CPU(first_cpu)->env.regs[1] = SDRAM_BASE + dtb_offset;
         }
+    } else {
+        if (machine->firmware) {
+            rom_add_file_fixed(machine->firmware, RX62N_CFLASH_BASE, 0);
+        } else if (!qtest_enabled()) {
+            error_report("No bios or kernel specified");
+            exit(1);
+        }
     }
 }
 
hw/rx/rx62n.c +0 -0
index 6eb4eea700..17ec73fc7b 100644
@@ -245,15 +245,6 @@ static void rx62n_realize(DeviceState *dev, Error **errp)
                            rxc->rom_flash_size, &error_abort);
     memory_region_add_subregion(s->sysmem, RX62N_CFLASH_BASE, &s->c_flash);
 
Quoted 12 lines

hw/rx/rx62n.c static void rx62n_realize(DeviceState *dev, Error **errp) · line 256

Quoted 9 lines
hw/rx/rx62n.c +0 -9
-    if (!s->kernel) {
-        if (bios_name) {
-            rom_add_file_fixed(bios_name, RX62N_CFLASH_BASE, 0);
-        }  else if (!qtest_enabled()) {
-            error_report("No bios or kernel specified");
-            exit(1);
-        }
-    }
-

I'm confused because on the face of it these are two different models. I'll defer to the domain expert on this one.

rx62n is the SoC, rx-gdbsim.c instead includes the rx62n7 and rx62n8 machines.

Paolo

#34 lore raw

Re: [PATCH 11/15] rx: move BIOS load from MCU to board

Quoted 41 lines · Paolo Bonzini
Quoted 40 lines · Alex Bennée
Quoted 37 lines · Paolo Bonzini

The ROM loader state is global and not part of the MCU, and the BIOS is in machine->firmware. So just like the kernel case, load it in the board.

Cc Philippe Mathieu-Daudé <[email protected]>
---
  hw/rx/rx-gdbsim.c | 7 +++++++
  hw/rx/rx62n.c     | 9 ---------
  2 files changed, 7 insertions(+), 9 deletions(-)
hw/rx/rx-gdbsim.c +7 -0
index 417ec0564b..040006c1c5 100644
@@ -142,6 +142,13 @@ static void rx_gdbsim_init(MachineState *machine)
              /* Set dtb address to R1 */
              RX_CPU(first_cpu)->env.regs[1] = SDRAM_BASE + dtb_offset;
          }
+    } else {
+        if (machine->firmware) {
+            rom_add_file_fixed(machine->firmware, RX62N_CFLASH_BASE, 0);
+        } else if (!qtest_enabled()) {
+            error_report("No bios or kernel specified");
+            exit(1);
+        }
      }
  }
 
hw/rx/rx62n.c +0 -0
index 6eb4eea700..17ec73fc7b 100644
@@ -245,15 +245,6 @@ static void rx62n_realize(DeviceState *dev, Error **errp)
                             rxc->rom_flash_size, &error_abort);
      memory_region_add_subregion(s->sysmem, RX62N_CFLASH_BASE, &s->c_flash);
 
Quoted 3 lines
Quoted 3 lines

hw/rx/rx62n.c static void rx62n_realize(DeviceState *dev, Error **errp) · line 250

Quoted 3 lines
hw/rx/rx62n.c +0 -3
-    if (!s->kernel) {
-        if (bios_name) {
-            rom_add_file_fixed(bios_name, RX62N_CFLASH_BASE, 0);

The acceptance test fails. There is some odd reset order problem, eventually related to this discussion "CPU reset handler priority":
https://www.mail-archive.com/[email protected]/msg686362.html

Quoted 9 lines
Quoted 9 lines

hw/rx/rx62n.c static void rx62n_realize(DeviceState *dev, Error **errp) · line 256

Quoted 6 lines
hw/rx/rx62n.c +0 -6
-        }  else if (!qtest_enabled()) {
-            error_report("No bios or kernel specified");
-            exit(1);
-        }
-    }
-

I'm confused because on the face of it these are two different models. I'll defer to the domain expert on this one.

Yoshinori started to clean that here:
https://www.mail-archive.com/[email protected]/msg734135.html

Quoted 6 lines

rx62n is the SoC, rx-gdbsim.c instead includes the rx62n7 and rx62n8 machines.

Paolo

#35 lore raw

PATCH 12/15 s390: remove bios_name

In reply to Paolo Bonzini
---
 hw/s390x/ipl.c             | 8 ++------
 hw/s390x/s390-virtio-ccw.c | 3 ++-
 2 files changed, 4 insertions(+), 7 deletions(-)
hw/s390x/ipl.c +2 -6
index 3d2652d75a..61e8c967d3 100644
@@ -128,11 +128,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
     if (!ipl->kernel || ipl->enforce_bios) {
         uint64_t fwbase = (MIN(ram_size, 0x80000000U) - 0x200000) & ~0xffffUL;
 
-        if (bios_name == NULL) {
-            bios_name = ipl->firmware;
-        }
-
-        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, ipl->firmware);
         if (bios_filename == NULL) {
             error_setg(errp, "could not find stage1 bootloader");
             return;
@@ -154,7 +150,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
         g_free(bios_filename);
 
         if (bios_size == -1) {
-            error_setg(errp, "could not load bootloader '%s'", bios_name);
+            error_setg(errp, "could not load bootloader '%s'", ipl->firmware);
             return;
         }
 
hw/s390x/s390-virtio-ccw.c +2 -1
index e52182f946..a521eba673 100644
@@ -258,7 +258,8 @@ static void ccw_init(MachineState *machine)
     /* get a BUS */
     css_bus = virtual_css_bus_init();
     s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
-                      machine->initrd_filename, "s390-ccw.img",
+                      machine->initrd_filename,
+                      machine->firmware ?: "s390-ccw.img",
                       "s390-netboot.img", true);
 
     dev = qdev_new(TYPE_S390_PCI_HOST_BRIDGE);
Signature · 1 line
2.26.2
Reviewed-by on v1 12/15
#36 lore raw

Re: [PATCH 12/15] s390: remove bios_name

Paolo Bonzini <[email protected]> writes:

Might be worth mentioning the trixy path from qdev_prop_set_string to end up in ipl->firmware because it's not obvious just from the diff. Anyway:

Signature · 1 line
Alex Bennée
Reviewed-by on v1 12/15
#37 lore raw

Re: [PATCH 12/15] s390: remove bios_name

In reply to Paolo Bonzini
Quoted 39 lines · Paolo Bonzini
---
 hw/s390x/ipl.c             | 8 ++------
 hw/s390x/s390-virtio-ccw.c | 3 ++-
 2 files changed, 4 insertions(+), 7 deletions(-)
hw/s390x/ipl.c +2 -6
index 3d2652d75a..61e8c967d3 100644
@@ -128,11 +128,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
     if (!ipl->kernel || ipl->enforce_bios) {
         uint64_t fwbase = (MIN(ram_size, 0x80000000U) - 0x200000) & ~0xffffUL;
 
-        if (bios_name == NULL) {
-            bios_name = ipl->firmware;
-        }
-
-        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, ipl->firmware);
         if (bios_filename == NULL) {
             error_setg(errp, "could not find stage1 bootloader");
             return;
@@ -154,7 +150,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
         g_free(bios_filename);
 
         if (bios_size == -1) {
-            error_setg(errp, "could not load bootloader '%s'", bios_name);
+            error_setg(errp, "could not load bootloader '%s'", ipl->firmware);
             return;
         }
 
hw/s390x/s390-virtio-ccw.c +0 -0
index e52182f946..a521eba673 100644

hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 265

Quoted 9 lines
hw/s390x/s390-virtio-ccw.c +2 -1
@@ -258,7 +258,8 @@ static void ccw_init(MachineState *machine)
     /* get a BUS */
     css_bus = virtual_css_bus_init();
     s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
-                      machine->initrd_filename, "s390-ccw.img",
+                      machine->initrd_filename,
+                      machine->firmware ?: "s390-ccw.img",
                       "s390-netboot.img", true);
 
     dev = qdev_new(TYPE_S390_PCI_HOST_BRIDGE);
#39 lore raw

Re: [PATCH 12/15] s390: remove bios_name

In reply to Paolo Bonzini
Quoted 38 lines · Paolo Bonzini
---
 hw/s390x/ipl.c             | 8 ++------
 hw/s390x/s390-virtio-ccw.c | 3 ++-
 2 files changed, 4 insertions(+), 7 deletions(-)
hw/s390x/ipl.c +2 -6
index 3d2652d75a..61e8c967d3 100644
@@ -128,11 +128,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
     if (!ipl->kernel || ipl->enforce_bios) {
         uint64_t fwbase = (MIN(ram_size, 0x80000000U) - 0x200000) & ~0xffffUL;
 
-        if (bios_name == NULL) {
-            bios_name = ipl->firmware;
-        }
-
-        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, ipl->firmware);
         if (bios_filename == NULL) {
             error_setg(errp, "could not find stage1 bootloader");
             return;
@@ -154,7 +150,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
         g_free(bios_filename);
 
         if (bios_size == -1) {
-            error_setg(errp, "could not load bootloader '%s'", bios_name);
+            error_setg(errp, "could not load bootloader '%s'", ipl->firmware);
             return;
         }
 
hw/s390x/s390-virtio-ccw.c +0 -0
index e52182f946..a521eba673 100644

hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 262

Quoted 6 lines
hw/s390x/s390-virtio-ccw.c +2 -1
@@ -258,7 +258,8 @@ static void ccw_init(MachineState *machine)
     /* get a BUS */
     css_bus = virtual_css_bus_init();
     s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
-                      machine->initrd_filename, "s390-ccw.img",
+                      machine->initrd_filename,
+                      machine->firmware ?: "s390-ccw.img",

Adding the elvis operator is actually a fix, no?

#40 lore raw

Re: [PATCH 12/15] s390: remove bios_name

Quoted 14 lines · Christian Borntraeger

hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 262

Quoted 12 lines
hw/s390x/s390-virtio-ccw.c +2 -1
index e52182f946..a521eba673 100644
@@ -258,7 +258,8 @@ static void ccw_init(MachineState *machine)
     /* get a BUS */
     css_bus = virtual_css_bus_init();
     s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
-                      machine->initrd_filename, "s390-ccw.img",
+                      machine->initrd_filename,
+                      machine->firmware ?: "s390-ccw.img",

Adding the elvis operator is actually a fix, no?

I think it was already doing the equivalent here in s390_ipl_realize

        if (bios_name == NULL) {
            bios_name = ipl->firmware;
        }

        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);

so it was just an encapsulation violation on part of the IPL device.

Paolo

#41 lore raw

PATCH 13/15 sh4: remove bios_name

In reply to Paolo Bonzini
---
 hw/sh4/shix.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/sh4/shix.c +1 -2
index f410c08883..d9a9fcbc59 100644
@@ -49,6 +49,7 @@ static void shix_init(MachineState *machine)
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *rom = g_new(MemoryRegion, 1);
     MemoryRegion *sdram = g_new(MemoryRegion, 2);
+    const char *bios_name = machine->firmware ?: BIOS_FILENAME;
     
     cpu = SUPERH_CPU(cpu_create(machine->cpu_type));
 
@@ -63,8 +64,6 @@ static void shix_init(MachineState *machine)
     memory_region_add_subregion(sysmem, 0x0c000000, &sdram[1]);
 
     /* Load BIOS in 0 (and access it through P2, 0xA0000000) */
-    if (bios_name == NULL)
-        bios_name = BIOS_FILENAME;
     ret = load_image_targphys(bios_name, 0, 0x4000);
     if (ret < 0 && !qtest_enabled()) {
         error_report("Could not load SHIX bios '%s'", bios_name);
Signature · 1 line
2.26.2
#44 lore raw

PATCH 14/15 sparc: remove bios_name

In reply to Paolo Bonzini
Cc Mark Cave-Ayland <[email protected]>
---
 hw/sparc/leon3.c   | 4 +---
 hw/sparc/sun4m.c   | 2 +-
 hw/sparc64/sun4u.c | 2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)
hw/sparc/leon3.c +1 -3
index d40b7891f6..1c50b02f81 100644
@@ -185,6 +185,7 @@ static void leon3_set_pil_in(void *opaque, int n, int level)
 static void leon3_generic_hw_init(MachineState *machine)
 {
     ram_addr_t ram_size = machine->ram_size;
+    const char *bios_name = machine->firmware ?: LEON3_PROM_FILENAME;
     const char *kernel_filename = machine->kernel_filename;
     SPARCCPU *cpu;
     CPUSPARCState   *env;
@@ -259,9 +260,6 @@ static void leon3_generic_hw_init(MachineState *machine)
     memory_region_add_subregion(address_space_mem, LEON3_PROM_OFFSET, prom);
 
     /* Load boot prom */
-    if (bios_name == NULL) {
-        bios_name = LEON3_PROM_FILENAME;
-    }
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 
     if (filename) {
hw/sparc/sun4m.c +1 -1
index 38d1e0fd12..81d4ae9385 100644
@@ -878,7 +878,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
                         hwdef->max_mem - machine->ram_size);
     }
 
-    prom_init(hwdef->slavio_base, bios_name);
+    prom_init(hwdef->slavio_base, machine->firmware);
 
     slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
                                        hwdef->intctl_base + 0x10000ULL,
hw/sparc64/sun4u.c +1 -1
index 05e659c8a4..50230d261a 100644
@@ -578,7 +578,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
     /* set up devices */
     ram_init(0, machine->ram_size);
 
-    prom_init(hwdef->prom_addr, bios_name);
+    prom_init(hwdef->prom_addr, machine->firmware);
 
     /* Init sabre (PCI host bridge) */
     sabre = SABRE(qdev_new(TYPE_SABRE));
Signature · 1 line
2.26.2
Acked-by on v1 14/15
#47 lore raw

Re: [PATCH 14/15] sparc: remove bios_name

In reply to Paolo Bonzini
Quoted 48 lines · Paolo Bonzini
Cc Mark Cave-Ayland <[email protected]>
---
  hw/sparc/leon3.c   | 4 +---
  hw/sparc/sun4m.c   | 2 +-
  hw/sparc64/sun4u.c | 2 +-
  3 files changed, 3 insertions(+), 5 deletions(-)
hw/sparc/leon3.c +1 -3
index d40b7891f6..1c50b02f81 100644
@@ -185,6 +185,7 @@ static void leon3_set_pil_in(void *opaque, int n, int level)
  static void leon3_generic_hw_init(MachineState *machine)
  {
      ram_addr_t ram_size = machine->ram_size;
+    const char *bios_name = machine->firmware ?: LEON3_PROM_FILENAME;
      const char *kernel_filename = machine->kernel_filename;
      SPARCCPU *cpu;
      CPUSPARCState   *env;
@@ -259,9 +260,6 @@ static void leon3_generic_hw_init(MachineState *machine)
      memory_region_add_subregion(address_space_mem, LEON3_PROM_OFFSET, prom);
 
      /* Load boot prom */
-    if (bios_name == NULL) {
-        bios_name = LEON3_PROM_FILENAME;
-    }
      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
 
      if (filename) {
hw/sparc/sun4m.c +1 -1
index 38d1e0fd12..81d4ae9385 100644
@@ -878,7 +878,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
                          hwdef->max_mem - machine->ram_size);
      }
 
-    prom_init(hwdef->slavio_base, bios_name);
+    prom_init(hwdef->slavio_base, machine->firmware);
 
      slavio_intctl = slavio_intctl_init(hwdef->intctl_base,
                                         hwdef->intctl_base + 0x10000ULL,
hw/sparc64/sun4u.c +0 -0
index 05e659c8a4..50230d261a 100644

hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 584

Quoted 8 lines
hw/sparc64/sun4u.c +1 -1
@@ -578,7 +578,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
      /* set up devices */
      ram_init(0, machine->ram_size);
 
-    prom_init(hwdef->prom_addr, bios_name);
+    prom_init(hwdef->prom_addr, machine->firmware);
 
      /* Init sabre (PCI host bridge) */
      sabre = SABRE(qdev_new(TYPE_SABRE));

Looks good to me:

ATB,

Mark.

#48 lore raw

PATCH 15/15 vl: remove bios_name

In reply to Paolo Bonzini

bios_name was a legacy variable used by machine code, but it is no more.

---
 include/sysemu/sysemu.h | 1 -
 softmmu/vl.c            | 2 --
 2 files changed, 3 deletions(-)
include/sysemu/sysemu.h +0 -1
index 817ff4cf75..1336b4264a 100644
@@ -8,7 +8,6 @@
 
 /* vl.c */
 
-extern const char *bios_name;
 extern int only_migratable;
 extern const char *qemu_name;
 extern QemuUUID qemu_uuid;
softmmu/vl.c +0 -2
index b7d7f43c88..7909709879 100644
@@ -119,7 +119,6 @@
 
 static const char *data_dir[16];
 static int data_dir_idx;
-const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int display_opengl;
 const char* keyboard_layout = NULL;
@@ -4205,7 +4204,6 @@ void qemu_init(int argc, char **argv, char **envp)
     kernel_filename = qemu_opt_get(machine_opts, "kernel");
     initrd_filename = qemu_opt_get(machine_opts, "initrd");
     kernel_cmdline = qemu_opt_get(machine_opts, "append");
-    bios_name = qemu_opt_get(machine_opts, "firmware");
 
     opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
     if (opts) {
Signature · 1 line
2.26.2
Reviewed-by on v1 15/15
#50 lore raw

Re: [PATCH 15/15] vl: remove bios_name

In reply to Paolo Bonzini
Quoted 35 lines · Paolo Bonzini

bios_name was a legacy variable used by machine code, but it is no more.

---
 include/sysemu/sysemu.h | 1 -
 softmmu/vl.c            | 2 --
 2 files changed, 3 deletions(-)
include/sysemu/sysemu.h +0 -1
index 817ff4cf75..1336b4264a 100644
@@ -8,7 +8,6 @@
 
 /* vl.c */
 
-extern const char *bios_name;
 extern int only_migratable;
 extern const char *qemu_name;
 extern QemuUUID qemu_uuid;
softmmu/vl.c +0 -1
index b7d7f43c88..7909709879 100644
@@ -119,7 +119,6 @@
 
 static const char *data_dir[16];
 static int data_dir_idx;
-const char *bios_name = NULL;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 int display_opengl;
 const char* keyboard_layout = NULL;

softmmu/vl.c void qemu_init(int argc, char **argv, char **envp) · line 4209

Quoted 7 lines
softmmu/vl.c +0 -1
@@ -4205,7 +4204,6 @@ void qemu_init(int argc, char **argv, char **envp)
     kernel_filename = qemu_opt_get(machine_opts, "kernel");
     initrd_filename = qemu_opt_get(machine_opts, "initrd");
     kernel_cmdline = qemu_opt_get(machine_opts, "append");
-    bios_name = qemu_opt_get(machine_opts, "firmware");
 
     opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
     if (opts) {
#51 lore raw
In reply to Paolo Bonzini
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH 00/15] remove bios_name variable

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
288a1cc..e75de83 master -> master
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
e6a3975 vl: remove bios_name
ff23ca8 sparc: remove bios_name
4b04e35 sh4: remove bios_name
35de573 s390: remove bios_name
a352220 rx: move BIOS load from MCU to board
83c3173 ppc: remove bios_name
c020272 moxie: remove bios_name
09bcdbc mips: remove bios_name
c618c9e m68k: remove bios_name
4ff17f7 lm32: remove bios_name
c6609bf i386: remove bios_name
2f2d724 hppa: remove bios_name
da68a51 arm: remove bios_name
5687239 digic: stash firmware into DigicState
2fae50e alpha: remove bios_name

=== OUTPUT BEGIN ===
1/15 Checking commit 2fae50e6defc (alpha: remove bios_name) 2/15 Checking commit 56872395809e (digic: stash firmware into DigicState) 3/15 Checking commit da68a516b853 (arm: remove bios_name)
WARNING: line over 80 characters
#37: FILE: hw/arm/highbank.c:299:
+ sysboot_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware);

total: 0 errors, 1 warnings, 105 lines checked

Patch 3/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
4/15 Checking commit 2f2d724e2d12 (hppa: remove bios_name)
WARNING: line over 80 characters
#21: FILE: hw/hppa/machine.c:216:
+ machine->firmware ?: "hppa-firmware.img");

total: 0 errors, 1 warnings, 9 lines checked

Patch 4/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
5/15 Checking commit c6609bf59a25 (i386: remove bios_name)
WARNING: line over 80 characters
#33: FILE: hw/i386/microvm.c:266:
+ x86_bios_rom_init(MACHINE(mms), default_firmware, get_system_memory(), true);

total: 0 errors, 1 warnings, 75 lines checked

Patch 5/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
6/15 Checking commit 4ff17f7afa49 (lm32: remove bios_name)
ERROR: spaces required around that ':' (ctx:VxE)
#19: FILE: hw/lm32/milkymist.c:111:
+ const char *bios_name = machine->firmware ? BIOS_FILENAME:

                                                              ^

total: 1 errors, 0 warnings, 16 lines checked

Patch 6/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

7/15 Checking commit c618c9eb69d3 (m68k: remove bios_name) 8/15 Checking commit 09bcdbcc744e (mips: remove bios_name)
WARNING: line over 80 characters
#44: FILE: hw/mips/jazz.c:221:
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware ?: BIOS_FILENAME);

WARNING: line over 80 characters
#79: FILE: hw/mips/malta.c:1346:
+ error_report("Could not load MIPS bios '%s'", machine->firmware);

WARNING: line over 80 characters
#92: FILE: hw/mips/mipssim.c:180:
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->firmware ?: BIOS_FILENAME);

total: 0 errors, 3 warnings, 89 lines checked

Patch 8/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
9/15 Checking commit c0202725c5bf (moxie: remove bios_name)
WARNING: line over 80 characters
#22: FILE: hw/moxie/moxiesim.c:137:
+ if (load_image_targphys(machine->firmware, FIRMWARE_BASE, FIRMWARE_SIZE) < 0) {

total: 0 errors, 1 warnings, 12 lines checked

Patch 9/15 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
10/15 Checking commit 83c31730c9bd (ppc: remove bios_name) 11/15 Checking commit a3522204200e (rx: move BIOS load from MCU to board) 12/15 Checking commit 35de573a9382 (s390: remove bios_name) 13/15 Checking commit 4b04e35c1605 (sh4: remove bios_name) 14/15 Checking commit ff23ca862682 (sparc: remove bios_name) 15/15 Checking commit e6a39752a393 (vl: remove bios_name)
=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]