AMD64 - Sync AMD64 support from Jordan Gordeev's svn repository and
[dragonfly.git] / sys / platform / pc64 / isa / ic / Am7990.h
1 /*
2  * Am7990, Local Area Network Controller for Ethernet (LANCE)
3  *
4  * Copyright (c) 1994, Paul Richards. This software may be used,
5  * modified, copied, distributed, and sold, in both source and binary
6  * form provided that the above copyright and these terms are retained.
7  * Under no circumstances is the author responsible for the proper
8  * functioning of this software, nor does the author assume any
9  * responsibility for damages incurred with its use.
10  *
11  * $DragonFly: src/sys/platform/pc64/isa/ic/Attic/Am7990.h,v 1.1 2008/08/29 17:07:21 dillon Exp $
12  */
13
14 /*
15  * The LANCE has four Control and Status Registers(CSRs) which are accessed
16  * through two bus addressable ports, the address port (RAP) and the data
17  * port (RDP).
18  *
19  */
20
21 #define CSR0    0
22 #define CSR1    1
23 #define CSR2    2
24 #define CSR3    3
25 #define CSR88   88
26 #define CSR89   89
27
28 #define BCR49   49
29 #define BCR32   32
30 #define BCR33   33
31 #define BCR34   34
32
33
34 /* Control and Status Register Masks */
35
36 /* CSR0 */
37
38 #define ERR     0x8000
39 #define BABL    0x4000
40 #define CERR    0x2000
41 #define MISS    0x1000
42 #define MERR    0x0800
43 #define RINT    0x0400
44 #define TINT    0x0200
45 #define IDON    0x0100
46 #define INTR    0x0080
47 #define INEA    0x0040
48 #define RXON    0x0020
49 #define TXON    0x0010
50 #define TDMD    0x0008
51 #define STOP    0x0004
52 #define STRT    0x0002
53 #define INIT    0x0001
54
55 /*
56  * CSR3
57  *
58  * Bits 3-15 are reserved.
59  *
60  */
61
62 #define BSWP    0x0004
63 #define ACON    0x0002
64 #define BCON    0x0001
65
66 /* Initialisation block */
67
68 struct init_block {
69         u_short mode;           /* Mode register                        */
70         u_char  padr[6];        /* Ethernet address                     */
71         u_char  ladrf[8];       /* Logical address filter (multicast)   */
72         u_short rdra;           /* Low order pointer to receive ring    */
73         u_short rlen;           /* High order pointer and no. rings     */
74         u_short tdra;           /* Low order pointer to transmit ring   */
75         u_short tlen;           /* High order pointer and no rings      */
76 };
77
78 /* Initialisation Block Mode Register Masks */
79
80 #define PROM      0x8000   /* Promiscuous Mode */
81 #define DRCVBC    0x4000   /* Disable Receive Broadcast */
82 #define DRCVPA    0x2000   /* Disable Receive Physical Address */
83 #define DLNKTST 0x1000   /* Disable Link Status */
84 #define DAPC      0x0800   /* Disable Automatic Polarity Correction */
85 #define MENDECL   0x0400   /* MENDEC Loopback Mode */
86 #define LRT       0x0200   /* Low Receive Threshold (T-MAU mode only) */
87 #define TSEL      0x0200   /* Transmit Mode Select  (AUI mode only) */
88 #define PORTSEL   0x0180   /* Port Select bits */
89 #define INTL      0x0040   /* Internal Loopback */
90 #define DRTY      0x0020   /* Disable Retry */
91 #define FCOLL     0x0010   /* Force Collision */
92 #define DXMTFCS   0x0008   /* Disable transmit CRC (FCS) */
93 #define LOOP      0x0004   /* Loopback Enabl */
94 #define DTX       0x0002   /* Disable the transmitter */
95 #define DRX       0x0001   /* Disable the receiver */
96
97 /*
98  * Message Descriptor Structure
99  *
100  * Each transmit or receive descriptor ring entry (RDRE's and TDRE's)
101  * is composed of 4, 16-bit, message descriptors. They contain the following
102  * information.
103  *
104  * 1. The address of the actual message data buffer in user (host) memory.
105  * 2. The length of that message buffer.
106  * 3. The status information for that particular buffer. The eight most
107  *    significant bits of md1 are collectively termed the STATUS of the
108  *    descriptor.
109  *
110  * Descriptor md0 contains LADR 0-15, the low order 16 bits of the 24-bit
111  * address of the actual data buffer.  Bits 0-7 of descriptor md1 contain
112  * HADR, the high order 8-bits of the 24-bit data buffer address. Bits 8-15
113  * of md1 contain the status flags of the buffer. Descriptor md2 contains the
114  * buffer byte count in bits 0-11 as a two's complement number and must have
115  * 1's written to bits 12-15. For the receive entry md3 has the Message Byte
116  * Count in bits 0-11, this is the length of the received message and is valid
117  * only when ERR is cleared and ENP is set. For the transmit entry it contains
118  * more status information.
119  *
120  */
121
122 struct mds {
123         u_short md0;
124         u_short md1;
125         short   md2;
126         u_short md3;
127 };
128
129 /* Receive STATUS flags for md1 */
130
131 #define OWN     0x8000          /* Owner bit, 0=host, 1=Lance   */
132 #define MDERR   0x4000          /* Error                        */
133 #define FRAM    0x2000          /* Framing error error          */
134 #define OFLO    0x1000          /* Silo overflow                */
135 #define CRC     0x0800          /* CRC error                    */
136 #define RBUFF   0x0400          /* Buffer error                 */
137 #define STP     0x0200          /* Start of packet              */
138 #define ENP     0x0100          /* End of packet                */
139 #define HADR    0x00FF          /* High order address bits      */
140
141 /* Receive STATUS flags for md2 */
142
143 #define BCNT    0x0FFF          /* Size of data buffer as 2's comp. no. */
144
145 /* Receive STATUS flags for md3 */
146
147 #define MCNT    0x0FFF          /* Total size of data for received packet */
148
149 /* Transmit STATUS flags for md1 */
150
151 #define ADD_FCS 0x2000          /* Controls generation of FCS   */
152 #define MORE    0x1000          /* Indicates more than one retry was needed */
153 #define ONE     0x0800          /* Exactly one retry was needed */
154 #define DEF     0x0400          /* Packet transmit deferred -- channel busy */
155
156 /*
157  * Transmit status flags for md2
158  *
159  * Same as for receive descriptor.
160  *
161  * BCNT   0x0FFF         Size of data buffer as 2's complement number.
162  *
163  */
164
165 /* Transmit status flags for md3 */
166
167 #define TBUFF   0x8000          /* Buffer error         */
168 #define UFLO    0x4000          /* Silo underflow       */
169 #define LCOL    0x1000          /* Late collision       */
170 #define LCAR    0x0800          /* Loss of carrier      */
171 #define RTRY    0x0400          /* Tried 16 times       */
172 #define TDR     0x03FF          /* Time domain reflectometry */
173