qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O
@ 2012-08-15 14:24 Andreas Färber
  2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 1/3] prep: Include devices for ppc64 as well Andreas Färber
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Andreas Färber @ 2012-08-15 14:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: blauwirbel, Andreas Färber, hpoussin, Alexander Graf,
	anthony

Hello,

This mini-series updates a patch by Hervé (that didn't make it into v1.1)
to clean up the PReP device emulation and allowing it to be shared with a
future 40P machine.

History: Hervé was original author of the 40P patches and provided them to me,
I sent up to v5 (issue: ISABus not being hotplug-capable),
then Hervé sent up to v2, so
this is actually v8. ;)

For v1.1 I deferred Hervé's v1 due to a hack wrt NULL chr handlers in initfn.
v2 moved the logic from the machine into the device, avoiding this for now.
This version of mine fixes an error in case of no -serial options through use
of qemu_chr_new() and applies some more QOM sugar and adds a header.

Prepended is a fix requested by Markus to allow using the -M prep machine
with qemu-system-ppc64 (it would conflict with the changes here if sent alone).

Since this only affects the PReP machine and has mostly been around for a while,
I feel this is still acceptable for v1.2 at this late stage unless Alex objects.

Regards,
Andreas

Cc: Anthony Liguori <anthony@codemonkey.ws>
Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Alexander Graf <agraf@suse.de>
Cc: Hervé Poussineau <hpoussin@reactos.org>

Changes from Hervé's v2 (04/2012):
* Introduce TYPE_PC87312 constant.
* Make TypeInfo static const, rename to ..._type_info.
* Introduce PC87312() cast macro, use QOM casts consistently.
* Change field types from DeviceState to ISADevice to avoid ->qdev accesses.
* ppc_prep: Reuse TYPE_PC87312 constant from header.
* MAINTAINERS: Add to PReP machine.
* Avoid "Can't create serial device, empty char device" error by creating
  char devs if absent, so that the 'prep' machine still works out of the box.

Andreas Färber (1):
  prep: Include devices for ppc64 as well

Hervé Poussineau (2):
  prep: Add pc87312 Super I/O emulation
  prep: Use pc87312 device instead of collection of random ISA devices

 MAINTAINERS                       |    1 +
 default-configs/ppc-softmmu.mak   |    2 +
 default-configs/ppc64-softmmu.mak |    5 +
 hw/Makefile.objs                  |    1 +
 hw/pc87312.c                      |  386 +++++++++++++++++++++++++++++++++++++
 hw/pc87312.h                      |   66 +++++++
 hw/ppc_prep.c                     |   39 +---
 trace-events                      |    8 +
 8 files changed, 476 insertions(+), 32 deletions(-)
 create mode 100644 hw/pc87312.c
 create mode 100644 hw/pc87312.h

-- 
1.7.7

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

* [Qemu-devel] [PATCH for-1.2 1/3] prep: Include devices for ppc64 as well
  2012-08-15 14:24 [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Andreas Färber
@ 2012-08-15 14:24 ` Andreas Färber
  2012-08-15 17:18   ` Hervé Poussineau
  2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 2/3] prep: Add pc87312 Super I/O emulation Andreas Färber
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Andreas Färber @ 2012-08-15 14:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Alexander Graf, blauwirbel,
	Andreas Färber, hpoussin, anthony

Allows running qemu-system-ppc64 -M prep for consistency.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Alexander Graf <agraf@suse.de>
---
 default-configs/ppc64-softmmu.mak |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-softmmu.mak
index e4265b4..a1d2d4f 100644
--- a/default-configs/ppc64-softmmu.mak
+++ b/default-configs/ppc64-softmmu.mak
@@ -12,9 +12,12 @@ CONFIG_I8254=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
 CONFIG_DMA=y
+CONFIG_I82374=y
 CONFIG_OPENPIC=y
 CONFIG_PREP_PCI=y
+CONFIG_I82378=y
 CONFIG_MACIO=y
+CONFIG_PCSPK=y
 CONFIG_CUDA=y
 CONFIG_ADB=y
 CONFIG_MAC_NVRAM=y
-- 
1.7.7

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

* [Qemu-devel] [PATCH for-1.2 2/3] prep: Add pc87312 Super I/O emulation
  2012-08-15 14:24 [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Andreas Färber
  2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 1/3] prep: Include devices for ppc64 as well Andreas Färber
