Skip to contentSkip to conversation

prep: some fixes and Super I/O emulation

PATCH In review Hervé Poussineau 6 participants 20 messages Mar 17, 2012 – Jun 1, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

cover prep: some fixes and Super I/O emulation

Hi,

First two patches repair some functionality broken since 2009! Debian install root floppy can now be started again.

Patches 4 to 6 implement the pc87312 Super I/O chip. Some versions by me or by Andreas Färber have already been sent on mailing list. This patch has been tested on PReP emulation and on IBM 40p (not yet committed).

Hervé Poussineau (6):
i82378/i82374: do not create DMA controller twice
prep: change default cpu to '7448'
isa: add isa_bus_from_device() method
fdc: Parametrize ISA base, IRQ and DMA
prep: add pc87312 Super I/O emulation
prep: use pc87312 Super I/O chip instead of collection of random ISA
devices

 Makefile.objs                   |    1 +
 default-configs/ppc-softmmu.mak |    2 +
 hw/fdc.c                        |   17 +-
 hw/i82374.c                     |    5 +-
 hw/i82378.c                     |    5 +-
 hw/isa.h                        |    5 +
 hw/pc87312.c                    |  425 +++++++++++++++++++++++++++++++++++++++
 hw/ppc_prep.c                   |   52 ++---
 8 files changed, 469 insertions(+), 43 deletions(-)
 create mode 100644 hw/pc87312.c
Signature · 1 line
1.7.9.1
#1 lore raw

PATCH 1/6 i82378/i82374: do not create DMA controller twice

This fixes a crash in PReP emulation when using DMA controller to access floppy drive.

---
 hw/i82374.c |    5 ++++-
 hw/i82378.c |    5 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)
