blob: 3fcc287a5a166fce9f28508d60d09d563cddf491 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
/*++
Copyright (c) 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Atapi.h
Abstract:
Revision History
--*/
#ifndef _ATAPI_H
#define _ATAPI_H
#include "Tiano.h"
#pragma pack(1)
typedef struct {
UINT16 config; /* General Configuration */
UINT16 cylinders; /* Number of Cylinders */
UINT16 reserved_2;
UINT16 heads; /* Number of logical heads */
UINT16 vendor_data1;
UINT16 vendoe_data2;
UINT16 sectors_per_track;
UINT16 vendor_specific_7_9[3];
CHAR8 SerialNo[20]; /* ASCII */
UINT16 vendor_specific_20_21[2];
UINT16 ecc_bytes_available;
CHAR8 FirmwareVer[8]; /* ASCII */
CHAR8 ModelName[40]; /* ASCII */
UINT16 multi_sector_cmd_max_sct_cnt;
UINT16 reserved_48;
UINT16 capabilities;
UINT16 reserved_50;
UINT16 pio_cycle_timing;
UINT16 reserved_52;
UINT16 field_validity;
UINT16 current_cylinders;
UINT16 current_heads;
UINT16 current_sectors;
UINT16 CurrentCapacityLsb;
UINT16 CurrentCapacityMsb;
UINT16 reserved_59;
UINT16 user_addressable_sectors_lo;
UINT16 user_addressable_sectors_hi;
UINT16 reserved_62;
UINT16 multi_word_dma_mode;
UINT16 advanced_pio_modes;
UINT16 min_multi_word_dma_cycle_time;
UINT16 rec_multi_word_dma_cycle_time;
UINT16 min_pio_cycle_time_without_flow_control;
UINT16 min_pio_cycle_time_with_flow_control;
UINT16 reserved_69_79[11];
UINT16 major_version_no;
UINT16 minor_version_no;
UINT16 reserved_82_127[46];
UINT16 security_status;
UINT16 vendor_data_129_159[31];
UINT16 reserved_160_255[96];
} IDENTIFY;
typedef struct {
UINT8 peripheral_type;
UINT8 RMB;
UINT8 version;
UINT8 response_data_format;
UINT8 addnl_length;
UINT8 reserved_5;
UINT8 reserved_6;
UINT8 reserved_7;
UINT8 vendor_info[8];
UINT8 product_id[12];
UINT8 eeprom_product_code[4];
UINT8 firmware_rev_level[4];
UINT8 firmware_sub_rev_level[1];
UINT8 reserved_37;
UINT8 reserved_38;
UINT8 reserved_39;
UINT8 max_capacity_hi;
UINT8 max_capacity_mid;
UINT8 max_capacity_lo;
UINT8 reserved_43_95[95 - 43 + 1];
UINT8 vendor_id[20];
UINT8 eeprom_drive_sno[12];
} INQUIRY_DATA;
typedef struct {
UINT8 error_code : 7;
UINT8 valid : 1;
UINT8 reserved_1;
UINT8 sense_key : 4;
UINT8 reserved_21 : 1;
UINT8 ILI : 1;
UINT8 reserved_22 : 2;
UINT8 vendor_specific_3;
UINT8 vendor_specific_4;
UINT8 vendor_specific_5;
UINT8 vendor_specific_6;
UINT8 addnl_sense_length; // n - 7
UINT8 vendor_specific_8;
UINT8 vendor_specific_9;
UINT8 vendor_specific_10;
UINT8 vendor_specific_11;
UINT8 addnl_sense_code; // mandatory
UINT8 addnl_sense_code_qualifier; // mandatory
UINT8 field_replaceable_unit_code; // optional
UINT8 reserved_15;
UINT8 reserved_16;
UINT8 reserved_17;
//
// Followed by additional sense bytes : FIXME
//
} REQUEST_SENSE_DATA;
typedef struct {
UINT8 LastLba3;
UINT8 LastLba2;
UINT8 LastLba1;
UINT8 LastLba0;
UINT8 BlockSize3;
UINT8 BlockSize2;
UINT8 BlockSize1;
UINT8 BlockSize0;
} READ_CAPACITY_DATA;
typedef struct {
UINT8 reserved_0;
UINT8 reserved_1;
UINT8 reserved_2;
UINT8 Capacity_Length;
UINT8 LastLba3;
UINT8 LastLba2;
UINT8 LastLba1;
UINT8 LastLba0;
UINT8 DesCode : 2;
UINT8 reserved_9 : 6;
UINT8 BlockSize2;
UINT8 BlockSize1;
UINT8 BlockSize0;
} READ_FORMAT_CAPACITY_DATA;
#pragma pack()
//
// ATAPI Command
//
#define ATAPI_SOFT_RESET_CMD 0x08
#define PACKET_CMD 0xA0
#define ATAPI_IDENTIFY_DEVICE_CMD 0xA1
#define ATAPI_SERVICE_CMD 0xA2
//
// ATAPI Packet Command
//
#pragma pack(1)
typedef struct {
UINT8 opcode;
UINT8 reserved_1;
UINT8 reserved_2;
UINT8 reserved_3;
UINT8 reserved_4;
UINT8 reserved_5;
UINT8 reserved_6;
UINT8 reserved_7;
UINT8 reserved_8;
UINT8 reserved_9;
UINT8 reserved_10;
UINT8 reserved_11;
} TEST_UNIT_READY_CMD;
typedef struct {
UINT8 opcode;
UINT8 reserved_1 : 4;
UINT8 lun : 4;
UINT8 page_code;
UINT8 reserved_3;
UINT8 allocation_length;
UINT8 reserved_5;
UINT8 reserved_6;
UINT8 reserved_7;
UINT8 reserved_8;
UINT8 reserved_9;
UINT8 reserved_10;
UINT8 reserved_11;
} INQUIRY_CMD;
typedef struct {
UINT8 opcode;
UINT8 reserved_1 : 4;
UINT8 lun : 4;
UINT8 reserved_2;
UINT8 reserved_3;
UINT8 allocation_length;
UINT8 reserved_5;
UINT8 reserved_6;
UINT8 reserved_7;
UINT8 reserved_8;
UINT8 reserved_9;
UINT8 reserved_10;
UINT8 reserved_11;
} REQUEST_SENSE_CMD;
typedef struct {
UINT8 opcode;
UINT8 reserved_1 : 5;
UINT8 lun : 3;
UINT8 Lba0;
UINT8 Lba1;
UINT8 Lba2;
UINT8 Lba3;
UINT8 reserved_6;
UINT8 TranLen0;
UINT8 TranLen1;
UINT8 reserved_9;
UINT8 reserved_10;
UINT8 reserved_11;
} READ10_CMD;
typedef struct {
UINT8 opcode;
UINT8 reserved_1;
UINT8 reserved_2;
UINT8 reserved_3;
UINT8 reserved_4;
UINT8 reserved_5;
UINT8 reserved_6;
UINT8 allocation_length_hi;
UINT8 allocation_length_lo;
UINT8 reserved_9;
UINT8 reserved_10;
UINT8 reserved_11;
} READ_FORMAT_CAP_CMD;
typedef struct {
UINT8 peripheral_type;
UINT8 RMB;
UINT8 version;
UINT8 response_data_format;
UINT8 addnl_length;
UINT8 reserved_5;
UINT8 reserved_6;
UINT8 reserved_7;
UINT8 vendor_info[8];
UINT8 product_id[12];
UINT8 eeprom_product_code[4];
UINT8 firmware_rev_level[4];
} USB_INQUIRY_DATA;
typedef union {
UINT16 Data16[6];
TEST_UNIT_READY_CMD TestUnitReady;
READ10_CMD Read10;
REQUEST_SENSE_CMD RequestSence;
INQUIRY_CMD Inquiry;
READ_FORMAT_CAP_CMD ReadFormatCapacity;
} ATAPI_PACKET_COMMAND;
#pragma pack()
//
// Packet Command Code
//
#define TEST_UNIT_READY 0x00
#define REQUEST_SENSE 0x03
#define INQUIRY 0x12
#define READ_FORMAT_CAPACITY 0x23
#define READ_CAPACITY 0x25
#define READ_10 0x28
#define DEFAULT_CTL (0x0a) // default content of device control register, disable INT
#define DEFAULT_CMD (0xa0)
#define MAX_ATAPI_BYTE_COUNT (0xfffe)
//
// Sense Key
//
#define REQUEST_SENSE_ERROR (0x70)
#define SK_NO_SENSE (0x0)
#define SK_RECOVERY_ERROR (0x1)
#define SK_NOT_READY (0x2)
#define SK_MEDIUM_ERROR (0x3)
#define SK_HARDWARE_ERROR (0x4)
#define SK_ILLEGAL_REQUEST (0x5)
#define SK_UNIT_ATTENTION (0x6)
#define SK_DATA_PROTECT (0x7)
#define SK_BLANK_CHECK (0x8)
#define SK_VENDOR_SPECIFIC (0x9)
#define SK_RESERVED_A (0xA)
#define SK_ABORT (0xB)
#define SK_RESERVED_C (0xC)
#define SK_OVERFLOW (0xD)
#define SK_MISCOMPARE (0xE)
#define SK_RESERVED_F (0xF)
//
// Additional Sense Codes
//
#define ASC_NOT_READY (0x04)
#define ASC_MEDIA_ERR1 (0x10)
#define ASC_MEDIA_ERR2 (0x11)
#define ASC_MEDIA_ERR3 (0x14)
#define ASC_MEDIA_ERR4 (0x30)
#define ASC_MEDIA_UPSIDE_DOWN (0x06)
#define ASC_INVALID_CMD (0x20)
#define ASC_LBA_OUT_OF_RANGE (0x21)
#define ASC_INVALID_FIELD (0x24)
#define ASC_WRITE_PROTECTED (0x27)
#define ASC_MEDIA_CHANGE (0x28)
#define ASC_RESET (0x29) /* Power On Reset or Bus Reset occurred */
#define ASC_ILLEGAL_FIELD (0x26)
#define ASC_NO_MEDIA (0x3A)
#define ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64)
//
// Additional Sense Code Qualifier
//
#define ASCQ_IN_PROGRESS (0x01)
#endif
|