225
225
#define MIN_BUF_SIZE 60
227
static void ne2000_receive(void *opaque, const uint8_t *buf, int size)
227
static ssize_t ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size_)
229
NE2000State *s = opaque;
229
NE2000State *s = vc->opaque;
231
232
unsigned int total_len, next, avail, len, index, mcast_idx;
232
233
uint8_t buf1[60];
759
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
760
ne2000_receive, ne2000_can_receive,
761
isa_ne2000_cleanup, s);
762
s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
763
ne2000_can_receive, ne2000_receive,
764
NULL, isa_ne2000_cleanup, s);
763
766
qemu_format_nic_info_str(s->vc, s->macaddr);
800
803
unregister_savevm("ne2000", s);
803
PCIDevice *pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
806
static void pci_ne2000_init(PCIDevice *pci_dev)
808
PCINE2000State *d = (PCINE2000State *)pci_dev;
807
810
uint8_t *pci_conf;
809
d = (PCINE2000State *)pci_register_device(bus,
810
"NE2000", sizeof(PCINE2000State),
816
812
pci_conf = d->dev.config;
817
813
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_REALTEK);
818
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_RTL8029);
814
pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_REALTEK_8029);
819
815
pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
820
pci_conf[0x0e] = 0x00; // header_type
816
pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
821
817
pci_conf[0x3d] = 1; // interrupt pin 0
823
pci_register_io_region(&d->dev, 0, 0x100,
819
pci_register_bar(&d->dev, 0, 0x100,
824
820
PCI_ADDRESS_SPACE_IO, ne2000_map);
826
822
s->irq = d->dev.irq[0];
827
823
s->pci_dev = (PCIDevice *)d;
828
memcpy(s->macaddr, nd->macaddr, 6);
824
qdev_get_macaddr(&d->dev.qdev, s->macaddr);
830
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
831
ne2000_receive, ne2000_can_receive,
826
s->vc = qdev_get_vlan_client(&d->dev.qdev,
827
ne2000_can_receive, ne2000_receive, NULL,
832
828
ne2000_cleanup, s);
834
830
qemu_format_nic_info_str(s->vc, s->macaddr);
836
832
register_savevm("ne2000", -1, 3, ne2000_save, ne2000_load, s);
838
return (PCIDevice *)d;
835
static PCIDeviceInfo ne2000_info = {
836
.qdev.name = "ne2k_pci",
837
.qdev.size = sizeof(PCINE2000State),
838
.init = pci_ne2000_init,
841
static void ne2000_register_devices(void)
843
pci_qdev_register(&ne2000_info);
846
device_init(ne2000_register_devices)