Paolo Bonzini | cb9c377 | 2012-12-06 12:15:58 +0100 | [diff] [blame] | 1 | #ifndef HW_PCNET_H |
| 2 | #define HW_PCNET_H 1 |
| 3 | |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 4 | #define PCNET_IOPORT_SIZE 0x20 |
| 5 | #define PCNET_PNPMMIO_SIZE 0x20 |
| 6 | |
| 7 | #define PCNET_LOOPTEST_CRC 1 |
| 8 | #define PCNET_LOOPTEST_NOCRC 2 |
| 9 | |
Paolo Bonzini | 022c62c | 2012-12-17 18:19:49 +0100 | [diff] [blame] | 10 | #include "exec/memory.h" |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 11 | |
Jan Kiszka | 488a1a5 | 2011-09-26 19:01:44 +0200 | [diff] [blame] | 12 | /* BUS CONFIGURATION REGISTERS */ |
| 13 | #define BCR_MSRDA 0 |
| 14 | #define BCR_MSWRA 1 |
| 15 | #define BCR_MC 2 |
| 16 | #define BCR_LNKST 4 |
| 17 | #define BCR_LED1 5 |
| 18 | #define BCR_LED2 6 |
| 19 | #define BCR_LED3 7 |
| 20 | #define BCR_FDC 9 |
| 21 | #define BCR_BSBC 18 |
| 22 | #define BCR_EECAS 19 |
| 23 | #define BCR_SWS 20 |
| 24 | #define BCR_PLAT 22 |
| 25 | |
Jan Kiszka | ef45c91 | 2012-02-29 15:37:43 +0100 | [diff] [blame] | 26 | #define BCR_TMAULOOP(S) !!((S)->bcr[BCR_MC ] & 0x4000) |
Jan Kiszka | 488a1a5 | 2011-09-26 19:01:44 +0200 | [diff] [blame] | 27 | #define BCR_APROMWE(S) !!((S)->bcr[BCR_MC ] & 0x0100) |
| 28 | #define BCR_DWIO(S) !!((S)->bcr[BCR_BSBC] & 0x0080) |
| 29 | #define BCR_SSIZE32(S) !!((S)->bcr[BCR_SWS ] & 0x0100) |
| 30 | #define BCR_SWSTYLE(S) ((S)->bcr[BCR_SWS ] & 0x00FF) |
| 31 | |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 32 | typedef struct PCNetState_st PCNetState; |
| 33 | |
| 34 | struct PCNetState_st { |
Mark McLoughlin | 1fa5148 | 2009-11-25 18:49:15 +0000 | [diff] [blame] | 35 | NICState *nic; |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 36 | NICConf conf; |
| 37 | QEMUTimer *poll_timer; |
| 38 | int rap, isr, lnkst; |
| 39 | uint32_t rdra, tdra; |
| 40 | uint8_t prom[16]; |
| 41 | uint16_t csr[128]; |
| 42 | uint16_t bcr[32]; |
Blue Swirl | fe87aa8 | 2011-08-07 19:38:49 +0000 | [diff] [blame] | 43 | int xmit_pos; |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 44 | uint64_t timer; |
Avi Kivity | bd8d6f7 | 2011-08-08 16:09:19 +0300 | [diff] [blame] | 45 | MemoryRegion mmio; |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 46 | uint8_t buffer[4096]; |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 47 | qemu_irq irq; |
Avi Kivity | a8170e5 | 2012-10-23 12:30:10 +0200 | [diff] [blame] | 48 | void (*phys_mem_read)(void *dma_opaque, hwaddr addr, |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 49 | uint8_t *buf, int len, int do_bswap); |
Avi Kivity | a8170e5 | 2012-10-23 12:30:10 +0200 | [diff] [blame] | 50 | void (*phys_mem_write)(void *dma_opaque, hwaddr addr, |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 51 | uint8_t *buf, int len, int do_bswap); |
| 52 | void *dma_opaque; |
Blue Swirl | fe87aa8 | 2011-08-07 19:38:49 +0000 | [diff] [blame] | 53 | int tx_busy; |
Gerd Hoffmann | 94e1a91 | 2009-10-21 15:25:33 +0200 | [diff] [blame] | 54 | int looptest; |
| 55 | }; |
| 56 | |
| 57 | void pcnet_h_reset(void *opaque); |
| 58 | void pcnet_ioport_writew(void *opaque, uint32_t addr, uint32_t val); |
| 59 | uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr); |
Paul Brook | a4c75a2 | 2010-11-27 11:23:34 +0000 | [diff] [blame] | 60 | void pcnet_ioport_writel(void *opaque, uint32_t addr, uint32_t val); |
| 61 | uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr); |
| 62 | uint32_t pcnet_bcr_readw(PCNetState *s, uint32_t rap); |
Stefan Hajnoczi | 4e68f7a | 2012-07-24 16:35:13 +0100 | [diff] [blame] | 63 | int pcnet_can_receive(NetClientState *nc); |
| 64 | ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_); |
| 65 | void pcnet_set_link_status(NetClientState *nc); |
Mark McLoughlin | 1fa5148 | 2009-11-25 18:49:15 +0000 | [diff] [blame] | 66 | int pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info); |
Juan Quintela | 3d86505 | 2009-10-19 18:02:13 +0200 | [diff] [blame] | 67 | extern const VMStateDescription vmstate_pcnet; |
Paolo Bonzini | cb9c377 | 2012-12-06 12:15:58 +0100 | [diff] [blame] | 68 | #endif |