VirtualBox

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

Last change on this file since 450 was 1, checked in by vboxsync, 55 years ago

import

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