Indirection Cleanup
cover Indirection Cleanup
Hi
v2:
- fix comment missmerge in eepro100 (Stefan Weil)
- add dev.qdev hint instead of double DO_UPCAST on lsi (Kraxel)
- usb-ohci: not everything is pci. Add PCI state only to the pci part (Kraxel)
- ne2000: Don't force pci bits into isa devices (make Kraxel happy)
- ne2000: split isa and pci save/load functions. From now, isa parts are only the common ones.
- cirrus_vga: Don't force pci bits into isa device (make Kraxel happy)
- pcnet: Add it here, split save/load function between pci and generic.
- e1000 cleanup: Add it to the series (was sent alone), just for easy tracking.
- drop es1370 bits: malc already integrated it.
ToDo:
- vga: It needs to have a separate VGAState and VGACommonState. And make clear what is shared and what no (convince cirrus_vga, vmware_vga and blizzard to use same/similar subset).
Later, Juan.
v1:
This patch series clean up "half" converted qemu drivers that had changed from:
struct FOOState
to
typedef PCIFOOState {
PCIDevice dev;
FOOState foo;
} PCIFOOState;It just moves PCIDevice to be the 1st field of FOOState.
Once there, other cleanups were done:
a - pci_dev pointer from FOOState to PCIFOOState is removed, jsut use s->dev
The field is leave only in the drivers that also emulate isa.
b- Once there, transformo
PCIFOOState *s = (PCIFOOState *)pci_dev
to
PCIFOOState *s = DO_UPCAST(PCIFOOState, dev, pci_dev)
where pci_dev is a PCI_DEVICE.
c- again, once there, remove all the casts from void * (they are not
needed since '89)
PCIFOOState *s = (PCIFOOState *)opaque;
to
PCIFOOState *s = opaque;
d- Start of vga.c cleanup. It is not trivial, as just now
VGAState == VGACommonState, functions need to be changed to use the right value.
ToDo:
- pcnet: It needs a different approach, because it can be both a PCIDevice or a SysBus device.
- vga: It have to separate the common part for the not common part, problems now is that VGAState is used for both the common state and the standard vga. To make things more interesting, different bits are "inherited" from vga in different devices:
- cirrus_vga
- vmware_vga
- blizzard (vga that is not pci)
- vga common state has a pci_dev pointer, that is only needed by std vga, as cirrus_vga stores it (with this patches) otherplace, blizzard is not pci .... you get the idea
- I guess some other driver is missing, but my fast grep didn't found it.
Later, Juan.
*** BLURB HERE ***
Juan Quintela (26):
eepro100: convert casts to DO_UPCAST()
eepro100: cast a void * makes no sense
eepro100: Remove unused indirection of PCIDevice
pci: remove casts from void *
rtl8139: Remove unneeded double indirection of PCIRTL8139State
rtl8139: remove pointless cast from void *
lsi53c895a: remove pointless cast from void *
lsi53c895a: use DO_UPCAST to cast from PCIDevice
lsi53c895a: rename PCIDevice field from pci_dev to dev (consistence)
lsi53c895a: LSIState is a PCIDevice is a DeviceHost Introduce vga_common_reset() to be able to typcheck vga_reset()
vga: Rename vga_state -> vga
Everything outside of vga.c should use VGACommonState
usb-ohci: Change casts to DO_UPCAST() for OHCIPCIState
ne2000: remove casts from void *
ne2000: pci_dev has this very value with the right type
ne2000: Change casts to DO_UPCAST() for PCINE2000State
We need PCINE2000State for save/load functions
Add pci_ne2000_{save/load} functions, then remove pci_dev NE2000State
field
cirrus_vga: remove pointless cast from void *
cirrus_vga: Change casts to DO_UPCAST() for PCICirrusVGAState Add pci_cirrus_vga_{save/load} functions, then remove vga.pci_dev use
pcnet: Change casts to DO_UPCAST() for PCIPCNetState
pcnet: remove useless casts This are casts to the very type of the
function
pcnet: Add pci_pcnet_{save/load} functions, then remove PCNetState
pci_dev field
e1000 cleanup
hw/cirrus_vga.c | 69 +++++++++++++++++++++++++++++++++--------------------- hw/e1000.c | 10 ++++---- hw/eepro100.c | 63 ++++++++++++++++++++----------------------------- hw/lsi53c895a.c | 64 +++++++++++++++++++++++++------------------------- hw/ne2000.c | 61 +++++++++++++++++++++++++++++------------------- hw/pci.c | 8 +++--- hw/pcnet.c | 59 ++++++++++++++++++++++++++++------------------ hw/rtl8139.c | 42 ++++++++++++--------------------- hw/usb-ohci.c | 7 +++-- hw/vga.c | 26 ++++++++++++-------- hw/vga_int.h | 12 ++++----- hw/vmware_vga.c | 4 +- 12 files changed, 224 insertions(+), 201 deletions(-)
PATCH 1/26 eepro100: convert casts to DO_UPCAST()
--- hw/eepro100.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
hw/eepro100.c +4 -4
@@ -1346,7 +1346,7 @@ typedef struct PCIEEPRO100State {static void pci_map (PCIDevice * pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCIEEPRO100State *d = (PCIEEPRO100State *) pci_dev; +PCIEEPRO100State *d =DO_UPCAST (PCIEEPRO100State, dev, pci_dev);EEPRO100State *s = &d->eepro100; logout("region %d, addr=0x%08x, size=0x%08x, type=%d\n",
@@ -1420,7 +1420,7 @@ static CPUReadMemoryFunc *pci_mmio_read[] = {static void pci_mmio_map (PCIDevice * pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCIEEPRO100State *d = (PCIEEPRO100State *) pci_dev; +PCIEEPRO100State *d =DO_UPCAST (PCIEEPRO100State, dev, pci_dev);logout ("region %d, addr=0x%08x, size=0x%08x, type=%d\n" , region_num, addr, size, type);
@@ -1720,7 +1720,7 @@ static void nic_cleanup(VLANClientState *vc)static int pci_nic_uninit (PCIDevice *dev) { -PCIEEPRO100State *d = (PCIEEPRO100State *) dev; +PCIEEPRO100State *d =DO_UPCAST (PCIEEPRO100State, dev, dev);EEPRO100State *s = &d->eepro100;cpu_unregister_io_memory (s->mmio_index);
@@ -1730,7 +1730,7 @@ static int pci_nic_uninit(PCIDevice *dev)static void nic_init (PCIDevice *pci_dev,uint32_t device) { -PCIEEPRO100State *d = (PCIEEPRO100State *)pci_dev; +PCIEEPRO100State *d =DO_UPCAST (PCIEEPRO100State, dev, pci_dev);EEPRO100State *s;logout ("\n" );
Signature · 1 line
1.6.2.5
PATCH 2/26 eepro100: cast a void * makes no sense
In reply to Juan Quintela--- hw/eepro100.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
hw/eepro100.c +3 -3
@@ -507,7 +507,7 @@ static void nic_selective_reset(EEPRO100State * s)static void nic_reset (void *opaque) { -EEPRO100State *s = (EEPRO100State *) opaque; +EEPRO100State *s = opaque;logout ("%p\n" , s);static int first;if (!first) {
@@ -1544,7 +1544,7 @@ static ssize_t nic_receive(VLANClientState *vc, const uint8_t * buf, size_t sizestatic int nic_load (QEMUFile * f,void *opaque,int version_id) { -EEPRO100State *s = (EEPRO100State *) opaque; +EEPRO100State *s = opaque;int i;int ret;
@@ -1634,7 +1634,7 @@ static int nic_load(QEMUFile * f, void *opaque, int version_id)static void nic_save (QEMUFile * f,void *opaque) { -EEPRO100State *s = (EEPRO100State *) opaque; +EEPRO100State *s = opaque;int i;if (s->pci_dev)
Signature · 1 line
1.6.2.5
PATCH 3/26 eepro100: Remove unused indirection of PCIDevice
In reply to Juan QuintelaOnce there, there is no way that we don't have a PCI Device at save/load time. Remove the check
--- hw/eepro100.c | 57 +++++++++++++++++++++++---------------------------------- 1 files changed, 23 insertions(+), 34 deletions(-)
hw/eepro100.c +23 -34
@@ -181,6 +181,7 @@ typedef enum { } ru_state_t; typedef struct { + PCIDevice dev; #if 1 uint8_t cmd; uint32_t start;
@@ -200,7 +201,6 @@ typedef struct {uint8_t curpag;uint8_t mult[8 ];/* multicast mask array */ int mmio_index; -PCIDevice *pci_dev;VLANClientState *vc;#endif uint8_t scb_stat;/* SCB stat/ack byte */
@@ -304,7 +304,7 @@ static void disable_interrupt(EEPRO100State * s) {if (s->int_stat) {logout ("interrupt disabled\n" ); -qemu_irq_lower (s->pci_dev->irq[0 ]); +qemu_irq_lower (s->dev.irq[0 ]); s->int_stat =0 ; } }
@@ -313,7 +313,7 @@ static void enable_interrupt(EEPRO100State * s) {if (!s->int_stat) {logout ("interrupt enabled\n" ); -qemu_irq_raise (s->pci_dev->irq[0 ]); +qemu_irq_raise (s->dev.irq[0 ]); s->int_stat =1 ; } }
@@ -392,7 +392,7 @@ static void eepro100_fcp_interrupt(EEPRO100State * s)static void pci_reset (EEPRO100State * s) {uint32_t device = s->device; -uint8_t *pci_conf = s->pci_dev->config; +uint8_t *pci_conf = s->dev.config;logout ("%p\n" , s);
@@ -1338,16 +1338,10 @@ static void ioport_write4(void *opaque, uint32_t addr, uint32_t val)/***********************************************************/ /* PCI EEPRO100 definitions */ -typedef struct PCIEEPRO100State { -PCIDevice dev; -EEPRO100State eepro100; -}PCIEEPRO100State ; -static void pci_map (PCIDevice * pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCIEEPRO100State *d =DO_UPCAST (PCIEEPRO100State, dev, pci_dev); -EEPRO100State *s = &d->eepro100; +EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);logout ("region %d, addr=0x%08x, size=0x%08x, type=%d\n" , region_num, addr, size, type);
@@ -1420,15 +1414,15 @@ static CPUReadMemoryFunc *pci_mmio_read[] = {static void pci_mmio_map (PCIDevice * pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCIEEPRO100State *d =DO_UPCAST (PCIEEPRO100State, dev, pci_dev); +EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);logout ("region %d, addr=0x%08x, size=0x%08x, type=%d\n" , region_num, addr, size, type);if (region_num ==0 ) {/* Map control / status registers. */ -cpu_register_physical_memory (addr, size, d->eepro100.mmio_index); - d->eepro100.region[region_num] = addr; +cpu_register_physical_memory (addr, size, s->mmio_index); + s->region[region_num] = addr; } }
@@ -1551,8 +1545,8 @@ static int nic_load(QEMUFile * f, void *opaque, int version_id)if (version_id >3 )return -EINVAL ; -if (s->pci_dev && version_id >=3 ) { - ret =pci_device_load (s->pci_dev, f); +if (version_id >=3 ) { + ret =pci_device_load (&s->dev, f);if (ret <0 )return ret; }
@@ -1637,8 +1631,7 @@ static void nic_save(QEMUFile * f, void *opaque)EEPRO100State *s = opaque;int i; -if (s->pci_dev) -pci_device_save (s->pci_dev, f); +pci_device_save (&s->dev, f);qemu_put_8s (f, &s->rxcr);
@@ -1720,8 +1713,7 @@ static void nic_cleanup(VLANClientState *vc)static int pci_nic_uninit (PCIDevice *dev) { -PCIEEPRO100State *d =DO_UPCAST (PCIEEPRO100State, dev, dev); -EEPRO100State *s = &d->eepro100; +EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, dev);cpu_unregister_io_memory (s->mmio_index);
@@ -1730,16 +1722,13 @@ static int pci_nic_uninit(PCIDevice *dev)static void nic_init (PCIDevice *pci_dev,uint32_t device) { -PCIEEPRO100State *d =DO_UPCAST (PCIEEPRO100State, dev, pci_dev); -EEPRO100State *s; +EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);logout ("\n" ); - d->dev.unregister = pci_nic_uninit; + s->dev.unregister = pci_nic_uninit; - s = &d->eepro100; s->device = device; - s->pci_dev = &d->dev;pci_reset (s);
@@ -1748,24 +1737,24 @@ static void nic_init(PCIDevice *pci_dev, uint32_t device) s->eeprom =eeprom93xx_new (EEPROM_SIZE );/* Handler for memory-mapped I/O */ - d->eepro100.mmio_index = + s->mmio_index =cpu_register_io_memory (pci_mmio_read, pci_mmio_write, s); -pci_register_bar (&d->dev,0 ,PCI_MEM_SIZE , +pci_register_bar (&s->dev,0 ,PCI_MEM_SIZE ,PCI_ADDRESS_SPACE_MEM |PCI_ADDRESS_SPACE_MEM_PREFETCH , pci_mmio_map); -pci_register_bar (&d->dev,1 ,PCI_IO_SIZE ,PCI_ADDRESS_SPACE_IO , +pci_register_bar (&s->dev,1 ,PCI_IO_SIZE ,PCI_ADDRESS_SPACE_IO , pci_map); -pci_register_bar (&d->dev,2 ,PCI_FLASH_SIZE ,PCI_ADDRESS_SPACE_MEM , +pci_register_bar (&s->dev,2 ,PCI_FLASH_SIZE ,PCI_ADDRESS_SPACE_MEM , pci_mmio_map); -qdev_get_macaddr (&d->dev.qdev, s->macaddr); +qdev_get_macaddr (&s->dev.qdev, s->macaddr);logout ("macaddr: %s\n" ,nic_dump (&s->macaddr[0 ],6 ));assert (s->region[1 ] ==0 );nic_reset (s); - s->vc =qdev_get_vlan_client (&d->dev.qdev, + s->vc =qdev_get_vlan_client (&s->dev.qdev, nic_can_receive, nic_receive,NULL , nic_cleanup, s);
@@ -1794,15 +1783,15 @@ static void pci_i82559er_init(PCIDevice *dev)static PCIDeviceInfo eepro100_info[] = { { .qdev.name ="i82551" , - .qdev.size =sizeof (PCIEEPRO100State), + .qdev.size =sizeof (EEPRO100State), .init = pci_i82551_init, },{ .qdev.name ="i82557b" , - .qdev.size =sizeof (PCIEEPRO100State), + .qdev.size =sizeof (EEPRO100State), .init = pci_i82557b_init, },{ .qdev.name ="i82559er" , - .qdev.size =sizeof (PCIEEPRO100State), + .qdev.size =sizeof (EEPRO100State), .init = pci_i82559er_init, },{/* end of list */
Signature · 1 line
1.6.2.5
PATCH 4/26 pci: remove casts from void *
In reply to Juan Quintela--- hw/pci.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
hw/pci.c +4 -4
@@ -75,7 +75,7 @@ static PCIBus *first_bus;static void pcibus_save (QEMUFile *f,void *opaque) { -PCIBus *bus = (PCIBus *)opaque; +PCIBus *bus = opaque;int i;qemu_put_be32 (f, bus->nirq);
@@ -85,7 +85,7 @@ static void pcibus_save(QEMUFile *f, void *opaque)static int pcibus_load (QEMUFile *f,void *opaque,int version_id) { -PCIBus *bus = (PCIBus *)opaque; +PCIBus *bus = opaque;int i, nirq;if (version_id !=1 )
@@ -106,7 +106,7 @@ static int pcibus_load(QEMUFile *f, void *opaque, int version_id)static void pci_bus_reset (void *opaque) { -PCIBus *bus = (PCIBus *)opaque; +PCIBus *bus = opaque;int i;for (i =0 ; i < bus->nirq; i++) {
@@ -624,7 +624,7 @@ uint32_t pci_data_read(void *opaque, uint32_t addr, int len)/* 0 <= irq_num <= 3. level must be 0 or 1 */ static void pci_set_irq (void *opaque,int irq_num,int level) { -PCIDevice *pci_dev = (PCIDevice *)opaque; +PCIDevice *pci_dev = opaque;PCIBus *bus;int change;
Signature · 1 line
1.6.2.5
PATCH 5/26 rtl8139: Remove unneeded double indirection of PCIRTL8139State
In reply to Juan Quintela--- hw/rtl8139.c | 38 +++++++++++++------------------------- 1 files changed, 13 insertions(+), 25 deletions(-)
hw/rtl8139.c +13 -25
@@ -423,6 +423,7 @@ static void RTL8139TallyCounters_load(QEMUFile* f, RTL8139TallyCounters *tally_cstatic void RTL8139TallyCounters_save (QEMUFile * f,RTL8139TallyCounters *tally_counters); typedef struct RTL8139State { + PCIDevice dev; uint8_t phys[8]; /* mac address */ uint8_t mult[8]; /* multicast mask array */
@@ -463,7 +464,6 @@ typedef struct RTL8139State {uint16_t CpCmd;uint8_t TxThresh; -PCIDevice *pci_dev;VLANClientState *vc;uint8_t macaddr[6 ];int rtl8139_mmio_io_addr;
@@ -692,7 +692,7 @@ static void rtl8139_update_irq(RTL8139State *s)DEBUG_PRINT (("RTL8139: Set IRQ to %d (%04x %04x)\n" , isr ?1 :0 , s->IntrStatus, s->IntrMask)); -qemu_set_irq (s->pci_dev->irq[0 ], (isr !=0 )); +qemu_set_irq (s->dev.irq[0 ], (isr !=0 )); }#define POLYNOMIAL 0x04c11db6
@@ -3121,7 +3121,7 @@ static void rtl8139_save(QEMUFile* f,void* opaque)RTL8139State * s=(RTL8139State *)opaque;unsigned int i; -pci_device_save (s->pci_dev, f); +pci_device_save (&s->dev, f);qemu_put_buffer (f, s->phys,6 );qemu_put_buffer (f, s->mult,8 );
@@ -3215,7 +3215,7 @@ static int rtl8139_load(QEMUFile* f,void* opaque,int version_id)return -EINVAL ;if (version_id >=3 ) { - ret =pci_device_load (s->pci_dev, f); + ret =pci_device_load (&s->dev, f);if (ret <0 )return ret; }
@@ -3323,16 +3323,10 @@ static int rtl8139_load(QEMUFile* f,void* opaque,int version_id)/***********************************************************/ /* PCI RTL8139 definitions */ -typedef struct PCIRTL8139State { -PCIDevice dev; -RTL8139State rtl8139; -}PCIRTL8139State ; -static void rtl8139_mmio_map (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCIRTL8139State *d = (PCIRTL8139State *)pci_dev; -RTL8139State *s = &d->rtl8139; +RTL8139State *s =DO_UPCAST (RTL8139State, dev, pci_dev);cpu_register_physical_memory (addr +0 ,0x100 , s->rtl8139_mmio_io_addr); }
@@ -3340,8 +3334,7 @@ static void rtl8139_mmio_map(PCIDevice *pci_dev, int region_num,static void rtl8139_ioport_map (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCIRTL8139State *d = (PCIRTL8139State *)pci_dev; -RTL8139State *s = &d->rtl8139; +RTL8139State *s =DO_UPCAST (RTL8139State, dev, pci_dev);register_ioport_write (addr,0x100 ,1 , rtl8139_ioport_writeb, s);register_ioport_read ( addr,0x100 ,1 , rtl8139_ioport_readb, s);
@@ -3437,8 +3430,7 @@ static void rtl8139_cleanup(VLANClientState *vc)static int pci_rtl8139_uninit (PCIDevice *dev) { -PCIRTL8139State *d = (PCIRTL8139State *)dev; -RTL8139State *s = &d->rtl8139; +RTL8139State *s =DO_UPCAST (RTL8139State, dev, dev);cpu_unregister_io_memory (s->rtl8139_mmio_io_addr);
@@ -3447,13 +3439,12 @@ static int pci_rtl8139_uninit(PCIDevice *dev)static void pci_rtl8139_init (PCIDevice *dev) { -PCIRTL8139State *d = (PCIRTL8139State *)dev; -RTL8139State *s; +RTL8139State * s =DO_UPCAST (RTL8139State, dev, dev);uint8_t *pci_conf; - d->dev.unregister = pci_rtl8139_uninit; + s->dev.unregister = pci_rtl8139_uninit; - pci_conf = d->dev.config; + pci_conf = s->dev.config;pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_REALTEK );pci_config_set_device_id (pci_conf,PCI_DEVICE_ID_REALTEK_8139 ); pci_conf[0x04 ] =0x05 ;/* command = I/O space, Bus Master */
@@ -3463,19 +3454,16 @@ static void pci_rtl8139_init(PCIDevice *dev) pci_conf[0x3d ] =1 ;/* interrupt pin 0 */ pci_conf[0x34 ] =0xdc ; - s = &d->rtl8139; -/* I/O handler for memory-mapped I/O */ s->rtl8139_mmio_io_addr =cpu_register_io_memory (rtl8139_mmio_read, rtl8139_mmio_write, s); -pci_register_bar (&d->dev,0 ,0x100 , +pci_register_bar (&s->dev,0 ,0x100 ,PCI_ADDRESS_SPACE_IO , rtl8139_ioport_map); -pci_register_bar (&d->dev,1 ,0x100 , +pci_register_bar (&s->dev,1 ,0x100 ,PCI_ADDRESS_SPACE_MEM , rtl8139_mmio_map); - s->pci_dev = (PCIDevice *)d;qdev_get_macaddr (&dev->qdev, s->macaddr);qemu_register_reset (rtl8139_reset, s);rtl8139_reset (s);
@@ -3501,7 +3489,7 @@ static void pci_rtl8139_init(PCIDevice *dev)static PCIDeviceInfo rtl8139_info = { .qdev.name ="rtl8139" , - .qdev.size =sizeof (PCIRTL8139State), + .qdev.size =sizeof (RTL8139State), .init = pci_rtl8139_init, };
Signature · 1 line
1.6.2.5
PATCH 6/26 rtl8139: remove pointless cast from void *
In reply to Juan Quintela--- hw/rtl8139.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/rtl8139.c +2 -2
@@ -3118,7 +3118,7 @@ static uint32_t rtl8139_mmio_readl(void *opaque, target_phys_addr_t addr)static void rtl8139_save (QEMUFile * f,void * opaque) { -RTL8139State * s=(RTL8139State *)opaque; +RTL8139State * s = opaque;unsigned int i;pci_device_save (&s->dev, f);
@@ -3206,7 +3206,7 @@ static void rtl8139_save(QEMUFile* f,void* opaque)static int rtl8139_load (QEMUFile * f,void * opaque,int version_id) { -RTL8139State * s=(RTL8139State *)opaque; +RTL8139State * s = opaque;unsigned int i;int ret;
Signature · 1 line
1.6.2.5
PATCH 7/26 lsi53c895a: remove pointless cast from void *
In reply to Juan Quintela--- hw/lsi53c895a.c | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-)
hw/lsi53c895a.c +19 -19
@@ -635,7 +635,7 @@ static int lsi_queue_tag(LSIState *s, uint32_t tag, uint32_t arg)static void lsi_command_complete (void *opaque,int reason,uint32_t tag,uint32_t arg) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;int out; out = (s->sstat1 &PHASE_MASK ) ==PHASE_DO ;
@@ -1724,14 +1724,14 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)static void lsi_mmio_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;lsi_reg_writeb (s, addr &0xff , val); }static void lsi_mmio_writew (void *opaque,target_phys_addr_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque; addr &=0xff ;lsi_reg_writeb (s, addr, val &0xff );
@@ -1740,7 +1740,7 @@ static void lsi_mmio_writew(void *opaque, target_phys_addr_t addr, uint32_t val)static void lsi_mmio_writel (void *opaque,target_phys_addr_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque; addr &=0xff ;lsi_reg_writeb (s, addr, val &0xff );
@@ -1751,14 +1751,14 @@ static void lsi_mmio_writel(void *opaque, target_phys_addr_t addr, uint32_t val)static uint32_t lsi_mmio_readb (void *opaque,target_phys_addr_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;return lsi_reg_readb (s, addr &0xff ); }static uint32_t lsi_mmio_readw (void *opaque,target_phys_addr_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;uint32_t val; addr &=0xff ;
@@ -1769,7 +1769,7 @@ static uint32_t lsi_mmio_readw(void *opaque, target_phys_addr_t addr)static uint32_t lsi_mmio_readl (void *opaque,target_phys_addr_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;uint32_t val; addr &=0xff ; val =lsi_reg_readb (s, addr);
@@ -1793,7 +1793,7 @@ static CPUWriteMemoryFunc *lsi_mmio_writefn[3] = {static void lsi_ram_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;uint32_t newval;int shift;
@@ -1807,7 +1807,7 @@ static void lsi_ram_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)static void lsi_ram_writew (void *opaque,target_phys_addr_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;uint32_t newval; addr &=0x1fff ;
@@ -1823,7 +1823,7 @@ static void lsi_ram_writew(void *opaque, target_phys_addr_t addr, uint32_t val)static void lsi_ram_writel (void *opaque,target_phys_addr_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque; addr &=0x1fff ; s->script_ram[addr >>2 ] = val;
@@ -1831,7 +1831,7 @@ static void lsi_ram_writel(void *opaque, target_phys_addr_t addr, uint32_t val)static uint32_t lsi_ram_readb (void *opaque,target_phys_addr_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;uint32_t val; addr &=0x1fff ;
@@ -1842,7 +1842,7 @@ static uint32_t lsi_ram_readb(void *opaque, target_phys_addr_t addr)static uint32_t lsi_ram_readw (void *opaque,target_phys_addr_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;uint32_t val; addr &=0x1fff ;
@@ -1854,7 +1854,7 @@ static uint32_t lsi_ram_readw(void *opaque, target_phys_addr_t addr)static uint32_t lsi_ram_readl (void *opaque,target_phys_addr_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque; addr &=0x1fff ;return le32_to_cpu (s->script_ram[addr >>2 ]);
@@ -1874,13 +1874,13 @@ static CPUWriteMemoryFunc *lsi_ram_writefn[3] = {static uint32_t lsi_io_readb (void *opaque,uint32_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;return lsi_reg_readb (s, addr &0xff ); }static uint32_t lsi_io_readw (void *opaque,uint32_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;uint32_t val; addr &=0xff ; val =lsi_reg_readb (s, addr);
@@ -1890,7 +1890,7 @@ static uint32_t lsi_io_readw(void *opaque, uint32_t addr)static uint32_t lsi_io_readl (void *opaque,uint32_t addr) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;uint32_t val; addr &=0xff ; val =lsi_reg_readb (s, addr);
@@ -1902,13 +1902,13 @@ static uint32_t lsi_io_readl(void *opaque, uint32_t addr)static void lsi_io_writeb (void *opaque,uint32_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque;lsi_reg_writeb (s, addr &0xff , val); }static void lsi_io_writew (void *opaque,uint32_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque; addr &=0xff ;lsi_reg_writeb (s, addr, val &0xff );lsi_reg_writeb (s, addr +1 , (val >>8 ) &0xff );
@@ -1916,7 +1916,7 @@ static void lsi_io_writew(void *opaque, uint32_t addr, uint32_t val)static void lsi_io_writel (void *opaque,uint32_t addr,uint32_t val) { -LSIState *s = (LSIState *)opaque; +LSIState *s = opaque; addr &=0xff ;lsi_reg_writeb (s, addr, val &0xff );lsi_reg_writeb (s, addr +1 , (val >>8 ) &0xff );
Signature · 1 line
1.6.2.5
PATCH 8/26 lsi53c895a: use DO_UPCAST to cast from PCIDevice
In reply to Juan Quintela--- hw/lsi53c895a.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
hw/lsi53c895a.c +5 -5
@@ -1927,7 +1927,7 @@ static void lsi_io_writel(void *opaque, uint32_t addr, uint32_t val)static void lsi_io_mapfunc (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -LSIState *s = (LSIState *)pci_dev; +LSIState *s =DO_UPCAST (LSIState, pci_dev, pci_dev);DPRINTF ("Mapping IO at %08x\n" , addr);
@@ -1942,7 +1942,7 @@ static void lsi_io_mapfunc(PCIDevice *pci_dev, int region_num,static void lsi_ram_mapfunc (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -LSIState *s = (LSIState *)pci_dev; +LSIState *s =DO_UPCAST (LSIState, pci_dev, pci_dev);DPRINTF ("Mapping ram at %08x\n" , addr); s->script_ram_base = addr;
@@ -1952,7 +1952,7 @@ static void lsi_ram_mapfunc(PCIDevice *pci_dev, int region_num,static void lsi_mmio_mapfunc (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -LSIState *s = (LSIState *)pci_dev; +LSIState *s =DO_UPCAST (LSIState, pci_dev, pci_dev);DPRINTF ("Mapping registers at %08x\n" , addr);cpu_register_physical_memory (addr +0 ,0x400 , s->mmio_io_addr);
@@ -2153,7 +2153,7 @@ static int lsi_scsi_load(QEMUFile *f, void *opaque, int version_id)static int lsi_scsi_uninit (PCIDevice *d) { -LSIState *s = (LSIState *) d; +LSIState *s =DO_UPCAST (LSIState, pci_dev, d);cpu_unregister_io_memory (s->mmio_io_addr);cpu_unregister_io_memory (s->ram_io_addr);
@@ -2165,7 +2165,7 @@ static int lsi_scsi_uninit(PCIDevice *d)static void lsi_scsi_init (PCIDevice *dev) { -LSIState *s = (LSIState *)dev; +LSIState *s =DO_UPCAST (LSIState, pci_dev, dev);uint8_t *pci_conf; pci_conf = s->pci_dev.config;
Signature · 1 line
1.6.2.5
PATCH 9/26 lsi53c895a: rename PCIDevice field from pci_dev to dev (consistence)
In reply to Juan Quintela--- hw/lsi53c895a.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
hw/lsi53c895a.c +12 -12
@@ -175,7 +175,7 @@ typedef struct { } lsi_queue; typedef struct { - PCIDevice pci_dev; + PCIDevice dev; int mmio_io_addr; int ram_io_addr; uint32_t script_ram_base;
@@ -410,7 +410,7 @@ static void lsi_update_irq(LSIState *s) level, s->dstat, s->sist1, s->sist0); last_level = level; } -qemu_set_irq (s->pci_dev.irq[0 ], level); +qemu_set_irq (s->dev.irq[0 ], level); }/* Stop SCRIPTS execution and raise a SCSI interrupt. */
@@ -1927,7 +1927,7 @@ static void lsi_io_writel(void *opaque, uint32_t addr, uint32_t val)static void lsi_io_mapfunc (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -LSIState *s =DO_UPCAST (LSIState, pci_dev, pci_dev); +LSIState *s =DO_UPCAST (LSIState, dev, pci_dev);DPRINTF ("Mapping IO at %08x\n" , addr);
@@ -1942,7 +1942,7 @@ static void lsi_io_mapfunc(PCIDevice *pci_dev, int region_num,static void lsi_ram_mapfunc (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -LSIState *s =DO_UPCAST (LSIState, pci_dev, pci_dev); +LSIState *s =DO_UPCAST (LSIState, dev, pci_dev);DPRINTF ("Mapping ram at %08x\n" , addr); s->script_ram_base = addr;
@@ -1952,7 +1952,7 @@ static void lsi_ram_mapfunc(PCIDevice *pci_dev, int region_num,static void lsi_mmio_mapfunc (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -LSIState *s =DO_UPCAST (LSIState, pci_dev, pci_dev); +LSIState *s =DO_UPCAST (LSIState, dev, pci_dev);DPRINTF ("Mapping registers at %08x\n" , addr);cpu_register_physical_memory (addr +0 ,0x400 , s->mmio_io_addr);
@@ -1980,7 +1980,7 @@ void lsi_scsi_attach(DeviceState *host, BlockDriverState *bd, int id) s->scsi_dev[id] =scsi_generic_init (bd,1 , lsi_command_complete, s);if (s->scsi_dev[id] ==NULL ) s->scsi_dev[id] =scsi_disk_init (bd,1 , lsi_command_complete, s); - bd->private = &s->pci_dev; + bd->private = &s->dev; }static void lsi_scsi_save (QEMUFile *f,void *opaque)
@@ -1991,7 +1991,7 @@ static void lsi_scsi_save(QEMUFile *f, void *opaque)assert (s->current_dma_len ==0 );assert (s->active_commands ==0 ); -pci_device_save (&s->pci_dev, f); +pci_device_save (&s->dev, f);qemu_put_sbe32s (f, &s->carry);qemu_put_sbe32s (f, &s->sense);
@@ -2074,7 +2074,7 @@ static int lsi_scsi_load(QEMUFile *f, void *opaque, int version_id)return -EINVAL ; } -if ((ret =pci_device_load (&s->pci_dev, f)) <0 ) +if ((ret =pci_device_load (&s->dev, f)) <0 )return ret;qemu_get_sbe32s (f, &s->carry);
@@ -2153,7 +2153,7 @@ static int lsi_scsi_load(QEMUFile *f, void *opaque, int version_id)static int lsi_scsi_uninit (PCIDevice *d) { -LSIState *s =DO_UPCAST (LSIState, pci_dev, d); +LSIState *s =DO_UPCAST (LSIState, dev, d);cpu_unregister_io_memory (s->mmio_io_addr);cpu_unregister_io_memory (s->ram_io_addr);
@@ -2165,10 +2165,10 @@ static int lsi_scsi_uninit(PCIDevice *d)static void lsi_scsi_init (PCIDevice *dev) { -LSIState *s =DO_UPCAST (LSIState, pci_dev, dev); +LSIState *s =DO_UPCAST (LSIState, dev, dev);uint8_t *pci_conf; - pci_conf = s->pci_dev.config; + pci_conf = s->dev.config;/* PCI Vendor ID (word) */ pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_LSI_LOGIC );
@@ -2198,7 +2198,7 @@ static void lsi_scsi_init(PCIDevice *dev) s->queue =qemu_malloc (sizeof (lsi_queue)); s->queue_len =1 ; s->active_commands =0 ; - s->pci_dev.unregister = lsi_scsi_uninit; + s->dev.unregister = lsi_scsi_uninit;lsi_soft_reset (s);
Signature · 1 line
1.6.2.5
PATCH 10/26 lsi53c895a: LSIState is a DeviceHost
In reply to Juan QuintelaGo figure.
--- hw/lsi53c895a.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/lsi53c895a.c +1 -1
@@ -1960,7 +1960,7 @@ static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num,void lsi_scsi_attach (DeviceState *host,BlockDriverState *bd,int id) { -LSIState *s = (LSIState *)host; +LSIState *s =DO_UPCAST (LSIState, dev.qdev, host);if (id <0 ) {for (id =0 ; id <LSI_MAX_DEVS ; id++) {
Signature · 1 line
1.6.2.5
PATCH 11/26 Introduce vga_common_reset() to be able to typcheck vga_reset()
In reply to Juan Quintela--- hw/cirrus_vga.c | 2 +- hw/vga.c | 10 +++++++--- hw/vga_int.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-)
hw/cirrus_vga.c +1 -1
@@ -3125,7 +3125,7 @@ static void cirrus_reset(void *opaque) {CirrusVGAState *s = opaque; -vga_reset (s); +vga_common_reset (&s->vga);unmap_linear_vram (s); s->vga.sr[0x06 ] =0x0f ;if (s->device_id ==CIRRUS_ID_CLGD5446 ) {
hw/vga.c +7 -3
@@ -1873,10 +1873,8 @@ static void vga_invalidate_display(void *opaque) s->full_update =1 ; } -void vga_reset (void *opaque) +void vga_common_reset (VGACommonState *s) { -VGAState *s = (VGAState *) opaque; - s->lfb_addr =0 ; s->lfb_end =0 ; s->map_addr =0 ;
@@ -1942,6 +1940,12 @@ void vga_reset(void *opaque) } } +static void vga_reset (void *opaque) +{ +VGAState *s = (VGAState *) opaque; +vga_common_reset (s); +} +#define TEXTMODE_X (x) ((x) % width)#define TEXTMODE_Y (x) ((x) / width)#define VMEM2CHTYPE (v) ((v & 0xff0007ff) | \
hw/vga_int.h +1 -1
@@ -192,7 +192,7 @@ static inline int c6_to_8(int v)void vga_common_init (VGAState *s,int vga_ram_size);void vga_init (VGAState *s); -void vga_reset (void *s); +void vga_common_reset (VGACommonState *s);void vga_dirty_log_start (VGAState *s);
Signature · 1 line
1.6.2.5
PATCH 12/26 vga: Rename vga_state -> vga
In reply to Juan Quintela--- hw/vga.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
hw/vga.c +6 -6
@@ -2227,7 +2227,7 @@ static int vga_load(QEMUFile *f, void *opaque, int version_id)typedef struct PCIVGAState {PCIDevice dev; -VGAState vga_state; +VGAState vga; }PCIVGAState ;void vga_dirty_log_start (VGAState *s)
@@ -2245,7 +2245,7 @@ static void vga_map(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) { PCIVGAState *d = (PCIVGAState *)pci_dev; -VGAState *s = &d->vga_state; +VGAState *s = &d->vga;if (region_num ==PCI_ROM_SLOT ) {cpu_register_physical_memory (addr, s->bios_size, s->bios_offset); }else {
@@ -2479,7 +2479,7 @@ static void pci_vga_write_config(PCIDevice *d, uint32_t address, uint32_t val, int len) { PCIVGAState *pvs = container_of(d, PCIVGAState, dev); -VGAState *s = &pvs->vga_state; +VGAState *s = &pvs->vga;pci_default_write_config (d, address, val, len);if (s->map_addr && pvs->dev.io_regions[0 ].addr ==-1 )
@@ -2489,7 +2489,7 @@ static void pci_vga_write_config(PCIDevice *d,static void pci_vga_initfn (PCIDevice *dev) {PCIVGAState *d =DO_UPCAST (PCIVGAState, dev, dev); -VGAState *s = &d->vga_state; +VGAState *s = &d->vga;uint8_t *pci_conf = d->dev.config;// vga + console init
@@ -2539,8 +2539,8 @@ static PCIDeviceInfo vga_info = { .init = pci_vga_initfn, .config_write = pci_vga_write_config, .qdev.props = (Property []) { -DEFINE_PROP_HEX32 ("bios-offset" , PCIVGAState, vga_state.bios_offset,0 ), -DEFINE_PROP_HEX32 ("bios-size" , PCIVGAState, vga_state.bios_size,0 ), +DEFINE_PROP_HEX32 ("bios-offset" , PCIVGAState, vga.bios_offset,0 ), +DEFINE_PROP_HEX32 ("bios-size" , PCIVGAState, vga.bios_size,0 ),DEFINE_PROP_END_OF_LIST (), } };
Signature · 1 line
1.6.2.5
PATCH 13/26 Everything outside of vga.c should use VGACommonState
In reply to Juan Quintela--- hw/cirrus_vga.c | 10 +++++----- hw/vga.c | 4 +++- hw/vga_int.h | 10 ++++------ hw/vmware_vga.c | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-)
hw/cirrus_vga.c +5 -5
@@ -1078,7 +1078,7 @@ static void cirrus_write_bitblt(CirrusVGAState * s, unsigned reg_value)* ***************************************/ -static void cirrus_get_offsets (VGAState *s1, +static void cirrus_get_offsets (VGACommonState *s1,uint32_t *pline_offset,uint32_t *pstart_addr,uint32_t *pline_compare)
@@ -1126,7 +1126,7 @@ static uint32_t cirrus_get_bpp16_depth(CirrusVGAState * s)return ret; } -static int cirrus_get_bpp (VGAState *s1) +static int cirrus_get_bpp (VGACommonState *s1) {CirrusVGAState * s =container_of (s1, CirrusVGAState, vga);uint32_t ret =8 ;
@@ -1164,7 +1164,7 @@ static int cirrus_get_bpp(VGAState *s1)return ret; } -static void cirrus_get_resolution (VGAState *s,int *pwidth,int *pheight) +static void cirrus_get_resolution (VGACommonState *s,int *pwidth,int *pheight) {int width, height;
@@ -2234,7 +2234,7 @@ static inline void cirrus_cursor_compute_yrange(CirrusVGAState *s)/* NOTE: we do not currently handle the cursor bitmap change, so we update the cursor only if it moves. */ -static void cirrus_cursor_invalidate (VGAState *s1) +static void cirrus_cursor_invalidate (VGACommonState *s1) {CirrusVGAState *s =container_of (s1, CirrusVGAState, vga);int size;
@@ -2263,7 +2263,7 @@ static void cirrus_cursor_invalidate(VGAState *s1) } } -static void cirrus_cursor_draw_line (VGAState *s1,uint8_t *d1,int scr_y) +static void cirrus_cursor_draw_line (VGACommonState *s1,uint8_t *d1,int scr_y) {CirrusVGAState *s =container_of (s1, CirrusVGAState, vga);int w, h, bpp, x1, x2, poffset;
hw/vga.c +3 -1
@@ -149,6 +149,8 @@ static uint32_t expand4[256];static uint16_t expand2[256 ];static uint8_t expand4to8[16 ]; +typedef VGACommonState VGAState ; +static void vga_screen_dump (void *opaque,const char *filename);static char *screen_dump_filename;static DisplayChangeListener *screen_dump_dcl;
@@ -2256,7 +2258,7 @@ static void vga_map(PCIDevice *pci_dev, int region_num, } } -void vga_common_init (VGAState *s,int vga_ram_size) +void vga_common_init (VGACommonState *s,int vga_ram_size) {int i, j, v, b;
hw/vga_int.h +4 -6
@@ -180,8 +180,6 @@ typedef struct VGACommonState {union vga_retrace retrace_info; } VGACommonState; -typedef VGACommonState VGAState ; -static inline int c6_to_8 (int v) {int b;
@@ -190,15 +188,15 @@ static inline int c6_to_8(int v)return (v <<2 ) | (b <<1 ) | b; } -void vga_common_init (VGAState *s,int vga_ram_size); -void vga_init (VGAState *s); +void vga_common_init (VGACommonState *s,int vga_ram_size); +void vga_init (VGACommonState *s);void vga_common_reset (VGACommonState *s); -void vga_dirty_log_start (VGAState *s); +void vga_dirty_log_start (VGACommonState *s);uint32_t vga_mem_readb (void *opaque,target_phys_addr_t addr);void vga_mem_writeb (void *opaque,target_phys_addr_t addr,uint32_t val); -void vga_invalidate_scanlines (VGAState *s,int y1,int y2); +void vga_invalidate_scanlines (VGACommonState *s,int y1,int y2);int ppm_save (const char *filename,struct DisplaySurface *ds); void vga_draw_cursor_line_8(uint8_t *d1, const uint8_t *src1,
hw/vmware_vga.c +2 -2
@@ -1129,8 +1129,8 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)vmsvga_reset (s);#ifdef EMBED_STDVGA -vga_common_init ((VGAState *) s, vga_ram_size); -vga_init ((VGAState *) s); +vga_common_init (&s->vga, vga_ram_size); +vga_init (&s->vga);#else s->vram_size = vga_ram_size; s->vram_offset =qemu_ram_alloc (vga_ram_size);
Signature · 1 line
1.6.2.5
PATCH 14/26 usb-ohci: Change casts to DO_UPCAST() for OHCIPCIState
In reply to Juan Quintela--- hw/usb-ohci.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
hw/usb-ohci.c +4 -3
@@ -1706,7 +1706,7 @@ typedef struct {static void ohci_mapfunc (PCIDevice *pci_dev,int i,uint32_t addr,uint32_t size,int type) { -OHCIPCIState *ohci = (OHCIPCIState *)pci_dev; +OHCIPCIState *ohci =DO_UPCAST (OHCIPCIState, pci_dev, pci_dev);cpu_register_physical_memory (addr, size, ohci->state.mem); }
@@ -1714,8 +1714,9 @@ void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn) {OHCIPCIState *ohci; - ohci = (OHCIPCIState *)pci_register_device (bus,"OHCI USB" ,sizeof (*ohci), - devfn,NULL ,NULL ); + ohci =DO_UPCAST (OHCIPCIState, pci_dev, +pci_register_device (bus,"OHCI USB" ,sizeof (*ohci), + devfn,NULL ,NULL ));if (ohci ==NULL ) {fprintf (stderr,"usb-ohci: Failed to register PCI device\n" );return ;
Signature · 1 line
1.6.2.5
PATCH 15/26 ne2000: remove casts from void *
In reply to Juan Quintela--- hw/ne2000.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/ne2000.c +2 -2
@@ -650,7 +650,7 @@ static uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr)static void ne2000_save (QEMUFile * f,void * opaque) { -NE2000State * s=(NE2000State *)opaque; +NE2000State * s = opaque;uint32_t tmp;if (s->pci_dev)
@@ -681,7 +681,7 @@ static void ne2000_save(QEMUFile* f,void* opaque)static int ne2000_load (QEMUFile * f,void * opaque,int version_id) { -NE2000State * s=(NE2000State *)opaque; +NE2000State * s = opaque;int ret;uint32_t tmp;
Signature · 1 line
1.6.2.5
PATCH 16/26 ne2000: pci_dev has this very value with the right type
In reply to Juan Quintela--- hw/ne2000.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/ne2000.c +1 -1
@@ -820,7 +820,7 @@ static void pci_ne2000_init(PCIDevice *pci_dev) PCI_ADDRESS_SPACE_IO, ne2000_map); s = &d->ne2000; s->irq = d->dev.irq[0 ]; - s->pci_dev = (PCIDevice *)d; + s->pci_dev = pci_dev;qdev_get_macaddr (&d->dev.qdev, s->macaddr);ne2000_reset (s); s->vc = qdev_get_vlan_client(&d->dev.qdev,
Signature · 1 line
1.6.2.5
PATCH 17/26 ne2000: Change casts to DO_UPCAST() for PCINE2000State
In reply to Juan Quintela--- hw/ne2000.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/ne2000.c +2 -2
@@ -779,7 +779,7 @@ typedef struct PCINE2000State {static void ne2000_map (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCINE2000State *d = (PCINE2000State *)pci_dev; +PCINE2000State *d =DO_UPCAST (PCINE2000State, dev, pci_dev);NE2000State *s = &d->ne2000;register_ioport_write (addr,16 ,1 , ne2000_ioport_write, s);
@@ -805,7 +805,7 @@ static void ne2000_cleanup(VLANClientState *vc)static void pci_ne2000_init (PCIDevice *pci_dev) { -PCINE2000State *d = (PCINE2000State *)pci_dev; +PCINE2000State *d =DO_UPCAST (PCINE2000State, dev, pci_dev);NE2000State *s;uint8_t *pci_conf;
Signature · 1 line
1.6.2.5
PATCH 18/26 We need PCINE2000State for save/load functions
In reply to Juan Quintela--- hw/ne2000.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
hw/ne2000.c +5 -5
@@ -147,6 +147,11 @@ typedef struct NE2000State {uint8_t mem[NE2000_MEM_SIZE ]; } NE2000State; +typedef struct PCINE2000State { +PCIDevice dev; +NE2000State ne2000; +}PCINE2000State ; +static void ne2000_reset (NE2000State *s) {int i;
@@ -771,11 +776,6 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)/***********************************************************/ /* PCI NE2000 definitions */ -typedef struct PCINE2000State { -PCIDevice dev; -NE2000State ne2000; -}PCINE2000State ; -static void ne2000_map (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) {
Signature · 1 line
1.6.2.5
PATCH 19/26 Add pci_ne2000_{save/load} functions, then remove pci_dev NE2000State field
In reply to Juan Quintela--- hw/ne2000.c | 43 ++++++++++++++++++++++++++++--------------- 1 files changed, 28 insertions(+), 15 deletions(-)
hw/ne2000.c +28 -15
@@ -141,7 +141,6 @@ typedef struct NE2000State {uint8_t mult[8 ];/* multicast mask array */ qemu_irq irq;int isa_io_base; -PCIDevice *pci_dev;VLANClientState *vc;uint8_t macaddr[6 ];uint8_t mem[NE2000_MEM_SIZE ];
@@ -653,14 +652,11 @@ static uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr)return 0 ; } -static void ne2000_save (QEMUFile * f,void * opaque) +static void ne2000_save (QEMUFile * f,void * opaque) {NE2000State * s = opaque;uint32_t tmp; -if (s->pci_dev) -pci_device_save (s->pci_dev, f); -qemu_put_8s (f, &s->rxcr);qemu_put_8s (f, &s->cmd);
@@ -684,21 +680,14 @@ static void ne2000_save(QEMUFile* f,void* opaque)qemu_put_buffer (f, s->mem,NE2000_MEM_SIZE ); } -static int ne2000_load (QEMUFile * f,void * opaque,int version_id) +static int ne2000_load (QEMUFile * f,void * opaque,int version_id) {NE2000State * s = opaque; -int ret;uint32_t tmp;if (version_id >3 )return -EINVAL ; -if (s->pci_dev && version_id >=3 ) { - ret =pci_device_load (s->pci_dev, f); -if (ret <0 ) -return ret; - } -if (version_id >=2 ) {qemu_get_8s (f, &s->rxcr); }else {
@@ -727,6 +716,31 @@ static int ne2000_load(QEMUFile* f,void* opaque,int version_id)return 0 ; } +static void pci_ne2000_save (QEMUFile * f,void * opaque) +{ +PCINE2000State * s = opaque; + +pci_device_save (&s->dev, f); +ne2000_save (f, &s->ne2000); +} + +static int pci_ne2000_load (QEMUFile * f,void * opaque,int version_id) +{ +PCINE2000State * s = opaque; +int ret; + +if (version_id >3 ) +return -EINVAL ; + +if (version_id >=3 ) { + ret =pci_device_load (&s->dev, f); +if (ret <0 ) +return ret; + } + +return ne2000_load (f, &s->ne2000, version_id); +} +static void isa_ne2000_cleanup (VLANClientState *vc) {NE2000State *s = vc->opaque;
@@ -820,7 +834,6 @@ static void pci_ne2000_init(PCIDevice *pci_dev) PCI_ADDRESS_SPACE_IO, ne2000_map); s = &d->ne2000; s->irq = d->dev.irq[0 ]; - s->pci_dev = pci_dev;qdev_get_macaddr (&d->dev.qdev, s->macaddr);ne2000_reset (s); s->vc = qdev_get_vlan_client(&d->dev.qdev,
@@ -829,7 +842,7 @@ static void pci_ne2000_init(PCIDevice *pci_dev)qemu_format_nic_info_str (s->vc, s->macaddr); -register_savevm ("ne2000" ,-1 ,3 , ne2000_save, ne2000_load, s); +register_savevm ("ne2000" ,-1 ,3 , pci_ne2000_save, pci_ne2000_load, d); }static PCIDeviceInfo ne2000_info = {
Signature · 1 line
1.6.2.5
PATCH 20/26 cirrus_vga: remove pointless cast from void *
In reply to Juan Quintela--- hw/cirrus_vga.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
hw/cirrus_vga.c +5 -5
@@ -2346,7 +2346,7 @@ static void cirrus_cursor_draw_line(VGACommonState *s1, uint8_t *d1, int scr_y)static uint32_t cirrus_linear_readb (void *opaque,target_phys_addr_t addr) { -CirrusVGAState *s = (CirrusVGAState *) opaque; +CirrusVGAState *s = opaque;uint32_t ret; addr &= s->cirrus_addr_mask;
@@ -2405,7 +2405,7 @@ static uint32_t cirrus_linear_readl(void *opaque, target_phys_addr_t addr)static void cirrus_linear_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) { -CirrusVGAState *s = (CirrusVGAState *) opaque; +CirrusVGAState *s = opaque;unsigned mode; addr &= s->cirrus_addr_mask;
@@ -2533,7 +2533,7 @@ static uint32_t cirrus_linear_bitblt_readl(void *opaque, target_phys_addr_t addrstatic void cirrus_linear_bitblt_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) { -CirrusVGAState *s = (CirrusVGAState *) opaque; +CirrusVGAState *s = opaque;if (s->cirrus_srcptr != s->cirrus_srcptr_end) {/* bitblt */
@@ -2919,7 +2919,7 @@ static void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)static uint32_t cirrus_mmio_readb (void *opaque,target_phys_addr_t addr) { -CirrusVGAState *s = (CirrusVGAState *) opaque; +CirrusVGAState *s = opaque; addr &=CIRRUS_PNPMMIO_SIZE -1 ;
@@ -2963,7 +2963,7 @@ static uint32_t cirrus_mmio_readl(void *opaque, target_phys_addr_t addr)static void cirrus_mmio_writeb (void *opaque,target_phys_addr_t addr,uint32_t val) { -CirrusVGAState *s = (CirrusVGAState *) opaque; +CirrusVGAState *s = opaque; addr &=CIRRUS_PNPMMIO_SIZE -1 ;
Signature · 1 line
1.6.2.5
PATCH 21/26 cirrus_vga: Change casts to DO_UPCAST() for PCICirrusVGAState
In reply to Juan Quintela--- hw/cirrus_vga.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
hw/cirrus_vga.c +5 -5
@@ -3263,7 +3263,7 @@ void isa_cirrus_vga_init(void)static void cirrus_pci_lfb_map (PCIDevice *d,int region_num,uint32_t addr,uint32_t size,int type) { -CirrusVGAState *s = &((PCICirrusVGAState *)d)->cirrus_vga; +CirrusVGAState *s = &DO_UPCAST (PCICirrusVGAState, dev, d)->cirrus_vga;/* XXX: add byte swapping apertures */ cpu_register_physical_memory(addr, s->vga.vram_size,
@@ -3284,7 +3284,7 @@ static void cirrus_pci_lfb_map(PCIDevice *d, int region_num,static void cirrus_pci_mmio_map (PCIDevice *d,int region_num,uint32_t addr,uint32_t size,int type) { -CirrusVGAState *s = &((PCICirrusVGAState *)d)->cirrus_vga; +CirrusVGAState *s = &DO_UPCAST (PCICirrusVGAState, dev, d)->cirrus_vga;cpu_register_physical_memory (addr,CIRRUS_PNPMMIO_SIZE , s->cirrus_mmio_io_addr);
@@ -3293,11 +3293,11 @@ static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,static void pci_cirrus_write_config (PCIDevice *d,uint32_t address,uint32_t val,int len) { -PCICirrusVGAState *pvs =container_of (d, PCICirrusVGAState, dev); +PCICirrusVGAState *pvs =DO_UPCAST (PCICirrusVGAState, dev, d);CirrusVGAState *s = &pvs->cirrus_vga;pci_default_write_config (d, address, val, len); -if (s->vga.map_addr && pvs->dev.io_regions[0 ].addr ==-1 ) +if (s->vga.map_addr && d->io_regions[0 ].addr ==-1 ) s->vga.map_addr =0 ;cirrus_update_memory_access (s); }
@@ -3312,7 +3312,7 @@ static void pci_cirrus_vga_initfn(PCIDevice *dev)/* setup VGA */ vga_common_init (&s->vga,VGA_RAM_SIZE );cirrus_init_common (s, device_id,1 ); - s->vga.pci_dev = (PCIDevice *)d; + s->vga.pci_dev = dev; s->vga.ds =graphic_console_init (s->vga.update, s->vga.invalidate, s->vga.screen_dump, s->vga.text_update, &s->vga);
Signature · 1 line
1.6.2.5
PATCH 22/26 Add pci_cirrus_vga_{save/load} functions, then remove vga.pci_dev use
In reply to Juan Quintela--- hw/cirrus_vga.c | 39 +++++++++++++++++++++++++++------------ 1 files changed, 27 insertions(+), 12 deletions(-)
hw/cirrus_vga.c +27 -12
@@ -3021,9 +3021,6 @@ static void cirrus_vga_save(QEMUFile *f, void *opaque) {CirrusVGAState *s = opaque; -if (s->vga.pci_dev) -pci_device_save (s->vga.pci_dev, f); -qemu_put_be32s (f, &s->vga.latch);qemu_put_8s (f, &s->vga.sr_index);qemu_put_buffer (f, s->vga.sr,256 );
@@ -3062,17 +3059,10 @@ static void cirrus_vga_save(QEMUFile *f, void *opaque)static int cirrus_vga_load (QEMUFile *f,void *opaque,int version_id) {CirrusVGAState *s = opaque; -int ret;if (version_id >2 )return -EINVAL ; -if (s->vga.pci_dev && version_id >=2 ) { - ret =pci_device_load (s->vga.pci_dev, f); -if (ret <0 ) -return ret; - } -qemu_get_be32s (f, &s->vga.latch);qemu_get_8s (f, &s->vga.sr_index);qemu_get_buffer (f, s->vga.sr,256 );
@@ -3115,6 +3105,31 @@ static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } +static void pci_cirrus_vga_save (QEMUFile *f,void *opaque) +{ +PCICirrusVGAState *s = opaque; + +pci_device_save (&s->dev, f); +cirrus_vga_save (f, &s->cirrus_vga); +} + +static int pci_cirrus_vga_load (QEMUFile *f,void *opaque,int version_id) +{ +PCICirrusVGAState *s = opaque; +int ret; + +if (version_id >2 ) +return -EINVAL ; + +if (version_id >=2 ) { + ret =pci_device_load (&s->dev, f); +if (ret <0 ) +return ret; + } + +return cirrus_vga_load (f, &s->cirrus_vga, version_id); +} +/*************************************** * * initialize
@@ -3231,7 +3246,6 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci)qemu_register_reset (cirrus_reset, s);cirrus_reset (s); -register_savevm ("cirrus_vga" ,0 ,2 , cirrus_vga_save, cirrus_vga_load, s); }/***************************************
@@ -3251,6 +3265,7 @@ void isa_cirrus_vga_init(void) s->vga.ds =graphic_console_init (s->vga.update, s->vga.invalidate, s->vga.screen_dump, s->vga.text_update, &s->vga); +register_savevm ("cirrus_vga" ,0 ,2 , cirrus_vga_save, cirrus_vga_load, s);/* XXX ISA-LFB support */ }
@@ -3312,7 +3327,6 @@ static void pci_cirrus_vga_initfn(PCIDevice *dev)/* setup VGA */ vga_common_init (&s->vga,VGA_RAM_SIZE );cirrus_init_common (s, device_id,1 ); - s->vga.pci_dev = dev; s->vga.ds =graphic_console_init (s->vga.update, s->vga.invalidate, s->vga.screen_dump, s->vga.text_update, &s->vga);
@@ -3334,6 +3348,7 @@ static void pci_cirrus_vga_initfn(PCIDevice *dev)pci_register_bar ((PCIDevice *)d,1 ,CIRRUS_PNPMMIO_SIZE ,PCI_ADDRESS_SPACE_MEM , cirrus_pci_mmio_map); } +register_savevm ("cirrus_vga" ,0 ,2 , pci_cirrus_vga_save, pci_cirrus_vga_load, d);/* XXX: ROM BIOS */ }
Signature · 1 line
1.6.2.5
PATCH 23/26 pcnet: Change casts to DO_UPCAST() for PCIPCNetState
In reply to Juan Quintela--- hw/pcnet.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
hw/pcnet.c +4 -4
@@ -1764,7 +1764,7 @@ static uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr)static void pcnet_ioport_map (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCNetState *d = &((PCIPCNetState *)pci_dev)->state; +PCNetState *d = &DO_UPCAST (PCIPCNetState, pci_dev, pci_dev)->state;#ifdef PCNET_DEBUG_IO printf ("pcnet_ioport_map addr=0x%04x size=0x%04x\n" , addr, size);
@@ -1978,7 +1978,7 @@ static CPUReadMemoryFunc *pcnet_mmio_read[] = {static void pcnet_mmio_map (PCIDevice *pci_dev,int region_num,uint32_t addr,uint32_t size,int type) { -PCIPCNetState *d = (PCIPCNetState *)pci_dev; +PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, pci_dev);#ifdef PCNET_DEBUG_IO printf ("pcnet_mmio_map addr=0x%08x 0x%08x\n" , addr, size);
@@ -2008,7 +2008,7 @@ static void pci_pcnet_cleanup(VLANClientState *vc)static int pci_pcnet_uninit (PCIDevice *dev) { -PCIPCNetState *d = (PCIPCNetState *)dev; +PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, dev);cpu_unregister_io_memory (d->state.mmio_index);
@@ -2017,7 +2017,7 @@ static int pci_pcnet_uninit(PCIDevice *dev)static void pci_pcnet_init (PCIDevice *pci_dev) { -PCIPCNetState *d = (PCIPCNetState *)pci_dev; +PCIPCNetState *d =DO_UPCAST (PCIPCNetState, pci_dev, pci_dev);PCNetState *s = &d->state;uint8_t *pci_conf;
Signature · 1 line
1.6.2.5
PATCH 24/26 pcnet: remove useless casts This are casts to the very type of the function
In reply to Juan Quintela--- hw/pcnet.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
hw/pcnet.c +6 -6
@@ -1964,15 +1964,15 @@ static void pcnet_common_init(DeviceState *dev, PCNetState *s,/* PCI interface */ static CPUWriteMemoryFunc *pcnet_mmio_write[] = { - (CPUWriteMemoryFunc *)&pcnet_mmio_writeb, - (CPUWriteMemoryFunc *)&pcnet_mmio_writew, - (CPUWriteMemoryFunc *)&pcnet_mmio_writel + &pcnet_mmio_writeb, + &pcnet_mmio_writew, + &pcnet_mmio_writel };static CPUReadMemoryFunc *pcnet_mmio_read[] = { - (CPUReadMemoryFunc *)&pcnet_mmio_readb, - (CPUReadMemoryFunc *)&pcnet_mmio_readw, - (CPUReadMemoryFunc *)&pcnet_mmio_readl + &pcnet_mmio_readb, + &pcnet_mmio_readw, + &pcnet_mmio_readl }; static void pcnet_mmio_map(PCIDevice *pci_dev, int region_num,
Signature · 1 line
1.6.2.5
PATCH 25/26 pcnet: Add pci_pcnet_{save/load} functions, then remove PCNetState pci_dev field
In reply to Juan Quintela--- hw/pcnet.c | 39 ++++++++++++++++++++++++++------------- 1 files changed, 26 insertions(+), 13 deletions(-)
hw/pcnet.c +26 -13
@@ -60,7 +60,6 @@typedef struct PCNetState_st PCNetState ;struct PCNetState_st { -PCIDevice *pci_dev;VLANClientState *vc;uint8_t macaddr[6 ];QEMUTimer *poll_timer;
@@ -1885,9 +1884,6 @@ static void pcnet_save(QEMUFile *f, void *opaque)PCNetState *s = opaque;unsigned int i; -if (s->pci_dev) -pci_device_save (s->pci_dev, f); -qemu_put_sbe32 (f, s->rap);qemu_put_sbe32 (f, s->isr);qemu_put_sbe32 (f, s->lnkst);
@@ -1909,17 +1905,11 @@ static void pcnet_save(QEMUFile *f, void *opaque)static int pcnet_load (QEMUFile *f,void *opaque,int version_id) {PCNetState *s = opaque; -int i, ret; +int i;if (version_id !=2 )return -EINVAL ; -if (s->pci_dev) { - ret =pci_device_load (s->pci_dev, f); -if (ret <0 ) -return ret; - } -qemu_get_sbe32s (f, &s->rap);qemu_get_sbe32s (f, &s->isr);qemu_get_sbe32s (f, &s->lnkst);
@@ -1940,6 +1930,29 @@ static int pcnet_load(QEMUFile *f, void *opaque, int version_id)return 0 ; } +static void pci_pcnet_save (QEMUFile *f,void *opaque) +{ +PCIPCNetState *s = opaque; + +pci_device_save (&s->pci_dev, f); +pcnet_save (f, &s->state); +} + +static int pci_pcnet_load (QEMUFile *f,void *opaque,int version_id) +{ +PCIPCNetState *s = opaque; +int ret; + +if (version_id !=2 ) +return -EINVAL ; + + ret =pci_device_load (&s->pci_dev, f); +if (ret <0 ) +return ret; + +return pcnet_load (f, &s->state, version_id); +} +static void pcnet_common_cleanup (PCNetState *d) {unregister_savevm ("pcnet" , d);
@@ -1958,7 +1971,6 @@ static void pcnet_common_init(DeviceState *dev, PCNetState *s, pcnet_can_receive, pcnet_receive,NULL , cleanup, s);pcnet_h_reset (s); -register_savevm ("pcnet" ,-1 ,2 , pcnet_save, pcnet_load, s); }/* PCI interface */
@@ -2059,9 +2071,9 @@ static void pci_pcnet_init(PCIDevice *pci_dev) s->irq = pci_dev->irq[0 ]; s->phys_mem_read = pci_physical_memory_read; s->phys_mem_write = pci_physical_memory_write; - s->pci_dev = pci_dev;pcnet_common_init (&pci_dev->qdev, s, pci_pcnet_cleanup); +register_savevm ("pcnet" ,-1 ,2 , pci_pcnet_save, pci_pcnet_load, d); }/* SPARC32 interface */
@@ -2138,6 +2150,7 @@ static void lance_init(SysBusDevice *dev) s->phys_mem_write = ledma_memory_write;pcnet_common_init (&dev->qdev, s, lance_cleanup); +register_savevm ("pcnet" ,-1 ,2 , pcnet_save, pcnet_load, s); }static SysBusDeviceInfo lance_info = {
Signature · 1 line
1.6.2.5
PATCH 26/26 e1000 cleanup
In reply to Juan QuintelaRemove un needed casts from void *.
Use DO_UPCAST() instead of blind casts
--- hw/e1000.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
hw/e1000.c +5 -5
@@ -897,7 +897,7 @@ enum { MAC_NARRAYS = ARRAY_SIZE(mac_regarraystosave) };static void nic_save (QEMUFile *f,void *opaque) { -E1000State *s = (E1000State *)opaque; +E1000State *s = opaque;int i, j;pci_device_save (&s->dev, f);
@@ -940,7 +940,7 @@ nic_save(QEMUFile *f, void *opaque)static int nic_load (QEMUFile *f,void *opaque,int version_id) { -E1000State *s = (E1000State *)opaque; +E1000State *s = opaque;int i, j, ret;if ((ret =pci_device_load (&s->dev, f)) <0 )
@@ -1032,7 +1032,7 @@ static void e1000_mmio_map(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) { -E1000State *d = (E1000State *)pci_dev; +E1000State *d =DO_UPCAST (E1000State, dev, pci_dev);int i;const uint32_t excluded_regs[] = {E1000_MDIC ,E1000_ICR ,E1000_ICS ,E1000_IMS ,
@@ -1062,7 +1062,7 @@ e1000_cleanup(VLANClientState *vc)static int pci_e1000_uninit (PCIDevice *dev) { -E1000State *d = (E1000State *) dev; +E1000State *d =DO_UPCAST (E1000State, dev, dev);cpu_unregister_io_memory (d->mmio_index);
@@ -1083,7 +1083,7 @@ static void e1000_reset(void *opaque)static void pci_e1000_init (PCIDevice *pci_dev) { -E1000State *d = (E1000State *)pci_dev; +E1000State *d =DO_UPCAST (E1000State, dev, pci_dev);uint8_t *pci_conf;uint16_t checksum =0 ;static const char info_str[] ="e1000" ;
Signature · 1 line
1.6.2.5
Hi,
Quoted 2 lines
- ne2000: split isa and pci save/load functions. From now, isa parts are only the common ones.
Well done, looks much better now.
The other patches of the series are fine too.
cheers,
Gerd