Skip to contentSkip to conversation

use FWCfgState* instead of void* for fw_cfg data

PATCH In review Eduardo Habkost 2 participants 6 messages Dec 7, 2012

lore
Share & tools
lore
#0 lore raw

cover use FWCfgState* instead of void* for fw_cfg data

Many parts of the code use void* for fw_cfg data when it could simply use the right data type (FWCfgState*). This series changes that code to use FWCfgState*.

Eduardo Habkost (4):
multiboot: use FWCfgState* as argument instead of void*
pc: use FWCfgState* instead of void* for fw_cfg data
ppc: use FWCfgState* instead of void* for fw_cfg data
sparc: use FWCfgState* instead of void* for fw_cfg data

 hw/acpi_piix4.c   |  2 +-
 hw/multiboot.c    |  2 +-
 hw/multiboot.h    |  4 +++-
 hw/pc.c           | 28 ++++++++++++++--------------
 hw/pc.h           | 19 ++++++++++---------
 hw/pc_piix.c      |  2 +-
 hw/ppc_newworld.c |  2 +-
 hw/ppc_oldworld.c |  2 +-
 hw/sun4m.c        |  6 +++---
 hw/sun4u.c        |  2 +-
 10 files changed, 36 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 1/4 multiboot: use FWCfgState* as argument instead of void*

There's no point in using void* if we can simply use the right type for the argument (FWCfgState*).

---
Cc: Anthony Liguori <[email protected]>

---
 hw/multiboot.c | 2 +-
 hw/multiboot.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
hw/multiboot.c +1 -1
index 09ec5b2..06bbf4c 100644
@@ -124,7 +124,7 @@ static void mb_add_mod(MultibootState *s,
     s->mb_mods_count++;
 }
 
-int load_multiboot(void *fw_cfg,
+int load_multiboot(FWCfgState *fw_cfg,
                    FILE *f,
                    const char *kernel_filename,
                    const char *initrd_filename,
hw/multiboot.h +3 -1
index 98fb1b7..33c82b1 100644
@@ -1,7 +1,9 @@
 #ifndef QEMU_MULTIBOOT_H
 #define QEMU_MULTIBOOT_H
 
-int load_multiboot(void *fw_cfg,
+#include "fw_cfg.h"
+
+int load_multiboot(FWCfgState *fw_cfg,
                    FILE *f,
                    const char *kernel_filename,
                    const char *initrd_filename,
Signature · 1 line
1.7.11.7
#2 lore raw

PATCH 2/4 pc: use FWCfgState* instead of void* for fw_cfg data

In reply to Eduardo Habkost

There's no point in using void* if all functions dealing with that data use FWCfgState*.

---
Cc: Anthony Liguori <[email protected]>

---
 hw/acpi_piix4.c |  2 +-
 hw/pc.c         | 28 ++++++++++++++--------------
 hw/pc.h         | 19 ++++++++++---------
 hw/pc_piix.c    |  2 +-
 4 files changed, 26 insertions(+), 25 deletions(-)
hw/acpi_piix4.c +1 -1
index 519269a..6ddee93 100644
@@ -473,7 +473,7 @@ static int piix4_pm_initfn(PCIDevice *dev)
 
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
-                       int kvm_enabled, void *fw_cfg)
+                       int kvm_enabled, FWCfgState *fw_cfg)
 {
     PCIDevice *dev;
     PIIX4PMState *s;
hw/pc.c +14 -14
index 2b5bbbf..70d3394 100644
@@ -567,9 +567,9 @@ int e820_add_entry(uint64_t address, uint64_t length, uint32_t type)
     return index;
 }
 
-static void *bochs_bios_init(void)
+static FWCfgState *bochs_bios_init(void)
 {
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     uint8_t *smbios_table;
     size_t smbios_len;
     uint64_t *numa_fw_cfg;
@@ -635,10 +635,10 @@ static long get_file_size(FILE *f)
     return size;
 }
 
-static void load_linux(void *fw_cfg,
+static void load_linux(FWCfgState *fw_cfg,
                        const char *kernel_filename,
-		       const char *initrd_filename,
-		       const char *kernel_cmdline,
+                       const char *initrd_filename,
+                       const char *kernel_cmdline,
                        hwaddr max_ram_size)
 {
     uint16_t protocol;
@@ -877,19 +877,19 @@ void pc_cpus_init(const char *cpu_model)
     }
 }
 
-void *pc_memory_init(MemoryRegion *system_memory,
-                    const char *kernel_filename,
-                    const char *kernel_cmdline,
-                    const char *initrd_filename,
-                    ram_addr_t below_4g_mem_size,
-                    ram_addr_t above_4g_mem_size,
-                    MemoryRegion *rom_memory,
-                    MemoryRegion **ram_memory)
+FWCfgState *pc_memory_init(MemoryRegion *system_memory,
+                           const char *kernel_filename,
+                           const char *kernel_cmdline,
+                           const char *initrd_filename,
+                           ram_addr_t below_4g_mem_size,
+                           ram_addr_t above_4g_mem_size,
+                           MemoryRegion *rom_memory,
+                           MemoryRegion **ram_memory)
 {
     int linux_boot, i;
     MemoryRegion *ram, *option_rom_mr;
     MemoryRegion *ram_below_4g, *ram_above_4g;
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
 
     linux_boot = (kernel_filename != NULL);
 
hw/pc.h +10 -9
index 2237e86..0fc97ea 100644
@@ -9,6 +9,7 @@
 #include "net.h"
 #include "memory.h"
 #include "ioapic.h"
+#include "fw_cfg.h"
 
 /* PC-style peripherals (also used by other machines).  */
 
@@ -79,14 +80,14 @@ void pc_register_ferr_irq(qemu_irq irq);
 void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
 void pc_cpus_init(const char *cpu_model);
-void *pc_memory_init(MemoryRegion *system_memory,
-                    const char *kernel_filename,
-                    const char *kernel_cmdline,
-                    const char *initrd_filename,
-                    ram_addr_t below_4g_mem_size,
-                    ram_addr_t above_4g_mem_size,
-                    MemoryRegion *rom_memory,
-                    MemoryRegion **ram_memory);
+FWCfgState *pc_memory_init(MemoryRegion *system_memory,
+                           const char *kernel_filename,
+                           const char *kernel_cmdline,
+                           const char *initrd_filename,
+                           ram_addr_t below_4g_mem_size,
+                           ram_addr_t above_4g_mem_size,
+                           MemoryRegion *rom_memory,
+                           MemoryRegion **ram_memory);
 qemu_irq *pc_allocate_cpu_irq(void);
 DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus);
 void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi,
@@ -118,7 +119,7 @@ int acpi_table_add(const char *table_desc);
 
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq smi_irq,
-                       int kvm_enabled, void *fw_cfg);
+                       int kvm_enabled, FWCfgState *fw_cfg);
 void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 
 /* hpet.c */
