17 #ifdef POK_NEEDS_RTL8029
18 # ifndef __POK_RTL8029_H__
19 # define __POK_RTL8029_H__
21 # include <libc/stdio.h>
22 # include <libc/string.h>
23 # include <arch/x86/pci.h>
24 # include <arch/x86/ioports.h>
25 # include <middleware/port.h>
27 # define ETH_DATA_MAXLEN 1500
28 # define ETH_DATA_MINLEN 46
29 # define ETH_MAC_LEN 6
31 # define RECV_BUF_SZ 20
36 char dst[ETH_MAC_LEN];
37 char src[ETH_MAC_LEN];
38 unsigned short ethertype;
49 # define NET_DATA_MAXLEN (ETH_DATA_MAXLEN - sizeof (udp_hdr_t))
50 # define NET_DATA_MINLEN (ETH_DATA_MINLEN - sizeof (udp_hdr_t))
56 char data[NET_DATA_MAXLEN];
63 char data[RECV_BUF_SZ];
71 pok_queue_t recv_buf[20];
82 # define NE2000_CR 0x00
83 # define NE2000_CR_STP (1 << 0)
86 # define NE2000_CR_STA (1 << 1)
89 # define NE2000_CR_TXP (1 << 2)
92 # define NE2000_CR_RD0 (1 << 3)
93 # define NE2000_CR_RD1 (1 << 4)
94 # define NE2000_CR_RD2 (1 << 5)
95 # define NE2000_CR_PS0 (1 << 6)
96 # define NE2000_CR_PS1 (1 << 7)
99 # define NE2000_ISR 0x07
101 # define NE2000_ISR_PRX (1 << 0)
103 # define NE2000_ISR_PTX (1 << 1)
105 # define NE2000_ISR_RXE (1 << 2)
110 # define NE2000_ISR_TXE (1 << 3)
113 # define NE2000_ISR_OVW (1 << 4)
115 # define NE2000_ISR_CNT (1 << 5)
117 # define NE2000_ISR_RDC (1 << 6)
119 # define NE2000_ISR_RST (1 << 7)
127 # define NE2000_DCR 0x0E
128 # define NE2000_DCR_WTS (1 << 0)
131 # define NE2000_DCR_BOS (1 << 1)
134 # define NE2000_DCR_LAS (1 << 2)
136 # define NE2000_DCR_LS (1 << 3)
140 # define NE2000_DCR_ARM (1 << 4)
144 # define NE2000_DCR_FT0 (1 << 5)
145 # define NE2000_DCR_FT1 (1 << 6)
148 # define NE2000_RCR 0x0C
149 # define NE2000_RCR_AB (1 << 2)
155 # define NE2000_RSR 0x0C
156 # define NE2000_RSR_PRX (1 << 0)
160 # define NE2000_IMR 0x0F
163 # define NE2000_PSTART 0x01
166 # define NE2000_PSTOP 0x02
169 # define NE2000_BNRY 0x03
172 # define NE2000_TPSR 0x04
175 # define NE2000_TCR 0x0D
178 # define NE2000_CURR 0x07
181 # define NE2000_TBCR0 0x05
182 # define NE2000_TBCR1 0x06
186 # define NE2000_RSAR0 0x08
187 # define NE2000_RSAR1 0x09
190 # define NE2000_RBCR0 0x0A
191 # define NE2000_RBCR1 0x0B
194 # define NE2000_PAR0 0x01
195 # define NE2000_PAR1 0x02
196 # define NE2000_PAR2 0x03
197 # define NE2000_PAR3 0x04
198 # define NE2000_PAR4 0x05
199 # define NE2000_PAR5 0x06
203 # define NE2000_MAR 0x08
206 # define NE2000_DMA_PORT 0x10
209 # define NE2000_MEMSZ 128 // device memory size in 256 bytes block
210 # define NE2000_TXBUF 64 // tx buffer offset in 256 bytes block
211 # define NE2000_TXBUFSZ 8 // tx buffer size in 256 bytes block
212 # define NE2000_RXBUF (NE2000_TXBUF + NE2000_TXBUFSZ) // rx buf offset
214 # define NE2000_RXBUFSZ (NE2000_MEMSZ - NE2000_TXBUFSZ) // rx buf size
216 # define outb(a,b) pok_outb((b), (a))