Patchwork [v3,11/25] ne2000-isa: add NEC PC-9821 family interface (MELCO LGY-98)

login
register
mail settings
Submitter 武田 =?ISO-2022-JP?B?IBskQj1TTGkbKEI=?=
Date Oct. 28, 2009, 4:51 p.m.
Message ID <200910281651.AA00174@YOUR-BD18D6DD63.m1.interq.or.jp>
Download mbox | patch
Permalink /patch/37139/
State New
Headers show

Comments


Patch

diff --git a/qemu/hw/ne2000-isa.c b/qemu/hw/ne2000-isa.c
index 729e8e2..7ec1f47 100644
--- a/qemu/hw/ne2000-isa.c
+++ b/qemu/hw/ne2000-isa.c
@@ -42,6 +42,23 @@  static void isa_ne2000_cleanup(VLANClientState *vc)
     s->vc = NULL;
 }
 
+static void isa_ne2000_initfn_common(ISADevice *dev,
+                                     ISANE2000State *isa, NE2000State *s)
+{
+    isa_init_irq(dev, &s->irq, isa->isairq);
+
+    qemu_macaddr_default_if_unset(&s->c.macaddr);
+    ne2000_reset(s);
+
+    s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, s->c.vlan, s->c.peer,
+                                 dev->qdev.info->name, dev->qdev.id,
+                                 ne2000_can_receive, ne2000_receive, NULL,
+                                 NULL, isa_ne2000_cleanup, s);
+    qemu_format_nic_info_str(s->vc, s->c.macaddr.a);
+
+    vmstate_register(-1, &vmstate_ne2000, s);
+}
+
 static int isa_ne2000_initfn(ISADevice *dev)
 {
     ISANE2000State *isa = DO_UPCAST(ISANE2000State, dev, dev);
@@ -58,18 +75,8 @@  static int isa_ne2000_initfn(ISADevice *dev)
     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);
-
-    qemu_macaddr_default_if_unset(&s->c.macaddr);
-    ne2000_reset(s);
-
-    s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, s->c.vlan, s->c.peer,
-                                 dev->qdev.info->name, dev->qdev.id,
-                                 ne2000_can_receive, ne2000_receive, NULL,
-                                 NULL, isa_ne2000_cleanup, s);
-    qemu_format_nic_info_str(s->vc, s->c.macaddr.a);
+    isa_ne2000_initfn_common(dev, isa, s);
 
-    vmstate_register(-1, &vmstate_ne2000, s);
     return 0;
 }
 
@@ -98,9 +105,58 @@  static ISADeviceInfo ne2000_isa_info = {
     },
 };
 
+/* NEC PC-9821 (MELCO LGY-98) */
+
+static int pc98_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 + 0x200, 1, 1, ne2000_asic_ioport_write, s);
+    register_ioport_read(isa->iobase + 0x200, 1, 1, ne2000_asic_ioport_read, s);
+    register_ioport_write(isa->iobase + 0x200, 2, 2, ne2000_asic_ioport_write, s);
+    register_ioport_read(isa->iobase + 0x200, 2, 2, ne2000_asic_ioport_read, s);
+
+    register_ioport_write(isa->iobase + 0x18, 1, 1, ne2000_reset_ioport_write, s);
+    register_ioport_read(isa->iobase + 0x18, 1, 1, ne2000_reset_ioport_read, s);
+
+    isa_ne2000_initfn_common(dev, isa, s);
+
+    return 0;
+}
+
+void pc98_ne2000_init(int base, int irq, NICInfo *nd)
+{
+    ISADevice *dev;
+
+    qemu_check_nic_model(nd, "ne2k_isa");
+
+    dev = isa_create("pc98_ne2k");
+    qdev_prop_set_uint32(&dev->qdev, "iobase", base);
+    qdev_prop_set_uint32(&dev->qdev, "irq",    irq);
+    qdev_set_nic_properties(&dev->qdev, nd);
+    qdev_init_nofail(&dev->qdev);
+}
+
+static ISADeviceInfo pc98_ne2000_info = {
+    .qdev.name  = "pc98_ne2k",
+    .qdev.size  = sizeof(ISANE2000State),
+    .init       = pc98_ne2000_initfn,
+    .qdev.props = (Property[]) {
+        DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0xd0),
+        DEFINE_PROP_UINT32("irq",   ISANE2000State, isairq, 3),
+        DEFINE_NIC_PROPERTIES(ISANE2000State, ne2000.c),
+        DEFINE_PROP_END_OF_LIST(),
+    },
+};
+
 static void ne2000_isa_register_devices(void)
 {
     isa_qdev_register(&ne2000_isa_info);
+    isa_qdev_register(&pc98_ne2000_info);
 }
 
 device_init(ne2000_isa_register_devices)