1 /* $NetBSD: i82586reg.h,v 1.12 2007/03/04 06:01:56 christos Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1992, University of Vermont and State Agricultural College.
34 * Copyright (c) 1992, Garrett A. Wollman.
35 * All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * Vermont and State Agricultural College and Garrett A. Wollman.
49 * 4. Neither the name of the University nor the name of the author
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR AUTHOR BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * Intel 82586 Ethernet chip
68 * Register, bit, and structure definitions.
70 * Written by GAW with reference to the Clarkson Packet Driver code for this
71 * chip written by Russ Nelson and others.
75 * NOTE, the structure definitions in here are for reference only.
76 * We use integer offsets exclusively to access the i82586 data structures.
80 * The i82596 has a hardware port that can be used to command the
81 * chip to perform special functions. For all but IE_PORT_RESET,
82 * a 16-byte aligned memory address is ORed into the port command.
84 #define IE_PORT_RESET 0x00 /* software reset */
85 #define IE_PORT_SELF_TEST 0x01 /* self-test */
86 #define IE_PORT_ALT_SCP 0x02 /* set alternate SCP address */
87 #define IE_PORT_DUMP 0x03 /* dump state */
90 * This is the master configuration block.
91 * It tells the hardware where all the rest of the stuff is.
93 struct __ie_sys_conf_ptr {
94 u_int16_t mbz; // must be zero
95 u_int8_t ie_bus_use; // true if 8-bit only
96 u_int8_t mbz2[5]; // must be zero
97 u_int32_t ie_iscp_ptr; // 24-bit physaddr of ISCP
101 #define IE_SCP_BUS_USE(base) ((base) + 2)
102 #define IE_SCP_ISCP(base) ((base) + 8)
105 * SYSBUS byte flags. Most are specific to the i82596, and so
106 * far we always run an i82596 in i82586-compatible mode.
108 #define IE_SYSBUS_16BIT (0x0 << 0)
109 #define IE_SYSBUS_8BIT (0x1 << 0)
110 #define IE_SYSBUS_596_82586 (0x0 << 1)
111 #define IE_SYSBUS_596_32SEG (0x1 << 1)
112 #define IE_SYSBUS_596_LINEAR (0x2 << 1)
113 #define IE_SYSBUS_596_TRGINT (0x0 << 3)
114 #define IE_SYSBUS_596_TRGEXT (0x1 << 3)
115 #define IE_SYSBUS_596_NOLOCK (0x0 << 4)
116 #define IE_SYSBUS_596_LOCK (0x1 << 4)
117 #define IE_SYSBUS_596_INTHIGH (0x0 << 4)
118 #define IE_SYSBUS_596_INTLOW (0x1 << 5)
119 #define IE_SYSBUS_596_RSVD_SET (0x1 << 6)
120 #define IE_SYSBUS_596_LE (0x0 << 7)
121 #define IE_SYSBUS_596_BE (0x1 << 7)
124 * Note that this is wired in hardware; the SCP is always located here, no
127 #define IE_SCP_ADDR 0xfffff4
130 * The tells the hardware where all the rest of the stuff is, too.
131 * FIXME: some of these should be re-commented after we figure out their
134 struct __ie_int_sys_conf_ptr {
135 u_int8_t ie_busy; // zeroed after init
137 u_int16_t ie_scb_offset; // 16-bit physaddr of next struct
138 void * ie_base; // 24-bit physaddr for all 16-bit vars
142 #define IE_ISCP_BUSY(base) ((base) + 0)
143 #define IE_ISCP_SCB(base) ((base) + 2)
144 #define IE_ISCP_BASE(base) ((base) + 4)
147 * This FINALLY tells the hardware what to do and where to put it.
149 struct __ie_sys_ctl_block {
150 u_int16_t ie_status; // status word
151 u_int16_t ie_command; // command word
152 u_int16_t ie_command_list; // 16-pointer to command block list
153 u_int16_t ie_recv_list; // 16-pointer to receive frame list
154 u_int16_t ie_err_crc; // CRC errors
155 u_int16_t ie_err_align; // Alignment errors
156 u_int16_t ie_err_resource; // Resource errors
157 u_int16_t ie_err_overrun; // Overrun errors
161 #define IE_SCB_STATUS(base) ((base) + 0)
162 #define IE_SCB_CMD(base) ((base) + 2)
163 #define IE_SCB_CMDLST(base) ((base) + 4)
164 #define IE_SCB_RCVLST(base) ((base) + 6)
165 #define IE_SCB_ERRCRC(base) ((base) + 8)
166 #define IE_SCB_ERRALN(base) ((base) + 10)
167 #define IE_SCB_ERRRES(base) ((base) + 12)
168 #define IE_SCB_ERROVR(base) ((base) + 14)
171 #define IE_RUC_MASK 0x0070 /* mask for RU command */
172 #define IE_RUC_NOP 0 /* for completeness */
173 #define IE_RUC_START 0x0010 /* start receive unit command */
174 #define IE_RUC_RESUME 0x0020 /* resume a suspended receiver command */
175 #define IE_RUC_SUSPEND 0x0030 /* suspend receiver command */
176 #define IE_RUC_ABORT 0x0040 /* abort current receive operation */
178 #define IE_CUC_MASK 0x0700 /* mask for CU command */
179 #define IE_CUC_NOP 0 /* included for completeness */
180 #define IE_CUC_START 0x0100 /* do-command command */
181 #define IE_CUC_RESUME 0x0200 /* resume a suspended cmd list */
182 #define IE_CUC_SUSPEND 0x0300 /* suspend current command */
183 #define IE_CUC_ABORT 0x0400 /* abort current command */
185 #define IE_ACK_COMMAND 0xf000 /* mask for ACK command */
186 #define IE_ACK_CX 0x8000 /* ack IE_ST_CX */
187 #define IE_ACK_FR 0x4000 /* ack IE_ST_FR */
188 #define IE_ACK_CNA 0x2000 /* ack IE_ST_CNA */
189 #define IE_ACK_RNR 0x1000 /* ack IE_ST_RNR */
191 #define IE_ACTION_COMMAND(x) (((x) & IE_CUC_MASK) == IE_CUC_START)
192 /* is this command an action command? */
195 #define IE_ST_WHENCE 0xf000 /* mask for cause of interrupt */
196 #define IE_ST_CX 0x8000 /* command with I bit completed */
197 #define IE_ST_FR 0x4000 /* frame received */
198 #define IE_ST_CNA 0x2000 /* all commands completed */
199 #define IE_ST_RNR 0x1000 /* receive not ready */
201 #define IE_CUS_MASK 0x0700 /* mask for command unit status */
202 #define IE_CUS_ACTIVE 0x0200 /* command unit is active */
203 #define IE_CUS_SUSPEND 0x0100 /* command unit is suspended */
205 #define IE_RUS_MASK 0x0070 /* mask for receiver unit status */
206 #define IE_RUS_SUSPEND 0x0010 /* receiver is suspended */
207 #define IE_RUS_NOSPACE 0x0020 /* receiver has no resources */
208 #define IE_RUS_READY 0x0040 /* receiver is ready */
211 * This is filled in partially by the chip, partially by us.
213 struct __ie_recv_frame_desc {
214 u_int16_t ie_fd_status; // status for this frame
215 u_int16_t ie_fd_last; // end of frame list flag
216 u_int16_t ie_fd_next; // 16-pointer to next RFD
217 u_int16_t ie_fd_buf_desc; // 16-pointer to list of buffer descs
218 struct __ie_en_addr dest; // destination ether
219 struct __ie_en_addr src; // source ether
220 u_int16_t ie_length; // 802 length/Ether type
221 u_short mbz; // must be zero
224 #define IE_RFRAME_SZ 24
225 #define IE_RFRAME_ADDR(base,i) ((base) + (i) * IE_RFRAME_SZ)
226 #define IE_RFRAME_STATUS(b,i) (IE_RFRAME_ADDR(b,i) + 0)
227 #define IE_RFRAME_LAST(b,i) (IE_RFRAME_ADDR(b,i) + 2)
228 #define IE_RFRAME_NEXT(b,i) (IE_RFRAME_ADDR(b,i) + 4)
229 #define IE_RFRAME_BUFDESC(b,i) (IE_RFRAME_ADDR(b,i) + 6)
230 #define IE_RFRAME_EDST(b,i) (IE_RFRAME_ADDR(b,i) + 8)
231 #define IE_RFRAME_ESRC(b,i) (IE_RFRAME_ADDR(b,i) + 14)
232 #define IE_RFRAME_ELEN(b,i) (IE_RFRAME_ADDR(b,i) + 20)
235 #define IE_FD_EOL 0x8000 /* last rfd in list */
236 #define IE_FD_SUSP 0x4000 /* suspend RU after receipt */
238 /* status field bits */
239 #define IE_FD_COMPLETE 0x8000 /* frame is complete */
240 #define IE_FD_BUSY 0x4000 /* frame is busy */
241 #define IE_FD_OK 0x2000 /* frame is ok */
242 #define IE_FD_CRC 0x0800 /* CRC error */
243 #define IE_FD_ALGN 0x0400 /* Alignment error */
244 #define IE_FD_RNR 0x0200 /* receiver out of resources here */
245 #define IE_FD_OVR 0x0100 /* DMA overrun */
246 #define IE_FD_SHORT 0x0080 /* Short frame */
247 #define IE_FD_NOEOF 0x0040 /* no EOF (?) */
248 #define IE_FD_ERRMASK /* all error bits */ \
249 (IE_FD_CRC|IE_FD_ALGN|IE_FD_RNR|IE_FD_OVR|IE_FD_SHORT|IE_FD_NOEOF)
250 #define IE_FD_STATUSBITS \
251 "\20\20COMPLT\17BUSY\16OK\14CRC\13ALGN\12RNR\11OVR\10SHORT\7NOEOF"
254 * linked list of buffers...
256 struct __ie_recv_buf_desc {
257 u_int16_t ie_rbd_status; // status for this buffer
258 u_int16_t ie_rbd_next; // 16-pointer to next RBD
259 void * ie_rbd_buffer; // 24-pointer to buffer for this RBD
260 u_int16_t ie_rbd_length; // length of the buffer
261 u_int16_t mbz; // must be zero
265 #define IE_RBD_ADDR(base,i) ((base) + (i) * IE_RBD_SZ)
266 #define IE_RBD_STATUS(b,i) (IE_RBD_ADDR(b,i) + 0)
267 #define IE_RBD_NEXT(b,i) (IE_RBD_ADDR(b,i) + 2)
268 #define IE_RBD_BUFADDR(b,i) (IE_RBD_ADDR(b,i) + 4)
269 #define IE_RBD_BUFLEN(b,i) (IE_RBD_ADDR(b,i) + 8)
271 /* RBD status fields */
272 #define IE_RBD_LAST 0x8000 /* last buffer */
273 #define IE_RBD_USED 0x4000 /* this buffer has data */
274 #define IE_RBD_CNTMASK 0x3fff /* byte count of buffer data */
276 /* RDB `End Of List' flag; encoded in `buffer length' field */
277 #define IE_RBD_EOL 0x8000 /* last buffer */
281 * All commands share this in common.
283 struct __ie_cmd_common {
284 u_int16_t ie_cmd_status; // status of this command
285 u_int16_t ie_cmd_cmd; // command word
286 u_int16_t ie_cmd_link; // link to next command
289 #define IE_CMD_COMMON_SZ 6
290 #define IE_CMD_COMMON_STATUS(base) ((base) + 0)
291 #define IE_CMD_COMMON_CMD(base) ((base) + 2)
292 #define IE_CMD_COMMON_LINK(base) ((base) + 4)
294 #define IE_STAT_COMPL 0x8000 /* command is completed */
295 #define IE_STAT_BUSY 0x4000 /* command is running now */
296 #define IE_STAT_OK 0x2000 /* command completed successfully */
297 #define IE_STAT_ABORT 0x1000 /* command was aborted */
299 #define IE_CMD_NOP 0x0000 /* NOP */
300 #define IE_CMD_IASETUP 0x0001 /* initial address setup */
301 #define IE_CMD_CONFIG 0x0002 /* configure command */
302 #define IE_CMD_MCAST 0x0003 /* multicast setup command */
303 #define IE_CMD_XMIT 0x0004 /* transmit command */
304 #define IE_CMD_TDR 0x0005 /* time-domain reflectometer command */
305 #define IE_CMD_DUMP 0x0006 /* dump command */
306 #define IE_CMD_DIAGNOSE 0x0007 /* diagnostics command */
308 #define IE_CMD_LAST 0x8000 /* this is the last command in the list */
309 #define IE_CMD_SUSPEND 0x4000 /* suspend CU after this command */
310 #define IE_CMD_INTR 0x2000 /* post an interrupt after completion */
313 * No-op commands; just like COMMON but "indexable"
315 #define IE_CMD_NOP_SZ IE_CMD_COMMON_SZ
316 #define IE_CMD_NOP_ADDR(base,i) ((base) + (i) * IE_CMD_NOP_SZ)
317 #define IE_CMD_NOP_STATUS(b,i) (IE_CMD_NOP_ADDR(b,i) + 0)
318 #define IE_CMD_NOP_CMD(b,i) (IE_CMD_NOP_ADDR(b,i) + 2)
319 #define IE_CMD_NOP_LINK(b,i) (IE_CMD_NOP_ADDR(b,i) + 4)
323 * This is the command to transmit a frame.
325 struct __ie_xmit_cmd {
326 struct __ie_cmd_common com; // common part
327 #define __ie_xmit_status com.ie_cmd_status
329 u_int16_t ie_xmit_desc; // pointer to buffer descriptor
330 struct __ie_en_addr ie_xmit_addr; // destination address
331 u_int16_t ie_xmit_length; // 802.3 length/Ether type field
334 #define IE_CMD_XMIT_SZ (IE_CMD_COMMON_SZ + 10)
335 #define IE_CMD_XMIT_ADDR(base,i) ((base) + (i) * IE_CMD_XMIT_SZ)
336 #define IE_CMD_XMIT_STATUS(b,i) \
337 (IE_CMD_XMIT_ADDR(b,i) + 0) /* == CMD_COMMON_STATUS */
338 #define IE_CMD_XMIT_CMD(b,i) \
339 (IE_CMD_XMIT_ADDR(b,i) + 2) /* == CMD_COMMON_CMD */
340 #define IE_CMD_XMIT_LINK(b,i) \
341 (IE_CMD_XMIT_ADDR(b,i) + 4) /* == CMD_COMMON_LINK */
342 #define IE_CMD_XMIT_DESC(b,i) \
343 (IE_CMD_XMIT_ADDR(b,i) + IE_CMD_COMMON_SZ + 0)
344 #define IE_CMD_XMIT_EADDR(b,i) \
345 (IE_CMD_XMIT_ADDR(b,i) + IE_CMD_COMMON_SZ + 2)
346 #define IE_CMD_XMIT_LEN(b,i) \
347 (IE_CMD_XMIT_ADDR(b,i) + IE_CMD_COMMON_SZ + 8)
349 #define IE_XS_MAXCOLL 0x000f /* number of collisions during transmit */
350 #define IE_XS_EXCMAX 0x0020 /* exceeded maximum number of collisions */
351 #define IE_XS_SQE 0x0040 /* SQE positive */
352 #define IE_XS_DEFERRED 0x0080 /* transmission deferred */
353 #define IE_XS_UNDERRUN 0x0100 /* DMA underrun */
354 #define IE_XS_LOSTCTS 0x0200 /* Lost CTS */
355 #define IE_XS_NOCARRIER 0x0400 /* No Carrier */
356 #define IE_XS_LATECOLL 0x0800 /* Late collision */
359 * This is a buffer descriptor for a frame to be transmitted.
361 struct __ie_xmit_buf {
362 u_int16_t ie_xmit_flags; // see below
363 u_int16_t ie_xmit_next; // 16-pointer to next desc
364 void *ie_xmit_buf; // 24-pointer to the actual buffer
368 #define IE_XBD_ADDR(base,i) ((base) + (i) * IE_XBD_SZ)
369 #define IE_XBD_FLAGS(b,i) (IE_XBD_ADDR(b,i) + 0)
370 #define IE_XBD_NEXT(b,i) (IE_XBD_ADDR(b,i) + 2)
371 #define IE_XBD_BUF(b,i) (IE_XBD_ADDR(b,i) + 4)
373 #define IE_TBD_EOL 0x8000 /* this TBD is the last one */
374 #define IE_TBD_CNTMASK 0x3fff /* The rest of the `flags' word
375 is actually the length. */
379 * Multicast setup command.
381 struct __ie_mcast_cmd {
382 struct __ie_cmd_common com; // common part
383 #define ie_mcast_status com.ie_cmd_status
385 // size (in bytes) of multicast addresses
386 u_short ie_mcast_bytes;
387 struct __ie_en_addr ie_mcast_addrs[IE_MAXMCAST + 1];// space for them
390 #define IE_CMD_MCAST_SZ (IE_CMD_COMMON_SZ + 2 /* + XXX */)
391 #define IE_CMD_MCAST_BYTES(base) ((base) + IE_CMD_COMMON_SZ + 0)
392 #define IE_CMD_MCAST_MADDR(base) ((base) + IE_CMD_COMMON_SZ + 2)
395 * Time Domain Reflectometer command.
397 struct __ie_tdr_cmd {
398 struct __ie_cmd_common com; // common part
399 #define ie_tdr_status com.ie_cmd_status
400 u_short ie_tdr_time; // error bits and time
403 #define IE_CMD_TDR_SZ (IE_CMD_COMMON_SZ + 2)
404 #define IE_CMD_TDR_TIME(base) ((base) + IE_CMD_COMMON_SZ + 0)
406 #define IE_TDR_SUCCESS 0x8000 /* TDR succeeded without error */
407 #define IE_TDR_XCVR 0x4000 /* detected a transceiver problem */
408 #define IE_TDR_OPEN 0x2000 /* detected an incorrect termination ("open") */
409 #define IE_TDR_SHORT 0x1000 /* TDR detected a short circuit */
410 #define IE_TDR_TIME 0x07ff /* mask for reflection time */
413 * Initial Address Setup command
415 struct __ie_iasetup_cmd {
416 struct __ie_cmd_common com;
417 #define ie_iasetup_status com.ie_cmd_status
418 struct __ie_en_addr ie_address;
421 #define IE_CMD_IAS_SZ (IE_CMD_COMMON_SZ + 6)
422 #define IE_CMD_IAS_EADDR(base) ((base) + IE_CMD_COMMON_SZ + 0)
425 * Configuration command
427 struct __ie_config_cmd {
428 struct __ie_cmd_common com; // common part
429 #define ie_config_status com.ie_cmd_status
431 u_int8_t ie_config_count; // byte count (0x0c)
432 u_int8_t ie_fifo; // fifo (8)
433 u_int8_t ie_save_bad; // save bad frames (0x40)
434 u_int8_t ie_addr_len; // address length (0x2e) (AL-LOC == 1)
435 u_int8_t ie_priority; // priority and backoff (0x0)
436 u_int8_t ie_ifs; // inter-frame spacing (0x60)
437 u_int8_t ie_slot_low; // slot time, LSB (0x0)
438 u_int8_t ie_slot_high; // slot time, MSN, and retries (0xf2)
439 u_int8_t ie_promisc; // 1 if promiscuous, else 0
440 u_int8_t ie_crs_cdt; // CSMA/CD parameters (0x0)
441 u_int8_t ie_min_len; // min frame length (0x40)
442 u_int8_t ie_junk; // stuff for 82596 (0xff)
445 #define IE_CMD_CFG_SZ (IE_CMD_COMMON_SZ + 12)
446 #define IE_CMD_CFG_CNT(base) ((base) + IE_CMD_COMMON_SZ + 0)
447 #define IE_CMD_CFG_FIFO(base) ((base) + IE_CMD_COMMON_SZ + 1)
448 #define IE_CMD_CFG_SAVEBAD(base) ((base) + IE_CMD_COMMON_SZ + 2)
449 #define IE_CMD_CFG_ADDRLEN(base) ((base) + IE_CMD_COMMON_SZ + 3)
450 #define IE_CMD_CFG_PRIORITY(base) ((base) + IE_CMD_COMMON_SZ + 4)
451 #define IE_CMD_CFG_IFS(base) ((base) + IE_CMD_COMMON_SZ + 5)
452 #define IE_CMD_CFG_SLOT_LOW(base) ((base) + IE_CMD_COMMON_SZ + 6)
453 #define IE_CMD_CFG_SLOT_HIGH(base) ((base) + IE_CMD_COMMON_SZ + 7)
454 #define IE_CMD_CFG_PROMISC(base) ((base) + IE_CMD_COMMON_SZ + 8)
455 #define IE_CMD_CFG_CRSCDT(base) ((base) + IE_CMD_COMMON_SZ + 9)
456 #define IE_CMD_CFG_MINLEN(base) ((base) + IE_CMD_COMMON_SZ + 10)
457 #define IE_CMD_CFG_JUNK(base) ((base) + IE_CMD_COMMON_SZ + 11)