All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@qumranet.com>, Anthony Liguori <aliguori@us.ibm.com>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>
Subject: [patch 06/13] QEMU: plug QEMUDevice pt2 / iomem awareness
Date: Thu, 17 Apr 2008 17:10:27 -0300	[thread overview]
Message-ID: <20080417203026.641034266@localhost.localdomain> (raw)
In-Reply-To: 20080417201021.515148882@localhost.localdomain

[-- Attachment #1: io-memory-lock --]
[-- Type: text/plain, Size: 25179 bytes --]

Same as before, but make the iomem->device relationship visible.

Index: kvm-userspace.io/qemu/cpu-all.h
===================================================================
--- kvm-userspace.io.orig/qemu/cpu-all.h
+++ kvm-userspace.io/qemu/cpu-all.h
@@ -840,7 +840,7 @@ void cpu_register_physical_memory(target
 uint32_t cpu_get_physical_page_desc(target_phys_addr_t addr);
 ram_addr_t qemu_ram_alloc(unsigned long size);
 void qemu_ram_free(ram_addr_t addr);
-int cpu_register_io_memory(int io_index,
+int cpu_register_io_memory(QEMUDevice *dev, int io_index,
                            CPUReadMemoryFunc **mem_read,
                            CPUWriteMemoryFunc **mem_write,
                            void *opaque);
Index: kvm-userspace.io/qemu/exec.c
===================================================================
--- kvm-userspace.io.orig/qemu/exec.c
+++ kvm-userspace.io/qemu/exec.c
@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 
+#include "qemu-device.h"
 #include "cpu.h"
 #include "exec-all.h"
 
@@ -2505,7 +2506,7 @@ static void *subpage_init (target_phys_a
     mmio = qemu_mallocz(sizeof(subpage_t));
     if (mmio != NULL) {
         mmio->base = base;
-        subpage_memory = cpu_register_io_memory(0, subpage_read, subpage_write, mmio);
+        subpage_memory = cpu_register_io_memory(NULL, 0, subpage_read, subpage_write, mmio);
 #if defined(DEBUG_SUBPAGE)
         printf("%s: %p base " TARGET_FMT_plx " len %08x %d\n", __func__,
                mmio, base, TARGET_PAGE_SIZE, subpage_memory);
@@ -2534,14 +2535,14 @@ static void io_mem_init(void)
 {
     int i;
 
-    cpu_register_io_memory(IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read, unassigned_mem_write, NULL);
-    cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT, unassigned_mem_read, unassigned_mem_write, NULL);
-    cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read, notdirty_mem_write, NULL);
+    cpu_register_io_memory(NULL, IO_MEM_ROM >> IO_MEM_SHIFT, error_mem_read, unassigned_mem_write, NULL);
+    cpu_register_io_memory(NULL, IO_MEM_UNASSIGNED >> IO_MEM_SHIFT, unassigned_mem_read, unassigned_mem_write, NULL);
+    cpu_register_io_memory(NULL, IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read, notdirty_mem_write, NULL);
     for (i=0; i<5; i++)
         io_mem_used[i] = 1;
 
 #if defined(CONFIG_SOFTMMU)
-    io_mem_watch = cpu_register_io_memory(-1, watch_mem_read,
+    io_mem_watch = cpu_register_io_memory(NULL, -1, watch_mem_read,
                                           watch_mem_write, NULL);
 #endif
     /* alloc dirty bits array */
@@ -2557,7 +2558,8 @@ static void io_mem_init(void)
    modified. If it is zero, a new io zone is allocated. The return
    value can be used with cpu_register_physical_memory(). (-1) is
    returned if error. */
-int cpu_register_io_memory(int io_index,
+int cpu_register_io_memory(QEMUDevice *dev,
+                           int io_index,
                            CPUReadMemoryFunc **mem_read,
                            CPUWriteMemoryFunc **mem_write,
                            void *opaque)
Index: kvm-userspace.io/qemu/hw/apic.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/apic.c
+++ kvm-userspace.io/qemu/hw/apic.c
@@ -70,6 +70,7 @@
 #define MAX_APIC_WORDS 8
 
 typedef struct APICState {
+    QEMUDevice qemu_dev;
     CPUState *cpu_env;
     uint32_t apicbase;
     uint8_t id;
@@ -93,6 +94,7 @@ typedef struct APICState {
 } APICState;
 
 struct IOAPICState {
+    QEMUDevice qemu_dev;
     uint8_t id;
     uint8_t ioregsel;
     uint64_t base_address;
@@ -958,6 +960,7 @@ int apic_init(CPUState *env)
     s = qemu_mallocz(sizeof(APICState));
     if (!s)
         return -1;
+    qemu_register_device(&s->qemu_dev);
     env->apic_state = s;
     apic_init_ipi(s);
     s->id = last_apic_id++;
@@ -977,7 +980,7 @@ int apic_init(CPUState *env)
     if (apic_io_memory == 0) {
         /* NOTE: the APIC is directly connected to the CPU - it is not
            on the global memory bus. */
-        apic_io_memory = cpu_register_io_memory(0, apic_mem_read,
+        apic_io_memory = cpu_register_io_memory(&s->qemu_dev, 0, apic_mem_read,
                                                 apic_mem_write, NULL);
         cpu_register_physical_memory(s->apicbase & ~0xfff, 0x1000,
                                      apic_io_memory);
@@ -1255,10 +1258,11 @@ IOAPICState *ioapic_init(void)
     s = qemu_mallocz(sizeof(IOAPICState));
     if (!s)
         return NULL;
+    qemu_register_device(&s->qemu_dev);
     ioapic_reset(s);
     s->id = last_apic_id++;
 
-    io_memory = cpu_register_io_memory(0, ioapic_mem_read,
+    io_memory = cpu_register_io_memory(&s->qemu_dev, 0, ioapic_mem_read,
                                        ioapic_mem_write, s);
     cpu_register_physical_memory(0xfec00000, 0x1000, io_memory);
 
Index: kvm-userspace.io/qemu/hw/cirrus_vga.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/cirrus_vga.c
+++ kvm-userspace.io/qemu/hw/cirrus_vga.c
@@ -3258,7 +3258,7 @@ static void cirrus_init_common(CirrusVGA
     register_ioport_read(dev, 0x3ba, 1, 1, vga_ioport_read, s);
     register_ioport_read(dev, 0x3da, 1, 1, vga_ioport_read, s);
 
-    vga_io_memory = cpu_register_io_memory(0, cirrus_vga_mem_read,
+    vga_io_memory = cpu_register_io_memory(dev, 0, cirrus_vga_mem_read,
                                            cirrus_vga_mem_write, s);
     cpu_register_physical_memory(isa_mem_base + 0x000a0000, 0x20000,
                                  vga_io_memory);
@@ -3300,18 +3300,18 @@ static void cirrus_init_common(CirrusVGA
 
     /* I/O handler for LFB */
     s->cirrus_linear_io_addr =
-	cpu_register_io_memory(0, cirrus_linear_read, cirrus_linear_write,
+	cpu_register_io_memory(dev, 0, cirrus_linear_read, cirrus_linear_write,
 			       s);
     s->cirrus_linear_write = cpu_get_io_memory_write(s->cirrus_linear_io_addr);
 
     /* I/O handler for LFB */
     s->cirrus_linear_bitblt_io_addr =
-	cpu_register_io_memory(0, cirrus_linear_bitblt_read, cirrus_linear_bitblt_write,
+	cpu_register_io_memory(dev, 0, cirrus_linear_bitblt_read, cirrus_linear_bitblt_write,
 			       s);
 
     /* I/O handler for memory-mapped I/O */
     s->cirrus_mmio_io_addr =
-	cpu_register_io_memory(0, cirrus_mmio_read, cirrus_mmio_write, s);
+	cpu_register_io_memory(dev, 0, cirrus_mmio_read, cirrus_mmio_write, s);
 
     /* XXX: s->vram_size must be a power of two */
     s->cirrus_addr_mask = s->real_vram_size - 1;
Index: kvm-userspace.io/qemu/hw/e1000.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/e1000.c
+++ kvm-userspace.io/qemu/hw/e1000.c
@@ -936,7 +936,8 @@ e1000_mmio_map(PCIDevice *pci_dev, int r
     DBGOUT(MMIO, "e1000_mmio_map addr=0x%08x 0x%08x\n", addr, size);
 
     d->mmio_base = addr;
-    cpu_register_physical_memory(addr, PNPMMIO_SIZE, d->mmio_index);
+    cpu_register_physical_memory(addr, PNPMMIO_SIZE,
+                                 d->mmio_index);
 }
 
 static int
@@ -976,7 +977,8 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd,
 
     pci_conf[0x3d] = 1; // interrupt pin 0
 
-    d->mmio_index = cpu_register_io_memory(0, e1000_mmio_read,
+    d->mmio_index = cpu_register_io_memory(&d->dev.qemu_dev, 0,
+            e1000_mmio_read,
             e1000_mmio_write, d);
 
     pci_register_io_region((PCIDevice *)d, 0, PNPMMIO_SIZE,
Index: kvm-userspace.io/qemu/hw/eepro100.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/eepro100.c
+++ kvm-userspace.io/qemu/hw/eepro100.c
@@ -1767,7 +1767,8 @@ static PCIDevice *nic_init(PCIBus * bus,
 
     /* Handler for memory-mapped I/O */
     d->eepro100.mmio_index =
-        cpu_register_io_memory(0, pci_mmio_read, pci_mmio_write, s);
+        cpu_register_io_memory(&d->dev.qemu_dev, 0, pci_mmio_read,
+                               pci_mmio_write, s);
 
     pci_register_io_region(&d->dev, 0, PCI_MEM_SIZE,
                            PCI_ADDRESS_SPACE_MEM |
Index: kvm-userspace.io/qemu/hw/fdc.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/fdc.c
+++ kvm-userspace.io/qemu/hw/fdc.c
@@ -755,8 +755,8 @@ fdctrl_t *fdctrl_init (qemu_irq irq, int
 
     fdctrl->sun4m = 0;
     if (mem_mapped) {
-        io_mem = cpu_register_io_memory(0, fdctrl_mem_read, fdctrl_mem_write,
-                                        fdctrl);
+        io_mem = cpu_register_io_memory(dev, 0, fdctrl_mem_read,
+                                        fdctrl_mem_write, fdctrl);
         cpu_register_physical_memory(io_base, 0x08, io_mem);
     } else {
         register_ioport_read(dev, (uint32_t)io_base + 0x01, 5, 1, &fdctrl_read,
@@ -777,10 +777,12 @@ fdctrl_t *sun4m_fdctrl_init (qemu_irq ir
 {
     fdctrl_t *fdctrl;
     int io_mem;
+    QEMUDevice *dev;
 
     fdctrl = fdctrl_init_common(irq, 0, io_base, fds);
+    dev = &fdctrl->qemu_dev;
     fdctrl->sun4m = 1;
-    io_mem = cpu_register_io_memory(0, fdctrl_mem_read_strict,
+    io_mem = cpu_register_io_memory(dev, 0, fdctrl_mem_read_strict,
                                     fdctrl_mem_write_strict,
                                     fdctrl);
     cpu_register_physical_memory(io_base, 0x08, io_mem);
Index: kvm-userspace.io/qemu/hw/isa_mmio.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/isa_mmio.c
+++ kvm-userspace.io/qemu/hw/isa_mmio.c
@@ -93,6 +93,11 @@ static CPUReadMemoryFunc *isa_mmio_read[
 
 static int isa_mmio_iomemtype = 0;
 
+
+/*
+ * FIXME to use QEMUDevice
+ */
+#if 0
 void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size)
 {
     if (!isa_mmio_iomemtype) {
@@ -101,3 +106,4 @@ void isa_mmio_init(target_phys_addr_t ba
     }
     cpu_register_physical_memory(base, size, isa_mmio_iomemtype);
 }
+#endif
Index: kvm-userspace.io/qemu/hw/lsi53c895a.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/lsi53c895a.c
+++ kvm-userspace.io/qemu/hw/lsi53c895a.c
@@ -1813,7 +1813,8 @@ static void lsi_ram_mapfunc(PCIDevice *p
 
     DPRINTF("Mapping ram at %08x\n", addr);
     s->script_ram_base = addr;
-    cpu_register_physical_memory(addr + 0, 0x2000, s->ram_io_addr);
+    cpu_register_physical_memory(addr + 0, 0x2000,
+                                 s->ram_io_addr);
 }
 
 static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num,
@@ -1822,7 +1823,8 @@ static void lsi_mmio_mapfunc(PCIDevice *
     LSIState *s = (LSIState *)pci_dev;
 
     DPRINTF("Mapping registers at %08x\n", addr);
-    cpu_register_physical_memory(addr + 0, 0x400, s->mmio_io_addr);
+    cpu_register_physical_memory(addr + 0, 0x400,
+                                 s->mmio_io_addr);
 }
 
 void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id)
@@ -1865,6 +1867,7 @@ int lsi_scsi_uninit(PCIDevice *d)
 void *lsi_scsi_init(PCIBus *bus, int devfn)
 {
     LSIState *s;
+    QEMUDevice *dev;
 
     s = (LSIState *)pci_register_device(bus, "LSI53C895A SCSI HBA",
                                         sizeof(*s), devfn, NULL, NULL);
@@ -1872,6 +1875,7 @@ void *lsi_scsi_init(PCIBus *bus, int dev
         fprintf(stderr, "lsi-scsi: Failed to register PCI device\n");
         return NULL;
     }
+    dev = &s->pci_dev.qemu_dev;
 
     s->pci_dev.config[0x00] = 0x00;
     s->pci_dev.config[0x01] = 0x10;
@@ -1880,9 +1884,9 @@ void *lsi_scsi_init(PCIBus *bus, int dev
     s->pci_dev.config[0x0b] = 0x01;
     s->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */
 
-    s->mmio_io_addr = cpu_register_io_memory(0, lsi_mmio_readfn,
+    s->mmio_io_addr = cpu_register_io_memory(dev, 0, lsi_mmio_readfn,
                                              lsi_mmio_writefn, s);
-    s->ram_io_addr = cpu_register_io_memory(0, lsi_ram_readfn,
+    s->ram_io_addr = cpu_register_io_memory(dev, 0, lsi_ram_readfn,
                                             lsi_ram_writefn, s);
 
     pci_register_io_region((struct PCIDevice *)s, 0, 256,
Index: kvm-userspace.io/qemu/hw/mc146818rtc.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/mc146818rtc.c
+++ kvm-userspace.io/qemu/hw/mc146818rtc.c
@@ -564,6 +564,7 @@ static CPUWriteMemoryFunc *rtc_mm_write[
     &cmos_mm_writel,
 };
 
+#ifdef TARGET_MIPS
 RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq)
 {
     RTCState *s;
@@ -598,3 +599,4 @@ RTCState *rtc_mm_init(target_phys_addr_t
     register_savevm("mc146818rtc", base, 1, rtc_save, rtc_load, s);
     return s;
 }
+#endif
Index: kvm-userspace.io/qemu/hw/parallel.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/parallel.c
+++ kvm-userspace.io/qemu/hw/parallel.c
@@ -523,6 +523,7 @@ static CPUWriteMemoryFunc *parallel_mm_w
     &parallel_mm_writel,
 };
 
+#ifdef TARGET_MIPS
 /* If fd is zero, it means that the parallel device uses the console */
 ParallelState *parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr)
 {
@@ -540,3 +541,4 @@ ParallelState *parallel_mm_init(target_p
     cpu_register_physical_memory(base, 8 << it_shift, io_sw);
     return s;
 }
+#endif
Index: kvm-userspace.io/qemu/hw/pckbd.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/pckbd.c
+++ kvm-userspace.io/qemu/hw/pckbd.c
@@ -432,6 +432,7 @@ static CPUWriteMemoryFunc *kbd_mm_write[
     &kbd_mm_writeb,
 };
 
+#ifdef TARGET_MIPS
 void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
                    target_phys_addr_t base, int it_shift)
 {
@@ -450,8 +451,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qem
 
     s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s);
     s->mouse = ps2_mouse_init(kbd_update_aux_irq, s);
-#ifdef TARGET_I386
     vmmouse_init(s->mouse);
-#endif
     qemu_register_reset(kbd_reset, s);
 }
+#endif
Index: kvm-userspace.io/qemu/hw/pcnet.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/pcnet.c
+++ kvm-userspace.io/qemu/hw/pcnet.c
@@ -1944,7 +1944,8 @@ static void pcnet_mmio_map(PCIDevice *pc
     printf("pcnet_ioport_map addr=0x%08x 0x%08x\n", addr, size);
 #endif
 
-    cpu_register_physical_memory(addr, PCNET_PNPMMIO_SIZE, d->mmio_index);
+    cpu_register_physical_memory(addr, PCNET_PNPMMIO_SIZE,
+                                 d->mmio_index);
 }
 
 static void pci_physical_memory_write(void *dma_opaque, target_phys_addr_t addr,
@@ -1962,6 +1963,7 @@ static void pci_physical_memory_read(voi
 PCIDevice *pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
     PCNetState *d;
+    QEMUDevice *dev;
     uint8_t *pci_conf;
 
 #if 0
@@ -1972,6 +1974,8 @@ PCIDevice *pci_pcnet_init(PCIBus *bus, N
     d = (PCNetState *)pci_register_device(bus, "PCNet", sizeof(PCNetState),
                                           devfn, NULL, NULL);
 
+    dev = &d->dev.qemu_dev;
+
     pci_conf = d->dev.config;
 
     *(uint16_t *)&pci_conf[0x00] = cpu_to_le16(0x1022);
@@ -1993,7 +1997,7 @@ PCIDevice *pci_pcnet_init(PCIBus *bus, N
 
     /* Handler for memory-mapped I/O */
     d->mmio_index =
-      cpu_register_io_memory(0, pcnet_mmio_read, pcnet_mmio_write, d);
+      cpu_register_io_memory(dev, 0, pcnet_mmio_read, pcnet_mmio_write, d);
 
     pci_register_io_region((PCIDevice *)d, 0, PCNET_IOPORT_SIZE,
                            PCI_ADDRESS_SPACE_IO, pcnet_ioport_map);
Index: kvm-userspace.io/qemu/hw/piix_pci.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/piix_pci.c
+++ kvm-userspace.io/qemu/hw/piix_pci.c
@@ -62,6 +62,7 @@ static int pci_irq_levels[4];
 static void update_pam(PCIDevice *d, uint32_t start, uint32_t end, int r)
 {
     uint32_t addr;
+    QEMUDevice *dev = &d->qemu_dev;
 
     //    printf("ISA mapping %08x-0x%08x: %d\n", start, end, r);
     switch(r) {
@@ -90,6 +91,7 @@ static void i440fx_update_memory_mapping
 {
     int i, r;
     uint32_t smram, addr;
+    QEMUDevice *dev = &d->qemu_dev;
 
     update_pam(d, 0xf0000, 0x100000, (d->config[0x59] >> 4) & 3);
     for(i = 0; i < 12; i++) {
Index: kvm-userspace.io/qemu/hw/rtl8139.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/rtl8139.c
+++ kvm-userspace.io/qemu/hw/rtl8139.c
@@ -3316,7 +3316,8 @@ static void rtl8139_mmio_map(PCIDevice *
     PCIRTL8139State *d = (PCIRTL8139State *)pci_dev;
     RTL8139State *s = &d->rtl8139;
 
-    cpu_register_physical_memory(addr + 0, 0x100, s->rtl8139_mmio_io_addr);
+    cpu_register_physical_memory(addr + 0, 0x100,
+                                 s->rtl8139_mmio_io_addr);
 }
 
 static void rtl8139_ioport_map(PCIDevice *pci_dev, int region_num,
@@ -3407,11 +3408,13 @@ PCIDevice *pci_rtl8139_init(PCIBus *bus,
     RTL8139State *s;
     uint8_t *pci_conf;
     static int rtl8139_id;
+    QEMUDevice *dev;
 
     d = (PCIRTL8139State *)pci_register_device(bus,
                                               "RTL8139", sizeof(PCIRTL8139State),
                                               devfn,
                                               NULL, NULL);
+    dev = &d->dev.qemu_dev;
     pci_conf = d->dev.config;
     pci_conf[0x00] = 0xec; /* Realtek 8139 */
     pci_conf[0x01] = 0x10;
@@ -3429,7 +3432,7 @@ PCIDevice *pci_rtl8139_init(PCIBus *bus,
 
     /* I/O handler for memory-mapped I/O */
     s->rtl8139_mmio_io_addr =
-    cpu_register_io_memory(0, rtl8139_mmio_read, rtl8139_mmio_write, s);
+    cpu_register_io_memory(dev, 0, rtl8139_mmio_read, rtl8139_mmio_write, s);
 
     pci_register_io_region(&d->dev, 0, 0x100,
                            PCI_ADDRESS_SPACE_IO,  rtl8139_ioport_map);
Index: kvm-userspace.io/qemu/hw/serial.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/serial.c
+++ kvm-userspace.io/qemu/hw/serial.c
@@ -477,6 +477,7 @@ static CPUWriteMemoryFunc *serial_mm_wri
     &serial_mm_writel,
 };
 
+#ifndef TARGET_I386
 SerialState *serial_mm_init (target_phys_addr_t base, int it_shift,
                              qemu_irq irq, CharDriverState *chr,
                              int ioregister)
@@ -506,3 +507,4 @@ SerialState *serial_mm_init (target_phys
                           serial_event, s);
     return s;
 }
+#endif
Index: kvm-userspace.io/qemu/hw/usb-ohci.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/usb-ohci.c
+++ kvm-userspace.io/qemu/hw/usb-ohci.c
@@ -1592,8 +1592,8 @@ static CPUWriteMemoryFunc *ohci_writefn[
     ohci_mem_write
 };
 
-static void usb_ohci_init(OHCIState *ohci, int num_ports, int devfn,
-            qemu_irq irq, enum ohci_type type, const char *name)
+static void usb_ohci_init(QEMUDevice *dev, OHCIState *ohci, int num_ports,
+            int devfn, qemu_irq irq, enum ohci_type type, const char *name)
 {
     int i;
 
@@ -1613,7 +1613,7 @@ static void usb_ohci_init(OHCIState *ohc
                 usb_frame_time, usb_bit_time);
     }
 
-    ohci->mem = cpu_register_io_memory(0, ohci_readfn, ohci_writefn, ohci);
+    ohci->mem = cpu_register_io_memory(dev, 0, ohci_readfn, ohci_writefn, ohci);
     ohci->name = name;
 
     ohci->irq = irq;
@@ -1639,7 +1639,8 @@ static void ohci_mapfunc(PCIDevice *pci_
 {
     OHCIPCIState *ohci = (OHCIPCIState *)pci_dev;
     ohci->state.mem_base = addr;
-    cpu_register_physical_memory(addr, size, ohci->state.mem);
+    cpu_register_physical_memory(addr, size,
+                                 ohci->state.mem);
 }
 
 void usb_ohci_init_pci(struct PCIBus *bus, int num_ports, int devfn)
@@ -1664,13 +1665,16 @@ void usb_ohci_init_pci(struct PCIBus *bu
     ohci->pci_dev.config[0x0b] = 0xc;
     ohci->pci_dev.config[0x3d] = 0x01; /* interrupt pin 1 */
 
-    usb_ohci_init(&ohci->state, num_ports, devfn, ohci->pci_dev.irq[0],
-                  OHCI_TYPE_PCI, ohci->pci_dev.name);
+    usb_ohci_init(&ohci->pci_dev.qemu_dev, &ohci->state, num_ports, devfn,
+                  ohci->pci_dev.irq[0], OHCI_TYPE_PCI, ohci->pci_dev.name);
 
     pci_register_io_region((struct PCIDevice *)ohci, 0, 256,
                            PCI_ADDRESS_SPACE_MEM, ohci_mapfunc);
 }
 
+
+#if 0
+FIXME: use QEMUDevice
 void usb_ohci_init_pxa(target_phys_addr_t base, int num_ports, int devfn,
                        qemu_irq irq)
 {
@@ -1682,3 +1686,4 @@ void usb_ohci_init_pxa(target_phys_addr_
 
     cpu_register_physical_memory(ohci->mem_base, 0x1000, ohci->mem);
 }
+#endif
Index: kvm-userspace.io/qemu/hw/vga.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/vga.c
+++ kvm-userspace.io/qemu/hw/vga.c
@@ -2008,6 +2008,8 @@ static void vga_map(PCIDevice *pci_dev, 
 {
     PCIVGAState *d = (PCIVGAState *)pci_dev;
     VGAState *s = &d->vga_state;
+    QEMUDevice *dev = &pci_dev->qemu_dev;
+
     if (region_num == PCI_ROM_SLOT) {
         cpu_register_physical_memory(addr, s->bios_size, s->bios_offset);
     } else {
@@ -2246,7 +2248,8 @@ void vga_init(VGAState *s, QEMUDevice *d
 #endif
 #endif /* CONFIG_BOCHS_VBE */
 
-    vga_io_memory = cpu_register_io_memory(0, vga_mem_read, vga_mem_write, s);
+    vga_io_memory = cpu_register_io_memory(dev, 0, vga_mem_read, vga_mem_write,
+                                           s);
     cpu_register_physical_memory(isa_mem_base + 0x000a0000, 0x20000,
                                  vga_io_memory);
 }
@@ -2313,11 +2316,12 @@ static void vga_mm_init(VGAState *s, tar
                         target_phys_addr_t ctrl_base, int it_shift)
 {
     int s_ioport_ctrl, vga_io_memory;
+    QEMUDevice *dev = &s->qemu_dev;
 
     s->base_ctrl = ctrl_base;
     s->it_shift = it_shift;
-    s_ioport_ctrl = cpu_register_io_memory(0, vga_mm_read_ctrl, vga_mm_write_ctrl, s);
-    vga_io_memory = cpu_register_io_memory(0, vga_mem_read, vga_mem_write, s);
+    s_ioport_ctrl = cpu_register_io_memory(dev, 0, vga_mm_read_ctrl, vga_mm_write_ctrl, s);
+    vga_io_memory = cpu_register_io_memory(dev, 0, vga_mem_read, vga_mem_write, s);
 
     register_savevm("vga", 0, 2, vga_save, vga_load, s);
 
@@ -2357,6 +2361,7 @@ int isa_vga_mm_init(DisplayState *ds, ui
                     int it_shift)
 {
     VGAState *s;
+    QEMUDevice *dev;
 
     s = qemu_mallocz(sizeof(VGAState));
     if (!s)
@@ -2365,6 +2370,7 @@ int isa_vga_mm_init(DisplayState *ds, ui
     vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
     vga_mm_init(s, vram_base, ctrl_base, it_shift);
 
+    dev = &s->qemu_dev;
     graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
                          s->text_update, s);
 
Index: kvm-userspace.io/qemu/hw/vmware_vga.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/vmware_vga.c
+++ kvm-userspace.io/qemu/hw/vmware_vga.c
@@ -1181,11 +1181,12 @@ static void pci_vmsvga_map_mem(PCIDevice
 {
     struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev;
     struct vmsvga_state_s *s = &d->chip;
+    QEMUDevice *dev = &pci_dev->qemu_dev;
     int iomemtype;
 
     s->vram_base = addr;
 #ifdef DIRECT_VRAM
-    iomemtype = cpu_register_io_memory(0, vmsvga_vram_read,
+    iomemtype = cpu_register_io_memory(dev, 0, vmsvga_vram_read,
                     vmsvga_vram_write, s);
 #else
     iomemtype = 0 | IO_MEM_RAM;
Index: kvm-userspace.io/qemu/kqemu.c
===================================================================
--- kvm-userspace.io.orig/qemu/kqemu.c
+++ kvm-userspace.io/qemu/kqemu.c
@@ -38,6 +38,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
 
Index: kvm-userspace.io/qemu/qemu-common.h
===================================================================
--- kvm-userspace.io.orig/qemu/qemu-common.h
+++ kvm-userspace.io/qemu/qemu-common.h
@@ -29,6 +29,8 @@
 
 #include "qemu-device.h"
 
+#include "qemu-device.h"
+
 #ifdef _WIN32
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
Index: kvm-userspace.io/qemu/hw/ide.c
===================================================================
--- kvm-userspace.io.orig/qemu/hw/ide.c
+++ kvm-userspace.io/qemu/hw/ide.c
@@ -3027,6 +3027,8 @@ void pci_piix4_ide_init(PCIBus *bus, Blo
     register_savevm("ide", 0, 1, pci_ide_save, pci_ide_load, d);
 }
 
+#ifdef TARGET_PPC
+
 /***********************************************************/
 /* MacIO based PowerPC IDE */
 
@@ -3151,6 +3153,7 @@ int pmac_ide_init (BlockDriverState **hd
                                              pmac_ide_write, &ide_if[0]);
     return pmac_ide_memory;
 }
+#endif
 
 /***********************************************************/
 /* CF-ATA Microdrive */

-- 


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

  parent reply	other threads:[~2008-04-17 20:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-17 20:10 [patch 00/13] RFC: split the global mutex Marcelo Tosatti
2008-04-17 20:10 ` [patch 01/13] QEMU: get rid of global cpu_single_env Marcelo Tosatti
2008-04-17 20:10 ` [patch 02/13] QEMU: introduce QEMUDevice Marcelo Tosatti
2008-04-17 20:10 ` [patch 03/13] QEMU: make esp.c build conditional to SPARC target Marcelo Tosatti
2008-04-17 20:10 ` [patch 04/13] QEMU: plug QEMUDevice pt1 / ioport awareness Marcelo Tosatti
2008-04-17 20:10 ` [patch 05/13] QEMU: add a mutex to protect IRQ chip data structures Marcelo Tosatti
2008-04-17 20:10 ` Marcelo Tosatti [this message]
2008-04-17 20:10 ` [patch 07/13] QEMU: grab device lock for ioport/iomem processing Marcelo Tosatti
2008-04-17 20:10 ` [patch 08/13] QEMU: character device locking Marcelo Tosatti
2008-04-17 20:10 ` [patch 09/13] QEMU: network " Marcelo Tosatti
2008-04-17 20:10 ` [patch 10/13] QEMU: get rid of aiocb cache Marcelo Tosatti
2008-04-17 20:10 ` [patch 11/13] QEMU: block device locking Marcelo Tosatti
2008-04-17 20:10 ` [patch 12/13] QEMU: scsi-disk reentrancy fix Marcelo Tosatti
2008-04-17 20:10 ` [patch 13/13] QEMU/KVM: get rid of global lock Marcelo Tosatti
2008-04-20 11:16 ` [patch 00/13] RFC: split the global mutex Avi Kivity
2008-04-21  0:00   ` Marcelo Tosatti
2008-04-21  6:10     ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080417203026.641034266@localhost.localdomain \
    --to=mtosatti@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.