* [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code
@ 2019-05-04 12:35 Philippe Mathieu-Daudé
2019-05-04 12:35 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-04 12:35 UTC (permalink / raw)
To: qemu-devel
Cc: Jason Wang, Thomas Huth, Paolo Bonzini,
Philippe Mathieu-Daudé
The ne2000.c file contains functions common the the ISA and PCI
devices. To allow to build with one or another, extract the PCI
specific part into a new file.
This fix an issue where the NE2000_ISA Kconfig had to pull the
full PCI core objects.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/net/Kconfig | 7 ++-
hw/net/Makefile.objs | 3 +-
hw/net/ne2000-pci.c | 132 +++++++++++++++++++++++++++++++++++++++++++
hw/net/ne2000.c | 105 ----------------------------------
4 files changed, 139 insertions(+), 108 deletions(-)
create mode 100644 hw/net/ne2000-pci.c
diff --git a/hw/net/Kconfig b/hw/net/Kconfig
index 7d7bbc5d7c9..4ef86dc3a53 100644
--- a/hw/net/Kconfig
+++ b/hw/net/Kconfig
@@ -1,10 +1,14 @@
config DP8393X
bool
+config NE2000_COMMON
+ bool
+
config NE2000_PCI
bool
default y if PCI_DEVICES
depends on PCI
+ select NE2000_COMMON
config EEPRO100_PCI
bool
@@ -51,8 +55,7 @@ config NE2000_ISA
bool
default y
depends on ISA_BUS
- depends on PCI # for NE2000State
- select NE2000_PCI
+ select NE2000_COMMON
config OPENCORES_ETH
bool
diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs
index ea637157802..9904273b060 100644
--- a/hw/net/Makefile.objs
+++ b/hw/net/Makefile.objs
@@ -1,8 +1,9 @@
common-obj-$(CONFIG_DP8393X) += dp8393x.o
common-obj-$(CONFIG_XEN) += xen_nic.o
+common-obj-$(CONFIG_NE2000_COMMON) += ne2000.o
# PCI network cards
-common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
+common-obj-$(CONFIG_NE2000_PCI) += ne2000-pci.o
common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
common-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o
common-obj-$(CONFIG_PCNET_COMMON) += pcnet.o
diff --git a/hw/net/ne2000-pci.c b/hw/net/ne2000-pci.c
new file mode 100644
index 00000000000..cb05744f3c3
--- /dev/null
+++ b/hw/net/ne2000-pci.c
@@ -0,0 +1,132 @@
+/*
+ * QEMU NE2000 emulation (PCI bus)
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * 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 "qemu/osdep.h"
+#include "hw/pci/pci.h"
+#include "ne2000.h"
+#include "sysemu/sysemu.h"
+
+typedef struct PCINE2000State {
+ PCIDevice dev;
+ NE2000State ne2000;
+} PCINE2000State;
+
+static const VMStateDescription vmstate_pci_ne2000 = {
+ .name = "ne2000",
+ .version_id = 3,
+ .minimum_version_id = 3,
+ .fields = (VMStateField[]) {
+ VMSTATE_PCI_DEVICE(dev, PCINE2000State),
+ VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static NetClientInfo net_ne2000_info = {
+ .type = NET_CLIENT_DRIVER_NIC,
+ .size = sizeof(NICState),
+ .receive = ne2000_receive,
+};
+
+static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp)
+{
+ PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+ NE2000State *s;
+ uint8_t *pci_conf;
+
+ pci_conf = d->dev.config;
+ pci_conf[PCI_INTERRUPT_PIN] = 1; /* interrupt pin A */
+
+ s = &d->ne2000;
+ ne2000_setup_io(s, DEVICE(pci_dev), 0x100);
+ pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
+ s->irq = pci_allocate_irq(&d->dev);
+
+ qemu_macaddr_default_if_unset(&s->c.macaddr);
+ ne2000_reset(s);
+
+ s->nic = qemu_new_nic(&net_ne2000_info, &s->c,
+ object_get_typename(OBJECT(pci_dev)),
+ pci_dev->qdev.id, s);
+ qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
+}
+
+static void pci_ne2000_exit(PCIDevice *pci_dev)
+{
+ PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+ NE2000State *s = &d->ne2000;
+
+ qemu_del_nic(s->nic);
+ qemu_free_irq(s->irq);
+}
+
+static void ne2000_instance_init(Object *obj)
+{
+ PCIDevice *pci_dev = PCI_DEVICE(obj);
+ PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+ NE2000State *s = &d->ne2000;
+
+ device_add_bootindex_property(obj, &s->c.bootindex,
+ "bootindex", "/ethernet-phy@0",
+ &pci_dev->qdev, NULL);
+}
+
+static Property ne2000_properties[] = {
+ DEFINE_NIC_PROPERTIES(PCINE2000State, ne2000.c),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void ne2000_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->realize = pci_ne2000_realize;
+ k->exit = pci_ne2000_exit;
+ k->romfile = "efi-ne2k_pci.rom",
+ k->vendor_id = PCI_VENDOR_ID_REALTEK;
+ k->device_id = PCI_DEVICE_ID_REALTEK_8029;
+ k->class_id = PCI_CLASS_NETWORK_ETHERNET;
+ dc->vmsd = &vmstate_pci_ne2000;
+ dc->props = ne2000_properties;
+ set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
+}
+
+static const TypeInfo ne2000_info = {
+ .name = "ne2k_pci",
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(PCINE2000State),
+ .class_init = ne2000_class_init,
+ .instance_init = ne2000_instance_init,
+ .interfaces = (InterfaceInfo[]) {
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+ { },
+ },
+};
+
+static void ne2000_register_types(void)
+{
+ type_register_static(&ne2000_info);
+}
+
+type_init(ne2000_register_types)
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 037afc8052a..ca792d96f1b 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
-#include "hw/pci/pci.h"
#include "net/eth.h"
#include "ne2000.h"
#include "sysemu/sysemu.h"
@@ -118,11 +117,6 @@
#define ENTSR_CDH 0x40 /* The collision detect "heartbeat" signal was lost. */
#define ENTSR_OWC 0x80 /* There was an out-of-window collision. */
-typedef struct PCINE2000State {
- PCIDevice dev;
- NE2000State ne2000;
-} PCINE2000State;
-
void ne2000_reset(NE2000State *s)
{
int i;
@@ -644,17 +638,6 @@ const VMStateDescription vmstate_ne2000 = {
}
};
-static const VMStateDescription vmstate_pci_ne2000 = {
- .name = "ne2000",
- .version_id = 3,
- .minimum_version_id = 3,
- .fields = (VMStateField[]) {
- VMSTATE_PCI_DEVICE(dev, PCINE2000State),
- VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
- VMSTATE_END_OF_LIST()
- }
-};
-
static uint64_t ne2000_read(void *opaque, hwaddr addr,
unsigned size)
{
@@ -711,91 +694,3 @@ void ne2000_setup_io(NE2000State *s, DeviceState *dev, unsigned size)
{
memory_region_init_io(&s->io, OBJECT(dev), &ne2000_ops, s, "ne2000", size);
}
-
-static NetClientInfo net_ne2000_info = {
- .type = NET_CLIENT_DRIVER_NIC,
- .size = sizeof(NICState),
- .receive = ne2000_receive,
-};
-
-static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp)
-{
- PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
- NE2000State *s;
- uint8_t *pci_conf;
-
- pci_conf = d->dev.config;
- pci_conf[PCI_INTERRUPT_PIN] = 1; /* interrupt pin A */
-
- s = &d->ne2000;
- ne2000_setup_io(s, DEVICE(pci_dev), 0x100);
- pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
- s->irq = pci_allocate_irq(&d->dev);
-
- qemu_macaddr_default_if_unset(&s->c.macaddr);
- ne2000_reset(s);
-
- s->nic = qemu_new_nic(&net_ne2000_info, &s->c,
- object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s);
- qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
-}
-
-static void pci_ne2000_exit(PCIDevice *pci_dev)
-{
- PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
- NE2000State *s = &d->ne2000;
-
- qemu_del_nic(s->nic);
- qemu_free_irq(s->irq);
-}
-
-static void ne2000_instance_init(Object *obj)
-{
- PCIDevice *pci_dev = PCI_DEVICE(obj);
- PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
- NE2000State *s = &d->ne2000;
-
- device_add_bootindex_property(obj, &s->c.bootindex,
- "bootindex", "/ethernet-phy@0",
- &pci_dev->qdev, NULL);
-}
-
-static Property ne2000_properties[] = {
- DEFINE_NIC_PROPERTIES(PCINE2000State, ne2000.c),
- DEFINE_PROP_END_OF_LIST(),
-};
-
-static void ne2000_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
- PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
- k->realize = pci_ne2000_realize;
- k->exit = pci_ne2000_exit;
- k->romfile = "efi-ne2k_pci.rom",
- k->vendor_id = PCI_VENDOR_ID_REALTEK;
- k->device_id = PCI_DEVICE_ID_REALTEK_8029;
- k->class_id = PCI_CLASS_NETWORK_ETHERNET;
- dc->vmsd = &vmstate_pci_ne2000;
- dc->props = ne2000_properties;
- set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
-}
-
-static const TypeInfo ne2000_info = {
- .name = "ne2k_pci",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(PCINE2000State),
- .class_init = ne2000_class_init,
- .instance_init = ne2000_instance_init,
- .interfaces = (InterfaceInfo[]) {
- { INTERFACE_CONVENTIONAL_PCI_DEVICE },
- { },
- },
-};
-
-static void ne2000_register_types(void)
-{
- type_register_static(&ne2000_info);
-}
-
-type_init(ne2000_register_types)
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code
2019-05-04 12:35 [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code Philippe Mathieu-Daudé
@ 2019-05-04 12:35 ` Philippe Mathieu-Daudé
2019-05-04 14:09 ` Thomas Huth
2019-05-08 12:15 ` Paolo Bonzini
2 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-04 12:35 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Jason Wang, Philippe Mathieu-Daudé,
Thomas Huth
The ne2000.c file contains functions common the the ISA and PCI
devices. To allow to build with one or another, extract the PCI
specific part into a new file.
This fix an issue where the NE2000_ISA Kconfig had to pull the
full PCI core objects.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/net/Kconfig | 7 ++-
hw/net/Makefile.objs | 3 +-
hw/net/ne2000-pci.c | 132 +++++++++++++++++++++++++++++++++++++++++++
hw/net/ne2000.c | 105 ----------------------------------
4 files changed, 139 insertions(+), 108 deletions(-)
create mode 100644 hw/net/ne2000-pci.c
diff --git a/hw/net/Kconfig b/hw/net/Kconfig
index 7d7bbc5d7c9..4ef86dc3a53 100644
--- a/hw/net/Kconfig
+++ b/hw/net/Kconfig
@@ -1,10 +1,14 @@
config DP8393X
bool
+config NE2000_COMMON
+ bool
+
config NE2000_PCI
bool
default y if PCI_DEVICES
depends on PCI
+ select NE2000_COMMON
config EEPRO100_PCI
bool
@@ -51,8 +55,7 @@ config NE2000_ISA
bool
default y
depends on ISA_BUS
- depends on PCI # for NE2000State
- select NE2000_PCI
+ select NE2000_COMMON
config OPENCORES_ETH
bool
diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs
index ea637157802..9904273b060 100644
--- a/hw/net/Makefile.objs
+++ b/hw/net/Makefile.objs
@@ -1,8 +1,9 @@
common-obj-$(CONFIG_DP8393X) += dp8393x.o
common-obj-$(CONFIG_XEN) += xen_nic.o
+common-obj-$(CONFIG_NE2000_COMMON) += ne2000.o
# PCI network cards
-common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
+common-obj-$(CONFIG_NE2000_PCI) += ne2000-pci.o
common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
common-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o
common-obj-$(CONFIG_PCNET_COMMON) += pcnet.o
diff --git a/hw/net/ne2000-pci.c b/hw/net/ne2000-pci.c
new file mode 100644
index 00000000000..cb05744f3c3
--- /dev/null
+++ b/hw/net/ne2000-pci.c
@@ -0,0 +1,132 @@
+/*
+ * QEMU NE2000 emulation (PCI bus)
+ *
+ * Copyright (c) 2003-2004 Fabrice Bellard
+ *
+ * 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 "qemu/osdep.h"
+#include "hw/pci/pci.h"
+#include "ne2000.h"
+#include "sysemu/sysemu.h"
+
+typedef struct PCINE2000State {
+ PCIDevice dev;
+ NE2000State ne2000;
+} PCINE2000State;
+
+static const VMStateDescription vmstate_pci_ne2000 = {
+ .name = "ne2000",
+ .version_id = 3,
+ .minimum_version_id = 3,
+ .fields = (VMStateField[]) {
+ VMSTATE_PCI_DEVICE(dev, PCINE2000State),
+ VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static NetClientInfo net_ne2000_info = {
+ .type = NET_CLIENT_DRIVER_NIC,
+ .size = sizeof(NICState),
+ .receive = ne2000_receive,
+};
+
+static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp)
+{
+ PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+ NE2000State *s;
+ uint8_t *pci_conf;
+
+ pci_conf = d->dev.config;
+ pci_conf[PCI_INTERRUPT_PIN] = 1; /* interrupt pin A */
+
+ s = &d->ne2000;
+ ne2000_setup_io(s, DEVICE(pci_dev), 0x100);
+ pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
+ s->irq = pci_allocate_irq(&d->dev);
+
+ qemu_macaddr_default_if_unset(&s->c.macaddr);
+ ne2000_reset(s);
+
+ s->nic = qemu_new_nic(&net_ne2000_info, &s->c,
+ object_get_typename(OBJECT(pci_dev)),
+ pci_dev->qdev.id, s);
+ qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
+}
+
+static void pci_ne2000_exit(PCIDevice *pci_dev)
+{
+ PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+ NE2000State *s = &d->ne2000;
+
+ qemu_del_nic(s->nic);
+ qemu_free_irq(s->irq);
+}
+
+static void ne2000_instance_init(Object *obj)
+{
+ PCIDevice *pci_dev = PCI_DEVICE(obj);
+ PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+ NE2000State *s = &d->ne2000;
+
+ device_add_bootindex_property(obj, &s->c.bootindex,
+ "bootindex", "/ethernet-phy@0",
+ &pci_dev->qdev, NULL);
+}
+
+static Property ne2000_properties[] = {
+ DEFINE_NIC_PROPERTIES(PCINE2000State, ne2000.c),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void ne2000_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->realize = pci_ne2000_realize;
+ k->exit = pci_ne2000_exit;
+ k->romfile = "efi-ne2k_pci.rom",
+ k->vendor_id = PCI_VENDOR_ID_REALTEK;
+ k->device_id = PCI_DEVICE_ID_REALTEK_8029;
+ k->class_id = PCI_CLASS_NETWORK_ETHERNET;
+ dc->vmsd = &vmstate_pci_ne2000;
+ dc->props = ne2000_properties;
+ set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
+}
+
+static const TypeInfo ne2000_info = {
+ .name = "ne2k_pci",
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(PCINE2000State),
+ .class_init = ne2000_class_init,
+ .instance_init = ne2000_instance_init,
+ .interfaces = (InterfaceInfo[]) {
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+ { },
+ },
+};
+
+static void ne2000_register_types(void)
+{
+ type_register_static(&ne2000_info);
+}
+
+type_init(ne2000_register_types)
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 037afc8052a..ca792d96f1b 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -22,7 +22,6 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
-#include "hw/pci/pci.h"
#include "net/eth.h"
#include "ne2000.h"
#include "sysemu/sysemu.h"
@@ -118,11 +117,6 @@
#define ENTSR_CDH 0x40 /* The collision detect "heartbeat" signal was lost. */
#define ENTSR_OWC 0x80 /* There was an out-of-window collision. */
-typedef struct PCINE2000State {
- PCIDevice dev;
- NE2000State ne2000;
-} PCINE2000State;
-
void ne2000_reset(NE2000State *s)
{
int i;
@@ -644,17 +638,6 @@ const VMStateDescription vmstate_ne2000 = {
}
};
-static const VMStateDescription vmstate_pci_ne2000 = {
- .name = "ne2000",
- .version_id = 3,
- .minimum_version_id = 3,
- .fields = (VMStateField[]) {
- VMSTATE_PCI_DEVICE(dev, PCINE2000State),
- VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
- VMSTATE_END_OF_LIST()
- }
-};
-
static uint64_t ne2000_read(void *opaque, hwaddr addr,
unsigned size)
{
@@ -711,91 +694,3 @@ void ne2000_setup_io(NE2000State *s, DeviceState *dev, unsigned size)
{
memory_region_init_io(&s->io, OBJECT(dev), &ne2000_ops, s, "ne2000", size);
}
-
-static NetClientInfo net_ne2000_info = {
- .type = NET_CLIENT_DRIVER_NIC,
- .size = sizeof(NICState),
- .receive = ne2000_receive,
-};
-
-static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp)
-{
- PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
- NE2000State *s;
- uint8_t *pci_conf;
-
- pci_conf = d->dev.config;
- pci_conf[PCI_INTERRUPT_PIN] = 1; /* interrupt pin A */
-
- s = &d->ne2000;
- ne2000_setup_io(s, DEVICE(pci_dev), 0x100);
- pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
- s->irq = pci_allocate_irq(&d->dev);
-
- qemu_macaddr_default_if_unset(&s->c.macaddr);
- ne2000_reset(s);
-
- s->nic = qemu_new_nic(&net_ne2000_info, &s->c,
- object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s);
- qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
-}
-
-static void pci_ne2000_exit(PCIDevice *pci_dev)
-{
- PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
- NE2000State *s = &d->ne2000;
-
- qemu_del_nic(s->nic);
- qemu_free_irq(s->irq);
-}
-
-static void ne2000_instance_init(Object *obj)
-{
- PCIDevice *pci_dev = PCI_DEVICE(obj);
- PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
- NE2000State *s = &d->ne2000;
-
- device_add_bootindex_property(obj, &s->c.bootindex,
- "bootindex", "/ethernet-phy@0",
- &pci_dev->qdev, NULL);
-}
-
-static Property ne2000_properties[] = {
- DEFINE_NIC_PROPERTIES(PCINE2000State, ne2000.c),
- DEFINE_PROP_END_OF_LIST(),
-};
-
-static void ne2000_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
- PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
-
- k->realize = pci_ne2000_realize;
- k->exit = pci_ne2000_exit;
- k->romfile = "efi-ne2k_pci.rom",
- k->vendor_id = PCI_VENDOR_ID_REALTEK;
- k->device_id = PCI_DEVICE_ID_REALTEK_8029;
- k->class_id = PCI_CLASS_NETWORK_ETHERNET;
- dc->vmsd = &vmstate_pci_ne2000;
- dc->props = ne2000_properties;
- set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
-}
-
-static const TypeInfo ne2000_info = {
- .name = "ne2k_pci",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(PCINE2000State),
- .class_init = ne2000_class_init,
- .instance_init = ne2000_instance_init,
- .interfaces = (InterfaceInfo[]) {
- { INTERFACE_CONVENTIONAL_PCI_DEVICE },
- { },
- },
-};
-
-static void ne2000_register_types(void)
-{
- type_register_static(&ne2000_info);
-}
-
-type_init(ne2000_register_types)
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code
2019-05-04 12:35 [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code Philippe Mathieu-Daudé
2019-05-04 12:35 ` Philippe Mathieu-Daudé
@ 2019-05-04 14:09 ` Thomas Huth
2019-05-04 14:09 ` Thomas Huth
2019-05-04 14:17 ` Philippe Mathieu-Daudé
2019-05-08 12:15 ` Paolo Bonzini
2 siblings, 2 replies; 7+ messages in thread
From: Thomas Huth @ 2019-05-04 14:09 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Jason Wang, Paolo Bonzini, QEMU Trivial
On 04/05/2019 14.35, Philippe Mathieu-Daudé wrote:
> The ne2000.c file contains functions common the the ISA and PCI
> devices. To allow to build with one or another, extract the PCI
> specific part into a new file.
>
> This fix an issue where the NE2000_ISA Kconfig had to pull the
> full PCI core objects.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/net/Kconfig | 7 ++-
> hw/net/Makefile.objs | 3 +-
> hw/net/ne2000-pci.c | 132 +++++++++++++++++++++++++++++++++++++++++++
> hw/net/ne2000.c | 105 ----------------------------------
> 4 files changed, 139 insertions(+), 108 deletions(-)
> create mode 100644 hw/net/ne2000-pci.c
>
> diff --git a/hw/net/Kconfig b/hw/net/Kconfig
> index 7d7bbc5d7c9..4ef86dc3a53 100644
> --- a/hw/net/Kconfig
> +++ b/hw/net/Kconfig
> @@ -1,10 +1,14 @@
> config DP8393X
> bool
>
> +config NE2000_COMMON
> + bool
I'd maybe rather simply name it "NE2000" instead of "NE2000_COMMON", but
that's just a matter of taste.
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code
2019-05-04 14:09 ` Thomas Huth
@ 2019-05-04 14:09 ` Thomas Huth
2019-05-04 14:17 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2019-05-04 14:09 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: QEMU Trivial, Paolo Bonzini, Jason Wang
On 04/05/2019 14.35, Philippe Mathieu-Daudé wrote:
> The ne2000.c file contains functions common the the ISA and PCI
> devices. To allow to build with one or another, extract the PCI
> specific part into a new file.
>
> This fix an issue where the NE2000_ISA Kconfig had to pull the
> full PCI core objects.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/net/Kconfig | 7 ++-
> hw/net/Makefile.objs | 3 +-
> hw/net/ne2000-pci.c | 132 +++++++++++++++++++++++++++++++++++++++++++
> hw/net/ne2000.c | 105 ----------------------------------
> 4 files changed, 139 insertions(+), 108 deletions(-)
> create mode 100644 hw/net/ne2000-pci.c
>
> diff --git a/hw/net/Kconfig b/hw/net/Kconfig
> index 7d7bbc5d7c9..4ef86dc3a53 100644
> --- a/hw/net/Kconfig
> +++ b/hw/net/Kconfig
> @@ -1,10 +1,14 @@
> config DP8393X
> bool
>
> +config NE2000_COMMON
> + bool
I'd maybe rather simply name it "NE2000" instead of "NE2000_COMMON", but
that's just a matter of taste.
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code
2019-05-04 14:09 ` Thomas Huth
2019-05-04 14:09 ` Thomas Huth
@ 2019-05-04 14:17 ` Philippe Mathieu-Daudé
2019-05-04 14:17 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-04 14:17 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: Jason Wang, Paolo Bonzini, QEMU Trivial
On 5/4/19 4:09 PM, Thomas Huth wrote:
> On 04/05/2019 14.35, Philippe Mathieu-Daudé wrote:
>> The ne2000.c file contains functions common the the ISA and PCI
>> devices. To allow to build with one or another, extract the PCI
>> specific part into a new file.
>>
>> This fix an issue where the NE2000_ISA Kconfig had to pull the
>> full PCI core objects.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> hw/net/Kconfig | 7 ++-
>> hw/net/Makefile.objs | 3 +-
>> hw/net/ne2000-pci.c | 132 +++++++++++++++++++++++++++++++++++++++++++
>> hw/net/ne2000.c | 105 ----------------------------------
>> 4 files changed, 139 insertions(+), 108 deletions(-)
>> create mode 100644 hw/net/ne2000-pci.c
>>
>> diff --git a/hw/net/Kconfig b/hw/net/Kconfig
>> index 7d7bbc5d7c9..4ef86dc3a53 100644
>> --- a/hw/net/Kconfig
>> +++ b/hw/net/Kconfig
>> @@ -1,10 +1,14 @@
>> config DP8393X
>> bool
>>
>> +config NE2000_COMMON
>> + bool
>
> I'd maybe rather simply name it "NE2000" instead of "NE2000_COMMON", but
> that's just a matter of taste.
I started using this name, but then realized it is confuse and someone
could enable CONFIG_NE2000=y expecting a network device, but none would
be linked.
Paolo, would it be useful to add some 'internal' Kconfig property (like
"default")? So that config is not user-selectable, but only
dependency-selectable. CONFIG_ARM_V7M might be a similar example (we
don't want the user to unselect it).
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code
2019-05-04 14:17 ` Philippe Mathieu-Daudé
@ 2019-05-04 14:17 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-05-04 14:17 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: QEMU Trivial, Paolo Bonzini, Jason Wang
On 5/4/19 4:09 PM, Thomas Huth wrote:
> On 04/05/2019 14.35, Philippe Mathieu-Daudé wrote:
>> The ne2000.c file contains functions common the the ISA and PCI
>> devices. To allow to build with one or another, extract the PCI
>> specific part into a new file.
>>
>> This fix an issue where the NE2000_ISA Kconfig had to pull the
>> full PCI core objects.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> hw/net/Kconfig | 7 ++-
>> hw/net/Makefile.objs | 3 +-
>> hw/net/ne2000-pci.c | 132 +++++++++++++++++++++++++++++++++++++++++++
>> hw/net/ne2000.c | 105 ----------------------------------
>> 4 files changed, 139 insertions(+), 108 deletions(-)
>> create mode 100644 hw/net/ne2000-pci.c
>>
>> diff --git a/hw/net/Kconfig b/hw/net/Kconfig
>> index 7d7bbc5d7c9..4ef86dc3a53 100644
>> --- a/hw/net/Kconfig
>> +++ b/hw/net/Kconfig
>> @@ -1,10 +1,14 @@
>> config DP8393X
>> bool
>>
>> +config NE2000_COMMON
>> + bool
>
> I'd maybe rather simply name it "NE2000" instead of "NE2000_COMMON", but
> that's just a matter of taste.
I started using this name, but then realized it is confuse and someone
could enable CONFIG_NE2000=y expecting a network device, but none would
be linked.
Paolo, would it be useful to add some 'internal' Kconfig property (like
"default")? So that config is not user-selectable, but only
dependency-selectable. CONFIG_ARM_V7M might be a similar example (we
don't want the user to unselect it).
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code
2019-05-04 12:35 [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code Philippe Mathieu-Daudé
2019-05-04 12:35 ` Philippe Mathieu-Daudé
2019-05-04 14:09 ` Thomas Huth
@ 2019-05-08 12:15 ` Paolo Bonzini
2 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2019-05-08 12:15 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Jason Wang, Thomas Huth
On 04/05/19 07:35, Philippe Mathieu-Daudé wrote:
> The ne2000.c file contains functions common the the ISA and PCI
> devices. To allow to build with one or another, extract the PCI
> specific part into a new file.
>
> This fix an issue where the NE2000_ISA Kconfig had to pull the
> full PCI core objects.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/net/Kconfig | 7 ++-
> hw/net/Makefile.objs | 3 +-
> hw/net/ne2000-pci.c | 132 +++++++++++++++++++++++++++++++++++++++++++
> hw/net/ne2000.c | 105 ----------------------------------
> 4 files changed, 139 insertions(+), 108 deletions(-)
> create mode 100644 hw/net/ne2000-pci.c
>
> diff --git a/hw/net/Kconfig b/hw/net/Kconfig
> index 7d7bbc5d7c9..4ef86dc3a53 100644
> --- a/hw/net/Kconfig
> +++ b/hw/net/Kconfig
> @@ -1,10 +1,14 @@
> config DP8393X
> bool
>
> +config NE2000_COMMON
> + bool
> +
> config NE2000_PCI
> bool
> default y if PCI_DEVICES
> depends on PCI
> + select NE2000_COMMON
>
> config EEPRO100_PCI
> bool
> @@ -51,8 +55,7 @@ config NE2000_ISA
> bool
> default y
> depends on ISA_BUS
> - depends on PCI # for NE2000State
> - select NE2000_PCI
> + select NE2000_COMMON
>
> config OPENCORES_ETH
> bool
> diff --git a/hw/net/Makefile.objs b/hw/net/Makefile.objs
> index ea637157802..9904273b060 100644
> --- a/hw/net/Makefile.objs
> +++ b/hw/net/Makefile.objs
> @@ -1,8 +1,9 @@
> common-obj-$(CONFIG_DP8393X) += dp8393x.o
> common-obj-$(CONFIG_XEN) += xen_nic.o
> +common-obj-$(CONFIG_NE2000_COMMON) += ne2000.o
>
> # PCI network cards
> -common-obj-$(CONFIG_NE2000_PCI) += ne2000.o
> +common-obj-$(CONFIG_NE2000_PCI) += ne2000-pci.o
> common-obj-$(CONFIG_EEPRO100_PCI) += eepro100.o
> common-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o
> common-obj-$(CONFIG_PCNET_COMMON) += pcnet.o
> diff --git a/hw/net/ne2000-pci.c b/hw/net/ne2000-pci.c
> new file mode 100644
> index 00000000000..cb05744f3c3
> --- /dev/null
> +++ b/hw/net/ne2000-pci.c
> @@ -0,0 +1,132 @@
> +/*
> + * QEMU NE2000 emulation (PCI bus)
> + *
> + * Copyright (c) 2003-2004 Fabrice Bellard
> + *
> + * 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 "qemu/osdep.h"
> +#include "hw/pci/pci.h"
> +#include "ne2000.h"
> +#include "sysemu/sysemu.h"
> +
> +typedef struct PCINE2000State {
> + PCIDevice dev;
> + NE2000State ne2000;
> +} PCINE2000State;
> +
> +static const VMStateDescription vmstate_pci_ne2000 = {
> + .name = "ne2000",
> + .version_id = 3,
> + .minimum_version_id = 3,
> + .fields = (VMStateField[]) {
> + VMSTATE_PCI_DEVICE(dev, PCINE2000State),
> + VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static NetClientInfo net_ne2000_info = {
> + .type = NET_CLIENT_DRIVER_NIC,
> + .size = sizeof(NICState),
> + .receive = ne2000_receive,
> +};
> +
> +static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp)
> +{
> + PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
> + NE2000State *s;
> + uint8_t *pci_conf;
> +
> + pci_conf = d->dev.config;
> + pci_conf[PCI_INTERRUPT_PIN] = 1; /* interrupt pin A */
> +
> + s = &d->ne2000;
> + ne2000_setup_io(s, DEVICE(pci_dev), 0x100);
> + pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
> + s->irq = pci_allocate_irq(&d->dev);
> +
> + qemu_macaddr_default_if_unset(&s->c.macaddr);
> + ne2000_reset(s);
> +
> + s->nic = qemu_new_nic(&net_ne2000_info, &s->c,
> + object_get_typename(OBJECT(pci_dev)),
> + pci_dev->qdev.id, s);
> + qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
> +}
> +
> +static void pci_ne2000_exit(PCIDevice *pci_dev)
> +{
> + PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
> + NE2000State *s = &d->ne2000;
> +
> + qemu_del_nic(s->nic);
> + qemu_free_irq(s->irq);
> +}
> +
> +static void ne2000_instance_init(Object *obj)
> +{
> + PCIDevice *pci_dev = PCI_DEVICE(obj);
> + PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
> + NE2000State *s = &d->ne2000;
> +
> + device_add_bootindex_property(obj, &s->c.bootindex,
> + "bootindex", "/ethernet-phy@0",
> + &pci_dev->qdev, NULL);
> +}
> +
> +static Property ne2000_properties[] = {
> + DEFINE_NIC_PROPERTIES(PCINE2000State, ne2000.c),
> + DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +static void ne2000_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
> + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
> +
> + k->realize = pci_ne2000_realize;
> + k->exit = pci_ne2000_exit;
> + k->romfile = "efi-ne2k_pci.rom",
> + k->vendor_id = PCI_VENDOR_ID_REALTEK;
> + k->device_id = PCI_DEVICE_ID_REALTEK_8029;
> + k->class_id = PCI_CLASS_NETWORK_ETHERNET;
> + dc->vmsd = &vmstate_pci_ne2000;
> + dc->props = ne2000_properties;
> + set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
> +}
> +
> +static const TypeInfo ne2000_info = {
> + .name = "ne2k_pci",
> + .parent = TYPE_PCI_DEVICE,
> + .instance_size = sizeof(PCINE2000State),
> + .class_init = ne2000_class_init,
> + .instance_init = ne2000_instance_init,
> + .interfaces = (InterfaceInfo[]) {
> + { INTERFACE_CONVENTIONAL_PCI_DEVICE },
> + { },
> + },
> +};
> +
> +static void ne2000_register_types(void)
> +{
> + type_register_static(&ne2000_info);
> +}
> +
> +type_init(ne2000_register_types)
> diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
> index 037afc8052a..ca792d96f1b 100644
> --- a/hw/net/ne2000.c
> +++ b/hw/net/ne2000.c
> @@ -22,7 +22,6 @@
> * THE SOFTWARE.
> */
> #include "qemu/osdep.h"
> -#include "hw/pci/pci.h"
> #include "net/eth.h"
> #include "ne2000.h"
> #include "sysemu/sysemu.h"
> @@ -118,11 +117,6 @@
> #define ENTSR_CDH 0x40 /* The collision detect "heartbeat" signal was lost. */
> #define ENTSR_OWC 0x80 /* There was an out-of-window collision. */
>
> -typedef struct PCINE2000State {
> - PCIDevice dev;
> - NE2000State ne2000;
> -} PCINE2000State;
> -
> void ne2000_reset(NE2000State *s)
> {
> int i;
> @@ -644,17 +638,6 @@ const VMStateDescription vmstate_ne2000 = {
> }
> };
>
> -static const VMStateDescription vmstate_pci_ne2000 = {
> - .name = "ne2000",
> - .version_id = 3,
> - .minimum_version_id = 3,
> - .fields = (VMStateField[]) {
> - VMSTATE_PCI_DEVICE(dev, PCINE2000State),
> - VMSTATE_STRUCT(ne2000, PCINE2000State, 0, vmstate_ne2000, NE2000State),
> - VMSTATE_END_OF_LIST()
> - }
> -};
> -
> static uint64_t ne2000_read(void *opaque, hwaddr addr,
> unsigned size)
> {
> @@ -711,91 +694,3 @@ void ne2000_setup_io(NE2000State *s, DeviceState *dev, unsigned size)
> {
> memory_region_init_io(&s->io, OBJECT(dev), &ne2000_ops, s, "ne2000", size);
> }
> -
> -static NetClientInfo net_ne2000_info = {
> - .type = NET_CLIENT_DRIVER_NIC,
> - .size = sizeof(NICState),
> - .receive = ne2000_receive,
> -};
> -
> -static void pci_ne2000_realize(PCIDevice *pci_dev, Error **errp)
> -{
> - PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
> - NE2000State *s;
> - uint8_t *pci_conf;
> -
> - pci_conf = d->dev.config;
> - pci_conf[PCI_INTERRUPT_PIN] = 1; /* interrupt pin A */
> -
> - s = &d->ne2000;
> - ne2000_setup_io(s, DEVICE(pci_dev), 0x100);
> - pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io);
> - s->irq = pci_allocate_irq(&d->dev);
> -
> - qemu_macaddr_default_if_unset(&s->c.macaddr);
> - ne2000_reset(s);
> -
> - s->nic = qemu_new_nic(&net_ne2000_info, &s->c,
> - object_get_typename(OBJECT(pci_dev)), pci_dev->qdev.id, s);
> - qemu_format_nic_info_str(qemu_get_queue(s->nic), s->c.macaddr.a);
> -}
> -
> -static void pci_ne2000_exit(PCIDevice *pci_dev)
> -{
> - PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
> - NE2000State *s = &d->ne2000;
> -
> - qemu_del_nic(s->nic);
> - qemu_free_irq(s->irq);
> -}
> -
> -static void ne2000_instance_init(Object *obj)
> -{
> - PCIDevice *pci_dev = PCI_DEVICE(obj);
> - PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
> - NE2000State *s = &d->ne2000;
> -
> - device_add_bootindex_property(obj, &s->c.bootindex,
> - "bootindex", "/ethernet-phy@0",
> - &pci_dev->qdev, NULL);
> -}
> -
> -static Property ne2000_properties[] = {
> - DEFINE_NIC_PROPERTIES(PCINE2000State, ne2000.c),
> - DEFINE_PROP_END_OF_LIST(),
> -};
> -
> -static void ne2000_class_init(ObjectClass *klass, void *data)
> -{
> - DeviceClass *dc = DEVICE_CLASS(klass);
> - PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
> -
> - k->realize = pci_ne2000_realize;
> - k->exit = pci_ne2000_exit;
> - k->romfile = "efi-ne2k_pci.rom",
> - k->vendor_id = PCI_VENDOR_ID_REALTEK;
> - k->device_id = PCI_DEVICE_ID_REALTEK_8029;
> - k->class_id = PCI_CLASS_NETWORK_ETHERNET;
> - dc->vmsd = &vmstate_pci_ne2000;
> - dc->props = ne2000_properties;
> - set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
> -}
> -
> -static const TypeInfo ne2000_info = {
> - .name = "ne2k_pci",
> - .parent = TYPE_PCI_DEVICE,
> - .instance_size = sizeof(PCINE2000State),
> - .class_init = ne2000_class_init,
> - .instance_init = ne2000_instance_init,
> - .interfaces = (InterfaceInfo[]) {
> - { INTERFACE_CONVENTIONAL_PCI_DEVICE },
> - { },
> - },
> -};
> -
> -static void ne2000_register_types(void)
> -{
> - type_register_static(&ne2000_info);
> -}
> -
> -type_init(ne2000_register_types)
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-05-08 12:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-04 12:35 [Qemu-devel] [PATCH] hw/net/ne2000: Extract the PCI device from the chipset common code Philippe Mathieu-Daudé
2019-05-04 12:35 ` Philippe Mathieu-Daudé
2019-05-04 14:09 ` Thomas Huth
2019-05-04 14:09 ` Thomas Huth
2019-05-04 14:17 ` Philippe Mathieu-Daudé
2019-05-04 14:17 ` Philippe Mathieu-Daudé
2019-05-08 12:15 ` Paolo Bonzini
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).