VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/ide.h@ 6239

Last change on this file since 6239 was 6239, checked in by vboxsync, 17 years ago

AHCI: Implement NCQ

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.4 KB
Line 
1/** @file
2 *
3 * VBox storage devices:
4 * ATA/ATAPI declarations
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef __IDE_h__
20#define __IDE_h__
21
22
23/* Bits of HD_STATUS */
24#define ATA_STAT_ERR 0x01
25#define ATA_STAT_INDEX 0x02
26#define ATA_STAT_ECC 0x04 /* Corrected error */
27#define ATA_STAT_DRQ 0x08
28#define ATA_STAT_SEEK 0x10
29#define ATA_STAT_SRV 0x10
30#define ATA_STAT_WRERR 0x20
31#define ATA_STAT_READY 0x40
32#define ATA_STAT_BUSY 0x80
33
34/* Bits for HD_ERROR */
35#define MARK_ERR 0x01 /* Bad address mark */
36#define TRK0_ERR 0x02 /* couldn't find track 0 */
37#define ABRT_ERR 0x04 /* Command aborted */
38#define MCR_ERR 0x08 /* media change request */
39#define ID_ERR 0x10 /* ID field not found */
40#define MC_ERR 0x20 /* media changed */
41#define ECC_ERR 0x40 /* Uncorrectable ECC error */
42#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */
43#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */
44
45/* Bits for uATARegDevCtl. */
46#define ATA_DEVCTL_DISABLE_IRQ 0x02
47#define ATA_DEVCTL_RESET 0x04
48#define ATA_DEVCTL_HOB 0x80
49
50
51/* ATA/ATAPI Commands (as of ATA/ATAPI-8 draft T13/1699D Revision 3a).
52 * Please keep this in sync with g_apszATACmdNames. */
53typedef enum ATACMD
54{
55 ATA_NOP = 0x00,
56 ATA_CFA_REQUEST_EXTENDED_ERROR_CODE = 0x03,
57 ATA_DEVICE_RESET = 0x08,
58 ATA_RECALIBRATE = 0x10,
59 ATA_READ_SECTORS = 0x20,
60 ATA_READ_SECTORS_WITHOUT_RETRIES = 0x21,
61 ATA_READ_LONG = 0x22,
62 ATA_READ_LONG_WITHOUT_RETRIES = 0x23,
63 ATA_READ_SECTORS_EXT = 0x24,
64 ATA_READ_DMA_EXT = 0x25,
65 ATA_READ_DMA_QUEUED_EXT = 0x26,
66 ATA_READ_NATIVE_MAX_ADDRESS_EXT = 0x27,
67 ATA_READ_MULTIPLE_EXT = 0x29,
68 ATA_READ_STREAM_DMA_EXT = 0x2a,
69 ATA_READ_STREAM_EXT = 0x2b,
70 ATA_READ_LOG_EXT = 0x2f,
71 ATA_WRITE_SECTORS = 0x30,
72 ATA_WRITE_SECTORS_WITHOUT_RETRIES = 0x31,
73 ATA_WRITE_LONG = 0x32,
74 ATA_WRITE_LONG_WITHOUT_RETRIES = 0x33,
75 ATA_WRITE_SECTORS_EXT = 0x34,
76 ATA_WRITE_DMA_EXT = 0x35,
77 ATA_WRITE_DMA_QUEUED_EXT = 0x36,
78 ATA_SET_MAX_ADDRESS_EXT = 0x37,
79 ATA_CFA_WRITE_SECTORS_WITHOUT_ERASE = 0x38,
80 ATA_WRITE_MULTIPLE_EXT = 0x39,
81 ATA_WRITE_STREAM_DMA_EXT = 0x3a,
82 ATA_WRITE_STREAM_EXT = 0x3b,
83 ATA_WRITE_VERIFY = 0x3c,
84 ATA_WRITE_DMA_FUA_EXT = 0x3d,
85 ATA_WRITE_DMA_QUEUED_FUA_EXT = 0x3e,
86 ATA_WRITE_LOG_EXT = 0x3f,
87 ATA_READ_VERIFY_SECTORS = 0x40,
88 ATA_READ_VERIFY_SECTORS_WITHOUT_RETRIES = 0x41,
89 ATA_READ_VERIFY_SECTORS_EXT = 0x42,
90 ATA_WRITE_UNCORRECTABLE_EXT = 0x45,
91 ATA_READ_LOG_DMA_EXT = 0x47,
92 ATA_FORMAT_TRACK = 0x50,
93 ATA_CONFIGURE_STREAM = 0x51,
94 ATA_WRITE_LOG_DMA_EXT = 0x57,
95 ATA_TRUSTED_RECEIVE = 0x5c,
96 ATA_TRUSTED_RECEIVE_DMA = 0x5d,
97 ATA_TRUSTED_SEND = 0x5e,
98 ATA_TRUSTED_SEND_DMA = 0x5f,
99 ATA_READ_FPDMA_QUEUED = 0x60,
100 ATA_WRITE_FPDMA_QUEUED = 0x61,
101 ATA_SEEK = 0x70,
102 ATA_CFA_TRANSLATE_SECTOR = 0x87,
103 ATA_EXECUTE_DEVICE_DIAGNOSTIC = 0x90,
104 ATA_INITIALIZE_DEVICE_PARAMETERS = 0x91,
105 ATA_DOWNLOAD_MICROCODE = 0x92,
106 ATA_STANDBY_IMMEDIATE__ALT = 0x94,
107 ATA_IDLE_IMMEDIATE__ALT = 0x95,
108 ATA_STANDBY__ALT = 0x96,
109 ATA_IDLE__ALT = 0x97,
110 ATA_CHECK_POWER_MODE__ALT = 0x98,
111 ATA_SLEEP__ALT = 0x99,
112 ATA_PACKET = 0xa0,
113 ATA_IDENTIFY_PACKET_DEVICE = 0xa1,
114 ATA_SERVICE = 0xa2,
115 ATA_SMART = 0xb0,
116 ATA_DEVICE_CONFIGURATION_OVERLAY = 0xb1,
117 ATA_NV_CACHE = 0xb6,
118 ATA_CFA_ERASE_SECTORS = 0xc0,
119 ATA_READ_MULTIPLE = 0xc4,
120 ATA_WRITE_MULTIPLE = 0xc5,
121 ATA_SET_MULTIPLE_MODE = 0xc6,
122 ATA_READ_DMA_QUEUED = 0xc7,
123 ATA_READ_DMA = 0xc8,
124 ATA_READ_DMA_WITHOUT_RETRIES = 0xc9,
125 ATA_WRITE_DMA = 0xca,
126 ATA_WRITE_DMA_WITHOUT_RETRIES = 0xcb,
127 ATA_WRITE_DMA_QUEUED = 0xcc,
128 ATA_CFA_WRITE_MULTIPLE_WITHOUT_ERASE = 0xcd,
129 ATA_WRITE_MULTIPLE_FUA_EXT = 0xce,
130 ATA_CHECK_MEDIA_CARD_TYPE = 0xd1,
131 ATA_GET_MEDIA_STATUS = 0xda,
132 ATA_ACKNOWLEDGE_MEDIA_CHANGE = 0xdb,
133 ATA_BOOT_POST_BOOT = 0xdc,
134 ATA_BOOT_PRE_BOOT = 0xdd,
135 ATA_MEDIA_LOCK = 0xde,
136 ATA_MEDIA_UNLOCK = 0xdf,
137 ATA_STANDBY_IMMEDIATE = 0xe0,
138 ATA_IDLE_IMMEDIATE = 0xe1,
139 ATA_STANDBY = 0xe2,
140 ATA_IDLE = 0xe3,
141 ATA_READ_BUFFER = 0xe4,
142 ATA_CHECK_POWER_MODE = 0xe5,
143 ATA_SLEEP = 0xe6,
144 ATA_FLUSH_CACHE = 0xe7,
145 ATA_WRITE_BUFFER = 0xe8,
146 ATA_WRITE_SAME = 0xe9,
147 ATA_FLUSH_CACHE_EXT = 0xea,
148 ATA_IDENTIFY_DEVICE = 0xec,
149 ATA_MEDIA_EJECT = 0xed,
150 ATA_IDENTIFY_DMA = 0xee,
151 ATA_SET_FEATURES = 0xef,
152 ATA_SECURITY_SET_PASSWORD = 0xf1,
153 ATA_SECURITY_UNLOCK = 0xf2,
154 ATA_SECURITY_ERASE_PREPARE = 0xf3,
155 ATA_SECURITY_ERASE_UNIT = 0xf4,
156 ATA_SECURITY_FREEZE_LOCK = 0xf5,
157 ATA_SECURITY_DISABLE_PASSWORD = 0xf6,
158 ATA_READ_NATIVE_MAX_ADDRESS = 0xf8,
159 ATA_SET_MAX = 0xf9
160} ATACMD;
161
162#ifdef DEBUG
163static const char * const g_apszATACmdNames[256] =
164{
165 "NOP", /* 0x00 */
166 "", /* 0x01 */
167 "", /* 0x02 */
168 "CFA REQUEST EXTENDED ERROR CODE", /* 0x03 */
169 "", /* 0x04 */
170 "", /* 0x05 */
171 "", /* 0x06 */
172 "", /* 0x07 */
173 "DEVICE RESET", /* 0x08 */
174 "", /* 0x09 */
175 "", /* 0x0a */
176 "", /* 0x0b */
177 "", /* 0x0c */
178 "", /* 0x0d */
179 "", /* 0x0e */
180 "", /* 0x0f */
181 "RECALIBRATE", /* 0x10 */
182 "", /* 0x11 */
183 "", /* 0x12 */
184 "", /* 0x13 */
185 "", /* 0x14 */
186 "", /* 0x15 */
187 "", /* 0x16 */
188 "", /* 0x17 */
189 "", /* 0x18 */
190 "", /* 0x19 */
191 "", /* 0x1a */
192 "", /* 0x1b */
193 "", /* 0x1c */
194 "", /* 0x1d */
195 "", /* 0x1e */
196 "", /* 0x1f */
197 "READ SECTORS", /* 0x20 */
198 "READ SECTORS WITHOUT RETRIES", /* 0x21 */
199 "READ LONG", /* 0x22 */
200 "READ LONG WITHOUT RETRIES", /* 0x23 */
201 "READ SECTORS EXT", /* 0x24 */
202 "READ DMA EXT", /* 0x25 */
203 "READ DMA QUEUED EXT", /* 0x26 */
204 "READ NATIVE MAX ADDRESS EXT", /* 0x27 */
205 "", /* 0x28 */
206 "READ MULTIPLE EXT", /* 0x29 */
207 "READ STREAM DMA EXT", /* 0x2a */
208 "READ STREAM EXT", /* 0x2b */
209 "", /* 0x2c */
210 "", /* 0x2d */
211 "", /* 0x2e */
212 "READ LOG EXT", /* 0x2f */
213 "WRITE SECTORS", /* 0x30 */
214 "WRITE SECTORS WITHOUT RETRIES", /* 0x31 */
215 "WRITE LONG", /* 0x32 */
216 "WRITE LONG WITHOUT RETRIES", /* 0x33 */
217 "WRITE SECTORS EXT", /* 0x34 */
218 "WRITE DMA EXT", /* 0x35 */
219 "WRITE DMA QUEUED EXT", /* 0x36 */
220 "SET MAX ADDRESS EXT", /* 0x37 */
221 "CFA WRITE SECTORS WITHOUT ERASE", /* 0x38 */
222 "WRITE MULTIPLE EXT", /* 0x39 */
223 "WRITE STREAM DMA EXT", /* 0x3a */
224 "WRITE STREAM EXT", /* 0x3b */
225 "WRITE VERIFY", /* 0x3c */
226 "WRITE DMA FUA EXT", /* 0x3d */
227 "WRITE DMA QUEUED FUA EXT", /* 0x3e */
228 "WRITE LOG EXT", /* 0x3f */
229 "READ VERIFY SECTORS", /* 0x40 */
230 "READ VERIFY SECTORS WITHOUT RETRIES", /* 0x41 */
231 "READ VERIFY SECTORS EXT", /* 0x42 */
232 "", /* 0x43 */
233 "", /* 0x44 */
234 "WRITE UNCORRECTABLE EXT", /* 0x45 */
235 "", /* 0x46 */
236 "READ LOG DMA EXT", /* 0x47 */
237 "", /* 0x48 */
238 "", /* 0x49 */
239 "", /* 0x4a */
240 "", /* 0x4b */
241 "", /* 0x4c */
242 "", /* 0x4d */
243 "", /* 0x4e */
244 "", /* 0x4f */
245 "FORMAT TRACK", /* 0x50 */
246 "CONFIGURE STREAM", /* 0x51 */
247 "", /* 0x52 */
248 "", /* 0x53 */
249 "", /* 0x54 */
250 "", /* 0x55 */
251 "", /* 0x56 */
252 "WRITE LOG DMA EXT", /* 0x57 */
253 "", /* 0x58 */
254 "", /* 0x59 */
255 "", /* 0x5a */
256 "", /* 0x5b */
257 "TRUSTED RECEIVE", /* 0x5c */
258 "TRUSTED RECEIVE DMA", /* 0x5d */
259 "TRUSTED SEND", /* 0x5e */
260 "TRUSTED SEND DMA", /* 0x5f */
261 "READ FPDMA QUEUED", /* 0x60 */
262 "WRITE FPDMA QUEUED", /* 0x61 */
263 "", /* 0x62 */
264 "", /* 0x63 */
265 "", /* 0x64 */
266 "", /* 0x65 */
267 "", /* 0x66 */
268 "", /* 0x67 */
269 "", /* 0x68 */
270 "", /* 0x69 */
271 "", /* 0x6a */
272 "", /* 0x6b */
273 "", /* 0x6c */
274 "", /* 0x6d */
275 "", /* 0x6e */
276 "", /* 0x6f */
277 "SEEK", /* 0x70 */
278 "", /* 0x71 */
279 "", /* 0x72 */
280 "", /* 0x73 */
281 "", /* 0x74 */
282 "", /* 0x75 */
283 "", /* 0x76 */
284 "", /* 0x77 */
285 "", /* 0x78 */
286 "", /* 0x79 */
287 "", /* 0x7a */
288 "", /* 0x7b */
289 "", /* 0x7c */
290 "", /* 0x7d */
291 "", /* 0x7e */
292 "", /* 0x7f */
293 "", /* 0x80 */
294 "", /* 0x81 */
295 "", /* 0x82 */
296 "", /* 0x83 */
297 "", /* 0x84 */
298 "", /* 0x85 */
299 "", /* 0x86 */
300 "CFA TRANSLATE SECTOR", /* 0x87 */
301 "", /* 0x88 */
302 "", /* 0x89 */
303 "", /* 0x8a */
304 "", /* 0x8b */
305 "", /* 0x8c */
306 "", /* 0x8d */
307 "", /* 0x8e */
308 "", /* 0x8f */
309 "EXECUTE DEVICE DIAGNOSTIC", /* 0x90 */
310 "INITIALIZE DEVICE PARAMETERS", /* 0x91 */
311 "DOWNLOAD MICROCODE", /* 0x92 */
312 "", /* 0x93 */
313 "STANDBY IMMEDIATE ALT", /* 0x94 */
314 "IDLE IMMEDIATE ALT", /* 0x95 */
315 "STANDBY ALT", /* 0x96 */
316 "IDLE ALT", /* 0x97 */
317 "CHECK POWER MODE ALT", /* 0x98 */
318 "SLEEP ALT", /* 0x99 */
319 "", /* 0x9a */
320 "", /* 0x9b */
321 "", /* 0x9c */
322 "", /* 0x9d */
323 "", /* 0x9e */
324 "", /* 0x9f */
325 "PACKET", /* 0xa0 */
326 "IDENTIFY PACKET DEVICE", /* 0xa1 */
327 "SERVICE", /* 0xa2 */
328 "", /* 0xa3 */
329 "", /* 0xa4 */
330 "", /* 0xa5 */
331 "", /* 0xa6 */
332 "", /* 0xa7 */
333 "", /* 0xa8 */
334 "", /* 0xa9 */
335 "", /* 0xaa */
336 "", /* 0xab */
337 "", /* 0xac */
338 "", /* 0xad */
339 "", /* 0xae */
340 "", /* 0xaf */
341 "SMART", /* 0xb0 */
342 "DEVICE CONFIGURATION OVERLAY", /* 0xb1 */
343 "", /* 0xb2 */
344 "", /* 0xb3 */
345 "", /* 0xb4 */
346 "", /* 0xb5 */
347 "NV CACHE", /* 0xb6 */
348 "", /* 0xb7 */
349 "", /* 0xb8 */
350 "", /* 0xb9 */
351 "", /* 0xba */
352 "", /* 0xbb */
353 "", /* 0xbc */
354 "", /* 0xbd */
355 "", /* 0xbe */
356 "", /* 0xbf */
357 "CFA ERASE SECTORS", /* 0xc0 */
358 "", /* 0xc1 */
359 "", /* 0xc2 */
360 "", /* 0xc3 */
361 "READ MULTIPLE", /* 0xc4 */
362 "WRITE MULTIPLE", /* 0xc5 */
363 "SET MULTIPLE MODE", /* 0xc6 */
364 "READ DMA QUEUED", /* 0xc7 */
365 "READ DMA", /* 0xc8 */
366 "READ DMA WITHOUT RETRIES", /* 0xc9 */
367 "WRITE DMA", /* 0xca */
368 "WRITE DMA WITHOUT RETRIES", /* 0xcb */
369 "WRITE DMA QUEUED", /* 0xcc */
370 "CFA WRITE MULTIPLE WITHOUT ERASE", /* 0xcd */
371 "WRITE MULTIPLE FUA EXT", /* 0xce */
372 "", /* 0xcf */
373 "", /* 0xd0 */
374 "CHECK MEDIA CARD TYPE", /* 0xd1 */
375 "", /* 0xd2 */
376 "", /* 0xd3 */
377 "", /* 0xd4 */
378 "", /* 0xd5 */
379 "", /* 0xd6 */
380 "", /* 0xd7 */
381 "", /* 0xd8 */
382 "", /* 0xd9 */
383 "GET MEDIA STATUS", /* 0xda */
384 "ACKNOWLEDGE MEDIA CHANGE", /* 0xdb */
385 "BOOT POST BOOT", /* 0xdc */
386 "BOOT PRE BOOT", /* 0xdd */
387 "MEDIA LOCK", /* 0xde */
388 "MEDIA UNLOCK", /* 0xdf */
389 "STANDBY IMMEDIATE", /* 0xe0 */
390 "IDLE IMMEDIATE", /* 0xe1 */
391 "STANDBY", /* 0xe2 */
392 "IDLE", /* 0xe3 */
393 "READ BUFFER", /* 0xe4 */
394 "CHECK POWER MODE", /* 0xe5 */
395 "SLEEP", /* 0xe6 */
396 "FLUSH CACHE", /* 0xe7 */
397 "WRITE BUFFER", /* 0xe8 */
398 "WRITE SAME", /* 0xe9 */
399 "FLUSH CACHE EXT", /* 0xea */
400 "", /* 0xeb */
401 "IDENTIFY DEVICE", /* 0xec */
402 "MEDIA EJECT", /* 0xed */
403 "IDENTIFY DMA", /* 0xee */
404 "SET FEATURES", /* 0xef */
405 "", /* 0xf0 */
406 "SECURITY SET PASSWORD", /* 0xf1 */
407 "SECURITY UNLOCK", /* 0xf2 */
408 "SECURITY ERASE PREPARE", /* 0xf3 */
409 "SECURITY ERASE UNIT", /* 0xf4 */
410 "SECURITY FREEZE LOCK", /* 0xf5 */
411 "SECURITY DISABLE PASSWORD", /* 0xf6 */
412 "", /* 0xf7 */
413 "READ NATIVE MAX ADDRESS", /* 0xf8 */
414 "SET MAX", /* 0xf9 */
415 "", /* 0xfa */
416 "", /* 0xfb */
417 "", /* 0xfc */
418 "", /* 0xfd */
419 "", /* 0xfe */
420 "" /* 0xff */
421};
422#endif /* DEBUG */
423
424
425#define ATA_MODE_MDMA 0x20
426#define ATA_MODE_UDMA 0x40
427
428
429#define ATA_TRANSFER_ID(thismode, maxspeed, currmode) \
430 ( ((1 << (maxspeed + 1)) - 1) \
431 | ((((thismode ^ currmode) & 0xf8) == 0) ? 1 << ((currmode & 0x07) + 8) : 0))
432
433
434/* ATAPI defines */
435
436#define ATAPI_PACKET_SIZE 12
437
438
439#define ATAPI_INT_REASON_CD 0x01 /* 0 = data transfer */
440#define ATAPI_INT_REASON_IO 0x02 /* 1 = transfer to the host */
441#define ATAPI_INT_REASON_REL 0x04
442#define ATAPI_INT_REASON_TAG_MASK 0xf8
443
444
445#endif /* __IDE_h__ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette