pci: misc cleanups
The following changes since commit 87d23f78aa79b72da022afda358bbc8a8509ca70:
virtio-pci: drop unused wmb macro (2013-05-29 08:16:21 -0500)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
for you to fetch changes up to c3c4fe35be9f6c37388ba7615c6c33e8f4034438:
pvpanic: use FWCfgState explicitly (2013-06-02 18:14:15 +0300)
----------------------------------------------------------------
pci: misc cleanups
This includes some pci-related cleanups,
and fw cfg cleanups which will be useful for on-going pci related work.
----------------------------------------------------------------
Laszlo Ersek (1):
refer to FWCfgState explicitly
Michael S. Tsirkin (8):
q35: set fw_name
dec.c - move to pci-bridge
firmware_abi: move to include/hw/nvram/
apic: rename apic specific bitopts
fw_cfg: move typedef to qemu/typedefs.h
fw_cfg: add API to find FW cfg object
fw_cfg: fw_cfg is a singleton
pvpanic: use FWCfgState explicitly
hw/acpi/piix4.c | 2 +-
hw/core/loader.c | 2 +-
hw/i386/multiboot.c | 2 +-
hw/i386/multiboot.h | 4 ++-
hw/i386/pc.c | 24 ++++++-------
hw/i386/pc_piix.c | 2 +-
hw/intc/apic.c | 42 +++++++++++-----------
hw/misc/pvpanic.c | 4 +--
hw/nvram/fw_cfg.c | 18 +++++++---
hw/nvram/mac_nvram.c | 2 +-
hw/pci-bridge/Makefile.objs | 2 ++
hw/{pci-host => pci-bridge}/dec.c | 0
hw/{pci-host => pci-bridge}/dec.h | 0
hw/pci-host/Makefile.objs | 1 -
hw/pci-host/q35.c | 1 +
hw/sparc/sun4m.c | 4 +--
hw/sparc64/sun4u.c | 4 +--
include/hw/i386/pc.h | 18 +++++-----
include/hw/loader.h | 3 +-
include/hw/nvram/fw_cfg.h | 4 ++-
.../openbios_firmware_abi.h} | 0
include/qemu/typedefs.h | 1 +
22 files changed, 78 insertions(+), 62 deletions(-)
rename hw/{pci-host => pci-bridge}/dec.c (100%)
rename hw/{pci-host => pci-bridge}/dec.h (100%)
rename include/hw/{sparc/firmware_abi.h => nvram/openbios_firmware_abi.h} (100%)[Qemu-devel] [PULL 2/9] dec.c - move to pci-bridge
Looks like dec.c is in pci-host by mistake.
Moving it over to pci-bridge.
---
hw/pci-bridge/Makefile.objs | 2 ++
hw/{pci-host => pci-bridge}/dec.c | 0
hw/{pci-host => pci-bridge}/dec.h | 0
hw/pci-host/Makefile.objs | 1 -
4 files changed, 2 insertions(+), 1 deletion(-)
rename hw/{pci-host => pci-bridge}/dec.c (100%)
rename hw/{pci-host => pci-bridge}/dec.h (100%)hw/pci-bridge/Makefile.objs +2 -0
@@ -1,3 +1,5 @@ common-obj-y += pci_bridge_dev.o common-obj-y += ioh3420.o xio3130_upstream.o xio3130_downstream.o common-obj-y += i82801b11.o +# NewWorld PowerMac +common-obj-$(CONFIG_DEC_PCI) += dec.o
hw/pci-bridge/dec.c renamed from hw/pci-host/dec.c +0 -0
hw/pci-bridge/dec.h renamed from hw/pci-host/dec.h +0 -0
hw/pci-host/Makefile.objs +0 -1
@@ -5,7 +5,6 @@ common-obj-$(CONFIG_PREP_PCI) += prep.o common-obj-$(CONFIG_GRACKLE_PCI) += grackle.o # NewWorld PowerMac common-obj-$(CONFIG_UNIN_PCI) += uninorth.o -common-obj-$(CONFIG_DEC_PCI) += dec.o # PowerPC E500 boards common-obj-$(CONFIG_PPCE500_PCI) += ppce500.o
Signature · 1 line
MST
[Qemu-devel] [PULL 1/9] q35: set fw_name
In reply to Michael S. TsirkinPCI host bridges need to set fw_name to be discoverable by bios for boot device selection.
In particular, seabios expects root device to be called "/pci/@i0cf8", so let's set it up like that for Q35.
--- hw/pci-host/q35.c | 1 + 1 file changed, 1 insertion(+)
hw/pci-host/q35.c +1 -0
@@ -76,6 +76,7 @@ static void q35_host_class_init(ObjectClass *klass, void *data) k->init = q35_host_init; dc->props = mch_props; + dc->fw_name ="pci" ; }static void q35_host_initfn (Object *obj)
Signature · 1 line
MST
[Qemu-devel] [PULL 3/9] firmware_abi: move to include/hw/nvram/
In reply to Michael S. Tsirkinfirmware_abi.h with structs for OpenBIOS landed in hw/sparc/ by mistake
- move it to hw/nvram/ alongside fw_cfg.h. In addition to sparc it's included from ppc mac_nvram.c and will need to include it from prep.c in the future.
---
hw/nvram/mac_nvram.c | 2 +-
hw/sparc/sun4m.c | 2 +-
hw/sparc64/sun4u.c | 2 +-
include/hw/{sparc/firmware_abi.h => nvram/openbios_firmware_abi.h} | 0
4 files changed, 3 insertions(+), 3 deletions(-)
rename include/hw/{sparc/firmware_abi.h => nvram/openbios_firmware_abi.h} (100%)hw/nvram/mac_nvram.c +1 -1
@@ -23,7 +23,7 @@* THE SOFTWARE. */ #include "hw/hw.h" -#include "hw/sparc/firmware_abi.h" +#include "hw/nvram/openbios_firmware_abi.h" #include "sysemu/sysemu.h" #include "hw/ppc/mac.h"
hw/sparc/sun4m.c +1 -1
@@ -30,7 +30,7 @@#include "sysemu/sysemu.h" #include "net/net.h" #include "hw/boards.h" -#include "hw/sparc/firmware_abi.h" +#include "hw/nvram/openbios_firmware_abi.h" #include "hw/scsi/esp.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h"
hw/sparc64/sun4u.c +1 -1
@@ -32,7 +32,7 @@#include "qemu/timer.h" #include "sysemu/sysemu.h" #include "hw/boards.h" -#include "hw/sparc/firmware_abi.h" +#include "hw/nvram/openbios_firmware_abi.h" #include "hw/nvram/fw_cfg.h" #include "hw/sysbus.h" #include "hw/ide.h"
include/hw/nvram/openbios_firmware_abi.h renamed from include/hw/sparc/firmware_abi.h +0 -0
Signature · 1 line
MST
[Qemu-devel] [PULL 4/9] apic: rename apic specific bitopts
In reply to Michael S. Tsirkinapic has its own version of bitops, with the difference that it works on u32 and not long. Add apic_ prefix to avoid namespace clashes.
We should look into reusing standard bitops long-term, but that's not entirely trivial.
--- hw/intc/apic.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
hw/intc/apic.c +21 -21
@@ -40,18 +40,18 @@ static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask, uint8_t dest, uint8_t dest_mode);/* Find first bit starting from msb */ -static int fls_bit (uint32_t value) +static int apic_fls_bit (uint32_t value) {return 31 -clz32 (value); }/* Find first bit starting from lsb */ -static int ffs_bit (uint32_t value) +static int apic_ffs_bit (uint32_t value) {return ctz32 (value); } -static inline void set_bit (uint32_t *tab,int index) +static inline void apic_set_bit (uint32_t *tab,int index) {int i, mask; i = index >>5 ;
@@ -59,7 +59,7 @@ static inline void set_bit(uint32_t *tab, int index) tab[i] |= mask; } -static inline void reset_bit (uint32_t *tab,int index) +static inline void apic_reset_bit (uint32_t *tab,int index) {int i, mask; i = index >>5 ;
@@ -67,7 +67,7 @@ static inline void reset_bit(uint32_t *tab, int index) tab[i] &= ~mask; } -static inline int get_bit (uint32_t *tab,int index) +static inline int apic_get_bit (uint32_t *tab,int index) {int i, mask; i = index >>5 ;
@@ -81,7 +81,7 @@ static int get_highest_priority_int(uint32_t *tab)int i;for (i =7 ; i >=0 ; i--) {if (tab[i] !=0 ) { -return i *32 +fls_bit (tab[i]); +return i *32 +apic_fls_bit (tab[i]); } }return -1 ;
@@ -184,7 +184,7 @@ void apic_deliver_pic_intr(DeviceState *d, int level)case APIC_DM_FIXED :if (!(lvt &APIC_LVT_LEVEL_TRIGGER ))break ; -reset_bit (s->irr, lvt &0xff ); +apic_reset_bit (s->irr, lvt &0xff );/* fall through */ case APIC_DM_EXTINT :cpu_reset_interrupt (CPU (s->cpu),CPU_INTERRUPT_HARD );
@@ -230,7 +230,7 @@ static void apic_bus_deliver(const uint32_t *deliver_bitmask, d =-1 ;for (i =0 ; i <MAX_APIC_WORDS ; i++) {if (deliver_bitmask[i]) { - d = i *32 +ffs_bit (deliver_bitmask[i]); + d = i *32 +apic_ffs_bit (deliver_bitmask[i]);break ; } }
@@ -386,13 +386,13 @@ void apic_poll_irq(DeviceState *d)static void apic_set_irq (APICCommonState *s,int vector_num,int trigger_mode) { -apic_report_irq_delivered (!get_bit (s->irr, vector_num)); +apic_report_irq_delivered (!apic_get_bit (s->irr, vector_num)); -set_bit (s->irr, vector_num); +apic_set_bit (s->irr, vector_num);if (trigger_mode) -set_bit (s->tmr, vector_num); +apic_set_bit (s->tmr, vector_num);else -reset_bit (s->tmr, vector_num); +apic_reset_bit (s->tmr, vector_num);if (s->vapic_paddr) {apic_sync_vapic (s,SYNC_ISR_IRR_TO_VAPIC );/*
@@ -412,8 +412,8 @@ static void apic_eoi(APICCommonState *s) isrv =get_highest_priority_int (s->isr);if (isrv <0 )return ; -reset_bit (s->isr, isrv); -if (!(s->spurious_vec &APIC_SV_DIRECTED_IO ) &&get_bit (s->tmr, isrv)) { +apic_reset_bit (s->isr, isrv); +if (!(s->spurious_vec &APIC_SV_DIRECTED_IO ) &&apic_get_bit (s->tmr, isrv)) {ioapic_eoi_broadcast (isrv); }apic_sync_vapic (s,SYNC_FROM_VAPIC |SYNC_TO_VAPIC );
@@ -452,7 +452,7 @@ static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,int idx =apic_find_dest (dest);memset (deliver_bitmask,0x00 ,MAX_APIC_WORDS *sizeof (uint32_t ));if (idx >=0 ) -set_bit (deliver_bitmask, idx); +apic_set_bit (deliver_bitmask, idx); } }else {/* XXX: cluster mode */
@@ -462,11 +462,11 @@ static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,if (apic_iter) {if (apic_iter->dest_mode ==0xf ) {if (dest & apic_iter->log_dest) -set_bit (deliver_bitmask, i); +apic_set_bit (deliver_bitmask, i); }else if (apic_iter->dest_mode ==0x0 ) {if ((dest &0xf0 ) == (apic_iter->log_dest &0xf0 ) && (dest & apic_iter->log_dest &0x0f )) { -set_bit (deliver_bitmask, i); +apic_set_bit (deliver_bitmask, i); } } }else {
@@ -509,14 +509,14 @@ static void apic_deliver(DeviceState *d, uint8_t dest, uint8_t dest_mode,break ;case 1 :memset (deliver_bitmask,0x00 ,sizeof (deliver_bitmask)); -set_bit (deliver_bitmask, s->idx); +apic_set_bit (deliver_bitmask, s->idx);break ;case 2 :memset (deliver_bitmask,0xff ,sizeof (deliver_bitmask));break ;case 3 :memset (deliver_bitmask,0xff ,sizeof (deliver_bitmask)); -reset_bit (deliver_bitmask, s->idx); +apic_reset_bit (deliver_bitmask, s->idx);break ; }
@@ -573,8 +573,8 @@ int apic_get_interrupt(DeviceState *d)apic_sync_vapic (s,SYNC_TO_VAPIC );return s->spurious_vec &0xff ; } -reset_bit (s->irr, intno); -set_bit (s->isr, intno); +apic_reset_bit (s->irr, intno); +apic_set_bit (s->isr, intno);apic_sync_vapic (s,SYNC_TO_VAPIC );/* re-inject if there is still a pending PIC interrupt */
Signature · 1 line
MST
[Qemu-devel] [PULL 6/9] fw_cfg: move typedef to qemu/typedefs.h
In reply to Michael S. TsirkinLess header dependencies this way.
--- include/hw/i386/pc.h | 1 - include/hw/nvram/fw_cfg.h | 2 +- include/qemu/typedefs.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)
include/hw/i386/pc.h +0 -1
@@ -8,7 +8,6 @@#include "hw/block/fdc.h" #include "net/net.h" #include "hw/i386/ioapic.h" -#include "hw/nvram/fw_cfg.h" /* PC-style peripherals (also used by other machines). */
include/hw/nvram/fw_cfg.h +1 -1
@@ -6,6 +6,7 @@#include <stddef.h> #include "exec/hwaddr.h" +#include "qemu/typedefs.h" #endif #define FW_CFG_SIGNATURE 0x00
@@ -60,7 +61,6 @@ typedef struct FWCfgFiles {typedef void (*FWCfgCallback )(void *opaque,uint8_t *data); -typedef struct FWCfgState FWCfgState ;void fw_cfg_add_bytes (FWCfgState *s,uint16_t key,void *data,size_t len);void fw_cfg_add_string (FWCfgState *s,uint16_t key,const char *value);void fw_cfg_add_i16 (FWCfgState *s,uint16_t key,uint16_t value);
include/qemu/typedefs.h +1 -0
@@ -61,5 +61,6 @@ typedef struct EventNotifier EventNotifier;typedef struct VirtIODevice VirtIODevice ;typedef struct QEMUSGList QEMUSGList ;typedef struct SHPCDevice SHPCDevice ; +typedef struct FWCfgState FWCfgState ;#endif /* QEMU_TYPEDEFS_H */
Signature · 1 line
MST
[Qemu-devel] [PULL 5/9] refer to FWCfgState explicitly
In reply to Michael S. TsirkinFrom: Laszlo Ersek <[email protected]>
Currently some places use pointer-to-void even though they mean pointer-to-FWCfgState. Clean them up.
--- hw/acpi/piix4.c | 2 +- hw/core/loader.c | 2 +- hw/i386/multiboot.c | 2 +- hw/i386/multiboot.h | 4 +++- hw/i386/pc.c | 24 ++++++++++++------------ hw/i386/pc_piix.c | 2 +- hw/sparc/sun4m.c | 2 +- hw/sparc64/sun4u.c | 2 +- include/hw/i386/pc.h | 19 ++++++++++--------- include/hw/loader.h | 3 ++- 10 files changed, 33 insertions(+), 29 deletions(-)
hw/acpi/piix4.c +1 -1
@@ -447,7 +447,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/core/loader.c +1 -1
@@ -733,7 +733,7 @@ int rom_load_all(void)return 0 ; } -void rom_set_fw (void *f) +void rom_set_fw (FWCfgState *f) { fw_cfg = f; }
hw/i386/multiboot.c +1 -1
@@ -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/i386/multiboot.h +3 -1
@@ -1,7 +1,9 @@#ifndef QEMU_MULTIBOOT_H #define QEMU_MULTIBOOT_H -int load_multiboot(void *fw_cfg, +#include "hw/nvram/fw_cfg.h" + +int load_multiboot(FWCfgState *fw_cfg, FILE *f, const char *kernel_filename, const char *initrd_filename,
hw/i386/pc.c +12 -12
@@ -595,9 +595,9 @@ static unsigned int pc_apic_id_limit(unsigned int max_cpus)return x86_cpu_apic_id_from_index (max_cpus -1 ) +1 ; } -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;
@@ -674,7 +674,7 @@ 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,
@@ -1012,19 +1012,19 @@ void pc_acpi_init(const char *default_dsdt) } } -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/i386/pc_piix.c +1 -1
@@ -89,7 +89,7 @@ static void pc_init1(MemoryRegion *system_memory,MemoryRegion *pci_memory;MemoryRegion *rom_memory;DeviceState *icc_bridge; -void *fw_cfg =NULL ; +FWCfgState *fw_cfg =NULL ; icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE ); object_property_add_child(qdev_get_machine(), "icc-bridge",
hw/sparc/sun4m.c +1 -1
@@ -831,7 +831,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 */
hw/sparc64/sun4u.c +1 -1
@@ -818,7 +818,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);
include/hw/i386/pc.h +10 -9
@@ -8,6 +8,7 @@#include "hw/block/fdc.h" #include "net/net.h" #include "hw/i386/ioapic.h" +#include "hw/nvram/fw_cfg.h" /* PC-style peripherals (also used by other machines). */
@@ -80,14 +81,14 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level);void pc_cpus_init (const char *cpu_model,DeviceState *icc_bridge);void pc_hot_add_cpu (const int64_t id,Error **errp);void pc_acpi_init (const char *default_dsdt); -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,
@@ -111,7 +112,7 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);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 */
include/hw/loader.h +2 -1
@@ -1,6 +1,7 @@#ifndef LOADER_H #define LOADER_H #include "qapi/qmp/qdict.h" +#include "hw/nvram/fw_cfg.h" /* loader.c */ int get_image_size (const char *filename);
@@ -30,7 +31,7 @@ int rom_add_blob(const char *name, const void *blob, size_t len,int rom_add_elf_program (const char *name,void *data,size_t datasize,size_t romsize,hwaddr addr);int rom_load_all (void ); -void rom_set_fw (void *f); +void rom_set_fw (FWCfgState *f);int rom_copy (uint8_t *dest,hwaddr addr,size_t size);void *rom_ptr (hwaddr addr);void do_info_roms (Monitor *mon,const QDict *qdict);
Signature · 1 line
MST
[Qemu-devel] [PULL 7/9] fw_cfg: add API to find FW cfg object
In reply to Michael S. TsirkinRemove some code duplication by adding a
function to look up the fw cfg file.
This way, we don't need to duplicate same strings everywhere. Use by both fw cfg and pvpanic device.
--- hw/misc/pvpanic.c | 2 +- hw/nvram/fw_cfg.c | 15 ++++++++++++--- include/hw/nvram/fw_cfg.h | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-)
hw/misc/pvpanic.c +1 -1
@@ -96,7 +96,7 @@ static int pvpanic_isa_initfn(ISADevice *dev)isa_register_ioport (dev, &s->io, s->ioport);if (!port_configured) { - fw_cfg =object_resolve_path ("/machine/fw_cfg" ,NULL ); + fw_cfg =fw_cfg_find ();if (fw_cfg) { fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", g_memdup(&s->ioport, sizeof(s->ioport)),
hw/nvram/fw_cfg.c +12 -3
@@ -32,6 +32,9 @@#define FW_CFG_SIZE 2#define FW_CFG_DATA_SIZE 1 +#define TYPE_FW_CFG "fw_cfg" +#define FW_CFG_NAME "fw_cfg" +#define FW_CFG_PATH "/machine/" FW_CFG_NAME typedef struct FWCfgEntry { uint32_t len;
@@ -493,8 +496,8 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, s =DO_UPCAST (FWCfgState, busdev.qdev, dev); -if (!object_resolve_path ("/machine/fw_cfg" ,NULL )) { -object_property_add_child (qdev_get_machine (),"fw_cfg" ,OBJECT (s), +if (!object_resolve_path (FW_CFG_PATH ,NULL )) { +object_property_add_child (qdev_get_machine (),FW_CFG_NAME ,OBJECT (s),NULL ); }
@@ -553,6 +556,12 @@ static Property fw_cfg_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +FWCfgState *fw_cfg_find (void ) +{ +return OBJECT_CHECK (FWCfgState,object_resolve_path (FW_CFG_PATH ,NULL ), +TYPE_FW_CFG ); +} +static void fw_cfg_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -566,7 +575,7 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data) }static const TypeInfo fw_cfg_info = { - .name ="fw_cfg" , + .name =TYPE_FW_CFG , .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (FWCfgState), .class_init = fw_cfg_class_init,
include/hw/nvram/fw_cfg.h +2 -0
@@ -73,6 +73,8 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,FWCfgState *fw_cfg_init (uint32_t ctl_port,uint32_t data_port,hwaddr crl_addr,hwaddr data_addr); +FWCfgState *fw_cfg_find (void ); +#endif /* NO_QEMU_PROTOS */ #endif
Signature · 1 line
MST
[Qemu-devel] [PULL 8/9] fw_cfg: fw_cfg is a singleton
In reply to Michael S. TsirkinMake sure we only have a single instance ever:
because if it isn't we can't find it so it's
useless anyway.
--- hw/nvram/fw_cfg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
hw/nvram/fw_cfg.c +3 -4
@@ -496,10 +496,9 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, s =DO_UPCAST (FWCfgState, busdev.qdev, dev); -if (!object_resolve_path (FW_CFG_PATH ,NULL )) { -object_property_add_child (qdev_get_machine (),FW_CFG_NAME ,OBJECT (s), -NULL ); - } +assert (!object_resolve_path (FW_CFG_PATH ,NULL )); + +object_property_add_child (qdev_get_machine (),FW_CFG_NAME ,OBJECT (s),NULL );qdev_init_nofail (dev);
Signature · 1 line
MST
[Qemu-devel] [PULL 9/9] pvpanic: use FWCfgState explicitly
In reply to Michael S. TsirkinUse the type-safe FWCfgState structure instead
of the unsafe void *.
--- hw/misc/pvpanic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/pvpanic.c +1 -1
@@ -90,7 +90,7 @@ static int pvpanic_isa_initfn(ISADevice *dev) {PVPanicState *s =ISA_PVPANIC_DEVICE (dev);static bool port_configured; -void *fw_cfg; +FWCfgState *fw_cfg;memory_region_init_io (&s->io, &pvpanic_ops, s,"pvpanic" ,1 );isa_register_ioport (dev, &s->io, s->ioport);
Signature · 1 line
MST
Pulled. Thanks.
Regards,
Anthony Liguori