qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/12] qdev isa patches.
@ 2009-09-09 14:45 Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 01/12] isapc: Fix irq routing Gerd Hoffmann
                   ` (12 more replies)
  0 siblings, 13 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Here is a batch of patches for the isa bus and isa bus devices.  qdev
support for the isa bus is reworked a bit, following up the default
value discussion with Markus.  A few devices are converted to qdev.
Some bugs (like -M isapc segfaulting) are fixed along the way.

As usual the individual patches have more verbose descriptions.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 01/12] isapc: Fix irq routing
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 02/12] isapc: pick a more sane default cpu for such old hardware Gerd Hoffmann
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Only send irqs to ioapic in case we have one.
Fixes qemu segfault.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/pc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 6292001..9af0cdb 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -100,7 +100,8 @@ static void isa_irq_handler(void *opaque, int n, int level)
     if (n < 16) {
         qemu_set_irq(isa->i8259[n], level);
     }
-    qemu_set_irq(isa->ioapic[n], level);
+    if (isa->ioapic)
+        qemu_set_irq(isa->ioapic[n], level);
 };
 
 static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 02/12] isapc: pick a more sane default cpu for such old hardware.
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 01/12] isapc: Fix irq routing Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 03/12] qdev: drop iobase properties from isa bus Gerd Hoffmann
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/pc.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 9af0cdb..872cb3a 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1450,6 +1450,8 @@ static void pc_init_isa(ram_addr_t ram_size,
                         const char *initrd_filename,
                         const char *cpu_model)
 {
+    if (cpu_model == NULL)
+        cpu_model = "486";
     pc_init1(ram_size, boot_device,
              kernel_filename, kernel_cmdline,
              initrd_filename, cpu_model, 0);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 03/12] qdev: drop iobase properties from isa bus
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 01/12] isapc: Fix irq routing Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 02/12] isapc: pick a more sane default cpu for such old hardware Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 04/12] qdev: simplify isa irq assignments Gerd Hoffmann
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Lot of ISA devices work at fixed addresses, so having iobase
as bus property doesn't make much sense.  Devices which can
have different iobases will get a device property.

Also simply hard-code stuff which can't be configured anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/fdc.c        |   17 +++++++++--------
 hw/fdc.h        |    4 +---
 hw/isa-bus.c    |   10 +---------
 hw/isa.h        |    4 +---
 hw/mips_malta.c |    4 ++--
 hw/pc.c         |    4 ++--
 hw/pckbd.c      |    8 ++++----
 hw/ppc_prep.c   |    2 +-
 hw/sun4u.c      |    4 ++--
 9 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/hw/fdc.c b/hw/fdc.c
index db57710..d761e62 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1871,14 +1871,14 @@ static void fdctrl_connect_drives(fdctrl_t *fdctrl, BlockDriverState **fds)
     }
 }
 
-fdctrl_t *fdctrl_init_isa(int isairq, int dma_chann,
-                          uint32_t io_base,
-                          BlockDriverState **fds)
+fdctrl_t *fdctrl_init_isa(BlockDriverState **fds)
 {
     fdctrl_t *fdctrl;
     ISADevice *dev;
+    int isairq = 6;
+    int dma_chann = 2;
 
-    dev = isa_create_simple("isa-fdc", io_base, 0, isairq, -1);
+    dev = isa_create_simple("isa-fdc", isairq, -1);
     fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
 
     fdctrl->dma_chann = dma_chann;
@@ -1968,14 +1968,15 @@ static int isabus_fdc_init1(ISADevice *dev)
 {
     fdctrl_isabus_t *isa = DO_UPCAST(fdctrl_isabus_t, busdev, dev);
     fdctrl_t *fdctrl = &isa->state;
+    int iobase = 0x3f0;
 
-    register_ioport_read(isa->busdev.iobase[0] + 0x01, 5, 1,
+    register_ioport_read(iobase + 0x01, 5, 1,
                          &fdctrl_read_port, fdctrl);
-    register_ioport_read(isa->busdev.iobase[0] + 0x07, 1, 1,
+    register_ioport_read(iobase + 0x07, 1, 1,
                          &fdctrl_read_port, fdctrl);
-    register_ioport_write(isa->busdev.iobase[0] + 0x01, 5, 1,
+    register_ioport_write(iobase + 0x01, 5, 1,
                           &fdctrl_write_port, fdctrl);
-    register_ioport_write(isa->busdev.iobase[0] + 0x07, 1, 1,
+    register_ioport_write(iobase + 0x07, 1, 1,
                           &fdctrl_write_port, fdctrl);
     isa_init_irq(&isa->busdev, &fdctrl->irq);
 
diff --git a/hw/fdc.h b/hw/fdc.h
index 04d64ea..1b81ec1 100644
--- a/hw/fdc.h
+++ b/hw/fdc.h
@@ -3,9 +3,7 @@
 
 typedef struct fdctrl_t fdctrl_t;
 
-fdctrl_t *fdctrl_init_isa(int isairq, int dma_chann,
-                          uint32_t io_base,
-                          BlockDriverState **fds);
+fdctrl_t *fdctrl_init_isa(BlockDriverState **fds);
 fdctrl_t *fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
                              target_phys_addr_t mmio_base,
                              BlockDriverState **fds);
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 2843b51..fde066a 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -35,11 +35,6 @@ static struct BusInfo isa_bus_info = {
     .name      = "ISA",
     .size      = sizeof(ISABus),
     .print_dev = isabus_dev_print,
-    .props     = (Property[]) {
-        DEFINE_PROP_HEX32("iobase",  ISADevice, iobase[0], -1),
-        DEFINE_PROP_HEX32("iobase2", ISADevice, iobase[1], -1),
-        DEFINE_PROP_END_OF_LIST(),
-    }
 };
 
 ISABus *isa_bus_new(DeviceState *dev)
@@ -122,8 +117,7 @@ void isa_qdev_register(ISADeviceInfo *info)
     qdev_register(&info->qdev);
 }
 
-ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2,
-                             uint32_t irq, uint32 irq2)
+ISADevice *isa_create_simple(const char *name, uint32_t irq, uint32 irq2)
 {
     DeviceState *dev;
     ISADevice *isa;
@@ -134,8 +128,6 @@ ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2
     }
     dev = qdev_create(&isabus->qbus, name);
     isa = DO_UPCAST(ISADevice, qdev, dev);
-    isa->iobase[0] = iobase;
-    isa->iobase[1] = iobase2;
     qdev_init(dev);
     if (irq != -1) {
         isa_connect_irq(isa, 0, irq);
diff --git a/hw/isa.h b/hw/isa.h
index d98acd5..24c5c66 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -12,7 +12,6 @@ typedef struct ISADeviceInfo ISADeviceInfo;
 
 struct ISADevice {
     DeviceState qdev;
-    uint32_t iobase[2];
     uint32_t isairq[2];
     qemu_irq *irqs[2];
     int nirqs;
@@ -30,8 +29,7 @@ void isa_connect_irq(ISADevice *dev, int devirq, int isairq);
 qemu_irq isa_reserve_irq(int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p);
 void isa_qdev_register(ISADeviceInfo *info);
-ISADevice *isa_create_simple(const char *name, uint32_t iobase, uint32_t iobase2,
-                             uint32_t irq, uint32_t irq2);
+ISADevice *isa_create_simple(const char *name, uint32_t irq, uint32_t irq2);
 
 extern target_phys_addr_t isa_mem_base;
 
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index bb6364b..3222e16 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -921,7 +921,7 @@ void mips_malta_init (ram_addr_t ram_size,
     DMA_init(0);
 
     /* Super I/O */
-    isa_dev = isa_create_simple("i8042", 0x60, 0x64, 1, 12);
+    isa_dev = isa_create_simple("i8042", 1, 12);
  
     rtc_state = rtc_init(0x70, isa_reserve_irq(8), 2000);
     serial_init(0x3f8, isa_reserve_irq(4), 115200, serial_hds[0]);
@@ -932,7 +932,7 @@ void mips_malta_init (ram_addr_t ram_size,
         dinfo = drive_get(IF_FLOPPY, 0, i);
         fd[i] = dinfo ? dinfo->bdrv : NULL;
     }
-    floppy_controller = fdctrl_init_isa(6, 2, 0x3f0, fd);
+    floppy_controller = fdctrl_init_isa(fd);
 
     /* Sound card */
 #ifdef HAS_AUDIO
diff --git a/hw/pc.c b/hw/pc.c
index 872cb3a..0219961 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1373,7 +1373,7 @@ static void pc_init1(ram_addr_t ram_size,
         }
     }
 
-    isa_dev = isa_create_simple("i8042", 0x60, 0x64, 1, 12);
+    isa_dev = isa_create_simple("i8042", 1, 12);
     DMA_init(0);
 #ifdef HAS_AUDIO
     audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
@@ -1383,7 +1383,7 @@ static void pc_init1(ram_addr_t ram_size,
         dinfo = drive_get(IF_FLOPPY, 0, i);
         fd[i] = dinfo ? dinfo->bdrv : NULL;
     }
-    floppy_controller = fdctrl_init_isa(6, 2, 0x3f0, fd);
+    floppy_controller = fdctrl_init_isa(fd);
 
     cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd);
 
diff --git a/hw/pckbd.c b/hw/pckbd.c
index 3f83320..b4b65a6 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -455,10 +455,10 @@ static int i8042_initfn(ISADevice *dev)
 
     kbd_reset(s);
     register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
-    register_ioport_read(dev->iobase[0], 1, 1, kbd_read_data, s);
-    register_ioport_write(dev->iobase[0], 1, 1, kbd_write_data, s);
-    register_ioport_read(dev->iobase[1], 1, 1, kbd_read_status, s);
-    register_ioport_write(dev->iobase[1], 1, 1, kbd_write_command, s);
+    register_ioport_read(0x60, 1, 1, kbd_read_data, s);
+    register_ioport_write(0x60, 1, 1, kbd_write_data, s);
+    register_ioport_read(0x64, 1, 1, kbd_read_status, s);
+    register_ioport_write(0x64, 1, 1, kbd_write_command, s);
 
     s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s);
     s->mouse = ps2_mouse_init(kbd_update_aux_irq, s);
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index c081d58..3fbfc8b 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -719,7 +719,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
         dinfo = drive_get(IF_FLOPPY, 0, i);
         fd[i] = dinfo ? dinfo->bdrv : NULL;
     }
-    fdctrl_init_isa(6, 2, 0x3f0, fd);
+    fdctrl_init_isa(fd);
 
     /* Register speaker port */
     register_ioport_read(0x61, 1, 1, speaker_ioport_read, NULL);
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 03855d3..b71df1f 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -617,12 +617,12 @@ static void sun4uv_init(ram_addr_t RAM_size,
 
     pci_cmd646_ide_init(pci_bus, hd, 1);
 
-    isa_create_simple("i8042", 0x60, 0x64, 1, 12);
+    isa_create_simple("i8042", 1, 12);
     for(i = 0; i < MAX_FD; i++) {
         dinfo = drive_get(IF_FLOPPY, 0, i);
         fd[i] = dinfo ? dinfo->bdrv : NULL;
     }
-    fdctrl_init_isa(6, 2, 0x3f0, fd);
+    fdctrl_init_isa(fd);
     /* FIXME: wire up interrupts.  */
     nvram = m48t59_init(NULL/*8*/, 0, 0x0074, NVRAM_SIZE, 59);
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 04/12] qdev: simplify isa irq assignments
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 03/12] qdev: drop iobase properties from isa bus Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 05/12] qdev: tag isabus-bridge as no-user Gerd Hoffmann
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

isa-bus owns the isa irqs now, so it can hand them out directly.
There is no need for the separate isa_connect_irqs step, drop it.

Also hard-code isa interrupts which can't be configured anyway.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/fdc.c        |    6 +++---
 hw/isa-bus.c    |   38 +++++++++++---------------------------
 hw/isa.h        |    6 ++----
 hw/mips_malta.c |    2 +-
 hw/pc.c         |    2 +-
 hw/pckbd.c      |    4 ++--
 hw/sun4u.c      |    2 +-
 7 files changed, 21 insertions(+), 39 deletions(-)

diff --git a/hw/fdc.c b/hw/fdc.c
index d761e62..47b1c9d 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1875,10 +1875,9 @@ fdctrl_t *fdctrl_init_isa(BlockDriverState **fds)
 {
     fdctrl_t *fdctrl;
     ISADevice *dev;
-    int isairq = 6;
     int dma_chann = 2;
 
-    dev = isa_create_simple("isa-fdc", isairq, -1);
+    dev = isa_create_simple("isa-fdc");
     fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state);
 
     fdctrl->dma_chann = dma_chann;
@@ -1969,6 +1968,7 @@ static int isabus_fdc_init1(ISADevice *dev)
     fdctrl_isabus_t *isa = DO_UPCAST(fdctrl_isabus_t, busdev, dev);
     fdctrl_t *fdctrl = &isa->state;
     int iobase = 0x3f0;
+    int isairq = 6;
 
     register_ioport_read(iobase + 0x01, 5, 1,
                          &fdctrl_read_port, fdctrl);
@@ -1978,7 +1978,7 @@ static int isabus_fdc_init1(ISADevice *dev)
                           &fdctrl_write_port, fdctrl);
     register_ioport_write(iobase + 0x07, 1, 1,
                           &fdctrl_write_port, fdctrl);
-    isa_init_irq(&isa->busdev, &fdctrl->irq);
+    isa_init_irq(&isa->busdev, &fdctrl->irq, isairq);
 
     return fdctrl_init_common(fdctrl);
 }
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index fde066a..bfd0fff 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -57,20 +57,6 @@ void isa_bus_irqs(qemu_irq *irqs)
     isabus->irqs = irqs;
 }
 
-void isa_connect_irq(ISADevice *dev, int devnr, int isairq)
-{
-    assert(devnr >= 0 && devnr < dev->nirqs);
-    if (isabus->assigned & (1 << isairq)) {
-        fprintf(stderr, "isa irq %d already assigned\n", isairq);
-        exit(1);
-    }
-    if (dev->irqs[devnr]) {
-        isabus->assigned |= (1 << isairq);
-        dev->isairq[devnr] = isairq;
-        *dev->irqs[devnr] = isabus->irqs[isairq];
-    }
-}
-
 /*
  * isa_reserve_irq() reserves the ISA irq and returns the corresponding
  * qemu_irq entry for the i8259.
@@ -92,10 +78,16 @@ qemu_irq isa_reserve_irq(int isairq)
     return isabus->irqs[isairq];
 }
 
-void isa_init_irq(ISADevice *dev, qemu_irq *p)
+void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
 {
-    assert(dev->nirqs < ARRAY_SIZE(dev->irqs));
-    dev->irqs[dev->nirqs] = p;
+    assert(dev->nirqs < ARRAY_SIZE(dev->isairq));
+    if (isabus->assigned & (1 << isairq)) {
+        fprintf(stderr, "isa irq %d already assigned\n", isairq);
+        exit(1);
+    }
+    isabus->assigned |= (1 << isairq);
+    dev->isairq[dev->nirqs] = isairq;
+    *p = isabus->irqs[isairq];
     dev->nirqs++;
 }
 
@@ -117,25 +109,17 @@ void isa_qdev_register(ISADeviceInfo *info)
     qdev_register(&info->qdev);
 }
 
-ISADevice *isa_create_simple(const char *name, uint32_t irq, uint32 irq2)
+ISADevice *isa_create_simple(const char *name)
 {
     DeviceState *dev;
-    ISADevice *isa;
 
     if (!isabus) {
         fprintf(stderr, "Tried to create isa device %s with no isa bus present.\n", name);
         return NULL;
     }
     dev = qdev_create(&isabus->qbus, name);
-    isa = DO_UPCAST(ISADevice, qdev, dev);
     qdev_init(dev);
-    if (irq != -1) {
-        isa_connect_irq(isa, 0, irq);
-    }
-    if (irq2 != -1) {
-        isa_connect_irq(isa, 1, irq2);
-    }
-    return isa;
+    return DO_UPCAST(ISADevice, qdev, dev);
 }
 
 static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
diff --git a/hw/isa.h b/hw/isa.h
index 24c5c66..4582ff9 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -13,7 +13,6 @@ typedef struct ISADeviceInfo ISADeviceInfo;
 struct ISADevice {
     DeviceState qdev;
     uint32_t isairq[2];
-    qemu_irq *irqs[2];
     int nirqs;
 };
 
@@ -25,11 +24,10 @@ struct ISADeviceInfo {
 
 ISABus *isa_bus_new(DeviceState *dev);
 void isa_bus_irqs(qemu_irq *irqs);
-void isa_connect_irq(ISADevice *dev, int devirq, int isairq);
 qemu_irq isa_reserve_irq(int isairq);
-void isa_init_irq(ISADevice *dev, qemu_irq *p);
+void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
 void isa_qdev_register(ISADeviceInfo *info);
-ISADevice *isa_create_simple(const char *name, uint32_t irq, uint32_t irq2);
+ISADevice *isa_create_simple(const char *name);
 
 extern target_phys_addr_t isa_mem_base;
 
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 3222e16..32c7102 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -921,7 +921,7 @@ void mips_malta_init (ram_addr_t ram_size,
     DMA_init(0);
 
     /* Super I/O */
-    isa_dev = isa_create_simple("i8042", 1, 12);
+    isa_dev = isa_create_simple("i8042");
  
     rtc_state = rtc_init(0x70, isa_reserve_irq(8), 2000);
     serial_init(0x3f8, isa_reserve_irq(4), 115200, serial_hds[0]);
diff --git a/hw/pc.c b/hw/pc.c
index 0219961..e1ffaa4 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1373,7 +1373,7 @@ static void pc_init1(ram_addr_t ram_size,
         }
     }
 
-    isa_dev = isa_create_simple("i8042", 1, 12);
+    isa_dev = isa_create_simple("i8042");
     DMA_init(0);
 #ifdef HAS_AUDIO
     audio_init(pci_enabled ? pci_bus : NULL, isa_irq);
diff --git a/hw/pckbd.c b/hw/pckbd.c
index b4b65a6..5acf4a6 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -450,8 +450,8 @@ static int i8042_initfn(ISADevice *dev)
 {
     KBDState *s = &(DO_UPCAST(ISAKBDState, dev, dev)->kbd);
 
-    isa_init_irq(dev, &s->irq_kbd);
-    isa_init_irq(dev, &s->irq_mouse);
+    isa_init_irq(dev, &s->irq_kbd, 1);
+    isa_init_irq(dev, &s->irq_mouse, 12);
 
     kbd_reset(s);
     register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
diff --git a/hw/sun4u.c b/hw/sun4u.c
index b71df1f..ffda4cd 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -617,7 +617,7 @@ static void sun4uv_init(ram_addr_t RAM_size,
 
     pci_cmd646_ide_init(pci_bus, hd, 1);
 
-    isa_create_simple("i8042", 1, 12);
+    isa_create_simple("i8042");
     for(i = 0; i < MAX_FD; i++) {
         dinfo = drive_get(IF_FLOPPY, 0, i);
         fd[i] = dinfo ? dinfo->bdrv : NULL;
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 05/12] qdev: tag isabus-bridge as no-user
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 04/12] qdev: simplify isa irq assignments Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 06/12] qdev: add isa_create() function Gerd Hoffmann
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

isabus-bridge isn't supposed to be added via -device ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/isa-bus.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index bfd0fff..3cc17b2 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -145,6 +145,7 @@ static SysBusDeviceInfo isabus_bridge_info = {
     .init = isabus_bridge_init,
     .qdev.name  = "isabus-bridge",
     .qdev.size  = sizeof(SysBusDevice),
+    .qdev.no_user = 1,
 };
 
 static void isabus_register_devices(void)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 06/12] qdev: add isa_create() function
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 05/12] qdev: tag isabus-bridge as no-user Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 07/12] qdev/isa: convert soundblaster Gerd Hoffmann
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Like isa_create_simple, but doesn't call qdev_init, so one can set
properties after creating and before initializing the device.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/isa-bus.c |   15 +++++++++++++--
 hw/isa.h     |    1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 3cc17b2..4ecc0f8 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -109,7 +109,7 @@ void isa_qdev_register(ISADeviceInfo *info)
     qdev_register(&info->qdev);
 }
 
-ISADevice *isa_create_simple(const char *name)
+ISADevice *isa_create(const char *name)
 {
     DeviceState *dev;
 
@@ -118,10 +118,21 @@ ISADevice *isa_create_simple(const char *name)
         return NULL;
     }
     dev = qdev_create(&isabus->qbus, name);
-    qdev_init(dev);
     return DO_UPCAST(ISADevice, qdev, dev);
 }
 
+ISADevice *isa_create_simple(const char *name)
+{
+    ISADevice *dev;
+
+    dev = isa_create(name);
+    if (qdev_init(&dev->qdev) != 0) {
+        qdev_free(&dev->qdev);
+        return NULL;
+    }
+    return dev;
+}
+
 static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
 {
     ISADevice *d = DO_UPCAST(ISADevice, qdev, dev);
diff --git a/hw/isa.h b/hw/isa.h
index 4582ff9..655ad62 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -27,6 +27,7 @@ void isa_bus_irqs(qemu_irq *irqs);
 qemu_irq isa_reserve_irq(int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
 void isa_qdev_register(ISADeviceInfo *info);
+ISADevice *isa_create(const char *name);
 ISADevice *isa_create_simple(const char *name);
 
 extern target_phys_addr_t isa_mem_base;
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 07/12] qdev/isa: convert soundblaster
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 06/12] qdev: add isa_create() function Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 08/12] qdev/isa: convert cs4231a sound card Gerd Hoffmann
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/sb16.c |   63 +++++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 39 insertions(+), 24 deletions(-)

diff --git a/hw/sb16.c b/hw/sb16.c
index ac41a13..4105579 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -25,6 +25,7 @@
 #include "audiodev.h"
 #include "audio/audio.h"
 #include "isa.h"
+#include "qdev.h"
 #include "qemu-timer.h"
 
 #define dolog(...) AUD_log ("sb16", __VA_ARGS__)
@@ -45,23 +46,15 @@
 
 static const char e3[] = "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992.";
 
-static struct {
-    int ver_lo;
-    int ver_hi;
-    int irq;
-    int dma;
-    int hdma;
-    int port;
-} conf = {5, 4, 5, 1, 5, 0x220};
-
 typedef struct SB16State {
+    ISADevice dev;
     QEMUSoundCard card;
     qemu_irq pic;
-    int irq;
-    int dma;
-    int hdma;
-    int port;
-    int ver;
+    uint32_t irq;
+    uint32_t dma;
+    uint32_t hdma;
+    uint32_t port;
+    uint32_t ver;
 
     int in_index;
     int out_data_len;
@@ -1398,22 +1391,17 @@ static int SB_load (QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-int SB16_init (qemu_irq *pic)
+static int sb16_initfn (ISADevice *dev)
 {
-    SB16State *s;
-    int i;
     static const uint8_t dsp_write_ports[] = {0x6, 0xc};
     static const uint8_t dsp_read_ports[] = {0x6, 0xa, 0xc, 0xd, 0xe, 0xf};
+    SB16State *s;
+    int i;
 
-    s = qemu_mallocz (sizeof (*s));
+    s = DO_UPCAST (SB16State, dev, dev);
 
     s->cmd = -1;
-    s->pic = isa_reserve_irq (conf.irq);
-    s->irq = conf.irq;
-    s->dma = conf.dma;
-    s->hdma = conf.hdma;
-    s->port = conf.port;
-    s->ver = conf.ver_lo | (conf.ver_hi << 8);
+    isa_init_irq (dev, &s->pic, s->irq);
 
     s->mixer_regs[0x80] = magic_of_irq (s->irq);
     s->mixer_regs[0x81] = (1 << s->dma) | (1 << s->hdma);
@@ -1449,3 +1437,30 @@ int SB16_init (qemu_irq *pic)
     AUD_register_card ("sb16", &s->card);
     return 0;
 }
+
+int SB16_init (qemu_irq *pic)
+{
+    isa_create_simple("sb16");
+    return 0;
+}
+
+static ISADeviceInfo sb16_info = {
+    .qdev.name     = "sb16",
+    .qdev.desc     = "Creative Sound Blaster 16",
+    .qdev.size     = sizeof (SB16State),
+    .init          = sb16_initfn,
+    .qdev.props    = (Property[]) {
+        DEFINE_PROP_HEX32  ("version", SB16State, ver,  0x0405), /* 4.5 */
+        DEFINE_PROP_HEX32  ("iobase",  SB16State, port, 0x220),
+        DEFINE_PROP_UINT32 ("irq",     SB16State, irq,  5),
+        DEFINE_PROP_UINT32 ("dma",     SB16State, dma,  1),
+        DEFINE_PROP_UINT32 ("dma16",   SB16State, hdma, 5),
+        DEFINE_PROP_END_OF_LIST (),
+    },
+};
+
+static void sb16_register(void)
+{
+    isa_qdev_register(&sb16_info);
+}
+device_init(sb16_register)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 08/12] qdev/isa: convert cs4231a sound card
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 07/12] qdev/isa: convert soundblaster Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 09/12] qdev/isa: convert gravis ultrasound Gerd Hoffmann
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/cs4231a.c |   46 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index 46c71eb..91ee2aa 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -25,6 +25,7 @@
 #include "audiodev.h"
 #include "audio/audio.h"
 #include "isa.h"
+#include "qdev.h"
 #include "qemu-timer.h"
 
 /*
@@ -40,11 +41,8 @@
 /* #define DEBUG_XLAW */
 
 static struct {
-    int irq;
-    int dma;
-    int port;
     int aci_counter;
-} conf = {9, 3, 0x534, 1};
+} conf = {1};
 
 #ifdef DEBUG
 #define dolog(...) AUD_log ("cs4231a", __VA_ARGS__)
@@ -59,12 +57,14 @@ static struct {
 #define CS_DREGS 32
 
 typedef struct CSState {
+    ISADevice dev;
     QEMUSoundCard card;
     qemu_irq pic;
     uint32_t regs[CS_REGS];
     uint8_t dregs[CS_DREGS];
-    int dma;
-    int port;
+    uint32_t irq;
+    uint32_t dma;
+    uint32_t port;
     int shift;
     int dma_running;
     int audio_free;
@@ -635,16 +635,12 @@ static int cs_load (QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-int cs4231a_init (qemu_irq *pic)
+static int cs4231a_initfn (ISADevice *dev)
 {
+    CSState *s = DO_UPCAST (CSState, dev, dev);
     int i;
-    CSState *s;
-
-    s = qemu_mallocz (sizeof (*s));
 
-    s->pic = isa_reserve_irq (conf.irq);
-    s->dma = conf.dma;
-    s->port = conf.port;
+    isa_init_irq (dev, &s->pic, s->irq);
 
     for (i = 0; i < 4; i++) {
         register_ioport_write (s->port + i, 1, 1, cs_write, s);
@@ -660,3 +656,27 @@ int cs4231a_init (qemu_irq *pic)
     AUD_register_card ("cs4231a", &s->card);
     return 0;
 }
+
+int cs4231a_init (qemu_irq *pic)
+{
+    isa_create_simple("cs4231a");
+    return 0;
+}
+
+static ISADeviceInfo cs4231a_info = {
+    .qdev.name     = "cs4231a",
+    .qdev.size     = sizeof (CSState),
+    .init          = cs4231a_initfn,
+    .qdev.props    = (Property[]) {
+        DEFINE_PROP_HEX32  ("iobase",  CSState, port, 0x534),
+        DEFINE_PROP_UINT32 ("irq",     CSState, irq,  9),
+        DEFINE_PROP_UINT32 ("dma",     CSState, dma,  3),
+        DEFINE_PROP_END_OF_LIST (),
+    },
+};
+
+static void cs4231a_register(void)
+{
+    isa_qdev_register(&cs4231a_info);
+}
+device_init(cs4231a_register)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 09/12] qdev/isa: convert gravis ultrasound
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (7 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 08/12] qdev/isa: convert cs4231a sound card Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000 Gerd Hoffmann
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/gus.c    |   75 ++++++++++++++++++++++++++++++++++++++--------------------
 hw/gusemu.h |    4 +-
 2 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/hw/gus.c b/hw/gus.c
index 5e73c5a..b41095e 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -54,16 +54,18 @@ static struct {
 } conf = {0x240, 7, 3, 44100};
 
 typedef struct GUSState {
+    ISADevice dev;
     GUSEmuState emu;
     QEMUSoundCard card;
-    int freq;
+    uint32_t freq;
+    uint32_t port;
     int pos, left, shift, irqs;
     GUSsample *mixbuf;
     uint8_t himem[1024 * 1024 + 32 + 4096];
     int samples;
     SWVoiceOut *voice;
     int64_t last_ticks;
-    qemu_irq *pic;
+    qemu_irq pic;
 } GUSState;
 
 IO_READ_PROTO (gus_readb)
@@ -168,8 +170,8 @@ reset:
 int GUS_irqrequest (GUSEmuState *emu, int hwirq, int n)
 {
     GUSState *s = emu->opaque;
-    /* qemu_irq_lower (s->pic[hwirq]); */
-    qemu_irq_raise (s->pic[hwirq]);
+    /* qemu_irq_lower (s->pic); */
+    qemu_irq_raise (s->pic);
     s->irqs += n;
     ldebug ("irqrequest %d %d %d\n", hwirq, n, s->irqs);
     return n;
@@ -179,7 +181,7 @@ void GUS_irqclear (GUSEmuState *emu, int hwirq)
 {
     GUSState *s = emu->opaque;
     ldebug ("irqclear %d %d\n", hwirq, s->irqs);
-    qemu_irq_lower (s->pic[hwirq]);
+    qemu_irq_lower (s->pic);
     s->irqs -= 1;
 #ifdef IRQ_STORM
     if (s->irqs > 0) {
@@ -250,16 +252,14 @@ static int GUS_load (QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-int GUS_init (qemu_irq *pic)
+static int gus_initfn (ISADevice *dev)
 {
-    GUSState *s;
+    GUSState *s = DO_UPCAST(GUSState, dev, dev);
     struct audsettings as;
 
-    s = qemu_mallocz (sizeof (*s));
-
     AUD_register_card ("gus", &s->card);
 
-    as.freq = conf.freq;
+    as.freq = s->freq;
     as.nchannels = 2;
     as.fmt = AUD_FMT_S16;
     as.endianness = GUS_ENDIANNESS;
@@ -283,34 +283,57 @@ int GUS_init (qemu_irq *pic)
     s->samples = AUD_get_buffer_size_out (s->voice) >> s->shift;
     s->mixbuf = qemu_mallocz (s->samples << s->shift);
 
-    register_ioport_write (conf.port, 1, 1, gus_writeb, s);
-    register_ioport_write (conf.port, 1, 2, gus_writew, s);
+    register_ioport_write (s->port, 1, 1, gus_writeb, s);
+    register_ioport_write (s->port, 1, 2, gus_writew, s);
 
-    register_ioport_read ((conf.port + 0x100) & 0xf00, 1, 1, gus_readb, s);
-    register_ioport_read ((conf.port + 0x100) & 0xf00, 1, 2, gus_readw, s);
+    register_ioport_read ((s->port + 0x100) & 0xf00, 1, 1, gus_readb, s);
+    register_ioport_read ((s->port + 0x100) & 0xf00, 1, 2, gus_readw, s);
 
-    register_ioport_write (conf.port + 6, 10, 1, gus_writeb, s);
-    register_ioport_write (conf.port + 6, 10, 2, gus_writew, s);
-    register_ioport_read (conf.port + 6, 10, 1, gus_readb, s);
-    register_ioport_read (conf.port + 6, 10, 2, gus_readw, s);
+    register_ioport_write (s->port + 6, 10, 1, gus_writeb, s);
+    register_ioport_write (s->port + 6, 10, 2, gus_writew, s);
+    register_ioport_read (s->port + 6, 10, 1, gus_readb, s);
+    register_ioport_read (s->port + 6, 10, 2, gus_readw, s);
 
 
-    register_ioport_write (conf.port + 0x100, 8, 1, gus_writeb, s);
-    register_ioport_write (conf.port + 0x100, 8, 2, gus_writew, s);
-    register_ioport_read (conf.port + 0x100, 8, 1, gus_readb, s);
-    register_ioport_read (conf.port + 0x100, 8, 2, gus_readw, s);
+    register_ioport_write (s->port + 0x100, 8, 1, gus_writeb, s);
+    register_ioport_write (s->port + 0x100, 8, 2, gus_writew, s);
+    register_ioport_read (s->port + 0x100, 8, 1, gus_readb, s);
+    register_ioport_read (s->port + 0x100, 8, 2, gus_readw, s);
 
     DMA_register_channel (conf.dma, GUS_read_DMA, s);
-    s->emu.gusirq = conf.irq;
-    s->emu.gusdma = conf.dma;
     s->emu.himemaddr = s->himem;
     s->emu.gusdatapos = s->emu.himemaddr + 1024 * 1024 + 32;
     s->emu.opaque = s;
-    s->freq = conf.freq;
-    s->pic = pic;
+    isa_init_irq(dev, &s->pic, s->emu.gusirq);
 
     AUD_set_active_out (s->voice, 1);
 
     register_savevm ("gus", 0, 2, GUS_save, GUS_load, s);
     return 0;
 }
+
+int GUS_init (qemu_irq *pic)
+{
+    isa_create_simple("gus");
+    return 0;
+}
+
+static ISADeviceInfo gus_info = {
+    .qdev.name     = "gus",
+    .qdev.desc     = "Creative Sound Blaster 16",
+    .qdev.size     = sizeof (GUSState),
+    .init          = gus_initfn,
+    .qdev.props    = (Property[]) {
+        DEFINE_PROP_UINT32 ("freq",    GUSState, freq,        44100),
+        DEFINE_PROP_HEX32  ("iobase",  GUSState, port,        0x240),
+        DEFINE_PROP_UINT32 ("irq",     GUSState, emu.gusirq,  7),
+        DEFINE_PROP_UINT32 ("dma",     GUSState, emu.gusdma,  3),
+        DEFINE_PROP_END_OF_LIST (),
+    },
+};
+
+static void gus_register(void)
+{
+    isa_qdev_register(&gus_info);
+}
+device_init(gus_register)
diff --git a/hw/gusemu.h b/hw/gusemu.h
index a64300a..5093767 100644
--- a/hw/gusemu.h
+++ b/hw/gusemu.h
@@ -46,8 +46,8 @@ typedef struct _GUSEmuState
 {
  GUSbyte *himemaddr; /* 1024*1024 bytes used for storing uploaded samples (+32 additional bytes for read padding) */
  GUSbyte *gusdatapos; /* (gusdataend-gusdata) bytes used for storing emulated GF1/mixer register states (32*32+4 bytes in initial GUSemu32 version) */
- int gusirq;
- int gusdma;
+ uint32_t gusirq;
+ uint32_t gusdma;
  unsigned int timer1fraction;
  unsigned int timer2fraction;
  void *opaque;
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (8 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 09/12] qdev/isa: convert gravis ultrasound Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 17:29   ` Markus Armbruster
  2009-09-09 17:50   ` Markus Armbruster
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 11/12] qdev/isa: finish pckbd conversion Gerd Hoffmann
                   ` (2 subsequent siblings)
  12 siblings, 2 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Also split the isa bits into a separate source file, so we don't drag in