hw/i82374.c +4 -1
index 67298a3..4a922c3 100644
@@ -38,6 +38,7 @@ do { fprintf(stderr, "i82374 ERROR: " fmt , ## __VA_ARGS__); } while (0)
 
 typedef struct I82374State {
     uint8_t commands[8];
+    qemu_irq out;
 } I82374State;
 
 static const VMStateDescription vmstate_i82374 = {
@@ -99,7 +100,7 @@ static uint32_t i82374_read_descriptor(void *opaque, uint32_t nport)
 
 static void i82374_init(I82374State *s)
 {
-    DMA_init(1, NULL);
+    DMA_init(1, &s->out);
     memset(s->commands, 0, sizeof(s->commands));
 }
 
@@ -132,6 +133,8 @@ static int i82374_isa_init(ISADevice *dev)
 
     i82374_init(s);
 
+    qdev_init_gpio_out(&dev->qdev, &s->out, 1);
+
     return 0;
 }
 
hw/i82378.c +3 -2
index faad1a3..9b11d90 100644
@@ -170,6 +170,7 @@ static void i82378_init(DeviceState *dev, I82378State *s)
 {
     ISABus *isabus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(dev, "isa.0"));
     ISADevice *pit;
+    ISADevice *isa;
     qemu_irq *out0_irq;
 
     /* This device has:
@@ -199,8 +200,8 @@ static void i82378_init(DeviceState *dev, I82378State *s)
     pcspk_init(isabus, pit);
 
     /* 2 82C37 (dma) */
-    DMA_init(1, &s->out[1]);
-    isa_create_simple(isabus, "i82374");
+    isa = isa_create_simple(isabus, "i82374");
+    qdev_connect_gpio_out(&isa->qdev, 0, s->out[1]);
 
     /* timer */
     isa_create_simple(isabus, "mc146818rtc");
Signature · 1 line
1.7.9.1
Reviewed-by on v1 1/6
#2 lore raw

Re: [Qemu-devel] [PATCH 1/6] i82378/i82374: do not create DMA controller twice

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 3 lines

This fixes a crash in PReP emulation when using DMA controller to access floppy drive.

Andreas

Quoted 58 lines
---
 hw/i82374.c |    5 ++++-
 hw/i82378.c |    5 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)
hw/i82374.c +4 -1
index 67298a3..4a922c3 100644
@@ -38,6 +38,7 @@ do { fprintf(stderr, "i82374 ERROR: " fmt , ## __VA_ARGS__); } while (0)
 
 typedef struct I82374State {
     uint8_t commands[8];
+    qemu_irq out;
 } I82374State;
 
 static const VMStateDescription vmstate_i82374 = {
@@ -99,7 +100,7 @@ static uint32_t i82374_read_descriptor(void *opaque, uint32_t nport)
 
 static void i82374_init(I82374State *s)
 {
-    DMA_init(1, NULL);
+    DMA_init(1, &s->out);
     memset(s->commands, 0, sizeof(s->commands));
 }
 
@@ -132,6 +133,8 @@ static int i82374_isa_init(ISADevice *dev)
 
     i82374_init(s);
 
+    qdev_init_gpio_out(&dev->qdev, &s->out, 1);
+
     return 0;
 }
 
hw/i82378.c +3 -2
index faad1a3..9b11d90 100644
@@ -170,6 +170,7 @@ static void i82378_init(DeviceState *dev, I82378State *s)
 {
     ISABus *isabus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(dev, "isa.0"));
     ISADevice *pit;
+    ISADevice *isa;
     qemu_irq *out0_irq;
 
     /* This device has:
@@ -199,8 +200,8 @@ static void i82378_init(DeviceState *dev, I82378State *s)
     pcspk_init(isabus, pit);
 
     /* 2 82C37 (dma) */
-    DMA_init(1, &s->out[1]);
-    isa_create_simple(isabus, "i82374");
+    isa = isa_create_simple(isabus, "i82374");
+    qdev_connect_gpio_out(&isa->qdev, 0, s->out[1]);
 
     /* timer */
     isa_create_simple(isabus, "mc146818rtc");
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#3 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/6] i82378/i82374: do not create DMA controller twice

Quoted 6 lines · Andreas Färber

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 3 lines

This fixes a crash in PReP emulation when using DMA controller to access floppy drive.

Why only reviewed? You're the PREP maintainer and this bug shows with PREP, so I don't see why this shouldn't go through your tree :).

Alex

#4 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/6] i82378/i82374: do not create DMA controller twice

Am 19.03.2012 12:23, schrieb Alexander Graf:

Quoted 11 lines · Andreas Färber
Quoted 7 lines

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 3 lines

This fixes a crash in PReP emulation when using DMA controller to access floppy drive.

Why only reviewed?

Because I didn't test and apply it yet :) before reading through the whole series and rebasing prep-up branch. I like feedback to my patches, so I provide some myself (and get journaling in my outbox as a bonus).

Quoted 1 line

You're the PREP maintainer and this bug shows with PREP, so I don't see why this shouldn't go through your tree :).

Correct apart from the spelling, and no one said it should go through you or the ppc tree. Relax and have a nice vacation! I never noticed you flaming Anthony for reviewing patches he is going to apply later on... ;)

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#5 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/6] i82378/i82374: do not create DMA controller twice

Quoted 17 lines · Andreas Färber

Am 19.03.2012 12:23, schrieb Alexander Graf:

Quoted 11 lines · Andreas Färber
Quoted 7 lines

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 3 lines

This fixes a crash in PReP emulation when using DMA controller to access floppy drive.

Why only reviewed?

Because I didn't test and apply it yet :) before reading through the whole series and rebasing prep-up branch. I like feedback to my patches, so I provide some myself (and get journaling in my outbox as a bonus).

Quoted 5 lines
Quoted 1 line

You're the PREP maintainer and this bug shows with PREP, so I don't see why this shouldn't go through your tree :).

Correct apart from the spelling, and no one said it should go through you or the ppc tree. Relax and have a nice vacation! I never noticed you flaming Anthony for reviewing patches he is going to apply later on... ;)

Oh, sorry, it sounded like "Reviewed, someone else please apply it". I didn't think of the case where you'd pick it up yourself later :).

Alex

#6 lore raw

PATCH 2/6 prep: change default cpu to '7448'

In reply to Hervé Poussineau

In b37fc148bb81b5b022846156a6cba266e6c23962, PReP default cpu was changed from 'default' to '602'. However, '7448' is closer of 'default' than '602'.

This repairs following command line, which is available in some tutorials:
qemu-system-ppc -kernel zImage.prep -fda debian_install_root.bin -M prep

---
 hw/ppc_prep.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/ppc_prep.c +1 -1
index 06d589d..19a674f 100644
@@ -517,7 +517,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
 
     /* init CPUs */
     if (cpu_model == NULL)
