ReactOS  0.4.14-dev-297-g23e575c
storahci.h File Reference
#include <ntddk.h>
#include <ata.h>
#include <storport.h>
#include <debug.h>
Include dependency graph for storahci.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  _AHCI_INTERRUPT_STATUS
 
struct  _AHCI_FIS_DMA_SETUP
 
struct  _AHCI_PIO_SETUP_FIS
 
struct  _AHCI_D2H_REGISTER_FIS
 
struct  _AHCI_SET_DEVICE_BITS_FIS
 
struct  _AHCI_QUEUE
 
union  _AHCI_COMMAND_HEADER_DESCRIPTION
 
union  _AHCI_GHC
 
union  _AHCI_PORT_CMD
 
union  _AHCI_SERIAL_ATA_CONTROL
 
union  _AHCI_SERIAL_ATA_STATUS
 
union  _AHCI_TASK_FILE_DATA
 
struct  _AHCI_PRDT
 
struct  _AHCI_COMMAND_TABLE
 
struct  _AHCI_COMMAND_HEADER
 
struct  _AHCI_RECEIVED_FIS
 
struct  _AHCI_PORT
 
union  _AHCI_INTERRUPT_ENABLE
 
struct  _AHCI_MEMORY_REGISTERS
 
struct  _AHCI_PORT_EXTENSION
 
struct  _AHCI_ADAPTER_EXTENSION
 
struct  _LOCAL_SCATTER_GATHER_LIST
 
struct  _AHCI_SRB_EXTENSION
 

Macros

#define NDEBUG
 
#define DEBUG   1
 
#define MAXIMUM_AHCI_PORT_COUNT   32
 
#define MAXIMUM_AHCI_PRDT_ENTRIES   32
 
#define MAXIMUM_AHCI_PORT_NCS   30
 
#define MAXIMUM_QUEUE_BUFFER_SIZE   255
 
#define MAXIMUM_TRANSFER_LENGTH   (128*1024)
 
#define DEVICE_ATA_BLOCK_SIZE   512
 
#define AHCI_DEVICE_TYPE_ATA   1
 
#define AHCI_DEVICE_TYPE_ATAPI   2
 
#define AHCI_DEVICE_TYPE_NODEVICE   3
 
#define AHCI_Global_HBA_CAP_S64A   (1 << 31)
 
#define FIS_TYPE_REG_H2D   0x27
 
#define FIS_TYPE_REG_D2H   0x34
 
#define FIS_TYPE_DMA_ACT   0x39
 
#define FIS_TYPE_DMA_SETUP   0x41
 
#define FIS_TYPE_BIST   0x58
 
#define FIS_TYPE_PIO_SETUP   0x5F
 
#define FIS_TYPE_DEV_BITS   0xA1
 
#define AHCI_ATA_CFIS_FisType   0
 
#define AHCI_ATA_CFIS_PMPort_C   1
 
#define AHCI_ATA_CFIS_CommandReg   2
 
#define AHCI_ATA_CFIS_FeaturesLow   3
 
#define AHCI_ATA_CFIS_LBA0   4
 
#define AHCI_ATA_CFIS_LBA1   5
 
#define AHCI_ATA_CFIS_LBA2   6
 
#define AHCI_ATA_CFIS_Device   7
 
#define AHCI_ATA_CFIS_LBA3   8
 
#define AHCI_ATA_CFIS_LBA4   9
 
#define AHCI_ATA_CFIS_LBA5   10
 
#define AHCI_ATA_CFIS_FeaturesHigh   11
 
#define AHCI_ATA_CFIS_SectorCountLow   12
 
#define AHCI_ATA_CFIS_SectorCountHigh   13
 
#define ATA_FUNCTION_ATA_COMMAND   0x100
 
#define ATA_FUNCTION_ATA_IDENTIFY   0x101
 
#define ATA_FUNCTION_ATA_READ   0x102
 
#define ATA_FUNCTION_ATAPI_COMMAND   0x200
 
#define ATA_FLAGS_DATA_IN   (1 << 1)
 
#define ATA_FLAGS_DATA_OUT   (1 << 2)
 
#define ATA_FLAGS_48BIT_COMMAND   (1 << 3)
 
#define ATA_FLAGS_USE_DMA   (1 << 4)
 
#define IsAtaCommand(AtaFunction)   (AtaFunction & ATA_FUNCTION_ATA_COMMAND)
 
#define IsAtapiCommand(AtaFunction)   (AtaFunction & ATA_FUNCTION_ATAPI_COMMAND)
 
#define IsDataTransferNeeded(SrbExtension)   (SrbExtension->Flags & (ATA_FLAGS_DATA_IN | ATA_FLAGS_DATA_OUT))
 
#define IsAdapterCAPS64(CAP)   (CAP & AHCI_Global_HBA_CAP_S64A)
 
#define AHCI_Global_Port_CAP_NCS(x)   (((x) & 0xF00) >> 8)
 
#define ROUND_UP(N, S)   ((((N) + (S) - 1) / (S)) * (S))
 
#define AhciDebugPrint(format, ...)   DbgPrint("(%s:%d) " format, __RELFILE__, __LINE__, ##__VA_ARGS__)
 

Typedefs

typedef VOID(* PAHCI_COMPLETION_ROUTINE) (__in PVOID PortExtension, __in PVOID Srb)
 
typedef union _AHCI_INTERRUPT_STATUS AHCI_INTERRUPT_STATUS
 
typedef struct _AHCI_FIS_DMA_SETUP AHCI_FIS_DMA_SETUP
 
typedef struct _AHCI_PIO_SETUP_FIS AHCI_PIO_SETUP_FIS
 
typedef struct _AHCI_D2H_REGISTER_FIS AHCI_D2H_REGISTER_FIS
 
typedef struct _AHCI_SET_DEVICE_BITS_FIS AHCI_SET_DEVICE_BITS_FIS
 
typedef struct _AHCI_QUEUE AHCI_QUEUE
 
typedef struct _AHCI_QUEUEPAHCI_QUEUE
 
typedef union _AHCI_COMMAND_HEADER_DESCRIPTION AHCI_COMMAND_HEADER_DESCRIPTION
 
typedef union _AHCI_GHC AHCI_GHC
 
typedef union _AHCI_PORT_CMD AHCI_PORT_CMD
 
typedef union _AHCI_SERIAL_ATA_CONTROL AHCI_SERIAL_ATA_CONTROL
 
typedef union _AHCI_SERIAL_ATA_STATUS AHCI_SERIAL_ATA_STATUS
 
typedef union _AHCI_TASK_FILE_DATA AHCI_TASK_FILE_DATA
 
typedef struct _AHCI_PRDT AHCI_PRDT
 
typedef struct _AHCI_PRDTPAHCI_PRDT
 
typedef struct _AHCI_COMMAND_TABLE AHCI_COMMAND_TABLE
 
typedef struct _AHCI_COMMAND_TABLEPAHCI_COMMAND_TABLE
 
typedef struct _AHCI_COMMAND_HEADER AHCI_COMMAND_HEADER
 
typedef struct _AHCI_COMMAND_HEADERPAHCI_COMMAND_HEADER
 
typedef struct _AHCI_RECEIVED_FIS AHCI_RECEIVED_FIS
 
typedef struct _AHCI_RECEIVED_FISPAHCI_RECEIVED_FIS
 
typedef struct _AHCI_PORT AHCI_PORT
 
typedef struct _AHCI_PORTPAHCI_PORT
 
typedef union _AHCI_INTERRUPT_ENABLE AHCI_INTERRUPT_ENABLE
 
typedef struct _AHCI_MEMORY_REGISTERS AHCI_MEMORY_REGISTERS
 
typedef struct _AHCI_MEMORY_REGISTERSPAHCI_MEMORY_REGISTERS
 
typedef struct _AHCI_PORT_EXTENSION AHCI_PORT_EXTENSION
 
typedef struct _AHCI_PORT_EXTENSIONPAHCI_PORT_EXTENSION
 
typedef struct _AHCI_ADAPTER_EXTENSION AHCI_ADAPTER_EXTENSION
 
