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