2012-12-06 19:15:58 +08:00
|
|
|
#ifndef HW_PCNET_H
|
2016-06-29 21:29:06 +08:00
|
|
|
#define HW_PCNET_H
|
2012-12-06 19:15:58 +08:00
|
|
|
|
2009-10-21 21:25:33 +08:00
|
|
|
#define PCNET_IOPORT_SIZE 0x20
|
|
|
|
#define PCNET_PNPMMIO_SIZE 0x20
|
|
|
|
|
|
|
|
#define PCNET_LOOPTEST_CRC 1
|
|
|
|
#define PCNET_LOOPTEST_NOCRC 2
|
|
|
|
|
2012-12-18 01:19:49 +08:00
|
|
|
#include "exec/memory.h"
|
2009-10-21 21:25:33 +08:00
|
|
|
|
2011-09-27 01:01:44 +08:00
|
|
|
/* BUS CONFIGURATION REGISTERS */
|
|
|
|
#define BCR_MSRDA 0
|
|
|
|
#define BCR_MSWRA 1
|
|
|
|
#define BCR_MC 2
|
|
|
|
#define BCR_LNKST 4
|
|
|
|
#define BCR_LED1 5
|
|
|
|
#define BCR_LED2 6
|
|
|
|
#define BCR_LED3 7
|
|
|
|
#define BCR_FDC 9
|
|
|
|
#define BCR_BSBC 18
|
|
|
|
#define BCR_EECAS 19
|
|
|
|
#define BCR_SWS 20
|
|
|
|
#define BCR_PLAT 22
|
|
|
|
|
2012-02-29 22:37:43 +08:00
|
|
|
#define BCR_TMAULOOP(S) !!((S)->bcr[BCR_MC ] & 0x4000)
|
2011-09-27 01:01:44 +08:00
|
|
|
#define BCR_APROMWE(S) !!((S)->bcr[BCR_MC ] & 0x0100)
|
|
|
|
#define BCR_DWIO(S) !!((S)->bcr[BCR_BSBC] & 0x0080)
|
|
|
|
#define BCR_SSIZE32(S) !!((S)->bcr[BCR_SWS ] & 0x0100)
|
|
|
|
#define BCR_SWSTYLE(S) ((S)->bcr[BCR_SWS ] & 0x00FF)
|
|
|
|
|
2009-10-21 21:25:33 +08:00
|
|
|
typedef struct PCNetState_st PCNetState;
|
|
|
|
|
|
|
|
struct PCNetState_st {
|
2009-11-26 02:49:15 +08:00
|
|
|
NICState *nic;
|
2009-10-21 21:25:33 +08:00
|
|
|
NICConf conf;
|
|
|
|
QEMUTimer *poll_timer;
|
|
|
|
int rap, isr, lnkst;
|
|
|
|
uint32_t rdra, tdra;
|
|
|
|
uint8_t prom[16];
|
|
|
|
uint16_t csr[128];
|
|
|
|
uint16_t bcr[32];
|
pcnet: avoid structure holes spotted by pahole
Edited report from pahole on amd64 host:
struct PCNetState_st {
...
uint16_t bcr[32]; /* 340 64 */
/* XXX 4 bytes hole, try to pack */
...
int tx_busy; /* 4520 4 */
/* XXX 4 bytes hole, try to pack */
qemu_irq irq; /* 4528 8 */
void (*phys_mem_read)(void *, target_phys_addr_t, uint8_t *, int, int); /* 4536 8 */
/* --- cacheline 71 boundary (4544 bytes) --- */
void (*phys_mem_write)(void *, target_phys_addr_t, uint8_t *, int, int); /* 4544 8 */
void * dma_opaque; /* 4552 8 */
int looptest; /* 4560 4 */
/* size: 4568, cachelines: 72 */
/* sum members: 4556, holes: 2, sum holes: 8 */
/* padding: 4 */
/* last cacheline: 24 bytes */
}; /* definitions: 2 */
Fix by rearranging the structure to avoid padding.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-08 03:38:49 +08:00
|
|
|
int xmit_pos;
|
2009-10-21 21:25:33 +08:00
|
|
|
uint64_t timer;
|
2011-08-08 21:09:19 +08:00
|
|
|
MemoryRegion mmio;
|
2009-10-21 21:25:33 +08:00
|
|
|
uint8_t buffer[4096];
|
|
|
|
qemu_irq irq;
|
2012-10-23 18:30:10 +08:00
|
|
|
void (*phys_mem_read)(void *dma_opaque, hwaddr addr,
|
2009-10-21 21:25:33 +08:00
|
|
|
uint8_t *buf, int len, int do_bswap);
|
2012-10-23 18:30:10 +08:00
|
|
|
void (*phys_mem_write)(void *dma_opaque, hwaddr addr,
|
2009-10-21 21:25:33 +08:00
|
|
|
uint8_t *buf, int len, int do_bswap);
|
|
|
|
void *dma_opaque;
|
pcnet: avoid structure holes spotted by pahole
Edited report from pahole on amd64 host:
struct PCNetState_st {
...
uint16_t bcr[32]; /* 340 64 */
/* XXX 4 bytes hole, try to pack */
...
int tx_busy; /* 4520 4 */
/* XXX 4 bytes hole, try to pack */
qemu_irq irq; /* 4528 8 */
void (*phys_mem_read)(void *, target_phys_addr_t, uint8_t *, int, int); /* 4536 8 */
/* --- cacheline 71 boundary (4544 bytes) --- */
void (*phys_mem_write)(void *, target_phys_addr_t, uint8_t *, int, int); /* 4544 8 */
void * dma_opaque; /* 4552 8 */
int looptest; /* 4560 4 */
/* size: 4568, cachelines: 72 */
/* sum members: 4556, holes: 2, sum holes: 8 */
/* padding: 4 */
/* last cacheline: 24 bytes */
}; /* definitions: 2 */
Fix by rearranging the structure to avoid padding.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-08-08 03:38:49 +08:00
|
|
|
int tx_busy;
|
2009-10-21 21:25:33 +08:00
|
|
|
int looptest;
|
|
|
|
};
|
|
|
|
|
|
|
|
void pcnet_h_reset(void *opaque);
|
|
|
|
void pcnet_ioport_writew(void *opaque, uint32_t addr, uint32_t val);
|
|
|
|
uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr);
|
2010-11-27 19:23:34 +08:00
|
|
|
void pcnet_ioport_writel(void *opaque, uint32_t addr, uint32_t val);
|
|
|
|
uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr);
|
|
|
|
uint32_t pcnet_bcr_readw(PCNetState *s, uint32_t rap);
|
2012-07-24 23:35:13 +08:00
|
|
|
ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_);
|
|
|
|
void pcnet_set_link_status(NetClientState *nc);
|
2015-01-19 22:52:31 +08:00
|
|
|
void pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info);
|
2009-10-20 00:02:13 +08:00
|
|
|
extern const VMStateDescription vmstate_pcnet;
|
2012-12-06 19:15:58 +08:00
|
|
|
#endif
|