typedef struct _AHCI_ADAPTER_EXTENSIONPAHCI_ADAPTER_EXTENSION
 
typedef struct _LOCAL_SCATTER_GATHER_LIST LOCAL_SCATTER_GATHER_LIST
 
typedef struct _LOCAL_SCATTER_GATHER_LISTPLOCAL_SCATTER_GATHER_LIST
 
typedef struct _AHCI_SRB_EXTENSION AHCI_SRB_EXTENSION
 
typedef struct _AHCI_SRB_EXTENSIONPAHCI_SRB_EXTENSION
 

Functions

VOID AhciProcessIO (__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in UCHAR PathId, __in PSCSI_REQUEST_BLOCK Srb)
 
BOOLEAN AhciAdapterReset (__in PAHCI_ADAPTER_EXTENSION AdapterExtension)
 
__inline VOID AhciZeroMemory (__out PCHAR Buffer, __in ULONG BufferSize)
 
__inline BOOLEAN IsPortValid (__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in ULONG pathId)
 
UCHAR DeviceRequestSense (__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
 
UCHAR DeviceRequestReadWrite (__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
 
UCHAR DeviceRequestCapacity (__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
 
UCHAR DeviceInquiryRequest (__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
 
UCHAR DeviceRequestComplete (__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
 
UCHAR DeviceReportLuns (__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
 
__inline BOOLEAN AddQueue (__inout PAHCI_QUEUE Queue, __in PVOID Srb)
 
__inline PVOID RemoveQueue (__inout PAHCI_QUEUE Queue)
 
__inline PAHCI_SRB_EXTENSION GetSrbExtension (__in PSCSI_REQUEST_BLOCK Srb)
 
__inline ULONG64 AhciGetLba (__in PCDB Cdb, __in ULONG CdbLength)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CAP)==0x00)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, GHC)==0x04)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, IS)==0x08)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, PI)==0x0C)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, VS)==0x10)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CCC_CTL)==0x14)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CCC_PTS)==0x18)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, EM_LOC)==0x1C)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, EM_CTL)==0x20)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CAP2)==0x24)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, BOHC)==0x28)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, Reserved)==0x2C)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, VendorSpecific)==0xA0)
 
 C_ASSERT (FIELD_OFFSET(AHCI_MEMORY_REGISTERS, PortList)==0x100)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, CLB)==0x00)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, CLBU)==0x04)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, FB)==0x08)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, FBU)==0x0C)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, IS)==0x10)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, IE)==0x14)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, CMD)==0x18)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, RSV0)==0x1C)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, TFD)==0x20)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, SIG)==0x24)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, SSTS)==0x28)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, SCTL)==0x2C)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, SERR)==0x30)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, SACT)==0x34)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, CI)==0x38)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, SNTF)==0x3C)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, FBS)==0x40)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, RSV1)==0x44)
 
 C_ASSERT (FIELD_OFFSET(AHCI_PORT, Vendor)==0x70)
 
 C_ASSERT ((sizeof(AHCI_COMMAND_TABLE) % 128)==0)
 
 C_ASSERT (sizeof(AHCI_GHC)==sizeof(ULONG))
 
 C_ASSERT (sizeof(AHCI_PORT_CMD)==sizeof(ULONG))
 
 C_ASSERT (sizeof(AHCI_TASK_FILE_DATA)==sizeof(ULONG))
 
 C_ASSERT (sizeof(AHCI_INTERRUPT_ENABLE)==sizeof(ULONG))
 
 C_ASSERT (sizeof(AHCI_SERIAL_ATA_STATUS)==sizeof(ULONG))
 
 C_ASSERT (sizeof(AHCI_SERIAL_ATA_CONTROL)==sizeof(ULONG))
 
 C_ASSERT (sizeof(AHCI_COMMAND_HEADER_DESCRIPTION)==sizeof(ULONG))
 
 C_ASSERT (FIELD_OFFSET(AHCI_COMMAND_TABLE, CFIS)==0x00)
 
 C_ASSERT (FIELD_OFFSET(AHCI_COMMAND_TABLE, ACMD)==0x40)
 
 C_ASSERT (FIELD_OFFSET(AHCI_COMMAND_TABLE, RSV0)==0x50)
 
 C_ASSERT (FIELD_OFFSET(AHCI_COMMAND_TABLE, PRDT)==0x80)
 

Macro Definition Documentation

◆ AHCI_ATA_CFIS_CommandReg

#define AHCI_ATA_CFIS_CommandReg   2

Definition at line 48 of file storahci.h.

◆ AHCI_ATA_CFIS_Device

#define AHCI_ATA_CFIS_Device   7

Definition at line 53 of file storahci.h.

◆ AHCI_ATA_CFIS_FeaturesHigh

#define AHCI_ATA_CFIS_FeaturesHigh   11

Definition at line 57 of file storahci.h.

◆ AHCI_ATA_CFIS_FeaturesLow

#define AHCI_ATA_CFIS_FeaturesLow   3

Definition at line 49 of file storahci.h.

◆ AHCI_ATA_CFIS_FisType

#define AHCI_ATA_CFIS_FisType   0

Definition at line 46 of file storahci.h.

◆ AHCI_ATA_CFIS_LBA0

#define AHCI_ATA_CFIS_LBA0   4

Definition at line 50 of file storahci.h.

◆ AHCI_ATA_CFIS_LBA1

#define AHCI_ATA_CFIS_LBA1   5

Definition at line 51 of file storahci.h.

◆ AHCI_ATA_CFIS_LBA2

#define AHCI_ATA_CFIS_LBA2   6

Definition at line 52 of file storahci.h.

◆ AHCI_ATA_CFIS_LBA3

#define AHCI_ATA_CFIS_LBA3   8

Definition at line 54 of file storahci.h.

◆ AHCI_ATA_CFIS_LBA4

#define AHCI_ATA_CFIS_LBA4   9

Definition at line 55 of file storahci.h.

◆ AHCI_ATA_CFIS_LBA5

#define AHCI_ATA_CFIS_LBA5   10

Definition at line 56 of file storahci.h.

◆ AHCI_ATA_CFIS_PMPort_C

#define AHCI_ATA_CFIS_PMPort_C   1

Definition at line 47 of file storahci.h.

◆ AHCI_ATA_CFIS_SectorCountHigh

#define AHCI_ATA_CFIS_SectorCountHigh   13

Definition at line 59 of file storahci.h.

◆ AHCI_ATA_CFIS_SectorCountLow

#define AHCI_ATA_CFIS_SectorCountLow   12

Definition at line 58 of file storahci.h.

◆ AHCI_DEVICE_TYPE_ATA

#define AHCI_DEVICE_TYPE_ATA   1

Definition at line 30 of file storahci.h.

◆ AHCI_DEVICE_TYPE_ATAPI

#define AHCI_DEVICE_TYPE_ATAPI   2

Definition at line 31 of file storahci.h.

◆ AHCI_DEVICE_TYPE_NODEVICE

#define AHCI_DEVICE_TYPE_NODEVICE   3

Definition at line 32 of file storahci.h.

◆ AHCI_Global_HBA_CAP_S64A

#define AHCI_Global_HBA_CAP_S64A   (1 << 31)

Definition at line 35 of file storahci.h.

◆ AHCI_Global_Port_CAP_NCS

#define AHCI_Global_Port_CAP_NCS (   x)    (((x) & 0xF00) >> 8)

Definition at line 81 of file storahci.h.

◆ AhciDebugPrint