a dependency for isa-bus.o for machines which want ne2k_pci only.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 Makefile.target |    5 +-
 hw/mips_r4k.c   |    2 +-
 hw/ne2000-isa.c |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/ne2000.c     |  106 +++++++++-------------------------------------------
 hw/ne2000.h     |   40 ++++++++++++++++++++
 hw/pc.c         |    2 +-
 hw/pc.h         |    2 +-
 hw/ppc_prep.c   |    2 +-
 8 files changed, 177 insertions(+), 93 deletions(-)
 create mode 100644 hw/ne2000-isa.c
 create mode 100644 hw/ne2000.h

diff --git a/Makefile.target b/Makefile.target
index 67bd4d7..2c03877 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -188,13 +188,14 @@ obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
 obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
 obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
 obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
+obj-i386-y += ne2000-isa.o
 
 # shared objects
 obj-ppc-y = ppc.o ide/core.o ide/isa.o ide/pci.o ide/macio.o
 obj-ppc-y += vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o
 # PREP target
 obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o
-obj-ppc-y += prep_pci.o ppc_prep.o
+obj-ppc-y += prep_pci.o ppc_prep.o ne2000-isa.o
 # Mac shared devices
 obj-ppc-y += macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o
 # OldWorld PowerMac
@@ -215,7 +216,7 @@ obj-mips-y += g364fb.o jazz_led.o dp8393x.o
 obj-mips-y += ide/core.o ide/isa.o ide/pci.o
 obj-mips-y += gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
 obj-mips-y += piix4.o parallel.o cirrus_vga.o isa-bus.o pcspk.o $(sound-obj-y)
