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