pcnet.h 2.1 KB
Newer Older
1 2 3 4 5 6
#define PCNET_IOPORT_SIZE       0x20
#define PCNET_PNPMMIO_SIZE      0x20

#define PCNET_LOOPTEST_CRC	1
#define PCNET_LOOPTEST_NOCRC	2

A
Avi Kivity 已提交
7
#include "memory.h"
8

J
Jan Kiszka 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* 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

23
#define BCR_TMAULOOP(S)  !!((S)->bcr[BCR_MC  ] & 0x4000)
J
Jan Kiszka 已提交
24 25 26 27 28
#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)

29 30 31
typedef struct PCNetState_st PCNetState;

struct PCNetState_st {
M
Mark McLoughlin 已提交
32
    NICState *nic;
33 34 35 36 37 38 39
    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];
40
    int xmit_pos;
41
    uint64_t timer;
A
Avi Kivity 已提交
42
    MemoryRegion mmio;
43 44 45 46 47 48 49
    uint8_t buffer[4096];
    qemu_irq irq;
    void (*phys_mem_read)(void *dma_opaque, target_phys_addr_t addr,
                         uint8_t *buf, int len, int do_bswap);
    void (*phys_mem_write)(void *dma_opaque, target_phys_addr_t addr,
                          uint8_t *buf, int len, int do_bswap);
    void *dma_opaque;
50
    int tx_busy;
51 52 53 54 55 56
    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);
P
Paul Brook 已提交
57 58 59
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);
M
Mark McLoughlin 已提交
60 61
int pcnet_can_receive(VLANClientState *nc);
ssize_t pcnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size_);
J
Jan Kiszka 已提交
62
void pcnet_set_link_status(VLANClientState *nc);
63
void pcnet_common_cleanup(PCNetState *d);
M
Mark McLoughlin 已提交
64
int pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info);
J
Juan Quintela 已提交
65
extern const VMStateDescription vmstate_pcnet;