-obj-mips-y += mipsnet.o
+obj-mips-y += mipsnet.o ne2000-isa.o
 obj-mips-y += pflash_cfi01.o
 obj-mips-y += vmware_vga.o
 
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index da5ca31..aacb256 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -260,7 +260,7 @@ void mips_r4k_init (ram_addr_t ram_size,
     isa_vga_init();
 
     if (nd_table[0].vlan)
-        isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
+        isa_ne2000_init(0x300, 9, &nd_table[0]);
 
     if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
         fprintf(stderr, "qemu: too many IDE bus\n");
diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c
new file mode 100644
index 0000000..3120035
--- /dev/null
+++ b/hw/ne2000-isa.c
@@ -0,0 +1,111 @@
+/*
+ * QEMU NE2000 emulation -- isa bus windup
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw.h"
+#include "pc.h"
+#include "isa.h"
+#include "qdev.h"
+#include "net.h"
+#include "ne2000.h"
+
+typedef struct ISANE2000State {
+    ISADevice dev;
+    uint32_t iobase;
+    uint32_t isairq;
+    NE2000State ne2000;
+} ISANE2000State;
+
+static void isa_ne2000_cleanup(VLANClientState *vc)
+{
+    NE2000State *s = vc->opaque;
+    ISANE2000State *isa = container_of(s, ISANE2000State, ne2000);
+
+    unregister_savevm("ne2000", s);
+
+    isa_unassign_ioport(isa->iobase, 16);
+    isa_unassign_ioport(isa->iobase + 0x10, 2);
+    isa_unassign_ioport(isa->iobase + 0x1f, 1);
+
+    qemu_free(s);
+}
+
+static int isa_ne2000_initfn(ISADevice *dev)
+{
+    ISANE2000State *isa = DO_UPCAST(ISANE2000State, dev, dev);
+    NE2000State *s = &isa->ne2000;
+
+    register_ioport_write(isa->iobase, 16, 1, ne2000_ioport_write, s);
+    register_ioport_read(isa->iobase, 16, 1, ne2000_ioport_read, s);
+
+    register_ioport_write(isa->iobase + 0x10, 1, 1, ne2000_asic_ioport_write, s);
+    register_ioport_read(isa->iobase + 0x10, 1, 1, ne2000_asic_ioport_read, s);
+    register_ioport_write(isa->iobase + 0x10, 2, 2, ne2000_asic_ioport_write, s);
+    register_ioport_read(isa->iobase + 0x10, 2, 2, ne2000_asic_ioport_read, s);
+
+    register_ioport_write(isa->iobase + 0x1f, 1, 1, ne2000_reset_ioport_write, s);
+    register_ioport_read(isa->iobase + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
+
+    isa_init_irq(dev, &s->irq, isa->isairq);
+
+    register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
+    return 0;
+}
+
+void isa_ne2000_init(int base, int irq, NICInfo *nd)
+{
+    ISADevice *dev;
+    NE2000State *s;
+
+    qemu_check_nic_model(nd, "ne2k_isa");
+
+    dev = isa_create("ne2k_isa");
+    qdev_prop_set_uint32(&dev->qdev, "iobase", base);
+    qdev_prop_set_uint32(&dev->qdev, "irq",    irq);
+    qdev_init(&dev->qdev);
+
+    s = &DO_UPCAST(ISANE2000State, dev, dev)->ne2000;
+    memcpy(s->macaddr, nd->macaddr, 6);
+    ne2000_reset(s); /* needs macaddr */
+    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+                                          ne2000_can_receive, ne2000_receive,
+                                          NULL, isa_ne2000_cleanup, s);
+    qemu_format_nic_info_str(s->vc, s->macaddr);
+}
+
+static ISADeviceInfo ne2000_isa_info = {
+    .qdev.name  = "ne2k_isa",
+    .qdev.size  = sizeof(ISANE2000State),
+    .init       = isa_ne2000_initfn,
+    .qdev.props = (Property[]) {
+        DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0x300),
+        DEFINE_PROP_UINT32("irq",   ISANE2000State, isairq, 9),
+        DEFINE_PROP_END_OF_LIST(),
+    },
+};
+
+static void ne2000_isa_register_devices(void)
+{
+    isa_qdev_register(&ne2000_isa_info);
+}
+
+device_init(ne2000_isa_register_devices)
diff --git a/hw/ne2000.c b/hw/ne2000.c
index bdfc9ed..cde64be 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -25,6 +25,7 @@
 #include "pci.h"
 #include "pc.h"
 #include "net.h"
