qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Add rtl8139b


From: takasi-y
Subject: [Qemu-devel] [PATCH] Add rtl8139b
Date: Mon, 15 Dec 2008 03:50:11 +0900 (JST)

This adds support for RTL8139 below Rev.C.
Name is "rtl8139b".
"rtl8139" is still RTL8139C and above as it was.

Signed-off-by: Takashi YOSHII <address@hidden>
---

Now hw/rtl8139.c can switch RTL8139C+ and others(call them B- here)
 by CPP definition. Actually, a difference is PCI id 1 byte.

But compile-time switch is hard to utilize because one binary support
multiple architecture.
This patch adds a capability to switch them runtime(on invoking qemu).

Now, RTL8139B- is referred by name "rtl8139b".
So, you can enable it with option "-net nic,model=rtl8139b"

The name "rtl8139" refers RTL8139C+ same as it was.
For users, this change should be seen as adding RTL8139B- but any other change.

---
 hw/pci.c     |    4 +++-
 hw/pci.h     |    1 +
 hw/rtl8139.c |   22 +++++++++++++++++-----
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 0689529..5415400 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -650,13 +650,15 @@ void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
         pci_i82559er_init(bus, nd, devfn);
     } else if (strcmp(nd->model, "rtl8139") == 0) {
         pci_rtl8139_init(bus, nd, devfn);
+    } else if (strcmp(nd->model, "rtl8139b") == 0) {
+        pci_rtl8139b_init(bus, nd, devfn);
     } else if (strcmp(nd->model, "e1000") == 0) {
         pci_e1000_init(bus, nd, devfn);
     } else if (strcmp(nd->model, "pcnet") == 0) {
         pci_pcnet_init(bus, nd, devfn);
     } else if (strcmp(nd->model, "?") == 0) {
         fprintf(stderr, "qemu: Supported PCI NICs: i82551 i82557b i82559er"
-                        " ne2k_pci pcnet rtl8139 e1000\n");
+                        " ne2k_pci pcnet rtl8139 rtl8139b e1000\n");
         exit (1);
     } else {
         fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
diff --git a/hw/pci.h b/hw/pci.h
index 669703e..8ecec22 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -137,6 +137,7 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
 /* rtl8139.c */
 
 void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
+void pci_rtl8139b_init(PCIBus *bus, NICInfo *nd, int devfn);
 
 /* e1000.c */
 void pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn);
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index c3ab854..d717a7b 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -349,8 +349,6 @@ enum chip_flags {
 #define RTL8139_PCI_REVID_8139      0x10
 #define RTL8139_PCI_REVID_8139CPLUS 0x20
 
-#define RTL8139_PCI_REVID           RTL8139_PCI_REVID_8139CPLUS
-
 /* Size is 64 * 16bit words */
 #define EEPROM_9346_ADDR_BITS 6
 #define EEPROM_9346_SIZE  (1 << EEPROM_9346_ADDR_BITS)
@@ -2856,7 +2854,7 @@ static uint32_t rtl8139_io_readb(void *opaque, uint8_t 
addr)
             break;
 
         case PCIRevisionID:
-            ret = RTL8139_PCI_REVID;
+            ret = s->pci_dev->config[0x08];
             DEBUG_PRINT(("RTL8139: PCI Revision ID read 0x%x\n", ret));
             break;
 
@@ -3400,7 +3398,7 @@ static void rtl8139_timer(void *opaque)
 }
 #endif /* RTL8139_ONBOARD_TIMER */
 
-void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
+RTL8139State *pci_rtl8139_common_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
     PCIRTL8139State *d;
     RTL8139State *s;
@@ -3416,7 +3414,6 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
     pci_conf[0x02] = 0x39;
     pci_conf[0x03] = 0x81;
     pci_conf[0x04] = 0x05; /* command = I/O space, Bus Master */
-    pci_conf[0x08] = RTL8139_PCI_REVID; /* PCI revision ID; >=0x20 is for 
8139C+ */
     pci_conf[0x0a] = 0x00; /* ethernet network controller */
     pci_conf[0x0b] = 0x02;
     pci_conf[0x0e] = 0x00; /* header_type */
@@ -3462,4 +3459,19 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int 
devfn)
     qemu_mod_timer(s->timer,
         rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
 #endif /* RTL8139_ONBOARD_TIMER */
+    return s;
+}
+
+void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
+{
+    RTL8139State *s;
+    s = pci_rtl8139_common_init(bus, nd, devfn);
+    s->pci_dev->config[0x08] = RTL8139_PCI_REVID_8139CPLUS;
+}
+
+void pci_rtl8139b_init(PCIBus *bus, NICInfo *nd, int devfn)
+{
+    RTL8139State *s;
+    s = pci_rtl8139_common_init(bus, nd, devfn);
+    s->pci_dev->config[0x08] = RTL8139_PCI_REVID_8139;
 }
-- 
1.5.6.3

/yoshii




reply via email to

[Prev in Thread] Current Thread [Next in Thread]