1 // vim: set et sw=4 sts=4 :
8 extern unsigned char uip_buf[80];
9 extern unsigned int uip_len;
12 #define ETH_DATA_PORT P2 // Adjust this to suit hardware.
13 #define ETH_ADDR_PORT P1 // Adjust this to suit hardware.
15 sbit at 0xB4 IOW; // ISA slot pin B13, RTL8019AS pin 30, active low
16 sbit at 0xB5 IOR; // ISA slot pin B14, RTL8019AS pin 29, active low
17 sbit at 0xB2 NICE; // A7, usado para activar placa de red
19 #define CTRL_PORT P3 // Adjust this to suit hardware.
20 sbit IOW = CTRL_PORT^4; // ISA slot pin B13, RTL8019AS pin 30, active low
21 sbit IOR = CTRL_PORT^5; // ISA slot pin B14, RTL8019AS pin 29, active low
22 sbit NICE = CTRL_PORT^2; // A7, usado para activar placa de red
26 // Register base address
27 #define ETH_REG_BASE 0x0000 // Hardwired to 0x0300
29 // Registers common to all pages.
30 #define CR ETH_REG_BASE + 0x00 // Control register
31 // Control register bits
32 #define PS1 0x80 // Page select bit 1
33 #define PS0 0x40 // Page select bit 0
34 #define RD2 0x20 // Remote DMA control bit 2
35 #define RD1 0x10 // Remote DMA control bit 1
36 #define RD0 0x08 // Remote DMA control bit 0
37 #define TXP 0x04 // Transmit packet bit
38 #define STA 0x02 // Start bit (a flag only)
39 #define STP 0x01 // Stop bit transceiver ctrl
41 #define PAGE0 0x00 // Page 0
42 #define PAGE1 0x40 // Page 1
43 #define PAGE2 0x80 // Page 2
44 #define PAGE3 0xC0 // Page 3 (Reserved!)
45 #define ABORT 0x20 // Abort/Complete DMA
46 #define READ 0x08 // Remote Read
47 #define WRITE 0x10 // Remote Write
48 #define SENDPKT 0x18 // Send Packet Command
49 #define RDMA 0x10 // Remote DMA port
50 #define RESET 0x18 // Reset port
52 // Page 0 read/write registers.
53 #define BNRY ETH_REG_BASE + 0x03 // Boundary register
54 #define ISR ETH_REG_BASE + 0x07 // Interrupt status register
55 // Interrupt status register bits
56 #define RST 0x80 // Reset state indicator bit
57 #define RDC 0x40 // Remote DMA complete bit
58 #define CNT 0x20 // Network tally counter MSB set
59 #define OVW 0x10 // Receive buffer exhausted
60 #define TXE 0x08 // Transmit abort error bit
61 #define RXE 0x04 // Receive error report bit
62 #define PTX 0x02 // Successful packet transmit
63 #define PRX 0x01 // Successful packet receive
65 // Page 0 read only registers.
66 #define CLDA0 ETH_REG_BASE + 0x01
67 #define CLDA1 ETH_REG_BASE + 0x02
68 #define TSR ETH_REG_BASE + 0x04
69 #define NCR ETH_REG_BASE + 0x05
70 #define FIFO ETH_REG_BASE + 0x06
71 #define CRDA0 ETH_REG_BASE + 0x08
72 #define CRDA1 ETH_REG_BASE + 0x09
73 #define CONFIGA ETH_REG_BASE + 0x0A
74 #define CONFIGB ETH_REG_BASE + 0x0B
75 #define RSR ETH_REG_BASE + 0x0C
76 #define CNTR0 ETH_REG_BASE + 0x0D
77 #define CNTR1 ETH_REG_BASE + 0x0E
78 #define CNTR2 ETH_REG_BASE + 0x0F
80 // Page 0 write only registers.
81 #define PSTART ETH_REG_BASE + 0x01 // Receive page start register
82 #define PSTOP ETH_REG_BASE + 0x02 // Receive page stop register
83 #define TPSR ETH_REG_BASE + 0x04 // Transmit page start register
84 #define TBCR0 ETH_REG_BASE + 0x05 // Transmit byte count register 0
85 #define TBCR1 ETH_REG_BASE + 0x06 // Transmit byte count register 1
86 #define RSAR0 ETH_REG_BASE + 0x08 // Remote start address register 0
87 #define RSAR1 ETH_REG_BASE + 0x09 // Remote start address register 0
88 #define RBCR0 ETH_REG_BASE + 0x0A // Remote byte count register 0
89 #define RBCR1 ETH_REG_BASE + 0x0B // Remote byte count register 1
90 #define RCR ETH_REG_BASE + 0x0C // Receive configuration register
91 // Receive configuration register bits (write in page 0, read in page 2)
92 #define MON 0x20 // Monitor mode select bit
93 #define PRO 0x10 // Promiscuous mode select bit
94 #define AM 0x08 // Multicast packet accept bit
95 #define AB 0x04 // Broadcast packet accept bit
96 #define AR 0x02 // Runt packet accept bit
97 #define SEP 0x01 // Error packet accept bit
98 #define TCR ETH_REG_BASE + 0x0D // Transmit configuration register
99 // Transmit configuration register bits
100 #define OFST 0x10 // Collision offset enable bit
101 #define ATD 0x08 // Auto transmit disable select bit
102 #define LB1 0x04 // Loopback mode select bit 1
103 #define LB0 0x02 // Loopback mode select bit 0
104 #define CRC 0x01 // CRC generation inhibit bit
106 #define MODE0 0x00 // Loopback mode 0
107 #define MODE1 0x02 // Loopback mode 1
108 #define MODE2 0x04 // Loopback mode 2
109 #define MODE3 0x06 // Loopback mode 3
110 #define DCR ETH_REG_BASE + 0x0E // Data configuration register
111 // Data configuration register bits (write in page 0, read in page 2)
112 #define FT1 0x40 // FIFO threshold select bit 1
113 #define FT0 0x20 // FIFO threshold select bit 0
114 #define ARM 0x10 // Auto-initialise remote
115 #define LS 0x08 // Loopback select bit
116 #define LAS 0x04 // Set to 0 (pwrup = 1)
117 #define BOS 0x02 // Byte order select bit
118 #define WTS 0x01 // Word transfer select bit
119 #define IMR ETH_REG_BASE + 0x0F // Interrupt mask register
120 // Interrupt mask register bits
121 // Each enable bit correspons with an interrupt flag in ISR
123 // Page 1 read/write registers.
124 #define PAR0 ETH_REG_BASE + 0x01 // Physical address register 0
125 #define PAR1 ETH_REG_BASE + 0x02 // Physical address register 1
126 #define PAR2 ETH_REG_BASE + 0x03 // Physical address register 2
127 #define PAR3 ETH_REG_BASE + 0x04 // Physical address register 3
128 #define PAR4 ETH_REG_BASE + 0x05 // Physical address register 4
129 #define PAR5 ETH_REG_BASE + 0x06 // Physical address register 5
130 #define CURR ETH_REG_BASE + 0x07 // Current receive buffer page
131 #define MAR0 ETH_REG_BASE + 0x08
132 #define MAR1 ETH_REG_BASE + 0x09
133 #define MAR2 ETH_REG_BASE + 0x0A
134 #define MAR3 ETH_REG_BASE + 0x0B
135 #define MAR4 ETH_REG_BASE + 0x0C
136 #define MAR5 ETH_REG_BASE + 0x0D
137 #define MAR6 ETH_REG_BASE + 0x0E
138 #define MAR7 ETH_REG_BASE + 0x0F
140 // Page 2 read only registers.
141 // Each previously defined in page 0 write only.
142 //#define PSTART ETH_REG_BASE + 0x01
143 //#define PSTOP ETH_REG_BASE + 0x02
144 //#define TPSR ETH_REG_BASE + 0x04
145 //#define RCR ETH_REG_BASE + 0x0C
146 //#define TCR ETH_REG_BASE + 0x0D
147 //#define DCR ETH_REG_BASE + 0x0E
148 //#define IMR ETH_REG_BASE + 0x0F
150 // Page 3 read/write registers.
151 #define _9346CR ETH_REG_BASE + 0x01 // 9346 EEPROM command register
152 // 9346 EEPROM command register bits
153 #define EEM1 0x80 // RTL8019AS operating mode bit 1
154 #define EEM0 0x40 // RTL8019AS operating mode bit 0
155 #define EECS 0x08 // 9346 EEPROM chip select bit
156 #define EESK 0x04 // 9346 EEPROM serial clock bit
157 #define EEDI 0x02 // 9346 EEPROM data input bit
158 #define EEDO 0x01 // 9346 EEPROM data output bit
159 #define BPAGE ETH_REG_BASE + 0x02
160 #define CONFIG1 ETH_REG_BASE + 0x04 // RTL9019AS config register 1
161 // RTL9019AS config register 1 bits
162 #define IRQEN 0x80 // IRQ enable bit (WR protected)
163 #define IRQS2 0x40 // IRQ line select bit 2
164 #define IRQS1 0x20 // IRQ line select bit 1
165 #define IRQS0 0x10 // IRQ line select bit 0
166 #define IOS3 0x08 // I/O base address select bit 3
167 #define IOS2 0x04 // I/O base address select bit 2
168 #define IOS1 0x02 // I/O base address select bit 1
169 #define IOS0 0x01 // I/O base address select bit 0
170 #define CONFIG2 ETH_REG_BASE + 0x05 //
171 // RTL9019AS config register 2 bits
172 #define PL1 0x80 // Network medium type select bit 1
173 #define PL0 0x40 // Network medium type select bit 0
174 #define BSELB 0x20 // Boot ROM disable (WR protected)
175 #define BS4 0x10 // Boot ROM configuration bit 4
176 #define BS3 0x08 // Boot ROM configuration bit 3
177 #define BS2 0x04 // Boot ROM configuration bit 2
178 #define BS1 0x02 // Boot ROM configuration bit 1
179 #define BS0 0x01 // Boot ROM configuration bit 0
180 #define CONFIG3 ETH_REG_BASE + 0x06 // RTL9019AS config register 3
181 // RTL9019AS config register 3 bits
182 #define PNP 0x80 // Plug & play mode indicator bit
183 #define FUDUP 0x40 // Full duplex mode select bit
184 #define LEDS1 0x20 // LED output select bit 1
185 #define LEDS0 0x10 // LED output select bit 0
186 #define SLEEP 0x04 // Sleep mode select bit
187 #define PWRDN 0x02 // Power down mode select bit
188 #define ACTIVEB 0x01 // Inverse of bit 0, PNP active reg
190 // Page 3 read only registers.
191 #define CONFIG0 ETH_REG_BASE + 0x03 // RTL9019AS config register 0
192 // RTL9019AS config register 0 bits
193 #define VERID1 0x80 // RTL9019AS version ID bit 1 (R/W)
194 #define VERID0 0x40 // RTL9019AS version ID bit 0 (R/W)
195 #define AUI 0x20 // AUI input pin state bit
196 #define PNPJP 0x10 // PNP jumper pin state bit
197 #define JP 0x08 // JP input pin state bit
198 #define BNC 0x04 // Thinnet mode indication bit
199 #define CSNSAV ETH_REG_BASE + 0x08
200 #define INTR ETH_REG_BASE + 0x0B
201 #define CONFIG4 ETH_REG_BASE + 0x0D
203 // Page 3 write only registers.
204 #define TEST ETH_REG_BASE + 0x07
205 #define HLTCLK ETH_REG_BASE + 0x09
206 #define FMWP ETH_REG_BASE + 0x0C
209 // Bits del byte de status del frame recibido
210 #define RXSOK 0x01 /* Received a good packet */
211 #define RXSCRC 0x02 /* CRC error */
212 #define RXSFAE 0x04 /* frame alignment error */
213 #define RXSFO 0x08 /* FIFO overrun */
214 #define RXSMPA 0x10 /* missed pkt */
215 #define RXSPHY 0x20 /* physical/multicast address */
216 #define RXSDIS 0x40 /* receiver disable. set in monitor mode */
217 #define RXSDEF 0x80 /* deferring */
220 bool etherdev_init(void);
221 void etherdev_send(void);
222 unsigned int etherdev_read(void);