+#include "ne2000.h"
 
 /* debug NE2000 card */
 //#define DEBUG_NE2000
@@ -116,42 +117,19 @@
 #define ENTSR_CDH 0x40	/* The collision detect "heartbeat" signal was lost. */
 #define ENTSR_OWC 0x80  /* There was an out-of-window collision. */
 
-#define NE2000_PMEM_SIZE    (32*1024)
-#define NE2000_PMEM_START   (16*1024)
-#define NE2000_PMEM_END     (NE2000_PMEM_SIZE+NE2000_PMEM_START)
-#define NE2000_MEM_SIZE     NE2000_PMEM_END
-
-typedef struct NE2000State {
-    uint8_t cmd;
-    uint32_t start;
-    uint32_t stop;
-    uint8_t boundary;
-    uint8_t tsr;
-    uint8_t tpsr;
-    uint16_t tcnt;
-    uint16_t rcnt;
-    uint32_t rsar;
-    uint8_t rsr;
-    uint8_t rxcr;
-    uint8_t isr;
-    uint8_t dcfg;
-    uint8_t imr;
-    uint8_t phys[6]; /* mac address */
-    uint8_t curpag;
-    uint8_t mult[8]; /* multicast mask array */
-    qemu_irq irq;
-    int isa_io_base;
-    VLANClientState *vc;
-    uint8_t macaddr[6];
-    uint8_t mem[NE2000_MEM_SIZE];
-} NE2000State;
-
 typedef struct PCINE2000State {
     PCIDevice dev;
     NE2000State ne2000;
 } PCINE2000State;
 