hw/pc_piix.c +1 -1
index aa3e7f4..d636bcf 100644
@@ -84,7 +84,7 @@ static void pc_init1(MemoryRegion *system_memory,
     MemoryRegion *ram_memory;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
-    void *fw_cfg = NULL;
+    FWCfgState *fw_cfg = NULL;
 
     pc_cpus_init(cpu_model);
 
Signature · 1 line
1.7.11.7
#3 lore raw

PATCH 3/4 ppc: use FWCfgState* instead of void* for fw_cfg data

In reply to Eduardo Habkost

There's no point in using void* if all functions dealing with that data use FWCfgState*.

---
Cc: Alexander Graf <[email protected]>

---
 hw/ppc_newworld.c | 2 +-
 hw/ppc_oldworld.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/ppc_newworld.c +1 -1
index 664747e..426ea51 100644
@@ -153,7 +153,7 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
     MemoryRegion *ide_mem[3];
     int ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     void *dbdma;
     int machine_arch;
 
hw/ppc_oldworld.c +1 -1
index e8138c0..9855dcd 100644
@@ -96,7 +96,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
     MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1), *ide_mem[2];
     uint16_t ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     void *dbdma;
 
     linux_boot = (kernel_filename != NULL);
Signature · 1 line
1.7.11.7
Acked-by on v1 3/4
#4 lore raw

Re: [Qemu-devel] [PATCH 3/4] ppc: use FWCfgState* instead of void* for fw_cfg data

Quoted 2 lines · Eduardo Habkost

There's no point in using void* if all functions dealing with that data use FWCfgState*.

Alex

Quoted 38 lines

---
Cc: Alexander Graf <[email protected]>
---
hw/ppc_newworld.c | 2 +-
hw/ppc_oldworld.c | 2 +-

2 files changed, 2 insertions(+), 2 deletions(-)
hw/ppc_newworld.c +1 -1
index 664747e..426ea51 100644
@@ -153,7 +153,7 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
    MemoryRegion *ide_mem[3];
    int ppc_boot_device;
    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
    void *dbdma;
    int machine_arch;
 
hw/ppc_oldworld.c +1 -1
index e8138c0..9855dcd 100644
@@ -96,7 +96,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
    MemoryRegion *escc_mem, *escc_bar = g_new(MemoryRegion, 1), *ide_mem[2];
    uint16_t ppc_boot_device;
    DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
    void *dbdma;
 
    linux_boot = (kernel_filename != NULL);
Signature · 1 line
1.7.11.7
#5 lore raw

PATCH 4/4 sparc: use FWCfgState* instead of void* for fw_cfg data

In reply to Eduardo Habkost

There's no point in using void* if all functions dealing with that data use FWCfgState*.

---
Cc: Blue Swirl <[email protected]>

---
 hw/sun4m.c | 6 +++---
 hw/sun4u.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/sun4m.c +3 -3
index 1a78676..efcd5dd 100644
@@ -866,7 +866,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
     qemu_irq *cpu_halt;
     unsigned long kernel_size;
     DriveInfo *fd[MAX_FD];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     unsigned int num_vsimms;
 
     /* init CPUs */
@@ -1576,7 +1576,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
         espdma_irq, ledma_irq;
     qemu_irq esp_reset, dma_enable;
     unsigned long kernel_size;
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     DeviceState *dev;
 
     /* init CPUs */
@@ -1776,7 +1776,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
     qemu_irq fdc_tc;
     unsigned long kernel_size;
     DriveInfo *fd[MAX_FD];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
     DeviceState *dev;
     unsigned int i;
 
hw/sun4u.c +1 -1
index b2b51e3..8a7f52d 100644
@@ -812,7 +812,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
     qemu_irq *ivec_irqs, *pbm_irqs;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     DriveInfo *fd[MAX_FD];
-    void *fw_cfg;
+    FWCfgState *fw_cfg;
 
     /* init CPUs */
     cpu = cpu_devinit(cpu_model, hwdef);
Signature · 1 line
1.7.11.7