@ 2012-08-15 14:24 ` Andreas Färber
  2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 3/3] prep: Use pc87312 device instead of collection of random ISA devices Andreas Färber
  2012-08-15 14:31 ` [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Alexander Graf
  3 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2012-08-15 14:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: blauwirbel, open list:PReP, Andreas Färber, hpoussin,
	anthony

From: Hervé Poussineau <hpoussin@reactos.org>

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

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
[AF: QOM'ify, split out header, create CharDriverState if absent]
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 hw/Makefile.objs |    1 +
 hw/pc87312.c     |  386 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/pc87312.h     |   66 +++++++++
 trace-events     |    8 +
 4 files changed, 461 insertions(+), 0 deletions(-)
 create mode 100644 hw/pc87312.c
 create mode 100644 hw/pc87312.h

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 7f57ed5..aab0a46 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -39,6 +39,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
diff --git a/hw/pc87312.c b/hw/pc87312.c
new file mode 100644
index 0000000..b5fa016
--- /dev/null
+++ b/hw/pc87312.c
@@ -0,0 +1,386 @@
+/*
+ * QEMU National Semiconductor PC87312 (Super I/O)
+ *
+ * Copyright (c) 2010-2012 Herve Poussineau
+ * Copyright (c) 2011-2012 Andreas Färber
+ *
+ * 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 "pc87312.h"
+#include "blockdev.h"
+#include "sysemu.h"
+#include "trace.h"
+
+
+#define REG_FER 0
+#define REG_FAR 1
+#define REG_PTR 2
+
+#define FER regs[REG_FER]
+#define FAR regs[REG_FAR]
+#define PTR regs[REG_PTR]
+
+#define FER_PARALLEL_EN   0x01
+#define FER_UART1_EN      0x02
+#define FER_UART2_EN      0x04
+#define FER_FDC_EN        0x08
+#define FER_FDC_4         0x10
+#define FER_FDC_ADDR      0x20
+#define FER_IDE_EN        0x40
+#define FER_IDE_ADDR      0x80
+
+#define FAR_PARALLEL_ADDR 0x03
+#define FAR_UART1_ADDR    0x0C
+#define FAR_UART2_ADDR    0x30
+#define FAR_UART_3_4      0xC0
+
+#define PTR_POWER_DOWN    0x01
+#define PTR_CLOCK_DOWN    0x02
+#define PTR_PWDN          0x04
+#define PTR_IRQ_5_7       0x08
+#define PTR_UART1_TEST    0x10
+#define PTR_UART2_TEST    0x20
+#define PTR_LOCK_CONF     0x40
+#define PTR_EPP_MODE      0x80
+
+
+/* Parallel port */
+
+static inline bool is_parallel_enabled(PC87312State *s)
+{
+    return s->FER & FER_PARALLEL_EN;
+}
+
+static const uint32_t parallel_base[] = { 0x378, 0x3bc, 0x278, 0x00 };
+
+static inline uint32_t get_parallel_iobase(PC87312State *s)
+{
+    return parallel_base[s->FAR & FAR_PARALLEL_ADDR];
+}
+
+static const uint32_t parallel_irq[] = { 5, 7, 5, 0 };
+
+static inline uint32_t get_parallel_irq(PC87312State *s)
+{
+    int idx;
+    idx = (s->FAR & FAR_PARALLEL_ADDR);
+    if (idx == 0) {
+        return (s->PTR & PTR_IRQ_5_7) ? 7 : 5;
+    } else {
+        return parallel_irq[idx];
+    }
+}
+
+static inline bool is_parallel_epp(PC87312State *s)
+{
+    return s->PTR & PTR_EPP_MODE;
+}
+
+
+/* UARTs */
+
+static const uint32_t uart_base[2][4] = {
+    { 0x3e8, 0x338, 0x2e8, 0x220 },
+    { 0x2e8, 0x238, 0x2e0, 0x228 }
+};
+
+static inline uint32_t get_uart_iobase(PC87312State *s, int i)
+{
+    int idx;
+    idx = (s->FAR >> (2 * i + 2)) & 0x3;
+    if (idx == 0) {
+        return 0x3f8;
+    } else if (idx == 1) {
+        return 0x2f8;
+    } else {
+        return uart_base[idx & 1][(s->FAR & FAR_UART_3_4) >> 6];
+    }
+}
+
+static inline uint32_t get_uart_irq(PC87312State *s, int i)
+{
+    int idx;
+    idx = (s->FAR >> (2 * i + 2)) & 0x3;
+    return (idx & 1) ? 3 : 4;
+}
+
+static inline bool is_uart_enabled(PC87312State *s, int i)
+{
+    return s->FER & (FER_UART1_EN << i);
+}
+
+
+/* Floppy controller */
+
+static inline bool is_fdc_enabled(PC87312State *s)
+{
+    return s->FER & FER_FDC_EN;
+}
+
+static inline uint32_t get_fdc_iobase(PC87312State *s)
+{
+    return (s->FER & FER_FDC_ADDR) ? 0x370 : 0x3f0;
+}
+
+
+/* IDE controller */
+
+static inline bool is_ide_enabled(PC87312State *s)
+{
+    return s->FER & FER_IDE_EN;
+}
+
+static inline uint32_t get_ide_iobase(PC87312State *s)
+{
+    return (s->FER & FER_IDE_ADDR) ? 0x170 : 0x1f0;
+}
+
+
+static void reconfigure_devices(PC87312State *s)
+{
+    error_report("pc87312: unsupported device reconfiguration (%02x %02x %02x)",
+                 s->FER, s->FAR, s->PTR);
+}
+
+static void pc87312_soft_reset(PC87312State *s)
+{
+    static const uint8_t fer_init[] = {
+        0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4b, 0x4b,
+        0x4b, 0x4b, 0x4b, 0x4b, 0x0f, 0x0f, 0x0f, 0x0f,
+        0x49, 0x49, 0x49, 0x49, 0x07, 0x07, 0x07, 0x07,
+        0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x08, 0x00,
+    };
+    static const uint8_t far_init[] = {
+        0x10, 0x11, 0x11, 0x39, 0x24, 0x38, 0x00, 0x01,
+        0x01, 0x09, 0x08, 0x08, 0x10, 0x11, 0x39, 0x24,
+        0x00, 0x01, 0x01, 0x00, 0x10, 0x11, 0x39, 0x24,
+        0x10, 0x11, 0x11, 0x39, 0x24, 0x38, 0x10, 0x10,
+    };
+    static const uint8_t ptr_init[] = {
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+    };
+
+    s->read_id_step = 0;
+    s->selected_index = REG_FER;
+
+    s->FER = fer_init[s->config & 0x1f];
+    s->FAR = far_init[s->config & 0x1f];
+    s->PTR = ptr_init[s->config & 0x1f];
+}
+
+static void pc87312_hard_reset(PC87312State *s)
+{
+    pc87312_soft_reset(s);
+}
+
+static void pc87312_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+{
+    PC87312State *s = opaque;
+
+    trace_pc87312_io_write(addr, val);
+
+    if ((addr & 1) == 0) {
+        /* Index register */
+        s->read_id_step = 2;
+        s->selected_index = val;
+    } else {
+        /* Data register */
+        if (s->selected_index < 3) {
+            s->regs[s->selected_index] = val;
+            reconfigure_devices(s);
+        }
+    }
+}
+
+static uint32_t pc87312_ioport_read(void *opaque, uint32_t addr)
+{
+    PC87312State *s = opaque;
+    uint32_t val;
+
+    if ((addr & 1) == 0) {
+        /* Index register */
+        if (s->read_id_step++ == 0) {
+            val = 0x88;
+        } else if (s->read_id_step++ == 1) {
+            val = 0;
+        } else {
+            val = s->selected_index;
+        }
+    } else {
+        /* Data register */
+        if (s->selected_index < 3) {
+            val = s->regs[s->selected_index];
+        } else {
+            /* Invalid selected index */
+            val = 0;
+        }
+    }
+
+    trace_pc87312_io_read(addr, val);
+    return val;
+}
+
+static int pc87312_post_load(void *opaque, int version_id)
+{
+    PC87312State *s = opaque;
+
+    reconfigure_devices(s);
+    return 0;
+}
+
+static void pc87312_reset(DeviceState *d)
+{
+    PC87312State *s = PC87312(d);
+
+    pc87312_soft_reset(s);
+}
+
+static int pc87312_init(ISADevice *dev)
+{
+    PC87312State *s;
+    DeviceState *d;
+    ISADevice *isa;
+    ISABus *bus;
+    CharDriverState *chr;
+    DriveInfo *drive;
+    char name[5];
+    int i;
+
+    s = PC87312(dev);
+    bus = isa_bus_from_device(dev);
+    pc87312_hard_reset(s);
+
+    if (is_parallel_enabled(s)) {
+        chr = parallel_hds[0];
+        if (chr == NULL) {
+            chr = qemu_chr_new("par0", "null", NULL);
+        }
+        isa = isa_create(bus, "isa-parallel");
+        d = DEVICE(isa);
+        qdev_prop_set_uint32(d, "index", 0);
+        qdev_prop_set_uint32(d, "iobase", get_parallel_iobase(s));
+        qdev_prop_set_uint32(d, "irq", get_parallel_irq(s));
+        qdev_prop_set_chr(d, "chardev", chr);
+        qdev_init_nofail(d);
+        s->parallel.dev = isa;
+        trace_pc87312_info_parallel(get_parallel_iobase(s),
+                                    get_parallel_irq(s));
+    }
+
+    for (i = 0; i < 2; i++) {
+        if (is_uart_enabled(s, i)) {
+            chr = serial_hds[i];
+            if (chr == NULL) {
+                snprintf(name, sizeof(name), "ser%d", i);
+                chr = qemu_chr_new(name, "null", NULL);
+            }
+            isa = isa_create(bus, "isa-serial");
+            d = DEVICE(isa);
+            qdev_prop_set_uint32(d, "index", i);
+            qdev_prop_set_uint32(d, "iobase", get_uart_iobase(s, i));
+            qdev_prop_set_uint32(d, "irq", get_uart_irq(s, i));
+            qdev_prop_set_chr(d, "chardev", chr);
+            qdev_init_nofail(d);
+            s->uart[i].dev = isa;
+            trace_pc87312_info_serial(i, get_uart_iobase(s, i),
+                                      get_uart_irq(s, i));
+        }
+    }
+
+    if (is_fdc_enabled(s)) {
+        isa = isa_create(bus, "isa-fdc");
+        d = DEVICE(isa);
+        qdev_prop_set_uint32(d, "iobase", get_fdc_iobase(s));
+        qdev_prop_set_uint32(d, "irq", 6);
+        drive = drive_get(IF_FLOPPY, 0, 0);
+        if (drive != NULL) {
+            qdev_prop_set_drive_nofail(d, "driveA", drive->bdrv);
+        }
+        drive = drive_get(IF_FLOPPY, 0, 1);
+        if (drive != NULL) {
+            qdev_prop_set_drive_nofail(d, "driveB", drive->bdrv);
+        }
+        qdev_init_nofail(d);
+        s->fdc.dev = isa;
+        trace_pc87312_info_floppy(get_fdc_iobase(s));
+    }
+
+    if (is_ide_enabled(s)) {
+        isa = isa_create(bus, "isa-ide");
+        d = DEVICE(isa);
+        qdev_prop_set_uint32(d, "iobase", get_ide_iobase(s));
+        qdev_prop_set_uint32(d, "iobase2", get_ide_iobase(s) + 0x206);
+        qdev_prop_set_uint32(d, "irq", 14);
+        qdev_init_nofail(d);
+        s->ide.dev = isa;
+        trace_pc87312_info_ide(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),
+    DEFINE_PROP_UINT8("config", PC87312State, config, 1),
+    DEFINE_PROP_END_OF_LIST()
+};
+
+static void pc87312_class_init(ObjectClass *klass, void *data)
+{
+    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 const TypeInfo pc87312_type_info = {
+    .name          = TYPE_PC87312,
+    .parent        = TYPE_ISA_DEVICE,
+    .instance_size = sizeof(PC87312State),
+    .class_init    = pc87312_class_init,
+};
+
+static void pc87312_register_types(void)
+{
+    type_register_static(&pc87312_type_info);
+}
+
+type_init(pc87312_register_types)
diff --git a/hw/pc87312.h b/hw/pc87312.h
new file mode 100644
index 0000000..7ca7912
--- /dev/null
+++ b/hw/pc87312.h
@@ -0,0 +1,66 @@
+/*
+ * QEMU National Semiconductor PC87312 (Super I/O)
+ *
+ * Copyright (c) 2010-2012 Herve Poussineau
+ * Copyright (c) 2011-2012 Andreas Färber
+ *
+ * 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.
+ */
+#ifndef QEMU_PC87312_H
+#define QEMU_PC87312_H
+
+#include "isa.h"
+
+
+#define TYPE_PC87312 "pc87312"
+#define PC87312(obj) OBJECT_CHECK(PC87312State, (obj), TYPE_PC87312)
+
+typedef struct PC87312State {
+    ISADevice dev;
+
+    uint32_t iobase;
+    uint8_t config; /* initial configuration */
+
+    struct {
+        ISADevice *dev;
+    } parallel;
+
+    struct {
+        ISADevice *dev;
+    } uart[2];
+
+    struct {
+        ISADevice *dev;
+        BlockDriverState *drive[2];
+        uint32_t base;
+    } fdc;
+
+    struct {
+        ISADevice *dev;
+        uint32_t base;
+    } ide;
+
+    uint8_t read_id_step;
+    uint8_t selected_index;
+
+    uint8_t regs[3];
+} PC87312State;
+
+
+#endif
diff --git a/trace-events b/trace-events
index 6b12f83..b4ca0e9 100644
--- a/trace-events
+++ b/trace-events
@@ -694,6 +694,14 @@ mipsnet_read(uint64_t addr, uint32_t val) "read addr=0x%" PRIx64 " val=0x%x"
 mipsnet_write(uint64_t addr, uint64_t val) "write addr=0x%" PRIx64 " val=0x%" PRIx64 ""
 mipsnet_irq(uint32_t isr, uint32_t intctl) "set irq to %d (%02x)"
 
+# hw/pc87312.c
+pc87312_io_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
+pc87312_io_write(uint32_t addr, uint32_t val) "write addr=%x val=%x"
+pc87312_info_floppy(uint32_t base) "base 0x%x"
+pc87312_info_ide(uint32_t base) "base 0x%x"
+pc87312_info_parallel(uint32_t base, uint32_t irq) "base 0x%x, irq %u"
+pc87312_info_serial(int n, uint32_t base, uint32_t irq) "id=%d, base 0x%x, irq %u"
+
 # xen-all.c
 xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: %#lx, size %#lx"
 xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_dirty) "%#"PRIx64" size %#lx, log_dirty %i"
-- 
1.7.7

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

* [Qemu-devel] [PATCH for-1.2 3/3] prep: Use pc87312 device instead of collection of random ISA devices
  2012-08-15 14:24 [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Andreas Färber
  2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 1/3] prep: Include devices for ppc64 as well Andreas Färber
  2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 2/3] prep: Add pc87312 Super I/O emulation Andreas Färber
@ 2012-08-15 14:24 ` Andreas Färber
  2012-08-15 14:31 ` [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Alexander Graf
  3 siblings, 0 replies; 8+ messages in thread
From: Andreas Färber @ 2012-08-15 14:24 UTC (permalink / raw)
  To: qemu-devel
  Cc: blauwirbel, open list:PReP, Andreas Färber, hpoussin,
	anthony

From: Hervé Poussineau <hpoussin@reactos.org>

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. Therefore the
pc87312's IDE function gets disabled via the config property.

PReP emulation also gains a parallel port emulation this way.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
[AF: Use TYPE_PC87312 constant, add to ppc64-softmmu and to MAINTAINERS]
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 MAINTAINERS                       |    1 +
 default-configs/ppc-softmmu.mak   |    2 +
 default-configs/ppc64-softmmu.mak |    2 +
 hw/ppc_prep.c                     |   39 ++++++------------------------------
 4 files changed, 12 insertions(+), 32 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6d864c1..950270f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -373,6 +373,7 @@ L: qemu-ppc@nongnu.org
 S: Odd Fixes
 F: hw/ppc_prep.c
 F: hw/prep_pci.[hc]
+F: hw/pc87312.[hc]
 
 SH4 Machines
 ------------
diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.mak
index d0fde7b..1f4a1cf 100644
--- a/default-configs/ppc-softmmu.mak
+++ b/default-configs/ppc-softmmu.mak
@@ -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
diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-softmmu.mak
index a1d2d4f..5ff406c 100644
--- a/default-configs/ppc64-softmmu.mak
+++ b/default-configs/ppc64-softmmu.mak
@@ -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
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index be2b268..59def90 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -36,6 +36,7 @@
 #include "ide.h"
 #include "loader.h"
 #include "mc146818rtc.h"
+#include "pc87312.h"
 #include "blockdev.h"
 #include "arch_init.h"
 #include "exec-memory.h"
@@ -180,7 +181,6 @@ typedef struct sysctrl_t {
     M48t59State *nvram;
     uint8_t state;
     uint8_t syscontrol;
-    uint8_t fake_io[2];
     int contiguous_map;
     int endian;
 } sysctrl_t;
@@ -191,24 +191,6 @@ enum {
 
 static sysctrl_t *sysctrl;
 
-static void PREP_io_write (void *opaque, uint32_t addr, uint32_t val)
-{
-    sysctrl_t *sysctrl = opaque;
-
-    PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n", addr - PPC_IO_BASE,
-                   val);
-    sysctrl->fake_io[addr - 0x0398] = val;
-}
-
-static uint32_t PREP_io_read (void *opaque, uint32_t addr)
-{
-    sysctrl_t *sysctrl = opaque;
-
-    PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n", addr - PPC_IO_BASE,
-                   sysctrl->fake_io[addr - 0x0398]);
-    return sysctrl->fake_io[addr - 0x0398];
-}
-
 static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val)
 {
     sysctrl_t *sysctrl = opaque;
@@ -475,10 +457,10 @@ static void ppc_prep_init (ram_addr_t ram_size,
     PCIBus *pci_bus;
     PCIDevice *pci;
     ISABus *isa_bus;
+    ISADevice *isa;
     qemu_irq *cpu_exit_irq;
     int ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
-    DriveInfo *fd[MAX_FD];
 
     sysctrl = g_malloc0(sizeof(sysctrl_t));
 
@@ -606,6 +588,11 @@ static void ppc_prep_init (ram_addr_t ram_size,
     sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11));
     isa_bus = DO_UPCAST(ISABus, qbus, qdev_get_child_bus(&pci->qdev, "isa.0"));
 
+    /* Super I/O (parallel + serial ports) */
+    isa = isa_create(isa_bus, TYPE_PC87312);
+    qdev_prop_set_uint8(&isa->qdev, "config", 13); /* fdc, ser0, ser1, par0 */
+    qdev_init_nofail(&isa->qdev);
+
     /* Register 8 MB of ISA IO space (needed for non-contiguous map) */
     memory_region_init_io(PPC_io_memory, &PPC_prep_io_ops, sysctrl,
                           "ppc-io", 0x00800000);
@@ -614,8 +601,6 @@ static void ppc_prep_init (ram_addr_t ram_size,
     /* init basic PC hardware */
     pci_vga_init(pci_bus);
 
-    if (serial_hds[0])
-        serial_isa_init(isa_bus, 0, serial_hds[0]);
     nb_nics1 = nb_nics;
     if (nb_nics1 > NE2000_NB_MAX)
         nb_nics1 = NE2000_NB_MAX;
@@ -639,17 +624,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
     }
     isa_create_simple(isa_bus, "i8042");
 
-    //    SB16_init();
-
-    for(i = 0; i < MAX_FD; i++) {
-        fd[i] = drive_get(IF_FLOPPY, 0, i);
-    }
-    fdctrl_init_isa(isa_bus, fd);
-
-    /* Register fake IO ports for PREP */
     sysctrl->reset_irq = first_cpu->irq_inputs[PPC6xx_INPUT_HRESET];
-    register_ioport_read(0x398, 2, 1, &PREP_io_read, sysctrl);
-    register_ioport_write(0x398, 2, 1, &PREP_io_write, sysctrl);
     /* System control ports */
     register_ioport_read(0x0092, 0x01, 1, &PREP_io_800_readb, sysctrl);
     register_ioport_write(0x0092, 0x01, 1, &PREP_io_800_writeb, sysctrl);
-- 
1.7.7

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

* Re: [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O
  2012-08-15 14:24 [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Andreas Färber
                   ` (2 preceding siblings ...)
  2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 3/3] prep: Use pc87312 device instead of collection of random ISA devices Andreas Färber
@ 2012-08-15 14:31 ` Alexander Graf
  2012-08-15 14:53   ` Andreas Färber
  3 siblings, 1 reply; 8+ messages in thread
From: Alexander Graf @ 2012-08-15 14:31 UTC (permalink / raw)
  To: Andreas Färber; +Cc: blauwirbel, hpoussin, qemu-devel, anthony


On 15.08.2012, at 16:24, Andreas Färber wrote:

> Hello,
> 
> This mini-series updates a patch by Hervé (that didn't make it into v1.1)
> to clean up the PReP device emulation and allowing it to be shared with a
> future 40P machine.
> 
> History: Hervé was original author of the 40P patches and provided them to me,
> I sent up to v5 (issue: ISABus not being hotplug-capable),
> then Hervé sent up to v2, so
> this is actually v8. ;)
> 
> For v1.1 I deferred Hervé's v1 due to a hack wrt NULL chr handlers in initfn.
> v2 moved the logic from the machine into the device, avoiding this for now.
> This version of mine fixes an error in case of no -serial options through use
> of qemu_chr_new() and applies some more QOM sugar and adds a header.
> 
> Prepended is a fix requested by Markus to allow using the -M prep machine
> with qemu-system-ppc64 (it would conflict with the changes here if sent alone).
> 
> Since this only affects the PReP machine and has mostly been around for a while,
> I feel this is still acceptable for v1.2 at this late stage unless Alex objects.

No objections. You might want to send a pull request rather than a patch set though :).


Alex

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

* Re: [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O
  2012-08-15 14:31 ` [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Alexander Graf
@ 2012-08-15 14:53   ` Andreas Färber
  2012-08-15 15:00     ` Alexander Graf
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Färber @ 2012-08-15 14:53 UTC (permalink / raw)
  To: Alexander Graf; +Cc: blauwirbel, hpoussin, qemu-devel, anthony

Am 15.08.2012 16:31, schrieb Alexander Graf:
> 
> On 15.08.2012, at 16:24, Andreas Färber wrote:
> 
>> Since this only affects the PReP machine and has mostly been around for a while,
>> I feel this is still acceptable for v1.2 at this late stage unless Alex objects.
> 
> No objections. You might want to send a pull request rather than a patch set though :).

Thanks. I'm strict about the protocol - first PATCH, then PULL. :)
Gives people up to five hours for acks or nacks. ;)

Andreas

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

* Re: [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O
  2012-08-15 14:53   ` Andreas Färber
@ 2012-08-15 15:00     ` Alexander Graf
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-08-15 15:00 UTC (permalink / raw)
  To: Andreas Färber; +Cc: blauwirbel, hpoussin, qemu-devel, anthony


On 15.08.2012, at 16:53, Andreas Färber wrote:

> Am 15.08.2012 16:31, schrieb Alexander Graf:
>> 
>> On 15.08.2012, at 16:24, Andreas Färber wrote:
>> 
>>> Since this only affects the PReP machine and has mostly been around for a while,
>>> I feel this is still acceptable for v1.2 at this late stage unless Alex objects.
>> 
>> No objections. You might want to send a pull request rather than a patch set though :).
> 
> Thanks. I'm strict about the protocol - first PATCH, then PULL. :)
> Gives people up to five hours for acks or nacks. ;)

Ah, ok, it sounded as if you were expecting Blue to pick it up from the patch set. Great then :).


Alex

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

* Re: [Qemu-devel] [PATCH for-1.2 1/3] prep: Include devices for ppc64 as well
  2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 1/3] prep: Include devices for ppc64 as well Andreas Färber
