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