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 /* Expansion ROM Base Address (depends on boot disable!!!) */
473 /* TODO: not needed, set when BAR is registered */
474 PCI_CONFIG_32(PCI_ROM_ADDRESS
, PCI_BASE_ADDRESS_SPACE_MEMORY
);
475 /* Capability Pointer */
476 /* TODO: revisions with power_management 1 use this but
477 * do not set new capability list bit in status register. */
478 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0xdc);
481 /* TODO: RST# value should be 0 */
482 PCI_CONFIG_8(PCI_INTERRUPT_PIN
, 1); // interrupt pin 0
484 PCI_CONFIG_8(PCI_MIN_GNT
, 0x08);
485 /* Maximum Latency */
486 PCI_CONFIG_8(PCI_MAX_LAT
, 0x18);
490 // TODO: check device id.
491 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
492 /* Revision ID: 0x0c, 0x0d, 0x0e. */
493 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0e);
494 // TODO: check size of statistical counters.
496 // TODO: check extended tcb support.
497 s
->has_extended_tcb_support
= 1;
500 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
501 /* Revision ID: 0x0f, 0x10. */
502 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0f);
503 // TODO: check size of statistical counters.
505 s
->has_extended_tcb_support
= 1;
508 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
509 PCI_CONFIG_8(PCI_REVISION_ID
, 0x01);
510 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
511 power_management
= 0;
514 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
515 PCI_CONFIG_8(PCI_REVISION_ID
, 0x02);
516 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
517 power_management
= 0;
520 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
521 PCI_CONFIG_8(PCI_REVISION_ID
, 0x03);
522 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
523 power_management
= 0;
526 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
527 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
528 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
529 PCI_CONFIG_8(PCI_REVISION_ID
, 0x04);
531 s
->has_extended_tcb_support
= 1;
534 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
535 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
536 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
537 PCI_CONFIG_8(PCI_REVISION_ID
, 0x05);
539 s
->has_extended_tcb_support
= 1;
542 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
543 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
544 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
545 PCI_CONFIG_8(PCI_REVISION_ID
, 0x06);
547 s
->has_extended_tcb_support
= 1;
550 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
551 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
552 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
553 PCI_CONFIG_8(PCI_REVISION_ID
, 0x07);
555 s
->has_extended_tcb_support
= 1;
558 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
559 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
560 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
561 PCI_CONFIG_8(PCI_REVISION_ID
, 0x08);
562 // TODO: Windows wants revision id 0x0c.
563 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0c);
565 PCI_CONFIG_16(PCI_SUBSYSTEM_VENDOR_ID
, 0x8086);
566 PCI_CONFIG_16(PCI_SUBSYSTEM_ID
, 0x0040);
569 s
->has_extended_tcb_support
= 1;
572 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
573 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
574 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
575 PCI_CONFIG_8(PCI_REVISION_ID
, 0x09);
577 s
->has_extended_tcb_support
= 1;
580 // TODO: check device id.
581 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
582 /* TODO: wrong revision id. */
583 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0e);
585 s
->has_extended_tcb_support
= 1;
588 logout("Device %X is undefined!\n", device
);
591 s
->configuration
[6] |= BIT(5);
593 if (s
->stats_size
== 80) {
594 /* TODO: check TCO Statistical Counters bit. Documentation not clear. */
595 if (s
->configuration
[6] & BIT(2)) {
596 /* TCO statistical counters. */
597 assert(s
->configuration
[6] & BIT(5));
599 if (s
->configuration
[6] & BIT(5)) {
600 /* No extended statistical counters, i82557 compatible. */
603 /* i82558 compatible. */
608 if (s
->configuration
[6] & BIT(5)) {
609 /* No extended statistical counters. */
613 assert(s
->stats_size
> 0 && s
->stats_size
<= sizeof(s
->statistics
));
615 if (power_management
) {
616 /* Power Management Capabilities */
617 PCI_CONFIG_8(0xdc, 0x01);
618 /* Next Item Pointer */
620 PCI_CONFIG_16(0xde, 0x7e21);
621 /* TODO: Power Management Control / Status. */
622 /* TODO: Ethernet Power Consumption Registers (i82559 and later). */
626 if (device
== i82557C
|| device
== i82558B
|| device
== i82559C
) {
627 // TODO: get vendor id from EEPROM for i82557C or later.
628 // TODO: get device id from EEPROM for i82557C or later.
629 // TODO: status bit 4 can be disabled by EEPROM for i82558, i82559.
630 // TODO: header type is determined by EEPROM for i82559.
631 // TODO: get subsystem id from EEPROM for i82557C or later.
632 // TODO: get subsystem vendor id from EEPROM for i82557C or later.
633 // TODO: exp. rom baddr depends on a bit in EEPROM for i82558 or later.
634 // TODO: capability pointer depends on EEPROM for i82558.
635 logout("Get device id and revision from EEPROM!!!\n");
637 #endif /* EEPROM_SIZE > 0 */
640 static void nic_selective_reset(EEPRO100State
* s
)
643 uint16_t *eeprom_contents
= eeprom93xx_data(s
->eeprom
);
644 //~ eeprom93xx_reset(s->eeprom);
645 memcpy(eeprom_contents
, s
->conf
.macaddr
.a
, 6);
646 eeprom_contents
[EEPROM_ID
] = 0x4000;
647 if (s
->device
== i82557B
|| s
->device
== i82557C
)
648 eeprom_contents
[5] = 0x0100;
649 eeprom_contents
[EEPROM_PHY_ID
] = 1;
651 for (i
= 0; i
< EEPROM_SIZE
- 1; i
++) {
652 sum
+= eeprom_contents
[i
];
654 eeprom_contents
[EEPROM_SIZE
- 1] = 0xbaba - sum
;
655 TRACE(EEPROM
, logout("checksum=0x%04x\n", eeprom_contents
[EEPROM_SIZE
- 1]));
657 memset(s
->mem
, 0, sizeof(s
->mem
));
658 uint32_t val
= BIT(21);
659 memcpy(&s
->mem
[SCBCtrlMDI
], &val
, sizeof(val
));
661 assert(sizeof(s
->mdimem
) == sizeof(eepro100_mdi_default
));
662 memcpy(&s
->mdimem
[0], &eepro100_mdi_default
[0], sizeof(s
->mdimem
));
665 static void nic_reset(void *opaque
)
667 EEPRO100State
*s
= opaque
;
668 TRACE(OTHER
, logout("%p\n", s
));
669 /* TODO: Clearing of multicast table for selective reset, too? */
670 memset(&s
->mult
[0], 0, sizeof(s
->mult
));
671 nic_selective_reset(s
);
674 #if defined(DEBUG_EEPRO100)
675 static const char * const e100_reg
[PCI_IO_SIZE
/ 4] = {
679 "EEPROM/Flash Control",
681 "Receive DMA Byte Count",
683 "General Status/Control"
686 static char *regname(uint32_t addr
)
689 if (addr
< PCI_IO_SIZE
) {
690 const char *r
= e100_reg
[addr
/ 4];
692 snprintf(buf
, sizeof(buf
), "%s+%u", r
, addr
% 4);
694 snprintf(buf
, sizeof(buf
), "0x%02x", addr
);
697 snprintf(buf
, sizeof(buf
), "??? 0x%08x", addr
);
701 #endif /* DEBUG_EEPRO100 */
704 static uint16_t eepro100_read_status(EEPRO100State
* s
)
706 uint16_t val
= s
->status
;
707 TRACE(OTHER
, logout("val=0x%04x\n", val
));
711 static void eepro100_write_status(EEPRO100State
* s
, uint16_t val
)
713 TRACE(OTHER
, logout("val=0x%04x\n", val
));
718 /*****************************************************************************
722 ****************************************************************************/
725 static uint16_t eepro100_read_command(EEPRO100State
* s
)
727 uint16_t val
= 0xffff;
728 //~ TRACE(OTHER, logout("val=0x%04x\n", val));
733 /* Commands that can be put in a command list entry. */
738 CmdMulticastList
= 3,
740 CmdTDR
= 5, /* load microcode */
744 /* And some extra flags: */
745 CmdSuspend
= 0x4000, /* Suspend after completion. */
746 CmdIntr
= 0x2000, /* Interrupt after completion. */
747 CmdTxFlex
= 0x0008, /* Use "Flexible mode" for CmdTx command. */
750 static cu_state_t
get_cu_state(EEPRO100State
* s
)
752 return ((s
->mem
[SCBStatus
] & BITS(7, 6)) >> 6);
755 static void set_cu_state(EEPRO100State
* s
, cu_state_t state
)
757 s
->mem
[SCBStatus
] = (s
->mem
[SCBStatus
] & ~BITS(7, 6)) + (state
<< 6);
760 static ru_state_t
get_ru_state(EEPRO100State
* s
)
762 return ((s
->mem
[SCBStatus
] & BITS(5, 2)) >> 2);
765 static void set_ru_state(EEPRO100State
* s
, ru_state_t state
)
767 s
->mem
[SCBStatus
] = (s
->mem
[SCBStatus
] & ~BITS(5, 2)) + (state
<< 2);
770 static void dump_statistics(EEPRO100State
* s
)
772 /* Dump statistical data. Most data is never changed by the emulation
773 * and always 0, so we first just copy the whole block and then those
774 * values which really matter.
775 * Number of data should check configuration!!!
777 cpu_physical_memory_write(s
->statsaddr
,
778 (uint8_t *) & s
->statistics
, s
->stats_size
);
779 stl_le_phys(s
->statsaddr
+ 0, s
->statistics
.tx_good_frames
);
780 stl_le_phys(s
->statsaddr
+ 36, s
->statistics
.rx_good_frames
);
781 stl_le_phys(s
->statsaddr
+ 48, s
->statistics
.rx_resource_errors
);
782 stl_le_phys(s
->statsaddr
+ 60, s
->statistics
.rx_short_frame_errors
);
783 //~ stw_le_phys(s->statsaddr + 76, s->statistics.xmt_tco_frames);
784 //~ stw_le_phys(s->statsaddr + 78, s->statistics.rcv_tco_frames);
785 //~ missing("CU dump statistical counters");
788 static void tx_command(EEPRO100State
*s
)
790 uint32_t tbd_array
= le32_to_cpu(s
->tx
.tbd_array_addr
);
791 uint16_t tcb_bytes
= (le16_to_cpu(s
->tx
.tcb_bytes
) & 0x3fff);
792 /* Sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes. */
795 uint32_t tbd_address
= s
->cb_address
+ 0x10;
797 ("transmit, TBD array address 0x%08x, TCB byte count 0x%04x, TBD count %u\n",
798 tbd_array
, tcb_bytes
, s
->tx
.tbd_count
));
800 if (tcb_bytes
> 2600) {
801 logout("TCB byte count too large, using 2600\n");
804 if (!((tcb_bytes
> 0) || (tbd_array
!= 0xffffffff))) {
806 ("illegal values of TBD array address and TCB byte count!\n");
808 assert(tcb_bytes
<= sizeof(buf
));
809 while (size
< tcb_bytes
) {
810 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
811 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
812 //~ uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
815 ("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
816 tx_buffer_address
, tx_buffer_size
));
817 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
818 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
820 size
+= tx_buffer_size
;
822 if (tbd_array
== 0xffffffff) {
823 /* Simplified mode. Was already handled by code above. */
826 uint8_t tbd_count
= 0;
827 if (s
->has_extended_tcb_support
&& !(s
->configuration
[6] & BIT(4))) {
828 /* Extended Flexible TCB. */
829 for (; tbd_count
< 2; tbd_count
++) {
830 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
831 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
832 uint16_t tx_buffer_el
= lduw_phys(tbd_address
+ 6);
835 ("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n",
836 tx_buffer_address
, tx_buffer_size
));
837 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
838 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
840 size
+= tx_buffer_size
;
841 if (tx_buffer_el
& 1) {
846 tbd_address
= tbd_array
;
847 for (; tbd_count
< s
->tx
.tbd_count
; 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 (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 TRACE(RXTX
, logout("%p sending frame, len=%d,%s\n", s
, size
, nic_dump(buf
, size
)));
865 qemu_send_packet(&s
->nic
->nc
, buf
, size
);
866 s
->statistics
.tx_good_frames
++;
867 /* Transmit with bad status would raise an CX/TNO interrupt.
868 * (82557 only). Emulation never has bad status. */
869 //~ eepro100_cx_interrupt(s);
872 static void set_multicast_list(EEPRO100State
*s
)
874 uint16_t multicast_count
= s
->tx
.tbd_array_addr
& BITS(13, 0);
876 memset(&s
->mult
[0], 0, sizeof(s
->mult
));
877 TRACE(OTHER
, logout("multicast list, multicast count = %u\n", multicast_count
));
878 for (i
= 0; i
< multicast_count
; i
+= 6) {
879 uint8_t multicast_addr
[6];
880 cpu_physical_memory_read(s
->cb_address
+ 10 + i
, multicast_addr
, 6);
881 TRACE(OTHER
, logout("multicast entry %s\n", nic_dump(multicast_addr
, 6)));
882 unsigned mcast_idx
= compute_mcast_idx(multicast_addr
);
883 assert(mcast_idx
< 64);
884 s
->mult
[mcast_idx
>> 3] |= (1 << (mcast_idx
& 7));
888 static void action_command(EEPRO100State
*s
)
891 s
->cb_address
= s
->cu_base
+ s
->cu_offset
;
892 cpu_physical_memory_read(s
->cb_address
, (uint8_t *)&s
->tx
, sizeof(s
->tx
));
893 uint16_t status
= le16_to_cpu(s
->tx
.status
);
894 uint16_t command
= le16_to_cpu(s
->tx
.command
);
895 logout("val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n",
896 status
, command
, s
->tx
.link
);
897 bool bit_el
= ((command
& COMMAND_EL
) != 0);
898 bool bit_s
= ((command
& COMMAND_S
) != 0);
899 bool bit_i
= ((command
& COMMAND_I
) != 0);
900 bool bit_nc
= ((command
& COMMAND_NC
) != 0);
902 //~ bool bit_sf = ((command & COMMAND_SF) != 0);
903 uint16_t cmd
= command
& COMMAND_CMD
;
904 s
->cu_offset
= le32_to_cpu(s
->tx
.link
);
910 cpu_physical_memory_read(s
->cb_address
+ 8, &s
->conf
.macaddr
.a
[0], 6);
911 TRACE(OTHER
, logout("macaddr: %s\n", nic_dump(&s
->conf
.macaddr
.a
[0], 6)));
914 cpu_physical_memory_read(s
->cb_address
+ 8, &s
->configuration
[0],
915 sizeof(s
->configuration
));
916 TRACE(OTHER
, logout("configuration: %s\n", nic_dump(&s
->configuration
[0], 16)));
918 case CmdMulticastList
:
919 set_multicast_list(s
);
923 missing("CmdTx: NC = 0");
930 TRACE(OTHER
, logout("load microcode\n"));
931 /* Starting with offset 8, the command contains
932 * 64 dwords microcode which we just ignore here. */
935 missing("undefined command");
939 /* Write new status. */
940 stw_phys(s
->cb_address
, status
| STATUS_C
| (success
? STATUS_OK
: 0));
942 /* CU completed action. */
943 eepro100_cx_interrupt(s
);
946 /* CU becomes idle. Terminate command loop. */
947 set_cu_state(s
, cu_idle
);
948 eepro100_cna_interrupt(s
);
951 /* CU becomes suspended. Terminate command loop. */
952 set_cu_state(s
, cu_suspended
);
953 eepro100_cna_interrupt(s
);
956 /* More entries in list. */
957 TRACE(OTHER
, logout("CU list with at least one more entry\n"));
960 TRACE(OTHER
, logout("CU list empty\n"));
961 /* List is empty. Now CU is idle or suspended. */
964 static void eepro100_cu_command(EEPRO100State
* s
, uint8_t val
)
971 if (get_cu_state(s
) != cu_idle
) {
972 /* Intel documentation says that CU must be idle for the CU
973 * start command. Intel driver for Linux also starts the CU
974 * from suspended state. */
975 logout("CU state is %u, should be %u\n", get_cu_state(s
), cu_idle
);
976 //~ assert(!"wrong CU state");
978 set_cu_state(s
, cu_active
);
979 s
->cu_offset
= s
->pointer
;
983 if (get_cu_state(s
) != cu_suspended
) {
984 logout("bad CU resume from CU state %u\n", get_cu_state(s
));
985 /* Workaround for bad Linux eepro100 driver which resumes
986 * from idle state. */
987 //~ missing("cu resume");
988 set_cu_state(s
, cu_suspended
);
990 if (get_cu_state(s
) == cu_suspended
) {
991 TRACE(OTHER
, logout("CU resuming\n"));
992 set_cu_state(s
, cu_active
);
997 /* Load dump counters address. */
998 s
->statsaddr
= s
->pointer
;
999 TRACE(OTHER
, logout("val=0x%02x (status address)\n", val
));
1002 /* Dump statistical counters. */
1003 TRACE(OTHER
, logout("val=0x%02x (dump stats)\n", val
));
1005 stl_le_phys(s
->statsaddr
+ s
->stats_size
, 0xa005);
1009 TRACE(OTHER
, logout("val=0x%02x (CU base address)\n", val
));
1010 s
->cu_base
= s
->pointer
;
1013 /* Dump and reset statistical counters. */
1014 TRACE(OTHER
, logout("val=0x%02x (dump stats and reset)\n", val
));
1016 stl_le_phys(s
->statsaddr
+ s
->stats_size
, 0xa007);
1017 memset(&s
->statistics
, 0, sizeof(s
->statistics
));
1020 /* CU static resume. */
1021 missing("CU static resume");
1024 missing("Undefined CU command");
1028 static void eepro100_ru_command(EEPRO100State
* s
, uint8_t val
)
1036 if (get_ru_state(s
) != ru_idle
) {
1037 logout("RU state is %u, should be %u\n", get_ru_state(s
), ru_idle
);
1038 //~ assert(!"wrong RU state");
1040 set_ru_state(s
, ru_ready
);
1041 s
->ru_offset
= s
->pointer
;
1042 TRACE(OTHER
, logout("val=0x%02x (rx start)\n", val
));
1046 if (get_ru_state(s
) != ru_suspended
) {
1047 logout("RU state is %u, should be %u\n", get_ru_state(s
),
1049 //~ assert(!"wrong RU state");
1051 set_ru_state(s
, ru_ready
);
1055 TRACE(OTHER
, logout("val=0x%02x (RU base address)\n", val
));
1056 s
->ru_base
= s
->pointer
;
1059 logout("val=0x%02x (undefined RU command)\n", val
);
1060 missing("Undefined SU command");
1064 static void eepro100_write_command(EEPRO100State
* s
, uint8_t val
)
1066 eepro100_ru_command(s
, val
& 0x0f);
1067 eepro100_cu_command(s
, val
& 0xf0);
1069 TRACE(OTHER
, logout("val=0x%02x\n", val
));
1071 /* Clear command byte after command was accepted. */
1075 /*****************************************************************************
1079 ****************************************************************************/
1081 #define EEPROM_CS 0x02
1082 #define EEPROM_SK 0x01
1083 #define EEPROM_DI 0x04
1084 #define EEPROM_DO 0x08
1086 static uint16_t eepro100_read_eeprom(EEPRO100State
* s
)
1089 memcpy(&val
, &s
->mem
[SCBeeprom
], sizeof(val
));
1090 if (eeprom93xx_read(s
->eeprom
)) {
1095 TRACE(EEPROM
, logout("val=0x%04x\n", val
));
1099 static void eepro100_write_eeprom(eeprom_t
* eeprom
, uint8_t val
)
1101 TRACE(EEPROM
, logout("val=0x%02x\n", val
));
1103 /* mask unwriteable bits */
1104 //~ val = SET_MASKED(val, 0x31, eeprom->value);
1106 int eecs
= ((val
& EEPROM_CS
) != 0);
1107 int eesk
= ((val
& EEPROM_SK
) != 0);
1108 int eedi
= ((val
& EEPROM_DI
) != 0);
1109 eeprom93xx_write(eeprom
, eecs
, eesk
, eedi
);
1112 static void eepro100_write_pointer(EEPRO100State
* s
, uint32_t val
)
1114 s
->pointer
= le32_to_cpu(val
);
1115 TRACE(OTHER
, logout("val=0x%08x\n", val
));
1118 /*****************************************************************************
1122 ****************************************************************************/
1124 #if defined(DEBUG_EEPRO100)
1125 static const char * const mdi_op_name
[] = {
1132 static const char * const mdi_reg_name
[] = {
1135 "PHY Identification (Word 1)",
1136 "PHY Identification (Word 2)",
1137 "Auto-Negotiation Advertisement",
1138 "Auto-Negotiation Link Partner Ability",
1139 "Auto-Negotiation Expansion"
1142 static const char *reg2name(uint8_t reg
)
1144 static char buffer
[10];
1145 const char *p
= buffer
;
1146 if (reg
< ARRAY_SIZE(mdi_reg_name
)) {
1147 p
= mdi_reg_name
[reg
];
1149 snprintf(buffer
, sizeof(buffer
), "reg=0x%02x", reg
);
1153 #endif /* DEBUG_EEPRO100 */
1155 static uint32_t eepro100_read_mdi(EEPRO100State
* s
)
1158 memcpy(&val
, &s
->mem
[0x10], sizeof(val
));
1160 #ifdef DEBUG_EEPRO100
1161 uint8_t raiseint
= (val
& BIT(29)) >> 29;
1162 uint8_t opcode
= (val
& BITS(27, 26)) >> 26;
1163 uint8_t phy
= (val
& BITS(25, 21)) >> 21;
1164 uint8_t reg
= (val
& BITS(20, 16)) >> 16;
1165 uint16_t data
= (val
& BITS(15, 0));
1167 /* Emulation takes no time to finish MDI transaction. */
1169 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1170 val
, raiseint
, mdi_op_name
[opcode
], phy
,
1171 reg2name(reg
), data
));
1175 static void eepro100_write_mdi(EEPRO100State
* s
, uint32_t val
)
1177 uint8_t raiseint
= (val
& BIT(29)) >> 29;
1178 uint8_t opcode
= (val
& BITS(27, 26)) >> 26;
1179 uint8_t phy
= (val
& BITS(25, 21)) >> 21;
1180 uint8_t reg
= (val
& BITS(20, 16)) >> 16;
1181 uint16_t data
= (val
& BITS(15, 0));
1182 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1183 val
, raiseint
, mdi_op_name
[opcode
], phy
, reg2name(reg
), data
));
1185 /* Unsupported PHY address. */
1186 //~ logout("phy must be 1 but is %u\n", phy);
1188 } else if (opcode
!= 1 && opcode
!= 2) {
1189 /* Unsupported opcode. */
1190 logout("opcode must be 1 or 2 but is %u\n", opcode
);
1192 } else if (reg
> 6) {
1193 /* Unsupported register. */
1194 logout("register must be 0...6 but is %u\n", reg
);
1197 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1198 val
, raiseint
, mdi_op_name
[opcode
], phy
,
1199 reg2name(reg
), data
));
1203 case 0: /* Control Register */
1204 if (data
& 0x8000) {
1205 /* Reset status and control registers to default. */
1206 s
->mdimem
[0] = eepro100_mdi_default
[0];
1207 s
->mdimem
[1] = eepro100_mdi_default
[1];
1208 data
= s
->mdimem
[reg
];
1210 /* Restart Auto Configuration = Normal Operation */
1214 case 1: /* Status Register */
1215 missing("not writable");
1216 data
= s
->mdimem
[reg
];
1218 case 2: /* PHY Identification Register (Word 1) */
1219 case 3: /* PHY Identification Register (Word 2) */
1220 missing("not implemented");
1222 case 4: /* Auto-Negotiation Advertisement Register */
1223 case 5: /* Auto-Negotiation Link Partner Ability Register */
1225 case 6: /* Auto-Negotiation Expansion Register */
1227 missing("not implemented");
1229 s
->mdimem
[reg
] = data
;
1230 } else if (opcode
== 2) {
1233 case 0: /* Control Register */
1234 if (data
& 0x8000) {
1235 /* Reset status and control registers to default. */
1236 s
->mdimem
[0] = eepro100_mdi_default
[0];
1237 s
->mdimem
[1] = eepro100_mdi_default
[1];
1240 case 1: /* Status Register */
1241 s
->mdimem
[reg
] |= 0x0020;
1243 case 2: /* PHY Identification Register (Word 1) */
1244 case 3: /* PHY Identification Register (Word 2) */
1245 case 4: /* Auto-Negotiation Advertisement Register */
1247 case 5: /* Auto-Negotiation Link Partner Ability Register */
1248 s
->mdimem
[reg
] = 0x41fe;
1250 case 6: /* Auto-Negotiation Expansion Register */
1251 s
->mdimem
[reg
] = 0x0001;
1254 data
= s
->mdimem
[reg
];
1256 /* Emulation takes no time to finish MDI transaction.
1257 * Set MDI bit in SCB status register. */
1258 s
->mem
[SCBAck
] |= 0x08;
1261 eepro100_mdi_interrupt(s
);
1264 val
= (val
& 0xffff0000) + data
;
1265 memcpy(&s
->mem
[0x10], &val
, sizeof(val
));
1268 /*****************************************************************************
1272 ****************************************************************************/
1274 #define PORT_SOFTWARE_RESET 0
1275 #define PORT_SELFTEST 1
1276 #define PORT_SELECTIVE_RESET 2
1278 #define PORT_SELECTION_MASK 3
1281 uint32_t st_sign
; /* Self Test Signature */
1282 uint32_t st_result
; /* Self Test Results */
1283 } eepro100_selftest_t
;
1285 static uint32_t eepro100_read_port(EEPRO100State
* s
)
1290 static void eepro100_write_port(EEPRO100State
* s
, uint32_t val
)
1292 val
= le32_to_cpu(val
);
1293 uint32_t address
= (val
& ~PORT_SELECTION_MASK
);
1294 uint8_t selection
= (val
& PORT_SELECTION_MASK
);
1295 switch (selection
) {
1296 case PORT_SOFTWARE_RESET
:
1300 TRACE(OTHER
, logout("selftest address=0x%08x\n", address
));
1301 eepro100_selftest_t data
;
1302 cpu_physical_memory_read(address
, (uint8_t *) & data
, sizeof(data
));
1303 data
.st_sign
= 0xffffffff;
1305 cpu_physical_memory_write(address
, (uint8_t *) & data
, sizeof(data
));
1307 case PORT_SELECTIVE_RESET
:
1308 TRACE(OTHER
, logout("selective reset, selftest address=0x%08x\n", address
));
1309 nic_selective_reset(s
);
1312 logout("val=0x%08x\n", val
);
1313 missing("unknown port selection");
1317 /*****************************************************************************
1319 * General hardware emulation.
1321 ****************************************************************************/
1323 static uint8_t eepro100_read1(EEPRO100State
* s
, uint32_t addr
)
1326 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1327 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1332 //~ val = eepro100_read_status(s);
1333 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1336 //~ val = eepro100_read_status(s);
1337 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1340 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1341 //~ val = eepro100_read_command(s);
1344 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1347 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1350 val
= eepro100_read_eeprom(s
);
1352 case SCBpmdr
: /* Power Management Driver Register */
1354 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1356 case SCBgstat
: /* General Status Register */
1357 /* 100 Mbps full duplex, valid link */
1359 TRACE(OTHER
, logout("addr=General Status val=%02x\n", val
));
1362 logout("addr=%s val=0x%02x\n", regname(addr
), val
);
1363 missing("unknown byte read");
1368 static uint16_t eepro100_read2(EEPRO100State
* s
, uint32_t addr
)
1371 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1372 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1377 //~ val = eepro100_read_status(s);
1379 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1382 val
= eepro100_read_eeprom(s
);
1383 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1386 logout("addr=%s val=0x%04x\n", regname(addr
), val
);
1387 missing("unknown word read");
1392 static uint32_t eepro100_read4(EEPRO100State
* s
, uint32_t addr
)
1395 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1396 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1401 //~ val = eepro100_read_status(s);
1402 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1405 //~ val = eepro100_read_pointer(s);
1406 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1409 val
= eepro100_read_port(s
);
1410 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1413 val
= eepro100_read_mdi(s
);
1416 logout("addr=%s val=0x%08x\n", regname(addr
), val
);
1417 missing("unknown longword read");
1422 static void eepro100_write1(EEPRO100State
* s
, uint32_t addr
, uint8_t val
)
1424 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1425 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1428 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1432 //~ eepro100_write_status(s, val);
1435 eepro100_acknowledge(s
);
1438 eepro100_write_command(s
, val
);
1442 eepro100_swi_interrupt(s
);
1444 eepro100_interrupt(s
, 0);
1447 case SCBFlow
: /* does not exist on 82557 */
1450 case SCBpmdr
: /* does not exist on 82557 */
1451 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1454 eepro100_write_eeprom(s
->eeprom
, val
);
1457 logout("addr=%s val=0x%02x\n", regname(addr
), val
);
1458 missing("unknown byte write");
1462 static void eepro100_write2(EEPRO100State
* s
, uint32_t addr
, uint16_t val
)
1464 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1465 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1468 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1472 //~ eepro100_write_status(s, val);
1473 eepro100_acknowledge(s
);
1476 eepro100_write_command(s
, val
);
1477 eepro100_write1(s
, SCBIntmask
, val
>> 8);
1480 eepro100_write_eeprom(s
->eeprom
, val
);
1483 logout("addr=%s val=0x%04x\n", regname(addr
), val
);
1484 missing("unknown word write");
1488 static void eepro100_write4(EEPRO100State
* s
, uint32_t addr
, uint32_t val
)
1490 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1491 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1496 eepro100_write_pointer(s
, val
);
1499 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1500 eepro100_write_port(s
, val
);
1503 eepro100_write_mdi(s
, val
);
1506 logout("addr=%s val=0x%08x\n", regname(addr
), val
);
1507 missing("unknown longword write");
1511 /*****************************************************************************
1515 ****************************************************************************/
1517 static uint32_t ioport_read1(void *opaque
, uint32_t addr
)
1519 EEPRO100State
*s
= opaque
;
1520 //~ logout("addr=%s\n", regname(addr));
1521 return eepro100_read1(s
, addr
- s
->region
[1]);
1524 static uint32_t ioport_read2(void *opaque
, uint32_t addr
)
1526 EEPRO100State
*s
= opaque
;
1527 return eepro100_read2(s
, addr
- s
->region
[1]);
1530 static uint32_t ioport_read4(void *opaque
, uint32_t addr
)
1532 EEPRO100State
*s
= opaque
;
1533 return eepro100_read4(s
, addr
- s
->region
[1]);
1536 static void ioport_write1(void *opaque
, uint32_t addr
, uint32_t val
)
1538 EEPRO100State
*s
= opaque
;
1539 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1540 eepro100_write1(s
, addr
- s
->region
[1], val
);
1543 static void ioport_write2(void *opaque
, uint32_t addr
, uint32_t val
)
1545 EEPRO100State
*s
= opaque
;
1546 eepro100_write2(s
, addr
- s
->region
[1], val
);
1549 static void ioport_write4(void *opaque
, uint32_t addr
, uint32_t val
)
1551 EEPRO100State
*s
= opaque
;
1552 eepro100_write4(s
, addr
- s
->region
[1], val
);
1555 /***********************************************************/
1556 /* PCI EEPRO100 definitions */
1558 static void pci_map(PCIDevice
* pci_dev
, int region_num
,
1559 pcibus_t addr
, pcibus_t size
, int type
)
1561 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1563 TRACE(OTHER
, logout("region %d, addr=0x%08"FMT_PCIBUS
", "
1564 "size=0x%08"FMT_PCIBUS
", type=%d\n",
1565 region_num
, addr
, size
, type
));
1567 assert(region_num
== 1);
1568 register_ioport_write(addr
, size
, 1, ioport_write1
, s
);
1569 register_ioport_read(addr
, size
, 1, ioport_read1
, s
);
1570 register_ioport_write(addr
, size
, 2, ioport_write2
, s
);
1571 register_ioport_read(addr
, size
, 2, ioport_read2
, s
);
1572 register_ioport_write(addr
, size
, 4, ioport_write4
, s
);
1573 register_ioport_read(addr
, size
, 4, ioport_read4
, s
);
1575 s
->region
[region_num
] = addr
;
1578 /*****************************************************************************
1580 * Memory mapped I/O.
1582 ****************************************************************************/
1584 static void pci_mmio_writeb(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1586 EEPRO100State
*s
= opaque
;
1587 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1588 eepro100_write1(s
, addr
, val
);
1591 static void pci_mmio_writew(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1593 EEPRO100State
*s
= opaque
;
1594 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1595 eepro100_write2(s
, addr
, val
);
1598 static void pci_mmio_writel(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1600 EEPRO100State
*s
= opaque
;
1601 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1602 eepro100_write4(s
, addr
, val
);
1605 static uint32_t pci_mmio_readb(void *opaque
, target_phys_addr_t addr
)
1607 EEPRO100State
*s
= opaque
;
1608 //~ logout("addr=%s\n", regname(addr));
1609 return eepro100_read1(s
, addr
);
1612 static uint32_t pci_mmio_readw(void *opaque
, target_phys_addr_t addr
)
1614 EEPRO100State
*s
= opaque
;
1615 //~ logout("addr=%s\n", regname(addr));
1616 return eepro100_read2(s
, addr
);
1619 static uint32_t pci_mmio_readl(void *opaque
, target_phys_addr_t addr
)
1621 EEPRO100State
*s
= opaque
;
1622 //~ logout("addr=%s\n", regname(addr));
1623 return eepro100_read4(s
, addr
);
1626 static CPUWriteMemoryFunc
* const pci_mmio_write
[] = {
1632 static CPUReadMemoryFunc
* const pci_mmio_read
[] = {
1638 static void pci_mmio_map(PCIDevice
* pci_dev
, int region_num
,
1639 pcibus_t addr
, pcibus_t size
, int type
)
1641 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1643 TRACE(OTHER
, logout("region %d, addr=0x%08"FMT_PCIBUS
", "
1644 "size=0x%08"FMT_PCIBUS
", type=%d\n",
1645 region_num
, addr
, size
, type
));
1647 if (region_num
== 0) {
1648 /* Map control / status registers. */
1649 cpu_register_physical_memory(addr
, size
, s
->mmio_index
);
1650 s
->region
[region_num
] = addr
;
1654 static int nic_can_receive(VLANClientState
*nc
)
1656 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1657 TRACE(RXTX
, logout("%p\n", s
));
1658 return get_ru_state(s
) == ru_ready
;
1659 //~ return !eepro100_buffer_full(s);
1662 static ssize_t
nic_receive(VLANClientState
*nc
, const uint8_t * buf
, size_t size
)
1665 * - Magic packets should set bit 30 in power management driver register.
1666 * - Interesting packets should set bit 29 in power management driver register.
1668 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1669 uint16_t rfd_status
= 0xa000;
1670 static const uint8_t broadcast_macaddr
[6] =
1671 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1673 /* TODO: check multiple IA bit. */
1674 if (s
->configuration
[20] & BIT(6)) {
1675 missing("Multiple IA bit");
1679 if (s
->configuration
[8] & 0x80) {
1680 /* CSMA is disabled. */
1681 logout("%p received while CSMA is disabled\n", s
);
1683 } else if (size
< 64 && (s
->configuration
[7] & BIT(0))) {
1684 /* Short frame and configuration byte 7/0 (discard short receive) set:
1685 * Short frame is discarded */
1686 logout("%p received short frame (%zu byte)\n", s
, size
);
1687 s
->statistics
.rx_short_frame_errors
++;
1689 } else if ((size
> MAX_ETH_FRAME_SIZE
+ 4) && !(s
->configuration
[18] & BIT(3))) {
1690 /* Long frame and configuration byte 18/3 (long receive ok) not set:
1691 * Long frames are discarded. */
1692 logout("%p received long frame (%zu byte), ignored\n", s
, size
);
1694 } else if (memcmp(buf
, s
->conf
.macaddr
.a
, 6) == 0) { // !!!
1695 /* Frame matches individual address. */
1696 /* TODO: check configuration byte 15/4 (ignore U/L). */
1697 TRACE(RXTX
, logout("%p received frame for me, len=%zu\n", s
, size
));
1698 } else if (memcmp(buf
, broadcast_macaddr
, 6) == 0) {
1699 /* Broadcast frame. */
1700 TRACE(RXTX
, logout("%p received broadcast, len=%zu\n", s
, size
));
1701 rfd_status
|= 0x0002;
1702 } else if (buf
[0] & 0x01) {
1703 /* Multicast frame. */
1704 TRACE(RXTX
, logout("%p received multicast, len=%zu,%s\n", s
, size
, nic_dump(buf
, size
)));
1705 if (s
->configuration
[21] & BIT(3)) {
1706 /* Multicast all bit is set, receive all multicast frames. */
1708 unsigned mcast_idx
= compute_mcast_idx(buf
);
1709 assert(mcast_idx
< 64);
1710 if (s
->mult
[mcast_idx
>> 3] & (1 << (mcast_idx
& 7))) {
1711 /* Multicast frame is allowed in hash table. */
1712 } else if (s
->configuration
[15] & BIT(0)) {
1713 /* Promiscuous: receive all. */
1714 rfd_status
|= 0x0004;
1716 TRACE(RXTX
, logout("%p multicast ignored\n", s
));
1720 /* TODO: Next not for promiscuous mode? */
1721 rfd_status
|= 0x0002;
1722 } else if (s
->configuration
[15] & BIT(0)) {
1723 /* Promiscuous: receive all. */
1724 TRACE(RXTX
, logout("%p received frame in promiscuous mode, len=%zu\n", s
, size
));
1725 rfd_status
|= 0x0004;
1727 TRACE(RXTX
, logout("%p received frame, ignored, len=%zu,%s\n", s
, size
,
1728 nic_dump(buf
, size
)));
1732 if (get_ru_state(s
) != ru_ready
) {
1733 /* No resources available. */
1734 logout("no resources, state=%u\n", get_ru_state(s
));
1735 s
->statistics
.rx_resource_errors
++;
1736 //~ assert(!"no resources");
1740 //~ $3 = {status = 0x0, command = 0xc000, link = 0x2d220, rx_buf_addr = 0x207dc, count = 0x0, size = 0x5f8, packet = {0x0 <repeats 1518 times>}}
1742 cpu_physical_memory_read(s
->ru_base
+ s
->ru_offset
, (uint8_t *) & rx
,
1743 offsetof(eepro100_rx_t
, packet
));
1744 uint16_t rfd_command
= le16_to_cpu(rx
.command
);
1745 uint16_t rfd_size
= le16_to_cpu(rx
.size
);
1747 if (size
> rfd_size
) {
1748 logout("Receive buffer (%" PRId16
" bytes) too small for data "
1749 "(%zu bytes); data truncated\n", rfd_size
, size
);
1753 rfd_status
|= 0x0080;
1755 TRACE(OTHER
, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
1756 rfd_command
, rx
.link
, rx
.rx_buf_addr
, rfd_size
));
1757 stw_phys(s
->ru_base
+ s
->ru_offset
+ offsetof(eepro100_rx_t
, status
),
1759 stw_phys(s
->ru_base
+ s
->ru_offset
+ offsetof(eepro100_rx_t
, count
), size
);
1760 /* Early receive interrupt not supported. */
1761 //~ eepro100_er_interrupt(s);
1762 /* Receive CRC Transfer not supported. */
1763 if (s
->configuration
[18] & BIT(2)) {
1764 missing("Receive CRC Transfer");
1767 /* TODO: check stripping enable bit. */
1768 //~ assert(!(s->configuration[17] & BIT(0)));
1769 cpu_physical_memory_write(s
->ru_base
+ s
->ru_offset
+
1770 offsetof(eepro100_rx_t
, packet
), buf
, size
);
1771 s
->statistics
.rx_good_frames
++;
1772 eepro100_fr_interrupt(s
);
1773 s
->ru_offset
= le32_to_cpu(rx
.link
);
1774 if (rfd_command
& COMMAND_EL
) {
1775 /* EL bit is set, so this was the last frame. */
1776 logout("receive: Running out of frames\n");
1777 set_ru_state(s
, ru_suspended
);
1779 if (rfd_command
& COMMAND_S
) {
1781 set_ru_state(s
, ru_suspended
);
1786 static const VMStateDescription vmstate_eepro100
= {
1788 .minimum_version_id
= 2,
1789 .minimum_version_id_old
= 2,
1790 .fields
= (VMStateField
[]) {
1791 VMSTATE_PCI_DEVICE(dev
, EEPRO100State
),
1793 VMSTATE_BUFFER(mult
, EEPRO100State
),
1794 VMSTATE_BUFFER(mem
, EEPRO100State
),
1795 /* Save all members of struct between scb_stat and mem. */
1796 VMSTATE_UINT8(scb_stat
, EEPRO100State
),
1797 VMSTATE_UINT8(int_stat
, EEPRO100State
),
1798 VMSTATE_UNUSED(3*4),
1799 VMSTATE_MACADDR(conf
.macaddr
, EEPRO100State
),
1800 VMSTATE_UNUSED(19*4),
1801 VMSTATE_UINT16_ARRAY(mdimem
, EEPRO100State
, 32),
1802 /* The eeprom should be saved and restored by its own routines. */
1803 VMSTATE_UINT32(device
, EEPRO100State
),
1804 /* TODO check device. */
1805 VMSTATE_UINT32(pointer
, EEPRO100State
),
1806 VMSTATE_UINT32(cu_base
, EEPRO100State
),
1807 VMSTATE_UINT32(cu_offset
, EEPRO100State
),
1808 VMSTATE_UINT32(ru_base
, EEPRO100State
),
1809 VMSTATE_UINT32(ru_offset
, EEPRO100State
),
1810 VMSTATE_UINT32(statsaddr
, EEPRO100State
),
1811 /* Save eepro100_stats_t statistics. */
1812 VMSTATE_UINT32(statistics
.tx_good_frames
, EEPRO100State
),
1813 VMSTATE_UINT32(statistics
.tx_max_collisions
, EEPRO100State
),
1814 VMSTATE_UINT32(statistics
.tx_late_collisions
, EEPRO100State
),
1815 VMSTATE_UINT32(statistics
.tx_underruns
, EEPRO100State
),
1816 VMSTATE_UINT32(statistics
.tx_lost_crs
, EEPRO100State
),
1817 VMSTATE_UINT32(statistics
.tx_deferred
, EEPRO100State
),
1818 VMSTATE_UINT32(statistics
.tx_single_collisions
, EEPRO100State
),
1819 VMSTATE_UINT32(statistics
.tx_multiple_collisions
, EEPRO100State
),
1820 VMSTATE_UINT32(statistics
.tx_total_collisions
, EEPRO100State
),
1821 VMSTATE_UINT32(statistics
.rx_good_frames
, EEPRO100State
),
1822 VMSTATE_UINT32(statistics
.rx_crc_errors
, EEPRO100State
),
1823 VMSTATE_UINT32(statistics
.rx_alignment_errors
, EEPRO100State
),
1824 VMSTATE_UINT32(statistics
.rx_resource_errors
, EEPRO100State
),
1825 VMSTATE_UINT32(statistics
.rx_overrun_errors
, EEPRO100State
),
1826 VMSTATE_UINT32(statistics
.rx_cdt_errors
, EEPRO100State
),
1827 VMSTATE_UINT32(statistics
.rx_short_frame_errors
, EEPRO100State
),
1828 VMSTATE_UINT32(statistics
.fc_xmt_pause
, EEPRO100State
),
1829 VMSTATE_UINT32(statistics
.fc_rcv_pause
, EEPRO100State
),
1830 VMSTATE_UINT32(statistics
.fc_rcv_unsupported
, EEPRO100State
),
1831 VMSTATE_UINT16(statistics
.xmt_tco_frames
, EEPRO100State
),
1832 VMSTATE_UINT16(statistics
.rcv_tco_frames
, EEPRO100State
),
1834 VMSTATE_UINT16(status
, EEPRO100State
),
1836 /* Configuration bytes. */
1837 VMSTATE_BUFFER(configuration
, EEPRO100State
),
1838 VMSTATE_END_OF_LIST()
1842 static void nic_cleanup(VLANClientState
*nc
)
1844 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1849 static int pci_nic_uninit(PCIDevice
*pci_dev
)
1851 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1853 cpu_unregister_io_memory(s
->mmio_index
);
1854 vmstate_unregister(s
->vmstate
, s
);
1855 eeprom93xx_free(s
->eeprom
);
1856 qemu_del_vlan_client(&s
->nic
->nc
);
1860 static NetClientInfo net_eepro100_info
= {
1861 .type
= NET_CLIENT_TYPE_NIC
,
1862 .size
= sizeof(NICState
),
1863 .can_receive
= nic_can_receive
,
1864 .receive
= nic_receive
,
1865 .cleanup
= nic_cleanup
,
1868 static int nic_init(PCIDevice
*pci_dev
, uint32_t device
)
1870 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1872 TRACE(OTHER
, logout("\n"));
1878 /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
1879 * i82559 and later support 64 or 256 word EEPROM. */
1880 s
->eeprom
= eeprom93xx_new(EEPROM_SIZE
);
1882 /* Handler for memory-mapped I/O */
1884 cpu_register_io_memory(pci_mmio_read
, pci_mmio_write
, s
);
1886 pci_register_bar(&s
->dev
, 0, PCI_MEM_SIZE
,
1887 PCI_BASE_ADDRESS_SPACE_MEMORY
|
1888 PCI_BASE_ADDRESS_MEM_PREFETCH
, pci_mmio_map
);
1889 pci_register_bar(&s
->dev
, 1, PCI_IO_SIZE
, PCI_BASE_ADDRESS_SPACE_IO
,
1891 pci_register_bar(&s
->dev
, 2, PCI_FLASH_SIZE
, PCI_BASE_ADDRESS_SPACE_MEMORY
,
1894 qemu_macaddr_default_if_unset(&s
->conf
.macaddr
);
1895 logout("macaddr: %s\n", nic_dump(&s
->conf
.macaddr
.a
[0], 6));
1896 assert(s
->region
[1] == 0);
1900 s
->nic
= qemu_new_nic(&net_eepro100_info
, &s
->conf
,
1901 pci_dev
->qdev
.info
->name
, pci_dev
->qdev
.id
, s
);
1903 qemu_format_nic_info_str(&s
->nic
->nc
, s
->conf
.macaddr
.a
);
1904 TRACE(OTHER
, logout("%s\n", s
->nic
->nc
.info_str
));
1906 qemu_register_reset(nic_reset
, s
);
1908 s
->vmstate
= qemu_malloc(sizeof(vmstate_eepro100
));
1909 memcpy(s
->vmstate
, &vmstate_eepro100
, sizeof(vmstate_eepro100
));
1910 s
->vmstate
->name
= s
->nic
->nc
.model
;
1911 vmstate_register(-1, s
->vmstate
, s
);
1916 static int pci_i82550_init(PCIDevice
*pci_dev
)
1918 return nic_init(pci_dev
, i82550
);
1921 static int pci_i82551_init(PCIDevice
*pci_dev
)
1923 return nic_init(pci_dev
, i82551
);
1926 static int pci_i82557a_init(PCIDevice
*pci_dev
)
1928 return nic_init(pci_dev
, i82557A
);
1931 static int pci_i82557b_init(PCIDevice
*pci_dev
)
1933 return nic_init(pci_dev
, i82557B
);
1936 static int pci_i82557c_init(PCIDevice
*pci_dev
)
1938 return nic_init(pci_dev
, i82557C
);
1941 static int pci_i82558a_init(PCIDevice
*pci_dev
)
1943 return nic_init(pci_dev
, i82558A
);
1946 static int pci_i82558b_init(PCIDevice
*pci_dev
)
1948 return nic_init(pci_dev
, i82558B
);
1951 static int pci_i82559a_init(PCIDevice
*pci_dev
)
1953 return nic_init(pci_dev
, i82559A
);
1956 static int pci_i82559b_init(PCIDevice
*pci_dev
)
1958 return nic_init(pci_dev
, i82559B
);
1961 static int pci_i82559c_init(PCIDevice
*pci_dev
)
1963 return nic_init(pci_dev
, i82559C
);
1966 static int pci_i82559er_init(PCIDevice
*pci_dev
)
1968 return nic_init(pci_dev
, i82559ER
);
1971 static int pci_i82562_init(PCIDevice
*pci_dev
)
1973 return nic_init(pci_dev
, i82562
);
1976 static PCIDeviceInfo eepro100_info
[] = {
1978 .qdev
.name
= "i82550",
1979 .qdev
.desc
= "Intel i82550 Ethernet",
1980 .qdev
.size
= sizeof(EEPRO100State
),
1981 .init
= pci_i82550_init
,
1982 .exit
= pci_nic_uninit
,
1983 .romfile
= "gpxe-eepro100-80861209.rom",
1984 .qdev
.props
= (Property
[]) {
1985 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1986 DEFINE_PROP_END_OF_LIST(),
1989 .qdev
.name
= "i82551",
1990 .qdev
.desc
= "Intel i82551 Ethernet",
1991 .qdev
.size
= sizeof(EEPRO100State
),
1992 .init
= pci_i82551_init
,
1993 .exit
= pci_nic_uninit
,
1994 .romfile
= "gpxe-eepro100-80861209.rom",
1995 .qdev
.props
= (Property
[]) {
1996 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1997 DEFINE_PROP_END_OF_LIST(),
2000 .qdev
.name
= "i82557a",
2001 .qdev
.desc
= "Intel i82557A Ethernet",
2002 .qdev
.size
= sizeof(EEPRO100State
),
2003 .init
= pci_i82557a_init
,
2004 .exit
= pci_nic_uninit
,
2005 .romfile
= "gpxe-eepro100-80861229.rom",
2006 .qdev
.props
= (Property
[]) {
2007 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2008 DEFINE_PROP_END_OF_LIST(),
2011 .qdev
.name
= "i82557b",
2012 .qdev
.desc
= "Intel i82557B Ethernet",
2013 .qdev
.size
= sizeof(EEPRO100State
),
2014 .init
= pci_i82557b_init
,
2015 .exit
= pci_nic_uninit
,
2016 .romfile
= "gpxe-eepro100-80861229.rom",
2017 .qdev
.props
= (Property
[]) {
2018 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2019 DEFINE_PROP_END_OF_LIST(),
2022 .qdev
.name
= "i82557c",
2023 .qdev
.desc
= "Intel i82557C Ethernet",
2024 .qdev
.size
= sizeof(EEPRO100State
),
2025 .init
= pci_i82557c_init
,
2026 .exit
= pci_nic_uninit
,
2027 .romfile
= "gpxe-eepro100-80861229.rom",
2028 .qdev
.props
= (Property
[]) {
2029 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2030 DEFINE_PROP_END_OF_LIST(),
2033 .qdev
.name
= "i82558a",
2034 .qdev
.desc
= "Intel i82558A Ethernet",
2035 .qdev
.size
= sizeof(EEPRO100State
),
2036 .init
= pci_i82558a_init
,
2037 .exit
= pci_nic_uninit
,
2038 .romfile
= "gpxe-eepro100-80861229.rom",
2039 .qdev
.props
= (Property
[]) {
2040 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2041 DEFINE_PROP_END_OF_LIST(),
2044 .qdev
.name
= "i82558b",
2045 .qdev
.desc
= "Intel i82558B Ethernet",
2046 .qdev
.size
= sizeof(EEPRO100State
),
2047 .init
= pci_i82558b_init
,
2048 .exit
= pci_nic_uninit
,
2049 .romfile
= "gpxe-eepro100-80861229.rom",
2050 .qdev
.props
= (Property
[]) {
2051 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2052 DEFINE_PROP_END_OF_LIST(),
2055 .qdev
.name
= "i82559a",
2056 .qdev
.desc
= "Intel i82559A Ethernet",
2057 .qdev
.size
= sizeof(EEPRO100State
),
2058 .init
= pci_i82559a_init
,
2059 .exit
= pci_nic_uninit
,
2060 .romfile
= "gpxe-eepro100-80861229.rom",
2061 .qdev
.props
= (Property
[]) {
2062 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2063 DEFINE_PROP_END_OF_LIST(),
2066 .qdev
.name
= "i82559b",
2067 .qdev
.desc
= "Intel i82559B Ethernet",
2068 .qdev
.size
= sizeof(EEPRO100State
),
2069 .init
= pci_i82559b_init
,
2070 .exit
= pci_nic_uninit
,
2071 .romfile
= "gpxe-eepro100-80861229.rom",
2072 .qdev
.props
= (Property
[]) {
2073 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2074 DEFINE_PROP_END_OF_LIST(),
2077 .qdev
.name
= "i82559c",
2078 .qdev
.desc
= "Intel i82559C Ethernet",
2079 .qdev
.size
= sizeof(EEPRO100State
),
2080 .init
= pci_i82559c_init
,
2081 .exit
= pci_nic_uninit
,
2082 .romfile
= "gpxe-eepro100-80861229.rom",
2083 .qdev
.props
= (Property
[]) {
2084 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2085 DEFINE_PROP_END_OF_LIST(),
2088 .qdev
.name
= "i82559er",
2089 .qdev
.desc
= "Intel i82559ER Ethernet",
2090 .qdev
.size
= sizeof(EEPRO100State
),
2091 .init
= pci_i82559er_init
,
2092 .exit
= pci_nic_uninit
,
2093 .romfile
= "gpxe-eepro100-80861209.rom",
2094 .qdev
.props
= (Property
[]) {
2095 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2096 DEFINE_PROP_END_OF_LIST(),
2099 .qdev
.name
= "i82562",
2100 .qdev
.desc
= "Intel i82562 Ethernet",
2101 .qdev
.size
= sizeof(EEPRO100State
),
2102 .init
= pci_i82562_init
,
2103 .exit
= pci_nic_uninit
,
2104 .romfile
= "gpxe-eepro100-80861209.rom",
2105 .qdev
.props
= (Property
[]) {
2106 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2107 DEFINE_PROP_END_OF_LIST(),
2114 static void eepro100_register_devices(void)
2116 pci_qdev_register_many(eepro100_info
);
2119 device_init(eepro100_register_devices
)