ReactOS  0.4.15-dev-4857-g47842d7
storahci.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GNU GPLv2 only as published by the Free Software Foundation
4  * PURPOSE: To Implement AHCI Miniport driver targeting storport NT 5.2
5  * PROGRAMMERS: Aman Priyadarshi (aman.eureka@gmail.com)
6  */
7 
8 #include <ntddk.h>
9 #include <ata.h>
10 #include <storport.h>
11 
12 #define NDEBUG
13 #include <debug.h>
14 
15 #define DEBUG 1
16 #if defined(_MSC_VER)
17 #pragma warning(disable:4214) // bit field types other than int
18 #pragma warning(disable:4201) // nameless struct/union
19 #endif
20 
21 #define MAXIMUM_AHCI_PORT_COUNT 32
22 #define MAXIMUM_AHCI_PRDT_ENTRIES 32
23 #define MAXIMUM_AHCI_PORT_NCS 30
24 #define MAXIMUM_QUEUE_BUFFER_SIZE 255
25 #define MAXIMUM_TRANSFER_LENGTH (128*1024) // 128 KB
26 
27 #define DEVICE_ATA_BLOCK_SIZE 512
28 
29 // device type (DeviceParams)
30 #define AHCI_DEVICE_TYPE_ATA 1
31 #define AHCI_DEVICE_TYPE_ATAPI 2
32 #define AHCI_DEVICE_TYPE_NODEVICE 3
33 
34 // section 3.1.2
35 #define AHCI_Global_HBA_CAP_S64A (1 << 31)
36 
37 // FIS Types : http://wiki.osdev.org/AHCI
38 #define FIS_TYPE_REG_H2D 0x27 // Register FIS - host to device
39 #define FIS_TYPE_REG_D2H 0x34 // Register FIS - device to host
40 #define FIS_TYPE_DMA_ACT 0x39 // DMA activate FIS - device to host
41 #define FIS_TYPE_DMA_SETUP 0x41 // DMA setup FIS - bidirectional
42 #define FIS_TYPE_BIST 0x58 // BIST activate FIS - bidirectional
43 #define FIS_TYPE_PIO_SETUP 0x5F // PIO setup FIS - device to host
44 #define FIS_TYPE_DEV_BITS 0xA1 // Set device bits FIS - device to host
45 
46 #define AHCI_ATA_CFIS_FisType 0
47 #define AHCI_ATA_CFIS_PMPort_C 1
48 #define AHCI_ATA_CFIS_CommandReg 2
49 #define AHCI_ATA_CFIS_FeaturesLow 3
50 #define AHCI_ATA_CFIS_LBA0 4
51 #define AHCI_ATA_CFIS_LBA1 5
52 #define AHCI_ATA_CFIS_LBA2 6
53 #define AHCI_ATA_CFIS_Device 7
54 #define AHCI_ATA_CFIS_LBA3 8
55 #define AHCI_ATA_CFIS_LBA4 9
56 #define AHCI_ATA_CFIS_LBA5 10
57 #define AHCI_ATA_CFIS_FeaturesHigh 11
58 #define AHCI_ATA_CFIS_SectorCountLow 12
59 #define AHCI_ATA_CFIS_SectorCountHigh 13
60 
61 // ATA Functions
62 #define ATA_FUNCTION_ATA_COMMAND 0x100
63 #define ATA_FUNCTION_ATA_IDENTIFY 0x101
64 #define ATA_FUNCTION_ATA_READ 0x102
65 
66 // ATAPI Functions
67 #define ATA_FUNCTION_ATAPI_COMMAND 0x200
68 
69 // ATA Flags
70 #define ATA_FLAGS_DATA_IN (1 << 1)
71 #define ATA_FLAGS_DATA_OUT (1 << 2)
72 #define ATA_FLAGS_48BIT_COMMAND (1 << 3)
73 #define ATA_FLAGS_USE_DMA (1 << 4)
74 
75 #define IsAtaCommand(AtaFunction) (AtaFunction & ATA_FUNCTION_ATA_COMMAND)
76 #define IsAtapiCommand(AtaFunction) (AtaFunction & ATA_FUNCTION_ATAPI_COMMAND)
77 #define IsDataTransferNeeded(SrbExtension) (SrbExtension->Flags & (ATA_FLAGS_DATA_IN | ATA_FLAGS_DATA_OUT))
78 #define IsAdapterCAPS64(CAP) (CAP & AHCI_Global_HBA_CAP_S64A)
79 
80 // 3.1.1 NCS = CAP[12:08] -> Align
81 #define AHCI_Global_Port_CAP_NCS(x) (((x) & 0xF00) >> 8)
82 
83 #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
84 //#define AhciDebugPrint(format, ...) StorPortDebugPrint(0, format, __VA_ARGS__)
85 #define AhciDebugPrint(format, ...) DbgPrint("(%s:%d) " format, __RELFILE__, __LINE__, ##__VA_ARGS__)
86 
87 typedef
88 VOID
90  __in PVOID PortExtension,
91  __in PVOID Srb
92  );
93 
95 // ---- Support Structures --- //
97 
98 // section 3.3.5
100 {
101  struct
102  {
103  ULONG DHRS:1; //Device to Host Register FIS Interrupt
104  ULONG PSS :1; //PIO Setup FIS Interrupt
105  ULONG DSS :1; //DMA Setup FIS Interrupt
106  ULONG SDBS :1; //Set Device Bits Interrupt
107  ULONG UFS :1; //Unknown FIS Interrupt
108  ULONG DPS :1; //Descriptor Processed
109  ULONG PCS :1; //Port Connect Change Status
110  ULONG DMPS :1; //Device Mechanical Presence Status (DMPS)
112  ULONG PRCS :1; //PhyRdy Change Status
113  ULONG IPMS :1; //Incorrect Port Multiplier Status
114  ULONG OFS :1; //Overflow Status
116  ULONG INFS :1; //Interface Non-fatal Error Status
117  ULONG IFS :1; //Interface Fatal Error Status
118  ULONG HBDS :1; //Host Bus Data Error Status
119  ULONG HBFS :1; //Host Bus Fatal Error Status
120  ULONG TFES :1; //Task File Error Status
121  ULONG CPDS :1; //Cold Port Detect Status
122  };
123 
126 
127 typedef struct _AHCI_FIS_DMA_SETUP
128 {
129  ULONG ULONG0_1; // FIS_TYPE_DMA_SETUP
130  // Port multiplier
131  // Reserved
132  // Data transfer direction, 1 - device to host
133  // Interrupt bit
134  // Auto-activate. Specifies if DMA Activate FIS is needed
135  UCHAR Reserved[2]; // Reserved
136  ULONG DmaBufferLow; // DMA Buffer Identifier. Used to Identify DMA buffer in host memory. SATA Spec says host specific and not in Spec. Trying AHCI spec might work.
138  ULONG Reserved2; // More reserved
139  ULONG DmaBufferOffset; // Byte offset into buffer. First 2 bits must be 0
140  ULONG TranferCount; // Number of bytes to transfer. Bit 0 must be 0
141  ULONG Reserved3; // Reserved
143 
144 typedef struct _AHCI_PIO_SETUP_FIS
145 {
148  UCHAR D :1;
149  UCHAR I :1;
153 
158 
163 
168 
172 
174 {
177  UCHAR I:1;
181 
186 
191 
195 
198 
200 {
202 
205  UCHAR I :1;
206  UCHAR N :1;
207 
212 
214 
217 
218 typedef struct _AHCI_QUEUE
219 {
220  PVOID Buffer[MAXIMUM_QUEUE_BUFFER_SIZE]; // because Storahci hold Srb queue of 255 size
224 
226 // --------------------------- //
228 
230 {
231  struct
232  {
233  ULONG CFL : 5; // Command FIS Length
234  ULONG A : 1; // IsATAPI
235  ULONG W : 1; // Write
236  ULONG P : 1; // Prefetchable
237 
238  ULONG R : 1; // Reset
239  ULONG B : 1; // BIST
240  ULONG C : 1; //Clear Busy upon R_OK
241  ULONG RSV : 1;
242  ULONG PMP : 4; //Port Multiplier Port
243 
244  ULONG PRDTL : 16; //Physical Region Descriptor Table Length
245  };
246 
249 
250 typedef union _AHCI_GHC
251 {
252  struct
253  {
254  ULONG HR : 1;
255  ULONG IE : 1;
256  ULONG MRSM : 1;
257  ULONG RSV0 : 28;
258  ULONG AE : 1;
259  };
260 
262 } AHCI_GHC;
263 
264 // section 3.3.7
265 typedef union _AHCI_PORT_CMD
266 {
267  struct
268  {
269  ULONG ST : 1;
270  ULONG SUD : 1;
271  ULONG POD : 1;
272  ULONG CLO : 1;
273  ULONG FRE : 1;
274  ULONG RSV0 : 3;
275  ULONG CCS : 5;
276  ULONG MPSS : 1;
277  ULONG FR : 1;
278  ULONG CR : 1;
279  ULONG CPS : 1;
280  ULONG PMA : 1;
281  ULONG HPCP : 1;
282  ULONG MPSP : 1;
283  ULONG CPD : 1;
284  ULONG ESP : 1;
288  ULONG DLAE : 1;
289  ULONG ALPE : 1;
290  ULONG ASP : 1;
291  ULONG ICC : 4;
292  };
293 
295 } AHCI_PORT_CMD;
296 
298 {
299  struct
300  {
301  ULONG DET :4;
302  ULONG SPD :4;
303  ULONG IPM :4;
304  ULONG SPM :4;
305  ULONG PMP :4;
307  };
308 
311 
313 {
314  struct
315  {
316  ULONG DET :4;
317  ULONG SPD :4;
318  ULONG IPM :4;
319  ULONG RSV0 :20;
320  };
321 
324 
325 typedef union _AHCI_TASK_FILE_DATA
326 {
327  struct
328  {
329  struct _STS
330  {
331  UCHAR ERR : 1;
332  UCHAR CS1 : 2;
333  UCHAR DRQ : 1;
334  UCHAR CS2 : 3;
335  UCHAR BSY : 1;
336  } STS;
337  UCHAR ERR;
339  };
340 
343 
344 typedef struct _AHCI_PRDT
345 {
349 
350  ULONG DBC : 22;
351  ULONG RSV1 : 9;
352  ULONG I : 1;
354 
355 // 4.2.3 Command Table
356 typedef struct _AHCI_COMMAND_TABLE
357 {
358  // (16 * 32) + 64 + 16 + 48 = 648
359  // 128 byte aligned :D
360  UCHAR CFIS[64];
361  UCHAR ACMD[16];
362  UCHAR RSV0[48];
365 
366 // 4.2.2 Command Header
367 typedef struct _AHCI_COMMAND_HEADER
368 {
370  ULONG PRDBC; // DW 1
371  ULONG CTBA; // DW 2
372  ULONG CTBA_U; // DW 3
373  ULONG Reserved[4]; // DW 4-7
375 
376 // Received FIS
377 typedef struct _AHCI_RECEIVED_FIS
378 {
379  struct _AHCI_FIS_DMA_SETUP DmaSetupFIS; // 0x00 -- DMA Setup FIS
380  ULONG pad0; // 4 BYTE padding
381  struct _AHCI_PIO_SETUP_FIS PioSetupFIS; // 0x20 -- PIO Setup FIS
382  ULONG pad1[3]; // 12 BYTE padding
383  struct _AHCI_D2H_REGISTER_FIS RegisterFIS; // 0x40 -- Register – Device to Host FIS
384  ULONG pad2; // 4 BYTE padding
385  struct _AHCI_SET_DEVICE_BITS_FIS SetDeviceFIS; // 0x58 -- Set Device Bit FIS
386  ULONG UnknowFIS[16]; // 0x60 -- Unknown FIS
387  ULONG Reserved[24]; // 0xA0 -- Reserved
389 
390 // Holds Port Information
391 typedef struct _AHCI_PORT
392 {
393  ULONG CLB; // 0x00, command list base address, 1K-byte aligned
394  ULONG CLBU; // 0x04, command list base address upper 32 bits
395  ULONG FB; // 0x08, FIS base address, 256-byte aligned
396  ULONG FBU; // 0x0C, FIS base address upper 32 bits
397  ULONG IS; // 0x10, interrupt status
398  ULONG IE; // 0x14, interrupt enable
399  ULONG CMD; // 0x18, command and status
400  ULONG RSV0; // 0x1C, Reserved
401  ULONG TFD; // 0x20, task file data
402  ULONG SIG; // 0x24, signature
403  ULONG SSTS; // 0x28, SATA status (SCR0:SStatus)
404  ULONG SCTL; // 0x2C, SATA control (SCR2:SControl)
405  ULONG SERR; // 0x30, SATA error (SCR1:SError)
406  ULONG SACT; // 0x34, SATA active (SCR3:SActive)
407  ULONG CI; // 0x38, command issue
408  ULONG SNTF; // 0x3C, SATA notification (SCR4:SNotification)
409  ULONG FBS; // 0x40, FIS-based switch control
410  ULONG RSV1[11]; // 0x44 ~ 0x6F, Reserved
411  ULONG Vendor[4]; // 0x70 ~ 0x7F, vendor specific
413 
415 {
416  struct
417  {
419  ULONG PSE :1;
420  ULONG DSE :1;
422  ULONG UFE :1;
423  ULONG DPE :1;
424  ULONG PCE :1;
429  ULONG OFE :1;
432  ULONG IFE :1;
437  };
438 
441 
443 {
444  // 0x00 - 0x2B, Generic Host Control
445  ULONG CAP; // 0x00, Host capability
446  ULONG GHC; // 0x04, Global host control
447  ULONG IS; // 0x08, Interrupt status
448  ULONG PI; // 0x0C, Port implemented
449  ULONG VS; // 0x10, Version
450  ULONG CCC_CTL; // 0x14, Command completion coalescing control
451  ULONG CCC_PTS; // 0x18, Command completion coalescing ports
452  ULONG EM_LOC; // 0x1C, Enclosure management location
453  ULONG EM_CTL; // 0x20, Enclosure management control
454  ULONG CAP2; // 0x24, Host capabilities extended
455  ULONG BOHC; // 0x28, BIOS/OS handoff control and status
456  ULONG Reserved[0x1d]; // 0x2C - 0x9F, Reserved
457  ULONG VendorSpecific[0x18]; // 0xA0 - 0xFF, Vendor specific registers
460 
461 // Holds information for each attached attached port to a given adapter.
462 typedef struct _AHCI_PORT_EXTENSION
463 {
465  ULONG QueueSlots; // slots which we have already assigned task (Slot)
466  ULONG CommandIssuedSlots; // slots which has been programmed
468 
469  struct
470  {
482  } DeviceParams;
483 
485  PAHCI_PORT Port; // AHCI Port Infomation
486  AHCI_QUEUE SrbQueue; // pending Srbs
488  PSCSI_REQUEST_BLOCK Slot[MAXIMUM_AHCI_PORT_NCS]; // Srbs which has been alloted a port
494  struct _AHCI_ADAPTER_EXTENSION* AdapterExtension; // Port's Adapter Information
496 
497 // Holds Adapter Information
499 {
503  PULONG IS;// Interrupt Status, In case of MSIM == `1`
504  ULONG PortImplemented;// bit-mapping of ports which are implemented
506 
510 
516 
517  PVOID NonCachedExtension; // holds virtual address to noncached buffer allocated for Port Extension
518 
519  struct
520  {
521  // Message per port or shared port?
524  ULONG Reserved : 30; // not in use -- maintain 4 byte alignment
525  } StateFlags;
526 
530 
532 {
537 
538 typedef struct _AHCI_SRB_EXTENSION
539 {
543 
554 
557 
562 
563  // for alignment purpose -- 128 byte alignment
564  // do not try to access (R/W) this field
567 
569 // Declarations //
571 
572 VOID
574  __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
575  __in UCHAR PathId,
577  );
578 
579 BOOLEAN
581  __in PAHCI_ADAPTER_EXTENSION AdapterExtension
582  );
583 
585 VOID
589  );
590 
592 BOOLEAN
593 IsPortValid (
594  __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
595  __in ULONG pathId
596  );
597 
599  __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
601  __in PCDB Cdb
602  );
603 
605  __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
607  __in PCDB Cdb
608  );
609 
611  __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
613  __in PCDB Cdb
614  );
615 
616 UCHAR
618  __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
620  __in PCDB Cdb
621  );
622 
624  __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
626  __in PCDB Cdb
627  );
628 
630  __in PAHCI_ADAPTER_EXTENSION AdapterExtension,
632  __in PCDB Cdb
633  );
634 
636 BOOLEAN
637 AddQueue (
639  __in PVOID Srb
640  );
641 
643 PVOID
644 RemoveQueue (
646  );
647 
652  );
653 
655 ULONG64
656 AhciGetLba (
657  __in PCDB Cdb,
658  __in ULONG CdbLength
659  );
660 
662 // Assertions //
664 
665 // I assert every silly mistake I can do while coding
666 // because god never help me debugging the code
667 // but these asserts do :')
668 
674 C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CCC_CTL) == 0x14);
675 C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CCC_PTS) == 0x18);
681 C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, VendorSpecific) == 0xA0);
682 C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, PortList) == 0x100);
683 
684 C_ASSERT(FIELD_OFFSET(AHCI_PORT, CLB) == 0x00);
685 C_ASSERT(FIELD_OFFSET(AHCI_PORT, CLBU) == 0x04);
686 C_ASSERT(FIELD_OFFSET(AHCI_PORT, FB) == 0x08);
687 C_ASSERT(FIELD_OFFSET(AHCI_PORT, FBU) == 0x0C);
688 C_ASSERT(FIELD_OFFSET(AHCI_PORT, IS) == 0x10);
689 C_ASSERT(FIELD_OFFSET(AHCI_PORT, IE) == 0x14);
691 C_ASSERT(FIELD_OFFSET(AHCI_PORT, RSV0) == 0x1C);
692 C_ASSERT(FIELD_OFFSET(AHCI_PORT, TFD) == 0x20);
693 C_ASSERT(FIELD_OFFSET(AHCI_PORT, SIG) == 0x24);
694 C_ASSERT(FIELD_OFFSET(AHCI_PORT, SSTS) == 0x28);
695 C_ASSERT(FIELD_OFFSET(AHCI_PORT, SCTL) == 0x2C);
696 C_ASSERT(FIELD_OFFSET(AHCI_PORT, SERR) == 0x30);
697 C_ASSERT(FIELD_OFFSET(AHCI_PORT, SACT) == 0x34);
698 C_ASSERT(FIELD_OFFSET(AHCI_PORT, CI) == 0x38);
699 C_ASSERT(FIELD_OFFSET(AHCI_PORT, SNTF) == 0x3C);
700 C_ASSERT(FIELD_OFFSET(AHCI_PORT, FBS) == 0x40);
701 C_ASSERT(FIELD_OFFSET(AHCI_PORT, RSV1) == 0x44);
702 C_ASSERT(FIELD_OFFSET(AHCI_PORT, Vendor) == 0x70);
703 
704 C_ASSERT((sizeof(AHCI_COMMAND_TABLE) % 128) == 0);
705 
706 C_ASSERT(sizeof(AHCI_GHC) == sizeof(ULONG));
707 C_ASSERT(sizeof(AHCI_PORT_CMD) == sizeof(ULONG));
708 C_ASSERT(sizeof(AHCI_TASK_FILE_DATA) == sizeof(ULONG));
709 C_ASSERT(sizeof(AHCI_INTERRUPT_ENABLE) == sizeof(ULONG));
710 C_ASSERT(sizeof(AHCI_SERIAL_ATA_STATUS) == sizeof(ULONG));
711 C_ASSERT(sizeof(AHCI_SERIAL_ATA_CONTROL) == sizeof(ULONG));
713 
AHCI_COMMAND_TABLE CommandTable
Definition: storahci.h:540
signed char * PCHAR
Definition: retypes.h:7
UCHAR CFIS[64]
Definition: storahci.h:360
union _AHCI_PORT_CMD AHCI_PORT_CMD
ULONG RSV0
Definition: storahci.h:348
ULONG IS
Definition: storahci.h:397
VOID AhciProcessIO(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in UCHAR PathId, __in PSCSI_REQUEST_BLOCK Srb)
Definition: storahci.c:1555
AHCI_PORT_EXTENSION PortExtension[MAXIMUM_AHCI_PORT_COUNT]
Definition: storahci.h:528
UCHAR Reserved5[2]
Definition: storahci.h:170
ULONG VendorSpecific[0x18]
Definition: storahci.h:457
union _AHCI_INTERRUPT_ENABLE AHCI_INTERRUPT_ENABLE
PLOCAL_SCATTER_GATHER_LIST pSgl
Definition: storahci.h:560
PSCSI_REQUEST_BLOCK Slot[MAXIMUM_AHCI_PORT_NCS]
Definition: storahci.h:488
ULONG Vendor[4]
Definition: storahci.h:411
ULONG Status
Definition: storahci.h:294
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989
union _AHCI_INTERRUPT_STATUS AHCI_INTERRUPT_STATUS
ULONG HR
Definition: storahci.h:254
union _AHCI_SERIAL_ATA_STATUS AHCI_SERIAL_ATA_STATUS
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1310
struct _AHCI_D2H_REGISTER_FIS AHCI_D2H_REGISTER_FIS
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2221
struct _AHCI_COMMAND_HEADER * PAHCI_COMMAND_HEADER
ULONG RSV0
Definition: storahci.h:400
union _AHCI_TASK_FILE_DATA AHCI_TASK_FILE_DATA
FORCEINLINE BOOLEAN IsPortValid(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in ULONG pathId)
Definition: storahci.c:2471
FORCEINLINE PVOID RemoveQueue(__inout PAHCI_QUEUE Queue)
Definition: storahci.c:2532
struct _AHCI_ADAPTER_EXTENSION::@1303 StateFlags
ULONG CommandIssuedSlots
Definition: storahci.h:466
Definition: cdrw_hw.h:28
#define CI(cs)
Definition: fontdlg.c:68
union _AHCI_COMMAND_HEADER_DESCRIPTION AHCI_COMMAND_HEADER_DESCRIPTION
ULONG RSV1
Definition: storahci.h:351
struct _AHCI_SET_DEVICE_BITS_FIS SetDeviceFIS
Definition: storahci.h:385
union _AHCI_GHC AHCI_GHC
ULONG DBAU
Definition: storahci.h:347
#define MAXIMUM_AHCI_PORT_COUNT
Definition: storahci.h:21
struct _AHCI_ADAPTER_EXTENSION AHCI_ADAPTER_EXTENSION
struct _AHCI_PRDT * PAHCI_PRDT
ULONG CLB
Definition: storahci.h:393
struct _AHCI_COMMAND_TABLE AHCI_COMMAND_TABLE
struct _AHCI_QUEUE AHCI_QUEUE
PAHCI_PORT Port
Definition: storahci.h:485
uint32_t ULONG_PTR
Definition: typedefs.h:65
ULONG SNTF
Definition: storahci.h:408
ULONG BytesPerLogicalSector
Definition: storahci.h:477
STOR_PHYSICAL_ADDRESS IdentifyDeviceDataPhysicalAddress
Definition: storahci.h:493
enum _STOR_DEVICE_POWER_STATE STOR_DEVICE_POWER_STATE
ULONG I
Definition: storahci.h:352
UCHAR VendorId[41]
Definition: storahci.h:479
struct _AHCI_PORT_EXTENSION * PAHCI_PORT_EXTENSION
ULONG AE
Definition: storahci.h:258
ULONG RSV1[11]
Definition: storahci.h:410
ULONG SERR
Definition: storahci.h:405
#define __out
Definition: dbghelp.h:62
struct _AHCI_ADAPTER_EXTENSION * PAHCI_ADAPTER_EXTENSION
PAHCI_COMPLETION_ROUTINE CompletionRoutine
Definition: storahci.h:561
ULONG CLBU
Definition: storahci.h:394
unsigned char BOOLEAN
struct _AHCI_SRB_EXTENSION * PAHCI_SRB_EXTENSION
struct _AHCI_SRB_EXTENSION AHCI_SRB_EXTENSION
ULONG MRSM
Definition: storahci.h:256
FORCEINLINE BOOLEAN AddQueue(__inout PAHCI_QUEUE Queue, __in PVOID Srb)
Definition: storahci.c:2501
struct _AHCI_PORT_EXTENSION AHCI_PORT_EXTENSION
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
UCHAR RSV0[48]
Definition: storahci.h:362
Definition: bufpool.h:45
UCHAR ACMD[16]
Definition: storahci.h:361
struct _AHCI_FIS_DMA_SETUP AHCI_FIS_DMA_SETUP
UCHAR DeviceRequestCapacity(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:2098
struct _AHCI_RECEIVED_FIS AHCI_RECEIVED_FIS
LARGE_INTEGER MaxLba
Definition: storahci.h:476
UCHAR SerialNumber[21]
Definition: storahci.h:481
ULONG BytesPerPhysicalSector
Definition: storahci.h:478
ULONG IE
Definition: storahci.h:398
AHCI_QUEUE CompletionQueue
Definition: storahci.h:487
FORCEINLINE PAHCI_SRB_EXTENSION GetSrbExtension(__in PSCSI_REQUEST_BLOCK Srb)
Definition: storahci.c:2564
#define PI
Definition: appview.h:58
ULONG UnknowFIS[16]
Definition: storahci.h:386
ULONG Status
Definition: storahci.h:261
ULONG SSTS
Definition: storahci.h:403
STOR_DEVICE_POWER_STATE DevicePowerState
Definition: storahci.h:491
UCHAR DeviceRequestComplete(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:2166
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
Definition: scratch.h:156
struct _AHCI_PORT_EXTENSION::@1302 DeviceParams
struct _AHCI_QUEUE * PAHCI_QUEUE
PIDENTIFY_DEVICE_DATA IdentifyDeviceData
Definition: storahci.h:492
AHCI_COMMAND_HEADER_DESCRIPTION DI
Definition: storahci.h:369
FORCEINLINE VOID AhciZeroMemory(__out PCHAR Buffer, __in ULONG BufferSize)
Definition: storahci.c:2443
#define MAXIMUM_AHCI_PORT_NCS
Definition: storahci.h:23
unsigned __int64 ULONG64
Definition: imports.h:198
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOLEAN AhciAdapterReset(__in PAHCI_ADAPTER_EXTENSION AdapterExtension)
Definition: storahci.c:2393
ULONG FBU
Definition: storahci.h:396
PAHCI_RECEIVED_FIS ReceivedFIS
Definition: storahci.h:489
#define VOID
Definition: acefi.h:82
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
union _AHCI_SERIAL_ATA_CONTROL AHCI_SERIAL_ATA_CONTROL
ULONG DBA
Definition: storahci.h:346
PAHCI_MEMORY_REGISTERS ABAR_Address
Definition: storahci.h:527
VOID(* PAHCI_COMPLETION_ROUTINE)(__in PVOID PortExtension, __in PVOID Srb)
Definition: storahci.h:89
struct _AHCI_TASK_FILE_DATA::@1298::_STS STS
#define __inout
Definition: dbghelp.h:50
struct _AHCI_D2H_REGISTER_FIS RegisterFIS
Definition: storahci.h:383
C_ASSERT(FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CAP)==0x00)
ULONG Head
Definition: storahci.h:221
USHORT TransferCount
Definition: storahci.h:169
FORCEINLINE ULONG64 AhciGetLba(__in PCDB Cdb, __in ULONG CdbLength)
Definition: storahci.c:2595
UCHAR DeviceRequestReadWrite(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:1988
#define CMD
Definition: stat64.c:23
ULONG FB
Definition: storahci.h:395
struct _AHCI_PORT * PAHCI_PORT
UCHAR DeviceInquiryRequest(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:2250
ULONG DBC
Definition: storahci.h:350
struct _AHCI_COMMAND_TABLE * PAHCI_COMMAND_TABLE
unsigned short USHORT
Definition: pedump.c:61
AHCI_PRDT PRDT[MAXIMUM_AHCI_PRDT_ENTRIES]
Definition: storahci.h:363
ULONG FBS
Definition: storahci.h:409
#define FORCEINLINE
Definition: wdftypes.h:67
ULONG IE
Definition: storahci.h:255
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
struct _AHCI_COMMAND_HEADER AHCI_COMMAND_HEADER
unsigned int * PULONG
Definition: retypes.h:1
UCHAR RevisionID[9]
Definition: storahci.h:480
ULONG Tail
Definition: storahci.h:222
ULONG RSV0
Definition: storahci.h:257
AHCI_QUEUE SrbQueue
Definition: storahci.h:486
UCHAR DeviceReportLuns(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:2196
struct _LOCAL_SCATTER_GATHER_LIST LOCAL_SCATTER_GATHER_LIST
struct _AHCI_PORT AHCI_PORT
ULONG CMD
Definition: storahci.h:399
struct _AHCI_PIO_SETUP_FIS PioSetupFIS
Definition: storahci.h:381
ULONG CI
Definition: storahci.h:407
unsigned int ULONG
Definition: retypes.h:1
struct _AHCI_PRDT AHCI_PRDT
struct _AHCI_FIS_DMA_SETUP DmaSetupFIS
Definition: storahci.h:379
struct _AHCI_MEMORY_REGISTERS AHCI_MEMORY_REGISTERS
ULONG SACT
Definition: storahci.h:406
ULONG SCTL
Definition: storahci.h:404
struct _AHCI_SET_DEVICE_BITS_FIS AHCI_SET_DEVICE_BITS_FIS
struct _AHCI_RECEIVED_FIS * PAHCI_RECEIVED_FIS
struct _AHCI_ADAPTER_EXTENSION * AdapterExtension
Definition: storahci.h:494
UCHAR DeviceRequestSense(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:1933
struct _AHCI_MEMORY_REGISTERS * PAHCI_MEMORY_REGISTERS
ULONG TFD
Definition: storahci.h:401
ULONG SIG
Definition: storahci.h:402
#define __in
Definition: dbghelp.h:35
AHCI_PORT PortList[MAXIMUM_AHCI_PORT_COUNT]
Definition: storahci.h:458
PAHCI_COMMAND_HEADER CommandList
Definition: storahci.h:490
STOR_DPC CommandCompletion
Definition: storahci.h:484
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define MAXIMUM_AHCI_PRDT_ENTRIES
Definition: storahci.h:22
#define MAXIMUM_QUEUE_BUFFER_SIZE
Definition: storahci.h:24
struct _AHCI_PIO_SETUP_FIS AHCI_PIO_SETUP_FIS
LOCAL_SCATTER_GATHER_LIST Sgl
Definition: storahci.h:559
struct _LOCAL_SCATTER_GATHER_LIST * PLOCAL_SCATTER_GATHER_LIST