-        cpu_model = "602";
+        cpu_model = "7448";
     for (i = 0; i < smp_cpus; i++) {
         env = cpu_init(cpu_model);
         if (!env) {
Signature · 1 line
1.7.9.1
#7 lore raw

Re: [Qemu-devel] [PATCH 2/6] prep: change default cpu to '7448'

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 8 lines

In b37fc148bb81b5b022846156a6cba266e6c23962, PReP default cpu was changed from 'default' to '602'. However, '7448' is closer of 'default' than '602'.

This repairs following command line, which is available in some tutorials:
qemu-system-ppc -kernel zImage.prep -fda debian_install_root.bin -M prep

Weak nack. I guess this depends more on the image than on the command line. If at this point we change the default CPU for -M prep, we would need to start creating prep-1.0 etc. which I would like to avoid as long as possible...

Did you happen to found out which physical machine 'prep' corresponds to? If so, what CPU did it have?
The Sandalfoot supposedly had a 601, the BeBox a dual 603.

Andreas

Quoted 17 lines
---
 hw/ppc_prep.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/ppc_prep.c +1 -1
index 06d589d..19a674f 100644
@@ -517,7 +517,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
 
     /* init CPUs */
     if (cpu_model == NULL)
-        cpu_model = "602";
+        cpu_model = "7448";
     for (i = 0; i < smp_cpus; i++) {
         env = cpu_init(cpu_model);
         if (!env) {
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#8 lore raw

Re: [Qemu-devel] [PATCH 2/6] prep: change default cpu to '7448'

Quoted 7 lines · Andreas Färber

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 6 lines

In b37fc148bb81b5b022846156a6cba266e6c23962, PReP default cpu was changed from 'default' to '602'. However, '7448' is closer of 'default' than '602'.

This repairs following command line, which is available in some tutorials:
qemu-system-ppc -kernel zImage.prep -fda debian_install_root.bin -M prep

Quoted 7 lines
Quoted 2 lines

Weak nack. I guess this depends more on the image than on the command line. If at this point we change the default CPU for -M prep, we would need to start creating prep-1.0 etc. which I would like to avoid as long as possible...

I'm using floppy images available at
http://archive.debian.org/debian/dists/woody/main/disks-powerpc/current/prep/images-1.44/
more specifically root.bin
The default cpu has already been changed once between 0.11 and 0.12, so I think it's not impossible to change it once more. Moreover, I don't think prep emulation is used in any production environment...

Quoted 3 lines

Did you happen to found out which physical machine 'prep' corresponds to? If so, what CPU did it have?

It seems that 'prep' emulates a Motorola, maybe the PowerStack/BlackHack, but I'm not sure...

Quoted 1 line

The Sandalfoot supposedly had a 601, the BeBox a dual 603.

With 601, Open Hack'Ware doesn't work.
With 602, the Debian installer doesn't start.
With 603, the Debian installer starts.
With 604, Open Hack'Ware doesn't work.

Will you accept a patch to change '602' to '603'?

Hervé

#9 lore raw

Re: [Qemu-devel] [PATCH 2/6] prep: change default cpu to '7448'

In reply to Andreas Färber
Quoted 7 lines · Andreas Färber

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 6 lines

In b37fc148bb81b5b022846156a6cba266e6c23962, PReP default cpu was changed from 'default' to '602'. However, '7448' is closer of 'default' than '602'.

This repairs following command line, which is available in some tutorials:
qemu-system-ppc -kernel zImage.prep -fda debian_install_root.bin -M prep

Quoted 7 lines
Quoted 2 lines

Weak nack. I guess this depends more on the image than on the command line. If at this point we change the default CPU for -M prep, we would need to start creating prep-1.0 etc. which I would like to avoid as long as possible...

I'm using floppy images available at
http://archive.debian.org/debian/dists/woody/main/disks-powerpc/current/prep/images-1.44/
more specifically root.bin
The default cpu has already been changed once between 0.11 and 0.12, so I think it's not impossible to change it once more. Moreover, I'm not sure PReP emulation is used in any real environment...

Quoted 3 lines

Did you happen to found out which physical machine 'prep' corresponds to? If so, what CPU did it have?

It seems that 'prep' emulates a Motorola, maybe the PowerStack/BlackHack, but I'm not sure...

Quoted 1 line

The Sandalfoot supposedly had a 601, the BeBox a dual 603.

With 601, Open Hack'Ware doesn't work.
With 602, the Debian installer doesn't start.
With 603, the Debian installer starts.
With 604, Open Hack'Ware doesn't work.

Will you accept a patch to change '602' to '603'?

Hervé

#10 lore raw

PATCH 3/6 isa: add isa_bus_from_device() method

In reply to Hervé Poussineau
---
 hw/isa.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
hw/isa.h +5 -0
index 40373fb..f7bc4b5 100644
@@ -76,6 +76,11 @@ void isa_register_portio_list(ISADevice *dev, uint16_t start,
                               const MemoryRegionPortio *portio,
                               void *opaque, const char *name);
 
+static inline ISABus *isa_bus_from_device(ISADevice *d)
+{
+    return DO_UPCAST(ISABus, qbus, d->qdev.parent_bus);
+}
+
 extern target_phys_addr_t isa_mem_base;
 
 void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
Signature · 1 line
1.7.9.1
#11 lore raw

PATCH 4/6 fdc: Parametrize ISA base, IRQ and DMA

In reply to Hervé Poussineau

Keep the PC values as defaults but allow to override them for PReP.

---
 hw/fdc.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
hw/fdc.c +10 -7
index a0236b7..756d4ce 100644
@@ -438,6 +438,9 @@ typedef struct FDCtrlSysBus {
 
 typedef struct FDCtrlISABus {
     ISADevice busdev;
+    uint32_t iobase;
+    uint32_t irq;
+    uint32_t dma;
     struct FDCtrl state;
     int32_t bootindexA;
     int32_t bootindexB;
@@ -1971,17 +1974,14 @@ static int isabus_fdc_init1(ISADevice *dev)
 {
     FDCtrlISABus *isa = DO_UPCAST(FDCtrlISABus, busdev, dev);
     FDCtrl *fdctrl = &isa->state;
-    int iobase = 0x3f0;
-    int isairq = 6;
-    int dma_chann = 2;
     int ret;
 
-    isa_register_portio_list(dev, iobase, fdc_portio_list, fdctrl, "fdc");
+    isa_register_portio_list(dev, isa->iobase, fdc_portio_list, fdctrl, "fdc");
 
-    isa_init_irq(&isa->busdev, &fdctrl->irq, isairq);
-    fdctrl->dma_chann = dma_chann;
+    isa_init_irq(&isa->busdev, &fdctrl->irq, isa->irq);
+    fdctrl->dma_chann = isa->dma;
 
-    qdev_set_legacy_instance_id(&dev->qdev, iobase, 2);
+    qdev_set_legacy_instance_id(&dev->qdev, isa->iobase, 2);
     ret = fdctrl_init_common(fdctrl);
 
     add_boot_device_path(isa->bootindexA, &dev->qdev, "/floppy@0");
@@ -2046,6 +2046,9 @@ static const VMStateDescription vmstate_isa_fdc ={
 };
 
 static Property isa_fdc_properties[] = {
+    DEFINE_PROP_HEX32("iobase", FDCtrlISABus, iobase, 0x3f0),
+    DEFINE_PROP_UINT32("irq", FDCtrlISABus, irq, 6),
+    DEFINE_PROP_UINT32("dma", FDCtrlISABus, dma, 2),
     DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].bs),
     DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].bs),
     DEFINE_PROP_INT32("bootindexA", FDCtrlISABus, bootindexA, -1),
Signature · 1 line
1.7.9.1
#13 lore raw

PATCH 5/6 prep: add pc87312 Super I/O emulation

In reply to Hervé Poussineau

This provides floppy and IDE controllers as well as serial and parallel ports. However, dynamic configuration of devices is not yet supported.

---
 Makefile.objs |    1 +
 hw/pc87312.c  |  425 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 426 insertions(+), 0 deletions(-)
 create mode 100644 hw/pc87312.c
Makefile.objs +1 -0
index 226b01d..232eed0 100644
@@ -252,6 +252,7 @@ hw-obj-$(CONFIG_I8259) += i8259_common.o i8259.o
 # PPC devices
 hw-obj-$(CONFIG_PREP_PCI) += prep_pci.o
 hw-obj-$(CONFIG_I82378) += i82378.o
+hw-obj-$(CONFIG_PC87312) += pc87312.o
 # Mac shared devices
 hw-obj-$(CONFIG_MACIO) += macio.o
 hw-obj-$(CONFIG_CUDA) += cuda.o
hw/pc87312.c new file +425 -0

425 lines not on this page · raw message

Signature · 1 line
1.7.9.1
#14 lore raw

Re: [Qemu-devel] [PATCH 5/6] prep: add pc87312 Super I/O emulation

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 17 lines

This provides floppy and IDE controllers as well as serial and parallel ports. However, dynamic configuration of devices is not yet supported.

---
 Makefile.objs |    1 +
 hw/pc87312.c  |  425 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 426 insertions(+), 0 deletions(-)
 create mode 100644 hw/pc87312.c
hw/pc87312.c new file +0 -0
new file mode 100644
index 0000000..1e28dbd

hw/pc87312.c line 4

Quoted 4 lines
hw/pc87312.c new file +4 -0
@@ -0,0 +1,425 @@
+/*
+ * QEMU National Semiconductor PC87312 (Super I/O)
+ *
+ * Copyright (c) 2010-2012 Herve Poussineau

FWIW mind to add

Copyright (c) 2011 Andreas Färber

?

Quoted 19 lines
hw/pc87312.c new file +19 -0
+ *
+ * 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.
+ */

hw/pc87312.c line 37

Quoted 10 lines
hw/pc87312.c new file +9 -0
 
+//#define DEBUG_PC87312
+
+#ifdef DEBUG_PC87312
+#define DPRINTF(fmt, ...) \
+do { fprintf(stderr, "pc87312: " fmt , ## __VA_ARGS__); } while (0)
+#else
+#define DPRINTF(fmt, ...) \
+do {} while (0)
+#endif

Mid-term we should replace this through proper tracing.

Quoted 5 lines
hw/pc87312.c new file +5 -0
+static int pc87312_init(ISADevice *dev)
+{
+    PC87312State *s;
+    ISADevice *isa;
+    ISABus *bus;

hw/pc87312.c line 313

Quoted 10 lines
hw/pc87312.c new file +10 -0
+    CharDriverState *chr;
+    BlockDriverState *bs;
+    int i;
+
+    s = DO_UPCAST(PC87312State, dev, dev);
+    bus = isa_bus_from_device(dev);
+    pc87312_hard_reset(s);
+
+    chr = s->parallel.chr;
+    if (s->parallel.chr != NULL && is_parallel_enabled(s)) {

This logic still seems to be flawed: it should not depend on s->parallel.chr. If that is NULL we need to create a null char device to match the device that's present in hardware according to is_parallel_enabled(s).

Quoted 1 line

+ qemu_chr_add_handlers(chr, NULL, NULL, NULL, NULL); /* HACK */

HACK alarm in [PATCH]: What for?

Quoted 6 lines
hw/pc87312.c new file +6 -0
+        isa = isa_create(bus, "isa-parallel");
+        qdev_prop_set_uint32(&isa->qdev, "index", 0);
+        qdev_prop_set_uint32(&isa->qdev, "iobase", get_parallel_iobase(s));
+        qdev_prop_set_uint32(&isa->qdev, "irq", get_parallel_irq(s));
+        qdev_prop_set_chr(&isa->qdev, "chardev", chr);
+        qdev_init_nofail(&isa->qdev);

hw/pc87312.c line 329

Quoted 10 lines
hw/pc87312.c new file +9 -0
+        s->parallel.dev = &isa->qdev;
+        DPRINTF("parallel: base 0x%x, irq %u\n",
+                get_parallel_iobase(s), get_parallel_irq(s));
+    }
+
+    for (i = 0; i < 2; i++) {
+        chr = s->uart[i].chr;
 
+        if (chr != NULL && is_uart_enabled(s, i)) {
+            qemu_chr_add_handlers(chr, NULL, NULL, NULL, NULL); /* HACK */

2x ditto.

Quoted 62 lines
hw/pc87312.c new file +62 -0
+            isa = isa_create(bus, "isa-serial");
+            qdev_prop_set_uint32(&isa->qdev, "index", i);
+            qdev_prop_set_uint32(&isa->qdev, "iobase", get_uart_iobase(s, i));
+            qdev_prop_set_uint32(&isa->qdev, "irq", get_uart_irq(s, i));
+            qdev_prop_set_chr(&isa->qdev, "chardev", chr);
+            qdev_init_nofail(&isa->qdev);
+            s->uart[i].dev = &isa->qdev;
+            DPRINTF("uart%d: base 0x%x, irq %u\n", i,
+                    get_uart_iobase(s, i),
+                    get_uart_irq(s, i));
+        }
+    }
+
+    if (is_fdc_enabled(s)) {
+        isa = isa_create(bus, "isa-fdc");
+        qdev_prop_set_uint32(&isa->qdev, "iobase", get_fdc_iobase(s));
+        qdev_prop_set_uint32(&isa->qdev, "irq", 6);
+        bs = s->fdc.drive[0];
+        if (bs != NULL) {
+            bdrv_detach_dev(bs, bdrv_get_attached_dev(bs)); /* HACK */
+            qdev_prop_set_drive_nofail(&isa->qdev, "driveA", bs);
+        }
+        bs = s->fdc.drive[1];
+        if (bs != NULL) {
+            bdrv_detach_dev(bs, bdrv_get_attached_dev(bs)); /* HACK */
+            qdev_prop_set_drive_nofail(&isa->qdev, "driveB", bs);
+        }
+        qdev_init_nofail(&isa->qdev);
+        s->fdc.dev = &isa->qdev;
+        DPRINTF("fdc: base 0x%x\n", get_fdc_iobase(s));
+    }
+
+    if (is_ide_enabled(s)) {
+        isa = isa_create(bus, "isa-ide");
+        qdev_prop_set_uint32(&isa->qdev, "iobase", get_ide_iobase(s));
+        qdev_prop_set_uint32(&isa->qdev, "iobase2", get_ide_iobase(s) + 0x206);
+        qdev_prop_set_uint32(&isa->qdev, "irq", 14);
+        qdev_init_nofail(&isa->qdev);
+        s->ide.dev = &isa->qdev;
+        DPRINTF("ide: base 0x%x\n", get_ide_iobase(s));
+    }
+
+    register_ioport_write(s->iobase, 2, 1, pc87312_ioport_write, s);
+    register_ioport_read(s->iobase, 2, 1, pc87312_ioport_read, s);
+    return 0;
+}
+
+static const VMStateDescription vmstate_pc87312 = {
+    .name = "pc87312",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .post_load = pc87312_post_load,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8(read_id_step, PC87312State),
+        VMSTATE_UINT8(selected_index, PC87312State),
+        VMSTATE_UINT8_ARRAY(regs, PC87312State, 3),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static Property pc87312_properties[] = {
+    DEFINE_PROP_HEX32("iobase", PC87312State, iobase, 0x398),

hw/pc87312.c line 401

Quoted 10 lines
hw/pc87312.c new file +10 -0
+    DEFINE_PROP_UINT8("config", PC87312State, config, 1),
+    DEFINE_PROP_CHR("parallel", PC87312State, parallel.chr),
+    DEFINE_PROP_CHR("uart1", PC87312State, uart[0].chr),
+    DEFINE_PROP_CHR("uart2", PC87312State, uart[1].chr),
+    DEFINE_PROP_DRIVE("floppyA", PC87312State, fdc.drive[0]),
+    DEFINE_PROP_DRIVE("floppyB", PC87312State, fdc.drive[1]),
+    DEFINE_PROP_END_OF_LIST()
+};
+
+static void pc87312_class_initfn(ObjectClass *klass, void *data)

I always thought initfn was used for instances...

Quoted 14 lines
hw/pc87312.c new file +14 -0
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
+
+    ic->init = pc87312_init;
+    dc->reset = pc87312_reset;
+    dc->vmsd = &vmstate_pc87312;
+    dc->props = pc87312_properties;
+}
+
+static TypeInfo pc87312_info = {
+    .name          = "pc87312",
+    .parent        = TYPE_ISA_DEVICE,
+    .instance_size = sizeof(PC87312State),

hw/pc87312.c line 425

Quoted 10 lines
hw/pc87312.c new file +10 -0
+    .class_init    = pc87312_class_initfn,
+};
+
+static void pc87312_register_types(void)
+{
+    type_register_static(&pc87312_info);
+}
+
+type_init(pc87312_register_types)
+

Trailing empty line.

So what about the ugly ISA hot-plug issue that originally stalled our two series? I'm missing a Change Log about that. You changed the initial configuration to the one used by 40P firmware IIRC and stopped supporting the chipset's reconfiguration? Either way any limitation of this implementation should be prominently documented please.

Thanks for your work on this,

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#15 lore raw

Re: [Qemu-devel] [PATCH 5/6] prep: add pc87312 Super I/O emulation

Quoted 25 lines · Andreas Färber

Am 17.03.2012 15:39, schrieb Hervé Poussineau:

Quoted 17 lines

This provides floppy and IDE controllers as well as serial and parallel ports. However, dynamic configuration of devices is not yet supported.

---
 Makefile.objs |    1 +
 hw/pc87312.c  |  425 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 426 insertions(+), 0 deletions(-)
 create mode 100644 hw/pc87312.c
hw/pc87312.c new file +0 -0
new file mode 100644
index 0000000..1e28dbd

hw/pc87312.c line 4

Quoted 4 lines
hw/pc87312.c new file +4 -0
@@ -0,0 +1,425 @@
+/*
+ * QEMU National Semiconductor PC87312 (Super I/O)
+ *
+ * Copyright (c) 2010-2012 Herve Poussineau

FWIW mind to add

Quoted 3 lines

Copyright (c) 2011 Andreas Färber

?

Yes, of course. Sorry about that.

Quoted 8 lines

hw/pc87312.c line 313

Quoted 3 lines
hw/pc87312.c new file +3 -0
+
+    chr = s->parallel.chr;
+    if (s->parallel.chr != NULL && is_parallel_enabled(s)) {

This logic still seems to be flawed: it should not depend on s->parallel.chr. If that is NULL we need to create a null char device to match the device that's present in hardware according to is_parallel_enabled(s).

Ok, will remove the 'chr != NULL' check.

Quoted 4 lines

hw/pc87312.c line 8

Quoted 2 lines
hw/pc87312.c new file +1 -0
+        qemu_chr_add_handlers(chr, NULL, NULL, NULL, NULL); /* HACK */

HACK alarm in [PATCH]: What for?

The problem is composition. Main board contains a pc87312, which contains a isa-parallel. Main board doesn't know the isa-parallel device.

isa-parallel device must have a chardev (set by a property). pc87312 creates the isa-parallel device, so it must know the chardev. I did it also with a chardev property. Unfortunately, a chardev can only be used once, and I have not found a better way to give chardev from main board to superI/O to parallel.
Do you have any better idea?

Quoted 7 lines

hw/pc87312.c line 329

Quoted 5 lines
hw/pc87312.c new file +4 -0
+    for (i = 0; i < 2; i++) {
+        chr = s->uart[i].chr;
 
+        if (chr != NULL && is_uart_enabled(s, i)) {
+            qemu_chr_add_handlers(chr, NULL, NULL, NULL, NULL); /* HACK */

2x ditto.

Same answer :)

Quoted 4 lines

hw/pc87312.c line 401

Quoted 2 lines
hw/pc87312.c new file +2 -0
+
+static void pc87312_class_initfn(ObjectClass *klass, void *data)

I always thought initfn was used for instances...

Ok, will change to pc87312_class_init

Quoted 5 lines

hw/pc87312.c line 425

Quoted 3 lines
hw/pc87312.c new file +3 -0
+
+type_init(pc87312_register_types)
+

Trailing empty line.

Ok, will remove.

Quoted 6 lines

So what about the ugly ISA hot-plug issue that originally stalled our two series? I'm missing a Change Log about that. You changed the initial configuration to the one used by 40P firmware IIRC and stopped supporting the chipset's reconfiguration? Either way any limitation of this implementation should be prominently documented please.

Yes, chipset reconfiguration required ISA hot-plug issue, so I didn't want to wait for this serie. In commit message, I wrote "However, dynamic configuration of devices is not yet supported.", and you get an error message at each reconfiguration:

+static void reconfigure_devices(PC87312State *s)
+{
+ error_report("pc87312: unsupported device reconfiguration (%02x %02x %02x)",
+ s->FER, s->FAR, s->PTR);
+}

What else should I add?
Anyway, if/when dynamic reconfiguration will be implemented, only this method will be changed.

About the initial configuration, it is controlled by "config" property.
In patch 6/6, when I use the Super I/O chip in 'prep' machine, I set this property to 13, which means fdc + serial0 + serial1 + parallel0. For IBM 40p, the initial configuration should be 15 (fdc + ide + serial0 + parallel0).
So I don't think the Super I/O is exclusively tied to IBM 40p.

Quoted 2 lines

Thanks for your work on this,

Thanks

Hervé

#16 lore raw

PATCH 6/6 prep: use pc87312 Super I/O chip instead of collection of random ISA devices

In reply to Hervé Poussineau

We can't however replace the built-in IDE controller, as the one in pc87312 is only single-channel and can use only IRQ 14.

---
 default-configs/ppc-softmmu.mak |    2 +
 hw/ppc_prep.c                   |   50 ++++++++++++++-------------------------
 2 files changed, 20 insertions(+), 32 deletions(-)
default-configs/ppc-softmmu.mak +2 -0
index 1a768fc..14568b3 100644
@@ -8,6 +8,7 @@ CONFIG_M48T59=y
 CONFIG_VGA=y
 CONFIG_VGA_PCI=y
 CONFIG_SERIAL=y
+CONFIG_PARALLEL=y
 CONFIG_I8254=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
@@ -16,6 +17,7 @@ CONFIG_I82374=y
 CONFIG_OPENPIC=y
 CONFIG_PREP_PCI=y
 CONFIG_I82378=y
+CONFIG_PC87312=y
 CONFIG_MACIO=y
 CONFIG_PCSPK=y
 CONFIG_CUDA=y
hw/ppc_prep.c +18 -32

90 lines not on this page · raw message

Signature · 1 line
1.7.9.1
#17 lore raw

Re: [Qemu-devel] [PATCH 6/6] prep: use pc87312 Super I/O chip instead of collection of random ISA devices

Il 17/03/2012 15:39, Hervé Poussineau ha scritto:

hw/ppc_prep.c static void ppc_prep_init (ram_addr_t ram_size, · line 625

Quoted 3 lines
hw/ppc_prep.c +3 -0
+    qdev_prop_set_chr(&isa->qdev, "parallel", parallel_hds[0]);
+    qdev_prop_set_chr(&isa->qdev, "uart1", serial_hds[0]);
+    qdev_prop_set_chr(&isa->qdev, "uart2", serial_hds[1]);

Set these conditionally on *_hds[] being non-NULL, so that you can use -chardev/-global on the command-line as an alternative to -serial/-parallel.

Paolo

#18 lore raw
In reply to Hervé Poussineau
Quoted 2 lines · Hervé Poussineau

First two patches repair some functionality broken since 2009! Debian install root floppy can now be started again.

Can you give the qemu command line for this?

Quoted 13 lines

Patches 4 to 6 implement the pc87312 Super I/O chip. Some versions by me or by Andreas Färber have already been sent on mailing list. This patch has been tested on PReP emulation and on IBM 40p (not yet committed).

Hervé Poussineau (6):
i82378/i82374: do not create DMA controller twice
prep: change default cpu to '7448'
isa: add isa_bus_from_device() method
fdc: Parametrize ISA base, IRQ and DMA
prep: add pc87312 Super I/O emulation
prep: use pc87312 Super I/O chip instead of collection of random ISA
devices

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/search/label/qemu
#19 lore raw

Hi,

Quoted 5 lines · Artyom Tarasenko
Quoted 2 lines · Hervé Poussineau

First two patches repair some functionality broken since 2009! Debian install root floppy can now be started again.

Can you give the qemu command line for this?

The command line is
qemu-system-ppc -kernel zImage.prep -fda debian_install_root.bin -M prep

You can find kernel and floppy image in archive http://www.h6.dion.ne.jp/~kazuw/qemu-win/qemu-0.9.0-ppc.zip

You can find other floppy images required for install at
http://archive.debian.org/debian/dists/woody/main/disks-powerpc/current/prep/images-1.44/

Quoted 6 lines
Quoted 6 lines

Patches 4 to 6 implement the pc87312 Super I/O chip. Some versions by me or by Andreas Färber have already been sent on mailing list. This patch has been tested on PReP emulation and on IBM 40p (not yet committed).

Quoted 10 lines
Quoted 8 lines

Hervé Poussineau (6):
i82378/i82374: do not create DMA controller twice
prep: change default cpu to '7448'
isa: add isa_bus_from_device() method
fdc: Parametrize ISA base, IRQ and DMA
prep: add pc87312 Super I/O emulation
prep: use pc87312 Super I/O chip instead of collection of random ISA
devices

Hervé