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 12/20] [MIPS] qdev: convert g364fb to rc4030 device
Date: Sun,  1 Aug 2010 19:37:14 +0200	[thread overview]
Message-ID: <1280684242-19611-12-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <4C5579DA.8050508@reactos.org>

Use it in Jazz emulation

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/g364fb.c    |   62 +++++++++++++++++++++++++++++++++++++++++--------------
 hw/mips.h      |    5 ----
 hw/mips_jazz.c |    2 +-
 vl.c           |    1 +
 4 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/hw/g364fb.c b/hw/g364fb.c
index 3c8fb98..4b5e6ef 100644
--- a/hw/g364fb.c
+++ b/hw/g364fb.c
@@ -21,6 +21,8 @@
 #include "mips.h"
 #include "console.h"
 #include "pixel_ops.h"
+#include "rc4030.h"
+#include "qdev-addr.h"
 
 //#define DEBUG_G364
 
@@ -37,7 +39,7 @@ typedef struct G364State {
     /* hardware */
     uint8_t *vram;
     ram_addr_t vram_offset;
-    int vram_size;
+    uint32_t vram_size;
     qemu_irq irq;
     /* registers */
     uint8_t color_palette[256][3];
@@ -53,6 +55,14 @@ typedef struct G364State {
     int blanked;
 } G364State;
 
+typedef struct RC4030G364State {
+    RC4030Device dev;
+    target_phys_addr_t iobase;
+    target_phys_addr_t vram;
+    uint32_t irq;
+    G364State state;
+} RC4030G364State;
+
 #define REG_ID       0x000000
 #define REG_BOOT     0x080000
 #define REG_DISPLAY  0x080118
@@ -279,9 +289,8 @@ static inline void g364fb_invalidate_display(void *opaque)
     }
 }
 
-static void g364fb_reset(void *opaque)
+static void g364fb_reset(G364State *s)
 {
-    G364State *s = opaque;
     qemu_irq_lower(s->irq);
 
     memset(s->color_palette, 0, sizeof(s->color_palette));
@@ -292,7 +301,13 @@ static void g364fb_reset(void *opaque)
     s->top_of_screen = 0;
     s->width = s->height = 0;
     memset(s->vram, 0, s->vram_size);
-    g364fb_invalidate_display(opaque);
+    g364fb_invalidate_display(s);
+}
+
+static void g364fb_reset1(DeviceState *d)
+{
+    G364State *s = &container_of(d, RC4030G364State, dev.qdev)->state;
+    g364fb_reset(s);
 }
 
 static void g364fb_screen_dump(void *opaque, const char *filename)
@@ -583,32 +598,47 @@ static void g364fb_save(QEMUFile *f, void *opaque)
     qemu_put_be32(f, s->height);
 }
 
-int g364fb_mm_init(target_phys_addr_t vram_base,
-                   target_phys_addr_t ctrl_base, int it_shift,
-                   qemu_irq irq)
+static int g364fb_init(RC4030Device *dev)
 {
-    G364State *s;
+    RC4030G364State *rc4030 = container_of(dev, RC4030G364State, dev);
+    G364State *s = &rc4030->state;
     int io_ctrl;
 
-    s = qemu_mallocz(sizeof(G364State));
-
-    s->vram_size = 8 * 1024 * 1024;
     s->vram_offset = qemu_ram_alloc(NULL, "g364fb.vram", s->vram_size);
     s->vram = qemu_get_ram_ptr(s->vram_offset);
-    s->irq = irq;
+    rc4030_init_irq(dev, &s->irq, rc4030->irq);
 
-    qemu_register_reset(g364fb_reset, s);
     register_savevm(NULL, "g364fb", 0, 1, g364fb_save, g364fb_load, s);
-    g364fb_reset(s);
 
     s->ds = graphic_console_init(g364fb_update_display,
                                  g364fb_invalidate_display,
                                  g364fb_screen_dump, NULL, s);
 
-    cpu_register_physical_memory(vram_base, s->vram_size, s->vram_offset);
+    cpu_register_physical_memory(rc4030->vram, s->vram_size, s->vram_offset);
 
     io_ctrl = cpu_register_io_memory(g364fb_ctrl_read, g364fb_ctrl_write, s);
-    cpu_register_physical_memory(ctrl_base, 0x200000, io_ctrl);
+    cpu_register_physical_memory(rc4030->iobase, 0x200000, io_ctrl);
 
     return 0;
 }
+
+static RC4030DeviceInfo g364fb_device_info = {
+    .qdev.name  = "rc4030-g364fb",
+    .qdev.size  = sizeof(RC4030G364State),
+    .qdev.reset = g364fb_reset1,
+    .init       = g364fb_init,
+    .qdev.props = (Property[]) {
+        DEFINE_PROP_TADDR("iobase", RC4030G364State, iobase, 0x60000000),
+        DEFINE_PROP_TADDR("vram", RC4030G364State, vram, 0x40000000),
+        DEFINE_PROP_HEX32("vram_size", RC4030G364State, state.vram_size, 8 * 1024 * 1024),
+        DEFINE_PROP_UINT32("irq", RC4030G364State, irq, 3),
+        DEFINE_PROP_END_OF_LIST(),
+    },
+};
+
+static void g364fb_register_devices(void)
+{
+    rc4030_qdev_register(&g364fb_device_info);
+}
+
+device_init(g364fb_register_devices)
diff --git a/hw/mips.h b/hw/mips.h
index 023d85c..aa790d8 100644
--- a/hw/mips.h
+++ b/hw/mips.h
@@ -12,11 +12,6 @@ PCIBus *bonito_init(qemu_irq *pic);
 void *ds1225y_init(target_phys_addr_t mem_base, const char *filename);
 void ds1225y_set_protection(void *opaque, int protection);
 
-/* g364fb.c */
-int g364fb_mm_init(target_phys_addr_t vram_base,
-                   target_phys_addr_t ctrl_base, int it_shift,
-                   qemu_irq irq);
-
 /* mipsnet.c */
 void mipsnet_init(int base, qemu_irq irq, NICInfo *nd);
 
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 96946e8..c4f3721 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -206,7 +206,7 @@ void mips_jazz_init (ram_addr_t ram_size,
     if (vga_interface_type != VGA_NONE) {
         switch (jazz_model) {
         case JAZZ_MAGNUM:
-            g364fb_mm_init(0x40000000, 0x60000000, 0, rc4030[3]);
+            rc4030_create_simple("rc4030-g364fb");
             break;
         case JAZZ_PICA61:
             isa_create_simple("isa-vga-mm");
diff --git a/vl.c b/vl.c
index 9815f8d..eb4c212 100644
--- a/vl.c
+++ b/vl.c
@@ -266,6 +266,7 @@ static struct {
     { .driver = "cirrus-vga",           .flag = &default_vga       },
     { .driver = "vmware-svga",          .flag = &default_vga       },
     { .driver = "isa-vga-mm",           .flag = &default_vga       },
+    { .driver = "rc4030-g364fb",        .flag = &default_vga       },
 };
 
 static int default_driver_check(QemuOpts *opts, void *opaque)
-- 
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 ` [Qemu-devel] [PATCH 07/20] [MIPS] qdev: convert parallel port " Hervé Poussineau
2010-08-01 17:37 ` [Qemu-devel] [PATCH 08/20] [MIPS] qdev: convert serial " 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 ` Hervé Poussineau [this message]
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-12-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).