1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 #define TWE_MAX_UNITS 16
37 #define TWE_MAXOFFSETS 62
38 #define TWE_MAXCMDS 255
39 #define TWE_SECTOR_SIZE 512
40 #define TWE_ALIGN 512
41 #define TWE_MAXFER (TWE_MAXOFFSETS * PAGE_SIZE)
42
43
44 #define TWE_CONTROL 0x00
45 #define TWE_CTRL_CHOSTI 0x00080000
46 #define TWE_CTRL_CATTNI 0x00040000
47 #define TWE_CTRL_MCMDI 0x00020000
48 #define TWE_CTRL_MRDYI 0x00010000
49 #define TWE_CTRL_ECMDI 0x00008000
50 #define TWE_CTRL_ERDYI 0x00004000
51 #define TWE_CTRL_CERR 0x00000200
52 #define TWE_CTRL_SRST 0x00000100
53 #define TWE_CTRL_EINT 0x00000080
54 #define TWE_CTRL_MINT 0x00000040
55 #define TWE_CTRL_HOSTI 0x00000020
56 #define TWE_STATUS 0x04
57 #define TWE_STAT_MAJV 0xf0000000
58 #define TWE_MAJV(st) (((st) >> 28) & 0xf)
59 #define TWE_STAT_MINV 0x0f000000
60 #define TWE_MINV(st) (((st) >> 24) & 0xf)
61 #define TWE_STAT_PCIPAR 0x00800000
62 #define TWE_STAT_QUEUEE 0x00400000
63 #define TWE_STAT_CPUERR 0x00200000
64 #define TWE_STAT_PCIABR 0x00100000
65 #define TWE_STAT_HOSTI 0x00080000
66 #define TWE_STAT_ATTNI 0x00040000
67 #define TWE_STAT_CMDI 0x00020000
68 #define TWE_STAT_RDYI 0x00010000
69 #define TWE_STAT_CQF 0x00008000
70 #define TWE_STAT_RQE 0x00004000
71 #define TWE_STAT_CPURDY 0x00002000
72 #define TWE_STAT_CQR 0x00001000
73 #define TWE_STAT_FLAGS 0x00fff000
74 #define TWE_STAT_BITS "\020\015cqr\016cpurdy\017rqe\20cqf" \
75 "\021rdyi\022cmdi\023attni\024hosti\025pciabr\026cpuerr\027queuee\030pcipar"
76
77 #define TWE_COMMANDQUEUE 0x08
78
79
80
81
82
83 #define TWE_CMD_NOP 0x0200
84 #define TWE_CMD_INIT 0x0301
85 #define TWE_CMD_READ 0x0362
86 #define TWE_CMD_WRITE 0x0363
87 #define TWE_CMD_RDVRFY 0x0364
88 #define TWE_CMD_VERIFY 0x0365
89 #define TWE_CMD_ZRFUNIT 0x0208
90 #define TWE_CMD_RPLUNIT 0x0209
91 #define TWE_CMD_HOTSWAP 0x020a
92 #define TWE_CMD_SETATA 0x020c
93 #define TWE_CMD_FLUSH 0x020e
94 #define TWE_CMD_ABORT 0x020f
95 #define TWE_CMD_QSTAT 0x0210
96 #define TWE_CMD_GPARAM 0x0252
97 #define TWE_CMD_SPARAM 0x0253
98 #define TWE_CMD_NEWUNIT 0x0214
99 #define TWE_CMD_DELUNIT 0x0215
100 #define TWE_CMD_RBLUNIT 0x0217
101 #define TWE_CMD_SECINF 0x021a
102 #define TWE_CMD_AEN 0x021c
103 #define TWE_CMD_CMDPK 0x021d
104 #define TWE_READYQUEUE 0x0c
105 #define TWE_READYID(u) (((u) >> 4) & 0xff)
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121 #define TWE_PARAM_ALL 0x000
122 #define TWE_PARAM_DSUM 0x002
123 #define TWE_PARAM_UC 0x003
124 #define TWE_PARAM_DC 0x200
125 #define TWE_PARAM_UI 0x300
126 #define TWE_PARAM_AEN 0x401
127 #define TWE_PARAM_VER 0x402
128 #define TWE_PARAM_CTRL 0x403
129 #define TWE_PARAM_FTRS 0x404
130 #define TWE_PARAM_DIR 0xffff
131
132 #define TWE_AEN_QEMPTY 0x0000
133 #define TWE_AEN_SRST 0x0001
134 #define TWE_AEN_DMIRROR 0x0002
135 #define TWE_AEN_CERROR 0x0003
136 #define TWE_AEN_RBFAIL 0x0004
137 #define TWE_AEN_RBDONE 0x0005
138 #define TWE_AEN_ILLUN 0x0006
139 #define TWE_AEN_INDONE 0x0007
140 #define TWE_AEN_DSHUT 0x0008
141 #define TWE_AEN_APORT 0x0009
142 #define TWE_AEN_DRVERR 0x000a
143 #define TWE_AEN_RBSTART 0x000b
144 #define TWE_AEN_ISTART 0x000c
145 #define TWE_AEN_TUN 0x0015
146
147 #define TWE_AEN_QFULL 0x00ff
148
149 #pragma pack(1)
150
151
152 struct twe_param {
153 u_int16_t table_id;
154 u_int8_t param_id;
155 u_int8_t param_size;
156 u_int8_t data[1];
157 };
158
159 struct twe_segs {
160 u_int32_t twes_addr;
161 u_int32_t twes_len;
162 };
163
164 struct twe_cmd {
165 u_int16_t cmd_op;
166 u_int8_t cmd_index;
167 u_int8_t cmd_unit_host;
168 #define TWE_UNITHOST(u, h) (((u) & 0xf) | ((h) << 4))
169 u_int8_t cmd_status;
170 u_int8_t cmd_flags;
171 #define TWE_FLAGS_CACHEDISABLE 0x01
172 union {
173 struct {
174 u_int16_t count;
175 u_int32_t lba;
176 struct twe_segs segs[TWE_MAXOFFSETS];
177 u_int32_t pad;
178 } _cmd_io;
179 #define cmd_io _._cmd_io
180 struct {
181 u_int16_t count;
182 struct twe_segs segs[TWE_MAXOFFSETS];
183 } _cmd_param;
184 #define cmd_param _._cmd_param
185 struct {
186 u_int16_t msgcr;
187 u_int32_t rdy_q_ptr;
188 } _cmd_init;
189 #define cmd_init _._cmd_init
190 struct {
191 u_int8_t action;
192 #define TWE_HSWAP_REMOVE 0
193 #define TWE_HSWAP_ADDCBOD 1
194 #define TWE_HSWAP_ADDSPARE 2
195 u_int8_t port;
196 } _cmd_aport;
197 #define cmd_hswap _._cmd_hswap
198 struct {
199 u_int8_t feature;
200 #define TWE_ATA_WCE 0x02
201 #define TWE_ATA_NWCE 0x82
202 u_int8_t mode;
203 u_int16_t units;
204 u_int16_t persist;
205 } _cmd_ata;
206 #define cmd_ata _._cmd_ata
207 u_int16_t cmd_status;
208 struct {
209 u_int8_t action;
210 #define TWE_REBUILD_NOP 0
211 #define TWE_REBUILD_STOP 2
212 #define TWE_REBUILD_START 4
213 #define TWE_REBUILD_STARTU 5
214 #define TWE_REBUILD_CS 0x80
215 u_int8_t subunit;
216 } _cmd_rebuild;
217 #define cmd_rebuild _._cmd_rebuild
218 } _;
219 };
220
221 #pragma pack()