qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Hervé Poussineau" <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Subject: [Qemu-devel] [PATCH 07/20] [MIPS] qdev: convert parallel port to rc4030 device
Date: Sun,  1 Aug 2010 19:37:09 +0200	[thread overview]
Message-ID: <1280684242-19611-7-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <4C5579DA.8050508@reactos.org>

Use it in Jazz emulation
Remove parallel_mm_init() function, which is not used anymore

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/mips_jazz.c |    5 ++-
 hw/parallel.c  |   58 +++++++++++++++++++++++++++++++++++++++++++++----------
 hw/pc.h        |    2 +-
 3 files changed, 51 insertions(+), 14 deletions(-)

diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 9663a3c..a027559 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -271,8 +271,9 @@ void mips_jazz_init (ram_addr_t ram_size,
     }
 
     /* Parallel port */
-    if (parallel_hds[0])
-        parallel_mm_init(0x80008000, 0, rc4030[0], parallel_hds[0]);
+    if (parallel_hds[0]) {
+        parallel_rc4030_init(parallel_hds[0]);
+    }
 
     /* Sound card */
     /* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
diff --git a/hw/parallel.c b/hw/parallel.c
index 6b11672..cb36fba 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -27,6 +27,8 @@
 #include "isa.h"
 #include "pc.h"
 #include "sysemu.h"
+#include "rc4030.h"
+#include "qdev-addr.h"
 
 //#define DEBUG_PARALLEL
 
@@ -87,6 +89,13 @@ typedef struct ISAParallelState {
     ParallelState state;
 } ISAParallelState;
 
+typedef struct RC4030ParallelState {
+    RC4030Device dev;
+    target_phys_addr_t iobase;
+    uint32_t irq;
+    ParallelState state;
+} RC4030ParallelState;
+
 static void parallel_update_irq(ParallelState *s)
 {
     if (s->irq_pending)
@@ -446,6 +455,12 @@ static void parallel_reset(void *opaque)
     s->last_read_offset = ~0U;
 }
 
+static void parallel_rc4030_reset(DeviceState *d)
+{
+    RC4030ParallelState *rc4030 = container_of(d, RC4030ParallelState, dev.qdev);
+    parallel_reset(&rc4030->state);
+}
+
 static const int isa_parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
 
 static int parallel_isa_initfn(ISADevice *dev)
@@ -565,21 +580,28 @@ static CPUWriteMemoryFunc * const parallel_mm_write_sw[] = {
     &parallel_mm_writel,
 };
 
-/* If fd is zero, it means that the parallel device uses the console */
-ParallelState *parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr)
+static int parallel_rc4030_initfn(RC4030Device *dev)
 {
-    ParallelState *s;
+    RC4030ParallelState *s = container_of(dev, RC4030ParallelState, dev);
     int io_sw;
 
-    s = qemu_mallocz(sizeof(ParallelState));
-    s->irq = irq;
-    s->chr = chr;
-    s->it_shift = it_shift;
-    qemu_register_reset(parallel_reset, s);
+    rc4030_init_irq(dev, &s->state.irq, s->irq);
+
+    io_sw = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw, &s->state);
+    cpu_register_physical_memory(s->iobase, 8, io_sw);
+
+    return 0;
+}
 
-    io_sw = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw, s);
-    cpu_register_physical_memory(base, 8 << it_shift, io_sw);
-    return s;
+ParallelState *parallel_rc4030_init(CharDriverState *chr)
+{
+    RC4030Device *dev;
+
+    dev = rc4030_create("rc4030-parallel");
+    qdev_prop_set_chr(&dev->qdev, "chardev", chr);
+    if (qdev_init(&dev->qdev) < 0)
+        return NULL;
+    return &DO_UPCAST(RC4030ParallelState, dev, dev)->state;
 }
 
 static ISADeviceInfo parallel_isa_info = {
@@ -595,9 +617,23 @@ static ISADeviceInfo parallel_isa_info = {
     },
 };
 
+static RC4030DeviceInfo parallel_rc4030_info = {
+    .qdev.name  = "rc4030-parallel",
+    .qdev.size  = sizeof(RC4030ParallelState),
+    .qdev.reset = parallel_rc4030_reset,
+    .init       = parallel_rc4030_initfn,
+    .qdev.props = (Property[]) {
+        DEFINE_PROP_TADDR("iobase", RC4030ParallelState, iobase, 0x80008000),
+        DEFINE_PROP_UINT32("irq", RC4030ParallelState, irq, 0),
+        DEFINE_PROP_CHR("chardev", RC4030ParallelState, state.chr),
+        DEFINE_PROP_END_OF_LIST(),
+    },
+};
+
 static void parallel_register_devices(void)
 {
     isa_qdev_register(&parallel_isa_info);
+    rc4030_qdev_register(&parallel_rc4030_info);
 }
 
 device_init(parallel_register_devices)
diff --git a/hw/pc.h b/hw/pc.h
index e078fd9..61b5fbb 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -23,7 +23,7 @@ void serial_set_frequency(SerialState *s, uint32_t frequency);
 
 typedef struct ParallelState ParallelState;
 ParallelState *parallel_init(int index, CharDriverState *chr);
-ParallelState *parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq, CharDriverState *chr);
+ParallelState *parallel_rc4030_init(CharDriverState *chr);
 
 /* i8259.c */
 
-- 
1.7.1.GIT

  parent reply	other threads:[~2010-08-01 18:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-01 13:42 [Qemu-devel] [PATCH 00/20] MIPS Magnum conversion to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 01/20] [MIPS] cpu: add a init inplace method Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 02/20] [MIPS] cpu: convert to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 03/20] [MIPS] Jazz emulation: create a qdev cpu Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 04/20] [MIPS] rc4030: convert to qdev Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 05/20] Add a stub for some rc4030 functions, if rc4030 support is not compiled in Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 06/20] [MIPS] qdev: convert i8042 to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` Hervé Poussineau [this message]
2010-08-01 17:37 ` [Qemu-devel] [PATCH 08/20] [MIPS] qdev: convert serial port " Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 09/20] [MIPS] qdev: convert jazz-led to sysbus device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 10/20] [MIPS] Jazz emulation: make video card optional Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 11/20] [MIPS] qdev: convert vga-isa-mm to ISA device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 12/20] [MIPS] qdev: convert g364fb to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 13/20] [MIPS] qdev: add a rtc forwarder device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 14/20] [MIPS] qdev: add an isa bus device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 15/20] [MIPS] qdev: convert dp83932 network card to rc4030 device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 16/20] [MIPS] qdev: convert floppy disk controller " Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 17/20] [MIPS] qdev: convert esp scsi adapter " Hervé Poussineau
2010-08-02 14:51   ` Artyom Tarasenko
2010-08-01 17:37 ` [Qemu-devel] [PATCH 18/20] [MIPS] qdev: convert ds1225y nvram to sysbus device Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 19/20] [MIPS] qdev: add a mips board device, which initializes the ram and the rom Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 20/20] [MIPS] qdev: Complete rc4030 conversion, by removing legacy stuff Hervé Poussineau
2010-08-02 16:06 ` [Qemu-devel] [PATCH 00/20] MIPS Magnum conversion to qdev Blue Swirl

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1280684242-19611-7-git-send-email-hpoussin@reactos.org \
    --to=hpoussin@reactos.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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).