Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / sas / include / sas_disk.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: sas_disk.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23#ifndef SAS_DISK_H_
24#define SAS_DISK_H_
25
26
27#include <sys/types.h>
28
29#define MAX_SCSI_COMMAND_SIZE 0x0C
30
31#define SCSI_COMMAND_TEST_UNIT_READY 0x00
32#define SCSI_COMMAND_REQUEST_SENSE 0x03
33#define SCSI_COMMAND_READ 0x08
34#define SCSI_COMMAND_WRITE 0x0A
35#define SCSI_COMMAND_INQUIRY 0x12
36#define SCSI_COMMAND_MODE_SENSE 0x1A
37#define SCSI_COMMAND_START_STOP_UNIT 0x1B
38#define SCSI_COMMAND_READ_CAPACITY 0x25
39#define SCSI_COMMAND_READ_LONG 0x28
40#define SCSI_COMMAND_WRITE_LONG 0x2A
41#define SCSI_COMMAND_LOG_SENSE 0x4D
42#define SCSI_COMMAND_PERSISTENT_RESERVE_IN 0x5E
43
44#define SCSI_COMMAND_REPORT_LUNS 0xA0
45
46#define STATUS_MASK 0x3E
47#define STATUS_GOOD 0x00
48#define STATUS_CHECK 0x02
49#define STATUS_MET 0x04
50#define STATUS_BUSY 0x08
51#define STATUS_INTERMEDIATE 0x10
52#define STATUS_SCSI2 0x20
53#define STATUS_INTERMEDIATE_MET 0x14
54#define STATUS_RESERVATION_CONFLICT 0x18
55#define STATUS_TERMINATED 0x22
56#define STATUS_QFULL 0x28
57#define STATUS_ACA_ACTIVE 0x30
58
59
60struct scsi_command_report_luns {
61 uint8_t opcode;
62 uint8_t res1;
63 uint8_t select_report;
64 uint8_t res2[3];
65 uint8_t allocation_length[4]; // big endian
66 uint8_t res3;
67 uint8_t control;
68};
69typedef struct scsi_command_report_luns scsi_command_report_luns_t;
70
71#define REPORT_LUNS_MIN_LUNS 2
72
73struct scsi_report_luns {
74 /* Number of bytes of data the target has available to send. */
75 uint32_t lun_list_len;
76 uint32_t reserved;
77 uint64_t lun[REPORT_LUNS_MIN_LUNS];
78};
79
80
81
82struct scsi_command_write {
83 uchar_t opcode;
84#if defined(ARCH_X64)
85 uchar_t lblk_msb:5,
86 lun:3;
87#else
88 uchar_t lun:3,
89 lblk_msb:5;
90#endif
91 ushort_t lblk;
92 uchar_t transfer_length;
93 uchar_t control;
94};
95
96typedef struct scsi_command_write scsi_command_write_t;
97
98
99struct scsi_command_write_long {
100 uchar_t opcode;
101#if defined(ARCH_X64)
102 uchar_t reladr:1,
103 res1:2,
104 fua:1,
105 dp0:1,
106 lun:3;
107#else
108 uchar_t lun:3,
109 dp0:1,
110 fua:1,
111 res1:2,
112 reladr:1;
113#endif
114 uchar_t lblk[4];
115 uchar_t res2;
116 uchar_t transfer_length[2];
117 uchar_t control;
118};
119
120typedef struct scsi_command_write_long scsi_command_write_long_t;
121
122struct scsi_command_read {
123 uchar_t opcode;
124#if defined(ARCH_X64)
125 uchar_t lblk_msb:5,
126 lun:3;
127#else
128 uchar_t lun:3,
129 lblk_msb:5;
130#endif
131 ushort_t lblk;
132 uchar_t transfer_length;
133 uchar_t control;
134};
135
136typedef struct scsi_command_read scsi_command_read_t;
137
138
139struct scsi_command_read_long {
140 uchar_t opcode;
141#if defined(ARCH_X64)
142 uchar_t reladr:1,
143 res1:2,
144 fua:1,
145 dp0:1,
146 lun:3;
147#else
148 uchar_t lun:3,
149 dp0:1,
150 fua:1,
151 res1:2,
152 reladr:1;
153#endif
154 uchar_t lblk[4];
155 uchar_t res2;
156 uchar_t transfer_length[2];
157 uchar_t control;
158};
159
160typedef struct scsi_command_read_long scsi_command_read_long_t;
161
162struct scsi_command_request_sense {
163 uchar_t opcode;
164#if defined(ARCH_X64)
165 uchar_t res1:5,
166 lun:3;
167#else
168 uchar_t lun:3,
169 res1:5;
170#endif
171 uchar_t res2;
172 uchar_t res3;
173 uchar_t allocation_length;
174 uchar_t control;
175};
176
177typedef struct scsi_command_request_sense scsi_command_request_sense_t;
178
179struct scsi_command_inquiry {
180 uchar_t opcode;
181#if defined(ARCH_X64)
182 uchar_t evpd:1,
183 res1:4,
184 lun:3;
185#else
186 uchar_t lun:3,
187 res1:4,
188 evpd:1;
189#endif
190 uchar_t pagecode;
191 uchar_t res2;
192 uchar_t allocation_length;
193 uchar_t control;
194};
195
196typedef struct scsi_command_inquiry scsi_command_inquiry_t;
197
198
199
200struct scsi_command_test_unit_ready {
201 uchar_t opcode;
202#if defined(ARCH_X64)
203 uchar_t res1:5,
204 lun:3;
205#else
206 uchar_t lun:3,
207 res1:5;
208#endif
209 uchar_t res2;
210 uchar_t res3;
211 uchar_t res4;
212 uchar_t control;
213};
214
215typedef struct scsi_command_test_unit_ready scsi_command_test_unit_ready_t;
216
217
218struct scsi_command_mode_sense {
219 uchar_t opcode;
220#if defined(ARCH_X64)
221 uchar_t res2:3,
222 dbd:1,
223 res1:1,
224 lun:3;
225 uchar_t pagecode:6,
226 pc:2;
227#else
228 uchar_t lun:3,
229 res1:1,
230 dbd:1,
231 res2:3;
232 uchar_t pc:2,
233 pagecode:6;
234#endif
235 uchar_t res3;
236 uchar_t allocation_length;
237 uchar_t control;
238};
239
240typedef struct scsi_command_mode_sense scsi_command_mode_sense_t;
241
242
243struct scsi_command_log_sense {
244 uchar_t opcode;
245#if defined(ARCH_X64)
246 uchar_t sp:1,
247 ppc:1,
248 res1:3,
249 lun:3;
250 uchar_t pagecode:6,
251 pc:2;
252#else
253 uchar_t lun:3,
254 res1:3,
255 ppc:1,
256 sp:1;
257 uchar_t pc:2,
258 pagecode:6;
259#endif
260 uchar_t res2;
261 uchar_t res3;
262 uchar_t parameter_pointer[2];
263 uchar_t allocation_length[2];
264 uchar_t control;
265};
266
267typedef struct scsi_command_log_sense scsi_command_log_sense_t;
268
269
270struct scsi_command_read_capacity {
271 uchar_t opcode;
272#if defined(ARCH_X64)
273 uchar_t reladr:1,
274 res1:4,
275 lun:3;
276#else
277 uchar_t lun:3,
278 res1:4,
279 reladr:1;
280#endif
281 uchar_t lblk[4];
282 uchar_t res2;
283 uchar_t res3;
284#if defined(ARCH_X64)
285 uchar_t pmi:1,
286 res4:7;
287#else
288 uchar_t res4:7,
289 pmi:1;
290#endif
291 uchar_t control;
292};
293
294typedef struct scsi_command_read_capacity scsi_command_read_capacity_t;
295
296struct scsi_command_read_capacity_data {
297 uint32_t lblk;
298 uint32_t lblk_size;
299};
300
301typedef scsi_command_read_capacity_data scsi_command_read_capacity_data_t;
302
303struct scsi_command_start_stop_unit {
304 uchar_t opcode;
305#if defined(ARCH_X64)
306 uchar_t immed:1,
307 res1:4,
308 lun:3;
309#else
310 uchar_t lun:3,
311 res1:4,
312 immed:1;
313#endif
314 uchar_t res2;
315 uchar_t res3;
316#if defined(ARCH_X64)
317 uchar_t start:1,
318 loej:1,
319 res4:6;
320#else
321 uchar_t res4:6,
322 loej:1,
323 start:1;
324#endif
325 uchar_t control;
326};
327
328typedef struct scsi_command_start_stop_unit scsi_command_start_stop_unit_t;
329
330
331struct scsi_disk_request_sense_data {
332#if defined(ARCH_X64)
333 uchar_t error_code:7,
334 valid:1;
335#else
336 uchar_t valid:1,
337 error_code:7;
338#endif
339 uchar_t segment_number;
340#if defined(ARCH_X64)
341 uchar_t sense_key:4,
342 res1:1,
343 ILI:1,
344 EOM:1,
345 Filemark:1;
346#else
347 uchar_t Filemark:1,
348 EOM:1,
349 ILI:1,
350 res1:1,
351 sense_key:4;
352#endif
353 uchar_t information[4];
354 uchar_t additional_sense_length;
355 uchar_t command_specific_info[4];
356 uchar_t additional_sense_code;
357 uchar_t additional_sense_code_qualifier;
358 uchar_t field_replaceable_unit_code;
359#if defined(ARCH_X64)
360 uchar_t sense_key_specific1:7,
361 SKSV:1;
362#else
363 uchar_t SKSV:1,
364 sense_key_specific1:7;
365#endif
366 uchar_t sense_key_specific2[2];
367 uchar_t additional_sense_bytes[2];
368};
369
370typedef struct scsi_disk_request_sense_data scsi_disk_request_sense_data_t;
371
372
373
374#endif /* SAS_DISK_H_ */
375