ReactOS  0.4.14-dev-49-gfb4591c
atapi.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 2002-2016 Alexandr A. Telyatnikov (Alter)
4 
5 Module Name:
6  atapi.h
7 
8 Abstract:
9  This file contains IDE, ATA, ATAPI and SCSI Miniport definitions
10  and function prototypes.
11 
12 Author:
13  Alexander A. Telyatnikov (Alter)
14 
15 Environment:
16  kernel mode only
17 
18 Notes:
19 
20  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 Revision History:
32 
33  Some definitions were taken from standard ATAPI.SYS sources from NT4 DDK by
34  Mike Glass (MGlass)
35 
36  Some definitions were taken from FreeBSD 4.3-4.6 ATA driver by
37  Søren Schmidt, Copyright (c) 1998,1999,2000,2001
38 
39  Code was changed/updated by
40  Alter, Copyright (c) 2002-20016
41 
42 Licence:
43  GPLv2
44 
45 
46 --*/
47 #ifndef __GLOBAL_H__
48 #define __GLOBAL_H__
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif //__cplusplus
53 
54 #ifndef USER_MODE
55 #include "config.h"
56 #endif //USER_MODE
57 
58 #include "scsi.h"
59 #include "stdio.h"
60 #include "string.h"
61 
62 #ifdef _DEBUG
63 
64 
65 #ifndef _DBGNT_
66 
67 #ifdef KdPrint
68 #undef KdPrint
69 #endif
70 
71 #ifdef USE_DBGPRINT_LOGGER
72 #include "inc/PostDbgMesg.h"
73 #define DbgPrint DbgDump_Printf
74 #define Connect_DbgPrint() {DbgDump_SetAutoReconnect(TRUE); DbgDump_Reconnect();}
75 #else // USE_DBGPRINT_LOGGER
76 #define Connect_DbgPrint() {;}
77 #endif // USE_DBGPRINT_LOGGER
78 
79 #ifdef SCSI_PORT_DBG_PRINT
80 
82 VOID
83 __cdecl
85  ULONG DebugPrintLevel,
86  PCCHAR DebugMessage,
87  ...
88  );
89 
90 #define PRINT_PREFIX 0,
91 
92 #define KdPrint3(_x_) ScsiDebugPrint _x_ {;}
93 #define KdPrint2(_x_) {ScsiDebugPrint("%x: ", PsGetCurrentThread()) ; ScsiDebugPrint _x_ ; }
94 #define KdPrint(_x_) ScsiDebugPrint _x_ {;}
95 
96 #else // SCSI_PORT_DBG_PRINT
97 
98 #ifndef USE_DBGPRINT_LOGGER
99 /*
100 ULONG
101 _cdecl
102 DbgPrint(
103  PCH Format,
104  ...
105  );
106 */
107 #endif // USE_DBGPRINT_LOGGER
108 
109 #define PRINT_PREFIX
110 
111 // Note, that using DbgPrint on raised IRQL will crash w2k
112 // ttis will not happen immediately, so we shall see some logs
113 //#define LOG_ON_RAISED_IRQL_W2K TRUE
114 //#define LOG_ON_RAISED_IRQL_W2K FALSE
115 
116 #define KdPrint3(_x_) {if(LOG_ON_RAISED_IRQL_W2K || MajorVersion < 0x05 || KeGetCurrentIrql() <= 2){/*DbgPrint("%x: ", PsGetCurrentThread()) ;*/ DbgPrint _x_ ; if(g_LogToDisplay){ PrintNtConsole _x_ ;} }}
117 #define KdPrint2(_x_) {if(LOG_ON_RAISED_IRQL_W2K || MajorVersion < 0x05 || KeGetCurrentIrql() <= 2){/*DbgPrint("%x: ", PsGetCurrentThread()) ;*/ DbgPrint _x_ ; if(g_LogToDisplay){ PrintNtConsole _x_ ;} }}
118 #define KdPrint(_x_) {if(LOG_ON_RAISED_IRQL_W2K || MajorVersion < 0x05 || KeGetCurrentIrql() <= 2){/*DbgPrint("%x: ", PsGetCurrentThread()) ;*/ DbgPrint _x_ ; if(g_LogToDisplay){ PrintNtConsole _x_ ;} }}
119 /*
120 #define PRINT_PREFIX_PTR ((PCHAR)&__tmp__kdprint__buff__)
121 #define PRINT_UPREFIX_PTR ((PWCHAR)&__tmp__kdprint__ubuff__)
122 #define PRINT_PREFIX PRINT_PREFIX_PTR,
123 #define KdPrint2(_x_) \
124 { \
125  WCHAR __tmp__kdprint__ubuff__[256]; \
126  CHAR __tmp__kdprint__buff__[256]; \
127  UNICODE_STRING __tmp__usrt__buff__; \
128  sprintf _x_; \
129  swprintf (PRINT_UPREFIX_PTR, L"%hs", PRINT_PREFIX_PTR); \
130  __tmp__usrt__buff__.Buffer = PRINT_UPREFIX_PTR; \
131  __tmp__usrt__buff__.Length = \
132  __tmp__usrt__buff__.MaximumLength = strlen(PRINT_PREFIX_PTR); \
133  NtDisplayString(&__tmp__usrt__buff__); \
134 };
135 #define KdPrint(_x_) DbgPrint _x_
136 */
137 #endif // SCSI_PORT_DBG_PRINT
138 
139 //#define AtapiStallExecution(dt) { KdPrint2((" AtapiStallExecution(%d)\n", dt)); ScsiPortStallExecution(dt); }
140 #define AtapiStallExecution(dt) { ScsiPortStallExecution(dt); }
141 
142 #endif // _DBGNT_
143 
144 #else // _DEBUG
145 
146 #ifdef KdPrint
147 #undef KdPrint
148 #endif
149 
150 #define PRINT_PREFIX "UniATA: "
151 
152 //#define KdPrint3(_x_) {if(LOG_ON_RAISED_IRQL_W2K || MajorVersion < 0x05 || KeGetCurrentIrql() <= 2){/*DbgPrint("%x: ", PsGetCurrentThread()) ;*/ DbgPrint _x_ ; if(g_LogToDisplay){ PrintNtConsole _x_ ;} }}
153 #define KdPrint3(_x_) {;}
154 #define KdPrint2(_x_) {;}
155 #define KdPrint(_x_) {;}
156 #define Connect_DbgPrint() {;}
157 
158 #define AtapiStallExecution(dt) ScsiPortStallExecution(dt)
159 
160 #endif // _DEBUG
161 
162 // IDE register definition
163 
164 #pragma pack(push, 1)
165 
166 typedef union _IDE_REGISTERS_1 {
167  struct _o {
176  } o;
177 
178  struct _i {
187  } i;
188 
190 
191 #define IDX_IO1 0
192 #define IDX_IO1_SZ sizeof(IDE_REGISTERS_1)
193 
194 #define IDX_IO1 0
195 #define IDX_IO1_SZ sizeof(IDE_REGISTERS_1)
196 #define IDX_IO1_i_Data (FIELD_OFFSET(IDE_REGISTERS_1, i.Data )+IDX_IO1)
197 #define IDX_IO1_i_Error (FIELD_OFFSET(IDE_REGISTERS_1, i.Error )+IDX_IO1)
198 #define IDX_IO1_i_BlockCount (FIELD_OFFSET(IDE_REGISTERS_1, i.BlockCount )+IDX_IO1)
199 #define IDX_IO1_i_BlockNumber (FIELD_OFFSET(IDE_REGISTERS_1, i.BlockNumber )+IDX_IO1)
200 #define IDX_IO1_i_CylinderLow (FIELD_OFFSET(IDE_REGISTERS_1, i.CylinderLow )+IDX_IO1)
201 #define IDX_IO1_i_CylinderHigh (FIELD_OFFSET(IDE_REGISTERS_1, i.CylinderHigh)+IDX_IO1)
202 #define IDX_IO1_i_DriveSelect (FIELD_OFFSET(IDE_REGISTERS_1, i.DriveSelect )+IDX_IO1)
203 #define IDX_IO1_i_Status (FIELD_OFFSET(IDE_REGISTERS_1, i.Status )+IDX_IO1)
204 
205 #define IDX_IO1_o IDX_IO1_SZ
206 #define IDX_IO1_o_SZ sizeof(IDE_REGISTERS_1)
207 
208 #define IDX_IO1_o_Data (FIELD_OFFSET(IDE_REGISTERS_1, o.Data )+IDX_IO1_o)
209 #define IDX_IO1_o_Feature (FIELD_OFFSET(IDE_REGISTERS_1, o.Feature )+IDX_IO1_o)
210 #define IDX_IO1_o_BlockCount (FIELD_OFFSET(IDE_REGISTERS_1, o.BlockCount )+IDX_IO1_o)
211 #define IDX_IO1_o_BlockNumber (FIELD_OFFSET(IDE_REGISTERS_1, o.BlockNumber )+IDX_IO1_o)
212 #define IDX_IO1_o_CylinderLow (FIELD_OFFSET(IDE_REGISTERS_1, o.CylinderLow )+IDX_IO1_o)
213 #define IDX_IO1_o_CylinderHigh (FIELD_OFFSET(IDE_REGISTERS_1, o.CylinderHigh)+IDX_IO1_o)
214 #define IDX_IO1_o_DriveSelect (FIELD_OFFSET(IDE_REGISTERS_1, o.DriveSelect )+IDX_IO1_o)
215 #define IDX_IO1_o_Command (FIELD_OFFSET(IDE_REGISTERS_1, o.Command )+IDX_IO1_o)
216 
217 typedef union _IDE_REGISTERS_2 {
221 
222 #define IDX_IO2 (IDX_IO1_o+IDX_IO1_o_SZ)
223 #define IDX_IO2_SZ sizeof(IDE_REGISTERS_2)
224 
225 #define IDX_IO2_AltStatus (FIELD_OFFSET(IDE_REGISTERS_2, AltStatus )+IDX_IO2)
226 //#define IDX_IO2_DriveAddress (FIELD_OFFSET(IDE_REGISTERS_2, DriveAddress)+IDX_IO2)
227 
228 #define IDX_IO2_o (IDX_IO2+IDX_IO2_SZ)
229 #define IDX_IO2_o_SZ sizeof(IDE_REGISTERS_2)
230 
231 #define IDX_IO2_o_Control (FIELD_OFFSET(IDE_REGISTERS_2, Control)+IDX_IO2_o)
232 //
233 // Device Extension Device Flags
234 //
235 
236 #define DFLAGS_DEVICE_PRESENT 0x0001 // Indicates that some device is present.
237 #define DFLAGS_ATAPI_DEVICE 0x0002 // Indicates whether ATAPI commands can be used.
238 #define DFLAGS_TAPE_DEVICE 0x0004 // Indicates whether this is a tape device.
239 #define DFLAGS_INT_DRQ 0x0008 // Indicates whether device interrupts as DRQ is set after
240  // receiving ATAPI Packet Command
241 #define DFLAGS_REMOVABLE_DRIVE 0x0010 // Indicates that the drive has the 'removable' bit set in
242  // identify data (offset 128)
243 #define DFLAGS_MEDIA_STATUS_ENABLED 0x0020 // Media status notification enabled
244 #define DFLAGS_ATAPI_CHANGER 0x0040 // Indicates atapi 2.5 changer present.
245 #define DFLAGS_SANYO_ATAPI_CHANGER 0x0080 // Indicates multi-platter device, not conforming to the 2.5 spec.
246 #define DFLAGS_CHANGER_INITED 0x0100 // Indicates that the init path for changers has already been done.
247 #define DFLAGS_LBA_ENABLED 0x0200 // Indicates that we should use LBA addressing rather than CHS
248 #define DFLAGS_DWORDIO_ENABLED 0x0400 // Indicates that we should use 32-bit IO
249 #define DFLAGS_WCACHE_ENABLED 0x0800 // Indicates that we use write cache
250 #define DFLAGS_RCACHE_ENABLED 0x1000 // Indicates that we use read cache
251 #define DFLAGS_ORIG_GEOMETRY 0x2000 //
252 #define DFLAGS_REINIT_DMA 0x4000 //
253 #define DFLAGS_HIDDEN 0x8000 // Hidden device, available only with special IOCTLs
254  // via communication virtual device
255 #define DFLAGS_MANUAL_CHS 0x10000 // For devices those have no IDENTIFY commands
256 #define DFLAGS_LBA32plus 0x20000 // Device is larger than LBA32
257 //#define DFLAGS_ 0x10000 //
258 //
259 // Used to disable 'advanced' features.
260 //
261 
262 #define MAX_ERRORS 4
263 
264 //
265 // ATAPI command definitions
266 //
267 
268 #define ATAPI_MODE_SENSE 0x5A
269 #define ATAPI_MODE_SELECT 0x55
270 #define ATAPI_FORMAT_UNIT 0x24
271 
272 // ATAPI Command Descriptor Block
273 
274 typedef struct _MODE_SENSE_10 {
277  UCHAR PageCode : 6;
278  UCHAR Pc : 2;
279  UCHAR Reserved2[4];
282  UCHAR Reserved3[3];
284 
285 typedef struct _MODE_SELECT_10 {
287  UCHAR Reserved1 : 4;
288  UCHAR PFBit : 1;
289  UCHAR Reserved2 : 3;
290  UCHAR Reserved3[5];
293  UCHAR Reserved4[3];
295 
296 typedef struct _MODE_PARAMETER_HEADER_10 {
300  UCHAR Reserved[5];
302 
303 //
304 // values for TransferMode
305 //
306 #define ATA_PIO 0x00
307 #define ATA_PIO_NRDY 0x01
308 
309 #define ATA_PIO0 0x08
310 #define ATA_PIO1 0x09
311 #define ATA_PIO2 0x0a
312 #define ATA_PIO3 0x0b
313 #define ATA_PIO4 0x0c
314 #define ATA_PIO5 0x0d
315 
316 #define ATA_DMA 0x10
317 #define ATA_SDMA 0x10
318 #define ATA_SDMA0 0x10
319 #define ATA_SDMA1 0x11
320 #define ATA_SDMA2 0x12
321 
322 #define ATA_WDMA 0x20
323 #define ATA_WDMA0 0x20
324 #define ATA_WDMA1 0x21
325 #define ATA_WDMA2 0x22
326 
327 #define ATA_UDMA 0x40
328 #define ATA_UDMA0 0x40 // ATA-16
329 #define ATA_UDMA1 0x41 // ATA-25
330 #define ATA_UDMA2 0x42 // ATA-33
331 #define ATA_UDMA3 0x43 // ATA-44
332 #define ATA_UDMA4 0x44 // ATA-66
333 #define ATA_UDMA5 0x45 // ATA-100
334 #define ATA_UDMA6 0x46 // ATA-133
335 //#define ATA_UDMA7 0x47 // ATA-166
336 
337 #define ATA_SA150 0x47 /*0x80*/
338 #define ATA_SA300 0x48 /*0x81*/
339 #define ATA_SA600 0x49 /*0x82*/
340 
341 #define ATA_MODE_NOT_SPEC ((ULONG)(-1)) /*0x82*/
342 
343 //
344 // IDE command definitions
345 //
346 
347 #define IDE_COMMAND_DATA_SET_MGMT 0x06 // TRIM
348 #define IDE_COMMAND_ATAPI_RESET 0x08
349 #define IDE_COMMAND_RECALIBRATE 0x10
350 #define IDE_COMMAND_READ 0x20
351 #define IDE_COMMAND_READ_NO_RETR 0x21
352 #define IDE_COMMAND_READ48 0x24
353 #define IDE_COMMAND_READ_DMA48 0x25
354 #define IDE_COMMAND_READ_DMA_Q48 0x26
355 #define IDE_COMMAND_READ_NATIVE_SIZE48 0x27
356 #define IDE_COMMAND_READ_MUL48 0x29
357 #define IDE_COMMAND_READ_STREAM_DMA48 0x2A
358 #define IDE_COMMAND_READ_STREAM48 0x2B
359 #define IDE_COMMAND_READ_LOG48 0x2f
360 #define IDE_COMMAND_WRITE 0x30
361 #define IDE_COMMAND_WRITE_NO_RETR 0x31
362 #define IDE_COMMAND_WRITE48 0x34
363 #define IDE_COMMAND_WRITE_DMA48 0x35
364 #define IDE_COMMAND_WRITE_DMA_Q48 0x36
365 #define IDE_COMMAND_SET_NATIVE_SIZE48 0x37
366 #define IDE_COMMAND_WRITE_MUL48 0x39
367 #define IDE_COMMAND_WRITE_STREAM_DMA48 0x3a
368 #define IDE_COMMAND_WRITE_STREAM48 0x3b
369 #define IDE_COMMAND_WRITE_FUA_DMA48 0x3d
370 #define IDE_COMMAND_WRITE_FUA_DMA_Q48 0x3e
371 #define IDE_COMMAND_WRITE_LOG48 0x3f
372 #define IDE_COMMAND_VERIFY 0x40
373 #define IDE_COMMAND_VERIFY48 0x42
374 #define IDE_COMMAND_READ_LOG_DMA48 0x47
375 #define IDE_COMMAND_WRITE_LOG_DMA48 0x57
376 #define IDE_COMMAND_TRUSTED_RCV 0x5c
377 #define IDE_COMMAND_TRUSTED_RCV_DMA 0x5d
378 #define IDE_COMMAND_TRUSTED_SEND 0x5e
379 #define IDE_COMMAND_TRUSTED_SEND_DMA 0x5f
380 #define IDE_COMMAND_SEEK 0x70
381 #define IDE_COMMAND_SET_DRIVE_PARAMETERS 0x91
382 #define IDE_COMMAND_ATAPI_PACKET 0xA0
383 #define IDE_COMMAND_ATAPI_IDENTIFY 0xA1
384 #define IDE_COMMAND_READ_MULTIPLE 0xC4
385 #define IDE_COMMAND_WRITE_MULTIPLE 0xC5
386 #define IDE_COMMAND_SET_MULTIPLE 0xC6
387 #define IDE_COMMAND_READ_DMA_Q 0xC7
388 #define IDE_COMMAND_READ_DMA 0xC8
389 #define IDE_COMMAND_WRITE_DMA 0xCA
390 #define IDE_COMMAND_WRITE_DMA_Q 0xCC
391 #define IDE_COMMAND_WRITE_MUL_FUA48 0xCE
392 #define IDE_COMMAND_GET_MEDIA_STATUS 0xDA
393 #define IDE_COMMAND_DOOR_LOCK 0xDE
394 #define IDE_COMMAND_DOOR_UNLOCK 0xDF
395 #define IDE_COMMAND_STANDBY_IMMED 0xE0 // flush and spin down
396 #define IDE_COMMAND_IDLE_IMMED 0xE1
397 #define IDE_COMMAND_STANDBY 0xE2 // flush and spin down and enable autopowerdown timer
398 #define IDE_COMMAND_IDLE 0xE3
399 #define IDE_COMMAND_READ_PM 0xE4 // SATA PM
400 #define IDE_COMMAND_SLEEP 0xE6 // flush, spin down and deactivate interface
401 #define IDE_COMMAND_FLUSH_CACHE 0xE7
402 #define IDE_COMMAND_WRITE_PM 0xE8 // SATA PM
403 #define IDE_COMMAND_IDENTIFY 0xEC
404 #define IDE_COMMAND_MEDIA_EJECT 0xED
405 #define IDE_COMMAND_FLUSH_CACHE48 0xEA
406 #define IDE_COMMAND_ENABLE_MEDIA_STATUS 0xEF
407 #define IDE_COMMAND_SET_FEATURES 0xEF /* features command,
408  IDE_COMMAND_ENABLE_MEDIA_STATUS */
409 #define IDE_COMMAND_READ_NATIVE_SIZE 0xF8
410 #define IDE_COMMAND_SET_NATIVE_SIZE 0xF9
411 
412 #define SCSIOP_ATA_PASSTHROUGH 0xCC //
413 
414 //
415 // IDE status definitions
416 //
417 
418 #define IDE_STATUS_SUCCESS 0x00
419 #define IDE_STATUS_ERROR 0x01
420 #define IDE_STATUS_INDEX 0x02
421 #define IDE_STATUS_CORRECTED_ERROR 0x04
422 #define IDE_STATUS_DRQ 0x08
423 #define IDE_STATUS_DSC 0x10
424 //#define IDE_STATUS_DWF 0x10 /* drive write fault */
425 #define IDE_STATUS_DMA 0x20 /* DMA ready */
426 #define IDE_STATUS_DWF 0x20 /* drive write fault */
427 #define IDE_STATUS_DRDY 0x40
428 #define IDE_STATUS_IDLE 0x50
429 #define IDE_STATUS_BUSY 0x80
430 
431 #define IDE_STATUS_WRONG 0xff
432 #define IDE_STATUS_MASK 0xff
433 
434 
435 //
436 // IDE drive select/head definitions
437 //
438 
439 #define IDE_DRIVE_SELECT 0xA0
440 #define IDE_DRIVE_1 0x00
441 #define IDE_DRIVE_2 0x10
442 #define IDE_DRIVE_SELECT_1 (IDE_DRIVE_SELECT | IDE_DRIVE_1)
443 #define IDE_DRIVE_SELECT_2 (IDE_DRIVE_SELECT | IDE_DRIVE_2)
444 #define IDE_DRIVE_MASK (IDE_DRIVE_SELECT_1 | IDE_DRIVE_SELECT_2)
445 
446 #define IDE_USE_LBA 0x40
447 
448 //
449 // IDE drive control definitions
450 //
451 
452 #define IDE_DC_DISABLE_INTERRUPTS 0x02
453 #define IDE_DC_RESET_CONTROLLER 0x04
454 #define IDE_DC_A_4BIT 0x80
455 #define IDE_DC_USE_HOB 0x80 // use high-order byte(s)
456 #define IDE_DC_REENABLE_CONTROLLER 0x00
457 
458 // IDE error definitions
459 //
460 
461 #define IDE_ERROR_ICRC 0x80
462 #define IDE_ERROR_BAD_BLOCK 0x80
463 #define IDE_ERROR_DATA_ERROR 0x40
464 #define IDE_ERROR_MEDIA_CHANGE 0x20
465 #define IDE_ERROR_ID_NOT_FOUND 0x10
466 #define IDE_ERROR_MEDIA_CHANGE_REQ 0x08
467 #define IDE_ERROR_COMMAND_ABORTED 0x04
468 #define IDE_ERROR_END_OF_MEDIA 0x02
469 #define IDE_ERROR_NO_MEDIA 0x02
470 #define IDE_ERROR_ILLEGAL_LENGTH 0x01
471 
472 //
473 // ATAPI register definition
474 //
475 
476 typedef union _ATAPI_REGISTERS_1 {
477  struct _o {
486  } o;
487 
488  struct _i {
497  } i;
498 
499  //IDE_REGISTERS_1 ide;
500 
502 
503 #define IDX_ATAPI_IO1 IDX_IO1
504 #define IDX_ATAPI_IO1_SZ sizeof(ATAPI_REGISTERS_1)
505 
506 #define IDX_ATAPI_IO1_i_Data (FIELD_OFFSET(ATAPI_REGISTERS_1, i.Data )+IDX_ATAPI_IO1)
507 #define IDX_ATAPI_IO1_i_Error (FIELD_OFFSET(ATAPI_REGISTERS_1, i.Error )+IDX_ATAPI_IO1)
508 #define IDX_ATAPI_IO1_i_InterruptReason (FIELD_OFFSET(ATAPI_REGISTERS_1, i.InterruptReason)+IDX_ATAPI_IO1)
509 #define IDX_ATAPI_IO1_i_Unused1 (FIELD_OFFSET(ATAPI_REGISTERS_1, i.Unused1 )+IDX_ATAPI_IO1)
510 #define IDX_ATAPI_IO1_i_ByteCountLow (FIELD_OFFSET(ATAPI_REGISTERS_1, i.ByteCountLow )+IDX_ATAPI_IO1)
511 #define IDX_ATAPI_IO1_i_ByteCountHigh (FIELD_OFFSET(ATAPI_REGISTERS_1, i.ByteCountHigh )+IDX_ATAPI_IO1)
512 #define IDX_ATAPI_IO1_i_DriveSelect (FIELD_OFFSET(ATAPI_REGISTERS_1, i.DriveSelect )+IDX_ATAPI_IO1)
513 #define IDX_ATAPI_IO1_i_Status (FIELD_OFFSET(ATAPI_REGISTERS_1, i.Status )+IDX_ATAPI_IO1)
514 
515 #define IDX_ATAPI_IO1_o_Data (FIELD_OFFSET(ATAPI_REGISTERS_1, o.Data )+IDX_ATAPI_IO1)
516 #define IDX_ATAPI_IO1_o_Feature (FIELD_OFFSET(ATAPI_REGISTERS_1, o.Feature )+IDX_ATAPI_IO1)
517 #define IDX_ATAPI_IO1_o_Unused0 (FIELD_OFFSET(ATAPI_REGISTERS_1, o.Unused0 )+IDX_ATAPI_IO1)
518 #define IDX_ATAPI_IO1_o_Unused1 (FIELD_OFFSET(ATAPI_REGISTERS_1, o.Unused1 )+IDX_ATAPI_IO1)
519 #define IDX_ATAPI_IO1_o_ByteCountLow (FIELD_OFFSET(ATAPI_REGISTERS_1, o.ByteCountLow )+IDX_ATAPI_IO1)
520 #define IDX_ATAPI_IO1_o_ByteCountHigh (FIELD_OFFSET(ATAPI_REGISTERS_1, o.ByteCountHigh)+IDX_ATAPI_IO1)
521 #define IDX_ATAPI_IO1_o_DriveSelect (FIELD_OFFSET(ATAPI_REGISTERS_1, o.DriveSelect )+IDX_ATAPI_IO1)
522 #define IDX_ATAPI_IO1_o_Command (FIELD_OFFSET(ATAPI_REGISTERS_1, o.Command )+IDX_ATAPI_IO1)
523 
524 /*
525 typedef union _ATAPI_REGISTERS_2 {
526  struct {
527  UCHAR AltStatus;
528  UCHAR DriveAddress;
529  };
530 
531  //IDE_REGISTERS_2 ide;
532 
533 } ATAPI_REGISTERS_2, *PATAPI_REGISTERS_2;
534 
535 #define IDX_ATAPI_IO2 IDX_ATAPI_IO2_SZ
536 #define IDX_ATAPI_IO2_SZ sizeof(ATAPI_REGISTERS_2)
537 */
538 
539 //
540 // ATAPI interrupt reasons
541 //
542 
543 // for IDX_ATAPI_IO1_i_InterruptReason
544 #define ATAPI_IR_COD 0x01
545 #define ATAPI_IR_COD_Data 0x0
546 #define ATAPI_IR_COD_Cmd 0x1
547 
548 #define ATAPI_IR_IO 0x02
549 #define ATAPI_IR_IO_toDev 0x00
550 #define ATAPI_IR_IO_toHost 0x02
551 
552 #define ATAPI_IR_Mask 0x03
553 
554 //
555 // ATA Features
556 //
557 
558 #define ATA_F_DMA 0x01 /* enable DMA */
559 #define ATA_F_OVL 0x02 /* enable overlap */
560 #define ATA_F_DMAREAD 0x04 /* DMA Packet (ATAPI) read */
561 
562 #define ATA_C_F_SETXFER 0x03 /* set transfer mode */
563 
564 #define ATA_C_F_ENAB_WCACHE 0x02 /* enable write cache */
565 #define ATA_C_F_DIS_WCACHE 0x82 /* disable write cache */
566 
567 #define ATA_C_F_ENAB_RCACHE 0xaa /* enable readahead cache */
568 #define ATA_C_F_DIS_RCACHE 0x55 /* disable readahead cache */
569 
570 #define ATA_C_F_ENAB_RELIRQ 0x5d /* enable release interrupt */
571 #define ATA_C_F_DIS_RELIRQ 0xdd /* disable release interrupt */
572 
573 #define ATA_C_F_ENAB_SRVIRQ 0x5e /* enable service interrupt */
574 #define ATA_C_F_DIS_SRVIRQ 0xde /* disable service interrupt */
575 
576 #define ATA_C_F_ENAB_MEDIASTAT 0x95 /* enable media status */
577 #define ATA_C_F_DIS_MEDIASTAT 0x31 /* disable media status */
578 
579 #define ATA_C_F_ENAB_APM 0x05 /* enable advanced power management */
580 #define ATA_C_F_DIS_APM 0x85 /* disable advanced power management */
581 #define ATA_C_F_APM_CNT_MAX_PERF 0xfe /* maximum performance */
582 #define ATA_C_F_APM_CNT_MIN_NO_STANDBY 0x80 /* min. power w/o standby */
583 #define ATA_C_F_APM_CNT_MIN_STANDBY 0x01 /* min. power with standby */
584 
585 #define ATA_C_F_ENAB_ACOUSTIC 0x42 /* enable acoustic management */
586 #define ATA_C_F_DIS_ACOUSTIC 0xc2 /* disable acoustic management */
587 #define ATA_C_F_AAM_CNT_MAX_PERF 0xfe /* maximum performance */
588 #define ATA_C_F_AAM_CNT_MAX_POWER_SAVE 0x80 /* min. power */
589 
590 // New SMART Feature definitions
591 #ifndef READ_LOG_SECTOR
592 #define READ_LOG_SECTOR 0xD5
593 #define WRITE_LOG_SECTOR 0xD6
594 #define WRITE_THRESHOLDS 0xD7
595 #define AUTO_OFFLINE 0xDB
596 #endif // READ_LOG_SECTOR
597 
598 //
599 // ATAPI interrupt reasons
600 //
601 
602 #define ATA_I_CMD 0x01 /* cmd (1) | data (0) */
603 #define ATA_I_IN 0x02 /* read (1) | write (0) */
604 #define ATA_I_RELEASE 0x04 /* released bus (1) */
605 #define ATA_I_TAGMASK 0xf8 /* tag mask */
606 
607 // IDENTIFY data
608 //
609 
610 typedef struct _IDENTIFY_DATA {
611  UCHAR AtapiCmdSize:2; // 00 00
612 #define ATAPI_PSIZE_12 0 /* 12 bytes */
613 #define ATAPI_PSIZE_16 1 /* 16 bytes */
614  UCHAR :3;
615  UCHAR DrqType:2; // 00 00
616 #define ATAPI_DRQT_MPROC 0 /* cpu 3 ms delay */
617 #define ATAPI_DRQT_INTR 1 /* intr 10 ms delay */
618 #define ATAPI_DRQT_ACCEL 2 /* accel 50 us delay */
620 
622 #define ATAPI_TYPE_DIRECT 0 /* disk/floppy */
623 #define ATAPI_TYPE_TAPE 1 /* streaming tape */
624 #define ATAPI_TYPE_CDROM 5 /* CD-ROM device */
625 #define ATAPI_TYPE_OPTICAL 7 /* optical disk */
626  UCHAR :1;
627  UCHAR CmdProtocol:2; // 00 00
628 #define ATAPI_PROTO_ATAPI 2
629 // USHORT GeneralConfiguration; // 00 00
630 
631  USHORT NumberOfCylinders; // 02 1
632  USHORT Reserved1; // 04 2
633  USHORT NumberOfHeads; // 06 3
634  USHORT UnformattedBytesPerTrack; // 08 4 // Now obsolete
635  USHORT UnformattedBytesPerSector; // 0A 5 // Now obsolete
636  USHORT SectorsPerTrack; // 0C 6
637 
638  USHORT VendorUnique1[3]; // 0E 7-9
639  UCHAR SerialNumber[20]; // 14 10-19
640 
641  USHORT BufferType; // 28 20
642 #define ATA_BT_SINGLEPORTSECTOR 1 /* 1 port, 1 sector buffer */
643 #define ATA_BT_DUALPORTMULTI 2 /* 2 port, mult sector buffer */
644 #define ATA_BT_DUALPORTMULTICACHE 3 /* above plus track cache */
645 
646  USHORT BufferSectorSize; // 2A 21
647  USHORT NumberOfEccBytes; // 2C 22
648  USHORT FirmwareRevision[4]; // 2E 23-26
649  USHORT ModelNumber[20]; // 36 27-46
650  UCHAR MaximumBlockTransfer; // 5E 47
651  UCHAR VendorUnique2; // 5F
652 
653  USHORT DoubleWordIo; // 60 48
654 
655  USHORT Reserved62_0:8; // 62 49
662  USHORT SupportQTag:1; /* supports queuing overlap */
663  USHORT SupportIDma:1; /* interleaved DMA supported */
664 
665 /* USHORT Capabilities; // 62 49
666 #define IDENTIFY_CAPABILITIES_SUPPORT_DMA 0x0100
667 #define IDENTIFY_CAPABILITIES_SUPPORT_LBA 0x0200
668 #define IDENTIFY_CAPABILITIES_DISABLE_IORDY 0x0400
669 #define IDENTIFY_CAPABILITIES_SUPPORT_IORDY 0x0800
670 #define IDENTIFY_CAPABILITIES_SOFT_RESET 0x1000
671 #define IDENTIFY_CAPABILITIES_STDBY_OVLP 0x2000
672 #define IDENTIFY_CAPABILITIES_SUPPORT_QTAG 0x4000
673 #define IDENTIFY_CAPABILITIES_SUPPORT_IDMA 0x8000*/
674 
679 // USHORT Reserved2;
680 
681  UCHAR Vendor51; // 66 51
683 
684  UCHAR Vendor52; // 68 52
686 
687  USHORT TranslationFieldsValid:1; // 6A 53 /* 54-58 */
688  USHORT PioTimingsValid:1; /* 64-70 */
689  USHORT UdmaModesValid:1; /* 88 */
690  USHORT Reserved3:13;
691 
692  USHORT NumberOfCurrentCylinders; // 6C 54 \-
693  USHORT NumberOfCurrentHeads; // 6E 55 \-
694  USHORT CurrentSectorsPerTrack; // 70 56 /- obsolete USHORT[5]
695  ULONG CurrentSectorCapacity; // 72 57-58 /-
696 
704 
705  ULONG UserAddressableSectors; // 60-61
706 
707  union {
708  struct {
709  USHORT SingleWordDMASupport : 8; // 62 ATA, obsolete
711  };
712  struct {
713  USHORT UDMASupport : 7; // 62 ATAPI
718  } AtapiDMA;
719  };
720 
721  USHORT MultiWordDMASupport : 8; // 63
723 
724  USHORT AdvancedPIOModes : 8; // 64
725  USHORT Reserved4 : 8;
726 
727 #define AdvancedPIOModes_3 1
728 #define AdvancedPIOModes_4 2
729 #define AdvancedPIOModes_5 4 // non-standard
730 
735 
748 
752  USHORT Reserved73_74[2]; // 73-74
753 
754  USHORT QueueLength : 5; // 75
756 
758 #define ATA_SATA_GEN1 0x0002
759 #define ATA_SATA_GEN2 0x0004
760 #define ATA_SATA_GEN3 0x0008
761 #define ATA_SUPPORT_NCQ 0x0100
762 #define ATA_SUPPORT_IFPWRMNGTRCV 0x0200
763 #define ATA_SUPPORT_PHY_EVENT_COUNTER 0x0400
764 #define ATA_SUPPORT_NCQ_UNLOAD 0x0800
765 #define ATA_SUPPORT_NCQ_PRI_INFO 0x1000
766 
768 
770 #define ATA_SUPPORT_NONZERO 0x0002
771 #define ATA_SUPPORT_AUTOACTIVATE 0x0004
772 #define ATA_SUPPORT_IFPWRMNGT 0x0008
773 #define ATA_SUPPORT_INORDERDATA 0x0010
774 
776  USHORT MajorRevision; // 80
777  USHORT MinorRevision; // 81
778 
779 #define ATA_VER_MJ_ATA4 0x0010
780 #define ATA_VER_MJ_ATA5 0x0020
781 #define ATA_VER_MJ_ATA6 0x0040
782 #define ATA_VER_MJ_ATA7 0x0080
783 #define ATA_VER_MJ_ATA8_ASC 0x0100
784 
785  struct {
786  USHORT Smart:1; // 82/85
802 
803  USHORT Microcode:1; // 83/86
804  USHORT Queued:1; //
805  USHORT CFA:1; //
806  USHORT APM:1; //
807  USHORT Notify:1; //
809  USHORT Spinup:1; //
819 
820  USHORT SmartErrorLog:1; // 84/87
830 
833 
837 
839 
840  USHORT HwResMaster : 8; // 93
844 
845 #define IDENTIFY_CABLE_ID_VALID 0x01
846 
849 
854 
856 
858  USHORT MaxLBARangeDescBlockCount; // 105 // in 512b blocks
859  union {
861  struct {
864  USHORT PLSS_LargeL:1; // =1 if 117-118 are valid
866  USHORT PLSS_Signature:2; // = 0x01 = 01b
867  };
868  };
870  USHORT WorldWideName[4]; // 108-111
871  USHORT Reserved112[5]; // 112-116
872 
873  ULONG LargeSectorSize; // 117-118
874 
875  struct {
878  USHORT Reserved121[4]; // 121-124
881 
883  union {
885  struct {
893  USHORT MasterPasswdCap:1; // 0 - high, 1 - max
896  };
897 
898  USHORT Reserved129[31]; // 129-159
900  USHORT Reserved161[7]; // 161-167
905  USHORT AdditionalProdNum[4]; // 170-173
906  USHORT Reserved174[2]; // 174-175
907  USHORT MediaSerial[30]; // 176-205
908  union {
909  USHORT SCT; // 206
910  struct {
912  USHORT Reserved:1;
918  };
919  };
920  USHORT Reserved_CE_ATA[2]; // 207-208
924 
927 
935 
941 
944 
946  union {
947  struct {
950  };
951  struct {
954  USHORT Reserved:14;
955  } PATA;
956  struct {
963  USHORT Reserved:10;
964  } SATA;
966  } TransportMajor;
968 
969  USHORT Reserved224[10]; // 224-233
970 
973 
974  USHORT Reserved236[19]; // 236-254
975 
976  union {
978  struct {
979 #define ATA_ChecksumValid 0xA5
982  };
983  };
985 
986 //
987 // Identify data without the Reserved4.
988 //
989 
990 #define IDENTIFY_DATA2 IDENTIFY_DATA
991 #define PIDENTIFY_DATA2 PIDENTIFY_DATA
992 
993 /*typedef struct _IDENTIFY_DATA2 {
994  UCHAR AtapiCmdSize:2; // 00 00
995  UCHAR :3;
996  UCHAR DrqType:2; // 00 00
997  UCHAR Removable:1;
998 
999  UCHAR DeviceType:5;
1000  UCHAR :1;
1001  UCHAR CmdProtocol:2; // 00 00
1002 // USHORT GeneralConfiguration; // 00
1003 
1004  USHORT NumberOfCylinders; // 02
1005  USHORT Reserved1; // 04
1006  USHORT NumberOfHeads; // 06
1007  USHORT UnformattedBytesPerTrack; // 08
1008  USHORT UnformattedBytesPerSector; // 0A
1009  USHORT SectorsPerTrack; // 0C
1010  USHORT VendorUnique1[3]; // 0E
1011  UCHAR SerialNumber[20]; // 14
1012  USHORT BufferType; // 28
1013  USHORT BufferSectorSize; // 2A
1014  USHORT NumberOfEccBytes; // 2C
1015  USHORT FirmwareRevision[4]; // 2E
1016  USHORT ModelNumber[20]; // 36
1017  UCHAR MaximumBlockTransfer; // 5E
1018  UCHAR VendorUnique2; // 5F
1019  USHORT DoubleWordIo; // 60
1020  USHORT Capabilities; // 62
1021  USHORT Reserved2; // 64
1022  UCHAR VendorUnique3; // 66
1023  UCHAR PioCycleTimingMode; // 67
1024  UCHAR VendorUnique4; // 68
1025  UCHAR DmaCycleTimingMode; // 69
1026  USHORT TranslationFieldsValid:1; // 6A
1027  USHORT Reserved3:15;
1028  USHORT NumberOfCurrentCylinders; // 6C
1029  USHORT NumberOfCurrentHeads; // 6E
1030  USHORT CurrentSectorsPerTrack; // 70
1031  ULONG CurrentSectorCapacity; // 72
1032 } IDENTIFY_DATA2, *PIDENTIFY_DATA2;*/
1033 
1034 #define IDENTIFY_DATA_SIZE sizeof(IDENTIFY_DATA)
1035 
1036 
1037 // IDENTIFY DMA timing cycle modes.
1038 #define IDENTIFY_DMA_CYCLES_MODE_0 0x00
1039 #define IDENTIFY_DMA_CYCLES_MODE_1 0x01
1040 #define IDENTIFY_DMA_CYCLES_MODE_2 0x02
1041 
1042 // for IDE_COMMAND_DATA_SET_MGMT
1043 typedef struct _TRIM_DATA {
1046 } TRIM_DATA, *PTRIM_DATA;
1047 
1048 /*
1049 #define PCI_DEV_HW_SPEC(idhi, idlo) \
1050  { #idlo, 4, #idhi, 4}
1051 
1052 typedef struct _BROKEN_CONTROLLER_INFORMATION {
1053  PCHAR VendorId;
1054  ULONG VendorIdLength;
1055  PCHAR DeviceId;
1056  ULONG DeviceIdLength;
1057 }BROKEN_CONTROLLER_INFORMATION, *PBROKEN_CONTROLLER_INFORMATION;
1058 
1059 BROKEN_CONTROLLER_INFORMATION const BrokenAdapters[] = {
1060  // CMD 640 ATA controller !WARNING! buggy chip data loss possible
1061  PCI_DEV_HW_SPEC( 0640, 1095 ), //{ "1095", 4, "0640", 4},
1062  // ??
1063  PCI_DEV_HW_SPEC( 0601, 1039 ), //{ "1039", 4, "0601", 4}
1064  // RZ 100? ATA controller !WARNING! buggy chip data loss possible
1065  PCI_DEV_HW_SPEC( 1000, 1042 ),
1066  PCI_DEV_HW_SPEC( 1001, 1042 )
1067 };
1068 
1069 #define BROKEN_ADAPTERS (sizeof(BrokenAdapters) / sizeof(BROKEN_CONTROLLER_INFORMATION))
1070 
1071 typedef struct _NATIVE_MODE_CONTROLLER_INFORMATION {
1072  PCHAR VendorId;
1073  ULONG VendorIdLength;
1074  PCHAR DeviceId;
1075  ULONG DeviceIdLength;
1076 }NATIVE_MODE_CONTROLLER_INFORMATION, *PNATIVE_MODE_CONTROLLER_INFORMATION;
1077 
1078 NATIVE_MODE_CONTROLLER_INFORMATION const NativeModeAdapters[] = {
1079  PCI_DEV_HW_SPEC( 0105, 10ad ) //{ "10ad", 4, "0105", 4}
1080 };
1081 
1082 #define NUM_NATIVE_MODE_ADAPTERS (sizeof(NativeModeAdapters) / sizeof(NATIVE_MODE_CONTROLLER_INFORMATION))
1083 */
1084 //
1085 // Beautification macros
1086 //
1087 
1088 #ifndef USER_MODE
1089 
1090 #define GetStatus(chan, Status) \
1091  Status = AtapiReadPort1(chan, IDX_IO2_AltStatus);
1092 
1093 #define GetBaseStatus(chan, pStatus) \
1094  pStatus = AtapiReadPort1(chan, IDX_IO1_i_Status);
1095 
1096 #define WriteCommand(chan, _Command) \
1097  AtapiWritePort1(chan, IDX_IO1_o_Command, _Command);
1098 
1099 /*
1100 #define SelectDrive(chan, unit) { \
1101  if(chan && chan->lun[unit] && chan->lun[unit]->DeviceFlags & DFLAGS_ATAPI_CHANGER) KdPrint3((" Select %d\n", unit)); \
1102  AtapiWritePort1(chan, IDX_IO1_o_DriveSelect, (unit) ? IDE_DRIVE_SELECT_2 : IDE_DRIVE_SELECT_1); \
1103 }
1104 */
1105 
1106 #define ReadBuffer(chan, Buffer, Count, timing) \
1107  AtapiReadBuffer2(chan, IDX_IO1_i_Data, \
1108  Buffer, \
1109  Count, \
1110  timing);
1111 
1112 #define WriteBuffer(chan, Buffer, Count, timing) \
1113  AtapiWriteBuffer2(chan, IDX_IO1_o_Data, \
1114  Buffer, \
1115  Count, \
1116  timing);
1117 
1118 #define ReadBuffer2(chan, Buffer, Count, timing) \
1119  AtapiReadBuffer4(chan, IDX_IO1_i_Data, \
1120  Buffer, \
1121  Count, \
1122  timing);
1123 
1124 #define WriteBuffer2(chan, Buffer, Count, timing) \
1125  AtapiWriteBuffer4(chan, IDX_IO1_o_Data, \
1126  Buffer, \
1127  Count, \
1128  timing);
1129 
1130 UCHAR
1131 DDKFASTAPI
1132 SelectDrive(
1133  IN struct _HW_CHANNEL* chan,
1135  );
1136 
1137 UCHAR
1138 DDKFASTAPI
1139 WaitOnBusy(
1140  IN struct _HW_CHANNEL* chan/*,
1141  PIDE_REGISTERS_2 BaseIoAddress*/
1142  );
1143 
1144 UCHAR
1145 DDKFASTAPI
1147  IN struct _HW_CHANNEL* chan/*,
1148  PIDE_REGISTERS_2 BaseIoAddress*/
1149  );
1150 
1151 UCHAR
1152 DDKFASTAPI
1154  IN struct _HW_CHANNEL* chan/*,
1155  PIDE_REGISTERS_1 BaseIoAddress*/
1156  );
1157 
1158 UCHAR
1159 DDKFASTAPI
1161  IN struct _HW_CHANNEL* chan/*,
1162  PIDE_REGISTERS_1 BaseIoAddress*/
1163  );
1164 
1165 UCHAR
1166 DDKFASTAPI
1167 WaitForDrq(
1168  IN struct _HW_CHANNEL* chan/*,
1169  PIDE_REGISTERS_2 BaseIoAddress*/
1170  );
1171 
1172 UCHAR
1173 DDKFASTAPI
1175  IN struct _HW_CHANNEL* chan/*,
1176  PIDE_REGISTERS_2 BaseIoAddress*/
1177  );
1178 
1179 VOID
1180 DDKFASTAPI
1182  IN struct _HW_CHANNEL* chan,/*
1183  PIDE_REGISTERS_1 BaseIoAddress*/
1185  );
1186 
1187 VOID
1188 DDKFASTAPI
1190  IN struct _HW_CHANNEL* chan,
1191  IN BOOLEAN DisableInterrupts,
1192  IN ULONG Delay
1193  );
1194 
1195 
1196 #endif //USER_MODE
1197 
1198 #define IS_RDP(OperationCode)\
1199  ((OperationCode == SCSIOP_ERASE)||\
1200  (OperationCode == SCSIOP_LOAD_UNLOAD)||\
1201  (OperationCode == SCSIOP_LOCATE)||\
1202  (OperationCode == SCSIOP_REWIND) ||\
1203  (OperationCode == SCSIOP_SPACE)||\
1204  (OperationCode == SCSIOP_SEEK)||\
1205 /* (OperationCode == SCSIOP_FORMAT_UNIT)||\
1206  (OperationCode == SCSIOP_BLANK)||*/ \
1207  (OperationCode == SCSIOP_WRITE_FILEMARKS))
1208 
1209 #ifndef USER_MODE
1210 
1212 NTAPI
1214  IN PVOID HwDeviceExtension,
1216  );
1217 
1219 NTAPI
1221  IN PVOID HwDeviceExtension,
1223  );
1224 
1225 VOID
1226 NTAPI
1228  IN PVOID HwDeviceExtension,
1229  IN ULONG TargetId,
1231  );
1232 
1233 ULONG
1234 NTAPI
1236  IN PVOID HwDeviceExtension,
1238  IN ULONG CmdAction
1239  );
1240 
1241 ULONG
1242 NTAPI
1244  IN PVOID HwDeviceExtension,
1246  IN ULONG CmdAction
1247  );
1248 
1249 #define AtapiCopyMemory RtlCopyMemory
1250 
1251 VOID
1252 NTAPI
1254  ULONG Value,
1255  PCHAR *Buffer
1256  );
1257 
1258 #define AtapiStringCmp(s1, s2, n) _strnicmp(s1, s2, n)
1259 
1260 BOOLEAN
1261 NTAPI
1263  IN PVOID HwDeviceExtension
1264  );
1265 
1266 BOOLEAN
1267 NTAPI
1269  IN PVOID HwDeviceExtension,
1270  IN UCHAR c
1271  );
1272 
1273 UCHAR
1274 NTAPI
1276  IN PVOID HwDeviceExtension,
1277  IN UCHAR c
1278  );
1279 
1280 #define INTERRUPT_REASON_IGNORE 0
1281 #define INTERRUPT_REASON_OUR 1
1282 #define INTERRUPT_REASON_UNEXPECTED 2
1283 
1284 BOOLEAN
1285 NTAPI
1287  IN PVOID HwDeviceExtension
1288  );
1289 
1290 ULONG
1291 NTAPI
1293  IN PVOID HwDeviceExtension,
1295  );
1296 
1297 VOID
1298 NTAPI
1300  BOOLEAN EnableMSN,
1301  IN PVOID HwDeviceExtension,
1302  IN ULONG lChannel,
1304  );
1305 
1306 ULONG
1307 NTAPI
1309  IN PVOID HwDeviceExtension,
1310  IN PVOID Context,
1311  IN PVOID BusInformation,
1312  IN PCHAR ArgumentString,
1314  OUT PBOOLEAN Again
1315  );
1316 
1317 ULONG
1318 NTAPI
1320  IN PVOID HwDeviceExtension,
1321  IN PVOID Context,
1322  IN PVOID BusInformation,
1323  IN PCHAR ArgumentString,
1325  OUT PBOOLEAN Again
1326  );
1327 
1328 ULONG
1329 NTAPI
1331  IN PCCH String,
1332  IN PCCH KeyWord
1333  );
1334 
1335 BOOLEAN
1336 NTAPI
1338  IN PVOID HwDeviceExtension,
1340  IN ULONG Channel,
1341  IN UCHAR Command,
1342  IN BOOLEAN NoSetup
1343  );
1344 
1345 BOOLEAN
1346 NTAPI
1348  IN PVOID HwDeviceExtension,
1350  IN ULONG Channel
1351  );
1352 
1353 ULONG
1354 NTAPI
1355 CheckDevice(
1356  IN PVOID HwDeviceExtension,
1357  IN ULONG Channel,
1358  IN ULONG deviceNumber,
1360  );
1361 
1362 #define UNIATA_FIND_DEV_UNHIDE 0x01
1363 
1364 BOOLEAN
1365 NTAPI
1366 FindDevices(
1367  IN PVOID HwDeviceExtension,
1368  IN ULONG Flags,
1369  IN ULONG Channel
1370  );
1371 
1372 #endif //USER_MODE
1373 
1374 #ifdef __cplusplus
1375 };
1376 #endif //__cplusplus
1377 
1378 #ifndef USER_MODE
1379 
1380 BOOLEAN
1381 NTAPI
1383  IN PVOID HwDeviceExtension,
1384  IN ULONG PathId
1385  );
1386 
1387 BOOLEAN
1388 NTAPI
1389 AtapiStartIo(
1390  IN PVOID HwDeviceExtension,
1392  );
1393 
1394 BOOLEAN
1395 NTAPI
1397  IN PVOID HwDeviceExtension,
1400  );
1401 
1402 extern UCHAR
1403 NTAPI
1404 AtaCommand48(
1405 // IN PVOID HwDeviceExtension,
1406  IN struct _HW_DEVICE_EXTENSION* deviceExtension,
1408  IN ULONG Channel,
1409  IN UCHAR command,
1410  IN ULONGLONG lba,
1411  IN USHORT count,
1412  IN USHORT feature,
1413  IN ULONG flags
1414  );
1415 
1416 extern UCHAR
1417 NTAPI
1418 AtaCommand(
1419 // IN PVOID HwDeviceExtension,
1420  IN struct _HW_DEVICE_EXTENSION* deviceExtension,
1422  IN ULONG Channel,
1423  IN UCHAR command,
1424  IN USHORT cylinder,
1425  IN UCHAR head,
1426  IN UCHAR sector,
1427  IN UCHAR count,
1428  IN UCHAR feature,
1429  IN ULONG flags
1430  );
1431 
1432 extern LONG
1433 NTAPI
1435 
1436 extern LONG
1437 NTAPI
1439 
1440 extern LONG
1441 NTAPI
1443 
1444 extern VOID
1445 NTAPI
1447  IN PKDPC Dpc,
1451  );
1452 
1453 //#define AtaCommand(de, devn, chan, cmd, cyl, hd, sec, cnt, feat, flg)
1454 
1455 extern LONG
1456 NTAPI
1457 AtaPio2Mode(LONG pio);
1458 
1459 extern LONG
1460 NTAPI
1462 
1463 extern VOID
1464 NTAPI
1466  IN PVOID HwDeviceExtension,
1467  IN ULONG c
1468  );
1469 
1470 extern VOID
1471 NTAPI
1473  IN PVOID HwDeviceExtension,
1474  IN ULONG c
1475  );
1476 
1477 extern VOID
1479  IN struct _HW_CHANNEL* chan,
1480  IN BOOLEAN Expecting
1481  );
1482 
1483 #define CHAN_NOT_SPECIFIED (0xffffffffL)
1484 #define CHAN_NOT_SPECIFIED_CHECK_CABLE (0xfffffffeL)
1485 #define DEVNUM_NOT_SPECIFIED (0xffffffffL)
1486 #define IOMODE_NOT_SPECIFIED (0xffffffffL)
1487 
1488 extern ULONG
1489 NTAPI
1491  IN PVOID HwDeviceExtension,
1492  IN ULONG chan,
1493  IN ULONG dev,
1494  IN PCWSTR Name,
1495  IN ULONG Default
1496  );
1497 
1498 extern ULONG
1499 NTAPI
1501  IN PVOID HwDeviceExtension,
1502  IN PCWSTR PathSuffix,
1503  IN PCWSTR Name,
1504  IN ULONG Default
1505  );
1506 
1507 extern ULONG g_LogToDisplay;
1508 
1509 extern "C"
1510 VOID
1511 _cdecl
1513  PCCH DebugMessage,
1514  ...
1515  );
1516 
1517 VOID
1518 NTAPI
1520  IN struct _HW_DEVICE_EXTENSION* deviceExtension,
1521  IN struct _IDE_BUSMASTER_REGISTERS* BaseIoAddressBM_0,
1522  IN BOOLEAN MemIo
1523  );
1524 
1525 VOID
1526 NTAPI
1528  IN struct _HW_CHANNEL* chan,
1529  IN PIDE_REGISTERS_1 BaseIoAddress1,
1530  IN PIDE_REGISTERS_2 BaseIoAddress2
1531  );
1532 
1533 VOID
1534 NTAPI
1536  IN struct _HW_CHANNEL* chan
1537  );
1538 
1539 VOID
1541  IN struct _HW_CHANNEL* chan,
1542  IN ULONG idx,
1543  IN ULONG addr,
1544  IN BOOLEAN MemIo,
1545  IN BOOLEAN Proc
1546  );
1547 
1548 VOID
1550  IN struct _IORES* IoRes,
1551  IN ULONG addr,
1552  IN BOOLEAN MemIo,
1553  IN BOOLEAN Proc
1554  );
1555 
1556 UCHAR
1557 DDKFASTAPI
1558 UniataIsIdle(
1559  IN struct _HW_DEVICE_EXTENSION* deviceExtension,
1560  IN UCHAR Status
1561  );
1562 
1563 VOID
1564 NTAPI
1566  IN struct _HW_CHANNEL* chan
1567  );
1568 
1569 ULONG
1570 NTAPI
1572  OUT PWCHAR Buffer,
1573  IN PUCHAR Str,
1574  IN ULONG Length
1575  );
1576 
1577 ULONGLONG
1578 NTAPI
1580  struct _HW_LU_EXTENSION* LunExt,
1581  ULONGLONG lba
1582  );
1583 
1584 ULONG
1585 NTAPI
1587  IN PVOID HwDeviceExtension,
1588  IN ULONG Channel,
1589  IN ULONG deviceNumber
1590  );
1591 
1592 #endif //USER_MODE
1593 
1594 #define ATA_AT_HOME_HDD 0x01
1595 #define ATA_AT_HOME_ATAPI 0x02
1596 #define ATA_AT_HOME_XXX 0x04
1597 #define ATA_AT_HOME_NOBODY 0x00
1598 
1599 #define ATA_CMD_FLAG_LBAIOsupp 0x01
1600 #define ATA_CMD_FLAG_48supp 0x02
1601 #define ATA_CMD_FLAG_48 0x04
1602 #define ATA_CMD_FLAG_DMA 0x08
1603 #define ATA_CMD_FLAG_FUA 0x10
1604 #define ATA_CMD_FLAG_In 0x40
1605 #define ATA_CMD_FLAG_Out 0x80
1606 
1607 /*
1608  We need LBA48 when requested LBA or BlockCount are too large.
1609  But for LBA-based commands we have *special* limitation
1610 */
1611 #define UniAta_need_lba48(command, lba, count, supp48) \
1612  ( ((AtaCommandFlags[command] & ATA_CMD_FLAG_LBAIOsupp) && (supp48) && (((lba+count) >= ATA_MAX_IOLBA28) || (count > 256)) ) || \
1613  (lba > ATA_MAX_LBA28) || (count > 255) )
1614 
1615 #ifndef USER_MODE
1616 
1617 #define UniAtaClearAtaReq(AtaReq) \
1618 { \
1619  RtlZeroMemory((PCHAR)(AtaReq), FIELD_OFFSET(ATA_REQ, ata)); \
1620 }
1621 
1622 extern UCHAR const AtaCommands48[256];
1623 extern UCHAR const AtaCommandFlags[256];
1624 
1625 //#define ATAPI_DEVICE(de, ldev) (de->lun[ldev].DeviceFlags & DFLAGS_ATAPI_DEVICE)
1626 #define ATAPI_DEVICE(chan, dev) ((chan->lun[dev]->DeviceFlags & DFLAGS_ATAPI_DEVICE) ? TRUE : FALSE)
1627 
1628 #ifdef _DEBUG
1629 #define PrintNtConsole _PrintNtConsole
1630 #else //_DEBUG
1631 #define PrintNtConsole(x) {;}
1632 #endif //_DEBUG
1633 
1634 #endif //USER_MODE
1635 
1636 __inline
1637 BOOLEAN
1640  )
1641 {
1642  return (ident->SataCapabilities && ident->SataCapabilities != 0xffff);
1643 } // end ata_is_sata()
1644 
1645 #define IDENT_MODE_MAX FALSE
1646 #define IDENT_MODE_ACTIVE TRUE
1647 
1648 __inline
1649 LONG
1652  BOOLEAN Active
1653  )
1654 {
1655  USHORT mode;
1656  if(ata_is_sata(ident)) {
1657  if(ident->SataCapabilities & ATA_SATA_GEN3) {
1658  return ATA_SA600;
1659  } else
1660  if(ident->SataCapabilities & ATA_SATA_GEN2) {
1661  return ATA_SA300;
1662  } else
1663  if(ident->SataCapabilities & ATA_SATA_GEN1) {
1664  return ATA_SA150;
1665  }
1666  return ATA_SA150;
1667  }
1668 
1669  if (ident->UdmaModesValid) {
1670  mode = Active ? ident->UltraDMAActive : ident->UltraDMASupport;
1671  if (mode & 0x40)
1672  return ATA_UDMA0+6;
1673  if (mode & 0x20)
1674  return ATA_UDMA0+5;
1675  if (mode & 0x10)
1676  return ATA_UDMA0+4;
1677  if (mode & 0x08)
1678  return ATA_UDMA0+3;
1679  if (mode & 0x04)
1680  return ATA_UDMA0+2;
1681  if (mode & 0x02)
1682  return ATA_UDMA0+1;
1683  if (mode & 0x01)
1684  return ATA_UDMA0+0;
1685  }
1686 
1687  mode = Active ? ident->MultiWordDMAActive : ident->MultiWordDMASupport;
1688  if (ident->MultiWordDMAActive & 0x04)
1689  return ATA_WDMA0+2;
1690  if (ident->MultiWordDMAActive & 0x02)
1691  return ATA_WDMA0+1;
1692  if (ident->MultiWordDMAActive & 0x01)
1693  return ATA_WDMA0+0;
1694 
1695  mode = Active ? ident->SingleWordDMAActive : ident->SingleWordDMASupport;
1696  if (ident->SingleWordDMAActive & 0x04)
1697  return ATA_SDMA0+2;
1698  if (ident->SingleWordDMAActive & 0x02)
1699  return ATA_SDMA0+1;
1700  if (ident->SingleWordDMAActive & 0x01)
1701  return ATA_SDMA0+0;
1702 
1703  if (ident->PioTimingsValid) {
1704  mode = ident->AdvancedPIOModes;
1705  if (mode & AdvancedPIOModes_5)
1706  return ATA_PIO0+5;
1707  if (mode & AdvancedPIOModes_4)
1708  return ATA_PIO0+4;
1709  if (mode & AdvancedPIOModes_3)
1710  return ATA_PIO0+3;
1711  }
1712  mode = ident->PioCycleTimingMode;
1713  if (ident->PioCycleTimingMode == 2)
1714  return ATA_PIO0+2;
1715  if (ident->PioCycleTimingMode == 1)
1716  return ATA_PIO0+1;
1717  if (ident->PioCycleTimingMode == 0)
1718  return ATA_PIO0+0;
1719 
1720  return ATA_PIO;
1721 } // end ata_cur_mode_from_ident()
1722 
1723 #pragma pack(pop)
1724 
1725 #endif // __GLOBAL_H__
USHORT BufferSectorSize
Definition: atapi.h:203
struct _MODE_PARAMETER_HEADER_10 * PMODE_PARAMETER_HEADER_10
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
USHORT ReleaseTimeOverlapped
Definition: atapi.h:235
signed char * PCHAR
Definition: retypes.h:7
USHORT DataSetManagementSupported
Definition: atapi.h:903
INTERNETFEATURELIST feature
Definition: misc.c:1689
UCHAR Reserved2[4]
Definition: atapi.h:74
#define ATA_PIO0
Definition: atapi.h:309
USHORT Reserved1
Definition: atapi.h:195
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
uint32_t sector
Definition: isohybrid.c:61
USHORT SupportDma
Definition: atapi.h:656
ULONG NTAPI AtapiParseArgumentString(IN PCCH String, IN PCCH KeyWord)
Definition: id_ata.cpp:3659
VOID UniataExpectChannelInterrupt(IN struct _HW_CHANNEL *chan, IN BOOLEAN Expecting)
Definition: id_ata.cpp:4446
struct _ATAPI_REGISTERS_1::_o o
USHORT WriteReadVerify_CurrentMode
Definition: atapi.h:942
UCHAR ParameterListLengthLsb
Definition: atapi.h:87
__inline LONG ata_cur_mode_from_ident(PIDENTIFY_DATA ident, BOOLEAN Active)
Definition: atapi.h:1650
USHORT UltraDMAActive
Definition: atapi.h:832
USHORT StreamAccessLatency
Definition: atapi.h:852
USHORT APM
Definition: atapi.h:806
UCHAR DDKFASTAPI UniataIsIdle(IN struct _HW_DEVICE_EXTENSION *deviceExtension, IN UCHAR Status)
Definition: id_ata.cpp:696
UCHAR DDKFASTAPI WaitForDrq(IN struct _HW_CHANNEL *chan)
USHORT Address48
Definition: atapi.h:813
UCHAR CylinderHigh
Definition: atapi.h:184
USHORT SCT_DataTables
Definition: atapi.h:916
VOID NTAPI IdeMediaStatus(BOOLEAN EnableMSN, IN PVOID HwDeviceExtension, IN ULONG lChannel, IN ULONG DeviceNumber)
Definition: id_ata.cpp:9018
#define ATA_PIO
Definition: atapi.h:306
struct _IDE_REGISTERS_1::_o o
USHORT HwResCableId
Definition: atapi.h:842
USHORT UdmaModesValid
Definition: atapi.h:689
struct _MODE_SELECT_10 * PMODE_SELECT_10
#define __cdecl
Definition: accygwin.h:79
UCHAR Vendor52
Definition: atapi.h:684
USHORT BufferType
Definition: atapi.h:202
USHORT StreamMinReqSize
Definition: atapi.h:850
UCHAR NTAPI AtaCommand48(IN struct _HW_DEVICE_EXTENSION *deviceExtension, IN ULONG DeviceNumber, IN ULONG Channel, IN UCHAR command, IN ULONGLONG lba, IN USHORT count, IN USHORT feature, IN ULONG flags)
UCHAR NTAPI AtapiCheckInterrupt__(IN PVOID HwDeviceExtension, IN UCHAR c)
Definition: id_ata.cpp:4466
USHORT NVCache_Version
Definition: atapi.h:934
ULONG NTAPI UniataAnybodyHome(IN PVOID HwDeviceExtension, IN ULONG Channel, IN ULONG deviceNumber)
Definition: id_probe.cpp:2762
UCHAR Control
Definition: atapi.h:219
USHORT MinimumPIOCycleTimeIORDY
Definition: atapi.h:233
struct outqueuenode * head
Definition: adnsresfilter.c:66
USHORT MicrocodeDownloadDMA
Definition: atapi.h:740
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1117
UCHAR Reserved3[5]
Definition: atapi.h:85
LONG NTAPI AtaWmode(PIDENTIFY_DATA2 ident)
Definition: id_ata.cpp:1195
USHORT ATA_ATAPI7
Definition: atapi.h:953
USHORT BlockEraseExtSupported
Definition: atapi.h:703
USHORT SupportZero
Definition: atapi.h:818
USHORT ReadBufferDMA
Definition: atapi.h:743
USHORT FlushCache
Definition: atapi.h:815
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1117
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define SCSIPORT_API
Definition: scsi_port.h:177
unsigned char * PUCHAR
Definition: retypes.h:3
USHORT Reserved4
Definition: atapi.h:229
USHORT CryptoScrambleExtSupported
Definition: atapi.h:701
VOID NTAPI ResetBus(IN PDEVICE_OBJECT Fdo)
Definition: disk.c:4162
USHORT Reserver_84_6
Definition: atapi.h:826
UCHAR CylinderHigh
Definition: atapi.h:173
GLUquadricObj * cylinder
Definition: cylfrac.c:44
USHORT ExtendedZero
Definition: atapi.h:828
USHORT v30
Definition: atapi.h:962
struct _IDENTIFY_DATA::@1008 FeaturesSupport
USHORT Reserved209_14_One
Definition: atapi.h:922
USHORT MaxPwdDMA
Definition: atapi.h:741
USHORT SupportLba
Definition: atapi.h:657
USHORT MediaSerial[30]
Definition: atapi.h:907
USHORT QueueLength
Definition: atapi.h:754
ULONGLONG NTAPI UniAtaCalculateLBARegsBack(struct _HW_LU_EXTENSION *LunExt, ULONGLONG lba)
USHORT DeviceNominalFormFactor
Definition: atapi.h:901
USHORT Queued
Definition: atapi.h:804
UCHAR DeviceType
Definition: atapi.h:621
#define ATA_UDMA0
Definition: atapi.h:328
USHORT MultiWordDMAActive
Definition: atapi.h:227
UCHAR DDKFASTAPI SelectDrive(IN struct _HW_CHANNEL *chan, IN ULONG DeviceNumber)
UCHAR DDKFASTAPI WaitOnBusy(IN struct _HW_CHANNEL *chan)
#define ATA_SA600
Definition: atapi.h:339
USHORT Reserved69_7_IEEE1667
Definition: atapi.h:739
USHORT StandbyOverlap
Definition: atapi.h:661
struct _IDE_REGISTERS_2 * PIDE_REGISTERS_2
#define ATA_SATA_GEN2
Definition: atapi.h:759
VOID NTAPI UniataInitSyncBaseIO(IN struct _HW_CHANNEL *chan)
#define ATA_SA300
Definition: atapi.h:338
USHORT MinorRevision
Definition: atapi.h:238
struct _IDENTIFY_DATA IDENTIFY_DATA
struct _IDENTIFY_DATA::@1016::@1030 SATA
static WCHAR String[]
Definition: stringtable.c:55
USHORT PLSS_Reserved
Definition: atapi.h:863
ULONG NTAPI AtapiReadArgumentString(IN PVOID HwDeviceExtension, IN PVOID Context, IN PVOID BusInformation, IN PCHAR ArgumentString, IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, OUT PBOOLEAN Again)
Definition: id_probe.cpp:2738
USHORT Spinup
Definition: atapi.h:809
uint16_t * PWCHAR
Definition: typedefs.h:54
Definition: shell.h:41
USHORT HwResSlave
Definition: atapi.h:841
BOOLEAN NTAPI FindDevices(IN PVOID HwDeviceExtension, IN ULONG Flags, IN ULONG Channel)
Definition: id_probe.cpp:3168
USHORT SingleWordDMASupport
Definition: atapi.h:224
USHORT SupportQTag
Definition: atapi.h:662
USHORT Reserved126
Definition: atapi.h:880
VOID _cdecl _PrintNtConsole(PCCH DebugMessage,...)
Definition: id_ata.cpp:11550
USHORT MinimumMWXferCycleTime
Definition: atapi.h:230
USHORT HwResValid
Definition: atapi.h:843
USHORT Reserved224[10]
Definition: atapi.h:969
USHORT DMADirRequired
Definition: atapi.h:717
USHORT Notify
Definition: atapi.h:807
USHORT v26
Definition: atapi.h:961
#define lba
struct _IDENTIFY_DATA::@1006::@1021 AtapiDMA
USHORT PLSS_Signature
Definition: atapi.h:866
UCHAR Removable
Definition: atapi.h:619
struct _IDENTIFY_DATA::@1012::@1024 SecurityStatusOpt
struct _ATAPI_REGISTERS_1::_i i
USHORT SataCapabilities
Definition: atapi.h:757
BOOLEAN NTAPI AtapiHwInitialize(IN PVOID HwDeviceExtension)
Definition: atapi.c:1282
USHORT SingleWordDMAActive
Definition: atapi.h:225
UCHAR const AtaCommands48[256]
Definition: atacmd_map.h:5
USHORT Enabled
Definition: atapi.h:887
USHORT ExtendedOne
Definition: atapi.h:827
ULONG UserAddressableSectors
Definition: atapi.h:223
USHORT DeviceStandbyMin
Definition: atapi.h:675
IN PFCB IN PCCB IN TYPE_OF_OPEN IN BOOLEAN IN BOOLEAN TopLevel
Definition: fatprocs.h:2401
USHORT MasterPasswdCap
Definition: atapi.h:893
USHORT Reserved62_0
Definition: atapi.h:655
VOID UniataInitIoResEx(IN struct _IORES *IoRes, IN ULONG addr, IN BOOLEAN MemIo, IN BOOLEAN Proc)
USHORT Frozen
Definition: atapi.h:889
USHORT LongSectorErrorReporting
Definition: atapi.h:745
USHORT ServiceDRQ
Definition: atapi.h:794
USHORT WriteBufferDMA
Definition: atapi.h:742
USHORT ReleaseTimeServiceCommand
Definition: atapi.h:236
USHORT Reserver_83_7
Definition: atapi.h:810
UCHAR ParameterListLengthMsb
Definition: atapi.h:75
USHORT FlushCache48
Definition: atapi.h:816
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
struct _MODE_SENSE_10 MODE_SENSE_10
VOID DDKFASTAPI AtapiSoftReset(IN struct _HW_CHANNEL *chan, IN ULONG DeviceNumber)
USHORT StreamTransferTime
Definition: atapi.h:851
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
__inline BOOLEAN ata_is_sata(PIDENTIFY_DATA ident)
Definition: atapi.h:1638
USHORT CurrentMultiSectorValid
Definition: atapi.h:698
USHORT DisableIordy
Definition: atapi.h:658
VOID NTAPI UniataDumpATARegs(IN struct _HW_CHANNEL *chan)
ULONGLONG BlockCount
Definition: atapi.h:1045
USHORT Microcode
Definition: atapi.h:803
USHORT PhysLogSectorSize
Definition: atapi.h:860
USHORT Protected
Definition: atapi.h:796
long LONG
Definition: pedump.c:60
UCHAR PioCycleTimingMode
Definition: atapi.h:213
UCHAR PFBit
Definition: atapi.h:83
USHORT CurrentMultiSector
Definition: atapi.h:697
USHORT NVCache_DeviceSpinUpTime
Definition: atapi.h:939
USHORT Reserved161[7]
Definition: atapi.h:900
USHORT NVCache_PM_Version
Definition: atapi.h:933
USHORT Reserved75_6
Definition: atapi.h:755
USHORT Nop
Definition: atapi.h:800
USHORT Reserved169_1_15
Definition: atapi.h:904
#define AdvancedPIOModes_3
Definition: atapi.h:727
USHORT SupportIDma
Definition: atapi.h:663
unsigned int idx
Definition: utils.c:41
USHORT TranslationFieldsValid
Definition: atapi.h:216
USHORT Reserved218
Definition: atapi.h:938
VOID __cdecl ScsiDebugPrint(IN ULONG DebugPrintLevel, IN PCCHAR DebugMessage, IN ...)
Definition: scsiport.c:462
USHORT RemovableStatus
Definition: atapi.h:882
ULONG g_LogToDisplay
USHORT FirmwareRevision[4]
Definition: atapi.h:205
USHORT Reserved50_1
Definition: atapi.h:676
USHORT AdvancedPIOModes
Definition: atapi.h:228
USHORT SanitizeSupported
Definition: atapi.h:700
UCHAR DrqType
Definition: atapi.h:615
unsigned char BOOLEAN
USHORT NumberOfCurrentHeads
Definition: atapi.h:219
USHORT Reserved_82_11
Definition: atapi.h:797
VOID NTAPI AtapiHexToString(ULONG Value, PCHAR *Buffer)
USHORT Flags
Definition: atapi.h:965
LONG NTAPI AtaUmode(PIDENTIFY_DATA2 ident)
Definition: id_ata.cpp:1208
USHORT SmartSelfTest
Definition: atapi.h:821
#define ATA_SATA_GEN3
Definition: atapi.h:760
UCHAR Reserved2
Definition: atapi.h:84
USHORT Standby
Definition: atapi.h:808
PSCSI_REQUEST_BLOCK NTAPI BuildMechanismStatusSrb(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: id_ata.cpp:11068
USHORT Reserved59_9_11
Definition: atapi.h:699
BOOLEAN NTAPI SetDriveParameters(IN PVOID HwDeviceExtension, IN ULONG DeviceNumber, IN ULONG Channel)
Definition: atapi.c:636
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
ULONG NTAPI IdeSendCommand(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, IN ULONG CmdAction)
Definition: id_ata.cpp:8186
Definition: bufpool.h:45
USHORT WriteBuffer
Definition: atapi.h:798
VOID UniataInitIoRes(IN struct _HW_CHANNEL *chan, IN ULONG idx, IN ULONG addr, IN BOOLEAN MemIo, IN BOOLEAN Proc)
USHORT ChecksumValid
Definition: atapi.h:980
UCHAR Reserved4[3]
Definition: atapi.h:88
#define ATA_SA150
Definition: atapi.h:337
Definition: sacdrv.h:287
ULONGLONG UserAddressableSectors48
Definition: atapi.h:855
LONG NTAPI AtaPioMode(PIDENTIFY_DATA2 ident)
Definition: id_ata.cpp:1174
UCHAR PageCode
Definition: atapi.h:72
UCHAR DmaCycleTimingMode
Definition: atapi.h:215
USHORT CurrentSectorsPerTrack
Definition: atapi.h:220
USHORT LogicalSectorOffset
Definition: atapi.h:921
UCHAR VendorUnique2
Definition: atapi.h:208
USHORT MediaSerialNo
Definition: atapi.h:822
#define DDKFASTAPI
Definition: config.h:144
struct _IDENTIFY_DATA * PIDENTIFY_DATA
USHORT CurrentAcoustic
Definition: atapi.h:847
PSCSI_REQUEST_BLOCK NTAPI BuildRequestSenseSrb(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: id_ata.cpp:11112
_In_ ULONG _In_ ULONG_PTR ident
Definition: winddi.h:3993
UCHAR DDKFASTAPI WaitOnBaseBusyLong(IN struct _HW_CHANNEL *chan)
USHORT Packet
Definition: atapi.h:790
USHORT Reserved174[2]
Definition: atapi.h:906
USHORT NominalMediaRotationRate
Definition: atapi.h:937
USHORT HwResMaster
Definition: atapi.h:840
#define AdvancedPIOModes_5
Definition: atapi.h:729
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
USHORT SoftReset
Definition: atapi.h:660
USHORT Reserved_CE_ATA[2]
Definition: atapi.h:920
USHORT TransportMinor
Definition: atapi.h:967
USHORT Reserved129[31]
Definition: atapi.h:898
CONST CHAR * PCCH
Definition: ntbasedef.h:399
USHORT SCT_Supported
Definition: atapi.h:911
USHORT CfAdvPowerMode
Definition: atapi.h:899
_In_ LARGE_INTEGER _In_opt_ PKDPC Dpc
Definition: kefuncs.h:524
USHORT NVCache_Size_LogicalBlocks[2]
Definition: atapi.h:936
ULONG NTAPI AtapiRegCheckDevValue(IN PVOID HwDeviceExtension, IN ULONG chan, IN ULONG dev, IN PCWSTR Name, IN ULONG Default)
Definition: id_ata.cpp:11226
VOID NTAPI AtapiDisableInterrupts(IN PVOID HwDeviceExtension, IN ULONG c)
Definition: id_ata.cpp:4411
USHORT EraseTime
Definition: atapi.h:834
#define AdvancedPIOModes_4
Definition: atapi.h:728
USHORT NVCache_PM_Enabled
Definition: atapi.h:929
struct _TRIM_DATA * PTRIM_DATA
USHORT MultiWordDMASupport
Definition: atapi.h:226
USHORT SerialNumber[10]
Definition: atapi.h:201
USHORT Smart
Definition: atapi.h:786
uint64_t ULONGLONG
Definition: typedefs.h:65
USHORT Reserved
Definition: atapi.h:876
ULONG NTAPI IdeBuildSenseBuffer(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: atapi.c:5737
ULONG StreamGranularity
Definition: atapi.h:853
USHORT DoubleWordIo
Definition: atapi.h:209
USHORT SataEnable
Definition: atapi.h:775
USHORT Reserved168_4_15
Definition: atapi.h:902
UCHAR Vendor51
Definition: atapi.h:681
USHORT ReadBuffer
Definition: atapi.h:799
BOOLEAN NTAPI AtapiStartIo(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: atapi.c:5811
UCHAR ParameterListLengthLsb
Definition: atapi.h:76
USHORT Reserved70
Definition: atapi.h:749
const GLubyte * c
Definition: glext.h:8905
ULONGLONG Lba
Definition: atapi.h:1044
USHORT Reserved7_8
Definition: atapi.h:892
USHORT SCT_WriteSame
Definition: atapi.h:913
USHORT EnhancedEraseSupport
Definition: atapi.h:891
VOID NTAPI UniataInitMapBase(IN struct _HW_CHANNEL *chan, IN PIDE_REGISTERS_1 BaseIoAddress1, IN PIDE_REGISTERS_2 BaseIoAddress2)
USHORT SCT
Definition: atapi.h:909
UCHAR OperationCode
Definition: atapi.h:81
struct _IDENTIFY_DATA::@1011 CommandFeatureSetSupport
USHORT UDMASupport
Definition: atapi.h:713
USHORT MinBlocks_MicrocodeDownload_Mode3
Definition: atapi.h:971
UCHAR Reserved1
Definition: atapi.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
USHORT WriteReadVerify_CountMode2[2]
Definition: atapi.h:925
USHORT SCT_ErrorRecovery
Definition: atapi.h:914
USHORT Reserved_82_15
Definition: atapi.h:801
GLbitfield flags
Definition: glext.h:7161
USHORT ATA8_AST
Definition: atapi.h:957
USHORT SecurityStatus
Definition: atapi.h:884
UCHAR const AtaCommandFlags[256]
Definition: atacmd_map.h:25
USHORT v10a
Definition: atapi.h:958
ULONG LargeSectorSize
Definition: atapi.h:873
LONG NTAPI AtaPio2Mode(LONG pio)
Definition: id_ata.cpp:1159
USHORT MajorRevision
Definition: atapi.h:237
struct _IDENTIFY_DATA::@1011 CommandFeatureSetEnabled
unsigned char UCHAR
Definition: xmlstorage.h:181
char * PBOOLEAN
Definition: retypes.h:11
USHORT AutoAcoustic
Definition: atapi.h:812
USHORT DevConfigDMA
Definition: atapi.h:744
VOID DDKFASTAPI AtapiHardReset(IN struct _HW_CHANNEL *chan, IN BOOLEAN DisableInterrupts, IN ULONG Delay)
Definition: id_ata.cpp:902
USHORT PLSS_LargeP
Definition: atapi.h:865
GLenum const GLvoid * addr
Definition: glext.h:9621
USHORT Locked
Definition: atapi.h:888
struct _ATAPI_REGISTERS_1 ATAPI_REGISTERS_1
USHORT MaxBlocks_MicrocodeDownload_Mode3
Definition: atapi.h:972
UCHAR ParameterListLengthMsb
Definition: atapi.h:86
Definition: ketypes.h:687
USHORT Removable
Definition: atapi.h:788
struct _MODE_PARAMETER_HEADER_10 MODE_PARAMETER_HEADER_10
#define ATA_WDMA0
Definition: atapi.h:323
ULONG CurrentSectorCapacity
Definition: atapi.h:221
UCHAR Reserved1
Definition: atapi.h:71
USHORT SupportOne
Definition: atapi.h:817
struct _TRIM_DATA TRIM_DATA
USHORT ATA8_APT
Definition: atapi.h:952
USHORT PLSS_Size
Definition: atapi.h:862
USHORT SataSupport
Definition: atapi.h:769
UCHAR MaximumBlockTransfer
Definition: atapi.h:207
ULONG NTAPI EncodeVendorStr(OUT PWCHAR Buffer, IN PUCHAR Str, IN ULONG Length)
Definition: id_ata.cpp:11186
UCHAR AtapiCmdSize
Definition: atapi.h:611
UCHAR AltStatus
Definition: atapi.h:218
GLenum mode
Definition: glext.h:6217
struct _MODE_SELECT_10 MODE_SELECT_10
BOOLEAN NTAPI IssueIdentify(IN PVOID HwDeviceExtension, IN ULONG DeviceNumber, IN ULONG Channel, IN UCHAR Command, IN BOOLEAN NoSetup)
Definition: id_ata.cpp:1483
struct _IDE_REGISTERS_2 IDE_REGISTERS_2
USHORT Reserved_6_15
Definition: atapi.h:917
USHORT RecommendedMWXferCycleTime
Definition: atapi.h:231
USHORT Logging
Definition: atapi.h:825
USHORT Integrity
Definition: atapi.h:977
VOID NTAPI AtapiEnableInterrupts(IN PVOID HwDeviceExtension, IN ULONG c)
Definition: id_ata.cpp:4351
USHORT Reserved9_15
Definition: atapi.h:894
USHORT Reserved236[19]
Definition: atapi.h:974
USHORT NVCache_Enabled
Definition: atapi.h:931
USHORT NVCache_Reserved_2_3
Definition: atapi.h:930
Status
Definition: gdiplustypes.h:24
BOOLEAN NTAPI AtapiInterrupt__(IN PVOID HwDeviceExtension, IN UCHAR c)
Definition: id_ata.cpp:4935
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
USHORT Streaming
Definition: atapi.h:824
USHORT PLSS_LargeL
Definition: atapi.h:864
USHORT CurentAPMLevel
Definition: atapi.h:836
USHORT Lba28Support
Definition: atapi.h:738
UCHAR DDKFASTAPI WaitOnBaseBusy(IN struct _HW_CHANNEL *chan)
USHORT PowerMngt
Definition: atapi.h:789
USHORT Reserved112[5]
Definition: atapi.h:871
struct _MODE_SENSE_10 * PMODE_SENSE_10
USHORT MaxSecurity
Definition: atapi.h:811
BOOLEAN NTAPI AtapiResetController(IN PVOID HwDeviceExtension, IN ULONG PathId)
Definition: atapi.c:733
USHORT Reset
Definition: atapi.h:795
struct _ATAPI_REGISTERS_1 * PATAPI_REGISTERS_1
USHORT StreamingTransferTimePIO
Definition: atapi.h:857
ULONG NTAPI AtapiSendCommand(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, IN ULONG CmdAction)
Definition: id_ata.cpp:7330
USHORT SCT_Feature
Definition: atapi.h:915
USHORT ReadZeroAfterTrim
Definition: atapi.h:737
USHORT NVCache_Reserved_5_7
Definition: atapi.h:932
USHORT VendorUnique1[3]
Definition: atapi.h:200
USHORT SectorsPerTrack
Definition: atapi.h:199
USHORT WriteCache
Definition: atapi.h:791
USHORT Reserved3
Definition: atapi.h:217
unsigned short USHORT
Definition: pedump.c:61
USHORT LookAhead
Definition: atapi.h:792
USHORT EnhancedEraseTime
Definition: atapi.h:835
USHORT Reserved121[4]
Definition: atapi.h:878
UCHAR DDKFASTAPI WaitShortForDrq(IN struct _HW_CHANNEL *chan)
USHORT ModelNumber[20]
Definition: atapi.h:206
USHORT InterSeekDelay
Definition: atapi.h:869
USHORT Checksum
Definition: atapi.h:981
UCHAR Reserved3[3]
Definition: atapi.h:77
USHORT ReleaseDRQ
Definition: atapi.h:793
USHORT MasterPasswdRevision
Definition: atapi.h:838
USHORT v25
Definition: atapi.h:960
struct _IDENTIFY_DATA::@1016::@1029 PATA
USHORT DeviceCapability1
Definition: atapi.h:677
USHORT NumberOfEccBytes
Definition: atapi.h:204
USHORT UnformattedBytesPerSector
Definition: atapi.h:198
USHORT AdditionalProdNum[4]
Definition: atapi.h:905
struct _IDENTIFY_DATA::@1008 FeaturesEnabled
USHORT NVCache_Reserved219_8_15
Definition: atapi.h:940
ULONG NTAPI CheckDevice(IN PVOID HwDeviceExtension, IN ULONG Channel, IN ULONG deviceNumber, IN BOOLEAN ResetBus)
Definition: id_probe.cpp:2881
struct _IDE_REGISTERS_1 IDE_REGISTERS_1
USHORT Security
Definition: atapi.h:787
USHORT NumberOfCylinders
Definition: atapi.h:194
ULONG NTAPI AtapiFindIsaController(IN PVOID HwDeviceExtension, IN PVOID Context, IN PVOID BusInformation, IN PCHAR ArgumentString, IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, OUT PBOOLEAN Again)
Definition: id_probe.cpp:2227
USHORT Reserved221
Definition: atapi.h:945
USHORT VendorAcoustic
Definition: atapi.h:848
USHORT CFastSupport
Definition: atapi.h:747
USHORT NumberOfHeads
Definition: atapi.h:196
USHORT PioTimingsValid
Definition: atapi.h:688
USHORT MinimumPIOCycleTime
Definition: atapi.h:232
struct _IDE_REGISTERS_1::_i i
#define OUT
Definition: typedefs.h:39
#define ATA_SDMA0
Definition: atapi.h:318
VOID NTAPI UniataInitMapBM(IN struct _HW_DEVICE_EXTENSION *deviceExtension, IN struct _IDE_BUSMASTER_REGISTERS *BaseIoAddressBM_0, IN BOOLEAN MemIo)
unsigned int ULONG
Definition: retypes.h:1
UCHAR CmdProtocol
Definition: atapi.h:627
#define ATA_SATA_GEN1
Definition: atapi.h:758
USHORT CFA
Definition: atapi.h:805
UCHAR NTAPI AtaCommand(IN struct _HW_DEVICE_EXTENSION *deviceExtension, IN ULONG DeviceNumber, IN ULONG Channel, IN UCHAR command, IN USHORT cylinder, IN UCHAR head, IN UCHAR sector, IN UCHAR count, IN UCHAR feature, IN ULONG flags)
USHORT MaxLBARangeDescBlockCount
Definition: atapi.h:858
USHORT SupportIordy
Definition: atapi.h:659
USHORT UnformattedBytesPerTrack
Definition: atapi.h:197
USHORT Reseved62_11_14
Definition: atapi.h:716
BOOLEAN NTAPI AtapiInterrupt(IN PVOID HwDeviceExtension)
Definition: atapi.c:3484
union _IDENTIFY_DATA::@1016 TransportMajor
VOID NTAPI AtapiHwInitializeChanger(IN PVOID HwDeviceExtension, IN ULONG TargetId, IN PMECHANICAL_STATUS_INFORMATION_HEADER MechanismStatus)
Definition: atapi.c:1469
USHORT Support
Definition: atapi.h:886
USHORT NumberOfCurrentCylinders
Definition: atapi.h:218
USHORT DMASupport
Definition: atapi.h:715
USHORT WriteReadVerify_CountMode3[2]
Definition: atapi.h:926
USHORT Reserved209_15_Zero
Definition: atapi.h:923
USHORT MediaCardPass
Definition: atapi.h:823
USHORT Reserved73_74[2]
Definition: atapi.h:752
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1036
VOID NTAPI AtapiDpcDispatch(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
USHORT Reserved77
Definition: atapi.h:767
USHORT DeviceCapability0
Definition: atapi.h:678
UCHAR Pc
Definition: atapi.h:73
USHORT TransportType
Definition: atapi.h:949
USHORT ConfigOverlay
Definition: atapi.h:814
USHORT CountExpired
Definition: atapi.h:890
USHORT SmartErrorLog
Definition: atapi.h:820
ULONG NTAPI AtapiRegCheckParameterValue(IN PVOID HwDeviceExtension, IN PCWSTR PathSuffix, IN PCWSTR Name, IN ULONG Default)
Definition: id_ata.cpp:11370
USHORT UltraDMASupport
Definition: atapi.h:831
USHORT NVCache_PM_Supported
Definition: atapi.h:928
USHORT OverwriteExtSupported
Definition: atapi.h:702
USHORT WriteReadVerify_Reserved220_8_15
Definition: atapi.h:943
UCHAR DDKFASTAPI WaitOnBusyLong(IN struct _HW_CHANNEL *chan)
USHORT AtapiByteCount0
Definition: atapi.h:879
USHORT Reserved69_0_4
Definition: atapi.h:736
USHORT WorldWideName[4]
Definition: atapi.h:870
struct _IDE_REGISTERS_1 * PIDE_REGISTERS_1
UCHAR OperationCode
Definition: atapi.h:70
USHORT VersionFlags
Definition: atapi.h:948
BOOLEAN NTAPI AtapiStartIo__(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, IN BOOLEAN TopLevel)
Definition: id_ata.cpp:9237
USHORT DeterministicReadAfterTrim
Definition: atapi.h:746
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:675
USHORT II_Ext
Definition: atapi.h:959