2012-12-06 15:15:58 +04:00
|
|
|
#ifndef HW_PCNET_H
|
2016-06-29 16:29:06 +03:00
|
|
|
#define HW_PCNET_H
|
2012-12-06 15:15:58 +04:00
|
|
|
|
2009-10-21 17:25:33 +04:00
|
|
|
#define PCNET_IOPORT_SIZE 0x20
|
|
|
|
#define PCNET_PNPMMIO_SIZE 0x20
|
|
|
|
|
|
|
|
#define PCNET_LOOPTEST_CRC 1
|
|
|
|
#define PCNET_LOOPTEST_NOCRC 2
|
|
|
|
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/memory.h"
|
2019-08-12 08:23:34 +03:00
|
|
|
#include "hw/irq.h"
|
2009-10-21 17:25:33 +04:00
|
|
|
|
2011-09-26 21:01:44 +04: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 18:37:43 +04:00
|
|
|
#define BCR_TMAULOOP(S) !!((S)->bcr[BCR_MC ] & 0x4000)
|
2011-09-26 21:01:44 +04: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 17:25:33 +04:00
|
|
|
typedef struct PCNetState_st PCNetState;
|
|
|
|
|
|
|
|
struct PCNetState_st {
|
2009-11-25 21:49:15 +03:00
|
|
|
NICState *nic;
|
2009-10-21 17:25:33 +04: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-07 23:38:49 +04:00
|
|
|
int xmit_pos;
|
2009-10-21 17:25:33 +04:00
|
|
|
uint64_t timer;
|
2011-08-08 17:09:19 +04:00
|
|
|
MemoryRegion mmio;
|
2009-10-21 17:25:33 +04:00
|
|
|
uint8_t buffer[4096];
|
|
|
|
qemu_irq irq;
|
2012-10-23 14:30:10 +04:00
|
|
|
void (*phys_mem_read)(void *dma_opaque, hwaddr addr,
|
2009-10-21 17:25:33 +04:00
|
|
|
uint8_t *buf, int len, int do_bswap);
|
2012-10-23 14:30:10 +04:00
|
|
|
void (*phys_mem_write)(void *dma_opaque, hwaddr addr,
|
2009-10-21 17:25:33 +04:00
|
|
|
uint8_t *buf, int len, int do_bswap);
|
2019-10-17 18:31:48 +03:00
|
|
|
DeviceState *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-07 23:38:49 +04:00
|
|
|
int tx_busy;
|
2009-10-21 17:25:33 +04: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 14:23:34 +03: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 19:35:13 +04:00
|
|
|
ssize_t pcnet_receive(NetClientState *nc, const uint8_t *buf, size_t size_);
|
|
|
|
void pcnet_set_link_status(NetClientState *nc);
|
2015-01-19 17:52:31 +03:00
|
|
|
void pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info);
|
2009-10-19 20:02:13 +04:00
|
|
|
extern const VMStateDescription vmstate_pcnet;
|
2012-12-06 15:15:58 +04:00
|
|
|
#endif
|