-static void ne2000_reset(NE2000State *s)
+typedef struct ISANE2000State {
+    ISADevice dev;
+    uint32_t iobase;
+    uint32_t isairq;
+    NE2000State ne2000;
+} ISANE2000State;
+
+void ne2000_reset(NE2000State *s)
 {
     int i;
 
@@ -217,7 +195,7 @@ static int ne2000_buffer_full(NE2000State *s)
     return 0;
 }
 
-static int ne2000_can_receive(VLANClientState *vc)
+int ne2000_can_receive(VLANClientState *vc)
 {
     NE2000State *s = vc->opaque;
 
@@ -228,7 +206,7 @@ static int ne2000_can_receive(VLANClientState *vc)
 
 #define MIN_BUF_SIZE 60
 
-static ssize_t ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size_)
+ssize_t ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size_)
 {
     NE2000State *s = vc->opaque;
     int size = size_;
@@ -325,7 +303,7 @@ static ssize_t ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t si
     return size_;
 }
 
-static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
 {
     NE2000State *s = opaque;
     int offset, page, index;
@@ -422,7 +400,7 @@ static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     }
 }
 
-static uint32_t ne2000_ioport_read(void *opaque, uint32_t addr)
+uint32_t ne2000_ioport_read(void *opaque, uint32_t addr)
 {
     NE2000State *s = opaque;
     int offset, page, ret;
@@ -572,7 +550,7 @@ static inline void ne2000_dma_update(NE2000State *s, int len)
     }
 }
 
-static void ne2000_asic_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+void ne2000_asic_ioport_write(void *opaque, uint32_t addr, uint32_t val)
 {
     NE2000State *s = opaque;
 
@@ -592,7 +570,7 @@ static void ne2000_asic_ioport_write(void *opaque, uint32_t addr, uint32_t val)
     }
 }
 
-static uint32_t ne2000_asic_ioport_read(void *opaque, uint32_t addr)
+uint32_t ne2000_asic_ioport_read(void *opaque, uint32_t addr)
 {
     NE2000State *s = opaque;
     int ret;
@@ -640,19 +618,19 @@ static uint32_t ne2000_asic_ioport_readl(void *opaque, uint32_t addr)
     return ret;
 }
 
-static void ne2000_reset_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+void ne2000_reset_ioport_write(void *opaque, uint32_t addr, uint32_t val)
 {
     /* nothing to do (end of reset pulse) */
 }
 
-static uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr)
+uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr)
 {
     NE2000State *s = opaque;
     ne2000_reset(s);
     return 0;
 }
 
-static void ne2000_save(QEMUFile* f, void* opaque)
+void ne2000_save(QEMUFile* f, void* opaque)
 {
 	NE2000State* s = opaque;
         uint32_t tmp;
@@ -680,7 +658,7 @@ 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)
+int ne2000_load(QEMUFile* f, void* opaque, int version_id)
 {
 	NE2000State* s = opaque;
         uint32_t tmp;
@@ -741,52 +719,6 @@ static int pci_ne2000_load(QEMUFile* f, void* opaque, int version_id)
         return ne2000_load(f, &s->ne2000, version_id);
 }
 
-static void isa_ne2000_cleanup(VLANClientState *vc)
-{
-    NE2000State *s = vc->opaque;
-
-    unregister_savevm("ne2000", s);
-
-    isa_unassign_ioport(s->isa_io_base, 16);
-    isa_unassign_ioport(s->isa_io_base + 0x10, 2);
-    isa_unassign_ioport(s->isa_io_base + 0x1f, 1);
-
-    qemu_free(s);
-}
-
-void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
-{
-    NE2000State *s;
-
-    qemu_check_nic_model(nd, "ne2k_isa");
-
-    s = qemu_mallocz(sizeof(NE2000State));
-
-    register_ioport_write(base, 16, 1, ne2000_ioport_write, s);
-    register_ioport_read(base, 16, 1, ne2000_ioport_read, s);
-
-    register_ioport_write(base + 0x10, 1, 1, ne2000_asic_ioport_write, s);
-    register_ioport_read(base + 0x10, 1, 1, ne2000_asic_ioport_read, s);
-    register_ioport_write(base + 0x10, 2, 2, ne2000_asic_ioport_write, s);
-    register_ioport_read(base + 0x10, 2, 2, ne2000_asic_ioport_read, s);
-
-    register_ioport_write(base + 0x1f, 1, 1, ne2000_reset_ioport_write, s);
-    register_ioport_read(base + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
-    s->isa_io_base = base;
-    s->irq = irq;
-    memcpy(s->macaddr, nd->macaddr, 6);
-
-    ne2000_reset(s);
-
-    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                          ne2000_can_receive, ne2000_receive,
-                                          NULL, isa_ne2000_cleanup, s);
-
-    qemu_format_nic_info_str(s->vc, s->macaddr);
-
-    register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
-}
-
 /***********************************************************/
 /* PCI NE2000 definitions */
 
