[STORPORT] Enumerate attached devices

- Implement AcquireSpinlock, ReleaseSpinlock and GetExtendedFunctionTable notifications.
- Implement a bus scan routine, borrowed from scsiport.

Storport and storahci are now able to detect a disk device attached to a Virtual Box AHCI controller.
This commit is contained in:
Eric Kohl 2018-05-24 11:39:01 +02:00
parent 8c726ae0d2
commit f7c01906e7
8 changed files with 581 additions and 22 deletions

View file

@ -57,7 +57,14 @@ extern "C" {
#define CDB10GENERIC_LENGTH 10
#define CDB12GENERIC_LENGTH 12
#define INQUIRYDATABUFFERSIZE 36
#define INQUIRYDATABUFFERSIZE 36
#define SENSE_BUFFER_SIZE 18
#define MAX_SENSE_BUFFER_SIZE 255
#define FILE_DEVICE_SCSI 0x0000001b
#define IOCTL_SCSI_EXECUTE_IN ((FILE_DEVICE_SCSI << 16) + 0x0011)
#define IOCTL_SCSI_EXECUTE_OUT ((FILE_DEVICE_SCSI << 16) + 0x0012)
#define IOCTL_SCSI_EXECUTE_NONE ((FILE_DEVICE_SCSI << 16) + 0x0013)
#define MODE_PAGE_VENDOR_SPECIFIC 0x00
#define MODE_PAGE_ERROR_RECOVERY 0x01
@ -563,6 +570,12 @@ typedef enum _STOR_EVENT_ASSOCIATION_ENUM
StorEventInvalidAssociation
} STOR_EVENT_ASSOCIATION_ENUM;
typedef enum _GETSGSTATUS
{
SG_ALLOCATED = 0,
SG_BUFFER_TOO_SMALL
} GETSGSTATUS, *PGETSGSTATUS;
typedef struct _SCSI_REQUEST_BLOCK
{
USHORT Length;
@ -2182,6 +2195,64 @@ VOID
_In_ PSTOR_SCATTER_GATHER_LIST ScatterGather,
_In_ PVOID Context);
typedef
BOOLEAN
(NTAPI *PStorPortGetMessageInterruptInformation)(
_In_ PVOID HwDeviceExtension,
_In_ ULONG MessageId,
_Out_ PMESSAGE_INTERRUPT_INFORMATION InterruptInfo);
typedef
VOID
(NTAPI *PStorPortPutScatterGatherList)(
_In_ PVOID HwDeviceExtension,
_In_ PSTOR_SCATTER_GATHER_LIST ScatterGatherList,
_In_ BOOLEAN WriteToDevice);
typedef
GETSGSTATUS
(NTAPI *PStorPortBuildScatterGatherList)(
_In_ PVOID HwDeviceExtension,
_In_ PVOID Mdl,
_In_ PVOID CurrentVa,
_In_ ULONG Length,
_In_ PpostScaterGatherExecute ExecutionRoutine,
_In_ PVOID Context,
_In_ BOOLEAN WriteToDevice,
_Inout_ PVOID ScatterGatherBuffer,
_In_ ULONG ScatterGatherBufferLength);
typedef
VOID
(NTAPI *PStorPortFreePool)(
_In_ PVOID PMemory,
_In_ PVOID HwDeviceExtension,
_In_opt_ PVOID PMdl);
typedef
PVOID
(NTAPI *PStorPortAllocatePool)(
_In_ ULONG NumberOfBytes,
_In_ ULONG Tag,
_In_ PVOID HwDeviceExtension,
_Out_ PVOID *PMdl);
typedef
PVOID
(NTAPI *PStorPortGetSystemAddress)(
_In_ PSCSI_REQUEST_BLOCK Srb);
typedef struct _STORPORT_EXTENDED_FUNCTIONS
{
ULONG Version;
PStorPortGetMessageInterruptInformation GetMessageInterruptInformation;
PStorPortPutScatterGatherList PutScatterGatherList;
PStorPortBuildScatterGatherList BuildScatterGatherList;
PStorPortFreePool FreePool;
PStorPortAllocatePool AllocatePool;
PStorPortGetSystemAddress GetSystemAddress;
} STORPORT_EXTENDED_FUNCTIONS, *PSTORPORT_EXTENDED_FUNCTIONS;
typedef struct _HW_INITIALIZATION_DATA
{
ULONG HwInitializationDataSize;