Defined more SCSI sense data keys
[AROS.git] / rom / devs / ahci / ahci_scsi.h
blob9b2eb2e4dc76494693ecf4ef7b9148fe38cb394e
1 /*
2 * Copyright (C) 2012, The AROS Development Team. All rights reserved.
3 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
5 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
6 */
8 #ifndef AHCI_SCSI_H
9 #define AHCI_SCSI_H
11 #include <exec/io.h>
13 #include <scsi/commands.h>
15 struct scsi_vpd_supported_page_list {
16 UBYTE device;
17 UBYTE page_code;
18 #define SVPD_SUPPORTED_PAGE_LIST 0
19 #define SVPD_SUPPORTED_PAGES_HDR_LEN 4
20 UBYTE resv;
21 UBYTE length;
22 #define SVPD_SUPPORTED_PAGES_SIZE 251
23 UBYTE list[SVPD_SUPPORTED_PAGES_SIZE];
26 struct scsi_vpd_unit_serial_number {
27 UBYTE device;
28 UBYTE page_code;
29 #define SVPD_UNIT_SERIAL_NUMBER 0x80
30 UBYTE resv;
31 UBYTE length;
32 #define SVPD_SERIAL_NUM_SIZE 251
33 UBYTE serial_num[SVPD_SERIAL_NUM_SIZE];
36 struct scsi_vpd_unit_devid {
37 UBYTE device;
38 UBYTE page_code;
39 #define SVPD_UNIT_DEVID 0x83
40 #define SVPD_UNIT_DEVID_MAX_SIZE 252
41 UBYTE length[2];
42 UBYTE desc_list[];
45 #define SHORT_INQUIRY_LENGTH 36
47 struct scsi_generic {
48 UBYTE opcode;
49 UBYTE resv[5];
51 struct scsi_inquiry {
52 UBYTE opcode;
53 UBYTE byte2;
54 #define SI_EVPD (1 << 0)
55 UBYTE page_code;
56 UBYTE length;
57 UBYTE control;
60 struct scsi_inquiry_data {
61 #define T_DIRECT 0x00
62 UBYTE device;
63 UBYTE dev_qual2;
64 UBYTE version;
65 #define SCSI_REV_SPC2 4
66 UBYTE response_format;
67 UBYTE additional_length;
68 UBYTE spc3_flags;
69 UBYTE spc2_flags;
70 UBYTE flags;
71 #define SID_VENDOR_SIZE 8
72 UBYTE vendor[SID_VENDOR_SIZE];
73 #define SID_PRODUCT_SIZE 16
74 UBYTE product[SID_PRODUCT_SIZE];
75 #define SID_REVISION_SIZE 4
76 UBYTE revision[SID_REVISION_SIZE];
77 UBYTE spi3data;
78 UBYTE reserved2;
79 UBYTE version1[2];
80 UBYTE version2[2];
81 UBYTE version3[2];
82 UBYTE version4[2];
83 UBYTE version5[2];
84 UBYTE version6[2];
85 UBYTE version7[2];
86 UBYTE version8[2];
87 UBYTE reserved3[22];
88 #define SID_VENDOR_SPECIFIC_1_SIZE 160
89 UBYTE vendor_specific[SID_VENDOR_SPECIFIC_1_SIZE];
92 struct scsi_sense_data {
93 UBYTE error_code;
94 #define SSD_ERRCODE 0x7f
95 #define SSD_CURRENT_ERROR 0x70
96 #define SSD_DEFERRED_ERROR 0x71
97 #define SSD_ERRCODE_VALID 0x80
98 #define SSD_FULL_SIZE 252
99 UBYTE segment;
100 UBYTE flags;
101 #define SSD_KEY 0x0f
102 #define SSD_KEY_NO_SENSE 0x00
103 #define SSD_KEY_RECOVERED_ERROR 0x01
104 #define SSD_KEY_NOT_READY 0x02
105 #define SSD_KEY_MEDIUM_ERROR 0x03
106 #define SSD_KEY_HARDWARE_ERROR 0x04
107 #define SSD_KEY_ILLEGAL_REQUEST 0x05
108 #define SSD_KEY_UNIT_ATTENTION 0x06
109 #define SSD_KEY_DATA_PROTECT 0x07
110 #define SSD_KEY_BLANK_CHECK 0x08
111 #define SSD_KEY_VENDOR_SPECIFIC 0x09
112 #define SSD_KEY_COPY_ABORTED 0x0a
113 #define SSD_KEY_ABORTED_COMMAND 0x0b
114 #define SSD_KEY_EQUAL 0x0c
115 #define SSD_KEY_VOLUME_OVERFLOW 0x0d
116 #define SSD_KEY_MISCOMPARE 0x0e
117 #define SSD_ILI 0x20
118 #define SSD_EOM 0x40
119 #define SSD_FILEMARK 0x80
120 UBYTE info[4];
121 UBYTE extra_len;
122 UBYTE cmd_spec_info[4];
123 UBYTE add_sense_code;
124 UBYTE add_sense_qual;
125 UBYTE fru;
126 UBYTE sense_key_spec[3];
127 UBYTE extra_bytes[14];
130 /* Commands */
131 struct scsi_sense {
132 UBYTE opcode;
133 UBYTE byte2;
134 UBYTE unused[2];
135 UBYTE length;
136 UBYTE control;
139 struct scsi_rw_6 {
140 UBYTE opcode;
141 UBYTE addr[3];
142 #define SRW_TOPADDR 0x1f
143 UBYTE length;
144 UBYTE control;
147 struct scsi_rw_10 {
148 UBYTE opcode;
149 UBYTE byte2;
150 UBYTE addr[4];
151 UBYTE reserved;
152 UBYTE length[2];
153 UBYTE control;
156 struct scsi_rw_12 {
157 UBYTE opcode;
158 UBYTE byte2;
159 UBYTE addr[4];
160 UBYTE length[4];
161 UBYTE resv;
162 UBYTE control;
165 struct scsi_rw_16 {
166 UBYTE opcode;
167 UBYTE byte2;
168 UBYTE addr[8];
169 UBYTE length[4];
170 UBYTE resv;
171 UBYTE control;
174 struct scsi_read_capacity_data {
175 UBYTE addr[4];
176 UBYTE length[4];
179 struct scsi_read_capacity {
180 UBYTE opcode;
181 UBYTE byte2;
182 #define SRC_RELADR 0x01
183 UBYTE addr[4];
184 UBYTE unused[2];
185 UBYTE pmi;
186 #define SRC_PMI 0x01
187 UBYTE control;
190 struct scsi_read_capacity_16 {
191 UBYTE opcode;
192 #define SRC16_SERVICE_ACTION 0x10
193 UBYTE service_action;
194 UBYTE addr[8];
195 UBYTE alloc_len[4];
196 #define SRC16_PMI 0x01
197 #define SRC16_RELADR 0x02
198 UBYTE reladr;
199 UBYTE control;
202 typedef union scsi_cdb {
203 struct scsi_generic generic;
204 struct scsi_inquiry inquiry;
205 struct scsi_read_capacity read_capacity;
206 struct scsi_rw_6 rw_6;
207 struct scsi_rw_10 rw_10;
208 struct scsi_rw_12 rw_12;
209 struct scsi_rw_16 rw_16;
210 struct scsi_sense sense;
211 } *scsi_cdb_t;
214 BOOL ahci_scsi_disk_io(struct IORequest *io, struct SCSICmd *scsi);
215 BOOL ahci_scsi_atapi_io(struct IORequest *io, struct SCSICmd *scsi);
217 #endif /* AHCI_SCSI_H */