1 /*****************************************************************
2 *
3 * defines for 3Com Etherlink Plus adapter
4 *
5 *****************************************************************/
6
7 /*
8 * I/O register offsets
9 */
10 #define PORT_COMMAND 0x00 /* read/write, 8-bit */
11 #define PORT_STATUS 0x02 /* read only, 8-bit */
12 #define PORT_AUXDMA 0x02 /* write only, 8-bit */
13 #define PORT_DATA 0x04 /* read/write, 16-bit */
14 #define PORT_CONTROL 0x06 /* read/write, 8-bit */
15
16 #define ELP_IO_EXTENT 0x10 /* size of used IO registers */
17
18 /*
19 * host control registers bits
20 */
21 #define ATTN 0x80 /* attention */
22 #define FLSH 0x40 /* flush data register */
23 #define DMAE 0x20 /* DMA enable */
24 #define DIR 0x10 /* direction */
25 #define TCEN 0x08 /* terminal count interrupt enable */
26 #define CMDE 0x04 /* command register interrupt enable */
27 #define HSF2 0x02 /* host status flag 2 */
28 #define HSF1 0x01 /* host status flag 1 */
29
30 /*
31 * combinations of HSF flags used for PCB transmission
32 */
33 #define HSF_PCB_ACK HSF1
34 #define HSF_PCB_NAK HSF2
35 #define HSF_PCB_END (HSF2|HSF1)
36 #define HSF_PCB_MASK (HSF2|HSF1)
37
38 /*
39 * host status register bits
40 */
41 #define HRDY 0x80 /* data register ready */
42 #define HCRE 0x40 /* command register empty */
43 #define ACRF 0x20 /* adapter command register full */
44 /* #define DIR 0x10 direction - same as in control register */
45 #define DONE 0x08 /* DMA done */
46 #define ASF3 0x04 /* adapter status flag 3 */
47 #define ASF2 0x02 /* adapter status flag 2 */
48 #define ASF1 0x01 /* adapter status flag 1 */
49
50 /*
51 * combinations of ASF flags used for PCB reception
52 */
53 #define ASF_PCB_ACK ASF1
54 #define ASF_PCB_NAK ASF2
55 #define ASF_PCB_END (ASF2|ASF1)
56 #define ASF_PCB_MASK (ASF2|ASF1)
57
58 /*
59 * host aux DMA register bits
60 */
61 #define DMA_BRST 0x01 /* DMA burst */
62
63 /*
64 * maximum amount of data data allowed in a PCB
65 */
66 #define MAX_PCB_DATA 62
67
68 /*****************************************************************
69 *
70 * timeout value
71 * this is a rough value used for loops to stop them from
72 * locking up the whole machine in the case of failure or
73 * error conditions
74 *
75 *****************************************************************/
76
77 #define TIMEOUT 300
78
79 /*****************************************************************
80 *
81 * PCB commands
82 *
83 *****************************************************************/
84
85 enum {
86 /*
87 * host PCB commands
88 */
89 CMD_CONFIGURE_ADAPTER_MEMORY = 0x01,
90 CMD_CONFIGURE_82586 = 0x02,
91 CMD_STATION_ADDRESS = 0x03,
92 CMD_DMA_DOWNLOAD = 0x04,
93 CMD_DMA_UPLOAD = 0x05,
94 CMD_PIO_DOWNLOAD = 0x06,
95 CMD_PIO_UPLOAD = 0x07,
96 CMD_RECEIVE_PACKET = 0x08,
97 CMD_TRANSMIT_PACKET = 0x09,
98 CMD_NETWORK_STATISTICS = 0x0a,
99 CMD_LOAD_MULTICAST_LIST = 0x0b,
100 CMD_CLEAR_PROGRAM = 0x0c,
101 CMD_DOWNLOAD_PROGRAM = 0x0d,
102 CMD_EXECUTE_PROGRAM = 0x0e,
103 CMD_SELF_TEST = 0x0f,
104 CMD_SET_STATION_ADDRESS = 0x10,
105 CMD_ADAPTER_INFO = 0x11,
106 NUM_TRANSMIT_CMDS,
107
108 /*
109 * adapter PCB commands
110 */
111 CMD_CONFIGURE_ADAPTER_RESPONSE = 0x31,
112 CMD_CONFIGURE_82586_RESPONSE = 0x32,
113 CMD_ADDRESS_RESPONSE = 0x33,
114 CMD_DOWNLOAD_DATA_REQUEST = 0x34,
115 CMD_UPLOAD_DATA_REQUEST = 0x35,
116 CMD_RECEIVE_PACKET_COMPLETE = 0x38,
117 CMD_TRANSMIT_PACKET_COMPLETE = 0x39,
118 CMD_NETWORK_STATISTICS_RESPONSE = 0x3a,
119 CMD_LOAD_MULTICAST_RESPONSE = 0x3b,
120 CMD_CLEAR_PROGRAM_RESPONSE = 0x3c,
121 CMD_DOWNLOAD_PROGRAM_RESPONSE = 0x3d,
122 CMD_EXECUTE_RESPONSE = 0x3e,
123 CMD_SELF_TEST_RESPONSE = 0x3f,
124 CMD_SET_ADDRESS_RESPONSE = 0x40,
125 CMD_ADAPTER_INFO_RESPONSE = 0x41
126 };
127
128 /* Definitions for the PCB data structure */
129
130 /* Data units */
131 typedef unsigned char byte;
132 typedef unsigned short int word;
133 typedef unsigned long int dword;
134
135 /* Data structures */
136 struct Memconf {
137 word cmd_q,
138 rcv_q,
139 mcast,
140 frame,
141 rcv_b,
142 progs;
143 };
144
145 struct Rcv_pkt {
146 word buf_ofs,
147 buf_seg,
148 buf_len,
149 timeout;
150 };
151
152 struct Xmit_pkt {
153 word buf_ofs,
154 buf_seg,
155 pkt_len;
156 };
157
158 struct Rcv_resp {
159 word buf_ofs,
160 buf_seg,
161 buf_len,
162 pkt_len,
163 timeout,
164 status;
165 dword timetag;
166 };
167
168 struct Xmit_resp {
169 word buf_ofs,
170 buf_seg,
171 c_stat,
172 status;
173 };
174
175
176 struct Netstat {
177 dword tot_recv,
178 tot_xmit;
179 word err_CRC,
180 err_align,
181 err_res,
182 err_ovrrun;
183 };
184
185
186 struct Selftest {
187 word error;
188 union {
189 word ROM_cksum;
190 struct {
191 word ofs, seg;
192 } RAM;
193 word i82586;
194 } failure;
195 };
196
197 struct Info {
198 byte minor_vers,
199 major_vers;
200 word ROM_cksum,
201 RAM_sz,
202 free_ofs,
203 free_seg;
204 };
205
206 struct Memdump {
207 word size,
208 off,
209 seg;
210 };
211
212 /*
213 Primary Command Block. The most important data structure. All communication
214 between the host and the adapter is done with these. (Except for the actual
215 ethernet data, which has different packaging.)
216 */
217 typedef struct {
218 byte command;
219 byte length;
220 union {
221 struct Memconf memconf;
222 word configure;
223 struct Rcv_pkt rcv_pkt;
224 struct Xmit_pkt xmit_pkt;
225 byte multicast[10][6];
226 byte eth_addr[6];
227 byte failed;
228 struct Rcv_resp rcv_resp;
229 struct Xmit_resp xmit_resp;
230 struct Netstat netstat;
231 struct Selftest selftest;
232 struct Info info;
233 struct Memdump memdump;
234 byte raw[62];
235 } data;
236 } pcb_struct;
237
238 /* These defines for 'configure' */
239 #define RECV_STATION 0x00
240 #define RECV_BROAD 0x01
241 #define RECV_MULTI 0x02
242 #define RECV_PROMISC 0x04
243 #define NO_LOOPBACK 0x00
244 #define INT_LOOPBACK 0x08
245 #define EXT_LOOPBACK 0x10