2 * QEMU i8255x (PRO100) emulation
4 * Copyright (C) 2006-2010 Stefan Weil
6 * Portions of the code are copies from grub / etherboot eepro100.c
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) version 3 or any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 * Tested features (i82559):
24 * Linux networking (i386) ok
32 * Intel 8255x 10/100 Mbps Ethernet Controller Family
33 * Open Source Software Developer Manual
36 * * PHY emulation should be separated from nic emulation.
37 * Most nic emulations could share the same phy code.
38 * * i82550 is untested. It is programmed like the i82559.
39 * * i82562 is untested. It is programmed like the i82559.
40 * * Power management (i82558 and later) is not implemented.
41 * * Wake-on-LAN is not implemented.
44 #include <stddef.h> /* offsetof */
49 #include "eeprom93xx.h"
51 /* Common declarations for all PCI devices. */
53 #define PCI_CONFIG_8(offset, value) \
54 (pci_conf[offset] = (value))
55 #define PCI_CONFIG_16(offset, value) \
56 (*(uint16_t *)&pci_conf[offset] = cpu_to_le16(value))
57 #define PCI_CONFIG_32(offset, value) \
58 (*(uint32_t *)&pci_conf[offset] = cpu_to_le32(value))
62 /* Debug EEPRO100 card. */
64 # define DEBUG_EEPRO100
68 #define logout(fmt, ...) fprintf(stderr, "EE100\t%-24s" fmt, __func__, ## __VA_ARGS__)
70 #define logout(fmt, ...) ((void)0)
73 /* Set flags to 0 to disable debug output. */
74 #define INT 1 /* interrupt related actions */
75 #define MDI 1 /* mdi related actions */
78 #define EEPROM 1 /* eeprom related actions */
80 #define TRACE(flag, command) ((flag) ? (command) : (void)0)
82 #define missing(text) fprintf(stderr, "eepro100: feature is missing in this emulation: " text "\n")
84 #define MAX_ETH_FRAME_SIZE 1514
86 /* This driver supports several different devices which are declared here. */
87 #define i82550 0x82550
88 #define i82551 0x82551
89 #define i82557A 0x82557a
90 #define i82557B 0x82557b
91 #define i82557C 0x82557c
92 #define i82558A 0x82558a
93 #define i82558B 0x82558b
94 #define i82559A 0x82559a
95 #define i82559B 0x82559b
96 #define i82559C 0x82559c
97 #define i82559ER 0x82559e
98 #define i82562 0x82562
100 /* Use 64 word EEPROM. TODO: could be a runtime option. */
101 #define EEPROM_SIZE 64
103 #define PCI_MEM_SIZE (4 * KiB)
104 #define PCI_IO_SIZE 64
105 #define PCI_FLASH_SIZE (128 * KiB)
107 #define BIT(n) (1 << (n))
108 #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
110 /* The SCB accepts the following controls for the Tx and Rx units: */
111 #define CU_NOP 0x0000 /* No operation. */
112 #define CU_START 0x0010 /* CU start. */
113 #define CU_RESUME 0x0020 /* CU resume. */
114 #define CU_STATSADDR 0x0040 /* Load dump counters address. */
115 #define CU_SHOWSTATS 0x0050 /* Dump statistical counters. */
116 #define CU_CMD_BASE 0x0060 /* Load CU base address. */
117 #define CU_DUMPSTATS 0x0070 /* Dump and reset statistical counters. */
118 #define CU_SRESUME 0x00a0 /* CU static resume. */
120 #define RU_NOP 0x0000
121 #define RX_START 0x0001
122 #define RX_RESUME 0x0002
123 #define RU_ABORT 0x0004
124 #define RX_ADDR_LOAD 0x0006
125 #define RX_RESUMENR 0x0007
126 #define INT_MASK 0x0100
127 #define DRVR_INT 0x0200 /* Driver generated interrupt. */
129 /* Offsets to the various registers.
130 All accesses need not be longword aligned. */
131 enum speedo_offsets {
132 SCBStatus = 0, /* Status Word. */
134 SCBCmd = 2, /* Rx/Command Unit command and status. */
136 SCBPointer = 4, /* General purpose pointer. */
137 SCBPort = 8, /* Misc. commands and operands. */
138 SCBflash = 12, /* Flash memory control. */
139 SCBeeprom = 14, /* EEPROM control. */
140 SCBCtrlMDI = 16, /* MDI interface control. */
141 SCBEarlyRx = 20, /* Early receive byte count. */
142 SCBFlow = 24, /* Flow Control. */
143 SCBpmdr = 27, /* Power Management Driver. */
144 SCBgctrl = 28, /* General Control. */
145 SCBgstat = 29, /* General Status. */
148 /* A speedo3 transmit buffer descriptor with two buffers... */
152 uint32_t link; /* void * */
153 uint32_t tbd_array_addr; /* transmit buffer descriptor array address. */
154 uint16_t tcb_bytes; /* transmit command block byte count (in lower 14 bits */
155 uint8_t tx_threshold; /* transmit threshold */
156 uint8_t tbd_count; /* TBD number */
158 /* This constitutes two "TBD" entries: hdr and data */
159 uint32_t tx_buf_addr0; /* void *, header of frame to be transmitted. */
160 int32_t tx_buf_size0; /* Length of Tx hdr. */
161 uint32_t tx_buf_addr1; /* void *, data to be transmitted. */
162 int32_t tx_buf_size1; /* Length of Tx data. */
166 /* Receive frame descriptor. */
170 uint32_t link; /* struct RxFD * */
171 uint32_t rx_buf_addr; /* void * */
174 char packet[MAX_ETH_FRAME_SIZE + 4];
178 COMMAND_EL = BIT(15),
183 COMMAND_CMD = BITS(2, 0),
192 uint32_t tx_good_frames, tx_max_collisions, tx_late_collisions,
193 tx_underruns, tx_lost_crs, tx_deferred, tx_single_collisions,
194 tx_multiple_collisions, tx_total_collisions;
195 uint32_t rx_good_frames, rx_crc_errors, rx_alignment_errors,
196 rx_resource_errors, rx_overrun_errors, rx_cdt_errors,
197 rx_short_frame_errors;
198 uint32_t fc_xmt_pause, fc_rcv_pause, fc_rcv_unsupported;
199 uint16_t xmt_tco_frames, rcv_tco_frames;
200 /* TODO: i82559 has six reserved statistics but a total of 24 dwords. */
201 uint32_t reserved[4];
221 uint8_t mult[8]; /* multicast mask array */
225 uint8_t scb_stat; /* SCB stat/ack byte */
226 uint8_t int_stat; /* PCI interrupt status */
227 /* region must not be saved by nic_save. */
228 uint32_t region[3]; /* PCI region addresses */
231 uint32_t device; /* device variant */
233 /* (cu_base + cu_offset) address the next command block in the command block list. */
234 uint32_t cu_base; /* CU base address */
235 uint32_t cu_offset; /* CU address offset */
236 /* (ru_base + ru_offset) address the RFD in the Receive Frame Area. */
237 uint32_t ru_base; /* RU base address */
238 uint32_t ru_offset; /* RU address offset */
239 uint32_t statsaddr; /* pointer to eepro100_stats_t */
241 /* Temporary status information (no need to save these values),
242 * used while processing CU commands. */
243 eepro100_tx_t tx; /* transmit buffer descriptor */
244 uint32_t cb_address; /* = cu_base + cu_offset */
246 /* Statistical counters. Also used for wake-up packet (i82559). */
247 eepro100_stats_t statistics;
253 /* Configuration bytes. */
254 uint8_t configuration[22];
256 /* Data in mem is always in the byte order of the controller (le). */
257 uint8_t mem[PCI_MEM_SIZE];
258 /* vmstate for each particular nic */
259 VMStateDescription *vmstate;
261 /* Quasi static device properties (no need to save them). */
263 bool has_extended_tcb_support;
266 /* Word indices in EEPROM. */
268 EEPROM_CNFG_MDIX = 0x03,
270 EEPROM_PHY_ID = 0x06,
271 EEPROM_VENDOR_ID = 0x0c,
272 EEPROM_CONFIG_ASF = 0x0d,
273 EEPROM_DEVICE_ID = 0x23,
274 EEPROM_SMBUS_ADDR = 0x90,
277 /* Bit values for EEPROM ID word. */
279 EEPROM_ID_MDM = BIT(0), /* Modem */
280 EEPROM_ID_STB = BIT(1), /* Standby Enable */
281 EEPROM_ID_WMR = BIT(2), /* ??? */
282 EEPROM_ID_WOL = BIT(5), /* Wake on LAN */
283 EEPROM_ID_DPD = BIT(6), /* Deep Power Down */
284 EEPROM_ID_ALT = BIT(7), /* */
285 /* BITS(10, 8) device revision */
286 EEPROM_ID_BD = BIT(11), /* boot disable */
287 EEPROM_ID_ID = BIT(13), /* id bit */
288 /* BITS(15, 14) signature */
289 EEPROM_ID_VALID = BIT(14), /* signature for valid eeprom */
292 /* Default values for MDI (PHY) registers */
293 static const uint16_t eepro100_mdi_default[] = {
294 /* MDI Registers 0 - 6, 7 */
295 0x3000, 0x780d, 0x02a8, 0x0154, 0x05e1, 0x0000, 0x0000, 0x0000,
296 /* MDI Registers 8 - 15 */
297 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
298 /* MDI Registers 16 - 31 */
299 0x0003, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
300 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
303 /* Readonly mask for MDI (PHY) registers */
304 static const uint16_t eepro100_mdi_mask[] = {
305 0x0000, 0xffff, 0xffff, 0xffff, 0xc01f, 0xffff, 0xffff, 0x0000,
306 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
307 0x0fff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
308 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
312 static void stl_le_phys(target_phys_addr_t addr, uint32_t val)
314 val = cpu_to_le32(val);
315 cpu_physical_memory_write(addr, (const uint8_t *)&val, sizeof(val));
318 #define POLYNOMIAL 0x04c11db6
322 static unsigned compute_mcast_idx(const uint8_t * ep)
329 for (i = 0; i < 6; i++) {
331 for (j = 0; j < 8; j++) {
332 carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
336 crc = ((crc ^ POLYNOMIAL) | carry);
340 return (crc & BITS(7, 2)) >> 2;
343 #if defined(DEBUG_EEPRO100)
344 static const char *nic_dump(const uint8_t * buf, unsigned size)
346 static char dump[3 * 16 + 1];
352 p += sprintf(p, " %02x", *buf++);
356 #endif /* DEBUG_EEPRO100 */
359 stat_ack_not_ours = 0x00,
360 stat_ack_sw_gen = 0x04,
362 stat_ack_cu_idle = 0x20,
363 stat_ack_frame_rx = 0x40,
364 stat_ack_cu_cmd_done = 0x80,
365 stat_ack_not_present = 0xFF,
366 stat_ack_rx = (stat_ack_sw_gen | stat_ack_rnr | stat_ack_frame_rx),
367 stat_ack_tx = (stat_ack_cu_idle | stat_ack_cu_cmd_done),
370 static void disable_interrupt(EEPRO100State * s)
373 TRACE(INT, logout("interrupt disabled\n"));
374 qemu_irq_lower(s->dev.irq[0]);
379 static void enable_interrupt(EEPRO100State * s)
382 TRACE(INT, logout("interrupt enabled\n"));
383 qemu_irq_raise(s->dev.irq[0]);
388 static void eepro100_acknowledge(EEPRO100State * s)
390 s->scb_stat &= ~s->mem[SCBAck];
391 s->mem[SCBAck] = s->scb_stat;
392 if (s->scb_stat == 0) {
393 disable_interrupt(s);
397 static void eepro100_interrupt(EEPRO100State * s, uint8_t status)
399 uint8_t mask = ~s->mem[SCBIntmask];
400 s->mem[SCBAck] |= status;
401 status = s->scb_stat = s->mem[SCBAck];
402 status &= (mask | 0x0f);
404 status &= (~s->mem[SCBIntmask] | 0x0xf);
406 if (status && (mask & 0x01)) {
407 /* SCB mask and SCB Bit M do not disable interrupt. */
409 } else if (s->int_stat) {
410 disable_interrupt(s);
414 static void eepro100_cx_interrupt(EEPRO100State * s)
416 /* CU completed action command. */
417 /* Transmit not ok (82557 only, not in emulation). */
418 eepro100_interrupt(s, 0x80);
421 static void eepro100_cna_interrupt(EEPRO100State * s)
423 /* CU left the active state. */
424 eepro100_interrupt(s, 0x20);
427 static void eepro100_fr_interrupt(EEPRO100State * s)
429 /* RU received a complete frame. */
430 eepro100_interrupt(s, 0x40);
433 static void eepro100_rnr_interrupt(EEPRO100State * s)
435 /* RU is not ready. */
436 eepro100_interrupt(s, 0x10);
439 static void eepro100_mdi_interrupt(EEPRO100State * s)
441 /* MDI completed read or write cycle. */
442 eepro100_interrupt(s, 0x08);
445 static void eepro100_swi_interrupt(EEPRO100State * s)
447 /* Software has requested an interrupt. */
448 eepro100_interrupt(s, 0x04);
452 static void eepro100_fcp_interrupt(EEPRO100State * s)
454 /* Flow control pause interrupt (82558 and later). */
455 eepro100_interrupt(s, 0x01);
459 static void pci_reset(EEPRO100State * s)
461 uint32_t device = s->device;
462 uint8_t *pci_conf = s->dev.config;
463 bool power_management = 1;
465 TRACE(OTHER, logout("%p\n", s));
468 pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
469 /* PCI Device ID depends on device and is set below. */
471 /* TODO: this is the default, do not override. */
472 PCI_CONFIG_16(PCI_COMMAND, 0x0000);
474 /* TODO: Value at RST# should be 0. */
475 PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_FAST_BACK);
476 /* PCI Revision ID */
477 PCI_CONFIG_8(PCI_REVISION_ID, 0x08);
478 /* TODO: this is the default, do not override. */
480 PCI_CONFIG_8(PCI_CLASS_PROG, 0x00);
481 pci_config_set_class(pci_conf, PCI_CLASS_NETWORK_ETHERNET);
482 /* PCI Cache Line Size */
483 /* check cache line size!!! */
485 PCI_CONFIG_8(0x0c, 0x00);
487 /* PCI Latency Timer */
488 PCI_CONFIG_8(PCI_LATENCY_TIMER, 0x20); /* latency timer = 32 clocks */
489 /* PCI Header Type */
490 /* BIST (built-in self test) */
491 /* Expansion ROM Base Address (depends on boot disable!!!) */
492 /* TODO: not needed, set when BAR is registered */
493 PCI_CONFIG_32(PCI_ROM_ADDRESS, PCI_BASE_ADDRESS_SPACE_MEMORY);
494 /* Capability Pointer */
495 /* TODO: revisions with power_management 1 use this but
496 * do not set new capability list bit in status register. */
497 PCI_CONFIG_8(PCI_CAPABILITY_LIST, 0xdc);
500 /* TODO: RST# value should be 0 */
501 PCI_CONFIG_8(PCI_INTERRUPT_PIN, 1); /* interrupt pin 0 */
503 PCI_CONFIG_8(PCI_MIN_GNT, 0x08);
504 /* Maximum Latency */
505 PCI_CONFIG_8(PCI_MAX_LAT, 0x18);
509 /* TODO: check device id. */
510 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82551IT);
511 /* Revision ID: 0x0c, 0x0d, 0x0e. */
512 PCI_CONFIG_8(PCI_REVISION_ID, 0x0e);
513 /* TODO: check size of statistical counters. */
515 /* TODO: check extended tcb support. */
516 s->has_extended_tcb_support = 1;
519 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82551IT);
520 /* Revision ID: 0x0f, 0x10. */
521 PCI_CONFIG_8(PCI_REVISION_ID, 0x0f);
522 /* TODO: check size of statistical counters. */
524 s->has_extended_tcb_support = 1;
527 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
528 PCI_CONFIG_8(PCI_REVISION_ID, 0x01);
529 PCI_CONFIG_8(PCI_CAPABILITY_LIST, 0x00);
530 power_management = 0;
533 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
534 PCI_CONFIG_8(PCI_REVISION_ID, 0x02);
535 PCI_CONFIG_8(PCI_CAPABILITY_LIST, 0x00);
536 power_management = 0;
539 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
540 PCI_CONFIG_8(PCI_REVISION_ID, 0x03);
541 PCI_CONFIG_8(PCI_CAPABILITY_LIST, 0x00);
542 power_management = 0;
545 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
546 PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
547 PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
548 PCI_CONFIG_8(PCI_REVISION_ID, 0x04);
550 s->has_extended_tcb_support = 1;
553 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
554 PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
555 PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
556 PCI_CONFIG_8(PCI_REVISION_ID, 0x05);
558 s->has_extended_tcb_support = 1;
561 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
562 PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
563 PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
564 PCI_CONFIG_8(PCI_REVISION_ID, 0x06);
566 s->has_extended_tcb_support = 1;
569 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
570 PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
571 PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
572 PCI_CONFIG_8(PCI_REVISION_ID, 0x07);
574 s->has_extended_tcb_support = 1;
577 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82557);
578 PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
579 PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
580 PCI_CONFIG_8(PCI_REVISION_ID, 0x08);
581 /* TODO: Windows wants revision id 0x0c. */
582 PCI_CONFIG_8(PCI_REVISION_ID, 0x0c);
584 PCI_CONFIG_16(PCI_SUBSYSTEM_VENDOR_ID, 0x8086);
585 PCI_CONFIG_16(PCI_SUBSYSTEM_ID, 0x0040);
588 s->has_extended_tcb_support = 1;
591 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82551IT);
592 PCI_CONFIG_16(PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM |
593 PCI_STATUS_FAST_BACK | PCI_STATUS_CAP_LIST);
594 PCI_CONFIG_8(PCI_REVISION_ID, 0x09);
596 s->has_extended_tcb_support = 1;
599 /* TODO: check device id. */
600 pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82551IT);
601 /* TODO: wrong revision id. */
602 PCI_CONFIG_8(PCI_REVISION_ID, 0x0e);
604 s->has_extended_tcb_support = 1;
607 logout("Device %X is undefined!\n", device);
610 s->configuration[6] |= BIT(5);
612 if (s->stats_size == 80) {
613 /* TODO: check TCO Statistical Counters bit. Documentation not clear. */
614 if (s->configuration[6] & BIT(2)) {
615 /* TCO statistical counters. */
616 assert(s->configuration[6] & BIT(5));
618 if (s->configuration[6] & BIT(5)) {
619 /* No extended statistical counters, i82557 compatible. */
622 /* i82558 compatible. */
627 if (s->configuration[6] & BIT(5)) {
628 /* No extended statistical counters. */
632 assert(s->stats_size > 0 && s->stats_size <= sizeof(s->statistics));
634 if (power_management) {
635 /* Power Management Capabilities */
636 PCI_CONFIG_8(0xdc, 0x01);
637 /* Next Item Pointer */
639 PCI_CONFIG_16(0xde, 0x7e21);
640 /* TODO: Power Management Control / Status. */
641 /* TODO: Ethernet Power Consumption Registers (i82559 and later). */
645 if (device == i82557C || device == i82558B || device == i82559C) {
647 TODO: get vendor id from EEPROM for i82557C or later.
648 TODO: get device id from EEPROM for i82557C or later.
649 TODO: status bit 4 can be disabled by EEPROM for i82558, i82559.
650 TODO: header type is determined by EEPROM for i82559.
651 TODO: get subsystem id from EEPROM for i82557C or later.
652 TODO: get subsystem vendor id from EEPROM for i82557C or later.
653 TODO: exp. rom baddr depends on a bit in EEPROM for i82558 or later.
654 TODO: capability pointer depends on EEPROM for i82558.
656 logout("Get device id and revision from EEPROM!!!\n");
658 #endif /* EEPROM_SIZE > 0 */
661 static void nic_selective_reset(EEPRO100State * s)
664 uint16_t *eeprom_contents = eeprom93xx_data(s->eeprom);
666 eeprom93xx_reset(s->eeprom);
668 memcpy(eeprom_contents, s->conf.macaddr.a, 6);
669 eeprom_contents[EEPROM_ID] = EEPROM_ID_VALID;
670 if (s->device == i82557B || s->device == i82557C)
671 eeprom_contents[5] = 0x0100;
672 eeprom_contents[EEPROM_PHY_ID] = 1;
674 for (i = 0; i < EEPROM_SIZE - 1; i++) {
675 sum += eeprom_contents[i];
677 eeprom_contents[EEPROM_SIZE - 1] = 0xbaba - sum;
678 TRACE(EEPROM, logout("checksum=0x%04x\n", eeprom_contents[EEPROM_SIZE - 1]));
680 memset(s->mem, 0, sizeof(s->mem));
681 uint32_t val = BIT(21);
682 memcpy(&s->mem[SCBCtrlMDI], &val, sizeof(val));
684 assert(sizeof(s->mdimem) == sizeof(eepro100_mdi_default));
685 memcpy(&s->mdimem[0], &eepro100_mdi_default[0], sizeof(s->mdimem));
688 static void nic_reset(void *opaque)
690 EEPRO100State *s = opaque;
691 TRACE(OTHER, logout("%p\n", s));
692 /* TODO: Clearing of multicast table for selective reset, too? */
693 memset(&s->mult[0], 0, sizeof(s->mult));
694 nic_selective_reset(s);
697 #if defined(DEBUG_EEPRO100)
698 static const char * const e100_reg[PCI_IO_SIZE / 4] = {
702 "EEPROM/Flash Control",
704 "Receive DMA Byte Count",
706 "General Status/Control"
709 static char *regname(uint32_t addr)
712 if (addr < PCI_IO_SIZE) {
713 const char *r = e100_reg[addr / 4];
715 snprintf(buf, sizeof(buf), "%s+%u", r, addr % 4);
717 snprintf(buf, sizeof(buf), "0x%02x", addr);
720 snprintf(buf, sizeof(buf), "??? 0x%08x", addr);
724 #endif /* DEBUG_EEPRO100 */
727 static uint16_t eepro100_read_status(EEPRO100State * s)
729 uint16_t val = s->status;
730 TRACE(OTHER, logout("val=0x%04x\n", val));
734 static void eepro100_write_status(EEPRO100State * s, uint16_t val)
736 TRACE(OTHER, logout("val=0x%04x\n", val));
741 /*****************************************************************************
745 ****************************************************************************/
748 static uint16_t eepro100_read_command(EEPRO100State * s)
750 uint16_t val = 0xffff;
751 TRACE(OTHER, logout("val=0x%04x\n", val));
756 /* Commands that can be put in a command list entry. */
761 CmdMulticastList = 3,
763 CmdTDR = 5, /* load microcode */
767 /* And some extra flags: */
768 CmdSuspend = 0x4000, /* Suspend after completion. */
769 CmdIntr = 0x2000, /* Interrupt after completion. */
770 CmdTxFlex = 0x0008, /* Use "Flexible mode" for CmdTx command. */
773 static cu_state_t get_cu_state(EEPRO100State * s)
775 return ((s->mem[SCBStatus] & BITS(7, 6)) >> 6);
778 static void set_cu_state(EEPRO100State * s, cu_state_t state)
780 s->mem[SCBStatus] = (s->mem[SCBStatus] & ~BITS(7, 6)) + (state << 6);
783 static ru_state_t get_ru_state(EEPRO100State * s)
785 return ((s->mem[SCBStatus] & BITS(5, 2)) >> 2);
788 static void set_ru_state(EEPRO100State * s, ru_state_t state)
790 s->mem[SCBStatus] = (s->mem[SCBStatus] & ~BITS(5, 2)) + (state << 2);
793 static void dump_statistics(EEPRO100State * s)
795 /* Dump statistical data. Most data is never changed by the emulation
796 * and always 0, so we first just copy the whole block and then those
797 * values which really matter.
798 * Number of data should check configuration!!!
800 cpu_physical_memory_write(s->statsaddr,
801 (uint8_t *) & s->statistics, s->stats_size);
802 stl_le_phys(s->statsaddr + 0, s->statistics.tx_good_frames);
803 stl_le_phys(s->statsaddr + 36, s->statistics.rx_good_frames);
804 stl_le_phys(s->statsaddr + 48, s->statistics.rx_resource_errors);
805 stl_le_phys(s->statsaddr + 60, s->statistics.rx_short_frame_errors);
807 stw_le_phys(s->statsaddr + 76, s->statistics.xmt_tco_frames);
808 stw_le_phys(s->statsaddr + 78, s->statistics.rcv_tco_frames);
809 missing("CU dump statistical counters");
813 static void read_cb(EEPRO100State *s)
815 cpu_physical_memory_read(s->cb_address, (uint8_t *) &s->tx, sizeof(s->tx));
816 s->tx.status = le16_to_cpu(s->tx.status);
817 s->tx.command = le16_to_cpu(s->tx.command);
818 s->tx.link = le32_to_cpu(s->tx.link);
819 s->tx.tbd_array_addr = le32_to_cpu(s->tx.tbd_array_addr);
820 s->tx.tcb_bytes = le16_to_cpu(s->tx.tcb_bytes);
823 static void tx_command(EEPRO100State *s)
825 uint32_t tbd_array = le32_to_cpu(s->tx.tbd_array_addr);
826 uint16_t tcb_bytes = (le16_to_cpu(s->tx.tcb_bytes) & 0x3fff);
827 /* Sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes. */
830 uint32_t tbd_address = s->cb_address + 0x10;
832 ("transmit, TBD array address 0x%08x, TCB byte count 0x%04x, TBD count %u\n",
833 tbd_array, tcb_bytes, s->tx.tbd_count));
835 if (tcb_bytes > 2600) {
836 logout("TCB byte count too large, using 2600\n");
839 if (!((tcb_bytes > 0) || (tbd_array != 0xffffffff))) {
841 ("illegal values of TBD array address and TCB byte count!\n");
843 assert(tcb_bytes <= sizeof(buf));
844 while (size < tcb_bytes) {
845 uint32_t tx_buffer_address = ldl_phys(tbd_address);
846 uint16_t tx_buffer_size = lduw_phys(tbd_address + 4);
848 uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
852 ("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
853 tx_buffer_address, tx_buffer_size));
854 tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
855 cpu_physical_memory_read(tx_buffer_address, &buf[size],
857 size += tx_buffer_size;
859 if (tbd_array == 0xffffffff) {
860 /* Simplified mode. Was already handled by code above. */
863 uint8_t tbd_count = 0;
864 if (s->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) {
865 /* Extended Flexible TCB. */
866 for (; tbd_count < 2; tbd_count++) {
867 uint32_t tx_buffer_address = ldl_phys(tbd_address);
868 uint16_t tx_buffer_size = lduw_phys(tbd_address + 4);
869 uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
872 ("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n",
873 tx_buffer_address, tx_buffer_size));
874 tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
875 cpu_physical_memory_read(tx_buffer_address, &buf[size],
877 size += tx_buffer_size;
878 if (tx_buffer_el & 1) {
883 tbd_address = tbd_array;
884 for (; tbd_count < s->tx.tbd_count; tbd_count++) {
885 uint32_t tx_buffer_address = ldl_phys(tbd_address);
886 uint16_t tx_buffer_size = lduw_phys(tbd_address + 4);
887 uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
890 ("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n",
891 tx_buffer_address, tx_buffer_size));
892 tx_buffer_size = MIN(tx_buffer_size, sizeof(buf) - size);
893 cpu_physical_memory_read(tx_buffer_address, &buf[size],
895 size += tx_buffer_size;
896 if (tx_buffer_el & 1) {
901 TRACE(RXTX, logout("%p sending frame, len=%d,%s\n", s, size, nic_dump(buf, size)));
902 qemu_send_packet(&s->nic->nc, buf, size);
903 s->statistics.tx_good_frames++;
904 /* Transmit with bad status would raise an CX/TNO interrupt.
905 * (82557 only). Emulation never has bad status. */
907 eepro100_cx_interrupt(s);
911 static void set_multicast_list(EEPRO100State *s)
913 uint16_t multicast_count = s->tx.tbd_array_addr & BITS(13, 0);
915 memset(&s->mult[0], 0, sizeof(s->mult));
916 TRACE(OTHER, logout("multicast list, multicast count = %u\n", multicast_count));
917 for (i = 0; i < multicast_count; i += 6) {
918 uint8_t multicast_addr[6];
919 cpu_physical_memory_read(s->cb_address + 10 + i, multicast_addr, 6);
920 TRACE(OTHER, logout("multicast entry %s\n", nic_dump(multicast_addr, 6)));
921 unsigned mcast_idx = compute_mcast_idx(multicast_addr);
922 assert(mcast_idx < 64);
923 s->mult[mcast_idx >> 3] |= (1 << (mcast_idx & 7));
927 static void action_command(EEPRO100State *s)
935 s->cb_address = s->cu_base + s->cu_offset;
937 bit_el = ((s->tx.command & COMMAND_EL) != 0);
938 bit_s = ((s->tx.command & COMMAND_S) != 0);
939 bit_i = ((s->tx.command & COMMAND_I) != 0);
940 bit_nc = ((s->tx.command & COMMAND_NC) != 0);
942 bool bit_sf = ((s->tx.command & COMMAND_SF) != 0);
944 s->cu_offset = s->tx.link;
946 logout("val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n",
947 s->tx.status, s->tx.command, s->tx.link));
948 switch (s->tx.command & COMMAND_CMD) {
953 cpu_physical_memory_read(s->cb_address + 8, &s->conf.macaddr.a[0], 6);
954 TRACE(OTHER, logout("macaddr: %s\n", nic_dump(&s->conf.macaddr.a[0], 6)));
957 cpu_physical_memory_read(s->cb_address + 8, &s->configuration[0],
958 sizeof(s->configuration));
959 TRACE(OTHER, logout("configuration: %s\n", nic_dump(&s->configuration[0], 16)));
961 case CmdMulticastList:
962 set_multicast_list(s);
966 missing("CmdTx: NC = 0");
973 TRACE(OTHER, logout("load microcode\n"));
974 /* Starting with offset 8, the command contains
975 * 64 dwords microcode which we just ignore here. */
978 TRACE(OTHER, logout("diagnose\n"));
979 /* Make sure error flag is not set. */
983 missing("undefined command");
987 /* Write new status. */
988 stw_phys(s->cb_address, s->tx.status | STATUS_C | (success ? STATUS_OK : 0));
990 /* CU completed action. */
991 eepro100_cx_interrupt(s);
994 /* CU becomes idle. Terminate command loop. */
995 set_cu_state(s, cu_idle);
996 eepro100_cna_interrupt(s);
999 /* CU becomes suspended. Terminate command loop. */
1000 set_cu_state(s, cu_suspended);
1001 eepro100_cna_interrupt(s);
1004 /* More entries in list. */
1005 TRACE(OTHER, logout("CU list with at least one more entry\n"));
1008 TRACE(OTHER, logout("CU list empty\n"));
1009 /* List is empty. Now CU is idle or suspended. */
1012 static void eepro100_cu_command(EEPRO100State * s, uint8_t val)
1014 cu_state_t cu_state;
1020 cu_state = get_cu_state(s);
1021 if (cu_state != cu_idle && cu_state != cu_suspended) {
1022 /* Intel documentation says that CU must be idle or suspended
1023 * for the CU start command. */
1024 logout("unexpected CU state is %u\n", cu_state);
1026 set_cu_state(s, cu_active);
1027 s->cu_offset = s->pointer;
1031 if (get_cu_state(s) != cu_suspended) {
1032 logout("bad CU resume from CU state %u\n", get_cu_state(s));
1033 /* Workaround for bad Linux eepro100 driver which resumes
1034 * from idle state. */
1036 missing("cu resume");
1038 set_cu_state(s, cu_suspended);
1040 if (get_cu_state(s) == cu_suspended) {
1041 TRACE(OTHER, logout("CU resuming\n"));
1042 set_cu_state(s, cu_active);
1047 /* Load dump counters address. */
1048 s->statsaddr = s->pointer;
1049 TRACE(OTHER, logout("val=0x%02x (status address)\n", val));
1052 /* Dump statistical counters. */
1053 TRACE(OTHER, logout("val=0x%02x (dump stats)\n", val));
1055 stl_le_phys(s->statsaddr + s->stats_size, 0xa005);
1059 TRACE(OTHER, logout("val=0x%02x (CU base address)\n", val));
1060 s->cu_base = s->pointer;
1063 /* Dump and reset statistical counters. */
1064 TRACE(OTHER, logout("val=0x%02x (dump stats and reset)\n", val));
1066 stl_le_phys(s->statsaddr + s->stats_size, 0xa007);
1067 memset(&s->statistics, 0, sizeof(s->statistics));
1070 /* CU static resume. */
1071 missing("CU static resume");
1074 missing("Undefined CU command");
1078 static void eepro100_ru_command(EEPRO100State * s, uint8_t val)
1086 if (get_ru_state(s) != ru_idle) {
1087 logout("RU state is %u, should be %u\n", get_ru_state(s), ru_idle);
1089 assert(!"wrong RU state");
1092 set_ru_state(s, ru_ready);
1093 s->ru_offset = s->pointer;
1094 TRACE(OTHER, logout("val=0x%02x (rx start)\n", val));
1098 if (get_ru_state(s) != ru_suspended) {
1099 logout("RU state is %u, should be %u\n", get_ru_state(s),
1102 assert(!"wrong RU state");
1105 set_ru_state(s, ru_ready);
1109 if (get_ru_state(s) == ru_ready) {
1110 eepro100_rnr_interrupt(s);
1112 set_ru_state(s, ru_idle);
1116 TRACE(OTHER, logout("val=0x%02x (RU base address)\n", val));
1117 s->ru_base = s->pointer;
1120 logout("val=0x%02x (undefined RU command)\n", val);
1121 missing("Undefined SU command");
1125 static void eepro100_write_command(EEPRO100State * s, uint8_t val)
1127 eepro100_ru_command(s, val & 0x0f);
1128 eepro100_cu_command(s, val & 0xf0);
1130 TRACE(OTHER, logout("val=0x%02x\n", val));
1132 /* Clear command byte after command was accepted. */
1136 /*****************************************************************************
1140 ****************************************************************************/
1142 #define EEPROM_CS 0x02
1143 #define EEPROM_SK 0x01
1144 #define EEPROM_DI 0x04
1145 #define EEPROM_DO 0x08
1147 static uint16_t eepro100_read_eeprom(EEPRO100State * s)
1150 memcpy(&val, &s->mem[SCBeeprom], sizeof(val));
1151 if (eeprom93xx_read(s->eeprom)) {
1156 TRACE(EEPROM, logout("val=0x%04x\n", val));
1160 static void eepro100_write_eeprom(eeprom_t * eeprom, uint8_t val)
1162 TRACE(EEPROM, logout("val=0x%02x\n", val));
1164 /* mask unwriteable bits */
1166 val = SET_MASKED(val, 0x31, eeprom->value);
1169 int eecs = ((val & EEPROM_CS) != 0);
1170 int eesk = ((val & EEPROM_SK) != 0);
1171 int eedi = ((val & EEPROM_DI) != 0);
1172 eeprom93xx_write(eeprom, eecs, eesk, eedi);
1175 static void eepro100_write_pointer(EEPRO100State * s, uint32_t val)
1177 s->pointer = le32_to_cpu(val);
1178 TRACE(OTHER, logout("val=0x%08x\n", val));
1181 /*****************************************************************************
1185 ****************************************************************************/
1187 #if defined(DEBUG_EEPRO100)
1188 static const char * const mdi_op_name[] = {
1195 static const char * const mdi_reg_name[] = {
1198 "PHY Identification (Word 1)",
1199 "PHY Identification (Word 2)",
1200 "Auto-Negotiation Advertisement",
1201 "Auto-Negotiation Link Partner Ability",
1202 "Auto-Negotiation Expansion"
1205 static const char *reg2name(uint8_t reg)
1207 static char buffer[10];
1208 const char *p = buffer;
1209 if (reg < ARRAY_SIZE(mdi_reg_name)) {
1210 p = mdi_reg_name[reg];
1212 snprintf(buffer, sizeof(buffer), "reg=0x%02x", reg);
1216 #endif /* DEBUG_EEPRO100 */
1218 static uint32_t eepro100_read_mdi(EEPRO100State * s)
1221 memcpy(&val, &s->mem[0x10], sizeof(val));
1223 #ifdef DEBUG_EEPRO100
1224 uint8_t raiseint = (val & BIT(29)) >> 29;
1225 uint8_t opcode = (val & BITS(27, 26)) >> 26;
1226 uint8_t phy = (val & BITS(25, 21)) >> 21;
1227 uint8_t reg = (val & BITS(20, 16)) >> 16;
1228 uint16_t data = (val & BITS(15, 0));
1230 /* Emulation takes no time to finish MDI transaction. */
1232 TRACE(MDI, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1233 val, raiseint, mdi_op_name[opcode], phy,
1234 reg2name(reg), data));
1238 static void eepro100_write_mdi(EEPRO100State * s, uint32_t val)
1240 uint8_t raiseint = (val & BIT(29)) >> 29;
1241 uint8_t opcode = (val & BITS(27, 26)) >> 26;
1242 uint8_t phy = (val & BITS(25, 21)) >> 21;
1243 uint8_t reg = (val & BITS(20, 16)) >> 16;
1244 uint16_t data = (val & BITS(15, 0));
1245 TRACE(MDI, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1246 val, raiseint, mdi_op_name[opcode], phy, reg2name(reg), data));
1248 /* Unsupported PHY address. */
1250 logout("phy must be 1 but is %u\n", phy);
1253 } else if (opcode != 1 && opcode != 2) {
1254 /* Unsupported opcode. */
1255 logout("opcode must be 1 or 2 but is %u\n", opcode);
1257 } else if (reg > 6) {
1258 /* Unsupported register. */
1259 logout("register must be 0...6 but is %u\n", reg);
1262 TRACE(MDI, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1263 val, raiseint, mdi_op_name[opcode], phy,
1264 reg2name(reg), data));
1268 case 0: /* Control Register */
1269 if (data & 0x8000) {
1270 /* Reset status and control registers to default. */
1271 s->mdimem[0] = eepro100_mdi_default[0];
1272 s->mdimem[1] = eepro100_mdi_default[1];
1273 data = s->mdimem[reg];
1275 /* Restart Auto Configuration = Normal Operation */
1279 case 1: /* Status Register */
1280 missing("not writable");
1281 data = s->mdimem[reg];
1283 case 2: /* PHY Identification Register (Word 1) */
1284 case 3: /* PHY Identification Register (Word 2) */
1285 missing("not implemented");
1287 case 4: /* Auto-Negotiation Advertisement Register */
1288 case 5: /* Auto-Negotiation Link Partner Ability Register */
1290 case 6: /* Auto-Negotiation Expansion Register */
1292 missing("not implemented");
1294 s->mdimem[reg] = data;
1295 } else if (opcode == 2) {
1298 case 0: /* Control Register */
1299 if (data & 0x8000) {
1300 /* Reset status and control registers to default. */
1301 s->mdimem[0] = eepro100_mdi_default[0];
1302 s->mdimem[1] = eepro100_mdi_default[1];
1305 case 1: /* Status Register */
1306 s->mdimem[reg] |= 0x0020;
1308 case 2: /* PHY Identification Register (Word 1) */
1309 case 3: /* PHY Identification Register (Word 2) */
1310 case 4: /* Auto-Negotiation Advertisement Register */
1312 case 5: /* Auto-Negotiation Link Partner Ability Register */
1313 s->mdimem[reg] = 0x41fe;
1315 case 6: /* Auto-Negotiation Expansion Register */
1316 s->mdimem[reg] = 0x0001;
1319 data = s->mdimem[reg];
1321 /* Emulation takes no time to finish MDI transaction.
1322 * Set MDI bit in SCB status register. */
1323 s->mem[SCBAck] |= 0x08;
1326 eepro100_mdi_interrupt(s);
1329 val = (val & 0xffff0000) + data;
1330 memcpy(&s->mem[0x10], &val, sizeof(val));
1333 /*****************************************************************************
1337 ****************************************************************************/
1339 #define PORT_SOFTWARE_RESET 0
1340 #define PORT_SELFTEST 1
1341 #define PORT_SELECTIVE_RESET 2
1343 #define PORT_SELECTION_MASK 3
1346 uint32_t st_sign; /* Self Test Signature */
1347 uint32_t st_result; /* Self Test Results */
1348 } eepro100_selftest_t;
1350 static uint32_t eepro100_read_port(EEPRO100State * s)
1355 static void eepro100_write_port(EEPRO100State * s, uint32_t val)
1357 val = le32_to_cpu(val);
1358 uint32_t address = (val & ~PORT_SELECTION_MASK);
1359 uint8_t selection = (val & PORT_SELECTION_MASK);
1360 switch (selection) {
1361 case PORT_SOFTWARE_RESET:
1365 TRACE(OTHER, logout("selftest address=0x%08x\n", address));
1366 eepro100_selftest_t data;
1367 cpu_physical_memory_read(address, (uint8_t *) & data, sizeof(data));
1368 data.st_sign = 0xffffffff;
1370 cpu_physical_memory_write(address, (uint8_t *) & data, sizeof(data));
1372 case PORT_SELECTIVE_RESET:
1373 TRACE(OTHER, logout("selective reset, selftest address=0x%08x\n", address));
1374 nic_selective_reset(s);
1377 logout("val=0x%08x\n", val);
1378 missing("unknown port selection");
1382 /*****************************************************************************
1384 * General hardware emulation.
1386 ****************************************************************************/
1388 static uint8_t eepro100_read1(EEPRO100State * s, uint32_t addr)
1391 if (addr <= sizeof(s->mem) - sizeof(val)) {
1392 memcpy(&val, &s->mem[addr], sizeof(val));
1398 val = eepro100_read_status(s);
1400 TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
1404 val = eepro100_read_status(s);
1406 TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
1409 TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
1411 val = eepro100_read_command(s);
1415 TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
1418 TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
1421 val = eepro100_read_eeprom(s);
1423 case SCBpmdr: /* Power Management Driver Register */
1425 TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
1427 case SCBgstat: /* General Status Register */
1428 /* 100 Mbps full duplex, valid link */
1430 TRACE(OTHER, logout("addr=General Status val=%02x\n", val));
1433 logout("addr=%s val=0x%02x\n", regname(addr), val);
1434 missing("unknown byte read");
1439 static uint16_t eepro100_read2(EEPRO100State * s, uint32_t addr)
1442 if (addr <= sizeof(s->mem) - sizeof(val)) {
1443 memcpy(&val, &s->mem[addr], sizeof(val));
1449 val = eepro100_read_status(s);
1452 TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
1455 val = eepro100_read_eeprom(s);
1456 TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
1459 logout("addr=%s val=0x%04x\n", regname(addr), val);
1460 missing("unknown word read");
1465 static uint32_t eepro100_read4(EEPRO100State * s, uint32_t addr)
1468 if (addr <= sizeof(s->mem) - sizeof(val)) {
1469 memcpy(&val, &s->mem[addr], sizeof(val));
1475 val = eepro100_read_status(s);
1477 TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
1481 val = eepro100_read_pointer(s);
1483 TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
1486 val = eepro100_read_port(s);
1487 TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
1490 val = eepro100_read_mdi(s);
1493 logout("addr=%s val=0x%08x\n", regname(addr), val);
1494 missing("unknown longword read");
1499 static void eepro100_write1(EEPRO100State * s, uint32_t addr, uint8_t val)
1501 if (addr <= sizeof(s->mem) - sizeof(val)) {
1502 memcpy(&s->mem[addr], &val, sizeof(val));
1505 TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
1510 eepro100_write_status(s, val);
1514 eepro100_acknowledge(s);
1517 eepro100_write_command(s, val);
1521 eepro100_swi_interrupt(s);
1523 eepro100_interrupt(s, 0);
1526 case SCBFlow: /* does not exist on 82557 */
1529 case SCBpmdr: /* does not exist on 82557 */
1530 TRACE(OTHER, logout("addr=%s val=0x%02x\n", regname(addr), val));
1533 eepro100_write_eeprom(s->eeprom, val);
1536 logout("addr=%s val=0x%02x\n", regname(addr), val);
1537 missing("unknown byte write");
1541 static void eepro100_write2(EEPRO100State * s, uint32_t addr, uint16_t val)
1543 if (addr <= sizeof(s->mem) - sizeof(val)) {
1544 memcpy(&s->mem[addr], &val, sizeof(val));
1547 TRACE(OTHER, logout("addr=%s val=0x%04x\n", regname(addr), val));
1552 eepro100_write_status(s, val);
1554 eepro100_acknowledge(s);
1557 eepro100_write_command(s, val);
1558 eepro100_write1(s, SCBIntmask, val >> 8);
1561 eepro100_write_eeprom(s->eeprom, val);
1564 logout("addr=%s val=0x%04x\n", regname(addr), val);
1565 missing("unknown word write");
1569 static void eepro100_write4(EEPRO100State * s, uint32_t addr, uint32_t val)
1571 if (addr <= sizeof(s->mem) - sizeof(val)) {
1572 memcpy(&s->mem[addr], &val, sizeof(val));
1577 eepro100_write_pointer(s, val);
1580 TRACE(OTHER, logout("addr=%s val=0x%08x\n", regname(addr), val));
1581 eepro100_write_port(s, val);
1584 eepro100_write_mdi(s, val);
1587 logout("addr=%s val=0x%08x\n", regname(addr), val);
1588 missing("unknown longword write");
1592 /*****************************************************************************
1596 ****************************************************************************/
1598 static uint32_t ioport_read1(void *opaque, uint32_t addr)
1600 EEPRO100State *s = opaque;
1602 logout("addr=%s\n", regname(addr));
1604 return eepro100_read1(s, addr - s->region[1]);
1607 static uint32_t ioport_read2(void *opaque, uint32_t addr)
1609 EEPRO100State *s = opaque;
1610 return eepro100_read2(s, addr - s->region[1]);
1613 static uint32_t ioport_read4(void *opaque, uint32_t addr)
1615 EEPRO100State *s = opaque;
1616 return eepro100_read4(s, addr - s->region[1]);
1619 static void ioport_write1(void *opaque, uint32_t addr, uint32_t val)
1621 EEPRO100State *s = opaque;
1623 logout("addr=%s val=0x%02x\n", regname(addr), val);
1625 eepro100_write1(s, addr - s->region[1], val);
1628 static void ioport_write2(void *opaque, uint32_t addr, uint32_t val)
1630 EEPRO100State *s = opaque;
1631 eepro100_write2(s, addr - s->region[1], val);
1634 static void ioport_write4(void *opaque, uint32_t addr, uint32_t val)
1636 EEPRO100State *s = opaque;
1637 eepro100_write4(s, addr - s->region[1], val);
1640 /***********************************************************/
1641 /* PCI EEPRO100 definitions */
1643 static void pci_map(PCIDevice * pci_dev, int region_num,
1644 pcibus_t addr, pcibus_t size, int type)
1646 EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
1648 TRACE(OTHER, logout("region %d, addr=0x%08"FMT_PCIBUS", "
1649 "size=0x%08"FMT_PCIBUS", type=%d\n",
1650 region_num, addr, size, type));
1652 assert(region_num == 1);
1653 register_ioport_write(addr, size, 1, ioport_write1, s);
1654 register_ioport_read(addr, size, 1, ioport_read1, s);
1655 register_ioport_write(addr, size, 2, ioport_write2, s);
1656 register_ioport_read(addr, size, 2, ioport_read2, s);
1657 register_ioport_write(addr, size, 4, ioport_write4, s);
1658 register_ioport_read(addr, size, 4, ioport_read4, s);
1660 s->region[region_num] = addr;
1663 /*****************************************************************************
1665 * Memory mapped I/O.
1667 ****************************************************************************/
1669 static void pci_mmio_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
1671 EEPRO100State *s = opaque;
1673 logout("addr=%s val=0x%02x\n", regname(addr), val);
1675 eepro100_write1(s, addr, val);
1678 static void pci_mmio_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
1680 EEPRO100State *s = opaque;
1682 logout("addr=%s val=0x%02x\n", regname(addr), val);
1684 eepro100_write2(s, addr, val);
1687 static void pci_mmio_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
1689 EEPRO100State *s = opaque;
1691 logout("addr=%s val=0x%02x\n", regname(addr), val);
1693 eepro100_write4(s, addr, val);
1696 static uint32_t pci_mmio_readb(void *opaque, target_phys_addr_t addr)
1698 EEPRO100State *s = opaque;
1700 logout("addr=%s\n", regname(addr));
1702 return eepro100_read1(s, addr);
1705 static uint32_t pci_mmio_readw(void *opaque, target_phys_addr_t addr)
1707 EEPRO100State *s = opaque;
1709 logout("addr=%s\n", regname(addr));
1711 return eepro100_read2(s, addr);
1714 static uint32_t pci_mmio_readl(void *opaque, target_phys_addr_t addr)
1716 EEPRO100State *s = opaque;
1718 logout("addr=%s\n", regname(addr));
1720 return eepro100_read4(s, addr);
1723 static CPUWriteMemoryFunc * const pci_mmio_write[] = {
1729 static CPUReadMemoryFunc * const pci_mmio_read[] = {
1735 static void pci_mmio_map(PCIDevice * pci_dev, int region_num,
1736 pcibus_t addr, pcibus_t size, int type)
1738 EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
1740 TRACE(OTHER, logout("region %d, addr=0x%08"FMT_PCIBUS", "
1741 "size=0x%08"FMT_PCIBUS", type=%d\n",
1742 region_num, addr, size, type));
1744 if (region_num == 0) {
1745 /* Map control / status registers. */
1746 cpu_register_physical_memory(addr, size, s->mmio_index);
1747 s->region[region_num] = addr;
1751 static int nic_can_receive(VLANClientState *nc)
1753 EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
1754 TRACE(RXTX, logout("%p\n", s));
1755 return get_ru_state(s) == ru_ready;
1757 return !eepro100_buffer_full(s);
1761 static ssize_t nic_receive(VLANClientState *nc, const uint8_t * buf, size_t size)
1764 * - Magic packets should set bit 30 in power management driver register.
1765 * - Interesting packets should set bit 29 in power management driver register.
1767 EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
1768 uint16_t rfd_status = 0xa000;
1769 static const uint8_t broadcast_macaddr[6] =
1770 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1772 /* TODO: check multiple IA bit. */
1773 if (s->configuration[20] & BIT(6)) {
1774 missing("Multiple IA bit");
1778 if (s->configuration[8] & 0x80) {
1779 /* CSMA is disabled. */
1780 logout("%p received while CSMA is disabled\n", s);
1782 } else if (size < 64 && (s->configuration[7] & BIT(0))) {
1783 /* Short frame and configuration byte 7/0 (discard short receive) set:
1784 * Short frame is discarded */
1785 logout("%p received short frame (%zu byte)\n", s, size);
1786 s->statistics.rx_short_frame_errors++;
1790 } else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & BIT(3))) {
1791 /* Long frame and configuration byte 18/3 (long receive ok) not set:
1792 * Long frames are discarded. */
1793 logout("%p received long frame (%zu byte), ignored\n", s, size);
1795 } else if (memcmp(buf, s->conf.macaddr.a, 6) == 0) { /* !!! */
1796 /* Frame matches individual address. */
1797 /* TODO: check configuration byte 15/4 (ignore U/L). */
1798 TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size));
1799 } else if (memcmp(buf, broadcast_macaddr, 6) == 0) {
1800 /* Broadcast frame. */
1801 TRACE(RXTX, logout("%p received broadcast, len=%zu\n", s, size));
1802 rfd_status |= 0x0002;
1803 } else if (buf[0] & 0x01) {
1804 /* Multicast frame. */
1805 TRACE(RXTX, logout("%p received multicast, len=%zu,%s\n", s, size, nic_dump(buf, size)));
1806 if (s->configuration[21] & BIT(3)) {
1807 /* Multicast all bit is set, receive all multicast frames. */
1809 unsigned mcast_idx = compute_mcast_idx(buf);
1810 assert(mcast_idx < 64);
1811 if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) {
1812 /* Multicast frame is allowed in hash table. */
1813 } else if (s->configuration[15] & BIT(0)) {
1814 /* Promiscuous: receive all. */
1815 rfd_status |= 0x0004;
1817 TRACE(RXTX, logout("%p multicast ignored\n", s));
1821 /* TODO: Next not for promiscuous mode? */
1822 rfd_status |= 0x0002;
1823 } else if (s->configuration[15] & BIT(0)) {
1824 /* Promiscuous: receive all. */
1825 TRACE(RXTX, logout("%p received frame in promiscuous mode, len=%zu\n", s, size));
1826 rfd_status |= 0x0004;
1828 TRACE(RXTX, logout("%p received frame, ignored, len=%zu,%s\n", s, size,
1829 nic_dump(buf, size)));
1833 if (get_ru_state(s) != ru_ready) {
1834 /* No resources available. */
1835 logout("no resources, state=%u\n", get_ru_state(s));
1836 /* TODO: RNR interrupt only at first failed frame? */
1837 eepro100_rnr_interrupt(s);
1838 s->statistics.rx_resource_errors++;
1840 assert(!"no resources");
1846 cpu_physical_memory_read(s->ru_base + s->ru_offset, (uint8_t *) & rx,
1847 offsetof(eepro100_rx_t, packet));
1848 uint16_t rfd_command = le16_to_cpu(rx.command);
1849 uint16_t rfd_size = le16_to_cpu(rx.size);
1851 if (size > rfd_size) {
1852 logout("Receive buffer (%" PRId16 " bytes) too small for data "
1853 "(%zu bytes); data truncated\n", rfd_size, size);
1857 rfd_status |= 0x0080;
1859 TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
1860 rfd_command, rx.link, rx.rx_buf_addr, rfd_size));
1861 stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status),
1863 stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size);
1864 /* Early receive interrupt not supported. */
1866 eepro100_er_interrupt(s);
1868 /* Receive CRC Transfer not supported. */
1869 if (s->configuration[18] & BIT(2)) {
1870 missing("Receive CRC Transfer");
1873 /* TODO: check stripping enable bit. */
1875 assert(!(s->configuration[17] & BIT(0)));
1877 cpu_physical_memory_write(s->ru_base + s->ru_offset +
1878 offsetof(eepro100_rx_t, packet), buf, size);
1879 s->statistics.rx_good_frames++;
1880 eepro100_fr_interrupt(s);
1881 s->ru_offset = le32_to_cpu(rx.link);
1882 if (rfd_command & COMMAND_EL) {
1883 /* EL bit is set, so this was the last frame. */
1884 logout("receive: Running out of frames\n");
1885 set_ru_state(s, ru_suspended);
1887 if (rfd_command & COMMAND_S) {
1889 set_ru_state(s, ru_suspended);
1894 static const VMStateDescription vmstate_eepro100 = {
1896 .minimum_version_id = 2,
1897 .minimum_version_id_old = 2,
1898 .fields = (VMStateField []) {
1899 VMSTATE_PCI_DEVICE(dev, EEPRO100State),
1901 VMSTATE_BUFFER(mult, EEPRO100State),
1902 VMSTATE_BUFFER(mem, EEPRO100State),
1903 /* Save all members of struct between scb_stat and mem. */
1904 VMSTATE_UINT8(scb_stat, EEPRO100State),
1905 VMSTATE_UINT8(int_stat, EEPRO100State),
1906 VMSTATE_UNUSED(3*4),
1907 VMSTATE_MACADDR(conf.macaddr, EEPRO100State),
1908 VMSTATE_UNUSED(19*4),
1909 VMSTATE_UINT16_ARRAY(mdimem, EEPRO100State, 32),
1910 /* The eeprom should be saved and restored by its own routines. */
1911 VMSTATE_UINT32(device, EEPRO100State),
1912 /* TODO check device. */
1913 VMSTATE_UINT32(pointer, EEPRO100State),
1914 VMSTATE_UINT32(cu_base, EEPRO100State),
1915 VMSTATE_UINT32(cu_offset, EEPRO100State),
1916 VMSTATE_UINT32(ru_base, EEPRO100State),
1917 VMSTATE_UINT32(ru_offset, EEPRO100State),
1918 VMSTATE_UINT32(statsaddr, EEPRO100State),
1919 /* Save eepro100_stats_t statistics. */
1920 VMSTATE_UINT32(statistics.tx_good_frames, EEPRO100State),
1921 VMSTATE_UINT32(statistics.tx_max_collisions, EEPRO100State),
1922 VMSTATE_UINT32(statistics.tx_late_collisions, EEPRO100State),
1923 VMSTATE_UINT32(statistics.tx_underruns, EEPRO100State),
1924 VMSTATE_UINT32(statistics.tx_lost_crs, EEPRO100State),
1925 VMSTATE_UINT32(statistics.tx_deferred, EEPRO100State),
1926 VMSTATE_UINT32(statistics.tx_single_collisions, EEPRO100State),
1927 VMSTATE_UINT32(statistics.tx_multiple_collisions, EEPRO100State),
1928 VMSTATE_UINT32(statistics.tx_total_collisions, EEPRO100State),
1929 VMSTATE_UINT32(statistics.rx_good_frames, EEPRO100State),
1930 VMSTATE_UINT32(statistics.rx_crc_errors, EEPRO100State),
1931 VMSTATE_UINT32(statistics.rx_alignment_errors, EEPRO100State),
1932 VMSTATE_UINT32(statistics.rx_resource_errors, EEPRO100State),
1933 VMSTATE_UINT32(statistics.rx_overrun_errors, EEPRO100State),
1934 VMSTATE_UINT32(statistics.rx_cdt_errors, EEPRO100State),
1935 VMSTATE_UINT32(statistics.rx_short_frame_errors, EEPRO100State),
1936 VMSTATE_UINT32(statistics.fc_xmt_pause, EEPRO100State),
1937 VMSTATE_UINT32(statistics.fc_rcv_pause, EEPRO100State),
1938 VMSTATE_UINT32(statistics.fc_rcv_unsupported, EEPRO100State),
1939 VMSTATE_UINT16(statistics.xmt_tco_frames, EEPRO100State),
1940 VMSTATE_UINT16(statistics.rcv_tco_frames, EEPRO100State),
1942 VMSTATE_UINT16(status, EEPRO100State),
1944 /* Configuration bytes. */
1945 VMSTATE_BUFFER(configuration, EEPRO100State),
1946 VMSTATE_END_OF_LIST()
1950 static void nic_cleanup(VLANClientState *nc)
1952 EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
1957 static int pci_nic_uninit(PCIDevice *pci_dev)
1959 EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
1961 cpu_unregister_io_memory(s->mmio_index);
1962 vmstate_unregister(s->vmstate, s);
1963 eeprom93xx_free(s->eeprom);
1964 qemu_del_vlan_client(&s->nic->nc);
1968 static NetClientInfo net_eepro100_info = {
1969 .type = NET_CLIENT_TYPE_NIC,
1970 .size = sizeof(NICState),
1971 .can_receive = nic_can_receive,
1972 .receive = nic_receive,
1973 .cleanup = nic_cleanup,
1976 static int nic_init(PCIDevice *pci_dev, uint32_t device)
1978 EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
1980 TRACE(OTHER, logout("\n"));
1986 /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
1987 * i82559 and later support 64 or 256 word EEPROM. */
1988 s->eeprom = eeprom93xx_new(EEPROM_SIZE);
1990 /* Handler for memory-mapped I/O */
1992 cpu_register_io_memory(pci_mmio_read, pci_mmio_write, s);
1994 pci_register_bar(&s->dev, 0, PCI_MEM_SIZE,
1995 PCI_BASE_ADDRESS_SPACE_MEMORY |
1996 PCI_BASE_ADDRESS_MEM_PREFETCH, pci_mmio_map);
1997 pci_register_bar(&s->dev, 1, PCI_IO_SIZE, PCI_BASE_ADDRESS_SPACE_IO,
1999 pci_register_bar(&s->dev, 2, PCI_FLASH_SIZE, PCI_BASE_ADDRESS_SPACE_MEMORY,
2002 qemu_macaddr_default_if_unset(&s->conf.macaddr);
2003 logout("macaddr: %s\n", nic_dump(&s->conf.macaddr.a[0], 6));
2004 assert(s->region[1] == 0);
2008 s->nic = qemu_new_nic(&net_eepro100_info, &s->conf,
2009 pci_dev->qdev.info->name, pci_dev->qdev.id, s);
2011 qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
2012 TRACE(OTHER, logout("%s\n", s->nic->nc.info_str));
2014 qemu_register_reset(nic_reset, s);
2016 s->vmstate = qemu_malloc(sizeof(vmstate_eepro100));
2017 memcpy(s->vmstate, &vmstate_eepro100, sizeof(vmstate_eepro100));
2018 s->vmstate->name = s->nic->nc.model;
2019 vmstate_register(-1, s->vmstate, s);
2024 static int pci_i82550_init(PCIDevice *pci_dev)
2026 return nic_init(pci_dev, i82550);
2029 static int pci_i82551_init(PCIDevice *pci_dev)
2031 return nic_init(pci_dev, i82551);
2034 static int pci_i82557a_init(PCIDevice *pci_dev)
2036 return nic_init(pci_dev, i82557A);
2039 static int pci_i82557b_init(PCIDevice *pci_dev)
2041 return nic_init(pci_dev, i82557B);
2044 static int pci_i82557c_init(PCIDevice *pci_dev)
2046 return nic_init(pci_dev, i82557C);
2049 static int pci_i82558a_init(PCIDevice *pci_dev)
2051 return nic_init(pci_dev, i82558A);
2054 static int pci_i82558b_init(PCIDevice *pci_dev)
2056 return nic_init(pci_dev, i82558B);
2059 static int pci_i82559a_init(PCIDevice *pci_dev)
2061 return nic_init(pci_dev, i82559A);
2064 static int pci_i82559b_init(PCIDevice *pci_dev)
2066 return nic_init(pci_dev, i82559B);
2069 static int pci_i82559c_init(PCIDevice *pci_dev)
2071 return nic_init(pci_dev, i82559C);
2074 static int pci_i82559er_init(PCIDevice *pci_dev)
2076 return nic_init(pci_dev, i82559ER);
2079 static int pci_i82562_init(PCIDevice *pci_dev)
2081 return nic_init(pci_dev, i82562);
2084 static PCIDeviceInfo eepro100_info[] = {
2086 .qdev.name = "i82550",
2087 .qdev.desc = "Intel i82550 Ethernet",
2088 .qdev.size = sizeof(EEPRO100State),
2089 .init = pci_i82550_init,
2090 .exit = pci_nic_uninit,
2091 .romfile = "gpxe-eepro100-80861209.rom",
2092 .qdev.props = (Property[]) {
2093 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2094 DEFINE_PROP_END_OF_LIST(),
2097 .qdev.name = "i82551",
2098 .qdev.desc = "Intel i82551 Ethernet",
2099 .qdev.size = sizeof(EEPRO100State),
2100 .init = pci_i82551_init,
2101 .exit = pci_nic_uninit,
2102 .romfile = "gpxe-eepro100-80861209.rom",
2103 .qdev.props = (Property[]) {
2104 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2105 DEFINE_PROP_END_OF_LIST(),
2108 .qdev.name = "i82557a",
2109 .qdev.desc = "Intel i82557A Ethernet",
2110 .qdev.size = sizeof(EEPRO100State),
2111 .init = pci_i82557a_init,
2112 .exit = pci_nic_uninit,
2113 .romfile = "gpxe-eepro100-80861229.rom",
2114 .qdev.props = (Property[]) {
2115 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2116 DEFINE_PROP_END_OF_LIST(),
2119 .qdev.name = "i82557b",
2120 .qdev.desc = "Intel i82557B Ethernet",
2121 .qdev.size = sizeof(EEPRO100State),
2122 .init = pci_i82557b_init,
2123 .exit = pci_nic_uninit,
2124 .romfile = "gpxe-eepro100-80861229.rom",
2125 .qdev.props = (Property[]) {
2126 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2127 DEFINE_PROP_END_OF_LIST(),
2130 .qdev.name = "i82557c",
2131 .qdev.desc = "Intel i82557C Ethernet",
2132 .qdev.size = sizeof(EEPRO100State),
2133 .init = pci_i82557c_init,
2134 .exit = pci_nic_uninit,
2135 .romfile = "gpxe-eepro100-80861229.rom",
2136 .qdev.props = (Property[]) {
2137 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2138 DEFINE_PROP_END_OF_LIST(),
2141 .qdev.name = "i82558a",
2142 .qdev.desc = "Intel i82558A Ethernet",
2143 .qdev.size = sizeof(EEPRO100State),
2144 .init = pci_i82558a_init,
2145 .exit = pci_nic_uninit,
2146 .romfile = "gpxe-eepro100-80861229.rom",
2147 .qdev.props = (Property[]) {
2148 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2149 DEFINE_PROP_END_OF_LIST(),
2152 .qdev.name = "i82558b",
2153 .qdev.desc = "Intel i82558B Ethernet",
2154 .qdev.size = sizeof(EEPRO100State),
2155 .init = pci_i82558b_init,
2156 .exit = pci_nic_uninit,
2157 .romfile = "gpxe-eepro100-80861229.rom",
2158 .qdev.props = (Property[]) {
2159 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2160 DEFINE_PROP_END_OF_LIST(),
2163 .qdev.name = "i82559a",
2164 .qdev.desc = "Intel i82559A Ethernet",
2165 .qdev.size = sizeof(EEPRO100State),
2166 .init = pci_i82559a_init,
2167 .exit = pci_nic_uninit,
2168 .romfile = "gpxe-eepro100-80861229.rom",
2169 .qdev.props = (Property[]) {
2170 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2171 DEFINE_PROP_END_OF_LIST(),
2174 .qdev.name = "i82559b",
2175 .qdev.desc = "Intel i82559B Ethernet",
2176 .qdev.size = sizeof(EEPRO100State),
2177 .init = pci_i82559b_init,
2178 .exit = pci_nic_uninit,
2179 .romfile = "gpxe-eepro100-80861229.rom",
2180 .qdev.props = (Property[]) {
2181 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2182 DEFINE_PROP_END_OF_LIST(),
2185 .qdev.name = "i82559c",
2186 .qdev.desc = "Intel i82559C Ethernet",
2187 .qdev.size = sizeof(EEPRO100State),
2188 .init = pci_i82559c_init,
2189 .exit = pci_nic_uninit,
2190 .romfile = "gpxe-eepro100-80861229.rom",
2191 .qdev.props = (Property[]) {
2192 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2193 DEFINE_PROP_END_OF_LIST(),
2196 .qdev.name = "i82559er",
2197 .qdev.desc = "Intel i82559ER Ethernet",
2198 .qdev.size = sizeof(EEPRO100State),
2199 .init = pci_i82559er_init,
2200 .exit = pci_nic_uninit,
2201 .romfile = "gpxe-eepro100-80861209.rom",
2202 .qdev.props = (Property[]) {
2203 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2204 DEFINE_PROP_END_OF_LIST(),
2207 .qdev.name = "i82562",
2208 .qdev.desc = "Intel i82562 Ethernet",
2209 .qdev.size = sizeof(EEPRO100State),
2210 .init = pci_i82562_init,
2211 .exit = pci_nic_uninit,
2212 .romfile = "gpxe-eepro100-80861209.rom",
2213 .qdev.props = (Property[]) {
2214 DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
2215 DEFINE_PROP_END_OF_LIST(),
2222 static void eepro100_register_devices(void)
2224 pci_qdev_register_many(eepro100_info);
2227 device_init(eepro100_register_devices)