#define AhciDebugPrint (   format,
  ... 
)    DbgPrint("(%s:%d) " format, __RELFILE__, __LINE__, ##__VA_ARGS__)

Definition at line 85 of file storahci.h.

◆ ATA_FLAGS_48BIT_COMMAND

#define ATA_FLAGS_48BIT_COMMAND   (1 << 3)

Definition at line 72 of file storahci.h.

◆ ATA_FLAGS_DATA_IN

#define ATA_FLAGS_DATA_IN   (1 << 1)

Definition at line 70 of file storahci.h.

◆ ATA_FLAGS_DATA_OUT

#define ATA_FLAGS_DATA_OUT   (1 << 2)

Definition at line 71 of file storahci.h.

◆ ATA_FLAGS_USE_DMA

#define ATA_FLAGS_USE_DMA   (1 << 4)

Definition at line 73 of file storahci.h.

◆ ATA_FUNCTION_ATA_COMMAND

#define ATA_FUNCTION_ATA_COMMAND   0x100

Definition at line 62 of file storahci.h.

◆ ATA_FUNCTION_ATA_IDENTIFY

#define ATA_FUNCTION_ATA_IDENTIFY   0x101

Definition at line 63 of file storahci.h.

◆ ATA_FUNCTION_ATA_READ

#define ATA_FUNCTION_ATA_READ   0x102

Definition at line 64 of file storahci.h.

◆ ATA_FUNCTION_ATAPI_COMMAND

#define ATA_FUNCTION_ATAPI_COMMAND   0x200

Definition at line 67 of file storahci.h.

◆ DEBUG

#define DEBUG   1

Definition at line 15 of file storahci.h.

◆ DEVICE_ATA_BLOCK_SIZE

#define DEVICE_ATA_BLOCK_SIZE   512

Definition at line 27 of file storahci.h.

◆ FIS_TYPE_BIST

#define FIS_TYPE_BIST   0x58

Definition at line 42 of file storahci.h.

◆ FIS_TYPE_DEV_BITS

#define FIS_TYPE_DEV_BITS   0xA1

Definition at line 44 of file storahci.h.

◆ FIS_TYPE_DMA_ACT

#define FIS_TYPE_DMA_ACT   0x39

Definition at line 40 of file storahci.h.

◆ FIS_TYPE_DMA_SETUP

#define FIS_TYPE_DMA_SETUP   0x41

Definition at line 41 of file storahci.h.

◆ FIS_TYPE_PIO_SETUP

#define FIS_TYPE_PIO_SETUP   0x5F

Definition at line 43 of file storahci.h.

◆ FIS_TYPE_REG_D2H

#define FIS_TYPE_REG_D2H   0x34

Definition at line 39 of file storahci.h.

◆ FIS_TYPE_REG_H2D

#define FIS_TYPE_REG_H2D   0x27

Definition at line 38 of file storahci.h.

◆ IsAdapterCAPS64

#define IsAdapterCAPS64 (   CAP)    (CAP & AHCI_Global_HBA_CAP_S64A)

Definition at line 78 of file storahci.h.

◆ IsAtaCommand

#define IsAtaCommand (   AtaFunction)    (AtaFunction & ATA_FUNCTION_ATA_COMMAND)

Definition at line 75 of file storahci.h.

◆ IsAtapiCommand

#define IsAtapiCommand (   AtaFunction)    (AtaFunction & ATA_FUNCTION_ATAPI_COMMAND)

Definition at line 76 of file storahci.h.

◆ IsDataTransferNeeded

#define IsDataTransferNeeded (   SrbExtension)    (SrbExtension->Flags & (ATA_FLAGS_DATA_IN | ATA_FLAGS_DATA_OUT))

Definition at line 77 of file storahci.h.

◆ MAXIMUM_AHCI_PORT_COUNT

#define MAXIMUM_AHCI_PORT_COUNT   32

Definition at line 21 of file storahci.h.

◆ MAXIMUM_AHCI_PORT_NCS

#define MAXIMUM_AHCI_PORT_NCS   30

Definition at line 23 of file storahci.h.

◆ MAXIMUM_AHCI_PRDT_ENTRIES

#define MAXIMUM_AHCI_PRDT_ENTRIES   32

Definition at line 22 of file storahci.h.

◆ MAXIMUM_QUEUE_BUFFER_SIZE

#define MAXIMUM_QUEUE_BUFFER_SIZE   255

Definition at line 24 of file storahci.h.

◆ MAXIMUM_TRANSFER_LENGTH

#define MAXIMUM_TRANSFER_LENGTH   (128*1024)

Definition at line 25 of file storahci.h.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file storahci.h.

◆ ROUND_UP

#define ROUND_UP (   N,
  S 
)    ((((N) + (S) - 1) / (S)) * (S))

Definition at line 83 of file storahci.h.

Typedef Documentation

◆ AHCI_ADAPTER_EXTENSION

◆ AHCI_COMMAND_HEADER

◆ AHCI_COMMAND_HEADER_DESCRIPTION

◆ AHCI_COMMAND_TABLE

◆ AHCI_D2H_REGISTER_FIS

◆ AHCI_FIS_DMA_SETUP

◆ AHCI_GHC

typedef union _AHCI_GHC AHCI_GHC

◆ AHCI_INTERRUPT_ENABLE

◆ AHCI_INTERRUPT_STATUS

◆ AHCI_MEMORY_REGISTERS

◆ AHCI_PIO_SETUP_FIS

◆ AHCI_PORT

◆ AHCI_PORT_CMD

◆ AHCI_PORT_EXTENSION

◆ AHCI_PRDT

◆ AHCI_QUEUE

◆ AHCI_RECEIVED_FIS

◆ AHCI_SERIAL_ATA_CONTROL

◆ AHCI_SERIAL_ATA_STATUS

◆ AHCI_SET_DEVICE_BITS_FIS

◆ AHCI_SRB_EXTENSION

◆ AHCI_TASK_FILE_DATA

◆ LOCAL_SCATTER_GATHER_LIST

◆ PAHCI_ADAPTER_EXTENSION

◆ PAHCI_COMMAND_HEADER

◆ PAHCI_COMMAND_TABLE

◆ PAHCI_COMPLETION_ROUTINE

typedef VOID(* PAHCI_COMPLETION_ROUTINE) (__in PVOID PortExtension, __in PVOID Srb)

Definition at line 89 of file storahci.h.

◆ PAHCI_MEMORY_REGISTERS

◆ PAHCI_PORT

◆ PAHCI_PORT_EXTENSION

◆ PAHCI_PRDT

◆ PAHCI_QUEUE

◆ PAHCI_RECEIVED_FIS

◆ PAHCI_SRB_EXTENSION

◆ PLOCAL_SCATTER_GATHER_LIST

Function Documentation

◆ AddQueue()

__inline BOOLEAN AddQueue ( __inout PAHCI_QUEUE  Queue,
__in PVOID  Srb 
)

Definition at line 2501 of file storahci.c.

2505 {
2506  NT_ASSERT(Queue->Head < MAXIMUM_QUEUE_BUFFER_SIZE);
2507  NT_ASSERT(Queue->Tail < MAXIMUM_QUEUE_BUFFER_SIZE);
2508 
2509  if (Queue->Tail == ((Queue->Head + 1) % MAXIMUM_QUEUE_BUFFER_SIZE))
2510  return FALSE;
2511 
2512  Queue->Buffer[Queue->Head++] = Srb;
2513  Queue->Head %= MAXIMUM_QUEUE_BUFFER_SIZE;
2514 
2515  return TRUE;
2516 }// -- AddQueue();
#define TRUE
Definition: types.h:120
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define MAXIMUM_QUEUE_BUFFER_SIZE
Definition: storahci.h:24
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciCompleteIssuedSrb(), and AhciProcessIO().

◆ AhciAdapterReset()

BOOLEAN AhciAdapterReset ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension)

Definition at line 2393 of file storahci.c.

2396 {
2397  ULONG ticks;
2398  AHCI_GHC ghc;
2400 
2401  AhciDebugPrint("AhciAdapterReset()\n");
2402 
2403  abar = AdapterExtension->ABAR_Address;
2404  if (abar == NULL) // basic sanity
2405  {
2406  return FALSE;
2407  }
2408 
2409  // HR -- Very first bit (lowest significant)
2410  ghc.HR = 1;
2411  StorPortWriteRegisterUlong(AdapterExtension, &abar->GHC, ghc.Status);
2412 
2413  for (ticks = 0; ticks < 50; ++ticks)
2414  {
2415  ghc.Status = StorPortReadRegisterUlong(AdapterExtension, &abar->GHC);
2416  if (ghc.HR == 0)
2417  {
2418  break;
2419  }
2420  StorPortStallExecution(20000);
2421  }
2422 
2423  if (ticks == 50)// 1 second
2424  {
2425  AhciDebugPrint("\tDevice Timeout\n");
2426  return FALSE;
2427  }
2428 
2429  return TRUE;
2430 }// -- AhciAdapterReset();
#define TRUE
Definition: types.h:120
STORPORT_API VOID NTAPI StorPortStallExecution(_In_ ULONG Delay)
Definition: storport.c:1417
ULONG HR
Definition: storahci.h:254
smooth NULL
Definition: ftsmooth.c:416
ULONG Status
Definition: storahci.h:261
STORPORT_API ULONG NTAPI StorPortReadRegisterUlong(_In_ PVOID HwDeviceExtension, _In_ PULONG Register)
Definition: stubs.c:143
STORPORT_API VOID NTAPI StorPortWriteRegisterUlong(_In_ PVOID HwDeviceExtension, _In_ PULONG Register, _In_ ULONG Value)
Definition: stubs.c:291
unsigned int ULONG
Definition: retypes.h:1
#define AhciDebugPrint(format,...)
Definition: storahci.h:85

Referenced by AhciHwFindAdapter().

◆ AhciGetLba()

__inline ULONG64 AhciGetLba ( __in PCDB  Cdb,
__in ULONG  CdbLength 
)

Definition at line 2595 of file storahci.c.

2599 {
2600  ULONG64 lba = 0;
2601 
2602  NT_ASSERT(Cdb != NULL);
2603  NT_ASSERT(CdbLength != 0);
2604 
2605  if (CdbLength == 0x10)
2606  {
2607  REVERSE_BYTES_QUAD(&lba, Cdb->CDB16.LogicalBlock);
2608  }
2609  else
2610  {
2611  lba |= Cdb->CDB10.LogicalBlockByte3 << 0;
2612  lba |= Cdb->CDB10.LogicalBlockByte2 << 8;
2613  lba |= Cdb->CDB10.LogicalBlockByte1 << 16;
2614  lba |= Cdb->CDB10.LogicalBlockByte0 << 24;
2615  }
2616 
2617  return lba;
2618 }
#define lba
smooth NULL
Definition: ftsmooth.c:416
unsigned __int64 ULONG64
Definition: imports.h:198
#define REVERSE_BYTES_QUAD(Destination, Source)
Definition: scsi.h:2694
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by DeviceRequestReadWrite().

◆ AhciProcessIO()

VOID AhciProcessIO ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension,
__in UCHAR  PathId,
__in PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 1555 of file storahci.c.

1560 {
1561  PSCSI_REQUEST_BLOCK tmpSrb;
1562  STOR_LOCK_HANDLE lockhandle = {0};
1563  PAHCI_PORT_EXTENSION PortExtension;
1564  ULONG commandSlotMask, occupiedSlots, slotIndex, NCS;
1565 
1566  AhciDebugPrint("AhciProcessIO()\n");
1567  AhciDebugPrint("\tPathId: %d\n", PathId);
1568 
1569  PortExtension = &AdapterExtension->PortExtension[PathId];
1570 
1571  NT_ASSERT(PathId < AdapterExtension->PortCount);
1572 
1573  // Acquire Lock
1574  StorPortAcquireSpinLock(AdapterExtension, InterruptLock, NULL, &lockhandle);
1575 
1576  // add Srb to queue
1577  AddQueue(&PortExtension->SrbQueue, Srb);
1578 
1579  if (PortExtension->DeviceParams.IsActive == FALSE)
1580  {
1581  // Release Lock
1582  StorPortReleaseSpinLock(AdapterExtension, &lockhandle);
1583  return; // we should wait for device to get active
1584  }
1585 
1586  occupiedSlots = (PortExtension->QueueSlots | PortExtension->CommandIssuedSlots); // Busy command slots for given port
1587  NCS = AHCI_Global_Port_CAP_NCS(AdapterExtension->CAP);
1588  commandSlotMask = (1 << NCS) - 1; // available slots mask
1589 
1590  commandSlotMask = (commandSlotMask & ~occupiedSlots);
1591  if(commandSlotMask != 0)
1592  {
1593  // iterate over HBA port slots
1594  for (slotIndex = 0; slotIndex < NCS; slotIndex++)
1595  {
1596  // find first free slot
1597  if ((commandSlotMask & (1 << slotIndex)) != 0)
1598  {
1599  tmpSrb = RemoveQueue(&PortExtension->SrbQueue);
1600  if (tmpSrb != NULL)
1601  {
1602  NT_ASSERT(tmpSrb->PathId == PathId);
1603  AhciProcessSrb(PortExtension, tmpSrb, slotIndex);
1604  }
1605  else
1606  {
1607  break;
1608  }
1609  }
1610  else
1611  {
1612  break;
1613  }
1614  }
1615  }
1616 
1617  // program HBA port
1618  AhciActivatePort(PortExtension);
1619 
1620  // Release Lock
1621  StorPortReleaseSpinLock(AdapterExtension, &lockhandle);
1622 
1623  return;
1624 }// -- AhciProcessIO();
VOID AhciProcessSrb(__in PAHCI_PORT_EXTENSION PortExtension, __in PSCSI_REQUEST_BLOCK Srb, __in ULONG SlotIndex)
Definition: storahci.c:1364
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1117
ULONG CommandIssuedSlots
Definition: storahci.h:466
FORCEINLINE VOID StorPortAcquireSpinLock(_In_ PVOID DeviceExtension, _In_ STOR_SPINLOCK SpinLock, _In_ PVOID LockContext, _Inout_ PSTOR_LOCK_HANDLE LockHandle)
Definition: storport.h:2904
__inline PVOID RemoveQueue(__inout PAHCI_QUEUE Queue)
Definition: storahci.c:2532
__inline BOOLEAN AddQueue(__inout PAHCI_QUEUE Queue, __in PVOID Srb)
Definition: storahci.c:2501
struct _AHCI_PORT_EXTENSION::@1298 DeviceParams
#define AHCI_Global_Port_CAP_NCS(x)
Definition: storahci.h:81
smooth NULL
Definition: ftsmooth.c:416
VOID AhciActivatePort(__in PAHCI_PORT_EXTENSION PortExtension)
Definition: storahci.c:1490
UCHAR PathId
Definition: srb.h:245
AHCI_QUEUE SrbQueue
Definition: storahci.h:486
unsigned int ULONG
Definition: retypes.h:1
#define AhciDebugPrint(format,...)
Definition: storahci.h:85
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
FORCEINLINE VOID StorPortReleaseSpinLock(_In_ PVOID DeviceExtension, _Inout_ PSTOR_LOCK_HANDLE LockHandle)
Definition: storport.h:2919
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciHwStartIo().

◆ AhciZeroMemory()

__inline VOID AhciZeroMemory ( __out PCHAR  Buffer,
__in ULONG  BufferSize 
)

Definition at line 2443 of file storahci.c.

2447 {
2448  ULONG i;
2449  for (i = 0; i < BufferSize; i++)
2450  {
2451  Buffer[i] = 0;
2452  }
2453 
2454  return;
2455 }// -- AhciZeroMemory();
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: bufpool.h:45
#define BufferSize
Definition: classpnp.h:419
unsigned int ULONG
Definition: retypes.h:1

Referenced by AhciAllocateResourceForAdapter(), AhciATA_CFIS(), AhciATAPI_CFIS(), DeviceInquiryRequest(), DeviceReportLuns(), and DeviceRequestSense().

◆ C_ASSERT() [1/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CAP)  = =0x00)

◆ C_ASSERT() [2/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, GHC)  = =0x04)

◆ C_ASSERT() [3/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, IS)  = =0x08)

◆ C_ASSERT() [4/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, PI = =0x0C)

◆ C_ASSERT() [5/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, VS)  = =0x10)

◆ C_ASSERT() [6/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CCC_CTL)  = =0x14)

◆ C_ASSERT() [7/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CCC_PTS)  = =0x18)

◆ C_ASSERT() [8/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, EM_LOC)  = =0x1C)

◆ C_ASSERT() [9/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, EM_CTL)  = =0x20)

◆ C_ASSERT() [10/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, CAP2)  = =0x24)

◆ C_ASSERT() [11/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, BOHC)  = =0x28)

◆ C_ASSERT() [12/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, Reserved = =0x2C)

◆ C_ASSERT() [13/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, VendorSpecific)  = =0xA0)

◆ C_ASSERT() [14/45]

C_ASSERT ( FIELD_OFFSET(AHCI_MEMORY_REGISTERS, PortList)  = =0x100)

◆ C_ASSERT() [15/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, CLB)  = =0x00)

◆ C_ASSERT() [16/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, CLBU)  = =0x04)

◆ C_ASSERT() [17/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, FB)  = =0x08)

◆ C_ASSERT() [18/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, FBU)  = =0x0C)

◆ C_ASSERT() [19/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, IS)  = =0x10)

◆ C_ASSERT() [20/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, IE)  = =0x14)

◆ C_ASSERT() [21/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, CMD = =0x18)

◆ C_ASSERT() [22/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, RSV0)  = =0x1C)

◆ C_ASSERT() [23/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, TFD)  = =0x20)

◆ C_ASSERT() [24/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, SIG)  = =0x24)

◆ C_ASSERT() [25/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, SSTS)  = =0x28)

◆ C_ASSERT() [26/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, SCTL)  = =0x2C)

◆ C_ASSERT() [27/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, SERR)  = =0x30)

◆ C_ASSERT() [28/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, SACT)  = =0x34)

◆ C_ASSERT() [29/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, CI = =0x38)

◆ C_ASSERT() [30/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, SNTF)  = =0x3C)

◆ C_ASSERT() [31/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, FBS)  = =0x40)

◆ C_ASSERT() [32/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, RSV1)  = =0x44)

◆ C_ASSERT() [33/45]

C_ASSERT ( FIELD_OFFSET(AHCI_PORT, Vendor)  = =0x70)

◆ C_ASSERT() [34/45]

C_ASSERT ( (sizeof(AHCI_COMMAND_TABLE) % 128)  = =0)

◆ C_ASSERT() [35/45]

