2 * QEMU i8255x (PRO100) emulation
4 * Copyright (c) 2006-2007 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) 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):
23 * PXE boot (i386) no valid link
24 * Linux networking (i386) ok
32 * Intel 8255x 10/100 Mbps Ethernet Controller Family
33 * Open Source Software Developer Manual
36 #if defined(TARGET_I386)
37 # warning "PXE boot still not working!"
40 #include <stddef.h> /* offsetof */
43 #include "loader.h" /* rom_add_option */
46 #include "eeprom93xx.h"
48 /* Common declarations for all PCI devices. */
50 #define PCI_CONFIG_8(offset, value) \
51 (pci_conf[offset] = (value))
52 #define PCI_CONFIG_16(offset, value) \
53 (*(uint16_t *)&pci_conf[offset] = cpu_to_le16(value))
54 #define PCI_CONFIG_32(offset, value) \
55 (*(uint32_t *)&pci_conf[offset] = cpu_to_le32(value))
59 /* Debug EEPRO100 card. */
60 //~ #define DEBUG_EEPRO100
63 #define logout(fmt, ...) fprintf(stderr, "EE100\t%-24s" fmt, __func__, ## __VA_ARGS__)
65 #define logout(fmt, ...) ((void)0)
68 /* Set flags to 0 to disable debug output. */
69 #define INT 1 /* interrupt related actions */
70 #define MDI 1 /* mdi related actions */
73 #define EEPROM 1 /* eeprom related actions */
75 #define TRACE(flag, command) ((flag) ? (command) : (void)0)
77 #define missing(text) fprintf(stderr, "eepro100: feature is missing in this emulation: " text "\n")
79 #define MAX_ETH_FRAME_SIZE 1514
81 /* This driver supports several different devices which are declared here. */
82 #define i82550 0x82550
83 #define i82551 0x82551
84 #define i82557A 0x82557a
85 #define i82557B 0x82557b
86 #define i82557C 0x82557c
87 #define i82558A 0x82558a
88 #define i82558B 0x82558b
89 #define i82559A 0x82559a
90 #define i82559B 0x82559b
91 #define i82559C 0x82559c
92 #define i82559ER 0x82559e
93 #define i82562 0x82562
95 /* Use 64 word EEPROM. TODO: could be a runtime option. */
96 #define EEPROM_SIZE 64
98 #define PCI_MEM_SIZE (4 * KiB)
99 #define PCI_IO_SIZE 64
100 #define PCI_FLASH_SIZE (128 * KiB)
102 #define BIT(n) (1 << (n))
103 #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
105 /* The SCB accepts the following controls for the Tx and Rx units: */
106 #define CU_NOP 0x0000 /* No operation. */
107 #define CU_START 0x0010 /* CU start. */
108 #define CU_RESUME 0x0020 /* CU resume. */
109 #define CU_STATSADDR 0x0040 /* Load dump counters address. */
110 #define CU_SHOWSTATS 0x0050 /* Dump statistical counters. */
111 #define CU_CMD_BASE 0x0060 /* Load CU base address. */
112 #define CU_DUMPSTATS 0x0070 /* Dump and reset statistical counters. */
113 #define CU_SRESUME 0x00a0 /* CU static resume. */
115 #define RU_NOP 0x0000
116 #define RX_START 0x0001
117 #define RX_RESUME 0x0002
118 #define RX_ABORT 0x0004
119 #define RX_ADDR_LOAD 0x0006
120 #define RX_RESUMENR 0x0007
121 #define INT_MASK 0x0100
122 #define DRVR_INT 0x0200 /* Driver generated interrupt. */
124 /* Offsets to the various registers.
125 All accesses need not be longword aligned. */
126 enum speedo_offsets
{
129 SCBCmd
= 2, /* Rx/Command Unit command and status. */
131 SCBPointer
= 4, /* General purpose pointer. */
132 SCBPort
= 8, /* Misc. commands and operands. */
133 SCBflash
= 12, SCBeeprom
= 14, /* EEPROM and flash memory control. */
134 SCBCtrlMDI
= 16, /* MDI interface control. */
135 SCBEarlyRx
= 20, /* Early receive byte count. */
139 /* A speedo3 transmit buffer descriptor with two buffers... */
143 uint32_t link
; /* void * */
144 uint32_t tx_desc_addr
; /* transmit buffer decsriptor array address. */
145 uint16_t tcb_bytes
; /* transmit command block byte count (in lower 14 bits */
146 uint8_t tx_threshold
; /* transmit threshold */
147 uint8_t tbd_count
; /* TBD number */
148 //~ /* This constitutes two "TBD" entries: hdr and data */
149 //~ uint32_t tx_buf_addr0; /* void *, header of frame to be transmitted. */
150 //~ int32_t tx_buf_size0; /* Length of Tx hdr. */
151 //~ uint32_t tx_buf_addr1; /* void *, data to be transmitted. */
152 //~ int32_t tx_buf_size1; /* Length of Tx data. */
155 /* Receive frame descriptor. */
159 uint32_t link
; /* struct RxFD * */
160 uint32_t rx_buf_addr
; /* void * */
163 char packet
[MAX_ETH_FRAME_SIZE
+ 4];
167 uint32_t tx_good_frames
, tx_max_collisions
, tx_late_collisions
,
168 tx_underruns
, tx_lost_crs
, tx_deferred
, tx_single_collisions
,
169 tx_multiple_collisions
, tx_total_collisions
;
170 uint32_t rx_good_frames
, rx_crc_errors
, rx_alignment_errors
,
171 rx_resource_errors
, rx_overrun_errors
, rx_cdt_errors
,
172 rx_short_frame_errors
;
173 uint32_t fc_xmt_pause
, fc_rcv_pause
, fc_rcv_unsupported
;
174 uint16_t xmt_tco_frames
, rcv_tco_frames
;
175 /* TODO: i82559 has six reserved statistics but a total of 24 dwords. */
176 uint32_t reserved
[4];
196 uint8_t mult
[8]; /* multicast mask array */
200 uint8_t scb_stat
; /* SCB stat/ack byte */
201 uint8_t int_stat
; /* PCI interrupt status */
202 /* region must not be saved by nic_save. */
203 uint32_t region
[3]; /* PCI region addresses */
206 uint32_t device
; /* device variant */
208 /* (cu_base + cu_offset) address the next command block in the command block list. */
209 uint32_t cu_base
; /* CU base address */
210 uint32_t cu_offset
; /* CU address offset */
211 /* (ru_base + ru_offset) address the RFD in the Receive Frame Area. */
212 uint32_t ru_base
; /* RU base address */
213 uint32_t ru_offset
; /* RU address offset */
214 uint32_t statsaddr
; /* pointer to eepro100_stats_t */
216 /* Statistical counters. Also used for wake-up packet (i82559). */
217 eepro100_stats_t statistics
;
223 /* Configuration bytes. */
224 uint8_t configuration
[22];
226 /* Data in mem is always in the byte order of the controller (le). */
227 uint8_t mem
[PCI_MEM_SIZE
];
228 /* vmstate for each particular nic */
229 VMStateDescription
*vmstate
;
231 /* Quasi static device properties (no need to save them). */
233 bool has_extended_tcb_support
;
236 /* Default values for MDI (PHY) registers */
237 static const uint16_t eepro100_mdi_default
[] = {
238 /* MDI Registers 0 - 6, 7 */
239 0x3000, 0x780d, 0x02a8, 0x0154, 0x05e1, 0x0000, 0x0000, 0x0000,
240 /* MDI Registers 8 - 15 */
241 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
242 /* MDI Registers 16 - 31 */
243 0x0003, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
244 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
247 /* Readonly mask for MDI (PHY) registers */
248 static const uint16_t eepro100_mdi_mask
[] = {
249 0x0000, 0xffff, 0xffff, 0xffff, 0xc01f, 0xffff, 0xffff, 0x0000,
250 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
251 0x0fff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
252 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
256 static void stl_le_phys(target_phys_addr_t addr
, uint32_t val
)
258 val
= cpu_to_le32(val
);
259 cpu_physical_memory_write(addr
, (const uint8_t *)&val
, sizeof(val
));
262 #define POLYNOMIAL 0x04c11db6
266 static int compute_mcast_idx(const uint8_t * ep
)
273 for (i
= 0; i
< 6; i
++) {
275 for (j
= 0; j
< 8; j
++) {
276 carry
= ((crc
& 0x80000000L
) ? 1 : 0) ^ (b
& 0x01);
280 crc
= ((crc
^ POLYNOMIAL
) | carry
);
287 #if defined(DEBUG_EEPRO100)
288 static const char *nic_dump(const uint8_t * buf
, unsigned size
)
290 static char dump
[3 * 16 + 1];
296 p
+= sprintf(p
, " %02x", *buf
++);
300 #endif /* DEBUG_EEPRO100 */
303 stat_ack_not_ours
= 0x00,
304 stat_ack_sw_gen
= 0x04,
306 stat_ack_cu_idle
= 0x20,
307 stat_ack_frame_rx
= 0x40,
308 stat_ack_cu_cmd_done
= 0x80,
309 stat_ack_not_present
= 0xFF,
310 stat_ack_rx
= (stat_ack_sw_gen
| stat_ack_rnr
| stat_ack_frame_rx
),
311 stat_ack_tx
= (stat_ack_cu_idle
| stat_ack_cu_cmd_done
),
314 static void disable_interrupt(EEPRO100State
* s
)
317 TRACE(INT
, logout("interrupt disabled\n"));
318 qemu_irq_lower(s
->dev
.irq
[0]);
323 static void enable_interrupt(EEPRO100State
* s
)
326 TRACE(INT
, logout("interrupt enabled\n"));
327 qemu_irq_raise(s
->dev
.irq
[0]);
332 static void eepro100_acknowledge(EEPRO100State
* s
)
334 s
->scb_stat
&= ~s
->mem
[SCBAck
];
335 s
->mem
[SCBAck
] = s
->scb_stat
;
336 if (s
->scb_stat
== 0) {
337 disable_interrupt(s
);
341 static void eepro100_interrupt(EEPRO100State
* s
, uint8_t stat
)
343 uint8_t mask
= ~s
->mem
[SCBIntmask
];
344 s
->mem
[SCBAck
] |= stat
;
345 stat
= s
->scb_stat
= s
->mem
[SCBAck
];
346 stat
&= (mask
| 0x0f);
347 //~ stat &= (~s->mem[SCBIntmask] | 0x0xf);
348 if (stat
&& (mask
& 0x01)) {
349 /* SCB mask and SCB Bit M do not disable interrupt. */
351 } else if (s
->int_stat
) {
352 disable_interrupt(s
);
356 static void eepro100_cx_interrupt(EEPRO100State
* s
)
358 /* CU completed action command. */
359 /* Transmit not ok (82557 only, not in emulation). */
360 eepro100_interrupt(s
, 0x80);
363 static void eepro100_cna_interrupt(EEPRO100State
* s
)
365 /* CU left the active state. */
366 eepro100_interrupt(s
, 0x20);
369 static void eepro100_fr_interrupt(EEPRO100State
* s
)
371 /* RU received a complete frame. */
372 eepro100_interrupt(s
, 0x40);
376 static void eepro100_rnr_interrupt(EEPRO100State
* s
)
378 /* RU is not ready. */
379 eepro100_interrupt(s
, 0x10);
383 static void eepro100_mdi_interrupt(EEPRO100State
* s
)
385 /* MDI completed read or write cycle. */
386 eepro100_interrupt(s
, 0x08);
389 static void eepro100_swi_interrupt(EEPRO100State
* s
)
391 /* Software has requested an interrupt. */
392 eepro100_interrupt(s
, 0x04);
396 static void eepro100_fcp_interrupt(EEPRO100State
* s
)
398 /* Flow control pause interrupt (82558 and later). */
399 eepro100_interrupt(s
, 0x01);
403 static void pci_reset(EEPRO100State
* s
)
405 uint32_t device
= s
->device
;
406 uint8_t *pci_conf
= s
->dev
.config
;
407 bool power_management
= 1;
409 TRACE(OTHER
, logout("%p\n", s
));
412 pci_config_set_vendor_id(pci_conf
, PCI_VENDOR_ID_INTEL
);
413 /* PCI Device ID depends on device and is set below. */
415 /* TODO: this is the default, do not override. */
416 PCI_CONFIG_16(PCI_COMMAND
, 0x0000);
418 /* TODO: Value at RST# should be 0. */
419 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
| PCI_STATUS_FAST_BACK
);
420 /* PCI Revision ID */
421 PCI_CONFIG_8(PCI_REVISION_ID
, 0x08);
422 /* TODO: this is the default, do not override. */
424 PCI_CONFIG_8(PCI_CLASS_PROG
, 0x00);
425 pci_config_set_class(pci_conf
, PCI_CLASS_NETWORK_ETHERNET
);
426 /* PCI Cache Line Size */
427 /* check cache line size!!! */
428 //~ PCI_CONFIG_8(0x0c, 0x00);
429 /* PCI Latency Timer */
430 PCI_CONFIG_8(PCI_LATENCY_TIMER
, 0x20); // latency timer = 32 clocks
431 /* PCI Header Type */
432 /* BIST (built-in self test) */
433 #if defined(TARGET_I386)
434 // !!! workaround for buggy bios
435 //~ #define PCI_BASE_ADDRESS_MEM_PREFETCH 0
438 /* PCI Base Address Registers */
439 /* CSR Memory Mapped Base Address */
440 PCI_CONFIG_32(PCI_BASE_ADDRESS_0
,
441 PCI_BASE_ADDRESS_SPACE_MEMORY
|
442 PCI_BASE_ADDRESS_MEM_PREFETCH
);
443 /* CSR I/O Mapped Base Address */
444 PCI_CONFIG_32(PCI_BASE_ADDRESS_1
, PCI_BASE_ADDRESS_SPACE_IO
);
446 /* Flash Memory Mapped Base Address */
447 PCI_CONFIG_32(PCI_BASE_ADDRESS_2
,
448 0xfffe0000 | PCI_BASE_ADDRESS_SPACE_MEMORY
);
451 /* Expansion ROM Base Address (depends on boot disable!!!) */
452 /* TODO: not needed, set when BAR is registered */
453 PCI_CONFIG_32(PCI_ROM_ADDRESS
, PCI_BASE_ADDRESS_SPACE_MEMORY
);
454 /* Capability Pointer */
455 /* TODO: revisions with power_management 1 use this but
456 * do not set new capability list bit in status register. */
457 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0xdc);
460 /* TODO: RST# value should be 0 */
461 PCI_CONFIG_8(PCI_INTERRUPT_PIN
, 1); // interrupt pin 0
463 PCI_CONFIG_8(PCI_MIN_GNT
, 0x08);
464 /* Maximum Latency */
465 PCI_CONFIG_8(PCI_MAX_LAT
, 0x18);
469 // TODO: check device id.
470 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
471 /* Revision ID: 0x0c, 0x0d, 0x0e. */
472 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0e);
473 // TODO: check size of statistical counters.
475 // TODO: check extended tcb support.
476 s
->has_extended_tcb_support
= 1;
479 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
480 /* Revision ID: 0x0f, 0x10. */
481 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0f);
482 // TODO: check size of statistical counters.
484 s
->has_extended_tcb_support
= 1;
487 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
488 PCI_CONFIG_8(PCI_REVISION_ID
, 0x01);
489 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
490 power_management
= 0;
493 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
494 PCI_CONFIG_8(PCI_REVISION_ID
, 0x02);
495 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
496 power_management
= 0;
499 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
500 PCI_CONFIG_8(PCI_REVISION_ID
, 0x03);
501 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
502 power_management
= 0;
505 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
506 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
507 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
508 PCI_CONFIG_8(PCI_REVISION_ID
, 0x04);
510 s
->has_extended_tcb_support
= 1;
513 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
514 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
515 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
516 PCI_CONFIG_8(PCI_REVISION_ID
, 0x05);
518 s
->has_extended_tcb_support
= 1;
521 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
522 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
523 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
524 PCI_CONFIG_8(PCI_REVISION_ID
, 0x06);
526 s
->has_extended_tcb_support
= 1;
529 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
530 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
531 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
532 PCI_CONFIG_8(PCI_REVISION_ID
, 0x07);
534 s
->has_extended_tcb_support
= 1;
537 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
538 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
539 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
540 PCI_CONFIG_8(PCI_REVISION_ID
, 0x08);
541 // TODO: Windows wants revision id 0x0c.
542 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0c);
544 PCI_CONFIG_16(PCI_SUBSYSTEM_VENDOR_ID
, 0x8086);
545 PCI_CONFIG_16(PCI_SUBSYSTEM_ID
, 0x0040);
548 s
->has_extended_tcb_support
= 1;
551 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
552 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
553 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
554 PCI_CONFIG_8(PCI_REVISION_ID
, 0x09);
556 s
->has_extended_tcb_support
= 1;
559 // TODO: check device id.
560 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
561 /* TODO: wrong revision id. */
562 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0e);
564 s
->has_extended_tcb_support
= 1;
567 logout("Device %X is undefined!\n", device
);
570 s
->configuration
[6] |= BIT(5);
572 if (s
->stats_size
== 80) {
573 /* TODO: check TCO Statistical Counters bit. Documentation not clear. */
574 if (s
->configuration
[6] & BIT(2)) {
575 /* TCO statistical counters. */
576 assert(s
->configuration
[6] & BIT(5));
578 if (s
->configuration
[6] & BIT(5)) {
579 /* No extended statistical counters, i82557 compatible. */
582 /* i82558 compatible. */
587 if (s
->configuration
[6] & BIT(5)) {
588 /* No extended statistical counters. */
592 assert(s
->stats_size
> 0 && s
->stats_size
<= sizeof(s
->statistics
));
594 if (power_management
) {
595 /* Power Management Capabilities */
596 PCI_CONFIG_8(0xdc, 0x01);
597 /* Next Item Pointer */
599 PCI_CONFIG_16(0xde, 0x7e21);
600 /* TODO: Power Management Control / Status. */
601 /* TODO: Ethernet Power Consumption Registers (i82559 and later). */
605 if (device
== i82557C
|| device
== i82558B
|| device
== i82559C
) {
606 // TODO: get vendor id from EEPROM for i82557C or later.
607 // TODO: get device id from EEPROM for i82557C or later.
608 // TODO: status bit 4 can be disabled by EEPROM for i82558, i82559.
609 // TODO: header type is determined by EEPROM for i82559.
610 // TODO: get subsystem id from EEPROM for i82557C or later.
611 // TODO: get subsystem vendor id from EEPROM for i82557C or later.
612 // TODO: exp. rom baddr depends on a bit in EEPROM for i82558 or later.
613 // TODO: capability pointer depends on EEPROM for i82558.
614 logout("Get device id and revision from EEPROM!!!\n");
616 #endif /* EEPROM_SIZE > 0 */
619 static void nic_selective_reset(EEPRO100State
* s
)
622 uint16_t *eeprom_contents
= eeprom93xx_data(s
->eeprom
);
623 //~ eeprom93xx_reset(s->eeprom);
624 memcpy(eeprom_contents
, s
->conf
.macaddr
.a
, 6);
625 eeprom_contents
[0xa] = 0x4000;
626 if (s
->device
== i82557B
|| s
->device
== i82557C
)
627 eeprom_contents
[5] = 0x0100;
629 for (i
= 0; i
< EEPROM_SIZE
- 1; i
++) {
630 sum
+= eeprom_contents
[i
];
632 eeprom_contents
[EEPROM_SIZE
- 1] = 0xbaba - sum
;
633 TRACE(EEPROM
, logout("checksum=0x%04x\n", eeprom_contents
[EEPROM_SIZE
- 1]));
635 memset(s
->mem
, 0, sizeof(s
->mem
));
636 uint32_t val
= BIT(21);
637 memcpy(&s
->mem
[SCBCtrlMDI
], &val
, sizeof(val
));
639 assert(sizeof(s
->mdimem
) == sizeof(eepro100_mdi_default
));
640 memcpy(&s
->mdimem
[0], &eepro100_mdi_default
[0], sizeof(s
->mdimem
));
643 static void nic_reset(void *opaque
)
645 EEPRO100State
*s
= opaque
;
646 TRACE(OTHER
, logout("%p\n", s
));
647 nic_selective_reset(s
);
650 #if defined(DEBUG_EEPRO100)
651 static const char * const e100_reg
[PCI_IO_SIZE
/ 4] = {
655 "EEPROM/Flash Control",
657 "Receive DMA Byte Count",
659 "General Status/Control"
662 static char *regname(uint32_t addr
)
665 if (addr
< PCI_IO_SIZE
) {
666 const char *r
= e100_reg
[addr
/ 4];
668 snprintf(buf
, sizeof(buf
), "%s+%u", r
, addr
% 4);
670 snprintf(buf
, sizeof(buf
), "0x%02x", addr
);
673 snprintf(buf
, sizeof(buf
), "??? 0x%08x", addr
);
677 #endif /* DEBUG_EEPRO100 */
680 static uint16_t eepro100_read_status(EEPRO100State
* s
)
682 uint16_t val
= s
->status
;
683 TRACE(OTHER
, logout("val=0x%04x\n", val
));
687 static void eepro100_write_status(EEPRO100State
* s
, uint16_t val
)
689 TRACE(OTHER
, logout("val=0x%04x\n", val
));
694 /*****************************************************************************
698 ****************************************************************************/
701 static uint16_t eepro100_read_command(EEPRO100State
* s
)
703 uint16_t val
= 0xffff;
704 //~ TRACE(OTHER, logout("val=0x%04x\n", val));
709 /* Commands that can be put in a command list entry. */
714 CmdMulticastList
= 3,
716 CmdTDR
= 5, /* load microcode */
720 /* And some extra flags: */
721 CmdSuspend
= 0x4000, /* Suspend after completion. */
722 CmdIntr
= 0x2000, /* Interrupt after completion. */
723 CmdTxFlex
= 0x0008, /* Use "Flexible mode" for CmdTx command. */
726 static cu_state_t
get_cu_state(EEPRO100State
* s
)
728 return ((s
->mem
[SCBStatus
] >> 6) & 0x03);
731 static void set_cu_state(EEPRO100State
* s
, cu_state_t state
)
733 s
->mem
[SCBStatus
] = (s
->mem
[SCBStatus
] & 0x3f) + (state
<< 6);
736 static ru_state_t
get_ru_state(EEPRO100State
* s
)
738 return ((s
->mem
[SCBStatus
] >> 2) & 0x0f);
741 static void set_ru_state(EEPRO100State
* s
, ru_state_t state
)
743 s
->mem
[SCBStatus
] = (s
->mem
[SCBStatus
] & 0xc3) + (state
<< 2);
746 static void dump_statistics(EEPRO100State
* s
)
748 /* Dump statistical data. Most data is never changed by the emulation
749 * and always 0, so we first just copy the whole block and then those
750 * values which really matter.
751 * Number of data should check configuration!!!
753 cpu_physical_memory_write(s
->statsaddr
,
754 (uint8_t *) & s
->statistics
, s
->stats_size
);
755 stl_le_phys(s
->statsaddr
+ 0, s
->statistics
.tx_good_frames
);
756 stl_le_phys(s
->statsaddr
+ 36, s
->statistics
.rx_good_frames
);
757 stl_le_phys(s
->statsaddr
+ 48, s
->statistics
.rx_resource_errors
);
758 stl_le_phys(s
->statsaddr
+ 60, s
->statistics
.rx_short_frame_errors
);
759 //~ stw_le_phys(s->statsaddr + 76, s->statistics.xmt_tco_frames);
760 //~ stw_le_phys(s->statsaddr + 78, s->statistics.rcv_tco_frames);
761 //~ missing("CU dump statistical counters");
764 static void action_command(EEPRO100State
*s
)
767 uint32_t cb_address
= s
->cu_base
+ s
->cu_offset
;
769 cpu_physical_memory_read(cb_address
, (uint8_t *) & tx
, sizeof(tx
));
770 uint16_t status
= le16_to_cpu(tx
.status
);
771 uint16_t command
= le16_to_cpu(tx
.command
);
773 ("val=0x%02x (cu start), status=0x%04x, command=0x%04x, link=0x%08x\n",
774 val
, status
, command
, tx
.link
);
775 bool bit_el
= ((command
& 0x8000) != 0);
776 bool bit_s
= ((command
& 0x4000) != 0);
777 bool bit_i
= ((command
& 0x2000) != 0);
778 bool bit_nc
= ((command
& 0x0010) != 0);
780 //~ bool bit_sf = ((command & 0x0008) != 0);
781 uint16_t cmd
= command
& 0x0007;
782 s
->cu_offset
= le32_to_cpu(tx
.link
);
788 cpu_physical_memory_read(cb_address
+ 8, &s
->conf
.macaddr
.a
[0], 6);
789 TRACE(OTHER
, logout("macaddr: %s\n", nic_dump(&s
->macaddr
[0], 6)));
792 cpu_physical_memory_read(cb_address
+ 8, &s
->configuration
[0],
793 sizeof(s
->configuration
));
794 TRACE(OTHER
, logout("configuration: %s\n", nic_dump(&s
->configuration
[0], 16)));
796 case CmdMulticastList
:
797 //~ missing("multicast list");
801 uint32_t tbd_array
= le32_to_cpu(tx
.tx_desc_addr
);
802 uint16_t tcb_bytes
= (le16_to_cpu(tx
.tcb_bytes
) & 0x3fff);
804 ("transmit, TBD array address 0x%08x, TCB byte count 0x%04x, TBD count %u\n",
805 tbd_array
, tcb_bytes
, tx
.tbd_count
));
808 missing("CmdTx: NC = 0");
813 if (tcb_bytes
> 2600) {
814 logout("TCB byte count too large, using 2600\n");
817 /* Next assertion fails for local configuration. */
818 //~ assert((tcb_bytes > 0) || (tbd_array != 0xffffffff));
819 if (!((tcb_bytes
> 0) || (tbd_array
!= 0xffffffff))) {
821 ("illegal values of TBD array address and TCB byte count!\n");
823 // sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes
826 uint32_t tbd_address
= cb_address
+ 0x10;
827 assert(tcb_bytes
<= sizeof(buf
));
828 while (size
< tcb_bytes
) {
829 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
830 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
831 //~ uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
834 ("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
835 tx_buffer_address
, tx_buffer_size
));
836 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
837 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
839 size
+= tx_buffer_size
;
841 if (tbd_array
== 0xffffffff) {
842 /* Simplified mode. Was already handled by code above. */
845 uint8_t tbd_count
= 0;
846 if (s
->has_extended_tcb_support
&& !(s
->configuration
[6] & BIT(4))) {
847 /* Extended Flexible TCB. */
848 for (; tbd_count
< 2; tbd_count
++) {
849 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
850 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
851 uint16_t tx_buffer_el
= lduw_phys(tbd_address
+ 6);
854 ("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n",
855 tx_buffer_address
, tx_buffer_size
));
856 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
857 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
859 size
+= tx_buffer_size
;
860 if (tx_buffer_el
& 1) {
865 tbd_address
= tbd_array
;
866 for (; tbd_count
< tx
.tbd_count
; tbd_count
++) {
867 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
868 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
869 uint16_t tx_buffer_el
= lduw_phys(tbd_address
+ 6);
872 ("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n",
873 tx_buffer_address
, tx_buffer_size
));
874 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
875 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
877 size
+= tx_buffer_size
;
878 if (tx_buffer_el
& 1) {
883 TRACE(RXTX
, logout("%p sending frame, len=%d,%s\n", s
, size
, nic_dump(buf
, size
)));
884 qemu_send_packet(&s
->nic
->nc
, buf
, size
);
885 s
->statistics
.tx_good_frames
++;
886 /* Transmit with bad status would raise an CX/TNO interrupt.
887 * (82557 only). Emulation never has bad status. */
888 //~ eepro100_cx_interrupt(s);
891 TRACE(OTHER
, logout("load microcode\n"));
892 /* Starting with offset 8, the command contains
893 * 64 dwords microcode which we just ignore here. */
896 missing("undefined command");
900 /* Write new status. */
901 stw_phys(cb_address
, status
| 0x8000 | (success
? 0x2000 : 0));
903 /* CU completed action. */
904 eepro100_cx_interrupt(s
);
907 /* CU becomes idle. Terminate command loop. */
908 set_cu_state(s
, cu_idle
);
909 eepro100_cna_interrupt(s
);
912 /* CU becomes suspended. Terminate command loop. */
913 set_cu_state(s
, cu_suspended
);
914 eepro100_cna_interrupt(s
);
917 /* More entries in list. */
918 TRACE(OTHER
, logout("CU list with at least one more entry\n"));
921 TRACE(OTHER
, logout("CU list empty\n"));
922 /* List is empty. Now CU is idle or suspended. */
925 static void eepro100_cu_command(EEPRO100State
* s
, uint8_t val
)
932 if (get_cu_state(s
) != cu_idle
) {
933 /* Intel documentation says that CU must be idle for the CU
934 * start command. Intel driver for Linux also starts the CU
935 * from suspended state. */
936 logout("CU state is %u, should be %u\n", get_cu_state(s
), cu_idle
);
937 //~ assert(!"wrong CU state");
939 set_cu_state(s
, cu_active
);
940 s
->cu_offset
= s
->pointer
;
944 if (get_cu_state(s
) != cu_suspended
) {
945 logout("bad CU resume from CU state %u\n", get_cu_state(s
));
946 /* Workaround for bad Linux eepro100 driver which resumes
947 * from idle state. */
948 //~ missing("cu resume");
949 set_cu_state(s
, cu_suspended
);
951 if (get_cu_state(s
) == cu_suspended
) {
952 TRACE(OTHER
, logout("CU resuming\n"));
953 set_cu_state(s
, cu_active
);
958 /* Load dump counters address. */
959 s
->statsaddr
= s
->pointer
;
960 TRACE(OTHER
, logout("val=0x%02x (status address)\n", val
));
963 /* Dump statistical counters. */
964 TRACE(OTHER
, logout("val=0x%02x (dump stats)\n", val
));
966 stl_le_phys(s
->statsaddr
+ s
->stats_size
, 0xa005);
970 TRACE(OTHER
, logout("val=0x%02x (CU base address)\n", val
));
971 s
->cu_base
= s
->pointer
;
974 /* Dump and reset statistical counters. */
975 TRACE(OTHER
, logout("val=0x%02x (dump stats and reset)\n", val
));
977 stl_le_phys(s
->statsaddr
+ s
->stats_size
, 0xa007);
978 memset(&s
->statistics
, 0, sizeof(s
->statistics
));
981 /* CU static resume. */
982 missing("CU static resume");
985 missing("Undefined CU command");
989 static void eepro100_ru_command(EEPRO100State
* s
, uint8_t val
)
997 if (get_ru_state(s
) != ru_idle
) {
998 logout("RU state is %u, should be %u\n", get_ru_state(s
), ru_idle
);
999 //~ assert(!"wrong RU state");
1001 set_ru_state(s
, ru_ready
);
1002 s
->ru_offset
= s
->pointer
;
1003 TRACE(OTHER
, logout("val=0x%02x (rx start)\n", val
));
1007 if (get_ru_state(s
) != ru_suspended
) {
1008 logout("RU state is %u, should be %u\n", get_ru_state(s
),
1010 //~ assert(!"wrong RU state");
1012 set_ru_state(s
, ru_ready
);
1016 TRACE(OTHER
, logout("val=0x%02x (RU base address)\n", val
));
1017 s
->ru_base
= s
->pointer
;
1020 logout("val=0x%02x (undefined RU command)\n", val
);
1021 missing("Undefined SU command");
1025 static void eepro100_write_command(EEPRO100State
* s
, uint8_t val
)
1027 eepro100_ru_command(s
, val
& 0x0f);
1028 eepro100_cu_command(s
, val
& 0xf0);
1030 TRACE(OTHER
, logout("val=0x%02x\n", val
));
1032 /* Clear command byte after command was accepted. */
1036 /*****************************************************************************
1040 ****************************************************************************/
1042 #define EEPROM_CS 0x02
1043 #define EEPROM_SK 0x01
1044 #define EEPROM_DI 0x04
1045 #define EEPROM_DO 0x08
1047 static uint16_t eepro100_read_eeprom(EEPRO100State
* s
)
1050 memcpy(&val
, &s
->mem
[SCBeeprom
], sizeof(val
));
1051 if (eeprom93xx_read(s
->eeprom
)) {
1056 TRACE(EEPROM
, logout("val=0x%04x\n", val
));
1060 static void eepro100_write_eeprom(eeprom_t
* eeprom
, uint8_t val
)
1062 TRACE(EEPROM
, logout("val=0x%02x\n", val
));
1064 /* mask unwriteable bits */
1065 //~ val = SET_MASKED(val, 0x31, eeprom->value);
1067 int eecs
= ((val
& EEPROM_CS
) != 0);
1068 int eesk
= ((val
& EEPROM_SK
) != 0);
1069 int eedi
= ((val
& EEPROM_DI
) != 0);
1070 eeprom93xx_write(eeprom
, eecs
, eesk
, eedi
);
1073 static void eepro100_write_pointer(EEPRO100State
* s
, uint32_t val
)
1075 s
->pointer
= le32_to_cpu(val
);
1076 TRACE(OTHER
, logout("val=0x%08x\n", val
));
1079 /*****************************************************************************
1083 ****************************************************************************/
1085 #if defined(DEBUG_EEPRO100)
1086 static const char * const mdi_op_name
[] = {
1093 static const char * const mdi_reg_name
[] = {
1096 "PHY Identification (Word 1)",
1097 "PHY Identification (Word 2)",
1098 "Auto-Negotiation Advertisement",
1099 "Auto-Negotiation Link Partner Ability",
1100 "Auto-Negotiation Expansion"
1103 static const char *reg2name(uint8_t reg
)
1105 static char buffer
[10];
1106 const char *p
= buffer
;
1107 if (reg
< ARRAY_SIZE(mdi_reg_name
)) {
1108 p
= mdi_reg_name
[reg
];
1110 snprintf(buffer
, sizeof(buffer
), "reg=0x%02x", reg
);
1114 #endif /* DEBUG_EEPRO100 */
1116 static uint32_t eepro100_read_mdi(EEPRO100State
* s
)
1119 memcpy(&val
, &s
->mem
[0x10], sizeof(val
));
1121 #ifdef DEBUG_EEPRO100
1122 uint8_t raiseint
= (val
& BIT(29)) >> 29;
1123 uint8_t opcode
= (val
& BITS(27, 26)) >> 26;
1124 uint8_t phy
= (val
& BITS(25, 21)) >> 21;
1125 uint8_t reg
= (val
& BITS(20, 16)) >> 16;
1126 uint16_t data
= (val
& BITS(15, 0));
1128 /* Emulation takes no time to finish MDI transaction. */
1130 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1131 val
, raiseint
, mdi_op_name
[opcode
], phy
,
1132 reg2name(reg
), data
));
1136 static void eepro100_write_mdi(EEPRO100State
* s
, uint32_t val
)
1138 uint8_t raiseint
= (val
& BIT(29)) >> 29;
1139 uint8_t opcode
= (val
& BITS(27, 26)) >> 26;
1140 uint8_t phy
= (val
& BITS(25, 21)) >> 21;
1141 uint8_t reg
= (val
& BITS(20, 16)) >> 16;
1142 uint16_t data
= (val
& BITS(15, 0));
1143 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1144 val
, raiseint
, mdi_op_name
[opcode
], phy
, reg2name(reg
), data
));
1146 /* Unsupported PHY address. */
1147 //~ logout("phy must be 1 but is %u\n", phy);
1149 } else if (opcode
!= 1 && opcode
!= 2) {
1150 /* Unsupported opcode. */
1151 logout("opcode must be 1 or 2 but is %u\n", opcode
);
1153 } else if (reg
> 6) {
1154 /* Unsupported register. */
1155 logout("register must be 0...6 but is %u\n", reg
);
1158 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1159 val
, raiseint
, mdi_op_name
[opcode
], phy
,
1160 reg2name(reg
), data
));
1164 case 0: /* Control Register */
1165 if (data
& 0x8000) {
1166 /* Reset status and control registers to default. */
1167 s
->mdimem
[0] = eepro100_mdi_default
[0];
1168 s
->mdimem
[1] = eepro100_mdi_default
[1];
1169 data
= s
->mdimem
[reg
];
1171 /* Restart Auto Configuration = Normal Operation */
1175 case 1: /* Status Register */
1176 missing("not writable");
1177 data
= s
->mdimem
[reg
];
1179 case 2: /* PHY Identification Register (Word 1) */
1180 case 3: /* PHY Identification Register (Word 2) */
1181 missing("not implemented");
1183 case 4: /* Auto-Negotiation Advertisement Register */
1184 case 5: /* Auto-Negotiation Link Partner Ability Register */
1186 case 6: /* Auto-Negotiation Expansion Register */
1188 missing("not implemented");
1190 s
->mdimem
[reg
] = data
;
1191 } else if (opcode
== 2) {
1194 case 0: /* Control Register */
1195 if (data
& 0x8000) {
1196 /* Reset status and control registers to default. */
1197 s
->mdimem
[0] = eepro100_mdi_default
[0];
1198 s
->mdimem
[1] = eepro100_mdi_default
[1];
1201 case 1: /* Status Register */
1202 s
->mdimem
[reg
] |= 0x0020;
1204 case 2: /* PHY Identification Register (Word 1) */
1205 case 3: /* PHY Identification Register (Word 2) */
1206 case 4: /* Auto-Negotiation Advertisement Register */
1208 case 5: /* Auto-Negotiation Link Partner Ability Register */
1209 s
->mdimem
[reg
] = 0x41fe;
1211 case 6: /* Auto-Negotiation Expansion Register */
1212 s
->mdimem
[reg
] = 0x0001;
1215 data
= s
->mdimem
[reg
];
1217 /* Emulation takes no time to finish MDI transaction.
1218 * Set MDI bit in SCB status register. */
1219 s
->mem
[SCBAck
] |= 0x08;
1222 eepro100_mdi_interrupt(s
);
1225 val
= (val
& 0xffff0000) + data
;
1226 memcpy(&s
->mem
[0x10], &val
, sizeof(val
));
1229 /*****************************************************************************
1233 ****************************************************************************/
1235 #define PORT_SOFTWARE_RESET 0
1236 #define PORT_SELFTEST 1
1237 #define PORT_SELECTIVE_RESET 2
1239 #define PORT_SELECTION_MASK 3
1242 uint32_t st_sign
; /* Self Test Signature */
1243 uint32_t st_result
; /* Self Test Results */
1244 } eepro100_selftest_t
;
1246 static uint32_t eepro100_read_port(EEPRO100State
* s
)
1251 static void eepro100_write_port(EEPRO100State
* s
, uint32_t val
)
1253 val
= le32_to_cpu(val
);
1254 uint32_t address
= (val
& ~PORT_SELECTION_MASK
);
1255 uint8_t selection
= (val
& PORT_SELECTION_MASK
);
1256 switch (selection
) {
1257 case PORT_SOFTWARE_RESET
:
1261 TRACE(OTHER
, logout("selftest address=0x%08x\n", address
));
1262 eepro100_selftest_t data
;
1263 cpu_physical_memory_read(address
, (uint8_t *) & data
, sizeof(data
));
1264 data
.st_sign
= 0xffffffff;
1266 cpu_physical_memory_write(address
, (uint8_t *) & data
, sizeof(data
));
1268 case PORT_SELECTIVE_RESET
:
1269 TRACE(OTHER
, logout("selective reset, selftest address=0x%08x\n", address
));
1270 nic_selective_reset(s
);
1273 logout("val=0x%08x\n", val
);
1274 missing("unknown port selection");
1278 /*****************************************************************************
1280 * General hardware emulation.
1282 ****************************************************************************/
1284 static uint8_t eepro100_read1(EEPRO100State
* s
, uint32_t addr
)
1287 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1288 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1293 //~ val = eepro100_read_status(s);
1294 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1297 //~ val = eepro100_read_status(s);
1298 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1301 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1302 //~ val = eepro100_read_command(s);
1305 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1308 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1311 val
= eepro100_read_eeprom(s
);
1313 case 0x1b: /* PMDR (power management driver register) */
1315 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1317 case 0x1d: /* general status register */
1318 /* 100 Mbps full duplex, valid link */
1320 TRACE(OTHER
, logout("addr=General Status val=%02x\n", val
));
1323 logout("addr=%s val=0x%02x\n", regname(addr
), val
);
1324 missing("unknown byte read");
1329 static uint16_t eepro100_read2(EEPRO100State
* s
, uint32_t addr
)
1332 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1333 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1338 //~ val = eepro100_read_status(s);
1340 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1343 val
= eepro100_read_eeprom(s
);
1344 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1347 logout("addr=%s val=0x%04x\n", regname(addr
), val
);
1348 missing("unknown word read");
1353 static uint32_t eepro100_read4(EEPRO100State
* s
, uint32_t addr
)
1356 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1357 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1362 //~ val = eepro100_read_status(s);
1363 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1366 //~ val = eepro100_read_pointer(s);
1367 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1370 val
= eepro100_read_port(s
);
1371 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1374 val
= eepro100_read_mdi(s
);
1377 logout("addr=%s val=0x%08x\n", regname(addr
), val
);
1378 missing("unknown longword read");
1383 static void eepro100_write1(EEPRO100State
* s
, uint32_t addr
, uint8_t val
)
1385 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1386 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1389 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1393 //~ eepro100_write_status(s, val);
1396 eepro100_acknowledge(s
);
1399 eepro100_write_command(s
, val
);
1403 eepro100_swi_interrupt(s
);
1405 eepro100_interrupt(s
, 0);
1408 case SCBFlow
: /* does not exist on 82557 */
1412 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1415 eepro100_write_eeprom(s
->eeprom
, val
);
1418 logout("addr=%s val=0x%02x\n", regname(addr
), val
);
1419 missing("unknown byte write");
1423 static void eepro100_write2(EEPRO100State
* s
, uint32_t addr
, uint16_t val
)
1425 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1426 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1429 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1433 //~ eepro100_write_status(s, val);
1434 eepro100_acknowledge(s
);
1437 eepro100_write_command(s
, val
);
1438 eepro100_write1(s
, SCBIntmask
, val
>> 8);
1441 eepro100_write_eeprom(s
->eeprom
, val
);
1444 logout("addr=%s val=0x%04x\n", regname(addr
), val
);
1445 missing("unknown word write");
1449 static void eepro100_write4(EEPRO100State
* s
, uint32_t addr
, uint32_t val
)
1451 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1452 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1457 eepro100_write_pointer(s
, val
);
1460 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1461 eepro100_write_port(s
, val
);
1464 eepro100_write_mdi(s
, val
);
1467 logout("addr=%s val=0x%08x\n", regname(addr
), val
);
1468 missing("unknown longword write");
1472 /*****************************************************************************
1476 ****************************************************************************/
1478 static uint32_t ioport_read1(void *opaque
, uint32_t addr
)
1480 EEPRO100State
*s
= opaque
;
1481 //~ logout("addr=%s\n", regname(addr));
1482 return eepro100_read1(s
, addr
- s
->region
[1]);
1485 static uint32_t ioport_read2(void *opaque
, uint32_t addr
)
1487 EEPRO100State
*s
= opaque
;
1488 return eepro100_read2(s
, addr
- s
->region
[1]);
1491 static uint32_t ioport_read4(void *opaque
, uint32_t addr
)
1493 EEPRO100State
*s
= opaque
;
1494 return eepro100_read4(s
, addr
- s
->region
[1]);
1497 static void ioport_write1(void *opaque
, uint32_t addr
, uint32_t val
)
1499 EEPRO100State
*s
= opaque
;
1500 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1501 eepro100_write1(s
, addr
- s
->region
[1], val
);
1504 static void ioport_write2(void *opaque
, uint32_t addr
, uint32_t val
)
1506 EEPRO100State
*s
= opaque
;
1507 eepro100_write2(s
, addr
- s
->region
[1], val
);
1510 static void ioport_write4(void *opaque
, uint32_t addr
, uint32_t val
)
1512 EEPRO100State
*s
= opaque
;
1513 eepro100_write4(s
, addr
- s
->region
[1], val
);
1516 /***********************************************************/
1517 /* PCI EEPRO100 definitions */
1519 static void pci_map(PCIDevice
* pci_dev
, int region_num
,
1520 pcibus_t addr
, pcibus_t size
, int type
)
1522 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1524 TRACE(OTHER
, logout("region %d, addr=0x%08"FMT_PCIBUS
", "
1525 "size=0x%08"FMT_PCIBUS
", type=%d\n",
1526 region_num
, addr
, size
, type
));
1528 assert(region_num
== 1);
1529 register_ioport_write(addr
, size
, 1, ioport_write1
, s
);
1530 register_ioport_read(addr
, size
, 1, ioport_read1
, s
);
1531 register_ioport_write(addr
, size
, 2, ioport_write2
, s
);
1532 register_ioport_read(addr
, size
, 2, ioport_read2
, s
);
1533 register_ioport_write(addr
, size
, 4, ioport_write4
, s
);
1534 register_ioport_read(addr
, size
, 4, ioport_read4
, s
);
1536 s
->region
[region_num
] = addr
;
1539 /*****************************************************************************
1541 * Memory mapped I/O.
1543 ****************************************************************************/
1545 static void pci_mmio_writeb(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1547 EEPRO100State
*s
= opaque
;
1548 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1549 eepro100_write1(s
, addr
, val
);
1552 static void pci_mmio_writew(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1554 EEPRO100State
*s
= opaque
;
1555 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1556 eepro100_write2(s
, addr
, val
);
1559 static void pci_mmio_writel(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1561 EEPRO100State
*s
= opaque
;
1562 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1563 eepro100_write4(s
, addr
, val
);
1566 static uint32_t pci_mmio_readb(void *opaque
, target_phys_addr_t addr
)
1568 EEPRO100State
*s
= opaque
;
1569 //~ logout("addr=%s\n", regname(addr));
1570 return eepro100_read1(s
, addr
);
1573 static uint32_t pci_mmio_readw(void *opaque
, target_phys_addr_t addr
)
1575 EEPRO100State
*s
= opaque
;
1576 //~ logout("addr=%s\n", regname(addr));
1577 return eepro100_read2(s
, addr
);
1580 static uint32_t pci_mmio_readl(void *opaque
, target_phys_addr_t addr
)
1582 EEPRO100State
*s
= opaque
;
1583 //~ logout("addr=%s\n", regname(addr));
1584 return eepro100_read4(s
, addr
);
1587 static CPUWriteMemoryFunc
* const pci_mmio_write
[] = {
1593 static CPUReadMemoryFunc
* const pci_mmio_read
[] = {
1599 static void pci_mmio_map(PCIDevice
* pci_dev
, int region_num
,
1600 pcibus_t addr
, pcibus_t size
, int type
)
1602 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1604 TRACE(OTHER
, logout("region %d, addr=0x%08"FMT_PCIBUS
", "
1605 "size=0x%08"FMT_PCIBUS
", type=%d\n",
1606 region_num
, addr
, size
, type
));
1608 if (region_num
== 0) {
1609 /* Map control / status registers. */
1610 cpu_register_physical_memory(addr
, size
, s
->mmio_index
);
1611 s
->region
[region_num
] = addr
;
1615 static int nic_can_receive(VLANClientState
*nc
)
1617 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1618 TRACE(RXTX
, logout("%p\n", s
));
1619 return get_ru_state(s
) == ru_ready
;
1620 //~ return !eepro100_buffer_full(s);
1623 static ssize_t
nic_receive(VLANClientState
*nc
, const uint8_t * buf
, size_t size
)
1626 * - Magic packets should set bit 30 in power management driver register.
1627 * - Interesting packets should set bit 29 in power management driver register.
1629 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1630 uint16_t rfd_status
= 0xa000;
1631 static const uint8_t broadcast_macaddr
[6] =
1632 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1634 /* TODO: check multiple IA bit. */
1635 if (s
->configuration
[20] & BIT(6)) {
1636 missing("Multiple IA bit");
1640 if (s
->configuration
[8] & 0x80) {
1641 /* CSMA is disabled. */
1642 logout("%p received while CSMA is disabled\n", s
);
1644 } else if (size
< 64 && (s
->configuration
[7] & 1)) {
1645 /* Short frame and configuration byte 7/0 (discard short receive) set:
1646 * Short frame is discarded */
1647 logout("%p received short frame (%zu byte)\n", s
, size
);
1648 s
->statistics
.rx_short_frame_errors
++;
1650 } else if ((size
> MAX_ETH_FRAME_SIZE
+ 4) && !(s
->configuration
[18] & 8)) {
1651 /* Long frame and configuration byte 18/3 (long receive ok) not set:
1652 * Long frames are discarded. */
1653 logout("%p received long frame (%zu byte), ignored\n", s
, size
);
1655 } else if (memcmp(buf
, s
->conf
.macaddr
.a
, 6) == 0) { // !!!
1656 /* Frame matches individual address. */
1657 /* TODO: check configuration byte 15/4 (ignore U/L). */
1658 TRACE(RXTX
, logout("%p received frame for me, len=%zu\n", s
, size
));
1659 } else if (memcmp(buf
, broadcast_macaddr
, 6) == 0) {
1660 /* Broadcast frame. */
1661 TRACE(RXTX
, logout("%p received broadcast, len=%zu\n", s
, size
));
1662 rfd_status
|= 0x0002;
1663 } else if (buf
[0] & 0x01) { // !!!
1664 /* Multicast frame. */
1665 TRACE(RXTX
, logout("%p received multicast, len=%zu\n", s
, size
));
1666 /* TODO: check multicast all bit. */
1667 if (s
->configuration
[21] & BIT(3)) {
1668 missing("Multicast All bit");
1670 int mcast_idx
= compute_mcast_idx(buf
);
1671 if (!(s
->mult
[mcast_idx
>> 3] & (1 << (mcast_idx
& 7)))) {
1674 rfd_status
|= 0x0002;
1675 } else if (s
->configuration
[15] & 1) {
1676 /* Promiscuous: receive all. */
1677 TRACE(RXTX
, logout("%p received frame in promiscuous mode, len=%zu\n", s
, size
));
1678 rfd_status
|= 0x0004;
1680 TRACE(RXTX
, logout("%p received frame, ignored, len=%zu,%s\n", s
, size
,
1681 nic_dump(buf
, size
)));
1685 if (get_ru_state(s
) != ru_ready
) {
1686 /* No resources available. */
1687 logout("no resources, state=%u\n", get_ru_state(s
));
1688 s
->statistics
.rx_resource_errors
++;
1689 //~ assert(!"no resources");
1693 //~ $3 = {status = 0x0, command = 0xc000, link = 0x2d220, rx_buf_addr = 0x207dc, count = 0x0, size = 0x5f8, packet = {0x0 <repeats 1518 times>}}
1695 cpu_physical_memory_read(s
->ru_base
+ s
->ru_offset
, (uint8_t *) & rx
,
1696 offsetof(eepro100_rx_t
, packet
));
1697 uint16_t rfd_command
= le16_to_cpu(rx
.command
);
1698 uint16_t rfd_size
= le16_to_cpu(rx
.size
);
1700 if (size
> rfd_size
) {
1701 logout("Receive buffer (%" PRId16
" bytes) too small for data "
1702 "(%zu bytes); data truncated\n", rfd_size
, size
);
1706 rfd_status
|= 0x0080;
1708 TRACE(OTHER
, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
1709 rfd_command
, rx
.link
, rx
.rx_buf_addr
, rfd_size
));
1710 stw_phys(s
->ru_base
+ s
->ru_offset
+ offsetof(eepro100_rx_t
, status
),
1712 stw_phys(s
->ru_base
+ s
->ru_offset
+ offsetof(eepro100_rx_t
, count
), size
);
1713 /* Early receive interrupt not supported. */
1714 //~ eepro100_er_interrupt(s);
1715 /* Receive CRC Transfer not supported. */
1716 if (s
->configuration
[18] & 4) {
1717 missing("Receive CRC Transfer");
1720 /* TODO: check stripping enable bit. */
1721 //~ assert(!(s->configuration[17] & 1));
1722 cpu_physical_memory_write(s
->ru_base
+ s
->ru_offset
+
1723 offsetof(eepro100_rx_t
, packet
), buf
, size
);
1724 s
->statistics
.rx_good_frames
++;
1725 eepro100_fr_interrupt(s
);
1726 s
->ru_offset
= le32_to_cpu(rx
.link
);
1727 if (rfd_command
& 0x8000) {
1728 /* EL bit is set, so this was the last frame. */
1729 logout("receive: Running out of frames\n");
1730 set_ru_state(s
, ru_suspended
);
1732 if (rfd_command
& 0x4000) {
1734 set_ru_state(s
, ru_suspended
);
1739 static const VMStateDescription vmstate_eepro100
= {
1741 .minimum_version_id
= 2,
1742 .minimum_version_id_old
= 2,
1743 .fields
= (VMStateField
[]) {
1744 VMSTATE_PCI_DEVICE(dev
, EEPRO100State
),
1746 VMSTATE_BUFFER(mult
, EEPRO100State
),
1747 VMSTATE_BUFFER(mem
, EEPRO100State
),
1748 /* Save all members of struct between scb_stat and mem. */
1749 VMSTATE_UINT8(scb_stat
, EEPRO100State
),
1750 VMSTATE_UINT8(int_stat
, EEPRO100State
),
1751 VMSTATE_UNUSED(3*4),
1752 VMSTATE_MACADDR(conf
.macaddr
, EEPRO100State
),
1753 VMSTATE_UNUSED(19*4),
1754 VMSTATE_UINT16_ARRAY(mdimem
, EEPRO100State
, 32),
1755 /* The eeprom should be saved and restored by its own routines. */
1756 VMSTATE_UINT32(device
, EEPRO100State
),
1757 /* TODO check device. */
1758 VMSTATE_UINT32(pointer
, EEPRO100State
),
1759 VMSTATE_UINT32(cu_base
, EEPRO100State
),
1760 VMSTATE_UINT32(cu_offset
, EEPRO100State
),
1761 VMSTATE_UINT32(ru_base
, EEPRO100State
),
1762 VMSTATE_UINT32(ru_offset
, EEPRO100State
),
1763 VMSTATE_UINT32(statsaddr
, EEPRO100State
),
1764 /* Save eepro100_stats_t statistics. */
1765 VMSTATE_UINT32(statistics
.tx_good_frames
, EEPRO100State
),
1766 VMSTATE_UINT32(statistics
.tx_max_collisions
, EEPRO100State
),
1767 VMSTATE_UINT32(statistics
.tx_late_collisions
, EEPRO100State
),
1768 VMSTATE_UINT32(statistics
.tx_underruns
, EEPRO100State
),
1769 VMSTATE_UINT32(statistics
.tx_lost_crs
, EEPRO100State
),
1770 VMSTATE_UINT32(statistics
.tx_deferred
, EEPRO100State
),
1771 VMSTATE_UINT32(statistics
.tx_single_collisions
, EEPRO100State
),
1772 VMSTATE_UINT32(statistics
.tx_multiple_collisions
, EEPRO100State
),
1773 VMSTATE_UINT32(statistics
.tx_total_collisions
, EEPRO100State
),
1774 VMSTATE_UINT32(statistics
.rx_good_frames
, EEPRO100State
),
1775 VMSTATE_UINT32(statistics
.rx_crc_errors
, EEPRO100State
),
1776 VMSTATE_UINT32(statistics
.rx_alignment_errors
, EEPRO100State
),
1777 VMSTATE_UINT32(statistics
.rx_resource_errors
, EEPRO100State
),
1778 VMSTATE_UINT32(statistics
.rx_overrun_errors
, EEPRO100State
),
1779 VMSTATE_UINT32(statistics
.rx_cdt_errors
, EEPRO100State
),
1780 VMSTATE_UINT32(statistics
.rx_short_frame_errors
, EEPRO100State
),
1781 VMSTATE_UINT32(statistics
.fc_xmt_pause
, EEPRO100State
),
1782 VMSTATE_UINT32(statistics
.fc_rcv_pause
, EEPRO100State
),
1783 VMSTATE_UINT32(statistics
.fc_rcv_unsupported
, EEPRO100State
),
1784 VMSTATE_UINT16(statistics
.xmt_tco_frames
, EEPRO100State
),
1785 VMSTATE_UINT16(statistics
.rcv_tco_frames
, EEPRO100State
),
1787 VMSTATE_UINT16(status
, EEPRO100State
),
1789 /* Configuration bytes. */
1790 VMSTATE_BUFFER(configuration
, EEPRO100State
),
1791 VMSTATE_END_OF_LIST()
1795 static void nic_cleanup(VLANClientState
*nc
)
1797 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1802 static int pci_nic_uninit(PCIDevice
*pci_dev
)
1804 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1806 cpu_unregister_io_memory(s
->mmio_index
);
1807 vmstate_unregister(s
->vmstate
, s
);
1808 eeprom93xx_free(s
->eeprom
);
1809 qemu_del_vlan_client(&s
->nic
->nc
);
1813 static NetClientInfo net_eepro100_info
= {
1814 .type
= NET_CLIENT_TYPE_NIC
,
1815 .size
= sizeof(NICState
),
1816 .can_receive
= nic_can_receive
,
1817 .receive
= nic_receive
,
1818 .cleanup
= nic_cleanup
,
1821 static int nic_init(PCIDevice
*pci_dev
, uint32_t device
)
1823 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1825 TRACE(OTHER
, logout("\n"));
1831 /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
1832 * i82559 and later support 64 or 256 word EEPROM. */
1833 s
->eeprom
= eeprom93xx_new(EEPROM_SIZE
);
1835 /* Handler for memory-mapped I/O */
1837 cpu_register_io_memory(pci_mmio_read
, pci_mmio_write
, s
);
1839 pci_register_bar(&s
->dev
, 0, PCI_MEM_SIZE
,
1840 PCI_BASE_ADDRESS_SPACE_MEMORY
|
1841 PCI_BASE_ADDRESS_MEM_PREFETCH
, pci_mmio_map
);
1842 pci_register_bar(&s
->dev
, 1, PCI_IO_SIZE
, PCI_BASE_ADDRESS_SPACE_IO
,
1844 pci_register_bar(&s
->dev
, 2, PCI_FLASH_SIZE
, PCI_BASE_ADDRESS_SPACE_MEMORY
,
1847 qemu_macaddr_default_if_unset(&s
->conf
.macaddr
);
1848 logout("macaddr: %s\n", nic_dump(&s
->macaddr
[0], 6));
1849 assert(s
->region
[1] == 0);
1853 s
->nic
= qemu_new_nic(&net_eepro100_info
, &s
->conf
,
1854 pci_dev
->qdev
.info
->name
, pci_dev
->qdev
.id
, s
);
1856 qemu_format_nic_info_str(&s
->nic
->nc
, s
->conf
.macaddr
.a
);
1857 TRACE(OTHER
, logout("%s\n", s
->nic
->nc
.info_str
));
1859 qemu_register_reset(nic_reset
, s
);
1861 s
->vmstate
= qemu_malloc(sizeof(vmstate_eepro100
));
1862 memcpy(s
->vmstate
, &vmstate_eepro100
, sizeof(vmstate_eepro100
));
1863 s
->vmstate
->name
= s
->nic
->nc
.model
;
1864 vmstate_register(-1, s
->vmstate
, s
);
1866 if (!pci_dev
->qdev
.hotplugged
) {
1867 static int loaded
= 0;
1870 snprintf(fname
, sizeof(fname
), "pxe-%s.bin", s
->nic
->nc
.model
);
1871 rom_add_option(fname
);
1878 static int pci_i82550_init(PCIDevice
*pci_dev
)
1880 return nic_init(pci_dev
, i82550
);
1883 static int pci_i82551_init(PCIDevice
*pci_dev
)
1885 return nic_init(pci_dev
, i82551
);
1888 static int pci_i82557a_init(PCIDevice
*pci_dev
)
1890 return nic_init(pci_dev
, i82557A
);
1893 static int pci_i82557b_init(PCIDevice
*pci_dev
)
1895 return nic_init(pci_dev
, i82557B
);
1898 static int pci_i82557c_init(PCIDevice
*pci_dev
)
1900 return nic_init(pci_dev
, i82557C
);
1903 static int pci_i82558a_init(PCIDevice
*pci_dev
)
1905 return nic_init(pci_dev
, i82558A
);
1908 static int pci_i82558b_init(PCIDevice
*pci_dev
)
1910 return nic_init(pci_dev
, i82558B
);
1913 static int pci_i82559a_init(PCIDevice
*pci_dev
)
1915 return nic_init(pci_dev
, i82559A
);
1918 static int pci_i82559b_init(PCIDevice
*pci_dev
)
1920 return nic_init(pci_dev
, i82559B
);
1923 static int pci_i82559c_init(PCIDevice
*pci_dev
)
1925 return nic_init(pci_dev
, i82559C
);
1928 static int pci_i82559er_init(PCIDevice
*pci_dev
)
1930 return nic_init(pci_dev
, i82559ER
);
1933 static int pci_i82562_init(PCIDevice
*pci_dev
)
1935 return nic_init(pci_dev
, i82562
);
1938 static PCIDeviceInfo eepro100_info
[] = {
1940 .qdev
.name
= "i82550",
1941 .qdev
.size
= sizeof(EEPRO100State
),
1942 .init
= pci_i82550_init
,
1943 .exit
= pci_nic_uninit
,
1944 .qdev
.props
= (Property
[]) {
1945 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1946 DEFINE_PROP_END_OF_LIST(),
1949 .qdev
.name
= "i82551",
1950 .qdev
.size
= sizeof(EEPRO100State
),
1951 .init
= pci_i82551_init
,
1952 .exit
= pci_nic_uninit
,
1953 .qdev
.props
= (Property
[]) {
1954 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1955 DEFINE_PROP_END_OF_LIST(),
1958 .qdev
.name
= "i82557a",
1959 .qdev
.size
= sizeof(EEPRO100State
),
1960 .init
= pci_i82557a_init
,
1961 .exit
= pci_nic_uninit
,
1962 .qdev
.props
= (Property
[]) {
1963 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1964 DEFINE_PROP_END_OF_LIST(),
1967 .qdev
.name
= "i82557b",
1968 .qdev
.size
= sizeof(EEPRO100State
),
1969 .init
= pci_i82557b_init
,
1970 .exit
= pci_nic_uninit
,
1971 .qdev
.props
= (Property
[]) {
1972 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1973 DEFINE_PROP_END_OF_LIST(),
1976 .qdev
.name
= "i82557c",
1977 .qdev
.size
= sizeof(EEPRO100State
),
1978 .init
= pci_i82557c_init
,
1979 .exit
= pci_nic_uninit
,
1980 .qdev
.props
= (Property
[]) {
1981 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1982 DEFINE_PROP_END_OF_LIST(),
1985 .qdev
.name
= "i82558a",
1986 .qdev
.size
= sizeof(EEPRO100State
),
1987 .init
= pci_i82558a_init
,
1988 .exit
= pci_nic_uninit
,
1989 .qdev
.props
= (Property
[]) {
1990 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1991 DEFINE_PROP_END_OF_LIST(),
1994 .qdev
.name
= "i82558b",
1995 .qdev
.size
= sizeof(EEPRO100State
),
1996 .init
= pci_i82558b_init
,
1997 .exit
= pci_nic_uninit
,
1998 .qdev
.props
= (Property
[]) {
1999 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2000 DEFINE_PROP_END_OF_LIST(),
2003 .qdev
.name
= "i82559a",
2004 .qdev
.size
= sizeof(EEPRO100State
),
2005 .init
= pci_i82559a_init
,
2006 .exit
= pci_nic_uninit
,
2007 .qdev
.props
= (Property
[]) {
2008 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2009 DEFINE_PROP_END_OF_LIST(),
2012 .qdev
.name
= "i82559b",
2013 .qdev
.size
= sizeof(EEPRO100State
),
2014 .init
= pci_i82559b_init
,
2015 .exit
= pci_nic_uninit
,
2016 .qdev
.props
= (Property
[]) {
2017 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2018 DEFINE_PROP_END_OF_LIST(),
2021 .qdev
.name
= "i82559c",
2022 .qdev
.size
= sizeof(EEPRO100State
),
2023 .init
= pci_i82559c_init
,
2024 .exit
= pci_nic_uninit
,
2025 .qdev
.props
= (Property
[]) {
2026 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2027 DEFINE_PROP_END_OF_LIST(),
2030 .qdev
.name
= "i82559er",
2031 .qdev
.size
= sizeof(EEPRO100State
),
2032 .init
= pci_i82559er_init
,
2033 .exit
= pci_nic_uninit
,
2034 .qdev
.props
= (Property
[]) {
2035 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2036 DEFINE_PROP_END_OF_LIST(),
2039 .qdev
.name
= "i82562",
2040 .qdev
.size
= sizeof(EEPRO100State
),
2041 .init
= pci_i82562_init
,
2042 .exit
= pci_nic_uninit
,
2043 .qdev
.props
= (Property
[]) {
2044 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2045 DEFINE_PROP_END_OF_LIST(),
2052 static void eepro100_register_devices(void)
2054 pci_qdev_register_many(eepro100_info
);
2057 device_init(eepro100_register_devices
)