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 RX_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 */
157 //~ /* This constitutes two "TBD" entries: hdr and data */
158 //~ uint32_t tx_buf_addr0; /* void *, header of frame to be transmitted. */
159 //~ int32_t tx_buf_size0; /* Length of Tx hdr. */
160 //~ uint32_t tx_buf_addr1; /* void *, data to be transmitted. */
161 //~ int32_t tx_buf_size1; /* Length of Tx data. */
164 /* Receive frame descriptor. */
168 uint32_t link
; /* struct RxFD * */
169 uint32_t rx_buf_addr
; /* void * */
172 char packet
[MAX_ETH_FRAME_SIZE
+ 4];
176 COMMAND_EL
= BIT(15),
181 COMMAND_CMD
= BITS(2, 0),
190 uint32_t tx_good_frames
, tx_max_collisions
, tx_late_collisions
,
191 tx_underruns
, tx_lost_crs
, tx_deferred
, tx_single_collisions
,
192 tx_multiple_collisions
, tx_total_collisions
;
193 uint32_t rx_good_frames
, rx_crc_errors
, rx_alignment_errors
,
194 rx_resource_errors
, rx_overrun_errors
, rx_cdt_errors
,
195 rx_short_frame_errors
;
196 uint32_t fc_xmt_pause
, fc_rcv_pause
, fc_rcv_unsupported
;
197 uint16_t xmt_tco_frames
, rcv_tco_frames
;
198 /* TODO: i82559 has six reserved statistics but a total of 24 dwords. */
199 uint32_t reserved
[4];
219 uint8_t mult
[8]; /* multicast mask array */
223 uint8_t scb_stat
; /* SCB stat/ack byte */
224 uint8_t int_stat
; /* PCI interrupt status */
225 /* region must not be saved by nic_save. */
226 uint32_t region
[3]; /* PCI region addresses */
229 uint32_t device
; /* device variant */
231 /* (cu_base + cu_offset) address the next command block in the command block list. */
232 uint32_t cu_base
; /* CU base address */
233 uint32_t cu_offset
; /* CU address offset */
234 /* (ru_base + ru_offset) address the RFD in the Receive Frame Area. */
235 uint32_t ru_base
; /* RU base address */
236 uint32_t ru_offset
; /* RU address offset */
237 uint32_t statsaddr
; /* pointer to eepro100_stats_t */
239 /* Temporary status information (no need to save these values),
240 * used while processing CU commands. */
241 eepro100_tx_t tx
; /* transmit buffer descriptor */
242 uint32_t cb_address
; /* = cu_base + cu_offset */
244 /* Statistical counters. Also used for wake-up packet (i82559). */
245 eepro100_stats_t statistics
;
251 /* Configuration bytes. */
252 uint8_t configuration
[22];
254 /* Data in mem is always in the byte order of the controller (le). */
255 uint8_t mem
[PCI_MEM_SIZE
];
256 /* vmstate for each particular nic */
257 VMStateDescription
*vmstate
;
259 /* Quasi static device properties (no need to save them). */
261 bool has_extended_tcb_support
;
264 /* Word indices in EEPROM. */
266 EEPROM_CNFG_MDIX
= 0x03,
268 EEPROM_PHY_ID
= 0x06,
269 EEPROM_VENDOR_ID
= 0x0c,
270 EEPROM_CONFIG_ASF
= 0x0d,
271 EEPROM_DEVICE_ID
= 0x23,
272 EEPROM_SMBUS_ADDR
= 0x90,
275 /* Default values for MDI (PHY) registers */
276 static const uint16_t eepro100_mdi_default
[] = {
277 /* MDI Registers 0 - 6, 7 */
278 0x3000, 0x780d, 0x02a8, 0x0154, 0x05e1, 0x0000, 0x0000, 0x0000,
279 /* MDI Registers 8 - 15 */
280 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
281 /* MDI Registers 16 - 31 */
282 0x0003, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
283 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
286 /* Readonly mask for MDI (PHY) registers */
287 static const uint16_t eepro100_mdi_mask
[] = {
288 0x0000, 0xffff, 0xffff, 0xffff, 0xc01f, 0xffff, 0xffff, 0x0000,
289 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
290 0x0fff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
291 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
295 static void stl_le_phys(target_phys_addr_t addr
, uint32_t val
)
297 val
= cpu_to_le32(val
);
298 cpu_physical_memory_write(addr
, (const uint8_t *)&val
, sizeof(val
));
301 #define POLYNOMIAL 0x04c11db6
305 static unsigned compute_mcast_idx(const uint8_t * ep
)
312 for (i
= 0; i
< 6; i
++) {
314 for (j
= 0; j
< 8; j
++) {
315 carry
= ((crc
& 0x80000000L
) ? 1 : 0) ^ (b
& 0x01);
319 crc
= ((crc
^ POLYNOMIAL
) | carry
);
323 return (crc
& BITS(7, 2)) >> 2;
326 #if defined(DEBUG_EEPRO100)
327 static const char *nic_dump(const uint8_t * buf
, unsigned size
)
329 static char dump
[3 * 16 + 1];
335 p
+= sprintf(p
, " %02x", *buf
++);
339 #endif /* DEBUG_EEPRO100 */
342 stat_ack_not_ours
= 0x00,
343 stat_ack_sw_gen
= 0x04,
345 stat_ack_cu_idle
= 0x20,
346 stat_ack_frame_rx
= 0x40,
347 stat_ack_cu_cmd_done
= 0x80,
348 stat_ack_not_present
= 0xFF,
349 stat_ack_rx
= (stat_ack_sw_gen
| stat_ack_rnr
| stat_ack_frame_rx
),
350 stat_ack_tx
= (stat_ack_cu_idle
| stat_ack_cu_cmd_done
),
353 static void disable_interrupt(EEPRO100State
* s
)
356 TRACE(INT
, logout("interrupt disabled\n"));
357 qemu_irq_lower(s
->dev
.irq
[0]);
362 static void enable_interrupt(EEPRO100State
* s
)
365 TRACE(INT
, logout("interrupt enabled\n"));
366 qemu_irq_raise(s
->dev
.irq
[0]);
371 static void eepro100_acknowledge(EEPRO100State
* s
)
373 s
->scb_stat
&= ~s
->mem
[SCBAck
];
374 s
->mem
[SCBAck
] = s
->scb_stat
;
375 if (s
->scb_stat
== 0) {
376 disable_interrupt(s
);
380 static void eepro100_interrupt(EEPRO100State
* s
, uint8_t stat
)
382 uint8_t mask
= ~s
->mem
[SCBIntmask
];
383 s
->mem
[SCBAck
] |= stat
;
384 stat
= s
->scb_stat
= s
->mem
[SCBAck
];
385 stat
&= (mask
| 0x0f);
386 //~ stat &= (~s->mem[SCBIntmask] | 0x0xf);
387 if (stat
&& (mask
& 0x01)) {
388 /* SCB mask and SCB Bit M do not disable interrupt. */
390 } else if (s
->int_stat
) {
391 disable_interrupt(s
);
395 static void eepro100_cx_interrupt(EEPRO100State
* s
)
397 /* CU completed action command. */
398 /* Transmit not ok (82557 only, not in emulation). */
399 eepro100_interrupt(s
, 0x80);
402 static void eepro100_cna_interrupt(EEPRO100State
* s
)
404 /* CU left the active state. */
405 eepro100_interrupt(s
, 0x20);
408 static void eepro100_fr_interrupt(EEPRO100State
* s
)
410 /* RU received a complete frame. */
411 eepro100_interrupt(s
, 0x40);
415 static void eepro100_rnr_interrupt(EEPRO100State
* s
)
417 /* RU is not ready. */
418 eepro100_interrupt(s
, 0x10);
422 static void eepro100_mdi_interrupt(EEPRO100State
* s
)
424 /* MDI completed read or write cycle. */
425 eepro100_interrupt(s
, 0x08);
428 static void eepro100_swi_interrupt(EEPRO100State
* s
)
430 /* Software has requested an interrupt. */
431 eepro100_interrupt(s
, 0x04);
435 static void eepro100_fcp_interrupt(EEPRO100State
* s
)
437 /* Flow control pause interrupt (82558 and later). */
438 eepro100_interrupt(s
, 0x01);
442 static void pci_reset(EEPRO100State
* s
)
444 uint32_t device
= s
->device
;
445 uint8_t *pci_conf
= s
->dev
.config
;
446 bool power_management
= 1;
448 TRACE(OTHER
, logout("%p\n", s
));
451 pci_config_set_vendor_id(pci_conf
, PCI_VENDOR_ID_INTEL
);
452 /* PCI Device ID depends on device and is set below. */
454 /* TODO: this is the default, do not override. */
455 PCI_CONFIG_16(PCI_COMMAND
, 0x0000);
457 /* TODO: Value at RST# should be 0. */
458 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
| PCI_STATUS_FAST_BACK
);
459 /* PCI Revision ID */
460 PCI_CONFIG_8(PCI_REVISION_ID
, 0x08);
461 /* TODO: this is the default, do not override. */
463 PCI_CONFIG_8(PCI_CLASS_PROG
, 0x00);
464 pci_config_set_class(pci_conf
, PCI_CLASS_NETWORK_ETHERNET
);
465 /* PCI Cache Line Size */
466 /* check cache line size!!! */
467 //~ PCI_CONFIG_8(0x0c, 0x00);
468 /* PCI Latency Timer */
469 PCI_CONFIG_8(PCI_LATENCY_TIMER
, 0x20); // latency timer = 32 clocks
470 /* PCI Header Type */
471 /* BIST (built-in self test) */
472 #if defined(TARGET_I386)
473 // !!! workaround for buggy bios
474 //~ #define PCI_BASE_ADDRESS_MEM_PREFETCH 0
477 /* PCI Base Address Registers */
478 /* CSR Memory Mapped Base Address */
479 PCI_CONFIG_32(PCI_BASE_ADDRESS_0
,
480 PCI_BASE_ADDRESS_SPACE_MEMORY
|
481 PCI_BASE_ADDRESS_MEM_PREFETCH
);
482 /* CSR I/O Mapped Base Address */
483 PCI_CONFIG_32(PCI_BASE_ADDRESS_1
, PCI_BASE_ADDRESS_SPACE_IO
);
485 /* Flash Memory Mapped Base Address */
486 PCI_CONFIG_32(PCI_BASE_ADDRESS_2
,
487 0xfffe0000 | PCI_BASE_ADDRESS_SPACE_MEMORY
);
490 /* Expansion ROM Base Address (depends on boot disable!!!) */
491 /* TODO: not needed, set when BAR is registered */
492 PCI_CONFIG_32(PCI_ROM_ADDRESS
, PCI_BASE_ADDRESS_SPACE_MEMORY
);
493 /* Capability Pointer */
494 /* TODO: revisions with power_management 1 use this but
495 * do not set new capability list bit in status register. */
496 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0xdc);
499 /* TODO: RST# value should be 0 */
500 PCI_CONFIG_8(PCI_INTERRUPT_PIN
, 1); // interrupt pin 0
502 PCI_CONFIG_8(PCI_MIN_GNT
, 0x08);
503 /* Maximum Latency */
504 PCI_CONFIG_8(PCI_MAX_LAT
, 0x18);
508 // TODO: check device id.
509 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
510 /* Revision ID: 0x0c, 0x0d, 0x0e. */
511 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0e);
512 // TODO: check size of statistical counters.
514 // TODO: check extended tcb support.
515 s
->has_extended_tcb_support
= 1;
518 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
519 /* Revision ID: 0x0f, 0x10. */
520 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0f);
521 // TODO: check size of statistical counters.
523 s
->has_extended_tcb_support
= 1;
526 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
527 PCI_CONFIG_8(PCI_REVISION_ID
, 0x01);
528 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
529 power_management
= 0;
532 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
533 PCI_CONFIG_8(PCI_REVISION_ID
, 0x02);
534 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
535 power_management
= 0;
538 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
539 PCI_CONFIG_8(PCI_REVISION_ID
, 0x03);
540 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
541 power_management
= 0;
544 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
545 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
546 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
547 PCI_CONFIG_8(PCI_REVISION_ID
, 0x04);
549 s
->has_extended_tcb_support
= 1;
552 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
553 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
554 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
555 PCI_CONFIG_8(PCI_REVISION_ID
, 0x05);
557 s
->has_extended_tcb_support
= 1;
560 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
561 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
562 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
563 PCI_CONFIG_8(PCI_REVISION_ID
, 0x06);
565 s
->has_extended_tcb_support
= 1;
568 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
569 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
570 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
571 PCI_CONFIG_8(PCI_REVISION_ID
, 0x07);
573 s
->has_extended_tcb_support
= 1;
576 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
577 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
578 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
579 PCI_CONFIG_8(PCI_REVISION_ID
, 0x08);
580 // TODO: Windows wants revision id 0x0c.
581 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0c);
583 PCI_CONFIG_16(PCI_SUBSYSTEM_VENDOR_ID
, 0x8086);
584 PCI_CONFIG_16(PCI_SUBSYSTEM_ID
, 0x0040);
587 s
->has_extended_tcb_support
= 1;
590 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
591 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
592 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
593 PCI_CONFIG_8(PCI_REVISION_ID
, 0x09);
595 s
->has_extended_tcb_support
= 1;
598 // TODO: check device id.
599 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
600 /* TODO: wrong revision id. */
601 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0e);
603 s
->has_extended_tcb_support
= 1;
606 logout("Device %X is undefined!\n", device
);
609 s
->configuration
[6] |= BIT(5);
611 if (s
->stats_size
== 80) {
612 /* TODO: check TCO Statistical Counters bit. Documentation not clear. */
613 if (s
->configuration
[6] & BIT(2)) {
614 /* TCO statistical counters. */
615 assert(s
->configuration
[6] & BIT(5));
617 if (s
->configuration
[6] & BIT(5)) {
618 /* No extended statistical counters, i82557 compatible. */
621 /* i82558 compatible. */
626 if (s
->configuration
[6] & BIT(5)) {
627 /* No extended statistical counters. */
631 assert(s
->stats_size
> 0 && s
->stats_size
<= sizeof(s
->statistics
));
633 if (power_management
) {
634 /* Power Management Capabilities */
635 PCI_CONFIG_8(0xdc, 0x01);
636 /* Next Item Pointer */
638 PCI_CONFIG_16(0xde, 0x7e21);
639 /* TODO: Power Management Control / Status. */
640 /* TODO: Ethernet Power Consumption Registers (i82559 and later). */
644 if (device
== i82557C
|| device
== i82558B
|| device
== i82559C
) {
645 // TODO: get vendor id from EEPROM for i82557C or later.
646 // TODO: get device id from EEPROM for i82557C or later.
647 // TODO: status bit 4 can be disabled by EEPROM for i82558, i82559.
648 // TODO: header type is determined by EEPROM for i82559.
649 // TODO: get subsystem id from EEPROM for i82557C or later.
650 // TODO: get subsystem vendor id from EEPROM for i82557C or later.
651 // TODO: exp. rom baddr depends on a bit in EEPROM for i82558 or later.
652 // TODO: capability pointer depends on EEPROM for i82558.
653 logout("Get device id and revision from EEPROM!!!\n");
655 #endif /* EEPROM_SIZE > 0 */
658 static void nic_selective_reset(EEPRO100State
* s
)
661 uint16_t *eeprom_contents
= eeprom93xx_data(s
->eeprom
);
662 //~ eeprom93xx_reset(s->eeprom);
663 memcpy(eeprom_contents
, s
->conf
.macaddr
.a
, 6);
664 eeprom_contents
[EEPROM_ID
] = 0x4000;
665 if (s
->device
== i82557B
|| s
->device
== i82557C
)
666 eeprom_contents
[5] = 0x0100;
667 eeprom_contents
[EEPROM_PHY_ID
] = 1;
669 for (i
= 0; i
< EEPROM_SIZE
- 1; i
++) {
670 sum
+= eeprom_contents
[i
];
672 eeprom_contents
[EEPROM_SIZE
- 1] = 0xbaba - sum
;
673 TRACE(EEPROM
, logout("checksum=0x%04x\n", eeprom_contents
[EEPROM_SIZE
- 1]));
675 memset(s
->mem
, 0, sizeof(s
->mem
));
676 uint32_t val
= BIT(21);
677 memcpy(&s
->mem
[SCBCtrlMDI
], &val
, sizeof(val
));
679 assert(sizeof(s
->mdimem
) == sizeof(eepro100_mdi_default
));
680 memcpy(&s
->mdimem
[0], &eepro100_mdi_default
[0], sizeof(s
->mdimem
));
683 static void nic_reset(void *opaque
)
685 EEPRO100State
*s
= opaque
;
686 TRACE(OTHER
, logout("%p\n", s
));
687 /* TODO: Clearing of multicast table for selective reset, too? */
688 memset(&s
->mult
[0], 0, sizeof(s
->mult
));
689 nic_selective_reset(s
);
692 #if defined(DEBUG_EEPRO100)
693 static const char * const e100_reg
[PCI_IO_SIZE
/ 4] = {
697 "EEPROM/Flash Control",
699 "Receive DMA Byte Count",
701 "General Status/Control"
704 static char *regname(uint32_t addr
)
707 if (addr
< PCI_IO_SIZE
) {
708 const char *r
= e100_reg
[addr
/ 4];
710 snprintf(buf
, sizeof(buf
), "%s+%u", r
, addr
% 4);
712 snprintf(buf
, sizeof(buf
), "0x%02x", addr
);
715 snprintf(buf
, sizeof(buf
), "??? 0x%08x", addr
);
719 #endif /* DEBUG_EEPRO100 */
722 static uint16_t eepro100_read_status(EEPRO100State
* s
)
724 uint16_t val
= s
->status
;
725 TRACE(OTHER
, logout("val=0x%04x\n", val
));
729 static void eepro100_write_status(EEPRO100State
* s
, uint16_t val
)
731 TRACE(OTHER
, logout("val=0x%04x\n", val
));
736 /*****************************************************************************
740 ****************************************************************************/
743 static uint16_t eepro100_read_command(EEPRO100State
* s
)
745 uint16_t val
= 0xffff;
746 //~ TRACE(OTHER, logout("val=0x%04x\n", val));
751 /* Commands that can be put in a command list entry. */
756 CmdMulticastList
= 3,
758 CmdTDR
= 5, /* load microcode */
762 /* And some extra flags: */
763 CmdSuspend
= 0x4000, /* Suspend after completion. */
764 CmdIntr
= 0x2000, /* Interrupt after completion. */
765 CmdTxFlex
= 0x0008, /* Use "Flexible mode" for CmdTx command. */
768 static cu_state_t
get_cu_state(EEPRO100State
* s
)
770 return ((s
->mem
[SCBStatus
] & BITS(7, 6)) >> 6);
773 static void set_cu_state(EEPRO100State
* s
, cu_state_t state
)
775 s
->mem
[SCBStatus
] = (s
->mem
[SCBStatus
] & ~BITS(7, 6)) + (state
<< 6);
778 static ru_state_t
get_ru_state(EEPRO100State
* s
)
780 return ((s
->mem
[SCBStatus
] & BITS(5, 2)) >> 2);
783 static void set_ru_state(EEPRO100State
* s
, ru_state_t state
)
785 s
->mem
[SCBStatus
] = (s
->mem
[SCBStatus
] & ~BITS(5, 2)) + (state
<< 2);
788 static void dump_statistics(EEPRO100State
* s
)
790 /* Dump statistical data. Most data is never changed by the emulation
791 * and always 0, so we first just copy the whole block and then those
792 * values which really matter.
793 * Number of data should check configuration!!!
795 cpu_physical_memory_write(s
->statsaddr
,
796 (uint8_t *) & s
->statistics
, s
->stats_size
);
797 stl_le_phys(s
->statsaddr
+ 0, s
->statistics
.tx_good_frames
);
798 stl_le_phys(s
->statsaddr
+ 36, s
->statistics
.rx_good_frames
);
799 stl_le_phys(s
->statsaddr
+ 48, s
->statistics
.rx_resource_errors
);
800 stl_le_phys(s
->statsaddr
+ 60, s
->statistics
.rx_short_frame_errors
);
801 //~ stw_le_phys(s->statsaddr + 76, s->statistics.xmt_tco_frames);
802 //~ stw_le_phys(s->statsaddr + 78, s->statistics.rcv_tco_frames);
803 //~ missing("CU dump statistical counters");
806 static void tx_command(EEPRO100State
*s
)
808 uint32_t tbd_array
= le32_to_cpu(s
->tx
.tbd_array_addr
);
809 uint16_t tcb_bytes
= (le16_to_cpu(s
->tx
.tcb_bytes
) & 0x3fff);
810 /* Sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes. */
813 uint32_t tbd_address
= s
->cb_address
+ 0x10;
815 ("transmit, TBD array address 0x%08x, TCB byte count 0x%04x, TBD count %u\n",
816 tbd_array
, tcb_bytes
, s
->tx
.tbd_count
));
818 if (tcb_bytes
> 2600) {
819 logout("TCB byte count too large, using 2600\n");
822 if (!((tcb_bytes
> 0) || (tbd_array
!= 0xffffffff))) {
824 ("illegal values of TBD array address and TCB byte count!\n");
826 assert(tcb_bytes
<= sizeof(buf
));
827 while (size
< tcb_bytes
) {
828 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
829 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
830 //~ uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
833 ("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
834 tx_buffer_address
, tx_buffer_size
));
835 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
836 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
838 size
+= tx_buffer_size
;
840 if (tbd_array
== 0xffffffff) {
841 /* Simplified mode. Was already handled by code above. */
844 uint8_t tbd_count
= 0;
845 if (s
->has_extended_tcb_support
&& !(s
->configuration
[6] & BIT(4))) {
846 /* Extended Flexible TCB. */
847 for (; tbd_count
< 2; tbd_count
++) {
848 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
849 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
850 uint16_t tx_buffer_el
= lduw_phys(tbd_address
+ 6);
853 ("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n",
854 tx_buffer_address
, tx_buffer_size
));
855 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
856 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
858 size
+= tx_buffer_size
;
859 if (tx_buffer_el
& 1) {
864 tbd_address
= tbd_array
;
865 for (; tbd_count
< s
->tx
.tbd_count
; tbd_count
++) {
866 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
867 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
868 uint16_t tx_buffer_el
= lduw_phys(tbd_address
+ 6);
871 ("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n",
872 tx_buffer_address
, tx_buffer_size
));
873 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
874 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
876 size
+= tx_buffer_size
;
877 if (tx_buffer_el
& 1) {
882 TRACE(RXTX
, logout("%p sending frame, len=%d,%s\n", s
, size
, nic_dump(buf
, size
)));
883 qemu_send_packet(&s
->nic
->nc
, buf
, size
);
884 s
->statistics
.tx_good_frames
++;
885 /* Transmit with bad status would raise an CX/TNO interrupt.
886 * (82557 only). Emulation never has bad status. */
887 //~ eepro100_cx_interrupt(s);
890 static void set_multicast_list(EEPRO100State
*s
)
892 uint16_t multicast_count
= s
->tx
.tbd_array_addr
& BITS(13, 0);
894 memset(&s
->mult
[0], 0, sizeof(s
->mult
));
895 TRACE(OTHER
, logout("multicast list, multicast count = %u\n", multicast_count
));
896 for (i
= 0; i
< multicast_count
; i
+= 6) {
897 uint8_t multicast_addr
[6];
898 cpu_physical_memory_read(s
->cb_address
+ 10 + i
, multicast_addr
, 6);
899 TRACE(OTHER
, logout("multicast entry %s\n", nic_dump(multicast_addr
, 6)));
900 unsigned mcast_idx
= compute_mcast_idx(multicast_addr
);
901 assert(mcast_idx
< 64);
902 s
->mult
[mcast_idx
>> 3] |= (1 << (mcast_idx
& 7));
906 static void action_command(EEPRO100State
*s
)
909 s
->cb_address
= s
->cu_base
+ s
->cu_offset
;
910 cpu_physical_memory_read(s
->cb_address
, (uint8_t *)&s
->tx
, sizeof(s
->tx
));
911 uint16_t status
= le16_to_cpu(s
->tx
.status
);
912 uint16_t command
= le16_to_cpu(s
->tx
.command
);
913 logout("val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n",
914 status
, command
, s
->tx
.link
);
915 bool bit_el
= ((command
& COMMAND_EL
) != 0);
916 bool bit_s
= ((command
& COMMAND_S
) != 0);
917 bool bit_i
= ((command
& COMMAND_I
) != 0);
918 bool bit_nc
= ((command
& COMMAND_NC
) != 0);
920 //~ bool bit_sf = ((command & COMMAND_SF) != 0);
921 uint16_t cmd
= command
& COMMAND_CMD
;
922 s
->cu_offset
= le32_to_cpu(s
->tx
.link
);
928 cpu_physical_memory_read(s
->cb_address
+ 8, &s
->conf
.macaddr
.a
[0], 6);
929 TRACE(OTHER
, logout("macaddr: %s\n", nic_dump(&s
->conf
.macaddr
.a
[0], 6)));
932 cpu_physical_memory_read(s
->cb_address
+ 8, &s
->configuration
[0],
933 sizeof(s
->configuration
));
934 TRACE(OTHER
, logout("configuration: %s\n", nic_dump(&s
->configuration
[0], 16)));
936 case CmdMulticastList
:
937 set_multicast_list(s
);
941 missing("CmdTx: NC = 0");
948 TRACE(OTHER
, logout("load microcode\n"));
949 /* Starting with offset 8, the command contains
950 * 64 dwords microcode which we just ignore here. */
953 missing("undefined command");
957 /* Write new status. */
958 stw_phys(s
->cb_address
, status
| STATUS_C
| (success
? STATUS_OK
: 0));
960 /* CU completed action. */
961 eepro100_cx_interrupt(s
);
964 /* CU becomes idle. Terminate command loop. */
965 set_cu_state(s
, cu_idle
);
966 eepro100_cna_interrupt(s
);
969 /* CU becomes suspended. Terminate command loop. */
970 set_cu_state(s
, cu_suspended
);
971 eepro100_cna_interrupt(s
);
974 /* More entries in list. */
975 TRACE(OTHER
, logout("CU list with at least one more entry\n"));
978 TRACE(OTHER
, logout("CU list empty\n"));
979 /* List is empty. Now CU is idle or suspended. */
982 static void eepro100_cu_command(EEPRO100State
* s
, uint8_t val
)
989 if (get_cu_state(s
) != cu_idle
) {
990 /* Intel documentation says that CU must be idle for the CU
991 * start command. Intel driver for Linux also starts the CU
992 * from suspended state. */
993 logout("CU state is %u, should be %u\n", get_cu_state(s
), cu_idle
);
994 //~ assert(!"wrong CU state");
996 set_cu_state(s
, cu_active
);
997 s
->cu_offset
= s
->pointer
;
1001 if (get_cu_state(s
) != cu_suspended
) {
1002 logout("bad CU resume from CU state %u\n", get_cu_state(s
));
1003 /* Workaround for bad Linux eepro100 driver which resumes
1004 * from idle state. */
1005 //~ missing("cu resume");
1006 set_cu_state(s
, cu_suspended
);
1008 if (get_cu_state(s
) == cu_suspended
) {
1009 TRACE(OTHER
, logout("CU resuming\n"));
1010 set_cu_state(s
, cu_active
);
1015 /* Load dump counters address. */
1016 s
->statsaddr
= s
->pointer
;
1017 TRACE(OTHER
, logout("val=0x%02x (status address)\n", val
));
1020 /* Dump statistical counters. */
1021 TRACE(OTHER
, logout("val=0x%02x (dump stats)\n", val
));
1023 stl_le_phys(s
->statsaddr
+ s
->stats_size
, 0xa005);
1027 TRACE(OTHER
, logout("val=0x%02x (CU base address)\n", val
));
1028 s
->cu_base
= s
->pointer
;
1031 /* Dump and reset statistical counters. */
1032 TRACE(OTHER
, logout("val=0x%02x (dump stats and reset)\n", val
));
1034 stl_le_phys(s
->statsaddr
+ s
->stats_size
, 0xa007);
1035 memset(&s
->statistics
, 0, sizeof(s
->statistics
));
1038 /* CU static resume. */
1039 missing("CU static resume");
1042 missing("Undefined CU command");
1046 static void eepro100_ru_command(EEPRO100State
* s
, uint8_t val
)
1054 if (get_ru_state(s
) != ru_idle
) {
1055 logout("RU state is %u, should be %u\n", get_ru_state(s
), ru_idle
);
1056 //~ assert(!"wrong RU state");
1058 set_ru_state(s
, ru_ready
);
1059 s
->ru_offset
= s
->pointer
;
1060 TRACE(OTHER
, logout("val=0x%02x (rx start)\n", val
));
1064 if (get_ru_state(s
) != ru_suspended
) {
1065 logout("RU state is %u, should be %u\n", get_ru_state(s
),
1067 //~ assert(!"wrong RU state");
1069 set_ru_state(s
, ru_ready
);
1073 TRACE(OTHER
, logout("val=0x%02x (RU base address)\n", val
));
1074 s
->ru_base
= s
->pointer
;
1077 logout("val=0x%02x (undefined RU command)\n", val
);
1078 missing("Undefined SU command");
1082 static void eepro100_write_command(EEPRO100State
* s
, uint8_t val
)
1084 eepro100_ru_command(s
, val
& 0x0f);
1085 eepro100_cu_command(s
, val
& 0xf0);
1087 TRACE(OTHER
, logout("val=0x%02x\n", val
));
1089 /* Clear command byte after command was accepted. */
1093 /*****************************************************************************
1097 ****************************************************************************/
1099 #define EEPROM_CS 0x02
1100 #define EEPROM_SK 0x01
1101 #define EEPROM_DI 0x04
1102 #define EEPROM_DO 0x08
1104 static uint16_t eepro100_read_eeprom(EEPRO100State
* s
)
1107 memcpy(&val
, &s
->mem
[SCBeeprom
], sizeof(val
));
1108 if (eeprom93xx_read(s
->eeprom
)) {
1113 TRACE(EEPROM
, logout("val=0x%04x\n", val
));
1117 static void eepro100_write_eeprom(eeprom_t
* eeprom
, uint8_t val
)
1119 TRACE(EEPROM
, logout("val=0x%02x\n", val
));
1121 /* mask unwriteable bits */
1122 //~ val = SET_MASKED(val, 0x31, eeprom->value);
1124 int eecs
= ((val
& EEPROM_CS
) != 0);
1125 int eesk
= ((val
& EEPROM_SK
) != 0);
1126 int eedi
= ((val
& EEPROM_DI
) != 0);
1127 eeprom93xx_write(eeprom
, eecs
, eesk
, eedi
);
1130 static void eepro100_write_pointer(EEPRO100State
* s
, uint32_t val
)
1132 s
->pointer
= le32_to_cpu(val
);
1133 TRACE(OTHER
, logout("val=0x%08x\n", val
));
1136 /*****************************************************************************
1140 ****************************************************************************/
1142 #if defined(DEBUG_EEPRO100)
1143 static const char * const mdi_op_name
[] = {
1150 static const char * const mdi_reg_name
[] = {
1153 "PHY Identification (Word 1)",
1154 "PHY Identification (Word 2)",
1155 "Auto-Negotiation Advertisement",
1156 "Auto-Negotiation Link Partner Ability",
1157 "Auto-Negotiation Expansion"
1160 static const char *reg2name(uint8_t reg
)
1162 static char buffer
[10];
1163 const char *p
= buffer
;
1164 if (reg
< ARRAY_SIZE(mdi_reg_name
)) {
1165 p
= mdi_reg_name
[reg
];
1167 snprintf(buffer
, sizeof(buffer
), "reg=0x%02x", reg
);
1171 #endif /* DEBUG_EEPRO100 */
1173 static uint32_t eepro100_read_mdi(EEPRO100State
* s
)
1176 memcpy(&val
, &s
->mem
[0x10], sizeof(val
));
1178 #ifdef DEBUG_EEPRO100
1179 uint8_t raiseint
= (val
& BIT(29)) >> 29;
1180 uint8_t opcode
= (val
& BITS(27, 26)) >> 26;
1181 uint8_t phy
= (val
& BITS(25, 21)) >> 21;
1182 uint8_t reg
= (val
& BITS(20, 16)) >> 16;
1183 uint16_t data
= (val
& BITS(15, 0));
1185 /* Emulation takes no time to finish MDI transaction. */
1187 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1188 val
, raiseint
, mdi_op_name
[opcode
], phy
,
1189 reg2name(reg
), data
));
1193 static void eepro100_write_mdi(EEPRO100State
* s
, uint32_t val
)
1195 uint8_t raiseint
= (val
& BIT(29)) >> 29;
1196 uint8_t opcode
= (val
& BITS(27, 26)) >> 26;
1197 uint8_t phy
= (val
& BITS(25, 21)) >> 21;
1198 uint8_t reg
= (val
& BITS(20, 16)) >> 16;
1199 uint16_t data
= (val
& BITS(15, 0));
1200 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1201 val
, raiseint
, mdi_op_name
[opcode
], phy
, reg2name(reg
), data
));
1203 /* Unsupported PHY address. */
1204 //~ logout("phy must be 1 but is %u\n", phy);
1206 } else if (opcode
!= 1 && opcode
!= 2) {
1207 /* Unsupported opcode. */
1208 logout("opcode must be 1 or 2 but is %u\n", opcode
);
1210 } else if (reg
> 6) {
1211 /* Unsupported register. */
1212 logout("register must be 0...6 but is %u\n", reg
);
1215 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1216 val
, raiseint
, mdi_op_name
[opcode
], phy
,
1217 reg2name(reg
), data
));
1221 case 0: /* Control Register */
1222 if (data
& 0x8000) {
1223 /* Reset status and control registers to default. */
1224 s
->mdimem
[0] = eepro100_mdi_default
[0];
1225 s
->mdimem
[1] = eepro100_mdi_default
[1];
1226 data
= s
->mdimem
[reg
];
1228 /* Restart Auto Configuration = Normal Operation */
1232 case 1: /* Status Register */
1233 missing("not writable");
1234 data
= s
->mdimem
[reg
];
1236 case 2: /* PHY Identification Register (Word 1) */
1237 case 3: /* PHY Identification Register (Word 2) */
1238 missing("not implemented");
1240 case 4: /* Auto-Negotiation Advertisement Register */
1241 case 5: /* Auto-Negotiation Link Partner Ability Register */
1243 case 6: /* Auto-Negotiation Expansion Register */
1245 missing("not implemented");
1247 s
->mdimem
[reg
] = data
;
1248 } else if (opcode
== 2) {
1251 case 0: /* Control Register */
1252 if (data
& 0x8000) {
1253 /* Reset status and control registers to default. */
1254 s
->mdimem
[0] = eepro100_mdi_default
[0];
1255 s
->mdimem
[1] = eepro100_mdi_default
[1];
1258 case 1: /* Status Register */
1259 s
->mdimem
[reg
] |= 0x0020;
1261 case 2: /* PHY Identification Register (Word 1) */
1262 case 3: /* PHY Identification Register (Word 2) */
1263 case 4: /* Auto-Negotiation Advertisement Register */
1265 case 5: /* Auto-Negotiation Link Partner Ability Register */
1266 s
->mdimem
[reg
] = 0x41fe;
1268 case 6: /* Auto-Negotiation Expansion Register */
1269 s
->mdimem
[reg
] = 0x0001;
1272 data
= s
->mdimem
[reg
];
1274 /* Emulation takes no time to finish MDI transaction.
1275 * Set MDI bit in SCB status register. */
1276 s
->mem
[SCBAck
] |= 0x08;
1279 eepro100_mdi_interrupt(s
);
1282 val
= (val
& 0xffff0000) + data
;
1283 memcpy(&s
->mem
[0x10], &val
, sizeof(val
));
1286 /*****************************************************************************
1290 ****************************************************************************/
1292 #define PORT_SOFTWARE_RESET 0
1293 #define PORT_SELFTEST 1
1294 #define PORT_SELECTIVE_RESET 2
1296 #define PORT_SELECTION_MASK 3
1299 uint32_t st_sign
; /* Self Test Signature */
1300 uint32_t st_result
; /* Self Test Results */
1301 } eepro100_selftest_t
;
1303 static uint32_t eepro100_read_port(EEPRO100State
* s
)
1308 static void eepro100_write_port(EEPRO100State
* s
, uint32_t val
)
1310 val
= le32_to_cpu(val
);
1311 uint32_t address
= (val
& ~PORT_SELECTION_MASK
);
1312 uint8_t selection
= (val
& PORT_SELECTION_MASK
);
1313 switch (selection
) {
1314 case PORT_SOFTWARE_RESET
:
1318 TRACE(OTHER
, logout("selftest address=0x%08x\n", address
));
1319 eepro100_selftest_t data
;
1320 cpu_physical_memory_read(address
, (uint8_t *) & data
, sizeof(data
));
1321 data
.st_sign
= 0xffffffff;
1323 cpu_physical_memory_write(address
, (uint8_t *) & data
, sizeof(data
));
1325 case PORT_SELECTIVE_RESET
:
1326 TRACE(OTHER
, logout("selective reset, selftest address=0x%08x\n", address
));
1327 nic_selective_reset(s
);
1330 logout("val=0x%08x\n", val
);
1331 missing("unknown port selection");
1335 /*****************************************************************************
1337 * General hardware emulation.
1339 ****************************************************************************/
1341 static uint8_t eepro100_read1(EEPRO100State
* s
, uint32_t addr
)
1344 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1345 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1350 //~ val = eepro100_read_status(s);
1351 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1354 //~ val = eepro100_read_status(s);
1355 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1358 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1359 //~ val = eepro100_read_command(s);
1362 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1365 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1368 val
= eepro100_read_eeprom(s
);
1370 case SCBpmdr
: /* Power Management Driver Register */
1372 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1374 case SCBgstat
: /* General Status Register */
1375 /* 100 Mbps full duplex, valid link */
1377 TRACE(OTHER
, logout("addr=General Status val=%02x\n", val
));
1380 logout("addr=%s val=0x%02x\n", regname(addr
), val
);
1381 missing("unknown byte read");
1386 static uint16_t eepro100_read2(EEPRO100State
* s
, uint32_t addr
)
1389 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1390 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1395 //~ val = eepro100_read_status(s);
1397 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1400 val
= eepro100_read_eeprom(s
);
1401 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1404 logout("addr=%s val=0x%04x\n", regname(addr
), val
);
1405 missing("unknown word read");
1410 static uint32_t eepro100_read4(EEPRO100State
* s
, uint32_t addr
)
1413 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1414 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1419 //~ val = eepro100_read_status(s);
1420 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1423 //~ val = eepro100_read_pointer(s);
1424 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1427 val
= eepro100_read_port(s
);
1428 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1431 val
= eepro100_read_mdi(s
);
1434 logout("addr=%s val=0x%08x\n", regname(addr
), val
);
1435 missing("unknown longword read");
1440 static void eepro100_write1(EEPRO100State
* s
, uint32_t addr
, uint8_t val
)
1442 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1443 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1446 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1450 //~ eepro100_write_status(s, val);
1453 eepro100_acknowledge(s
);
1456 eepro100_write_command(s
, val
);
1460 eepro100_swi_interrupt(s
);
1462 eepro100_interrupt(s
, 0);
1465 case SCBFlow
: /* does not exist on 82557 */
1468 case SCBpmdr
: /* does not exist on 82557 */
1469 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1472 eepro100_write_eeprom(s
->eeprom
, val
);
1475 logout("addr=%s val=0x%02x\n", regname(addr
), val
);
1476 missing("unknown byte write");
1480 static void eepro100_write2(EEPRO100State
* s
, uint32_t addr
, uint16_t val
)
1482 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1483 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1486 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1490 //~ eepro100_write_status(s, val);
1491 eepro100_acknowledge(s
);
1494 eepro100_write_command(s
, val
);
1495 eepro100_write1(s
, SCBIntmask
, val
>> 8);
1498 eepro100_write_eeprom(s
->eeprom
, val
);
1501 logout("addr=%s val=0x%04x\n", regname(addr
), val
);
1502 missing("unknown word write");
1506 static void eepro100_write4(EEPRO100State
* s
, uint32_t addr
, uint32_t val
)
1508 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1509 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1514 eepro100_write_pointer(s
, val
);
1517 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1518 eepro100_write_port(s
, val
);
1521 eepro100_write_mdi(s
, val
);
1524 logout("addr=%s val=0x%08x\n", regname(addr
), val
);
1525 missing("unknown longword write");
1529 /*****************************************************************************
1533 ****************************************************************************/
1535 static uint32_t ioport_read1(void *opaque
, uint32_t addr
)
1537 EEPRO100State
*s
= opaque
;
1538 //~ logout("addr=%s\n", regname(addr));
1539 return eepro100_read1(s
, addr
- s
->region
[1]);
1542 static uint32_t ioport_read2(void *opaque
, uint32_t addr
)
1544 EEPRO100State
*s
= opaque
;
1545 return eepro100_read2(s
, addr
- s
->region
[1]);
1548 static uint32_t ioport_read4(void *opaque
, uint32_t addr
)
1550 EEPRO100State
*s
= opaque
;
1551 return eepro100_read4(s
, addr
- s
->region
[1]);
1554 static void ioport_write1(void *opaque
, uint32_t addr
, uint32_t val
)
1556 EEPRO100State
*s
= opaque
;
1557 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1558 eepro100_write1(s
, addr
- s
->region
[1], val
);
1561 static void ioport_write2(void *opaque
, uint32_t addr
, uint32_t val
)
1563 EEPRO100State
*s
= opaque
;
1564 eepro100_write2(s
, addr
- s
->region
[1], val
);
1567 static void ioport_write4(void *opaque
, uint32_t addr
, uint32_t val
)
1569 EEPRO100State
*s
= opaque
;
1570 eepro100_write4(s
, addr
- s
->region
[1], val
);
1573 /***********************************************************/
1574 /* PCI EEPRO100 definitions */
1576 static void pci_map(PCIDevice
* pci_dev
, int region_num
,
1577 pcibus_t addr
, pcibus_t size
, int type
)
1579 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1581 TRACE(OTHER
, logout("region %d, addr=0x%08"FMT_PCIBUS
", "
1582 "size=0x%08"FMT_PCIBUS
", type=%d\n",
1583 region_num
, addr
, size
, type
));
1585 assert(region_num
== 1);
1586 register_ioport_write(addr
, size
, 1, ioport_write1
, s
);
1587 register_ioport_read(addr
, size
, 1, ioport_read1
, s
);
1588 register_ioport_write(addr
, size
, 2, ioport_write2
, s
);
1589 register_ioport_read(addr
, size
, 2, ioport_read2
, s
);
1590 register_ioport_write(addr
, size
, 4, ioport_write4
, s
);
1591 register_ioport_read(addr
, size
, 4, ioport_read4
, s
);
1593 s
->region
[region_num
] = addr
;
1596 /*****************************************************************************
1598 * Memory mapped I/O.
1600 ****************************************************************************/
1602 static void pci_mmio_writeb(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1604 EEPRO100State
*s
= opaque
;
1605 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1606 eepro100_write1(s
, addr
, val
);
1609 static void pci_mmio_writew(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1611 EEPRO100State
*s
= opaque
;
1612 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1613 eepro100_write2(s
, addr
, val
);
1616 static void pci_mmio_writel(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1618 EEPRO100State
*s
= opaque
;
1619 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1620 eepro100_write4(s
, addr
, val
);
1623 static uint32_t pci_mmio_readb(void *opaque
, target_phys_addr_t addr
)
1625 EEPRO100State
*s
= opaque
;
1626 //~ logout("addr=%s\n", regname(addr));
1627 return eepro100_read1(s
, addr
);
1630 static uint32_t pci_mmio_readw(void *opaque
, target_phys_addr_t addr
)
1632 EEPRO100State
*s
= opaque
;
1633 //~ logout("addr=%s\n", regname(addr));
1634 return eepro100_read2(s
, addr
);
1637 static uint32_t pci_mmio_readl(void *opaque
, target_phys_addr_t addr
)
1639 EEPRO100State
*s
= opaque
;
1640 //~ logout("addr=%s\n", regname(addr));
1641 return eepro100_read4(s
, addr
);
1644 static CPUWriteMemoryFunc
* const pci_mmio_write
[] = {
1650 static CPUReadMemoryFunc
* const pci_mmio_read
[] = {
1656 static void pci_mmio_map(PCIDevice
* pci_dev
, int region_num
,
1657 pcibus_t addr
, pcibus_t size
, int type
)
1659 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1661 TRACE(OTHER
, logout("region %d, addr=0x%08"FMT_PCIBUS
", "
1662 "size=0x%08"FMT_PCIBUS
", type=%d\n",
1663 region_num
, addr
, size
, type
));
1665 if (region_num
== 0) {
1666 /* Map control / status registers. */
1667 cpu_register_physical_memory(addr
, size
, s
->mmio_index
);
1668 s
->region
[region_num
] = addr
;
1672 static int nic_can_receive(VLANClientState
*nc
)
1674 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1675 TRACE(RXTX
, logout("%p\n", s
));
1676 return get_ru_state(s
) == ru_ready
;
1677 //~ return !eepro100_buffer_full(s);
1680 static ssize_t
nic_receive(VLANClientState
*nc
, const uint8_t * buf
, size_t size
)
1683 * - Magic packets should set bit 30 in power management driver register.
1684 * - Interesting packets should set bit 29 in power management driver register.
1686 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1687 uint16_t rfd_status
= 0xa000;
1688 static const uint8_t broadcast_macaddr
[6] =
1689 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1691 /* TODO: check multiple IA bit. */
1692 if (s
->configuration
[20] & BIT(6)) {
1693 missing("Multiple IA bit");
1697 if (s
->configuration
[8] & 0x80) {
1698 /* CSMA is disabled. */
1699 logout("%p received while CSMA is disabled\n", s
);
1701 } else if (size
< 64 && (s
->configuration
[7] & BIT(0))) {
1702 /* Short frame and configuration byte 7/0 (discard short receive) set:
1703 * Short frame is discarded */
1704 logout("%p received short frame (%zu byte)\n", s
, size
);
1705 s
->statistics
.rx_short_frame_errors
++;
1707 } else if ((size
> MAX_ETH_FRAME_SIZE
+ 4) && !(s
->configuration
[18] & BIT(3))) {
1708 /* Long frame and configuration byte 18/3 (long receive ok) not set:
1709 * Long frames are discarded. */
1710 logout("%p received long frame (%zu byte), ignored\n", s
, size
);
1712 } else if (memcmp(buf
, s
->conf
.macaddr
.a
, 6) == 0) { // !!!
1713 /* Frame matches individual address. */
1714 /* TODO: check configuration byte 15/4 (ignore U/L). */
1715 TRACE(RXTX
, logout("%p received frame for me, len=%zu\n", s
, size
));
1716 } else if (memcmp(buf
, broadcast_macaddr
, 6) == 0) {
1717 /* Broadcast frame. */
1718 TRACE(RXTX
, logout("%p received broadcast, len=%zu\n", s
, size
));
1719 rfd_status
|= 0x0002;
1720 } else if (buf
[0] & 0x01) {
1721 /* Multicast frame. */
1722 TRACE(RXTX
, logout("%p received multicast, len=%zu,%s\n", s
, size
, nic_dump(buf
, size
)));
1723 if (s
->configuration
[21] & BIT(3)) {
1724 /* Multicast all bit is set, receive all multicast frames. */
1726 unsigned mcast_idx
= compute_mcast_idx(buf
);
1727 assert(mcast_idx
< 64);
1728 if (s
->mult
[mcast_idx
>> 3] & (1 << (mcast_idx
& 7))) {
1729 /* Multicast frame is allowed in hash table. */
1730 } else if (s
->configuration
[15] & BIT(0)) {
1731 /* Promiscuous: receive all. */
1732 rfd_status
|= 0x0004;
1734 TRACE(RXTX
, logout("%p multicast ignored\n", s
));
1738 /* TODO: Next not for promiscuous mode? */
1739 rfd_status
|= 0x0002;
1740 } else if (s
->configuration
[15] & BIT(0)) {
1741 /* Promiscuous: receive all. */
1742 TRACE(RXTX
, logout("%p received frame in promiscuous mode, len=%zu\n", s
, size
));
1743 rfd_status
|= 0x0004;
1745 TRACE(RXTX
, logout("%p received frame, ignored, len=%zu,%s\n", s
, size
,
1746 nic_dump(buf
, size
)));
1750 if (get_ru_state(s
) != ru_ready
) {
1751 /* No resources available. */
1752 logout("no resources, state=%u\n", get_ru_state(s
));
1753 s
->statistics
.rx_resource_errors
++;
1754 //~ assert(!"no resources");
1758 //~ $3 = {status = 0x0, command = 0xc000, link = 0x2d220, rx_buf_addr = 0x207dc, count = 0x0, size = 0x5f8, packet = {0x0 <repeats 1518 times>}}
1760 cpu_physical_memory_read(s
->ru_base
+ s
->ru_offset
, (uint8_t *) & rx
,
1761 offsetof(eepro100_rx_t
, packet
));
1762 uint16_t rfd_command
= le16_to_cpu(rx
.command
);
1763 uint16_t rfd_size
= le16_to_cpu(rx
.size
);
1765 if (size
> rfd_size
) {
1766 logout("Receive buffer (%" PRId16
" bytes) too small for data "
1767 "(%zu bytes); data truncated\n", rfd_size
, size
);
1771 rfd_status
|= 0x0080;
1773 TRACE(OTHER
, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
1774 rfd_command
, rx
.link
, rx
.rx_buf_addr
, rfd_size
));
1775 stw_phys(s
->ru_base
+ s
->ru_offset
+ offsetof(eepro100_rx_t
, status
),
1777 stw_phys(s
->ru_base
+ s
->ru_offset
+ offsetof(eepro100_rx_t
, count
), size
);
1778 /* Early receive interrupt not supported. */
1779 //~ eepro100_er_interrupt(s);
1780 /* Receive CRC Transfer not supported. */
1781 if (s
->configuration
[18] & BIT(2)) {
1782 missing("Receive CRC Transfer");
1785 /* TODO: check stripping enable bit. */
1786 //~ assert(!(s->configuration[17] & BIT(0)));
1787 cpu_physical_memory_write(s
->ru_base
+ s
->ru_offset
+
1788 offsetof(eepro100_rx_t
, packet
), buf
, size
);
1789 s
->statistics
.rx_good_frames
++;
1790 eepro100_fr_interrupt(s
);
1791 s
->ru_offset
= le32_to_cpu(rx
.link
);
1792 if (rfd_command
& COMMAND_EL
) {
1793 /* EL bit is set, so this was the last frame. */
1794 logout("receive: Running out of frames\n");
1795 set_ru_state(s
, ru_suspended
);
1797 if (rfd_command
& COMMAND_S
) {
1799 set_ru_state(s
, ru_suspended
);
1804 static const VMStateDescription vmstate_eepro100
= {
1806 .minimum_version_id
= 2,
1807 .minimum_version_id_old
= 2,
1808 .fields
= (VMStateField
[]) {
1809 VMSTATE_PCI_DEVICE(dev
, EEPRO100State
),
1811 VMSTATE_BUFFER(mult
, EEPRO100State
),
1812 VMSTATE_BUFFER(mem
, EEPRO100State
),
1813 /* Save all members of struct between scb_stat and mem. */
1814 VMSTATE_UINT8(scb_stat
, EEPRO100State
),
1815 VMSTATE_UINT8(int_stat
, EEPRO100State
),
1816 VMSTATE_UNUSED(3*4),
1817 VMSTATE_MACADDR(conf
.macaddr
, EEPRO100State
),
1818 VMSTATE_UNUSED(19*4),
1819 VMSTATE_UINT16_ARRAY(mdimem
, EEPRO100State
, 32),
1820 /* The eeprom should be saved and restored by its own routines. */
1821 VMSTATE_UINT32(device
, EEPRO100State
),
1822 /* TODO check device. */
1823 VMSTATE_UINT32(pointer
, EEPRO100State
),
1824 VMSTATE_UINT32(cu_base
, EEPRO100State
),
1825 VMSTATE_UINT32(cu_offset
, EEPRO100State
),
1826 VMSTATE_UINT32(ru_base
, EEPRO100State
),
1827 VMSTATE_UINT32(ru_offset
, EEPRO100State
),
1828 VMSTATE_UINT32(statsaddr
, EEPRO100State
),
1829 /* Save eepro100_stats_t statistics. */
1830 VMSTATE_UINT32(statistics
.tx_good_frames
, EEPRO100State
),
1831 VMSTATE_UINT32(statistics
.tx_max_collisions
, EEPRO100State
),
1832 VMSTATE_UINT32(statistics
.tx_late_collisions
, EEPRO100State
),
1833 VMSTATE_UINT32(statistics
.tx_underruns
, EEPRO100State
),
1834 VMSTATE_UINT32(statistics
.tx_lost_crs
, EEPRO100State
),
1835 VMSTATE_UINT32(statistics
.tx_deferred
, EEPRO100State
),
1836 VMSTATE_UINT32(statistics
.tx_single_collisions
, EEPRO100State
),
1837 VMSTATE_UINT32(statistics
.tx_multiple_collisions
, EEPRO100State
),
1838 VMSTATE_UINT32(statistics
.tx_total_collisions
, EEPRO100State
),
1839 VMSTATE_UINT32(statistics
.rx_good_frames
, EEPRO100State
),
1840 VMSTATE_UINT32(statistics
.rx_crc_errors
, EEPRO100State
),
1841 VMSTATE_UINT32(statistics
.rx_alignment_errors
, EEPRO100State
),
1842 VMSTATE_UINT32(statistics
.rx_resource_errors
, EEPRO100State
),
1843 VMSTATE_UINT32(statistics
.rx_overrun_errors
, EEPRO100State
),
1844 VMSTATE_UINT32(statistics
.rx_cdt_errors
, EEPRO100State
),
1845 VMSTATE_UINT32(statistics
.rx_short_frame_errors
, EEPRO100State
),
1846 VMSTATE_UINT32(statistics
.fc_xmt_pause
, EEPRO100State
),
1847 VMSTATE_UINT32(statistics
.fc_rcv_pause
, EEPRO100State
),
1848 VMSTATE_UINT32(statistics
.fc_rcv_unsupported
, EEPRO100State
),
1849 VMSTATE_UINT16(statistics
.xmt_tco_frames
, EEPRO100State
),
1850 VMSTATE_UINT16(statistics
.rcv_tco_frames
, EEPRO100State
),
1852 VMSTATE_UINT16(status
, EEPRO100State
),
1854 /* Configuration bytes. */
1855 VMSTATE_BUFFER(configuration
, EEPRO100State
),
1856 VMSTATE_END_OF_LIST()
1860 static void nic_cleanup(VLANClientState
*nc
)
1862 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1867 static int pci_nic_uninit(PCIDevice
*pci_dev
)
1869 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1871 cpu_unregister_io_memory(s
->mmio_index
);
1872 vmstate_unregister(s
->vmstate
, s
);
1873 eeprom93xx_free(s
->eeprom
);
1874 qemu_del_vlan_client(&s
->nic
->nc
);
1878 static NetClientInfo net_eepro100_info
= {
1879 .type
= NET_CLIENT_TYPE_NIC
,
1880 .size
= sizeof(NICState
),
1881 .can_receive
= nic_can_receive
,
1882 .receive
= nic_receive
,
1883 .cleanup
= nic_cleanup
,
1886 static int nic_init(PCIDevice
*pci_dev
, uint32_t device
)
1888 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1890 TRACE(OTHER
, logout("\n"));
1896 /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
1897 * i82559 and later support 64 or 256 word EEPROM. */
1898 s
->eeprom
= eeprom93xx_new(EEPROM_SIZE
);
1900 /* Handler for memory-mapped I/O */
1902 cpu_register_io_memory(pci_mmio_read
, pci_mmio_write
, s
);
1904 pci_register_bar(&s
->dev
, 0, PCI_MEM_SIZE
,
1905 PCI_BASE_ADDRESS_SPACE_MEMORY
|
1906 PCI_BASE_ADDRESS_MEM_PREFETCH
, pci_mmio_map
);
1907 pci_register_bar(&s
->dev
, 1, PCI_IO_SIZE
, PCI_BASE_ADDRESS_SPACE_IO
,
1909 pci_register_bar(&s
->dev
, 2, PCI_FLASH_SIZE
, PCI_BASE_ADDRESS_SPACE_MEMORY
,
1912 qemu_macaddr_default_if_unset(&s
->conf
.macaddr
);
1913 logout("macaddr: %s\n", nic_dump(&s
->conf
.macaddr
.a
[0], 6));
1914 assert(s
->region
[1] == 0);
1918 s
->nic
= qemu_new_nic(&net_eepro100_info
, &s
->conf
,
1919 pci_dev
->qdev
.info
->name
, pci_dev
->qdev
.id
, s
);
1921 qemu_format_nic_info_str(&s
->nic
->nc
, s
->conf
.macaddr
.a
);
1922 TRACE(OTHER
, logout("%s\n", s
->nic
->nc
.info_str
));
1924 qemu_register_reset(nic_reset
, s
);
1926 s
->vmstate
= qemu_malloc(sizeof(vmstate_eepro100
));
1927 memcpy(s
->vmstate
, &vmstate_eepro100
, sizeof(vmstate_eepro100
));
1928 s
->vmstate
->name
= s
->nic
->nc
.model
;
1929 vmstate_register(-1, s
->vmstate
, s
);
1934 static int pci_i82550_init(PCIDevice
*pci_dev
)
1936 return nic_init(pci_dev
, i82550
);
1939 static int pci_i82551_init(PCIDevice
*pci_dev
)
1941 return nic_init(pci_dev
, i82551
);
1944 static int pci_i82557a_init(PCIDevice
*pci_dev
)
1946 return nic_init(pci_dev
, i82557A
);
1949 static int pci_i82557b_init(PCIDevice
*pci_dev
)
1951 return nic_init(pci_dev
, i82557B
);
1954 static int pci_i82557c_init(PCIDevice
*pci_dev
)
1956 return nic_init(pci_dev
, i82557C
);
1959 static int pci_i82558a_init(PCIDevice
*pci_dev
)
1961 return nic_init(pci_dev
, i82558A
);
1964 static int pci_i82558b_init(PCIDevice
*pci_dev
)
1966 return nic_init(pci_dev
, i82558B
);
1969 static int pci_i82559a_init(PCIDevice
*pci_dev
)
1971 return nic_init(pci_dev
, i82559A
);
1974 static int pci_i82559b_init(PCIDevice
*pci_dev
)
1976 return nic_init(pci_dev
, i82559B
);
1979 static int pci_i82559c_init(PCIDevice
*pci_dev
)
1981 return nic_init(pci_dev
, i82559C
);
1984 static int pci_i82559er_init(PCIDevice
*pci_dev
)
1986 return nic_init(pci_dev
, i82559ER
);
1989 static int pci_i82562_init(PCIDevice
*pci_dev
)
1991 return nic_init(pci_dev
, i82562
);
1994 static PCIDeviceInfo eepro100_info
[] = {
1996 .qdev
.name
= "i82550",
1997 .qdev
.desc
= "Intel i82550 Ethernet",
1998 .qdev
.size
= sizeof(EEPRO100State
),
1999 .init
= pci_i82550_init
,
2000 .exit
= pci_nic_uninit
,
2001 .romfile
= "gpxe-eepro100-80861209.rom",
2002 .qdev
.props
= (Property
[]) {
2003 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2004 DEFINE_PROP_END_OF_LIST(),
2007 .qdev
.name
= "i82551",
2008 .qdev
.desc
= "Intel i82551 Ethernet",
2009 .qdev
.size
= sizeof(EEPRO100State
),
2010 .init
= pci_i82551_init
,
2011 .exit
= pci_nic_uninit
,
2012 .romfile
= "gpxe-eepro100-80861209.rom",
2013 .qdev
.props
= (Property
[]) {
2014 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2015 DEFINE_PROP_END_OF_LIST(),
2018 .qdev
.name
= "i82557a",
2019 .qdev
.desc
= "Intel i82557A Ethernet",
2020 .qdev
.size
= sizeof(EEPRO100State
),
2021 .init
= pci_i82557a_init
,
2022 .exit
= pci_nic_uninit
,
2023 .romfile
= "gpxe-eepro100-80861229.rom",
2024 .qdev
.props
= (Property
[]) {
2025 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2026 DEFINE_PROP_END_OF_LIST(),
2029 .qdev
.name
= "i82557b",
2030 .qdev
.desc
= "Intel i82557B Ethernet",
2031 .qdev
.size
= sizeof(EEPRO100State
),
2032 .init
= pci_i82557b_init
,
2033 .exit
= pci_nic_uninit
,
2034 .romfile
= "gpxe-eepro100-80861229.rom",
2035 .qdev
.props
= (Property
[]) {
2036 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2037 DEFINE_PROP_END_OF_LIST(),
2040 .qdev
.name
= "i82557c",
2041 .qdev
.desc
= "Intel i82557C Ethernet",
2042 .qdev
.size
= sizeof(EEPRO100State
),
2043 .init
= pci_i82557c_init
,
2044 .exit
= pci_nic_uninit
,
2045 .romfile
= "gpxe-eepro100-80861229.rom",
2046 .qdev
.props
= (Property
[]) {
2047 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2048 DEFINE_PROP_END_OF_LIST(),
2051 .qdev
.name
= "i82558a",
2052 .qdev
.desc
= "Intel i82558A Ethernet",
2053 .qdev
.size
= sizeof(EEPRO100State
),
2054 .init
= pci_i82558a_init
,
2055 .exit
= pci_nic_uninit
,
2056 .romfile
= "gpxe-eepro100-80861229.rom",
2057 .qdev
.props
= (Property
[]) {
2058 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2059 DEFINE_PROP_END_OF_LIST(),
2062 .qdev
.name
= "i82558b",
2063 .qdev
.desc
= "Intel i82558B Ethernet",
2064 .qdev
.size
= sizeof(EEPRO100State
),
2065 .init
= pci_i82558b_init
,
2066 .exit
= pci_nic_uninit
,
2067 .romfile
= "gpxe-eepro100-80861229.rom",
2068 .qdev
.props
= (Property
[]) {
2069 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2070 DEFINE_PROP_END_OF_LIST(),
2073 .qdev
.name
= "i82559a",
2074 .qdev
.desc
= "Intel i82559A Ethernet",
2075 .qdev
.size
= sizeof(EEPRO100State
),
2076 .init
= pci_i82559a_init
,
2077 .exit
= pci_nic_uninit
,
2078 .romfile
= "gpxe-eepro100-80861229.rom",
2079 .qdev
.props
= (Property
[]) {
2080 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2081 DEFINE_PROP_END_OF_LIST(),
2084 .qdev
.name
= "i82559b",
2085 .qdev
.desc
= "Intel i82559B Ethernet",
2086 .qdev
.size
= sizeof(EEPRO100State
),
2087 .init
= pci_i82559b_init
,
2088 .exit
= pci_nic_uninit
,
2089 .romfile
= "gpxe-eepro100-80861229.rom",
2090 .qdev
.props
= (Property
[]) {
2091 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2092 DEFINE_PROP_END_OF_LIST(),
2095 .qdev
.name
= "i82559c",
2096 .qdev
.desc
= "Intel i82559C Ethernet",
2097 .qdev
.size
= sizeof(EEPRO100State
),
2098 .init
= pci_i82559c_init
,
2099 .exit
= pci_nic_uninit
,
2100 .romfile
= "gpxe-eepro100-80861229.rom",
2101 .qdev
.props
= (Property
[]) {
2102 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2103 DEFINE_PROP_END_OF_LIST(),
2106 .qdev
.name
= "i82559er",
2107 .qdev
.desc
= "Intel i82559ER Ethernet",
2108 .qdev
.size
= sizeof(EEPRO100State
),
2109 .init
= pci_i82559er_init
,
2110 .exit
= pci_nic_uninit
,
2111 .romfile
= "gpxe-eepro100-80861209.rom",
2112 .qdev
.props
= (Property
[]) {
2113 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2114 DEFINE_PROP_END_OF_LIST(),
2117 .qdev
.name
= "i82562",
2118 .qdev
.desc
= "Intel i82562 Ethernet",
2119 .qdev
.size
= sizeof(EEPRO100State
),
2120 .init
= pci_i82562_init
,
2121 .exit
= pci_nic_uninit
,
2122 .romfile
= "gpxe-eepro100-80861209.rom",
2123 .qdev
.props
= (Property
[]) {
2124 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2125 DEFINE_PROP_END_OF_LIST(),
2132 static void eepro100_register_devices(void)
2134 pci_qdev_register_many(eepro100_info
);
2137 device_init(eepro100_register_devices
)