C_ASSERT ( sizeof(AHCI_GHC = =sizeof(ULONG))

◆ C_ASSERT() [36/45]

C_ASSERT ( sizeof(AHCI_PORT_CMD = =sizeof(ULONG))

◆ C_ASSERT() [37/45]

C_ASSERT ( sizeof(AHCI_TASK_FILE_DATA = =sizeof(ULONG))

◆ C_ASSERT() [38/45]

◆ C_ASSERT() [39/45]

◆ C_ASSERT() [40/45]

◆ C_ASSERT() [41/45]

◆ C_ASSERT() [42/45]

C_ASSERT ( FIELD_OFFSET(AHCI_COMMAND_TABLE, CFIS)  = =0x00)

◆ C_ASSERT() [43/45]

C_ASSERT ( FIELD_OFFSET(AHCI_COMMAND_TABLE, ACMD)  = =0x40)

◆ C_ASSERT() [44/45]

C_ASSERT ( FIELD_OFFSET(AHCI_COMMAND_TABLE, RSV0)  = =0x50)

◆ C_ASSERT() [45/45]

C_ASSERT ( FIELD_OFFSET(AHCI_COMMAND_TABLE, PRDT)  = =0x80)

◆ DeviceInquiryRequest()

UCHAR DeviceInquiryRequest ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension,
__in PSCSI_REQUEST_BLOCK  Srb,
__in PCDB  Cdb 
)

Definition at line 2250 of file storahci.c.

2255 {
2256  PVOID DataBuffer;
2257  PAHCI_SRB_EXTENSION SrbExtension;
2258  PAHCI_PORT_EXTENSION PortExtension;
2259  PVPD_SUPPORTED_PAGES_PAGE VpdOutputBuffer;
2260  ULONG DataBufferLength, RequiredDataBufferLength;
2261 
2262  AhciDebugPrint("DeviceInquiryRequest()\n");
2263 
2264  NT_ASSERT(Cdb->CDB10.OperationCode == SCSIOP_INQUIRY);
2265  NT_ASSERT(IsPortValid(AdapterExtension, Srb->PathId));
2266 
2267  SrbExtension = GetSrbExtension(Srb);
2268  PortExtension = &AdapterExtension->PortExtension[Srb->PathId];
2269 
2270  if (PortExtension->DeviceParams.DeviceType == AHCI_DEVICE_TYPE_ATAPI)
2271  {
2272  return AhciATAPICommand(AdapterExtension, Srb, Cdb);
2273  }
2274 
2275  if (Srb->Lun != 0)
2276  {
2278  }
2279  else if (Cdb->CDB6INQUIRY3.EnableVitalProductData == 0)
2280  {
2281  // 3.6.1
2282  // If the EVPD bit is set to zero, the device server shall return the standard INQUIRY data
2283  AhciDebugPrint("\tEVPD Inquired\n");
2284  NT_ASSERT(SrbExtension != NULL);
2285 
2286  SrbExtension->AtaFunction = ATA_FUNCTION_ATA_IDENTIFY;
2287  SrbExtension->Flags |= ATA_FLAGS_DATA_IN;
2288  SrbExtension->CompletionRoutine = InquiryCompletion;
2289  SrbExtension->CommandReg = IDE_COMMAND_NOT_VALID;
2290 
2291  // TODO: Should use AhciZeroMemory
2292  SrbExtension->FeaturesLow = 0;
2293  SrbExtension->LBA0 = 0;
2294  SrbExtension->LBA1 = 0;
2295  SrbExtension->LBA2 = 0;
2296  SrbExtension->Device = 0xA0;
2297  SrbExtension->LBA3 = 0;
2298  SrbExtension->LBA4 = 0;
2299  SrbExtension->LBA5 = 0;
2300  SrbExtension->FeaturesHigh = 0;
2301  SrbExtension->SectorCountLow = 0;
2302  SrbExtension->SectorCountHigh = 0;
2303 
2304  SrbExtension->Sgl.NumberOfElements = 1;
2305  SrbExtension->Sgl.List[0].PhysicalAddress.LowPart = PortExtension->IdentifyDeviceDataPhysicalAddress.LowPart;
2306  SrbExtension->Sgl.List[0].PhysicalAddress.HighPart = PortExtension->IdentifyDeviceDataPhysicalAddress.HighPart;
2307  SrbExtension->Sgl.List[0].Length = sizeof(IDENTIFY_DEVICE_DATA);
2308 
2309  SrbExtension->pSgl = &SrbExtension->Sgl;
2310  return SRB_STATUS_PENDING;
2311  }
2312  else
2313  {
2314  AhciDebugPrint("\tVPD Inquired\n");
2315 
2316  DataBuffer = Srb->DataBuffer;
2317  DataBufferLength = Srb->DataTransferLength;
2318  RequiredDataBufferLength = DataBufferLength; // make the compiler happy :p
2319 
2320  if (DataBuffer == NULL)
2321  {
2323  }
2324 
2325  AhciZeroMemory(DataBuffer, DataBufferLength);
2326 
2327  switch(Cdb->CDB6INQUIRY3.PageCode)
2328  {
2329  case VPD_SUPPORTED_PAGES:
2330  {
2331  AhciDebugPrint("\tVPD_SUPPORTED_PAGES\n");
2332  RequiredDataBufferLength = sizeof(VPD_SUPPORTED_PAGES_PAGE) + 1;
2333 
2334  if (DataBufferLength < RequiredDataBufferLength)
2335  {
2336  AhciDebugPrint("\tDataBufferLength: %d Required: %d\n", DataBufferLength, RequiredDataBufferLength);
2338  }
2339 
2340  VpdOutputBuffer = (PVPD_SUPPORTED_PAGES_PAGE)DataBuffer;
2341 
2342  VpdOutputBuffer->DeviceType = PortExtension->DeviceParams.AccessType;
2343  VpdOutputBuffer->DeviceTypeQualifier = 0;
2344  VpdOutputBuffer->PageCode = VPD_SUPPORTED_PAGES;
2345  VpdOutputBuffer->PageLength = 1;
2346  VpdOutputBuffer->SupportedPageList[0] = VPD_SUPPORTED_PAGES;
2347  //VpdOutputBuffer->SupportedPageList[1] = VPD_SERIAL_NUMBER;
2348  //VpdOutputBuffer->SupportedPageList[2] = VPD_DEVICE_IDENTIFIERS;
2349 
2350  NT_ASSERT(VpdOutputBuffer->DeviceType == DIRECT_ACCESS_DEVICE);
2351  }
2352  break;
2353  case VPD_SERIAL_NUMBER:
2354  {
2355  AhciDebugPrint("\tVPD_SERIAL_NUMBER\n");
2356  }
2357  break;
2359  {
2360  AhciDebugPrint("\tVPD_DEVICE_IDENTIFIERS\n");
2361  }
2362  break;
2363  default:
2364  AhciDebugPrint("\tPageCode: %x\n", Cdb->CDB6INQUIRY3.PageCode);
2366  }
2367 
2368  Srb->DataTransferLength = RequiredDataBufferLength;
2369  return SRB_STATUS_SUCCESS;
2370  }
2371 }// -- DeviceInquiryRequest();
#define SRB_STATUS_INVALID_REQUEST
Definition: srb.h:338
struct _VPD_SUPPORTED_PAGES_PAGE * PVPD_SUPPORTED_PAGES_PAGE
struct _VPD_SUPPORTED_PAGES_PAGE VPD_SUPPORTED_PAGES_PAGE
__inline BOOLEAN IsPortValid(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in ULONG pathId)
Definition: storahci.c:2471
PLOCAL_SCATTER_GATHER_LIST pSgl
Definition: storahci.h:560
#define VPD_SUPPORTED_PAGES
Definition: scsi.h:495
#define ATA_FLAGS_DATA_IN
Definition: uata_ctl.h:222
__inline PAHCI_SRB_EXTENSION GetSrbExtension(__in PSCSI_REQUEST_BLOCK Srb)
Definition: storahci.c:2564
STOR_PHYSICAL_ADDRESS PhysicalAddress
Definition: storport.h:2047
#define AHCI_DEVICE_TYPE_ATAPI
Definition: storahci.h:31
#define VPD_DEVICE_IDENTIFIERS
Definition: scsi.h:497
STOR_PHYSICAL_ADDRESS IdentifyDeviceDataPhysicalAddress
Definition: storahci.h:493
struct _AHCI_PORT_EXTENSION::@1298 DeviceParams
#define ATA_FUNCTION_ATA_IDENTIFY
Definition: storahci.h:63
UCHAR AhciATAPICommand(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:1843
PAHCI_COMPLETION_ROUTINE CompletionRoutine
Definition: storahci.h:561
#define SRB_STATUS_PENDING
Definition: srb.h:332
smooth NULL
Definition: ftsmooth.c:416
UCHAR SupportedPageList[0]
Definition: scsi.h:2143
#define SCSIOP_INQUIRY
Definition: cdrw_hw.h:888
#define DIRECT_ACCESS_DEVICE
Definition: cdrw_hw.h:1144
struct _IDENTIFY_DEVICE_DATA IDENTIFY_DEVICE_DATA
#define IDE_COMMAND_NOT_VALID
Definition: ata.h:299
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_opt_ GUID _In_ USHORT DataBufferLength
Definition: fltkernel.h:1270
STOR_SCATTER_GATHER_ELEMENT List[MAXIMUM_AHCI_PRDT_ENTRIES]
Definition: storahci.h:535
VOID InquiryCompletion(__in PVOID _Extension, __in PVOID _Srb)
Definition: storahci.c:1681
ULONG LowPart
Definition: typedefs.h:104
__inline VOID AhciZeroMemory(__out PCHAR Buffer, __in ULONG BufferSize)
Definition: storahci.c:2443
#define SRB_STATUS_SELECTION_TIMEOUT
Definition: srb.h:342
unsigned int ULONG
Definition: retypes.h:1
#define VPD_SERIAL_NUMBER
Definition: scsi.h:496
#define AhciDebugPrint(format,...)
Definition: storahci.h:85
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
LOCAL_SCATTER_GATHER_LIST Sgl
Definition: storahci.h:559
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciHwStartIo().

◆ DeviceReportLuns()

UCHAR DeviceReportLuns ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension,
__in PSCSI_REQUEST_BLOCK  Srb,
__in PCDB  Cdb 
)

Definition at line 2196 of file storahci.c.

2201 {
2202  PLUN_LIST LunList;
2203  PAHCI_PORT_EXTENSION PortExtension;
2204 
2205  AhciDebugPrint("DeviceReportLuns()\n");
2206 
2208 
2209  PortExtension = &AdapterExtension->PortExtension[Srb->PathId];
2210 
2211  NT_ASSERT(Srb->DataTransferLength >= sizeof(LUN_LIST));
2212  NT_ASSERT(Cdb->CDB10.OperationCode == SCSIOP_REPORT_LUNS);
2213 
2214  if (PortExtension->DeviceParams.DeviceType == AHCI_DEVICE_TYPE_ATAPI)
2215  {
2216  return AhciATAPICommand(AdapterExtension, Srb, Cdb);
2217  }
2218 
2219  LunList = (PLUN_LIST)Srb->DataBuffer;
2220 
2221  NT_ASSERT(LunList != NULL);
2222 
2223  AhciZeroMemory((PCHAR)LunList, sizeof(LUN_LIST));
2224 
2225  LunList->LunListLength[3] = 8;
2226 
2227  Srb->ScsiStatus = SCSISTAT_GOOD;
2228  Srb->DataTransferLength = sizeof(LUN_LIST);
2229 
2230  return SRB_STATUS_SUCCESS;
2231 }// -- DeviceReportLuns();
signed char * PCHAR
Definition: retypes.h:7
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define AHCI_DEVICE_TYPE_ATAPI
Definition: storahci.h:31
struct _AHCI_PORT_EXTENSION::@1298 DeviceParams
UCHAR AhciATAPICommand(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:1843
smooth NULL
Definition: ftsmooth.c:416
#define SCSIOP_REPORT_LUNS
Definition: scsi.h:921
__inline VOID AhciZeroMemory(__out PCHAR Buffer, __in ULONG BufferSize)
Definition: storahci.c:2443
struct _LUN_LIST * PLUN_LIST
struct _LUN_LIST LUN_LIST
#define AhciDebugPrint(format,...)
Definition: storahci.h:85
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
#define SCSISTAT_GOOD
Definition: cdrw_hw.h:1078
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciHwStartIo().

◆ DeviceRequestCapacity()

UCHAR DeviceRequestCapacity ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension,
__in PSCSI_REQUEST_BLOCK  Srb,
__in PCDB  Cdb 
)

Definition at line 2098 of file storahci.c.

2103 {
2104  ULONG MaxLba, BytesPerLogicalSector;
2105  PREAD_CAPACITY_DATA ReadCapacity;
2106  PAHCI_PORT_EXTENSION PortExtension;
2107 
2108  AhciDebugPrint("DeviceRequestCapacity()\n");
2109 
2110  UNREFERENCED_PARAMETER(AdapterExtension);
2112 
2113  NT_ASSERT(Srb->DataBuffer != NULL);
2114  NT_ASSERT(IsPortValid(AdapterExtension, Srb->PathId));
2115 
2116 
2117  PortExtension = &AdapterExtension->PortExtension[Srb->PathId];
2118 
2119  if (PortExtension->DeviceParams.DeviceType == AHCI_DEVICE_TYPE_ATAPI)
2120  {
2121  return AhciATAPICommand(AdapterExtension, Srb, Cdb);
2122  }
2123 
2124  if (Cdb->CDB10.OperationCode == SCSIOP_READ_CAPACITY)
2125  {
2126  ReadCapacity = (PREAD_CAPACITY_DATA)Srb->DataBuffer;
2127 
2128  BytesPerLogicalSector = PortExtension->DeviceParams.BytesPerLogicalSector;
2129  MaxLba = (ULONG)PortExtension->DeviceParams.MaxLba.QuadPart - 1;
2130 
2131  // I trust you windows :D
2132  NT_ASSERT(Srb->DataTransferLength >= sizeof(READ_CAPACITY_DATA));
2133 
2134  // I trust you user :D
2135  NT_ASSERT(PortExtension->DeviceParams.MaxLba.QuadPart < (ULONG)-1);
2136 
2137  // Actually I don't trust anyone :p
2138  Srb->DataTransferLength = sizeof(READ_CAPACITY_DATA);
2139 
2140  REVERSE_BYTES(&ReadCapacity->BytesPerBlock, &BytesPerLogicalSector);
2141  REVERSE_BYTES(&ReadCapacity->LogicalBlockAddress, &MaxLba);
2142  }
2143  else
2144  {
2145  AhciDebugPrint("\tSCSIOP_READ_CAPACITY16 not supported\n");
2146  NT_ASSERT(FALSE);
2147  }
2148 
2149  return SRB_STATUS_SUCCESS;
2150 }// -- DeviceRequestCapacity();
__inline BOOLEAN IsPortValid(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in ULONG pathId)
Definition: storahci.c:2471
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define REVERSE_BYTES(Destination, Source)
Definition: scsi.h:2707
ULONG LogicalBlockAddress
Definition: cdrw_hw.h:1471
#define AHCI_DEVICE_TYPE_ATAPI
Definition: storahci.h:31
struct _AHCI_PORT_EXTENSION::@1298 DeviceParams
UCHAR AhciATAPICommand(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:1843
smooth NULL
Definition: ftsmooth.c:416
struct _READ_CAPACITY_DATA READ_CAPACITY_DATA
struct _READ_CAPACITY_DATA * PREAD_CAPACITY_DATA
#define SCSIOP_READ_CAPACITY
Definition: cdrw_hw.h:904
unsigned int ULONG
Definition: retypes.h:1
#define AhciDebugPrint(format,...)
Definition: storahci.h:85
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciHwStartIo().

◆ DeviceRequestComplete()

UCHAR DeviceRequestComplete ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension,
__in PSCSI_REQUEST_BLOCK  Srb,
__in PCDB  Cdb 
)

Definition at line 2166 of file storahci.c.

2171 {
2172  AhciDebugPrint("DeviceRequestComplete()\n");
2173 
2174  UNREFERENCED_PARAMETER(AdapterExtension);
2176 
2177  Srb->ScsiStatus = SCSISTAT_GOOD;
2178 
2179  return SRB_STATUS_SUCCESS;
2180 }// -- DeviceRequestComplete();
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define AhciDebugPrint(format,...)
Definition: storahci.h:85
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
#define SCSISTAT_GOOD
Definition: cdrw_hw.h:1078
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49

Referenced by AhciHwStartIo().

◆ DeviceRequestReadWrite()

UCHAR DeviceRequestReadWrite ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension,
__in PSCSI_REQUEST_BLOCK  Srb,
__in PCDB  Cdb 
)

Definition at line 1988 of file storahci.c.

1993 {
1994  BOOLEAN IsReading;
1995  ULONG64 StartOffset;
1996  PAHCI_SRB_EXTENSION SrbExtension;
1997  PAHCI_PORT_EXTENSION PortExtension;
1998  ULONG DataTransferLength, BytesPerSector, SectorCount;
1999 
2000  AhciDebugPrint("DeviceRequestReadWrite()\n");
2001 
2002  NT_ASSERT(IsPortValid(AdapterExtension, Srb->PathId));
2003  NT_ASSERT((Cdb->CDB10.OperationCode == SCSIOP_READ) || (Cdb->CDB10.OperationCode == SCSIOP_WRITE));
2004 
2005  SrbExtension = GetSrbExtension(Srb);
2006  PortExtension = &AdapterExtension->PortExtension[Srb->PathId];
2007 
2008  if (PortExtension->DeviceParams.DeviceType == AHCI_DEVICE_TYPE_ATAPI)
2009  {
2010  return AhciATAPICommand(AdapterExtension, Srb, Cdb);
2011  }
2012 
2013  DataTransferLength = Srb->DataTransferLength;
2014  BytesPerSector = PortExtension->DeviceParams.BytesPerLogicalSector;
2015 
2016  NT_ASSERT(BytesPerSector > 0);
2017 
2018  //ROUND_UP(DataTransferLength, BytesPerSector);
2019 
2020  SectorCount = DataTransferLength / BytesPerSector;
2021 
2022  Srb->DataTransferLength = SectorCount * BytesPerSector;
2023 
2024  StartOffset = AhciGetLba(Cdb, Srb->CdbLength);
2025  IsReading = (Cdb->CDB10.OperationCode == SCSIOP_READ);
2026 
2027  NT_ASSERT(SectorCount > 0);
2028 
2029  SrbExtension->AtaFunction = ATA_FUNCTION_ATA_READ;
2030  SrbExtension->Flags |= ATA_FLAGS_USE_DMA;
2031  SrbExtension->CompletionRoutine = NULL;
2032 
2033  if (IsReading)
2034  {
2035  SrbExtension->Flags |= ATA_FLAGS_DATA_IN;
2036  SrbExtension->CommandReg = IDE_COMMAND_READ_DMA;
2037  }
2038  else
2039  {
2040  SrbExtension->Flags |= ATA_FLAGS_DATA_OUT;
2041  SrbExtension->CommandReg = IDE_COMMAND_WRITE_DMA;
2042  }
2043 
2044  SrbExtension->FeaturesLow = 0;
2045  SrbExtension->LBA0 = (StartOffset >> 0) & 0xFF;
2046  SrbExtension->LBA1 = (StartOffset >> 8) & 0xFF;
2047  SrbExtension->LBA2 = (StartOffset >> 16) & 0xFF;
2048 
2049  SrbExtension->Device = (0xA0 | IDE_LBA_MODE);
2050 
2051  if (PortExtension->DeviceParams.Lba48BitMode)
2052  {
2053  SrbExtension->Flags |= ATA_FLAGS_48BIT_COMMAND;
2054 
2055  if (IsReading)
2056  {
2057  SrbExtension->CommandReg = IDE_COMMAND_READ_DMA_EXT;
2058  }
2059  else
2060  {
2061  SrbExtension->CommandReg = IDE_COMMAND_WRITE_DMA_EXT;
2062  }
2063 
2064  SrbExtension->LBA3 = (StartOffset >> 24) & 0xFF;
2065  SrbExtension->LBA4 = (StartOffset >> 32) & 0xFF;
2066  SrbExtension->LBA5 = (StartOffset >> 40) & 0xFF;
2067  }
2068  else
2069  {
2070  NT_ASSERT(FALSE);
2071  }
2072 
2073  SrbExtension->FeaturesHigh = 0;
2074  SrbExtension->SectorCountLow = (SectorCount >> 0) & 0xFF;
2075  SrbExtension->SectorCountHigh = (SectorCount >> 8) & 0xFF;
2076 
2077  NT_ASSERT(SectorCount < 0x100);
2078 
2079  SrbExtension->pSgl = (PLOCAL_SCATTER_GATHER_LIST)StorPortGetScatterGatherList(AdapterExtension, Srb);
2080 
2081  return SRB_STATUS_PENDING;
2082 }// -- DeviceRequestReadWrite();
__inline BOOLEAN IsPortValid(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in ULONG pathId)
Definition: storahci.c:2471
#define IDE_COMMAND_READ_DMA_EXT
Definition: ata.h:262
PLOCAL_SCATTER_GATHER_LIST pSgl
Definition: storahci.h:560
#define IDE_LBA_MODE
Definition: ata.h:255
#define ATA_FLAGS_DATA_IN
Definition: uata_ctl.h:222
__inline PAHCI_SRB_EXTENSION GetSrbExtension(__in PSCSI_REQUEST_BLOCK Srb)
Definition: storahci.c:2564
#define ATA_FUNCTION_ATA_READ
Definition: storahci.h:64
#define AHCI_DEVICE_TYPE_ATAPI
Definition: storahci.h:31
#define ATA_FLAGS_USE_DMA
Definition: uata_ctl.h:226
struct _AHCI_PORT_EXTENSION::@1298 DeviceParams
#define SCSIOP_READ
Definition: cdrw_hw.h:905
UCHAR AhciATAPICommand(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:1843
PAHCI_COMPLETION_ROUTINE CompletionRoutine
Definition: storahci.h:561
#define SRB_STATUS_PENDING
Definition: srb.h:332
#define SCSIOP_WRITE
Definition: cdrw_hw.h:906
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define IDE_COMMAND_WRITE_DMA_EXT
Definition: ata.h:267
unsigned __int64 ULONG64
Definition: imports.h:198
#define ATA_FLAGS_48BIT_COMMAND
Definition: uata_ctl.h:223
STORPORT_API PSTOR_SCATTER_GATHER_LIST NTAPI StorPortGetScatterGatherList(_In_ PVOID DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
Definition: storport.c:846
ULONG SectorCount
Definition: part_xbox.c:32
__inline ULONG64 AhciGetLba(__in PCDB Cdb, __in ULONG CdbLength)
Definition: storahci.c:2595
unsigned int ULONG
Definition: retypes.h:1
#define AhciDebugPrint(format,...)
Definition: storahci.h:85
#define IDE_COMMAND_READ_DMA
Definition: atapi.h:114
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define IDE_COMMAND_WRITE_DMA
Definition: atapi.h:115
#define ATA_FLAGS_DATA_OUT
Definition: uata_ctl.h:221
struct _LOCAL_SCATTER_GATHER_LIST * PLOCAL_SCATTER_GATHER_LIST
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciHwStartIo().

◆ DeviceRequestSense()

UCHAR DeviceRequestSense ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension,
__in PSCSI_REQUEST_BLOCK  Srb,
__in PCDB  Cdb 
)

Definition at line 1933 of file storahci.c.

1938 {
1939  PMODE_PARAMETER_HEADER ModeHeader;
1940  PAHCI_PORT_EXTENSION PortExtension;
1941 
1942  AhciDebugPrint("DeviceRequestSense()\n");
1943 
1944  NT_ASSERT(IsPortValid(AdapterExtension, Srb->PathId));
1945  NT_ASSERT(Cdb->CDB10.OperationCode == SCSIOP_MODE_SENSE);
1946 
1947  PortExtension = &AdapterExtension->PortExtension[Srb->PathId];
1948 
1949  if (PortExtension->DeviceParams.DeviceType == AHCI_DEVICE_TYPE_ATAPI)
1950  {
1951  return AhciATAPICommand(AdapterExtension, Srb, Cdb);
1952  }
1953 
1954  ModeHeader = (PMODE_PARAMETER_HEADER)Srb->DataBuffer;
1955 
1956  NT_ASSERT(ModeHeader != NULL);
1957 
1958  AhciZeroMemory((PCHAR)ModeHeader, Srb->DataTransferLength);
1959 
1960  ModeHeader->ModeDataLength = sizeof(MODE_PARAMETER_HEADER);
1961  ModeHeader->MediumType = 0;
1962  ModeHeader->DeviceSpecificParameter = 0;
1963  ModeHeader->BlockDescriptorLength = 0;
1964 
1965  if (Cdb->MODE_SENSE.PageCode == MODE_SENSE_CURRENT_VALUES)
1966  {
1967  ModeHeader->ModeDataLength = sizeof(MODE_PARAMETER_HEADER) + sizeof(MODE_PARAMETER_BLOCK);
1968  ModeHeader->BlockDescriptorLength = sizeof(MODE_PARAMETER_BLOCK);
1969  }
1970 
1971  return SRB_STATUS_SUCCESS;
1972 }// -- DeviceRequestSense();
signed char * PCHAR
Definition: retypes.h:7
__inline BOOLEAN IsPortValid(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in ULONG pathId)
Definition: storahci.c:2471
struct _MODE_PARAMETER_HEADER MODE_PARAMETER_HEADER
#define SCSIOP_MODE_SENSE
Definition: cdrw_hw.h:896
struct _MODE_PARAMETER_BLOCK MODE_PARAMETER_BLOCK
#define AHCI_DEVICE_TYPE_ATAPI
Definition: storahci.h:31
struct _AHCI_PORT_EXTENSION::@1298 DeviceParams
UCHAR AhciATAPICommand(__in PAHCI_ADAPTER_EXTENSION AdapterExtension, __in PSCSI_REQUEST_BLOCK Srb, __in PCDB Cdb)
Definition: storahci.c:1843
smooth NULL
Definition: ftsmooth.c:416
UCHAR DeviceSpecificParameter
Definition: cdrw_hw.h:2507
struct _MODE_PARAMETER_HEADER * PMODE_PARAMETER_HEADER
__inline VOID AhciZeroMemory(__out PCHAR Buffer, __in ULONG BufferSize)
Definition: storahci.c:2443
#define AhciDebugPrint(format,...)
Definition: storahci.h:85
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define MODE_SENSE_CURRENT_VALUES
Definition: cdrw_hw.h:859
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciHwStartIo().

◆ GetSrbExtension()

__inline PAHCI_SRB_EXTENSION GetSrbExtension ( __in PSCSI_REQUEST_BLOCK  Srb)

Definition at line 2564 of file storahci.c.

2567 {
2568  ULONG Offset;
2569  ULONG_PTR SrbExtension;
2570 
2571  SrbExtension = (ULONG_PTR)Srb->SrbExtension;
2572  Offset = SrbExtension % 128;
2573 
2574  // CommandTable should be 128 byte aligned
2575  if (Offset != 0)
2576  Offset = 128 - Offset;
2577 
2578  return (PAHCI_SRB_EXTENSION)(SrbExtension + Offset);
2579 }// -- PAHCI_SRB_EXTENSION();
uint32_t ULONG_PTR
Definition: typedefs.h:63
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49

Referenced by AhciATAPICommand(), AhciCommandCompletionDpcRoutine(), AhciCompleteIssuedSrb(), AhciProcessSrb(), DeviceInquiryRequest(), DeviceRequestReadWrite(), and InquiryCompletion().

◆ IsPortValid()

__inline BOOLEAN IsPortValid ( __in PAHCI_ADAPTER_EXTENSION  AdapterExtension,
__in ULONG  pathId 
)

Definition at line 2471 of file storahci.c.

2475 {
2477 
2478  if (pathId >= AdapterExtension->PortCount)
2479  {
2480  return FALSE;
2481  }
2482 
2483  return AdapterExtension->PortExtension[pathId].DeviceParams.IsActive;
2484 }// -- IsPortValid()
#define MAXIMUM_AHCI_PORT_COUNT
Definition: storahci.h:21
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciHwInterrupt(), AhciHwResetBus(), AhciHwStartIo(), AhciInterruptHandler(), DeviceInquiryRequest(), DeviceRequestCapacity(), DeviceRequestReadWrite(), and DeviceRequestSense().

◆ RemoveQueue()

__inline PVOID RemoveQueue ( __inout PAHCI_QUEUE  Queue)

Definition at line 2532 of file storahci.c.

2535 {
2536  PVOID Srb;
2537 
2538  NT_ASSERT(Queue->Head < MAXIMUM_QUEUE_BUFFER_SIZE);
2539  NT_ASSERT(Queue->Tail < MAXIMUM_QUEUE_BUFFER_SIZE);
2540 
2541  if (Queue->Head == Queue->Tail)
2542  return NULL;
2543 
2544  Srb = Queue->Buffer[Queue->Tail++];
2545  Queue->Tail %= MAXIMUM_QUEUE_BUFFER_SIZE;
2546 
2547  return Srb;
2548 }// -- RemoveQueue();
smooth NULL
Definition: ftsmooth.c:416
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define MAXIMUM_QUEUE_BUFFER_SIZE
Definition: storahci.h:24
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by AhciCommandCompletionDpcRoutine(), and AhciProcessIO().