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 */
45 #include "eeprom93xx.h"
47 /* Common declarations for all PCI devices. */
49 #define PCI_CONFIG_8(offset, value) \
50 (pci_conf[offset] = (value))
51 #define PCI_CONFIG_16(offset, value) \
52 (*(uint16_t *)&pci_conf[offset] = cpu_to_le16(value))
53 #define PCI_CONFIG_32(offset, value) \
54 (*(uint32_t *)&pci_conf[offset] = cpu_to_le32(value))
58 /* Debug EEPRO100 card. */
60 # define DEBUG_EEPRO100
64 #define logout(fmt, ...) fprintf(stderr, "EE100\t%-24s" fmt, __func__, ## __VA_ARGS__)
66 #define logout(fmt, ...) ((void)0)
69 /* Set flags to 0 to disable debug output. */
70 #define INT 1 /* interrupt related actions */
71 #define MDI 1 /* mdi related actions */
74 #define EEPROM 1 /* eeprom related actions */
76 #define TRACE(flag, command) ((flag) ? (command) : (void)0)
78 #define missing(text) fprintf(stderr, "eepro100: feature is missing in this emulation: " text "\n")
80 #define MAX_ETH_FRAME_SIZE 1514
82 /* This driver supports several different devices which are declared here. */
83 #define i82550 0x82550
84 #define i82551 0x82551
85 #define i82557A 0x82557a
86 #define i82557B 0x82557b
87 #define i82557C 0x82557c
88 #define i82558A 0x82558a
89 #define i82558B 0x82558b
90 #define i82559A 0x82559a
91 #define i82559B 0x82559b
92 #define i82559C 0x82559c
93 #define i82559ER 0x82559e
94 #define i82562 0x82562
96 /* Use 64 word EEPROM. TODO: could be a runtime option. */
97 #define EEPROM_SIZE 64
99 #define PCI_MEM_SIZE (4 * KiB)
100 #define PCI_IO_SIZE 64
101 #define PCI_FLASH_SIZE (128 * KiB)
103 #define BIT(n) (1 << (n))
104 #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
106 /* The SCB accepts the following controls for the Tx and Rx units: */
107 #define CU_NOP 0x0000 /* No operation. */
108 #define CU_START 0x0010 /* CU start. */
109 #define CU_RESUME 0x0020 /* CU resume. */
110 #define CU_STATSADDR 0x0040 /* Load dump counters address. */
111 #define CU_SHOWSTATS 0x0050 /* Dump statistical counters. */
112 #define CU_CMD_BASE 0x0060 /* Load CU base address. */
113 #define CU_DUMPSTATS 0x0070 /* Dump and reset statistical counters. */
114 #define CU_SRESUME 0x00a0 /* CU static resume. */
116 #define RU_NOP 0x0000
117 #define RX_START 0x0001
118 #define RX_RESUME 0x0002
119 #define RX_ABORT 0x0004
120 #define RX_ADDR_LOAD 0x0006
121 #define RX_RESUMENR 0x0007
122 #define INT_MASK 0x0100
123 #define DRVR_INT 0x0200 /* Driver generated interrupt. */
125 /* Offsets to the various registers.
126 All accesses need not be longword aligned. */
127 enum speedo_offsets
{
130 SCBCmd
= 2, /* Rx/Command Unit command and status. */
132 SCBPointer
= 4, /* General purpose pointer. */
133 SCBPort
= 8, /* Misc. commands and operands. */
134 SCBflash
= 12, SCBeeprom
= 14, /* EEPROM and flash memory control. */
135 SCBCtrlMDI
= 16, /* MDI interface control. */
136 SCBEarlyRx
= 20, /* Early receive byte count. */
140 /* A speedo3 transmit buffer descriptor with two buffers... */
144 uint32_t link
; /* void * */
145 uint32_t tbd_array_addr
; /* transmit buffer descriptor array address. */
146 uint16_t tcb_bytes
; /* transmit command block byte count (in lower 14 bits */
147 uint8_t tx_threshold
; /* transmit threshold */
148 uint8_t tbd_count
; /* TBD number */
149 //~ /* This constitutes two "TBD" entries: hdr and data */
150 //~ uint32_t tx_buf_addr0; /* void *, header of frame to be transmitted. */
151 //~ int32_t tx_buf_size0; /* Length of Tx hdr. */
152 //~ uint32_t tx_buf_addr1; /* void *, data to be transmitted. */
153 //~ int32_t tx_buf_size1; /* Length of Tx data. */
156 /* Receive frame descriptor. */
160 uint32_t link
; /* struct RxFD * */
161 uint32_t rx_buf_addr
; /* void * */
164 char packet
[MAX_ETH_FRAME_SIZE
+ 4];
168 uint32_t tx_good_frames
, tx_max_collisions
, tx_late_collisions
,
169 tx_underruns
, tx_lost_crs
, tx_deferred
, tx_single_collisions
,
170 tx_multiple_collisions
, tx_total_collisions
;
171 uint32_t rx_good_frames
, rx_crc_errors
, rx_alignment_errors
,
172 rx_resource_errors
, rx_overrun_errors
, rx_cdt_errors
,
173 rx_short_frame_errors
;
174 uint32_t fc_xmt_pause
, fc_rcv_pause
, fc_rcv_unsupported
;
175 uint16_t xmt_tco_frames
, rcv_tco_frames
;
176 /* TODO: i82559 has six reserved statistics but a total of 24 dwords. */
177 uint32_t reserved
[4];
197 uint8_t mult
[8]; /* multicast mask array */
201 uint8_t scb_stat
; /* SCB stat/ack byte */
202 uint8_t int_stat
; /* PCI interrupt status */
203 /* region must not be saved by nic_save. */
204 uint32_t region
[3]; /* PCI region addresses */
207 uint32_t device
; /* device variant */
209 /* (cu_base + cu_offset) address the next command block in the command block list. */
210 uint32_t cu_base
; /* CU base address */
211 uint32_t cu_offset
; /* CU address offset */
212 /* (ru_base + ru_offset) address the RFD in the Receive Frame Area. */
213 uint32_t ru_base
; /* RU base address */
214 uint32_t ru_offset
; /* RU address offset */
215 uint32_t statsaddr
; /* pointer to eepro100_stats_t */
217 /* Temporary status information (no need to save these values),
218 * used while processing CU commands. */
219 eepro100_tx_t tx
; /* transmit buffer descriptor */
220 uint32_t cb_address
; /* = cu_base + cu_offset */
222 /* Statistical counters. Also used for wake-up packet (i82559). */
223 eepro100_stats_t statistics
;
229 /* Configuration bytes. */
230 uint8_t configuration
[22];
232 /* Data in mem is always in the byte order of the controller (le). */
233 uint8_t mem
[PCI_MEM_SIZE
];
234 /* vmstate for each particular nic */
235 VMStateDescription
*vmstate
;
237 /* Quasi static device properties (no need to save them). */
239 bool has_extended_tcb_support
;
242 /* Default values for MDI (PHY) registers */
243 static const uint16_t eepro100_mdi_default
[] = {
244 /* MDI Registers 0 - 6, 7 */
245 0x3000, 0x780d, 0x02a8, 0x0154, 0x05e1, 0x0000, 0x0000, 0x0000,
246 /* MDI Registers 8 - 15 */
247 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
248 /* MDI Registers 16 - 31 */
249 0x0003, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
250 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
253 /* Readonly mask for MDI (PHY) registers */
254 static const uint16_t eepro100_mdi_mask
[] = {
255 0x0000, 0xffff, 0xffff, 0xffff, 0xc01f, 0xffff, 0xffff, 0x0000,
256 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
257 0x0fff, 0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
258 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
262 static void stl_le_phys(target_phys_addr_t addr
, uint32_t val
)
264 val
= cpu_to_le32(val
);
265 cpu_physical_memory_write(addr
, (const uint8_t *)&val
, sizeof(val
));
268 #define POLYNOMIAL 0x04c11db6
272 static unsigned compute_mcast_idx(const uint8_t * ep
)
279 for (i
= 0; i
< 6; i
++) {
281 for (j
= 0; j
< 8; j
++) {
282 carry
= ((crc
& 0x80000000L
) ? 1 : 0) ^ (b
& 0x01);
286 crc
= ((crc
^ POLYNOMIAL
) | carry
);
290 return (crc
& BITS(7, 2)) >> 2;
293 #if defined(DEBUG_EEPRO100)
294 static const char *nic_dump(const uint8_t * buf
, unsigned size
)
296 static char dump
[3 * 16 + 1];
302 p
+= sprintf(p
, " %02x", *buf
++);
306 #endif /* DEBUG_EEPRO100 */
309 stat_ack_not_ours
= 0x00,
310 stat_ack_sw_gen
= 0x04,
312 stat_ack_cu_idle
= 0x20,
313 stat_ack_frame_rx
= 0x40,
314 stat_ack_cu_cmd_done
= 0x80,
315 stat_ack_not_present
= 0xFF,
316 stat_ack_rx
= (stat_ack_sw_gen
| stat_ack_rnr
| stat_ack_frame_rx
),
317 stat_ack_tx
= (stat_ack_cu_idle
| stat_ack_cu_cmd_done
),
320 static void disable_interrupt(EEPRO100State
* s
)
323 TRACE(INT
, logout("interrupt disabled\n"));
324 qemu_irq_lower(s
->dev
.irq
[0]);
329 static void enable_interrupt(EEPRO100State
* s
)
332 TRACE(INT
, logout("interrupt enabled\n"));
333 qemu_irq_raise(s
->dev
.irq
[0]);
338 static void eepro100_acknowledge(EEPRO100State
* s
)
340 s
->scb_stat
&= ~s
->mem
[SCBAck
];
341 s
->mem
[SCBAck
] = s
->scb_stat
;
342 if (s
->scb_stat
== 0) {
343 disable_interrupt(s
);
347 static void eepro100_interrupt(EEPRO100State
* s
, uint8_t stat
)
349 uint8_t mask
= ~s
->mem
[SCBIntmask
];
350 s
->mem
[SCBAck
] |= stat
;
351 stat
= s
->scb_stat
= s
->mem
[SCBAck
];
352 stat
&= (mask
| 0x0f);
353 //~ stat &= (~s->mem[SCBIntmask] | 0x0xf);
354 if (stat
&& (mask
& 0x01)) {
355 /* SCB mask and SCB Bit M do not disable interrupt. */
357 } else if (s
->int_stat
) {
358 disable_interrupt(s
);
362 static void eepro100_cx_interrupt(EEPRO100State
* s
)
364 /* CU completed action command. */
365 /* Transmit not ok (82557 only, not in emulation). */
366 eepro100_interrupt(s
, 0x80);
369 static void eepro100_cna_interrupt(EEPRO100State
* s
)
371 /* CU left the active state. */
372 eepro100_interrupt(s
, 0x20);
375 static void eepro100_fr_interrupt(EEPRO100State
* s
)
377 /* RU received a complete frame. */
378 eepro100_interrupt(s
, 0x40);
382 static void eepro100_rnr_interrupt(EEPRO100State
* s
)
384 /* RU is not ready. */
385 eepro100_interrupt(s
, 0x10);
389 static void eepro100_mdi_interrupt(EEPRO100State
* s
)
391 /* MDI completed read or write cycle. */
392 eepro100_interrupt(s
, 0x08);
395 static void eepro100_swi_interrupt(EEPRO100State
* s
)
397 /* Software has requested an interrupt. */
398 eepro100_interrupt(s
, 0x04);
402 static void eepro100_fcp_interrupt(EEPRO100State
* s
)
404 /* Flow control pause interrupt (82558 and later). */
405 eepro100_interrupt(s
, 0x01);
409 static void pci_reset(EEPRO100State
* s
)
411 uint32_t device
= s
->device
;
412 uint8_t *pci_conf
= s
->dev
.config
;
413 bool power_management
= 1;
415 TRACE(OTHER
, logout("%p\n", s
));
418 pci_config_set_vendor_id(pci_conf
, PCI_VENDOR_ID_INTEL
);
419 /* PCI Device ID depends on device and is set below. */
421 /* TODO: this is the default, do not override. */
422 PCI_CONFIG_16(PCI_COMMAND
, 0x0000);
424 /* TODO: Value at RST# should be 0. */
425 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
| PCI_STATUS_FAST_BACK
);
426 /* PCI Revision ID */
427 PCI_CONFIG_8(PCI_REVISION_ID
, 0x08);
428 /* TODO: this is the default, do not override. */
430 PCI_CONFIG_8(PCI_CLASS_PROG
, 0x00);
431 pci_config_set_class(pci_conf
, PCI_CLASS_NETWORK_ETHERNET
);
432 /* PCI Cache Line Size */
433 /* check cache line size!!! */
434 //~ PCI_CONFIG_8(0x0c, 0x00);
435 /* PCI Latency Timer */
436 PCI_CONFIG_8(PCI_LATENCY_TIMER
, 0x20); // latency timer = 32 clocks
437 /* PCI Header Type */
438 /* BIST (built-in self test) */
439 #if defined(TARGET_I386)
440 // !!! workaround for buggy bios
441 //~ #define PCI_BASE_ADDRESS_MEM_PREFETCH 0
444 /* PCI Base Address Registers */
445 /* CSR Memory Mapped Base Address */
446 PCI_CONFIG_32(PCI_BASE_ADDRESS_0
,
447 PCI_BASE_ADDRESS_SPACE_MEMORY
|
448 PCI_BASE_ADDRESS_MEM_PREFETCH
);
449 /* CSR I/O Mapped Base Address */
450 PCI_CONFIG_32(PCI_BASE_ADDRESS_1
, PCI_BASE_ADDRESS_SPACE_IO
);
452 /* Flash Memory Mapped Base Address */
453 PCI_CONFIG_32(PCI_BASE_ADDRESS_2
,
454 0xfffe0000 | PCI_BASE_ADDRESS_SPACE_MEMORY
);
457 /* Expansion ROM Base Address (depends on boot disable!!!) */
458 /* TODO: not needed, set when BAR is registered */
459 PCI_CONFIG_32(PCI_ROM_ADDRESS
, PCI_BASE_ADDRESS_SPACE_MEMORY
);
460 /* Capability Pointer */
461 /* TODO: revisions with power_management 1 use this but
462 * do not set new capability list bit in status register. */
463 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0xdc);
466 /* TODO: RST# value should be 0 */
467 PCI_CONFIG_8(PCI_INTERRUPT_PIN
, 1); // interrupt pin 0
469 PCI_CONFIG_8(PCI_MIN_GNT
, 0x08);
470 /* Maximum Latency */
471 PCI_CONFIG_8(PCI_MAX_LAT
, 0x18);
475 // TODO: check device id.
476 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
477 /* Revision ID: 0x0c, 0x0d, 0x0e. */
478 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0e);
479 // TODO: check size of statistical counters.
481 // TODO: check extended tcb support.
482 s
->has_extended_tcb_support
= 1;
485 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
486 /* Revision ID: 0x0f, 0x10. */
487 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0f);
488 // TODO: check size of statistical counters.
490 s
->has_extended_tcb_support
= 1;
493 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
494 PCI_CONFIG_8(PCI_REVISION_ID
, 0x01);
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
, 0x02);
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_8(PCI_REVISION_ID
, 0x03);
507 PCI_CONFIG_8(PCI_CAPABILITY_LIST
, 0x00);
508 power_management
= 0;
511 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
512 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
513 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
514 PCI_CONFIG_8(PCI_REVISION_ID
, 0x04);
516 s
->has_extended_tcb_support
= 1;
519 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
520 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
521 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
522 PCI_CONFIG_8(PCI_REVISION_ID
, 0x05);
524 s
->has_extended_tcb_support
= 1;
527 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
528 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
529 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
530 PCI_CONFIG_8(PCI_REVISION_ID
, 0x06);
532 s
->has_extended_tcb_support
= 1;
535 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
536 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
537 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
538 PCI_CONFIG_8(PCI_REVISION_ID
, 0x07);
540 s
->has_extended_tcb_support
= 1;
543 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82557
);
544 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
545 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
546 PCI_CONFIG_8(PCI_REVISION_ID
, 0x08);
547 // TODO: Windows wants revision id 0x0c.
548 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0c);
550 PCI_CONFIG_16(PCI_SUBSYSTEM_VENDOR_ID
, 0x8086);
551 PCI_CONFIG_16(PCI_SUBSYSTEM_ID
, 0x0040);
554 s
->has_extended_tcb_support
= 1;
557 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
558 PCI_CONFIG_16(PCI_STATUS
, PCI_STATUS_DEVSEL_MEDIUM
|
559 PCI_STATUS_FAST_BACK
| PCI_STATUS_CAP_LIST
);
560 PCI_CONFIG_8(PCI_REVISION_ID
, 0x09);
562 s
->has_extended_tcb_support
= 1;
565 // TODO: check device id.
566 pci_config_set_device_id(pci_conf
, PCI_DEVICE_ID_INTEL_82551IT
);
567 /* TODO: wrong revision id. */
568 PCI_CONFIG_8(PCI_REVISION_ID
, 0x0e);
570 s
->has_extended_tcb_support
= 1;
573 logout("Device %X is undefined!\n", device
);
576 s
->configuration
[6] |= BIT(5);
578 if (s
->stats_size
== 80) {
579 /* TODO: check TCO Statistical Counters bit. Documentation not clear. */
580 if (s
->configuration
[6] & BIT(2)) {
581 /* TCO statistical counters. */
582 assert(s
->configuration
[6] & BIT(5));
584 if (s
->configuration
[6] & BIT(5)) {
585 /* No extended statistical counters, i82557 compatible. */
588 /* i82558 compatible. */
593 if (s
->configuration
[6] & BIT(5)) {
594 /* No extended statistical counters. */
598 assert(s
->stats_size
> 0 && s
->stats_size
<= sizeof(s
->statistics
));
600 if (power_management
) {
601 /* Power Management Capabilities */
602 PCI_CONFIG_8(0xdc, 0x01);
603 /* Next Item Pointer */
605 PCI_CONFIG_16(0xde, 0x7e21);
606 /* TODO: Power Management Control / Status. */
607 /* TODO: Ethernet Power Consumption Registers (i82559 and later). */
611 if (device
== i82557C
|| device
== i82558B
|| device
== i82559C
) {
612 // TODO: get vendor id from EEPROM for i82557C or later.
613 // TODO: get device id from EEPROM for i82557C or later.
614 // TODO: status bit 4 can be disabled by EEPROM for i82558, i82559.
615 // TODO: header type is determined by EEPROM for i82559.
616 // TODO: get subsystem id from EEPROM for i82557C or later.
617 // TODO: get subsystem vendor id from EEPROM for i82557C or later.
618 // TODO: exp. rom baddr depends on a bit in EEPROM for i82558 or later.
619 // TODO: capability pointer depends on EEPROM for i82558.
620 logout("Get device id and revision from EEPROM!!!\n");
622 #endif /* EEPROM_SIZE > 0 */
625 static void nic_selective_reset(EEPRO100State
* s
)
628 uint16_t *eeprom_contents
= eeprom93xx_data(s
->eeprom
);
629 //~ eeprom93xx_reset(s->eeprom);
630 memcpy(eeprom_contents
, s
->conf
.macaddr
.a
, 6);
631 eeprom_contents
[0xa] = 0x4000;
632 if (s
->device
== i82557B
|| s
->device
== i82557C
)
633 eeprom_contents
[5] = 0x0100;
635 for (i
= 0; i
< EEPROM_SIZE
- 1; i
++) {
636 sum
+= eeprom_contents
[i
];
638 eeprom_contents
[EEPROM_SIZE
- 1] = 0xbaba - sum
;
639 TRACE(EEPROM
, logout("checksum=0x%04x\n", eeprom_contents
[EEPROM_SIZE
- 1]));
641 memset(s
->mem
, 0, sizeof(s
->mem
));
642 uint32_t val
= BIT(21);
643 memcpy(&s
->mem
[SCBCtrlMDI
], &val
, sizeof(val
));
645 assert(sizeof(s
->mdimem
) == sizeof(eepro100_mdi_default
));
646 memcpy(&s
->mdimem
[0], &eepro100_mdi_default
[0], sizeof(s
->mdimem
));
649 static void nic_reset(void *opaque
)
651 EEPRO100State
*s
= opaque
;
652 TRACE(OTHER
, logout("%p\n", s
));
653 /* TODO: Clearing of multicast table for selective reset, too? */
654 memset(&s
->mult
[0], 0, sizeof(s
->mult
));
655 nic_selective_reset(s
);
658 #if defined(DEBUG_EEPRO100)
659 static const char * const e100_reg
[PCI_IO_SIZE
/ 4] = {
663 "EEPROM/Flash Control",
665 "Receive DMA Byte Count",
667 "General Status/Control"
670 static char *regname(uint32_t addr
)
673 if (addr
< PCI_IO_SIZE
) {
674 const char *r
= e100_reg
[addr
/ 4];
676 snprintf(buf
, sizeof(buf
), "%s+%u", r
, addr
% 4);
678 snprintf(buf
, sizeof(buf
), "0x%02x", addr
);
681 snprintf(buf
, sizeof(buf
), "??? 0x%08x", addr
);
685 #endif /* DEBUG_EEPRO100 */
688 static uint16_t eepro100_read_status(EEPRO100State
* s
)
690 uint16_t val
= s
->status
;
691 TRACE(OTHER
, logout("val=0x%04x\n", val
));
695 static void eepro100_write_status(EEPRO100State
* s
, uint16_t val
)
697 TRACE(OTHER
, logout("val=0x%04x\n", val
));
702 /*****************************************************************************
706 ****************************************************************************/
709 static uint16_t eepro100_read_command(EEPRO100State
* s
)
711 uint16_t val
= 0xffff;
712 //~ TRACE(OTHER, logout("val=0x%04x\n", val));
717 /* Commands that can be put in a command list entry. */
722 CmdMulticastList
= 3,
724 CmdTDR
= 5, /* load microcode */
728 /* And some extra flags: */
729 CmdSuspend
= 0x4000, /* Suspend after completion. */
730 CmdIntr
= 0x2000, /* Interrupt after completion. */
731 CmdTxFlex
= 0x0008, /* Use "Flexible mode" for CmdTx command. */
734 static cu_state_t
get_cu_state(EEPRO100State
* s
)
736 return ((s
->mem
[SCBStatus
] >> 6) & 0x03);
739 static void set_cu_state(EEPRO100State
* s
, cu_state_t state
)
741 s
->mem
[SCBStatus
] = (s
->mem
[SCBStatus
] & 0x3f) + (state
<< 6);
744 static ru_state_t
get_ru_state(EEPRO100State
* s
)
746 return ((s
->mem
[SCBStatus
] >> 2) & 0x0f);
749 static void set_ru_state(EEPRO100State
* s
, ru_state_t state
)
751 s
->mem
[SCBStatus
] = (s
->mem
[SCBStatus
] & 0xc3) + (state
<< 2);
754 static void dump_statistics(EEPRO100State
* s
)
756 /* Dump statistical data. Most data is never changed by the emulation
757 * and always 0, so we first just copy the whole block and then those
758 * values which really matter.
759 * Number of data should check configuration!!!
761 cpu_physical_memory_write(s
->statsaddr
,
762 (uint8_t *) & s
->statistics
, s
->stats_size
);
763 stl_le_phys(s
->statsaddr
+ 0, s
->statistics
.tx_good_frames
);
764 stl_le_phys(s
->statsaddr
+ 36, s
->statistics
.rx_good_frames
);
765 stl_le_phys(s
->statsaddr
+ 48, s
->statistics
.rx_resource_errors
);
766 stl_le_phys(s
->statsaddr
+ 60, s
->statistics
.rx_short_frame_errors
);
767 //~ stw_le_phys(s->statsaddr + 76, s->statistics.xmt_tco_frames);
768 //~ stw_le_phys(s->statsaddr + 78, s->statistics.rcv_tco_frames);
769 //~ missing("CU dump statistical counters");
772 static void tx_command(EEPRO100State
*s
)
774 uint32_t tbd_array
= le32_to_cpu(s
->tx
.tbd_array_addr
);
775 uint16_t tcb_bytes
= (le16_to_cpu(s
->tx
.tcb_bytes
) & 0x3fff);
776 /* Sends larger than MAX_ETH_FRAME_SIZE are allowed, up to 2600 bytes. */
779 uint32_t tbd_address
= s
->cb_address
+ 0x10;
781 ("transmit, TBD array address 0x%08x, TCB byte count 0x%04x, TBD count %u\n",
782 tbd_array
, tcb_bytes
, s
->tx
.tbd_count
));
784 if (tcb_bytes
> 2600) {
785 logout("TCB byte count too large, using 2600\n");
788 if (!((tcb_bytes
> 0) || (tbd_array
!= 0xffffffff))) {
790 ("illegal values of TBD array address and TCB byte count!\n");
792 assert(tcb_bytes
<= sizeof(buf
));
793 while (size
< tcb_bytes
) {
794 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
795 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
796 //~ uint16_t tx_buffer_el = lduw_phys(tbd_address + 6);
799 ("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
800 tx_buffer_address
, tx_buffer_size
));
801 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
802 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
804 size
+= tx_buffer_size
;
806 if (tbd_array
== 0xffffffff) {
807 /* Simplified mode. Was already handled by code above. */
810 uint8_t tbd_count
= 0;
811 if (s
->has_extended_tcb_support
&& !(s
->configuration
[6] & BIT(4))) {
812 /* Extended Flexible TCB. */
813 for (; tbd_count
< 2; tbd_count
++) {
814 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
815 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
816 uint16_t tx_buffer_el
= lduw_phys(tbd_address
+ 6);
819 ("TBD (extended flexible mode): buffer address 0x%08x, size 0x%04x\n",
820 tx_buffer_address
, tx_buffer_size
));
821 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
822 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
824 size
+= tx_buffer_size
;
825 if (tx_buffer_el
& 1) {
830 tbd_address
= tbd_array
;
831 for (; tbd_count
< s
->tx
.tbd_count
; tbd_count
++) {
832 uint32_t tx_buffer_address
= ldl_phys(tbd_address
);
833 uint16_t tx_buffer_size
= lduw_phys(tbd_address
+ 4);
834 uint16_t tx_buffer_el
= lduw_phys(tbd_address
+ 6);
837 ("TBD (flexible mode): buffer address 0x%08x, size 0x%04x\n",
838 tx_buffer_address
, tx_buffer_size
));
839 tx_buffer_size
= MIN(tx_buffer_size
, sizeof(buf
) - size
);
840 cpu_physical_memory_read(tx_buffer_address
, &buf
[size
],
842 size
+= tx_buffer_size
;
843 if (tx_buffer_el
& 1) {
848 TRACE(RXTX
, logout("%p sending frame, len=%d,%s\n", s
, size
, nic_dump(buf
, size
)));
849 qemu_send_packet(&s
->nic
->nc
, buf
, size
);
850 s
->statistics
.tx_good_frames
++;
851 /* Transmit with bad status would raise an CX/TNO interrupt.
852 * (82557 only). Emulation never has bad status. */
853 //~ eepro100_cx_interrupt(s);
856 static void set_multicast_list(EEPRO100State
*s
)
858 uint16_t multicast_count
= s
->tx
.tbd_array_addr
& BITS(13, 0);
860 memset(&s
->mult
[0], 0, sizeof(s
->mult
));
861 TRACE(OTHER
, logout("multicast list, multicast count = %u\n", multicast_count
));
862 for (i
= 0; i
< multicast_count
; i
+= 6) {
863 uint8_t multicast_addr
[6];
864 cpu_physical_memory_read(s
->cb_address
+ 10 + i
, multicast_addr
, 6);
865 TRACE(OTHER
, logout("multicast entry %s\n", nic_dump(multicast_addr
, 6)));
866 unsigned mcast_idx
= compute_mcast_idx(multicast_addr
);
867 assert(mcast_idx
< 64);
868 s
->mult
[mcast_idx
>> 3] |= (1 << (mcast_idx
& 7));
872 static void action_command(EEPRO100State
*s
)
875 s
->cb_address
= s
->cu_base
+ s
->cu_offset
;
876 cpu_physical_memory_read(s
->cb_address
, (uint8_t *)&s
->tx
, sizeof(s
->tx
));
877 uint16_t status
= le16_to_cpu(s
->tx
.status
);
878 uint16_t command
= le16_to_cpu(s
->tx
.command
);
879 logout("val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n",
880 status
, command
, s
->tx
.link
);
881 bool bit_el
= ((command
& 0x8000) != 0);
882 bool bit_s
= ((command
& 0x4000) != 0);
883 bool bit_i
= ((command
& 0x2000) != 0);
884 bool bit_nc
= ((command
& 0x0010) != 0);
886 //~ bool bit_sf = ((command & 0x0008) != 0);
887 uint16_t cmd
= command
& 0x0007;
888 s
->cu_offset
= le32_to_cpu(s
->tx
.link
);
894 cpu_physical_memory_read(s
->cb_address
+ 8, &s
->conf
.macaddr
.a
[0], 6);
895 TRACE(OTHER
, logout("macaddr: %s\n", nic_dump(&s
->conf
.macaddr
.a
[0], 6)));
898 cpu_physical_memory_read(s
->cb_address
+ 8, &s
->configuration
[0],
899 sizeof(s
->configuration
));
900 TRACE(OTHER
, logout("configuration: %s\n", nic_dump(&s
->configuration
[0], 16)));
902 case CmdMulticastList
:
903 set_multicast_list(s
);
907 missing("CmdTx: NC = 0");
914 TRACE(OTHER
, logout("load microcode\n"));
915 /* Starting with offset 8, the command contains
916 * 64 dwords microcode which we just ignore here. */
919 missing("undefined command");
923 /* Write new status. */
924 stw_phys(s
->cb_address
, status
| 0x8000 | (success
? 0x2000 : 0));
926 /* CU completed action. */
927 eepro100_cx_interrupt(s
);
930 /* CU becomes idle. Terminate command loop. */
931 set_cu_state(s
, cu_idle
);
932 eepro100_cna_interrupt(s
);
935 /* CU becomes suspended. Terminate command loop. */
936 set_cu_state(s
, cu_suspended
);
937 eepro100_cna_interrupt(s
);
940 /* More entries in list. */
941 TRACE(OTHER
, logout("CU list with at least one more entry\n"));
944 TRACE(OTHER
, logout("CU list empty\n"));
945 /* List is empty. Now CU is idle or suspended. */
948 static void eepro100_cu_command(EEPRO100State
* s
, uint8_t val
)
955 if (get_cu_state(s
) != cu_idle
) {
956 /* Intel documentation says that CU must be idle for the CU
957 * start command. Intel driver for Linux also starts the CU
958 * from suspended state. */
959 logout("CU state is %u, should be %u\n", get_cu_state(s
), cu_idle
);
960 //~ assert(!"wrong CU state");
962 set_cu_state(s
, cu_active
);
963 s
->cu_offset
= s
->pointer
;
967 if (get_cu_state(s
) != cu_suspended
) {
968 logout("bad CU resume from CU state %u\n", get_cu_state(s
));
969 /* Workaround for bad Linux eepro100 driver which resumes
970 * from idle state. */
971 //~ missing("cu resume");
972 set_cu_state(s
, cu_suspended
);
974 if (get_cu_state(s
) == cu_suspended
) {
975 TRACE(OTHER
, logout("CU resuming\n"));
976 set_cu_state(s
, cu_active
);
981 /* Load dump counters address. */
982 s
->statsaddr
= s
->pointer
;
983 TRACE(OTHER
, logout("val=0x%02x (status address)\n", val
));
986 /* Dump statistical counters. */
987 TRACE(OTHER
, logout("val=0x%02x (dump stats)\n", val
));
989 stl_le_phys(s
->statsaddr
+ s
->stats_size
, 0xa005);
993 TRACE(OTHER
, logout("val=0x%02x (CU base address)\n", val
));
994 s
->cu_base
= s
->pointer
;
997 /* Dump and reset statistical counters. */
998 TRACE(OTHER
, logout("val=0x%02x (dump stats and reset)\n", val
));
1000 stl_le_phys(s
->statsaddr
+ s
->stats_size
, 0xa007);
1001 memset(&s
->statistics
, 0, sizeof(s
->statistics
));
1004 /* CU static resume. */
1005 missing("CU static resume");
1008 missing("Undefined CU command");
1012 static void eepro100_ru_command(EEPRO100State
* s
, uint8_t val
)
1020 if (get_ru_state(s
) != ru_idle
) {
1021 logout("RU state is %u, should be %u\n", get_ru_state(s
), ru_idle
);
1022 //~ assert(!"wrong RU state");
1024 set_ru_state(s
, ru_ready
);
1025 s
->ru_offset
= s
->pointer
;
1026 TRACE(OTHER
, logout("val=0x%02x (rx start)\n", val
));
1030 if (get_ru_state(s
) != ru_suspended
) {
1031 logout("RU state is %u, should be %u\n", get_ru_state(s
),
1033 //~ assert(!"wrong RU state");
1035 set_ru_state(s
, ru_ready
);
1039 TRACE(OTHER
, logout("val=0x%02x (RU base address)\n", val
));
1040 s
->ru_base
= s
->pointer
;
1043 logout("val=0x%02x (undefined RU command)\n", val
);
1044 missing("Undefined SU command");
1048 static void eepro100_write_command(EEPRO100State
* s
, uint8_t val
)
1050 eepro100_ru_command(s
, val
& 0x0f);
1051 eepro100_cu_command(s
, val
& 0xf0);
1053 TRACE(OTHER
, logout("val=0x%02x\n", val
));
1055 /* Clear command byte after command was accepted. */
1059 /*****************************************************************************
1063 ****************************************************************************/
1065 #define EEPROM_CS 0x02
1066 #define EEPROM_SK 0x01
1067 #define EEPROM_DI 0x04
1068 #define EEPROM_DO 0x08
1070 static uint16_t eepro100_read_eeprom(EEPRO100State
* s
)
1073 memcpy(&val
, &s
->mem
[SCBeeprom
], sizeof(val
));
1074 if (eeprom93xx_read(s
->eeprom
)) {
1079 TRACE(EEPROM
, logout("val=0x%04x\n", val
));
1083 static void eepro100_write_eeprom(eeprom_t
* eeprom
, uint8_t val
)
1085 TRACE(EEPROM
, logout("val=0x%02x\n", val
));
1087 /* mask unwriteable bits */
1088 //~ val = SET_MASKED(val, 0x31, eeprom->value);
1090 int eecs
= ((val
& EEPROM_CS
) != 0);
1091 int eesk
= ((val
& EEPROM_SK
) != 0);
1092 int eedi
= ((val
& EEPROM_DI
) != 0);
1093 eeprom93xx_write(eeprom
, eecs
, eesk
, eedi
);
1096 static void eepro100_write_pointer(EEPRO100State
* s
, uint32_t val
)
1098 s
->pointer
= le32_to_cpu(val
);
1099 TRACE(OTHER
, logout("val=0x%08x\n", val
));
1102 /*****************************************************************************
1106 ****************************************************************************/
1108 #if defined(DEBUG_EEPRO100)
1109 static const char * const mdi_op_name
[] = {
1116 static const char * const mdi_reg_name
[] = {
1119 "PHY Identification (Word 1)",
1120 "PHY Identification (Word 2)",
1121 "Auto-Negotiation Advertisement",
1122 "Auto-Negotiation Link Partner Ability",
1123 "Auto-Negotiation Expansion"
1126 static const char *reg2name(uint8_t reg
)
1128 static char buffer
[10];
1129 const char *p
= buffer
;
1130 if (reg
< ARRAY_SIZE(mdi_reg_name
)) {
1131 p
= mdi_reg_name
[reg
];
1133 snprintf(buffer
, sizeof(buffer
), "reg=0x%02x", reg
);
1137 #endif /* DEBUG_EEPRO100 */
1139 static uint32_t eepro100_read_mdi(EEPRO100State
* s
)
1142 memcpy(&val
, &s
->mem
[0x10], sizeof(val
));
1144 #ifdef DEBUG_EEPRO100
1145 uint8_t raiseint
= (val
& BIT(29)) >> 29;
1146 uint8_t opcode
= (val
& BITS(27, 26)) >> 26;
1147 uint8_t phy
= (val
& BITS(25, 21)) >> 21;
1148 uint8_t reg
= (val
& BITS(20, 16)) >> 16;
1149 uint16_t data
= (val
& BITS(15, 0));
1151 /* Emulation takes no time to finish MDI transaction. */
1153 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1154 val
, raiseint
, mdi_op_name
[opcode
], phy
,
1155 reg2name(reg
), data
));
1159 static void eepro100_write_mdi(EEPRO100State
* s
, uint32_t val
)
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));
1166 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1167 val
, raiseint
, mdi_op_name
[opcode
], phy
, reg2name(reg
), data
));
1169 /* Unsupported PHY address. */
1170 //~ logout("phy must be 1 but is %u\n", phy);
1172 } else if (opcode
!= 1 && opcode
!= 2) {
1173 /* Unsupported opcode. */
1174 logout("opcode must be 1 or 2 but is %u\n", opcode
);
1176 } else if (reg
> 6) {
1177 /* Unsupported register. */
1178 logout("register must be 0...6 but is %u\n", reg
);
1181 TRACE(MDI
, logout("val=0x%08x (int=%u, %s, phy=%u, %s, data=0x%04x\n",
1182 val
, raiseint
, mdi_op_name
[opcode
], phy
,
1183 reg2name(reg
), data
));
1187 case 0: /* Control Register */
1188 if (data
& 0x8000) {
1189 /* Reset status and control registers to default. */
1190 s
->mdimem
[0] = eepro100_mdi_default
[0];
1191 s
->mdimem
[1] = eepro100_mdi_default
[1];
1192 data
= s
->mdimem
[reg
];
1194 /* Restart Auto Configuration = Normal Operation */
1198 case 1: /* Status Register */
1199 missing("not writable");
1200 data
= s
->mdimem
[reg
];
1202 case 2: /* PHY Identification Register (Word 1) */
1203 case 3: /* PHY Identification Register (Word 2) */
1204 missing("not implemented");
1206 case 4: /* Auto-Negotiation Advertisement Register */
1207 case 5: /* Auto-Negotiation Link Partner Ability Register */
1209 case 6: /* Auto-Negotiation Expansion Register */
1211 missing("not implemented");
1213 s
->mdimem
[reg
] = data
;
1214 } else if (opcode
== 2) {
1217 case 0: /* Control Register */
1218 if (data
& 0x8000) {
1219 /* Reset status and control registers to default. */
1220 s
->mdimem
[0] = eepro100_mdi_default
[0];
1221 s
->mdimem
[1] = eepro100_mdi_default
[1];
1224 case 1: /* Status Register */
1225 s
->mdimem
[reg
] |= 0x0020;
1227 case 2: /* PHY Identification Register (Word 1) */
1228 case 3: /* PHY Identification Register (Word 2) */
1229 case 4: /* Auto-Negotiation Advertisement Register */
1231 case 5: /* Auto-Negotiation Link Partner Ability Register */
1232 s
->mdimem
[reg
] = 0x41fe;
1234 case 6: /* Auto-Negotiation Expansion Register */
1235 s
->mdimem
[reg
] = 0x0001;
1238 data
= s
->mdimem
[reg
];
1240 /* Emulation takes no time to finish MDI transaction.
1241 * Set MDI bit in SCB status register. */
1242 s
->mem
[SCBAck
] |= 0x08;
1245 eepro100_mdi_interrupt(s
);
1248 val
= (val
& 0xffff0000) + data
;
1249 memcpy(&s
->mem
[0x10], &val
, sizeof(val
));
1252 /*****************************************************************************
1256 ****************************************************************************/
1258 #define PORT_SOFTWARE_RESET 0
1259 #define PORT_SELFTEST 1
1260 #define PORT_SELECTIVE_RESET 2
1262 #define PORT_SELECTION_MASK 3
1265 uint32_t st_sign
; /* Self Test Signature */
1266 uint32_t st_result
; /* Self Test Results */
1267 } eepro100_selftest_t
;
1269 static uint32_t eepro100_read_port(EEPRO100State
* s
)
1274 static void eepro100_write_port(EEPRO100State
* s
, uint32_t val
)
1276 val
= le32_to_cpu(val
);
1277 uint32_t address
= (val
& ~PORT_SELECTION_MASK
);
1278 uint8_t selection
= (val
& PORT_SELECTION_MASK
);
1279 switch (selection
) {
1280 case PORT_SOFTWARE_RESET
:
1284 TRACE(OTHER
, logout("selftest address=0x%08x\n", address
));
1285 eepro100_selftest_t data
;
1286 cpu_physical_memory_read(address
, (uint8_t *) & data
, sizeof(data
));
1287 data
.st_sign
= 0xffffffff;
1289 cpu_physical_memory_write(address
, (uint8_t *) & data
, sizeof(data
));
1291 case PORT_SELECTIVE_RESET
:
1292 TRACE(OTHER
, logout("selective reset, selftest address=0x%08x\n", address
));
1293 nic_selective_reset(s
);
1296 logout("val=0x%08x\n", val
);
1297 missing("unknown port selection");
1301 /*****************************************************************************
1303 * General hardware emulation.
1305 ****************************************************************************/
1307 static uint8_t eepro100_read1(EEPRO100State
* s
, uint32_t addr
)
1310 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1311 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1316 //~ val = eepro100_read_status(s);
1317 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1320 //~ val = eepro100_read_status(s);
1321 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1324 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1325 //~ val = eepro100_read_command(s);
1328 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1331 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1334 val
= eepro100_read_eeprom(s
);
1336 case 0x1b: /* PMDR (power management driver register) */
1338 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1340 case 0x1d: /* general status register */
1341 /* 100 Mbps full duplex, valid link */
1343 TRACE(OTHER
, logout("addr=General Status val=%02x\n", val
));
1346 logout("addr=%s val=0x%02x\n", regname(addr
), val
);
1347 missing("unknown byte read");
1352 static uint16_t eepro100_read2(EEPRO100State
* s
, uint32_t addr
)
1355 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1356 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1361 //~ val = eepro100_read_status(s);
1363 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1366 val
= eepro100_read_eeprom(s
);
1367 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1370 logout("addr=%s val=0x%04x\n", regname(addr
), val
);
1371 missing("unknown word read");
1376 static uint32_t eepro100_read4(EEPRO100State
* s
, uint32_t addr
)
1379 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1380 memcpy(&val
, &s
->mem
[addr
], sizeof(val
));
1385 //~ val = eepro100_read_status(s);
1386 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1389 //~ val = eepro100_read_pointer(s);
1390 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1393 val
= eepro100_read_port(s
);
1394 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1397 val
= eepro100_read_mdi(s
);
1400 logout("addr=%s val=0x%08x\n", regname(addr
), val
);
1401 missing("unknown longword read");
1406 static void eepro100_write1(EEPRO100State
* s
, uint32_t addr
, uint8_t val
)
1408 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1409 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1412 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1416 //~ eepro100_write_status(s, val);
1419 eepro100_acknowledge(s
);
1422 eepro100_write_command(s
, val
);
1426 eepro100_swi_interrupt(s
);
1428 eepro100_interrupt(s
, 0);
1431 case SCBFlow
: /* does not exist on 82557 */
1435 TRACE(OTHER
, logout("addr=%s val=0x%02x\n", regname(addr
), val
));
1438 eepro100_write_eeprom(s
->eeprom
, val
);
1441 logout("addr=%s val=0x%02x\n", regname(addr
), val
);
1442 missing("unknown byte write");
1446 static void eepro100_write2(EEPRO100State
* s
, uint32_t addr
, uint16_t val
)
1448 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1449 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1452 TRACE(OTHER
, logout("addr=%s val=0x%04x\n", regname(addr
), val
));
1456 //~ eepro100_write_status(s, val);
1457 eepro100_acknowledge(s
);
1460 eepro100_write_command(s
, val
);
1461 eepro100_write1(s
, SCBIntmask
, val
>> 8);
1464 eepro100_write_eeprom(s
->eeprom
, val
);
1467 logout("addr=%s val=0x%04x\n", regname(addr
), val
);
1468 missing("unknown word write");
1472 static void eepro100_write4(EEPRO100State
* s
, uint32_t addr
, uint32_t val
)
1474 if (addr
<= sizeof(s
->mem
) - sizeof(val
)) {
1475 memcpy(&s
->mem
[addr
], &val
, sizeof(val
));
1480 eepro100_write_pointer(s
, val
);
1483 TRACE(OTHER
, logout("addr=%s val=0x%08x\n", regname(addr
), val
));
1484 eepro100_write_port(s
, val
);
1487 eepro100_write_mdi(s
, val
);
1490 logout("addr=%s val=0x%08x\n", regname(addr
), val
);
1491 missing("unknown longword write");
1495 /*****************************************************************************
1499 ****************************************************************************/
1501 static uint32_t ioport_read1(void *opaque
, uint32_t addr
)
1503 EEPRO100State
*s
= opaque
;
1504 //~ logout("addr=%s\n", regname(addr));
1505 return eepro100_read1(s
, addr
- s
->region
[1]);
1508 static uint32_t ioport_read2(void *opaque
, uint32_t addr
)
1510 EEPRO100State
*s
= opaque
;
1511 return eepro100_read2(s
, addr
- s
->region
[1]);
1514 static uint32_t ioport_read4(void *opaque
, uint32_t addr
)
1516 EEPRO100State
*s
= opaque
;
1517 return eepro100_read4(s
, addr
- s
->region
[1]);
1520 static void ioport_write1(void *opaque
, uint32_t addr
, uint32_t val
)
1522 EEPRO100State
*s
= opaque
;
1523 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1524 eepro100_write1(s
, addr
- s
->region
[1], val
);
1527 static void ioport_write2(void *opaque
, uint32_t addr
, uint32_t val
)
1529 EEPRO100State
*s
= opaque
;
1530 eepro100_write2(s
, addr
- s
->region
[1], val
);
1533 static void ioport_write4(void *opaque
, uint32_t addr
, uint32_t val
)
1535 EEPRO100State
*s
= opaque
;
1536 eepro100_write4(s
, addr
- s
->region
[1], val
);
1539 /***********************************************************/
1540 /* PCI EEPRO100 definitions */
1542 static void pci_map(PCIDevice
* pci_dev
, int region_num
,
1543 pcibus_t addr
, pcibus_t size
, int type
)
1545 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1547 TRACE(OTHER
, logout("region %d, addr=0x%08"FMT_PCIBUS
", "
1548 "size=0x%08"FMT_PCIBUS
", type=%d\n",
1549 region_num
, addr
, size
, type
));
1551 assert(region_num
== 1);
1552 register_ioport_write(addr
, size
, 1, ioport_write1
, s
);
1553 register_ioport_read(addr
, size
, 1, ioport_read1
, s
);
1554 register_ioport_write(addr
, size
, 2, ioport_write2
, s
);
1555 register_ioport_read(addr
, size
, 2, ioport_read2
, s
);
1556 register_ioport_write(addr
, size
, 4, ioport_write4
, s
);
1557 register_ioport_read(addr
, size
, 4, ioport_read4
, s
);
1559 s
->region
[region_num
] = addr
;
1562 /*****************************************************************************
1564 * Memory mapped I/O.
1566 ****************************************************************************/
1568 static void pci_mmio_writeb(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1570 EEPRO100State
*s
= opaque
;
1571 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1572 eepro100_write1(s
, addr
, val
);
1575 static void pci_mmio_writew(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1577 EEPRO100State
*s
= opaque
;
1578 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1579 eepro100_write2(s
, addr
, val
);
1582 static void pci_mmio_writel(void *opaque
, target_phys_addr_t addr
, uint32_t val
)
1584 EEPRO100State
*s
= opaque
;
1585 //~ logout("addr=%s val=0x%02x\n", regname(addr), val);
1586 eepro100_write4(s
, addr
, val
);
1589 static uint32_t pci_mmio_readb(void *opaque
, target_phys_addr_t addr
)
1591 EEPRO100State
*s
= opaque
;
1592 //~ logout("addr=%s\n", regname(addr));
1593 return eepro100_read1(s
, addr
);
1596 static uint32_t pci_mmio_readw(void *opaque
, target_phys_addr_t addr
)
1598 EEPRO100State
*s
= opaque
;
1599 //~ logout("addr=%s\n", regname(addr));
1600 return eepro100_read2(s
, addr
);
1603 static uint32_t pci_mmio_readl(void *opaque
, target_phys_addr_t addr
)
1605 EEPRO100State
*s
= opaque
;
1606 //~ logout("addr=%s\n", regname(addr));
1607 return eepro100_read4(s
, addr
);
1610 static CPUWriteMemoryFunc
* const pci_mmio_write
[] = {
1616 static CPUReadMemoryFunc
* const pci_mmio_read
[] = {
1622 static void pci_mmio_map(PCIDevice
* pci_dev
, int region_num
,
1623 pcibus_t addr
, pcibus_t size
, int type
)
1625 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1627 TRACE(OTHER
, logout("region %d, addr=0x%08"FMT_PCIBUS
", "
1628 "size=0x%08"FMT_PCIBUS
", type=%d\n",
1629 region_num
, addr
, size
, type
));
1631 if (region_num
== 0) {
1632 /* Map control / status registers. */
1633 cpu_register_physical_memory(addr
, size
, s
->mmio_index
);
1634 s
->region
[region_num
] = addr
;
1638 static int nic_can_receive(VLANClientState
*nc
)
1640 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1641 TRACE(RXTX
, logout("%p\n", s
));
1642 return get_ru_state(s
) == ru_ready
;
1643 //~ return !eepro100_buffer_full(s);
1646 static ssize_t
nic_receive(VLANClientState
*nc
, const uint8_t * buf
, size_t size
)
1649 * - Magic packets should set bit 30 in power management driver register.
1650 * - Interesting packets should set bit 29 in power management driver register.
1652 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1653 uint16_t rfd_status
= 0xa000;
1654 static const uint8_t broadcast_macaddr
[6] =
1655 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1657 /* TODO: check multiple IA bit. */
1658 if (s
->configuration
[20] & BIT(6)) {
1659 missing("Multiple IA bit");
1663 if (s
->configuration
[8] & 0x80) {
1664 /* CSMA is disabled. */
1665 logout("%p received while CSMA is disabled\n", s
);
1667 } else if (size
< 64 && (s
->configuration
[7] & 1)) {
1668 /* Short frame and configuration byte 7/0 (discard short receive) set:
1669 * Short frame is discarded */
1670 logout("%p received short frame (%zu byte)\n", s
, size
);
1671 s
->statistics
.rx_short_frame_errors
++;
1673 } else if ((size
> MAX_ETH_FRAME_SIZE
+ 4) && !(s
->configuration
[18] & 8)) {
1674 /* Long frame and configuration byte 18/3 (long receive ok) not set:
1675 * Long frames are discarded. */
1676 logout("%p received long frame (%zu byte), ignored\n", s
, size
);
1678 } else if (memcmp(buf
, s
->conf
.macaddr
.a
, 6) == 0) { // !!!
1679 /* Frame matches individual address. */
1680 /* TODO: check configuration byte 15/4 (ignore U/L). */
1681 TRACE(RXTX
, logout("%p received frame for me, len=%zu\n", s
, size
));
1682 } else if (memcmp(buf
, broadcast_macaddr
, 6) == 0) {
1683 /* Broadcast frame. */
1684 TRACE(RXTX
, logout("%p received broadcast, len=%zu\n", s
, size
));
1685 rfd_status
|= 0x0002;
1686 } else if (buf
[0] & 0x01) {
1687 /* Multicast frame. */
1688 TRACE(RXTX
, logout("%p received multicast, len=%zu,%s\n", s
, size
, nic_dump(buf
, size
)));
1689 if (s
->configuration
[21] & BIT(3)) {
1690 /* Multicast all bit is set, receive all multicast frames. */
1692 unsigned mcast_idx
= compute_mcast_idx(buf
);
1693 assert(mcast_idx
< 64);
1694 if (s
->mult
[mcast_idx
>> 3] & (1 << (mcast_idx
& 7))) {
1695 /* Multicast frame is allowed in hash table. */
1696 } else if (s
->configuration
[15] & 1) {
1697 /* Promiscuous: receive all. */
1698 rfd_status
|= 0x0004;
1700 TRACE(RXTX
, logout("%p multicast ignored\n", s
));
1704 /* TODO: Next not for promiscuous mode? */
1705 rfd_status
|= 0x0002;
1706 } else if (s
->configuration
[15] & 1) {
1707 /* Promiscuous: receive all. */
1708 TRACE(RXTX
, logout("%p received frame in promiscuous mode, len=%zu\n", s
, size
));
1709 rfd_status
|= 0x0004;
1711 TRACE(RXTX
, logout("%p received frame, ignored, len=%zu,%s\n", s
, size
,
1712 nic_dump(buf
, size
)));
1716 if (get_ru_state(s
) != ru_ready
) {
1717 /* No resources available. */
1718 logout("no resources, state=%u\n", get_ru_state(s
));
1719 s
->statistics
.rx_resource_errors
++;
1720 //~ assert(!"no resources");
1724 //~ $3 = {status = 0x0, command = 0xc000, link = 0x2d220, rx_buf_addr = 0x207dc, count = 0x0, size = 0x5f8, packet = {0x0 <repeats 1518 times>}}
1726 cpu_physical_memory_read(s
->ru_base
+ s
->ru_offset
, (uint8_t *) & rx
,
1727 offsetof(eepro100_rx_t
, packet
));
1728 uint16_t rfd_command
= le16_to_cpu(rx
.command
);
1729 uint16_t rfd_size
= le16_to_cpu(rx
.size
);
1731 if (size
> rfd_size
) {
1732 logout("Receive buffer (%" PRId16
" bytes) too small for data "
1733 "(%zu bytes); data truncated\n", rfd_size
, size
);
1737 rfd_status
|= 0x0080;
1739 TRACE(OTHER
, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n",
1740 rfd_command
, rx
.link
, rx
.rx_buf_addr
, rfd_size
));
1741 stw_phys(s
->ru_base
+ s
->ru_offset
+ offsetof(eepro100_rx_t
, status
),
1743 stw_phys(s
->ru_base
+ s
->ru_offset
+ offsetof(eepro100_rx_t
, count
), size
);
1744 /* Early receive interrupt not supported. */
1745 //~ eepro100_er_interrupt(s);
1746 /* Receive CRC Transfer not supported. */
1747 if (s
->configuration
[18] & 4) {
1748 missing("Receive CRC Transfer");
1751 /* TODO: check stripping enable bit. */
1752 //~ assert(!(s->configuration[17] & 1));
1753 cpu_physical_memory_write(s
->ru_base
+ s
->ru_offset
+
1754 offsetof(eepro100_rx_t
, packet
), buf
, size
);
1755 s
->statistics
.rx_good_frames
++;
1756 eepro100_fr_interrupt(s
);
1757 s
->ru_offset
= le32_to_cpu(rx
.link
);
1758 if (rfd_command
& 0x8000) {
1759 /* EL bit is set, so this was the last frame. */
1760 logout("receive: Running out of frames\n");
1761 set_ru_state(s
, ru_suspended
);
1763 if (rfd_command
& 0x4000) {
1765 set_ru_state(s
, ru_suspended
);
1770 static const VMStateDescription vmstate_eepro100
= {
1772 .minimum_version_id
= 2,
1773 .minimum_version_id_old
= 2,
1774 .fields
= (VMStateField
[]) {
1775 VMSTATE_PCI_DEVICE(dev
, EEPRO100State
),
1777 VMSTATE_BUFFER(mult
, EEPRO100State
),
1778 VMSTATE_BUFFER(mem
, EEPRO100State
),
1779 /* Save all members of struct between scb_stat and mem. */
1780 VMSTATE_UINT8(scb_stat
, EEPRO100State
),
1781 VMSTATE_UINT8(int_stat
, EEPRO100State
),
1782 VMSTATE_UNUSED(3*4),
1783 VMSTATE_MACADDR(conf
.macaddr
, EEPRO100State
),
1784 VMSTATE_UNUSED(19*4),
1785 VMSTATE_UINT16_ARRAY(mdimem
, EEPRO100State
, 32),
1786 /* The eeprom should be saved and restored by its own routines. */
1787 VMSTATE_UINT32(device
, EEPRO100State
),
1788 /* TODO check device. */
1789 VMSTATE_UINT32(pointer
, EEPRO100State
),
1790 VMSTATE_UINT32(cu_base
, EEPRO100State
),
1791 VMSTATE_UINT32(cu_offset
, EEPRO100State
),
1792 VMSTATE_UINT32(ru_base
, EEPRO100State
),
1793 VMSTATE_UINT32(ru_offset
, EEPRO100State
),
1794 VMSTATE_UINT32(statsaddr
, EEPRO100State
),
1795 /* Save eepro100_stats_t statistics. */
1796 VMSTATE_UINT32(statistics
.tx_good_frames
, EEPRO100State
),
1797 VMSTATE_UINT32(statistics
.tx_max_collisions
, EEPRO100State
),
1798 VMSTATE_UINT32(statistics
.tx_late_collisions
, EEPRO100State
),
1799 VMSTATE_UINT32(statistics
.tx_underruns
, EEPRO100State
),
1800 VMSTATE_UINT32(statistics
.tx_lost_crs
, EEPRO100State
),
1801 VMSTATE_UINT32(statistics
.tx_deferred
, EEPRO100State
),
1802 VMSTATE_UINT32(statistics
.tx_single_collisions
, EEPRO100State
),
1803 VMSTATE_UINT32(statistics
.tx_multiple_collisions
, EEPRO100State
),
1804 VMSTATE_UINT32(statistics
.tx_total_collisions
, EEPRO100State
),
1805 VMSTATE_UINT32(statistics
.rx_good_frames
, EEPRO100State
),
1806 VMSTATE_UINT32(statistics
.rx_crc_errors
, EEPRO100State
),
1807 VMSTATE_UINT32(statistics
.rx_alignment_errors
, EEPRO100State
),
1808 VMSTATE_UINT32(statistics
.rx_resource_errors
, EEPRO100State
),
1809 VMSTATE_UINT32(statistics
.rx_overrun_errors
, EEPRO100State
),
1810 VMSTATE_UINT32(statistics
.rx_cdt_errors
, EEPRO100State
),
1811 VMSTATE_UINT32(statistics
.rx_short_frame_errors
, EEPRO100State
),
1812 VMSTATE_UINT32(statistics
.fc_xmt_pause
, EEPRO100State
),
1813 VMSTATE_UINT32(statistics
.fc_rcv_pause
, EEPRO100State
),
1814 VMSTATE_UINT32(statistics
.fc_rcv_unsupported
, EEPRO100State
),
1815 VMSTATE_UINT16(statistics
.xmt_tco_frames
, EEPRO100State
),
1816 VMSTATE_UINT16(statistics
.rcv_tco_frames
, EEPRO100State
),
1818 VMSTATE_UINT16(status
, EEPRO100State
),
1820 /* Configuration bytes. */
1821 VMSTATE_BUFFER(configuration
, EEPRO100State
),
1822 VMSTATE_END_OF_LIST()
1826 static void nic_cleanup(VLANClientState
*nc
)
1828 EEPRO100State
*s
= DO_UPCAST(NICState
, nc
, nc
)->opaque
;
1833 static int pci_nic_uninit(PCIDevice
*pci_dev
)
1835 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1837 cpu_unregister_io_memory(s
->mmio_index
);
1838 vmstate_unregister(s
->vmstate
, s
);
1839 eeprom93xx_free(s
->eeprom
);
1840 qemu_del_vlan_client(&s
->nic
->nc
);
1844 static NetClientInfo net_eepro100_info
= {
1845 .type
= NET_CLIENT_TYPE_NIC
,
1846 .size
= sizeof(NICState
),
1847 .can_receive
= nic_can_receive
,
1848 .receive
= nic_receive
,
1849 .cleanup
= nic_cleanup
,
1852 static int nic_init(PCIDevice
*pci_dev
, uint32_t device
)
1854 EEPRO100State
*s
= DO_UPCAST(EEPRO100State
, dev
, pci_dev
);
1856 TRACE(OTHER
, logout("\n"));
1862 /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM,
1863 * i82559 and later support 64 or 256 word EEPROM. */
1864 s
->eeprom
= eeprom93xx_new(EEPROM_SIZE
);
1866 /* Handler for memory-mapped I/O */
1868 cpu_register_io_memory(pci_mmio_read
, pci_mmio_write
, s
);
1870 pci_register_bar(&s
->dev
, 0, PCI_MEM_SIZE
,
1871 PCI_BASE_ADDRESS_SPACE_MEMORY
|
1872 PCI_BASE_ADDRESS_MEM_PREFETCH
, pci_mmio_map
);
1873 pci_register_bar(&s
->dev
, 1, PCI_IO_SIZE
, PCI_BASE_ADDRESS_SPACE_IO
,
1875 pci_register_bar(&s
->dev
, 2, PCI_FLASH_SIZE
, PCI_BASE_ADDRESS_SPACE_MEMORY
,
1878 qemu_macaddr_default_if_unset(&s
->conf
.macaddr
);
1879 logout("macaddr: %s\n", nic_dump(&s
->conf
.macaddr
.a
[0], 6));
1880 assert(s
->region
[1] == 0);
1884 s
->nic
= qemu_new_nic(&net_eepro100_info
, &s
->conf
,
1885 pci_dev
->qdev
.info
->name
, pci_dev
->qdev
.id
, s
);
1887 qemu_format_nic_info_str(&s
->nic
->nc
, s
->conf
.macaddr
.a
);
1888 TRACE(OTHER
, logout("%s\n", s
->nic
->nc
.info_str
));
1890 qemu_register_reset(nic_reset
, s
);
1892 s
->vmstate
= qemu_malloc(sizeof(vmstate_eepro100
));
1893 memcpy(s
->vmstate
, &vmstate_eepro100
, sizeof(vmstate_eepro100
));
1894 s
->vmstate
->name
= s
->nic
->nc
.model
;
1895 vmstate_register(-1, s
->vmstate
, s
);
1900 static int pci_i82550_init(PCIDevice
*pci_dev
)
1902 return nic_init(pci_dev
, i82550
);
1905 static int pci_i82551_init(PCIDevice
*pci_dev
)
1907 return nic_init(pci_dev
, i82551
);
1910 static int pci_i82557a_init(PCIDevice
*pci_dev
)
1912 return nic_init(pci_dev
, i82557A
);
1915 static int pci_i82557b_init(PCIDevice
*pci_dev
)
1917 return nic_init(pci_dev
, i82557B
);
1920 static int pci_i82557c_init(PCIDevice
*pci_dev
)
1922 return nic_init(pci_dev
, i82557C
);
1925 static int pci_i82558a_init(PCIDevice
*pci_dev
)
1927 return nic_init(pci_dev
, i82558A
);
1930 static int pci_i82558b_init(PCIDevice
*pci_dev
)
1932 return nic_init(pci_dev
, i82558B
);
1935 static int pci_i82559a_init(PCIDevice
*pci_dev
)
1937 return nic_init(pci_dev
, i82559A
);
1940 static int pci_i82559b_init(PCIDevice
*pci_dev
)
1942 return nic_init(pci_dev
, i82559B
);
1945 static int pci_i82559c_init(PCIDevice
*pci_dev
)
1947 return nic_init(pci_dev
, i82559C
);
1950 static int pci_i82559er_init(PCIDevice
*pci_dev
)
1952 return nic_init(pci_dev
, i82559ER
);
1955 static int pci_i82562_init(PCIDevice
*pci_dev
)
1957 return nic_init(pci_dev
, i82562
);
1960 static PCIDeviceInfo eepro100_info
[] = {
1962 .qdev
.name
= "i82550",
1963 .qdev
.size
= sizeof(EEPRO100State
),
1964 .init
= pci_i82550_init
,
1965 .exit
= pci_nic_uninit
,
1966 .qdev
.props
= (Property
[]) {
1967 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1968 DEFINE_PROP_END_OF_LIST(),
1971 .qdev
.name
= "i82551",
1972 .qdev
.size
= sizeof(EEPRO100State
),
1973 .init
= pci_i82551_init
,
1974 .exit
= pci_nic_uninit
,
1975 .qdev
.props
= (Property
[]) {
1976 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1977 DEFINE_PROP_END_OF_LIST(),
1980 .qdev
.name
= "i82557a",
1981 .qdev
.size
= sizeof(EEPRO100State
),
1982 .init
= pci_i82557a_init
,
1983 .exit
= pci_nic_uninit
,
1984 .qdev
.props
= (Property
[]) {
1985 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1986 DEFINE_PROP_END_OF_LIST(),
1989 .qdev
.name
= "i82557b",
1990 .qdev
.size
= sizeof(EEPRO100State
),
1991 .init
= pci_i82557b_init
,
1992 .exit
= pci_nic_uninit
,
1993 .qdev
.props
= (Property
[]) {
1994 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
1995 DEFINE_PROP_END_OF_LIST(),
1998 .qdev
.name
= "i82557c",
1999 .qdev
.size
= sizeof(EEPRO100State
),
2000 .init
= pci_i82557c_init
,
2001 .exit
= pci_nic_uninit
,
2002 .qdev
.props
= (Property
[]) {
2003 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2004 DEFINE_PROP_END_OF_LIST(),
2007 .qdev
.name
= "i82558a",
2008 .qdev
.size
= sizeof(EEPRO100State
),
2009 .init
= pci_i82558a_init
,
2010 .exit
= pci_nic_uninit
,
2011 .qdev
.props
= (Property
[]) {
2012 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2013 DEFINE_PROP_END_OF_LIST(),
2016 .qdev
.name
= "i82558b",
2017 .qdev
.size
= sizeof(EEPRO100State
),
2018 .init
= pci_i82558b_init
,
2019 .exit
= pci_nic_uninit
,
2020 .qdev
.props
= (Property
[]) {
2021 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2022 DEFINE_PROP_END_OF_LIST(),
2025 .qdev
.name
= "i82559a",
2026 .qdev
.size
= sizeof(EEPRO100State
),
2027 .init
= pci_i82559a_init
,
2028 .exit
= pci_nic_uninit
,
2029 .qdev
.props
= (Property
[]) {
2030 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2031 DEFINE_PROP_END_OF_LIST(),
2034 .qdev
.name
= "i82559b",
2035 .qdev
.size
= sizeof(EEPRO100State
),
2036 .init
= pci_i82559b_init
,
2037 .exit
= pci_nic_uninit
,
2038 .qdev
.props
= (Property
[]) {
2039 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2040 DEFINE_PROP_END_OF_LIST(),
2043 .qdev
.name
= "i82559c",
2044 .qdev
.size
= sizeof(EEPRO100State
),
2045 .init
= pci_i82559c_init
,
2046 .exit
= pci_nic_uninit
,
2047 .qdev
.props
= (Property
[]) {
2048 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2049 DEFINE_PROP_END_OF_LIST(),
2052 .qdev
.name
= "i82559er",
2053 .qdev
.size
= sizeof(EEPRO100State
),
2054 .init
= pci_i82559er_init
,
2055 .exit
= pci_nic_uninit
,
2056 .romfile
= "pxe-i82559er.bin",
2057 .qdev
.props
= (Property
[]) {
2058 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2059 DEFINE_PROP_END_OF_LIST(),
2062 .qdev
.name
= "i82562",
2063 .qdev
.size
= sizeof(EEPRO100State
),
2064 .init
= pci_i82562_init
,
2065 .exit
= pci_nic_uninit
,
2066 .qdev
.props
= (Property
[]) {
2067 DEFINE_NIC_PROPERTIES(EEPRO100State
, conf
),
2068 DEFINE_PROP_END_OF_LIST(),
2075 static void eepro100_register_devices(void)
2077 pci_qdev_register_many(eepro100_info
);
2080 device_init(eepro100_register_devices
)