@ 2012-08-15 17:18   ` Hervé Poussineau
  0 siblings, 0 replies; 8+ messages in thread
From: Hervé Poussineau @ 2012-08-15 17:18 UTC (permalink / raw)
  To: Andreas Färber
  Cc: blauwirbel, Alexander Graf, qemu-devel, anthony,
	Markus Armbruster

Andreas Färber a écrit :
> Allows running qemu-system-ppc64 -M prep for consistency.
> 
> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Alexander Graf <agraf@suse.de>

Acked-by: Hervé Poussineau <hpoussin@reactos.org>

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

end of thread, other threads:[~2012-08-15 17:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-15 14:24 [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Andreas Färber
2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 1/3] prep: Include devices for ppc64 as well Andreas Färber
2012-08-15 17:18   ` Hervé Poussineau
2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 2/3] prep: Add pc87312 Super I/O emulation Andreas Färber
2012-08-15 14:24 ` [Qemu-devel] [PATCH for-1.2 3/3] prep: Use pc87312 device instead of collection of random ISA devices Andreas Färber
2012-08-15 14:31 ` [Qemu-devel] [PATCH for-1.2 0/3] prep: QOM'ify Super I/O Alexander Graf
2012-08-15 14:53   ` Andreas Färber
2012-08-15 15:00     ` Alexander Graf

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).