diff --git a/hw/ne2000.h b/hw/ne2000.h
new file mode 100644
index 0000000..92a2ddb
--- /dev/null
+++ b/hw/ne2000.h
@@ -0,0 +1,40 @@
+#define NE2000_PMEM_SIZE    (32*1024)
+#define NE2000_PMEM_START   (16*1024)
+#define NE2000_PMEM_END     (NE2000_PMEM_SIZE+NE2000_PMEM_START)
+#define NE2000_MEM_SIZE     NE2000_PMEM_END
+
+typedef struct NE2000State {
+    uint8_t cmd;
+    uint32_t start;
+    uint32_t stop;
+    uint8_t boundary;
+    uint8_t tsr;
+    uint8_t tpsr;
+    uint16_t tcnt;
+    uint16_t rcnt;
+    uint32_t rsar;
+    uint8_t rsr;
+    uint8_t rxcr;
+    uint8_t isr;
+    uint8_t dcfg;
+    uint8_t imr;
+    uint8_t phys[6]; /* mac address */
+    uint8_t curpag;
+    uint8_t mult[8]; /* multicast mask array */
+    qemu_irq irq;
+    VLANClientState *vc;
+    uint8_t macaddr[6];
+    uint8_t mem[NE2000_MEM_SIZE];
+} NE2000State;
+
+void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val);
+uint32_t ne2000_ioport_read(void *opaque, uint32_t addr);
+void ne2000_asic_ioport_write(void *opaque, uint32_t addr, uint32_t val);
+uint32_t ne2000_asic_ioport_read(void *opaque, uint32_t addr);
+void ne2000_reset_ioport_write(void *opaque, uint32_t addr, uint32_t val);
+uint32_t ne2000_reset_ioport_read(void *opaque, uint32_t addr);
+void ne2000_save(QEMUFile* f, void* opaque);
+int ne2000_load(QEMUFile* f, void* opaque, int version_id);
+void ne2000_reset(NE2000State *s);
+int ne2000_can_receive(VLANClientState *vc);
+ssize_t ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size_);
diff --git a/hw/pc.c b/hw/pc.c
index e1ffaa4..9497f71 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1052,7 +1052,7 @@ static void pc_init_ne2k_isa(NICInfo *nd)
     if (nb_ne2k == NE2000_NB_MAX)
         return;
     isa_ne2000_init(ne2000_io[nb_ne2k],
-                    isa_reserve_irq(ne2000_irq[nb_ne2k]), nd);
+                    ne2000_irq[nb_ne2k], nd);
     nb_ne2k++;
 }
 
diff --git a/hw/pc.h b/hw/pc.h
index ec5735b..d80d3a5 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -148,7 +148,7 @@ void isa_cirrus_vga_init(void);
 
 /* ne2000.c */
 
-void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd);
+void isa_ne2000_init(int base, int irq, NICInfo *nd);
 
 int cpu_is_bsp(CPUState *env);
 #endif
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 3fbfc8b..994c965 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -691,7 +691,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
 	    nd_table[i].model = "ne2k_isa";
         }
         if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
-            isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
+            isa_ne2000_init(ne2000_io[i], ne2000_irq[i], &nd_table[i]);
         } else {
             pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
         }
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 11/12] qdev/isa: finish pckbd conversion
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (9 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000 Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 12/12] qdev/isa: convert real time clock Gerd Hoffmann
  2009-09-09 17:56 ` [Qemu-devel] [PATCH 00/12] qdev isa patches Markus Armbruster
  12 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

drop old init path and switch remaining users to
isa_create_simple().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/mips_r4k.c |    4 +++-
 hw/pckbd.c    |   22 ----------------------
 hw/ppc_prep.c |    2 +-
 3 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index aacb256..ae265a0 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -241,6 +241,8 @@ void mips_r4k_init (ram_addr_t ram_size,
 
     /* The PIC is attached to the MIPS CPU INT0 pin */
     i8259 = i8259_init(env->irq[2]);
+    isa_bus_new(NULL);
+    isa_bus_irqs(i8259);
 
     rtc_state = rtc_init(0x70, i8259[8], 2000);
 
@@ -276,7 +278,7 @@ void mips_r4k_init (ram_addr_t ram_size,
                      hd[MAX_IDE_DEVS * i],
 		     hd[MAX_IDE_DEVS * i + 1]);
 
-    i8042_init(i8259[1], i8259[12], 0x60);
+    isa_create_simple("i8042");
 }
 
 static QEMUMachine mips_machine = {
diff --git a/hw/pckbd.c b/hw/pckbd.c
index 5acf4a6..3d573c2 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -362,28 +362,6 @@ static int kbd_load(QEMUFile* f, void* opaque, int version_id)
     return 0;
 }
 
-void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base)
-{
-    KBDState *s = &kbd_state;
-
-    s->irq_kbd = kbd_irq;
-    s->irq_mouse = mouse_irq;
-
-    kbd_reset(s);
-    register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
-    register_ioport_read(io_base, 1, 1, kbd_read_data, s);
-    register_ioport_write(io_base, 1, 1, kbd_write_data, s);
-    register_ioport_read(io_base + 4, 1, 1, kbd_read_status, s);
-    register_ioport_write(io_base + 4, 1, 1, kbd_write_command, s);
-
-    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);
-}
-
 /* Memory mapped interface */
 static uint32_t kbd_mm_readb (void *opaque, target_phys_addr_t addr)
 {
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 994c965..0bab6d7 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -711,7 +711,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
                      hd[2 * i],
 		     hd[2 * i + 1]);
     }
-    i8042_init(i8259[1], i8259[12], 0x60);
+    isa_create_simple("i8042");
     DMA_init(1);
     //    SB16_init();
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH 12/12] qdev/isa: convert real time clock
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (10 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 11/12] qdev/isa: finish pckbd conversion Gerd Hoffmann
@ 2009-09-09 14:45 ` Gerd Hoffmann
  2009-09-09 19:43   ` [Qemu-devel] " Gerd Hoffmann
  2009-09-09 17:56 ` [Qemu-devel] [PATCH 00/12] qdev isa patches Markus Armbruster
  12 siblings, 1 reply; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 14:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/mc146818rtc.c |   41 +++++++++++++++++++++++++++++++----------
 hw/mips_jazz.c   |    2 +-
 hw/mips_malta.c  |    2 +-
 hw/mips_r4k.c    |    2 +-
 hw/pc.c          |    2 +-
 hw/pc.h          |    3 +--
 hw/ppc_prep.c    |    2 +-
 7 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 5c8676e..2741139 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -63,10 +63,11 @@
 #define REG_C_AF   0x20
 
 struct RTCState {
+    ISADevice dev;
     uint8_t cmos_data[128];
     uint8_t cmos_index;
     struct tm current_tm;
-    int base_year;
+    uint32_t base_year;
     qemu_irq irq;
     qemu_irq sqw_irq;
     int it_shift;
@@ -588,20 +589,19 @@ static void rtc_reset(void *opaque)
 #endif
 }
 
