VirtualBox

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

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

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.3 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 as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * 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_SEEK = 0x70,
100 ATA_CFA_TRANSLATE_SECTOR = 0x87,
101 ATA_EXECUTE_DEVICE_DIAGNOSTIC = 0x90,
102 ATA_INITIALIZE_DEVICE_PARAMETERS = 0x91,
103 ATA_DOWNLOAD_MICROCODE = 0x92,
104 ATA_STANDBY_IMMEDIATE__ALT = 0x94,
105 ATA_IDLE_IMMEDIATE__ALT = 0x95,
106 ATA_STANDBY__ALT = 0x96,
107 ATA_IDLE__ALT = 0x97,
108 ATA_CHECK_POWER_MODE__ALT = 0x98,
109 ATA_SLEEP__ALT = 0x99,
110 ATA_PACKET = 0xa0,
111 ATA_IDENTIFY_PACKET_DEVICE = 0xa1,
112 ATA_SERVICE = 0xa2,
113 ATA_SMART = 0xb0,
114 ATA_DEVICE_CONFIGURATION_OVERLAY = 0xb1,
115 ATA_NV_CACHE = 0xb6,
116 ATA_CFA_ERASE_SECTORS = 0xc0,
117 ATA_READ_MULTIPLE = 0xc4,
118 ATA_WRITE_MULTIPLE = 0xc5,
119 ATA_SET_MULTIPLE_MODE = 0xc6,
120 ATA_READ_DMA_QUEUED = 0xc7,
121 ATA_READ_DMA = 0xc8,
122 ATA_READ_DMA_WITHOUT_RETRIES = 0xc9,
123 ATA_WRITE_DMA = 0xca,
124 ATA_WRITE_DMA_WITHOUT_RETRIES = 0xcb,
125 ATA_WRITE_DMA_QUEUED = 0xcc,
126 ATA_CFA_WRITE_MULTIPLE_WITHOUT_ERASE = 0xcd,
127 ATA_WRITE_MULTIPLE_FUA_EXT = 0xce,
128 ATA_CHECK_MEDIA_CARD_TYPE = 0xd1,
129 ATA_GET_MEDIA_STATUS = 0xda,
130 ATA_ACKNOWLEDGE_MEDIA_CHANGE = 0xdb,
131 ATA_BOOT_POST_BOOT = 0xdc,
132 ATA_BOOT_PRE_BOOT = 0xdd,
133 ATA_MEDIA_LOCK = 0xde,
134 ATA_MEDIA_UNLOCK = 0xdf,
135 ATA_STANDBY_IMMEDIATE = 0xe0,
136 ATA_IDLE_IMMEDIATE = 0xe1,
137 ATA_STANDBY = 0xe2,
138 ATA_IDLE = 0xe3,
139 ATA_READ_BUFFER = 0xe4,
140 ATA_CHECK_POWER_MODE = 0xe5,
141 ATA_SLEEP = 0xe6,
142 ATA_FLUSH_CACHE = 0xe7,
143 ATA_WRITE_BUFFER = 0xe8,
144 ATA_WRITE_SAME = 0xe9,
145 ATA_FLUSH_CACHE_EXT = 0xea,
146 ATA_IDENTIFY_DEVICE = 0xec,
147 ATA_MEDIA_EJECT = 0xed,
148 ATA_IDENTIFY_DMA = 0xee,
149 ATA_SET_FEATURES = 0xef,
150 ATA_SECURITY_SET_PASSWORD = 0xf1,
151 ATA_SECURITY_UNLOCK = 0xf2,
152 ATA_SECURITY_ERASE_PREPARE = 0xf3,
153 ATA_SECURITY_ERASE_UNIT = 0xf4,
154 ATA_SECURITY_FREEZE_LOCK = 0xf5,
155 ATA_SECURITY_DISABLE_PASSWORD = 0xf6,
156 ATA_READ_NATIVE_MAX_ADDRESS = 0xf8,
157 ATA_SET_MAX = 0xf9
158} ATACMD;
159
160#ifdef DEBUG
161static const char * const g_apszATACmdNames[256] =
162{
163 "NOP", /* 0x00 */
164 "", /* 0x01 */
165 "", /* 0x02 */
166 "CFA REQUEST EXTENDED ERROR CODE", /* 0x03 */
167 "", /* 0x04 */
168 "", /* 0x05 */
169 "", /* 0x06 */
170 "", /* 0x07 */
171 "DEVICE RESET", /* 0x08 */
172 "", /* 0x09 */
173 "", /* 0x0a */
174 "", /* 0x0b */
175 "", /* 0x0c */
176 "", /* 0x0d */
177 "", /* 0x0e */
178 "", /* 0x0f */
179 "RECALIBRATE", /* 0x10 */
180 "", /* 0x11 */
181 "", /* 0x12 */
182 "", /* 0x13 */
183 "", /* 0x14 */
184 "", /* 0x15 */
185 "", /* 0x16 */
186 "", /* 0x17 */
187 "", /* 0x18 */
188 "", /* 0x19 */
189 "", /* 0x1a */
190 "", /* 0x1b */
191 "", /* 0x1c */
192 "", /* 0x1d */
193 "", /* 0x1e */
194 "", /* 0x1f */
195 "READ SECTORS", /* 0x20 */
196 "READ SECTORS WITHOUT RETRIES", /* 0x21 */
197 "READ LONG", /* 0x22 */
198 "READ LONG WITHOUT RETRIES", /* 0x23 */
199 "READ SECTORS EXT", /* 0x24 */
200 "READ DMA EXT", /* 0x25 */
201 "READ DMA QUEUED EXT", /* 0x26 */
202 "READ NATIVE MAX ADDRESS EXT", /* 0x27 */
203 "", /* 0x28 */
204 "READ MULTIPLE EXT", /* 0x29 */
205 "READ STREAM DMA EXT", /* 0x2a */
206 "READ STREAM EXT", /* 0x2b */
207 "", /* 0x2c */
208 "", /* 0x2d */
209 "", /* 0x2e */
210 "READ LOG EXT", /* 0x2f */
211 "WRITE SECTORS", /* 0x30 */
212 "WRITE SECTORS WITHOUT RETRIES", /* 0x31 */
213 "WRITE LONG", /* 0x32 */
214 "WRITE LONG WITHOUT RETRIES", /* 0x33 */
215 "WRITE SECTORS EXT", /* 0x34 */
216 "WRITE DMA EXT", /* 0x35 */
217 "WRITE DMA QUEUED EXT", /* 0x36 */
218 "SET MAX ADDRESS EXT", /* 0x37 */
219 "CFA WRITE SECTORS WITHOUT ERASE", /* 0x38 */
220 "WRITE MULTIPLE EXT", /* 0x39 */
221 "WRITE STREAM DMA EXT", /* 0x3a */
222 "WRITE STREAM EXT", /* 0x3b */
223 "WRITE VERIFY", /* 0x3c */
224 "WRITE DMA FUA EXT", /* 0x3d */
225 "WRITE DMA QUEUED FUA EXT", /* 0x3e */
226 "WRITE LOG EXT", /* 0x3f */
227 "READ VERIFY SECTORS", /* 0x40 */
228 "READ VERIFY SECTORS WITHOUT RETRIES", /* 0x41 */
229 "READ VERIFY SECTORS EXT", /* 0x42 */
230 "", /* 0x43 */
231 "", /* 0x44 */
232 "WRITE UNCORRECTABLE EXT", /* 0x45 */
233 "", /* 0x46 */
234 "READ LOG DMA EXT", /* 0x47 */
235 "", /* 0x48 */
236 "", /* 0x49 */
237 "", /* 0x4a */
238 "", /* 0x4b */
239 "", /* 0x4c */
240 "", /* 0x4d */
241 "", /* 0x4e */
242 "", /* 0x4f */
243 "FORMAT TRACK", /* 0x50 */
244 "CONFIGURE STREAM", /* 0x51 */
245 "", /* 0x52 */
246 "", /* 0x53 */
247 "", /* 0x54 */
248 "", /* 0x55 */
249 "", /* 0x56 */
250 "WRITE LOG DMA EXT", /* 0x57 */
251 "", /* 0x58 */
252 "", /* 0x59 */
253 "", /* 0x5a */
254 "", /* 0x5b */
255 "TRUSTED RECEIVE", /* 0x5c */
256 "TRUSTED RECEIVE DMA", /* 0x5d */
257 "TRUSTED SEND", /* 0x5e */
258 "TRUSTED SEND DMA", /* 0x5f */
259 "", /* 0x60 */
260 "", /* 0x61 */
261 "", /* 0x62 */
262 "", /* 0x63 */
263 "", /* 0x64 */
264 "", /* 0x65 */
265 "", /* 0x66 */
266 "", /* 0x67 */
267 "", /* 0x68 */
268 "", /* 0x69 */
269 "", /* 0x6a */
270 "", /* 0x6b */
271 "", /* 0x6c */
272 "", /* 0x6d */
273 "", /* 0x6e */
274 "", /* 0x6f */
275 "SEEK", /* 0x70 */
276 "", /* 0x71 */
277 "", /* 0x72 */
278 "", /* 0x73 */
279 "", /* 0x74 */
280 "", /* 0x75 */
281 "", /* 0x76 */
282 "", /* 0x77 */
283 "", /* 0x78 */
284 "", /* 0x79 */
285 "", /* 0x7a */
286 "", /* 0x7b */
287 "", /* 0x7c */
288 "", /* 0x7d */
289 "", /* 0x7e */
290 "", /* 0x7f */
291 "", /* 0x80 */
292 "", /* 0x81 */
293 "", /* 0x82 */
294 "", /* 0x83 */
295 "", /* 0x84 */
296 "", /* 0x85 */
297 "", /* 0x86 */
298 "CFA TRANSLATE SECTOR", /* 0x87 */
299 "", /* 0x88 */
300 "", /* 0x89 */
301 "", /* 0x8a */
302 "", /* 0x8b */
303 "", /* 0x8c */
304 "", /* 0x8d */
305 "", /* 0x8e */
306 "", /* 0x8f */
307 "EXECUTE DEVICE DIAGNOSTIC", /* 0x90 */
308 "INITIALIZE DEVICE PARAMETERS", /* 0x91 */
309 "DOWNLOAD MICROCODE", /* 0x92 */
310 "", /* 0x93 */
311 "STANDBY IMMEDIATE ALT", /* 0x94 */
312 "IDLE IMMEDIATE ALT", /* 0x95 */
313 "STANDBY ALT", /* 0x96 */
314 "IDLE ALT", /* 0x97 */
315 "CHECK POWER MODE ALT", /* 0x98 */
316 "SLEEP ALT", /* 0x99 */
317 "", /* 0x9a */
318 "", /* 0x9b */
319 "", /* 0x9c */
320 "", /* 0x9d */
321 "", /* 0x9e */
322 "", /* 0x9f */
323 "PACKET", /* 0xa0 */
324 "IDENTIFY PACKET DEVICE", /* 0xa1 */
325 "SERVICE", /* 0xa2 */
326 "", /* 0xa3 */
327 "", /* 0xa4 */
328 "", /* 0xa5 */
329 "", /* 0xa6 */
330 "", /* 0xa7 */
331 "", /* 0xa8 */
332 "", /* 0xa9 */
333 "", /* 0xaa */
334 "", /* 0xab */
335 "", /* 0xac */
336 "", /* 0xad */
337 "", /* 0xae */
338 "", /* 0xaf */
339 "SMART", /* 0xb0 */
340 "DEVICE CONFIGURATION OVERLAY", /* 0xb1 */
341 "", /* 0xb2 */
342 "", /* 0xb3 */
343 "", /* 0xb4 */
344 "", /* 0xb5 */
345 "NV CACHE", /* 0xb6 */
346 "", /* 0xb7 */
347 "", /* 0xb8 */
348 "", /* 0xb9 */
349 "", /* 0xba */
350 "", /* 0xbb */
351 "", /* 0xbc */
352 "", /* 0xbd */
353 "", /* 0xbe */
354 "", /* 0xbf */
355 "CFA ERASE SECTORS", /* 0xc0 */
356 "", /* 0xc1 */
357 "", /* 0xc2 */
358 "", /* 0xc3 */
359 "READ MULTIPLE", /* 0xc4 */
360 "WRITE MULTIPLE", /* 0xc5 */
361 "SET MULTIPLE MODE", /* 0xc6 */
362 "READ DMA QUEUED", /* 0xc7 */
363 "READ DMA", /* 0xc8 */
364 "READ DMA WITHOUT RETRIES", /* 0xc9 */
365 "WRITE DMA", /* 0xca */
366 "WRITE DMA WITHOUT RETRIES", /* 0xcb */
367 "WRITE DMA QUEUED", /* 0xcc */
368 "CFA WRITE MULTIPLE WITHOUT ERASE", /* 0xcd */
369 "WRITE MULTIPLE FUA EXT", /* 0xce */
370 "", /* 0xcf */
371 "", /* 0xd0 */
372 "CHECK MEDIA CARD TYPE", /* 0xd1 */
373 "", /* 0xd2 */
374 "", /* 0xd3 */
375 "", /* 0xd4 */
376 "", /* 0xd5 */
377 "", /* 0xd6 */
378 "", /* 0xd7 */
379 "", /* 0xd8 */
380 "", /* 0xd9 */
381 "GET MEDIA STATUS", /* 0xda */
382 "ACKNOWLEDGE MEDIA CHANGE", /* 0xdb */
383 "BOOT POST BOOT", /* 0xdc */
384 "BOOT PRE BOOT", /* 0xdd */
385 "MEDIA LOCK", /* 0xde */
386 "MEDIA UNLOCK", /* 0xdf */
387 "STANDBY IMMEDIATE", /* 0xe0 */
388 "IDLE IMMEDIATE", /* 0xe1 */
389 "STANDBY", /* 0xe2 */
390 "IDLE", /* 0xe3 */
391 "READ BUFFER", /* 0xe4 */
392 "CHECK POWER MODE", /* 0xe5 */
393 "SLEEP", /* 0xe6 */
394 "FLUSH CACHE", /* 0xe7 */
395 "WRITE BUFFER", /* 0xe8 */
396 "WRITE SAME", /* 0xe9 */
397 "FLUSH CACHE EXT", /* 0xea */
398 "", /* 0xeb */
399 "IDENTIFY DEVICE", /* 0xec */
400 "MEDIA EJECT", /* 0xed */
401 "IDENTIFY DMA", /* 0xee */
402 "SET FEATURES", /* 0xef */
403 "", /* 0xf0 */
404 "SECURITY SET PASSWORD", /* 0xf1 */
405 "SECURITY UNLOCK", /* 0xf2 */
406 "SECURITY ERASE PREPARE", /* 0xf3 */
407 "SECURITY ERASE UNIT", /* 0xf4 */
408 "SECURITY FREEZE LOCK", /* 0xf5 */
409 "SECURITY DISABLE PASSWORD", /* 0xf6 */
410 "", /* 0xf7 */
411 "READ NATIVE MAX ADDRESS", /* 0xf8 */
412 "SET MAX", /* 0xf9 */
413 "", /* 0xfa */
414 "", /* 0xfb */
415 "", /* 0xfc */
416 "", /* 0xfd */
417 "", /* 0xfe */
418 "" /* 0xff */
419};
420#endif /* DEBUG */
421
422
423#define ATA_MODE_MDMA 0x20
424#define ATA_MODE_UDMA 0x40
425
426
427#define ATA_TRANSFER_ID(thismode, maxspeed, currmode) \
428 ( ((1 << (maxspeed + 1)) - 1) \
429 | ((((thismode ^ currmode) & 0xf8) == 0) ? 1 << ((currmode & 0x07) + 8) : 0))
430
431
432/* ATAPI defines */
433
434#define ATAPI_PACKET_SIZE 12
435
436
437#define ATAPI_INT_REASON_CD 0x01 /* 0 = data transfer */
438#define ATAPI_INT_REASON_IO 0x02 /* 1 = transfer to the host */
439#define ATAPI_INT_REASON_REL 0x04
440#define ATAPI_INT_REASON_TAG_MASK 0xf8
441
442
443#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