-RTCState *rtc_init_sqw(int base, qemu_irq irq, qemu_irq sqw_irq, int base_year)
+static int rtc_initfn(ISADevice *dev)
 {
-    RTCState *s;
+    RTCState *s = DO_UPCAST(RTCState, dev, dev);
+    int base = 0x70;
+    int isairq = 8;
 
-    s = qemu_mallocz(sizeof(RTCState));
+    isa_init_irq(dev, &s->irq, isairq);
 
-    s->irq = irq;
-    s->sqw_irq = sqw_irq;
     s->cmos_data[RTC_REG_A] = 0x26;
     s->cmos_data[RTC_REG_B] = 0x02;
     s->cmos_data[RTC_REG_C] = 0x00;
     s->cmos_data[RTC_REG_D] = 0x80;
 
-    s->base_year = base_year;
     rtc_set_date_from_host(s);
 
     s->periodic_timer = qemu_new_timer(vm_clock,
@@ -627,14 +627,35 @@ RTCState *rtc_init_sqw(int base, qemu_irq irq, qemu_irq sqw_irq, int base_year)
         register_savevm("mc146818rtc-td", base, 1, rtc_save_td, rtc_load_td, s);
 #endif
     qemu_register_reset(rtc_reset, s);
-
-    return s;
+    return 0;
 }
 
-RTCState *rtc_init(int base, qemu_irq irq, int base_year)
+RTCState *rtc_init(int base_year)
+{
+    ISADevice *dev;
+
+    dev = isa_create("mc146818rtc");
+    qdev_prop_set_uint32(&dev->qdev, "base_year", base_year);
+    qdev_init(&dev->qdev);
+    return DO_UPCAST(RTCState, dev, dev);
+}
+
+static ISADeviceInfo mc146818rtc_info = {
+    .qdev.name     = "mc146818rtc",
+    .qdev.size     = sizeof(RTCState),
+    .qdev.no_user  = 1,
+    .init          = rtc_initfn,
+    .qdev.props    = (Property[]) {
+        DEFINE_PROP_UINT32("base_year", RTCState, base_year, 1980),
+        DEFINE_PROP_END_OF_LIST(),
+    }
+};
+
+static void mc146818rtc_register(void)
 {
-    return rtc_init_sqw(base, irq, NULL, base_year);
+    isa_qdev_register(&mc146818rtc_info);
 }
+device_init(mc146818rtc_register)
 
 /* Memory mapped interface */
 static uint32_t cmos_mm_readb (void *opaque, target_phys_addr_t addr)
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 1cbd947..d62a584 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -241,7 +241,7 @@ void mips_jazz_init (ram_addr_t ram_size,
     fdctrl_init_sysbus(rc4030[1], 0, 0x80003000, fds);
 
     /* Real time clock */
-    rtc_init(0x70, i8259[8], 1980);
+    rtc_init(1980);
     s_rtc = cpu_register_io_memory(rtc_read, rtc_write, env);
     cpu_register_physical_memory(0x80004000, 0x00001000, s_rtc);
 
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 32c7102..25e32bf 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -923,7 +923,7 @@ void mips_malta_init (ram_addr_t ram_size,
     /* Super I/O */
     isa_dev = isa_create_simple("i8042");
  
-    rtc_state = rtc_init(0x70, isa_reserve_irq(8), 2000);
+    rtc_state = rtc_init(2000);
     serial_init(0x3f8, isa_reserve_irq(4), 115200, serial_hds[0]);
     serial_init(0x2f8, isa_reserve_irq(3), 115200, serial_hds[1]);
     if (parallel_hds[0])
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index ae265a0..d801417 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -244,7 +244,7 @@ void mips_r4k_init (ram_addr_t ram_size,
     isa_bus_new(NULL);
     isa_bus_irqs(i8259);
 
-    rtc_state = rtc_init(0x70, i8259[8], 2000);
+    rtc_state = rtc_init(2000);
 
     /* Register 64 KB of ISA IO space at 0x14000000 */
     isa_mmio_init(0x14000000, 0x00010000);
diff --git a/hw/pc.c b/hw/pc.c
index 9497f71..d96d756 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1313,7 +1313,7 @@ static void pc_init1(ram_addr_t ram_size,
         }
     }
 
-    rtc_state = rtc_init(0x70, isa_reserve_irq(8), 2000);
+    rtc_state = rtc_init(2000);
 
     qemu_register_boot_set(pc_boot_set, rtc_state);
 
diff --git a/hw/pc.h b/hw/pc.h
index d80d3a5..c9cdd4a 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -81,8 +81,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
 
 typedef struct RTCState RTCState;
 
-RTCState *rtc_init(int base, qemu_irq irq, int base_year);
-RTCState *rtc_init_sqw(int base, qemu_irq irq, qemu_irq sqw_irq, int base_year);
+RTCState *rtc_init(int base_year);
 RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
                       int base_year);
 void rtc_set_memory(RTCState *s, int addr, int val);
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 0bab6d7..2b39f4d 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -680,7 +680,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
     pci_vga_init(pci_bus, 0, 0);
     //    openpic = openpic_init(0x00000000, 0xF0000000, 1);
     //    pit = pit_init(0x40, i8259[0]);
-    rtc_init(0x70, i8259[8], 2000);
+    rtc_init(2000);
 
     serial_init(0x3f8, i8259[4], 115200, serial_hds[0]);
     nb_nics1 = nb_nics;
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000 Gerd Hoffmann
@ 2009-09-09 17:29   ` Markus Armbruster
  2009-09-09 17:50   ` Markus Armbruster
  1 sibling, 0 replies; 20+ messages in thread
From: Markus Armbruster @ 2009-09-09 17:29 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Gerd Hoffmann <kraxel@redhat.com> writes:

> Also split the isa bits into a separate source file, so we don't drag in
> a dependency for isa-bus.o for machines which want ne2k_pci only.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Review would be easier if the split was a separate commit that doesn't
change code.  No need to respin.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000 Gerd Hoffmann
  2009-09-09 17:29   ` Markus Armbruster
@ 2009-09-09 17:50   ` Markus Armbruster
  2009-09-09 19:58     ` Gerd Hoffmann
  1 sibling, 1 reply; 20+ messages in thread
From: Markus Armbruster @ 2009-09-09 17:50 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Gerd Hoffmann <kraxel@redhat.com> writes:

> Also split the isa bits into a separate source file, so we don't drag in
> a dependency for isa-bus.o for machines which want ne2k_pci only.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Closer examination led to a few questions...

> ---
>  Makefile.target |    5 +-
>  hw/mips_r4k.c   |    2 +-
>  hw/ne2000-isa.c |  111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/ne2000.c     |  106 +++++++++-------------------------------------------
>  hw/ne2000.h     |   40 ++++++++++++++++++++
>  hw/pc.c         |    2 +-
>  hw/pc.h         |    2 +-
>  hw/ppc_prep.c   |    2 +-
>  8 files changed, 177 insertions(+), 93 deletions(-)
>  create mode 100644 hw/ne2000-isa.c
>  create mode 100644 hw/ne2000.h
>
> diff --git a/Makefile.target b/Makefile.target
> index 67bd4d7..2c03877 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -188,13 +188,14 @@ obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
>  obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
>  obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
>  obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
> +obj-i386-y += ne2000-isa.o
>  
>  # shared objects
>  obj-ppc-y = ppc.o ide/core.o ide/isa.o ide/pci.o ide/macio.o
>  obj-ppc-y += vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o
>  # PREP target
>  obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o
> -obj-ppc-y += prep_pci.o ppc_prep.o
> +obj-ppc-y += prep_pci.o ppc_prep.o ne2000-isa.o
>  # Mac shared devices
>  obj-ppc-y += macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o
>  # OldWorld PowerMac
> @@ -215,7 +216,7 @@ obj-mips-y += g364fb.o jazz_led.o dp8393x.o
>  obj-mips-y += ide/core.o ide/isa.o ide/pci.o
>  obj-mips-y += gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
>  obj-mips-y += piix4.o parallel.o cirrus_vga.o isa-bus.o pcspk.o $(sound-obj-y)
> -obj-mips-y += mipsnet.o
> +obj-mips-y += mipsnet.o ne2000-isa.o
>  obj-mips-y += pflash_cfi01.o
>  obj-mips-y += vmware_vga.o
>  
> diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
> index da5ca31..aacb256 100644
> --- a/hw/mips_r4k.c
> +++ b/hw/mips_r4k.c
> @@ -260,7 +260,7 @@ void mips_r4k_init (ram_addr_t ram_size,
>      isa_vga_init();
>  
>      if (nd_table[0].vlan)
> -        isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
> +        isa_ne2000_init(0x300, 9, &nd_table[0]);
>  
>      if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
>          fprintf(stderr, "qemu: too many IDE bus\n");
> diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c
> new file mode 100644
> index 0000000..3120035
> --- /dev/null
> +++ b/hw/ne2000-isa.c
> @@ -0,0 +1,111 @@
> +/*
> + * QEMU NE2000 emulation -- isa bus windup
> + *
> + * Copyright (c) 2003-2004 Fabrice Bellard
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a copy
> + * of this software and associated documentation files (the "Software"), to deal
> + * in the Software without restriction, including without limitation the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> + * copies of the Software, and to permit persons to whom the Software is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> + * THE SOFTWARE.
> + */
> +#include "hw.h"
> +#include "pc.h"
> +#include "isa.h"
> +#include "qdev.h"
> +#include "net.h"
> +#include "ne2000.h"
> +
> +typedef struct ISANE2000State {
> +    ISADevice dev;
> +    uint32_t iobase;
> +    uint32_t isairq;
> +    NE2000State ne2000;
> +} ISANE2000State;
> +
> +static void isa_ne2000_cleanup(VLANClientState *vc)
> +{
> +    NE2000State *s = vc->opaque;
> +    ISANE2000State *isa = container_of(s, ISANE2000State, ne2000);
> +
> +    unregister_savevm("ne2000", s);
> +
> +    isa_unassign_ioport(isa->iobase, 16);
> +    isa_unassign_ioport(isa->iobase + 0x10, 2);
> +    isa_unassign_ioport(isa->iobase + 0x1f, 1);
> +
> +    qemu_free(s);
> +}
> +
> +static int isa_ne2000_initfn(ISADevice *dev)
> +{
> +    ISANE2000State *isa = DO_UPCAST(ISANE2000State, dev, dev);
> +    NE2000State *s = &isa->ne2000;
> +
> +    register_ioport_write(isa->iobase, 16, 1, ne2000_ioport_write, s);
> +    register_ioport_read(isa->iobase, 16, 1, ne2000_ioport_read, s);
> +
> +    register_ioport_write(isa->iobase + 0x10, 1, 1, ne2000_asic_ioport_write, s);
> +    register_ioport_read(isa->iobase + 0x10, 1, 1, ne2000_asic_ioport_read, s);
> +    register_ioport_write(isa->iobase + 0x10, 2, 2, ne2000_asic_ioport_write, s);
> +    register_ioport_read(isa->iobase + 0x10, 2, 2, ne2000_asic_ioport_read, s);
> +
> +    register_ioport_write(isa->iobase + 0x1f, 1, 1, ne2000_reset_ioport_write, s);
> +    register_ioport_read(isa->iobase + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
> +
> +    isa_init_irq(dev, &s->irq, isa->isairq);
> +
> +    register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
> +    return 0;
> +}
> +
> +void isa_ne2000_init(int base, int irq, NICInfo *nd)

Nitpick: in qdev parlance, this function is a create_simple, not an
init.

> +{
> +    ISADevice *dev;
> +    NE2000State *s;
> +
> +    qemu_check_nic_model(nd, "ne2k_isa");
> +
> +    dev = isa_create("ne2k_isa");
> +    qdev_prop_set_uint32(&dev->qdev, "iobase", base);
> +    qdev_prop_set_uint32(&dev->qdev, "irq",    irq);
> +    qdev_init(&dev->qdev);
> +

Shouldn't the rest be in isa_ne2000_initfn()?  Think of -device, which
doesn't go through this function...

> +    s = &DO_UPCAST(ISANE2000State, dev, dev)->ne2000;
> +    memcpy(s->macaddr, nd->macaddr, 6);
> +    ne2000_reset(s); /* needs macaddr */
> +    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
> +                                          ne2000_can_receive, ne2000_receive,
> +                                          NULL, isa_ne2000_cleanup, s);

Shouldn't this use qdev_get_vlan_client(), like the other qdevified
NICs?

> +    qemu_format_nic_info_str(s->vc, s->macaddr);
> +}
> +
> +static ISADeviceInfo ne2000_isa_info = {
> +    .qdev.name  = "ne2k_isa",
> +    .qdev.size  = sizeof(ISANE2000State),
> +    .init       = isa_ne2000_initfn,
> +    .qdev.props = (Property[]) {
> +        DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0x300),
> +        DEFINE_PROP_UINT32("irq",   ISANE2000State, isairq, 9),
> +        DEFINE_PROP_END_OF_LIST(),
> +    },
> +};
> +
> +static void ne2000_isa_register_devices(void)
> +{
> +    isa_qdev_register(&ne2000_isa_info);
> +}
> +
> +device_init(ne2000_isa_register_devices)
> diff --git a/hw/ne2000.c b/hw/ne2000.c
> index bdfc9ed..cde64be 100644
> --- a/hw/ne2000.c
> +++ b/hw/ne2000.c
> @@ -25,6 +25,7 @@
>  #include "pci.h"
>  #include "pc.h"
>  #include "net.h"
> +#include "ne2000.h"
>  
>  /* debug NE2000 card */
>  //#define DEBUG_NE2000
> @@ -116,42 +117,19 @@
>  #define ENTSR_CDH 0x40	/* The collision detect "heartbeat" signal was lost. */
>  #define ENTSR_OWC 0x80  /* There was an out-of-window collision. */
>  
> -#define NE2000_PMEM_SIZE    (32*1024)
> -#define NE2000_PMEM_START   (16*1024)
> -#define NE2000_PMEM_END     (NE2000_PMEM_SIZE+NE2000_PMEM_START)
> -#define NE2000_MEM_SIZE     NE2000_PMEM_END
> -
> -typedef struct NE2000State {
> -    uint8_t cmd;
> -    uint32_t start;
> -    uint32_t stop;
> -    uint8_t boundary;
> -    uint8_t tsr;
> -    uint8_t tpsr;
> -    uint16_t tcnt;
> -    uint16_t rcnt;
> -    uint32_t rsar;
> -    uint8_t rsr;
> -    uint8_t rxcr;
> -    uint8_t isr;
> -    uint8_t dcfg;
> -    uint8_t imr;
> -    uint8_t phys[6]; /* mac address */
> -    uint8_t curpag;
> -    uint8_t mult[8]; /* multicast mask array */
> -    qemu_irq irq;
> -    int isa_io_base;
> -    VLANClientState *vc;
> -    uint8_t macaddr[6];
> -    uint8_t mem[NE2000_MEM_SIZE];
> -} NE2000State;
> -
>  typedef struct PCINE2000State {
>      PCIDevice dev;
>      NE2000State ne2000;
>  } PCINE2000State;
>  
> -static void ne2000_reset(NE2000State *s)
> +typedef struct ISANE2000State {
> +    ISADevice dev;
> +    uint32_t iobase;
> +    uint32_t isairq;
> +    NE2000State ne2000;
> +} ISANE2000State;

ISANE2000State doesn't belong here, and isn't used as far as I can see.

> +
> +void ne2000_reset(NE2000State *s)
>  {
>      int i;
>  
[...]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 00/12] qdev isa patches.
  2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
                   ` (11 preceding siblings ...)
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 12/12] qdev/isa: convert real time clock Gerd Hoffmann
@ 2009-09-09 17:56 ` Markus Armbruster
  12 siblings, 0 replies; 20+ messages in thread
From: Markus Armbruster @ 2009-09-09 17:56 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Gerd Hoffmann <kraxel@redhat.com> writes:

>   Hi,
>
> Here is a batch of patches for the isa bus and isa bus devices.  qdev
> support for the isa bus is reworked a bit, following up the default
> value discussion with Markus.  A few devices are converted to qdev.
> Some bugs (like -M isapc segfaulting) are fixed along the way.
>
> As usual the individual patches have more verbose descriptions.
>
> cheers,
>   Gerd

The whole series looks good to me, except for "[PATCH 10/12] qdev/isa:
convert ne2000"; see my comments there.

After "[PATCH 03/12] qdev: drop iobase properties from isa bus", ISA I/O
bases are no longer visible in info qdev.  I think that's okay.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Qemu-devel] Re: [PATCH 12/12] qdev/isa: convert real time clock
  2009-09-09 14:45 ` [Qemu-devel] [PATCH 12/12] qdev/isa: convert real time clock Gerd Hoffmann
@ 2009-09-09 19:43   ` Gerd Hoffmann
  2009-09-11  9:29     ` Jan Kiszka
  0 siblings, 1 reply; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 19:43 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

> --- a/hw/mc146818rtc.c
> +++ b/hw/mc146818rtc.c
> @@ -63,10 +63,11 @@
>   #define REG_C_AF   0x20
>
>   struct RTCState {
> +    ISADevice dev;
>       uint8_t cmos_data[128];
>       uint8_t cmos_index;
>       struct tm current_tm;
> -    int base_year;
> +    uint32_t base_year;

Self-NACK.  This sign change breaks some math and makes my VMs 
time-travel to 2005 ...

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000
  2009-09-09 17:50   ` Markus Armbruster
@ 2009-09-09 19:58     ` Gerd Hoffmann
  0 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2009-09-09 19:58 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel

>> +
>> +void isa_ne2000_init(int base, int irq, NICInfo *nd)
>
> Nitpick: in qdev parlance, this function is a create_simple, not an
> init.

Long-term I want zap that anyway ...

>> +{
>> +    ISADevice *dev;
>> +    NE2000State *s;
>> +
>> +    qemu_check_nic_model(nd, "ne2k_isa");
>> +
>> +    dev = isa_create("ne2k_isa");
>> +    qdev_prop_set_uint32(&dev->qdev, "iobase", base);
>> +    qdev_prop_set_uint32(&dev->qdev, "irq",    irq);
>> +    qdev_init(&dev->qdev);
>> +
>
> Shouldn't the rest be in isa_ne2000_initfn()?  Think of -device, which
> doesn't go through this function...

It should.  Need to figure a way to handle that nicely though, see below.

Right now you can't create a single nic via -device because they are not 
yet completely qdev-ified.  ne2k_isa is no exception here ;)

>> +    s =&DO_UPCAST(ISANE2000State, dev, dev)->ne2000;
>> +    memcpy(s->macaddr, nd->macaddr, 6);
>> +    ne2000_reset(s); /* needs macaddr */
>> +    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
>> +                                          ne2000_can_receive, ne2000_receive,
>> +                                          NULL, isa_ne2000_cleanup, s);
>
> Shouldn't this use qdev_get_vlan_client(), like the other qdevified
> NICs?

Have a close look at this vlan stuff is on my todo list.  Right now it 
is a big hack.  DeviceState->nd must go away, likewise 
qdev_get_vlan_client() and qdev_get_macaddr().  Instead do something 
sane using properties.

>> +typedef struct ISANE2000State {
>> +    ISADevice dev;
>> +    uint32_t iobase;
>> +    uint32_t isairq;
>> +    NE2000State ne2000;
>> +} ISANE2000State;
>
> ISANE2000State doesn't belong here, and isn't used as far as I can see.

Indeed.

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Qemu-devel] Re: [PATCH 12/12] qdev/isa: convert real time clock
  2009-09-09 19:43   ` [Qemu-devel] " Gerd Hoffmann
@ 2009-09-11  9:29     ` Jan Kiszka
  2009-09-11  9:32       ` Jan Kiszka
  0 siblings, 1 reply; 20+ messages in thread
From: Jan Kiszka @ 2009-09-11  9:29 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Anthony Liguori, qemu-devel

Gerd Hoffmann wrote:
>> --- a/hw/mc146818rtc.c
>> +++ b/hw/mc146818rtc.c
>> @@ -63,10 +63,11 @@
>>   #define REG_C_AF   0x20
>>
>>   struct RTCState {
>> +    ISADevice dev;
>>       uint8_t cmos_data[128];
>>       uint8_t cmos_index;
>>       struct tm current_tm;
>> -    int base_year;
>> +    uint32_t base_year;
> 
> Self-NACK.  This sign change breaks some math and makes my VMs
> time-travel to 2005 ...
> 

I thought you retracted this patch, but now I find it in master. Is
there fix in the queue?

To err is human, and the more patches are committed, the more errors can
happen. Still, my impression is that the current rate could be lower.
Gerd, maybe you should have CC'ed Anthony for the NACK.

Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Qemu-devel] Re: [PATCH 12/12] qdev/isa: convert real time clock
  2009-09-11  9:29     ` Jan Kiszka
@ 2009-09-11  9:32       ` Jan Kiszka
  0 siblings, 0 replies; 20+ messages in thread
From: Jan Kiszka @ 2009-09-11  9:32 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Anthony Liguori, qemu-devel

Jan Kiszka wrote:
> Gerd Hoffmann wrote:
>>> --- a/hw/mc146818rtc.c
>>> +++ b/hw/mc146818rtc.c
>>> @@ -63,10 +63,11 @@
>>>   #define REG_C_AF   0x20
>>>
>>>   struct RTCState {
>>> +    ISADevice dev;
>>>       uint8_t cmos_data[128];
>>>       uint8_t cmos_index;
>>>       struct tm current_tm;
>>> -    int base_year;
>>> +    uint32_t base_year;
>> Self-NACK.  This sign change breaks some math and makes my VMs
>> time-travel to 2005 ...
>>
> 
> I thought you retracted this patch, but now I find it in master. Is
> there fix in the queue?
> 
> To err is human, and the more patches are committed, the more errors can
> happen. Still, my impression is that the current rate could be lower.
> Gerd, maybe you should have CC'ed Anthony for the NACK.
> 

Err, sorry, wrong alarm, v2 got merged.

Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-09-11  9:32 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-09 14:45 [Qemu-devel] [PATCH 00/12] qdev isa patches Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 01/12] isapc: Fix irq routing Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 02/12] isapc: pick a more sane default cpu for such old hardware Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 03/12] qdev: drop iobase properties from isa bus Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 04/12] qdev: simplify isa irq assignments Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 05/12] qdev: tag isabus-bridge as no-user Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 06/12] qdev: add isa_create() function Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 07/12] qdev/isa: convert soundblaster Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 08/12] qdev/isa: convert cs4231a sound card Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 09/12] qdev/isa: convert gravis ultrasound Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 10/12] qdev/isa: convert ne2000 Gerd Hoffmann
2009-09-09 17:29   ` Markus Armbruster
2009-09-09 17:50   ` Markus Armbruster
2009-09-09 19:58     ` Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 11/12] qdev/isa: finish pckbd conversion Gerd Hoffmann
2009-09-09 14:45 ` [Qemu-devel] [PATCH 12/12] qdev/isa: convert real time clock Gerd Hoffmann
2009-09-09 19:43   ` [Qemu-devel] " Gerd Hoffmann
2009-09-11  9:29     ` Jan Kiszka
2009-09-11  9:32       ` Jan Kiszka
2009-09-09 17:56 ` [Qemu-devel] [PATCH 00/12] qdev isa patches Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).