ReactOS 0.4.15-dev-8428-g6910fa6
storport.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for storport.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS PortAddDriverInitData (PDRIVER_OBJECT_EXTENSION DriverExtension, PHW_INITIALIZATION_DATA HwInitializationData)
 
static VOID PortDeleteDriverInitData (PDRIVER_OBJECT_EXTENSION DriverExtension)
 
PHW_INITIALIZATION_DATA PortGetDriverInitData (PDRIVER_OBJECT_EXTENSION DriverExtension, INTERFACE_TYPE InterfaceType)
 
static VOID PortAcquireSpinLock (PFDO_DEVICE_EXTENSION DeviceExtension, STOR_SPINLOCK SpinLock, PVOID LockContext, PSTOR_LOCK_HANDLE LockHandle)
 
static VOID PortReleaseSpinLock (PFDO_DEVICE_EXTENSION DeviceExtension, PSTOR_LOCK_HANDLE LockHandle)
 
static NTSTATUS NTAPI PortAddDevice (_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT PhysicalDeviceObject)
 
static VOID NTAPI PortUnload (_In_ PDRIVER_OBJECT DriverObject)
 
static NTSTATUS NTAPI PortDispatchCreate (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI PortDispatchClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI PortDispatchDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI PortDispatchScsi (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI PortDispatchSystemControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI PortDispatchPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
static NTSTATUS NTAPI PortDispatchPower (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI DriverEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
 
STORPORT_API PUCHAR NTAPI StorPortAllocateRegistryBuffer (_In_ PVOID HwDeviceExtension, _In_ PULONG Length)
 
STORPORT_API BOOLEAN NTAPI StorPortBusy (_In_ PVOID HwDeviceExtension, _In_ ULONG RequestsToComplete)
 
STORPORT_API VOID NTAPI StorPortCompleteRequest (_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ UCHAR SrbStatus)
 
STORPORT_API ULONG NTAPI StorPortConvertPhysicalAddressToUlong (_In_ STOR_PHYSICAL_ADDRESS Address)
 
STORPORT_API STOR_PHYSICAL_ADDRESS NTAPI StorPortConvertUlongToPhysicalAddress (_In_ ULONG_PTR UlongAddress)
 
STORPORT_API VOID StorPortDebugPrint (_In_ ULONG DebugPrintLevel, _In_ PCHAR DebugMessage,...)
 
STORPORT_API BOOLEAN NTAPI StorPortDeviceBusy (_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ ULONG RequestsToComplete)
 
STORPORT_API BOOLEAN NTAPI StorPortDeviceReady (_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
 
STORPORT_API ULONG StorPortExtendedFunction (_In_ STORPORT_FUNCTION_CODE FunctionCode, _In_ PVOID HwDeviceExtension,...)
 
STORPORT_API VOID NTAPI StorPortFreeDeviceBase (_In_ PVOID HwDeviceExtension, _In_ PVOID MappedAddress)
 
STORPORT_API VOID NTAPI StorPortFreeRegistryBuffer (_In_ PVOID HwDeviceExtension, _In_ PUCHAR Buffer)
 
STORPORT_API ULONG NTAPI StorPortGetBusData (_In_ PVOID DeviceExtension, _In_ ULONG BusDataType, _In_ ULONG SystemIoBusNumber, _In_ ULONG SlotNumber, _Out_ _When_(Length !=0, _Out_writes_bytes_(Length)) PVOID Buffer, _In_ ULONG Length)
 
STORPORT_API PVOID NTAPI StorPortGetDeviceBase (_In_ PVOID HwDeviceExtension, _In_ INTERFACE_TYPE BusType, _In_ ULONG SystemIoBusNumber, _In_ STOR_PHYSICAL_ADDRESS IoAddress, _In_ ULONG NumberOfBytes, _In_ BOOLEAN InIoSpace)
 
STORPORT_API PVOID NTAPI StorPortGetLogicalUnit (_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
 
STORPORT_API STOR_PHYSICAL_ADDRESS NTAPI StorPortGetPhysicalAddress (_In_ PVOID HwDeviceExtension, _In_opt_ PSCSI_REQUEST_BLOCK Srb, _In_ PVOID VirtualAddress, _Out_ ULONG *Length)
 
STORPORT_API PSTOR_SCATTER_GATHER_LIST NTAPI StorPortGetScatterGatherList (_In_ PVOID DeviceExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
 
STORPORT_API PSCSI_REQUEST_BLOCK NTAPI StorPortGetSrb (_In_ PVOID DeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ LONG QueueTag)
 
STORPORT_API PVOID NTAPI StorPortGetUncachedExtension (_In_ PVOID HwDeviceExtension, _In_ PPORT_CONFIGURATION_INFORMATION ConfigInfo, _In_ ULONG NumberOfBytes)
 
STORPORT_API PVOID NTAPI StorPortGetVirtualAddress (_In_ PVOID HwDeviceExtension, _In_ STOR_PHYSICAL_ADDRESS PhysicalAddress)
 
STORPORT_API ULONG NTAPI StorPortInitialize (_In_ PVOID Argument1, _In_ PVOID Argument2, _In_ struct _HW_INITIALIZATION_DATA *HwInitializationData, _In_opt_ PVOID HwContext)
 
STORPORT_API VOID NTAPI StorPortLogError (_In_ PVOID HwDeviceExtension, _In_opt_ PSCSI_REQUEST_BLOCK Srb, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ ULONG ErrorCode, _In_ ULONG UniqueId)
 
STORPORT_API VOID NTAPI StorPortMoveMemory (_Out_writes_bytes_(Length) PVOID Destination, _In_reads_bytes_(Length) PVOID Source, _In_ ULONG Length)
 
STORPORT_API VOID StorPortNotification (_In_ SCSI_NOTIFICATION_TYPE NotificationType, _In_ PVOID HwDeviceExtension,...)
 
STORPORT_API BOOLEAN NTAPI StorPortPause (_In_ PVOID HwDeviceExtension, _In_ ULONG TimeOut)
 
STORPORT_API BOOLEAN NTAPI StorPortPauseDevice (_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ ULONG TimeOut)
 
STORPORT_API BOOLEAN NTAPI StorPortReady (_In_ PVOID HwDeviceExtension)
 
STORPORT_API BOOLEAN NTAPI StorPortRegistryRead (_In_ PVOID HwDeviceExtension, _In_ PUCHAR ValueName, _In_ ULONG Global, _In_ ULONG Type, _In_ PUCHAR Buffer, _In_ PULONG BufferLength)
 
STORPORT_API BOOLEAN NTAPI StorPortRegistryWrite (_In_ PVOID HwDeviceExtension, _In_ PUCHAR ValueName, _In_ ULONG Global, _In_ ULONG Type, _In_ PUCHAR Buffer, _In_ ULONG BufferLength)
 
STORPORT_API BOOLEAN NTAPI StorPortResume (_In_ PVOID HwDeviceExtension)
 
STORPORT_API BOOLEAN NTAPI StorPortResumeDevice (_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
 
STORPORT_API ULONG NTAPI StorPortSetBusDataByOffset (_In_ PVOID DeviceExtension, _In_ ULONG BusDataType, _In_ ULONG SystemIoBusNumber, _In_ ULONG SlotNumber, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Offset, _In_ ULONG Length)
 
STORPORT_API BOOLEAN NTAPI StorPortSetDeviceQueueDepth (_In_ PVOID HwDeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun, _In_ ULONG Depth)
 
STORPORT_API VOID NTAPI StorPortStallExecution (_In_ ULONG Delay)
 
STORPORT_API VOID NTAPI StorPortSynchronizeAccess (_In_ PVOID HwDeviceExtension, _In_ PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine, _In_opt_ PVOID Context)
 
STORPORT_API BOOLEAN NTAPI StorPortValidateRange (_In_ PVOID HwDeviceExtension, _In_ INTERFACE_TYPE BusType, _In_ ULONG SystemIoBusNumber, _In_ STOR_PHYSICAL_ADDRESS IoAddress, _In_ ULONG NumberOfBytes, _In_ BOOLEAN InIoSpace)
 

Variables

ULONG PortNumber = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file storport.c.

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PUNICODE_STRING  RegistryPath 
)

Definition at line 457 of file storport.c.

460{
461 DPRINT1("DriverEntry(%p %p)\n", DriverObject, RegistryPath);
462 return STATUS_SUCCESS;
463}
#define DPRINT1
Definition: precomp.h:8
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

◆ PortAcquireSpinLock()

static VOID PortAcquireSpinLock ( PFDO_DEVICE_EXTENSION  DeviceExtension,
STOR_SPINLOCK  SpinLock,
PVOID  LockContext,
PSTOR_LOCK_HANDLE  LockHandle 
)
static

Definition at line 105 of file storport.c.

110{
111 DPRINT1("PortAcquireSpinLock(%p %lu %p %p)\n",
112 DeviceExtension, SpinLock, LockContext, LockHandle);
113
114 LockHandle->Lock = SpinLock;
115
116 switch (SpinLock)
117 {
118 case DpcLock: /* 1, */
119 DPRINT1("DpcLock\n");
120 break;
121
122 case StartIoLock: /* 2 */
123 DPRINT1("StartIoLock\n");
124 break;
125
126 case InterruptLock: /* 3 */
127 DPRINT1("InterruptLock\n");
128 if (DeviceExtension->Interrupt == NULL)
129 LockHandle->Context.OldIrql = 0;
130 else
131 LockHandle->Context.OldIrql = KeAcquireInterruptSpinLock(DeviceExtension->Interrupt);
132 break;
133 }
134}
#define NULL
Definition: types.h:112
KIRQL NTAPI KeAcquireInterruptSpinLock(IN PKINTERRUPT Interrupt)
Definition: spinlock.c:154
@ StartIoLock
Definition: storport.h:486
@ InterruptLock
Definition: storport.h:487
@ DpcLock
Definition: storport.h:485
PKINTERRUPT Interrupt
Definition: parport.h:51
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:228
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:717

Referenced by StorPortNotification().

◆ PortAddDevice()

static NTSTATUS NTAPI PortAddDevice ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PDEVICE_OBJECT  PhysicalDeviceObject 
)
static

Definition at line 169 of file storport.c.

172{
173 PDRIVER_OBJECT_EXTENSION DriverObjectExtension;
174 PFDO_DEVICE_EXTENSION DeviceExtension = NULL;
175 WCHAR NameBuffer[80];
180
181 DPRINT1("PortAddDevice(%p %p)\n",
183
186
187 swprintf(NameBuffer,
188 L"\\Device\\RaidPort%lu",
189 PortNumber);
190 RtlInitUnicodeString(&DeviceName, NameBuffer);
191 PortNumber++;
192
193 DPRINT1("Creating device: %wZ\n", &DeviceName);
194
195 /* Create the port device */
197 sizeof(FDO_DEVICE_EXTENSION),
198 &DeviceName,
201 FALSE,
202 &Fdo);
203 if (!NT_SUCCESS(Status))
204 {
205 DPRINT1("IoCreateDevice() failed (Status 0x%08lx)\n", Status);
206 return Status;
207 }
208
209 DPRINT1("Created device: %wZ (%p)\n", &DeviceName, Fdo);
210
211 /* Initialize the device */
212 Fdo->Flags |= DO_DIRECT_IO;
213 Fdo->Flags |= DO_POWER_PAGABLE;
214
215 /* Initialize the device extension */
216 DeviceExtension = (PFDO_DEVICE_EXTENSION)Fdo->DeviceExtension;
217 RtlZeroMemory(DeviceExtension, sizeof(FDO_DEVICE_EXTENSION));
218
219 DeviceExtension->ExtensionType = FdoExtension;
220
221 DeviceExtension->Device = Fdo;
222 DeviceExtension->PhysicalDevice = PhysicalDeviceObject;
223
224 DeviceExtension->PnpState = dsStopped;
225
226 KeInitializeSpinLock(&DeviceExtension->PdoListLock);
227 InitializeListHead(&DeviceExtension->PdoListHead);
228
229 /* Attach the FDO to the device stack */
232 &DeviceExtension->LowerDevice);
233 if (!NT_SUCCESS(Status))
234 {
235 DPRINT1("IoAttachDeviceToDeviceStackSafe() failed (Status 0x%08lx)\n", Status);
237 return Status;
238 }
239
240 /* Insert the FDO to the drivers FDO list */
241 DriverObjectExtension = IoGetDriverObjectExtension(DriverObject,
243 ASSERT(DriverObjectExtension->ExtensionType == DriverExtension);
244
245 DeviceExtension->DriverExtension = DriverObjectExtension;
246
247 KeAcquireInStackQueuedSpinLock(&DriverObjectExtension->AdapterListLock,
248 &LockHandle);
249
250 InsertHeadList(&DriverObjectExtension->AdapterListHead,
251 &DeviceExtension->AdapterListEntry);
252 DriverObjectExtension->AdapterCount++;
253
255
256 /* The device has been initialized */
257 Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
258
259 DPRINT1("PortAddDevice() done (Status 0x%08lx)\n", Status);
260
261 return Status;
262}
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define swprintf
Definition: precomp.h:40
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
@ FdoExtension
Definition: precomp.h:48
#define InsertHeadList(ListHead, Entry)
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
Status
Definition: gdiplustypes.h:25
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:130
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
Definition: spinlock.c:166
@ dsStopped
Definition: isapnp.h:34
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
NTSTATUS NTAPI IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice, IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
Definition: device.c:980
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1904
#define L(x)
Definition: ntvdm.h:50
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:49
ULONG PortNumber
Definition: storport.c:18
LIST_ENTRY AdapterListHead
Definition: precomp.h:64
KSPIN_LOCK AdapterListLock
Definition: precomp.h:63
EXTENSION_TYPE ExtensionType
Definition: precomp.h:60
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
PDEVICE_OBJECT PhysicalDevice
Definition: precomp.h:96
LIST_ENTRY PdoListHead
Definition: precomp.h:116
KSPIN_LOCK PdoListLock
Definition: precomp.h:115
DEVICE_STATE PnpState
Definition: i8042prt.h:132
EXTENSION_TYPE ExtensionType
Definition: precomp.h:92
PDEVICE_OBJECT Device
Definition: precomp.h:94
LIST_ENTRY AdapterListEntry
Definition: precomp.h:99
PDRIVER_OBJECT_EXTENSION DriverExtension
Definition: precomp.h:97
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
#define DO_POWER_PAGABLE
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by StorPortInitialize().

◆ PortAddDriverInitData()

static NTSTATUS PortAddDriverInitData ( PDRIVER_OBJECT_EXTENSION  DriverExtension,
PHW_INITIALIZATION_DATA  HwInitializationData 
)
static

Definition at line 25 of file storport.c.

28{
29 PDRIVER_INIT_DATA InitData;
30
31 DPRINT1("PortAddDriverInitData()\n");
32
34 sizeof(DRIVER_INIT_DATA),
36 if (InitData == NULL)
37 return STATUS_NO_MEMORY;
38
39 RtlCopyMemory(&InitData->HwInitData,
42
43 InsertHeadList(&DriverExtension->InitDataListHead,
44 &InitData->Entry);
45
46 return STATUS_SUCCESS;
47}
#define TAG_INIT_DATA
Definition: precomp.h:27
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA * HwInitializationData
Definition: srb.h:906
HW_INITIALIZATION_DATA HwInitData
Definition: precomp.h:55
LIST_ENTRY Entry
Definition: precomp.h:54
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by StorPortInitialize().

◆ PortDeleteDriverInitData()

static VOID PortDeleteDriverInitData ( PDRIVER_OBJECT_EXTENSION  DriverExtension)
static

Definition at line 52 of file storport.c.

54{
55 PDRIVER_INIT_DATA InitData;
56 PLIST_ENTRY ListEntry;
57
58 DPRINT1("PortDeleteDriverInitData()\n");
59
60 ListEntry = DriverExtension->InitDataListHead.Flink;
61 while (ListEntry != &DriverExtension->InitDataListHead)
62 {
63 InitData = CONTAINING_RECORD(ListEntry,
65 Entry);
66
67 RemoveEntryList(&InitData->Entry);
68
69 ExFreePoolWithTag(InitData,
71
72 ListEntry = DriverExtension->InitDataListHead.Flink;
73 }
74}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by PortUnload().

◆ PortDispatchClose()

static NTSTATUS NTAPI PortDispatchClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 307 of file storport.c.

310{
311 DPRINT1("PortDispatchClose(%p %p)\n",
313
314 Irp->IoStatus.Status = STATUS_SUCCESS;
315 Irp->IoStatus.Information = 0;
316
318
319 return STATUS_SUCCESS;
320}
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by StorPortInitialize().

◆ PortDispatchCreate()

static NTSTATUS NTAPI PortDispatchCreate ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 288 of file storport.c.

291{
292 DPRINT1("PortDispatchCreate(%p %p)\n",
294
295 Irp->IoStatus.Status = STATUS_SUCCESS;
296 Irp->IoStatus.Information = FILE_OPENED;
297
299
300 return STATUS_SUCCESS;
301}
#define FILE_OPENED
Definition: nt_native.h:769

Referenced by StorPortInitialize().

◆ PortDispatchDeviceControl()

static NTSTATUS NTAPI PortDispatchDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 326 of file storport.c.

329{
330 DPRINT1("PortDispatchDeviceControl(%p %p)\n",
332
333 Irp->IoStatus.Status = STATUS_SUCCESS;
334 Irp->IoStatus.Information = 0;
335
337
338 return STATUS_SUCCESS;
339}

Referenced by StorPortInitialize().

◆ PortDispatchPnp()

static NTSTATUS NTAPI PortDispatchPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 400 of file storport.c.

403{
404 PFDO_DEVICE_EXTENSION DeviceExtension;
405
406 DPRINT1("PortDispatchPnp(%p %p)\n",
408
409 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
410 DPRINT1("ExtensionType: %u\n", DeviceExtension->ExtensionType);
411
412 switch (DeviceExtension->ExtensionType)
413 {
414 case FdoExtension:
416 Irp);
417
418 case PdoExtension:
420 Irp);
421
422 default:
423 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
424 Irp->IoStatus.Information = 0;
426 return STATUS_UNSUCCESSFUL;
427 }
428}
@ PdoExtension
Definition: precomp.h:49
NTSTATUS NTAPI PortFdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: fdo.c:596
NTSTATUS NTAPI PortPdoPnp(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: pdo.c:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by StorPortInitialize().

◆ PortDispatchPower()

static NTSTATUS NTAPI PortDispatchPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 434 of file storport.c.

437{
438 DPRINT1("PortDispatchPower(%p %p)\n",
440
441 Irp->IoStatus.Status = STATUS_SUCCESS;
442 Irp->IoStatus.Information = 0;
443
445
446 return STATUS_SUCCESS;
447}

Referenced by StorPortInitialize().

◆ PortDispatchScsi()

static NTSTATUS NTAPI PortDispatchScsi ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 345 of file storport.c.

348{
349 PFDO_DEVICE_EXTENSION DeviceExtension;
350
351 DPRINT1("PortDispatchScsi(%p %p)\n",
353
354 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
355 DPRINT1("ExtensionType: %u\n", DeviceExtension->ExtensionType);
356
357 switch (DeviceExtension->ExtensionType)
358 {
359 case FdoExtension:
361 Irp);
362
363 case PdoExtension:
365 Irp);
366
367 default:
368 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
369 Irp->IoStatus.Information = 0;
371 return STATUS_UNSUCCESSFUL;
372 }
373
374 return STATUS_SUCCESS;
375}
NTSTATUS NTAPI PortFdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: fdo.c:568
NTSTATUS NTAPI PortPdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: pdo.c:120

Referenced by StorPortInitialize().

◆ PortDispatchSystemControl()

static NTSTATUS NTAPI PortDispatchSystemControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 381 of file storport.c.

384{
385 DPRINT1("PortDispatchSystemControl(%p %p)\n",
387
388 Irp->IoStatus.Status = STATUS_SUCCESS;
389 Irp->IoStatus.Information = 0;
390
392
393 return STATUS_SUCCESS;
394}

Referenced by StorPortInitialize().

◆ PortGetDriverInitData()

PHW_INITIALIZATION_DATA PortGetDriverInitData ( PDRIVER_OBJECT_EXTENSION  DriverExtension,
INTERFACE_TYPE  InterfaceType 
)

Definition at line 78 of file storport.c.

81{
82 PDRIVER_INIT_DATA InitData;
83 PLIST_ENTRY ListEntry;
84
85 DPRINT1("PortGetDriverInitData()\n");
86
87 ListEntry = DriverExtension->InitDataListHead.Flink;
88 while (ListEntry != &DriverExtension->InitDataListHead)
89 {
90 InitData = CONTAINING_RECORD(ListEntry,
92 Entry);
94 return &InitData->HwInitData;
95
96 ListEntry = ListEntry->Flink;
97 }
98
99 return NULL;
100}
INTERFACE_TYPE AdapterInterfaceType
Definition: srb.h:565
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463

Referenced by PortFdoStartMiniport().

◆ PortReleaseSpinLock()

static VOID PortReleaseSpinLock ( PFDO_DEVICE_EXTENSION  DeviceExtension,
PSTOR_LOCK_HANDLE  LockHandle 
)
static

Definition at line 139 of file storport.c.

142{
143 DPRINT1("PortReleaseSpinLock(%p %p)\n",
144 DeviceExtension, LockHandle);
145
146 switch (LockHandle->Lock)
147 {
148 case DpcLock: /* 1, */
149 DPRINT1("DpcLock\n");
150 break;
151
152 case StartIoLock: /* 2 */
153 DPRINT1("StartIoLock\n");
154 break;
155
156 case InterruptLock: /* 3 */
157 DPRINT1("InterruptLock\n");
158 if (DeviceExtension->Interrupt != NULL)
159 KeReleaseInterruptSpinLock(DeviceExtension->Interrupt,
160 LockHandle->Context.OldIrql);
161 break;
162 }
163}
VOID NTAPI KeReleaseInterruptSpinLock(IN PKINTERRUPT Interrupt, IN KIRQL OldIrql)
Definition: spinlock.c:171

Referenced by StorPortNotification().

◆ PortUnload()

static VOID NTAPI PortUnload ( _In_ PDRIVER_OBJECT  DriverObject)
static

Definition at line 268 of file storport.c.

270{
272
273 DPRINT1("PortUnload(%p)\n",
275
278 if (DriverExtension != NULL)
279 {
281 }
282}
static VOID PortDeleteDriverInitData(PDRIVER_OBJECT_EXTENSION DriverExtension)
Definition: storport.c:52

Referenced by StorPortInitialize().

◆ StorPortAllocateRegistryBuffer()

STORPORT_API PUCHAR NTAPI StorPortAllocateRegistryBuffer ( _In_ PVOID  HwDeviceExtension,
_In_ PULONG  Length 
)

Definition at line 472 of file storport.c.

475{
476 DPRINT1("StorPortAllocateRegistryBuffer()\n");
478 return NULL;
479}
#define UNIMPLEMENTED
Definition: debug.h:118

◆ StorPortBusy()

STORPORT_API BOOLEAN NTAPI StorPortBusy ( _In_ PVOID  HwDeviceExtension,
_In_ ULONG  RequestsToComplete 
)

Definition at line 488 of file storport.c.

491{
492 DPRINT1("StorPortBuzy()\n");
494 return FALSE;
495}

◆ StorPortCompleteRequest()

STORPORT_API VOID NTAPI StorPortCompleteRequest ( _In_ PVOID  HwDeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun,
_In_ UCHAR  SrbStatus 
)

Definition at line 504 of file storport.c.

510{
511 DPRINT1("StorPortCompleteRequest()\n");
513}

◆ StorPortConvertPhysicalAddressToUlong()

STORPORT_API ULONG NTAPI StorPortConvertPhysicalAddressToUlong ( _In_ STOR_PHYSICAL_ADDRESS  Address)

Definition at line 522 of file storport.c.

524{
525 DPRINT1("StorPortConvertPhysicalAddressToUlong()\n");
526
527 return Address.u.LowPart;
528}
static WCHAR Address[46]
Definition: ping.c:68

◆ StorPortConvertUlongToPhysicalAddress()

STORPORT_API STOR_PHYSICAL_ADDRESS NTAPI StorPortConvertUlongToPhysicalAddress ( _In_ ULONG_PTR  UlongAddress)

Definition at line 537 of file storport.c.

539{
541
542 DPRINT1("StorPortConvertUlongToPhysicalAddress()\n");
543
544 Address.QuadPart = UlongAddress;
545 return Address;
546}

◆ StorPortDebugPrint()

STORPORT_API VOID StorPortDebugPrint ( _In_ ULONG  DebugPrintLevel,
_In_ PCHAR  DebugMessage,
  ... 
)

Definition at line 554 of file storport.c.

558{
559 va_list ap;
560
561 va_start(ap, DebugMessage);
562 vDbgPrintExWithPrefix("STORMINI: ", 0x58, DebugPrintLevel, DebugMessage, ap);
563 va_end(ap);
564}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
NTSYSAPI NTSTATUS WINAPI vDbgPrintExWithPrefix(LPCSTR, ULONG, ULONG, LPCSTR, __ms_va_list)
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

◆ StorPortDeviceBusy()

STORPORT_API BOOLEAN NTAPI StorPortDeviceBusy ( _In_ PVOID  HwDeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun,
_In_ ULONG  RequestsToComplete 
)

Definition at line 573 of file storport.c.

579{
580 DPRINT1("StorPortDeviceBusy()\n");
582 return FALSE;
583}

◆ StorPortDeviceReady()

STORPORT_API BOOLEAN NTAPI StorPortDeviceReady ( _In_ PVOID  HwDeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun 
)

Definition at line 592 of file storport.c.

597{
598 DPRINT1("StorPortDeviceReady()\n");
600 return FALSE;
601}

◆ StorPortExtendedFunction()

◆ StorPortFreeDeviceBase()

STORPORT_API VOID NTAPI StorPortFreeDeviceBase ( _In_ PVOID  HwDeviceExtension,
_In_ PVOID  MappedAddress 
)

Definition at line 627 of file storport.c.

630{
631 DPRINT1("StorPortFreeDeviceBase(%p %p)\n",
632 HwDeviceExtension, MappedAddress);
633}

◆ StorPortFreeRegistryBuffer()

STORPORT_API VOID NTAPI StorPortFreeRegistryBuffer ( _In_ PVOID  HwDeviceExtension,
_In_ PUCHAR  Buffer 
)

Definition at line 642 of file storport.c.

645{
646 DPRINT1("StorPortFreeRegistryBuffer()\n");
648}

◆ StorPortGetBusData()

STORPORT_API ULONG NTAPI StorPortGetBusData ( _In_ PVOID  DeviceExtension,
_In_ ULONG  BusDataType,
_In_ ULONG  SystemIoBusNumber,
_In_ ULONG  SlotNumber,
_Out_ _When_(Length !=0, _Out_writes_bytes_(Length)) PVOID  Buffer,
_In_ ULONG  Length 
)

Definition at line 657 of file storport.c.

664{
665 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
668
669 DPRINT1("StorPortGetBusData(%p %lu %lu %lu %p %lu)\n",
670 DeviceExtension, BusDataType, SystemIoBusNumber, SlotNumber, Buffer, Length);
671
672 /* Get the miniport extension */
673 MiniportExtension = CONTAINING_RECORD(DeviceExtension,
675 HwDeviceExtension);
676 DPRINT1("DeviceExtension %p MiniportExtension %p\n",
677 DeviceExtension, MiniportExtension);
678
679 Interface = &MiniportExtension->Miniport->DeviceExtension->BusInterface;
680
681 if (BusDataType == 4)
682 BusDataType = 0;
683
684 ReturnLength = Interface->GetBusData(Interface->Context,
685 BusDataType,
686 Buffer,
687 0,
688 Length);
689 DPRINT1("ReturnLength: %lu\n", ReturnLength);
690
691 return ReturnLength;
692}
Definition: bufpool.h:45
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
struct _MINIPORT * Miniport
Definition: precomp.h:72
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68

Referenced by AhciHwFindAdapter().

◆ StorPortGetDeviceBase()

STORPORT_API PVOID NTAPI StorPortGetDeviceBase ( _In_ PVOID  HwDeviceExtension,
_In_ INTERFACE_TYPE  BusType,
_In_ ULONG  SystemIoBusNumber,
_In_ STOR_PHYSICAL_ADDRESS  IoAddress,
_In_ ULONG  NumberOfBytes,
_In_ BOOLEAN  InIoSpace 
)

Definition at line 701 of file storport.c.

708{
709 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
711 PVOID MappedAddress;
713
714 DPRINT1("StorPortGetDeviceBase(%p %lu %lu 0x%I64x %lu %u)\n",
715 HwDeviceExtension, BusType, SystemIoBusNumber, IoAddress.QuadPart, NumberOfBytes, InIoSpace);
716
717 /* Get the miniport extension */
718 MiniportExtension = CONTAINING_RECORD(HwDeviceExtension,
720 HwDeviceExtension);
721 DPRINT1("HwDeviceExtension %p MiniportExtension %p\n",
722 HwDeviceExtension, MiniportExtension);
723
724 if (!TranslateResourceListAddress(MiniportExtension->Miniport->DeviceExtension,
725 BusType,
726 SystemIoBusNumber,
727 IoAddress,
729 InIoSpace,
731 {
732 DPRINT1("Checkpoint!\n");
733 return NULL;
734 }
735
736 DPRINT1("Translated Address: 0x%I64x\n", TranslatedAddress.QuadPart);
737
738 /* In I/O space */
739 if (InIoSpace)
740 {
741 DPRINT1("Translated Address: %p\n", (PVOID)(ULONG_PTR)TranslatedAddress.QuadPart);
743 }
744
745 /* In memory space */
746 MappedAddress = MmMapIoSpace(TranslatedAddress,
748 FALSE);
749 DPRINT1("Mapped Address: %p\n", MappedAddress);
750
751 Status = AllocateAddressMapping(&MiniportExtension->Miniport->DeviceExtension->MappedAddressList,
752 IoAddress,
753 MappedAddress,
755 SystemIoBusNumber);
756 if (!NT_SUCCESS(Status))
757 {
758 DPRINT1("Checkpoint!\n");
759 MappedAddress = NULL;
760 }
761
762 DPRINT1("Mapped Address: %p\n", MappedAddress);
763 return MappedAddress;
764}
#define ULONG_PTR
Definition: config.h:101
NTSTATUS AllocateAddressMapping(PMAPPED_ADDRESS *MappedAddressList, STOR_PHYSICAL_ADDRESS IoAddress, PVOID MappedAddress, ULONG NumberOfBytes, ULONG BusNumber)
Definition: misc.c:290
BOOLEAN TranslateResourceListAddress(PFDO_DEVICE_EXTENSION DeviceExtension, INTERFACE_TYPE BusType, ULONG SystemIoBusNumber, STOR_PHYSICAL_ADDRESS IoAddress, ULONG NumberOfBytes, BOOLEAN InIoSpace, PPHYSICAL_ADDRESS TranslatedAddress)
Definition: misc.c:172
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
uint32_t ULONG_PTR
Definition: typedefs.h:65
LONGLONG QuadPart
Definition: typedefs.h:114
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:159
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

Referenced by AhciHwFindAdapter().

◆ StorPortGetLogicalUnit()

STORPORT_API PVOID NTAPI StorPortGetLogicalUnit ( _In_ PVOID  HwDeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun 
)

Definition at line 773 of file storport.c.

778{
779 DPRINT1("StorPortGetLogicalUnit()\n");
781 return NULL;
782}

◆ StorPortGetPhysicalAddress()

STORPORT_API STOR_PHYSICAL_ADDRESS NTAPI StorPortGetPhysicalAddress ( _In_ PVOID  HwDeviceExtension,
_In_opt_ PSCSI_REQUEST_BLOCK  Srb,
_In_ PVOID  VirtualAddress,
_Out_ ULONG Length 
)

Definition at line 791 of file storport.c.

796{
797 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
798 PFDO_DEVICE_EXTENSION DeviceExtension;
801
802 DPRINT1("StorPortGetPhysicalAddress(%p %p %p %p)\n",
803 HwDeviceExtension, Srb, VirtualAddress, Length);
804
805 /* Get the miniport extension */
806 MiniportExtension = CONTAINING_RECORD(HwDeviceExtension,
808 HwDeviceExtension);
809 DPRINT1("HwDeviceExtension %p MiniportExtension %p\n",
810 HwDeviceExtension, MiniportExtension);
811
812 DeviceExtension = MiniportExtension->Miniport->DeviceExtension;
813
814 /* Inside of the uncached extension? */
817 {
819
821 *Length = DeviceExtension->UncachedExtensionSize - Offset;
822
823 return PhysicalAddress;
824 }
825
826 // FIXME
827
828
830 *Length = 1;
831// UNIMPLEMENTED;
832
833// *Length = 0;
834// PhysicalAddress.QuadPart = (LONGLONG)0;
835
836 return PhysicalAddress;
837}
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
PHYSICAL_ADDRESS NTAPI MmGetPhysicalAddress(IN PVOID Address)
Definition: stubs.c:685
PVOID UncachedExtensionVirtualBase
Definition: precomp.h:108
ULONG UncachedExtensionSize
Definition: precomp.h:110
PHYSICAL_ADDRESS UncachedExtensionPhysicalBase
Definition: precomp.h:109
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098

Referenced by AhciPortInitialize(), and AhciProcessSrb().

◆ StorPortGetScatterGatherList()

STORPORT_API PSTOR_SCATTER_GATHER_LIST NTAPI StorPortGetScatterGatherList ( _In_ PVOID  DeviceExtension,
_In_ PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 846 of file storport.c.

849{
850 DPRINT1("StorPortGetScatterGatherList()\n");
852 return NULL;
853}

Referenced by AhciATAPICommand(), and DeviceRequestReadWrite().

◆ StorPortGetSrb()

STORPORT_API PSCSI_REQUEST_BLOCK NTAPI StorPortGetSrb ( _In_ PVOID  DeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun,
_In_ LONG  QueueTag 
)

Definition at line 862 of file storport.c.

868{
869 DPRINT("StorPortGetSrb()\n");
870 return NULL;
871}
#define DPRINT
Definition: sndvol32.h:73

◆ StorPortGetUncachedExtension()

STORPORT_API PVOID NTAPI StorPortGetUncachedExtension ( _In_ PVOID  HwDeviceExtension,
_In_ PPORT_CONFIGURATION_INFORMATION  ConfigInfo,
_In_ ULONG  NumberOfBytes 
)

Definition at line 880 of file storport.c.

884{
885 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
886 PFDO_DEVICE_EXTENSION DeviceExtension;
887 PHYSICAL_ADDRESS LowestAddress, HighestAddress, Alignment;
888
889 DPRINT1("StorPortGetUncachedExtension(%p %p %lu)\n",
890 HwDeviceExtension, ConfigInfo, NumberOfBytes);
891
892 /* Get the miniport extension */
893 MiniportExtension = CONTAINING_RECORD(HwDeviceExtension,
895 HwDeviceExtension);
896 DPRINT1("HwDeviceExtension %p MiniportExtension %p\n",
897 HwDeviceExtension, MiniportExtension);
898
899 DeviceExtension = MiniportExtension->Miniport->DeviceExtension;
900
901 /* Return the uncached extension base address if we already have one */
902 if (DeviceExtension->UncachedExtensionVirtualBase != NULL)
903 return DeviceExtension->UncachedExtensionVirtualBase;
904
905 // FIXME: Set DMA stuff here?
906
907 /* Allocate the uncached extension */
908 Alignment.QuadPart = 0;
909 LowestAddress.QuadPart = 0;
910 HighestAddress.QuadPart = 0x00000000FFFFFFFF;
912 LowestAddress,
913 HighestAddress,
914 Alignment,
915 MmCached);
916 if (DeviceExtension->UncachedExtensionVirtualBase == NULL)
917 return NULL;
918
920 DeviceExtension->UncachedExtensionSize = NumberOfBytes;
921
922 return DeviceExtension->UncachedExtensionVirtualBase;
923}
PVOID NTAPI MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS LowestAcceptableAddress OPTIONAL, IN PHYSICAL_ADDRESS HighestAcceptableAddress, IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, IN MEMORY_CACHING_TYPE CacheType OPTIONAL)
Definition: contmem.c:574
union Alignment_ Alignment
@ MmCached
Definition: mmtypes.h:130

Referenced by AhciAllocateResourceForAdapter().

◆ StorPortGetVirtualAddress()

STORPORT_API PVOID NTAPI StorPortGetVirtualAddress ( _In_ PVOID  HwDeviceExtension,
_In_ STOR_PHYSICAL_ADDRESS  PhysicalAddress 
)

Definition at line 932 of file storport.c.

935{
936 DPRINT1("StorPortGetVirtualAddress(%p %I64x)\n",
937 HwDeviceExtension, PhysicalAddress.QuadPart);
939 return NULL;
940}

◆ StorPortInitialize()

STORPORT_API ULONG NTAPI StorPortInitialize ( _In_ PVOID  Argument1,
_In_ PVOID  Argument2,
_In_ struct _HW_INITIALIZATION_DATA HwInitializationData,
_In_opt_ PVOID  HwContext 
)

Definition at line 949 of file storport.c.

954{
957 PDRIVER_OBJECT_EXTENSION DriverObjectExtension;
959
960 DPRINT1("StorPortInitialize(%p %p %p %p)\n",
962
963 DPRINT1("HwInitializationDataSize: %lu\n", HwInitializationData->HwInitializationDataSize);
964 DPRINT1("AdapterInterfaceType: %u\n", HwInitializationData->AdapterInterfaceType);
965 DPRINT1("HwInitialize: %p\n", HwInitializationData->HwInitialize);
966 DPRINT1("HwStartIo: %p\n", HwInitializationData->HwStartIo);
967 DPRINT1("HwInterrupt: %p\n", HwInitializationData->HwInterrupt);
968 DPRINT1("HwFindAdapter: %p\n", HwInitializationData->HwFindAdapter);
969 DPRINT1("HwResetBus: %p\n", HwInitializationData->HwResetBus);
970 DPRINT1("HwDmaStarted: %p\n", HwInitializationData->HwDmaStarted);
971 DPRINT1("HwAdapterState: %p\n", HwInitializationData->HwAdapterState);
972 DPRINT1("DeviceExtensionSize: %lu\n", HwInitializationData->DeviceExtensionSize);
973 DPRINT1("SpecificLuExtensionSize: %lu\n", HwInitializationData->SpecificLuExtensionSize);
974 DPRINT1("SrbExtensionSize: %lu\n", HwInitializationData->SrbExtensionSize);
975 DPRINT1("NumberOfAccessRanges: %lu\n", HwInitializationData->NumberOfAccessRanges);
976
977 /* Check parameters */
978 if ((DriverObject == NULL) ||
979 (RegistryPath == NULL) ||
981 {
982 DPRINT1("Invalid parameter!\n");
984 }
985
986 /* Check initialization data */
987 if ((HwInitializationData->HwInitializationDataSize < sizeof(HW_INITIALIZATION_DATA)) ||
988 (HwInitializationData->HwInitialize == NULL) ||
989 (HwInitializationData->HwStartIo == NULL) ||
990 (HwInitializationData->HwFindAdapter == NULL) ||
991 (HwInitializationData->HwResetBus == NULL))
992 {
993 DPRINT1("Revision mismatch!\n");
995 }
996
997 DriverObjectExtension = IoGetDriverObjectExtension(DriverObject,
999 if (DriverObjectExtension == NULL)
1000 {
1001 DPRINT1("No driver object extension!\n");
1002
1006 (PVOID *)&DriverObjectExtension);
1007 if (!NT_SUCCESS(Status))
1008 {
1009 DPRINT1("IoAllocateDriverObjectExtension() failed (Status 0x%08lx)\n", Status);
1010 return Status;
1011 }
1012
1013 DPRINT1("Driver object extension created!\n");
1014
1015 /* Initialize the driver object extension */
1016 RtlZeroMemory(DriverObjectExtension,
1017 sizeof(DRIVER_OBJECT_EXTENSION));
1018
1019 DriverObjectExtension->ExtensionType = DriverExtension;
1020 DriverObjectExtension->DriverObject = DriverObject;
1021
1022 InitializeListHead(&DriverObjectExtension->AdapterListHead);
1023 KeInitializeSpinLock(&DriverObjectExtension->AdapterListLock);
1024
1025 InitializeListHead(&DriverObjectExtension->InitDataListHead);
1026
1027 /* Set handlers */
1028 DriverObject->DriverExtension->AddDevice = PortAddDevice;
1029// DriverObject->DriverStartIo = PortStartIo;
1030 DriverObject->DriverUnload = PortUnload;
1034 DriverObject->MajorFunction[IRP_MJ_SCSI] = PortDispatchScsi;
1037 DriverObject->MajorFunction[IRP_MJ_PNP] = PortDispatchPnp;
1038 }
1039
1040 /* Add the initialzation data to the driver extension */
1041 Status = PortAddDriverInitData(DriverObjectExtension,
1043
1044 DPRINT1("StorPortInitialize() done (Status 0x%08lx)\n", Status);
1045
1046 return Status;
1047}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_In_ PVOID Argument2
Definition: classpnp.h:721
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1826
#define STATUS_REVISION_MISMATCH
Definition: ntstatus.h:325
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA _In_ PVOID HwContext
Definition: srb.h:907
static NTSTATUS NTAPI PortDispatchSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:381
static NTSTATUS NTAPI PortDispatchClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:307
static NTSTATUS NTAPI PortDispatchPower(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:434
static NTSTATUS NTAPI PortDispatchDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:326
static NTSTATUS PortAddDriverInitData(PDRIVER_OBJECT_EXTENSION DriverExtension, PHW_INITIALIZATION_DATA HwInitializationData)
Definition: storport.c:25
static NTSTATUS NTAPI PortDispatchPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:400
static NTSTATUS NTAPI PortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:345
static NTSTATUS NTAPI PortDispatchCreate(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: storport.c:288
static VOID NTAPI PortUnload(_In_ PDRIVER_OBJECT DriverObject)
Definition: storport.c:268
static NTSTATUS NTAPI PortAddDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT PhysicalDeviceObject)
Definition: storport.c:169
LIST_ENTRY InitDataListHead
Definition: precomp.h:67
PDRIVER_OBJECT DriverObject
Definition: precomp.h:61
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:696
#define IRP_MJ_SCSI
struct _DRIVER_OBJECT * PDRIVER_OBJECT
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_POWER

Referenced by DriverEntry().

◆ StorPortLogError()

STORPORT_API VOID NTAPI StorPortLogError ( _In_ PVOID  HwDeviceExtension,
_In_opt_ PSCSI_REQUEST_BLOCK  Srb,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun,
_In_ ULONG  ErrorCode,
_In_ ULONG  UniqueId 
)

Definition at line 1056 of file storport.c.

1064{
1065 DPRINT1("ScsiPortLogError() called\n");
1066 DPRINT1("PathId: 0x%02x TargetId: 0x%02x Lun: 0x%02x ErrorCode: 0x%08lx UniqueId: 0x%08lx\n",
1067 PathId, TargetId, Lun, ErrorCode, UniqueId);
1068
1069 DPRINT1("ScsiPortLogError() done\n");
1070}
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1315
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1313
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1314
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436

◆ StorPortMoveMemory()

STORPORT_API VOID NTAPI StorPortMoveMemory ( _Out_writes_bytes_(Length) PVOID  Destination,
_In_reads_bytes_(Length) PVOID  Source,
_In_ ULONG  Length 
)

Definition at line 1079 of file storport.c.

1083{
1085}
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3016
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

◆ StorPortNotification()

STORPORT_API VOID StorPortNotification ( _In_ SCSI_NOTIFICATION_TYPE  NotificationType,
_In_ PVOID  HwDeviceExtension,
  ... 
)

Definition at line 1093 of file storport.c.

1097{
1098 PMINIPORT_DEVICE_EXTENSION MiniportExtension = NULL;
1099 PFDO_DEVICE_EXTENSION DeviceExtension = NULL;
1100 PHW_PASSIVE_INITIALIZE_ROUTINE HwPassiveInitRoutine;
1101 PSTORPORT_EXTENDED_FUNCTIONS *ppExtendedFunctions;
1103 PSTOR_DPC Dpc;
1104 PHW_DPC_ROUTINE HwDpcRoutine;
1105 va_list ap;
1106
1108 PVOID LockContext;
1111
1112 DPRINT1("StorPortNotification(%x %p)\n",
1113 NotificationType, HwDeviceExtension);
1114
1115 /* Get the miniport extension */
1116 if (HwDeviceExtension != NULL)
1117 {
1118 MiniportExtension = CONTAINING_RECORD(HwDeviceExtension,
1120 HwDeviceExtension);
1121 DPRINT1("HwDeviceExtension %p MiniportExtension %p\n",
1122 HwDeviceExtension, MiniportExtension);
1123
1124 DeviceExtension = MiniportExtension->Miniport->DeviceExtension;
1125 }
1126
1127 va_start(ap, HwDeviceExtension);
1128
1129 switch (NotificationType)
1130 {
1131 case RequestComplete:
1132 DPRINT1("RequestComplete\n");
1134 DPRINT1("Srb %p\n", Srb);
1135 if (Srb->OriginalRequest != NULL)
1136 {
1137 DPRINT1("Need to complete the IRP!\n");
1138
1139 }
1140 break;
1141
1143 DPRINT1("GetExtendedFunctionTable\n");
1145 if (ppExtendedFunctions != NULL)
1146 *ppExtendedFunctions = NULL; /* FIXME */
1147 break;
1148
1150 DPRINT1("EnablePassiveInitialization\n");
1152 DPRINT1("HwPassiveInitRoutine %p\n", HwPassiveInitRoutine);
1154
1155 *Result = FALSE;
1156
1157 if ((DeviceExtension != NULL) &&
1158 (DeviceExtension->HwPassiveInitRoutine == NULL))
1159 {
1160 DeviceExtension->HwPassiveInitRoutine = HwPassiveInitRoutine;
1161 *Result = TRUE;
1162 }
1163 break;
1164
1165 case InitializeDpc:
1166 DPRINT1("InitializeDpc\n");
1168 DPRINT1("Dpc %p\n", Dpc);
1169 HwDpcRoutine = (PHW_DPC_ROUTINE)va_arg(ap, PHW_DPC_ROUTINE);
1170 DPRINT1("HwDpcRoutine %p\n", HwDpcRoutine);
1171
1172 KeInitializeDpc((PRKDPC)&Dpc->Dpc,
1173 (PKDEFERRED_ROUTINE)HwDpcRoutine,
1174 (PVOID)DeviceExtension);
1175 KeInitializeSpinLock(&Dpc->Lock);
1176 break;
1177
1178 case AcquireSpinLock:
1179 DPRINT1("AcquireSpinLock\n");
1181 DPRINT1("SpinLock %lu\n", SpinLock);
1182 LockContext = (PVOID)va_arg(ap, PVOID);
1183 DPRINT1("LockContext %p\n", LockContext);
1185 DPRINT1("LockHandle %p\n", LockHandle);
1186 PortAcquireSpinLock(DeviceExtension,
1187 SpinLock,
1188 LockContext,
1189 LockHandle);
1190 break;
1191
1192 case ReleaseSpinLock:
1193 DPRINT1("ReleaseSpinLock\n");
1195 DPRINT1("LockHandle %p\n", LockHandle);
1196 PortReleaseSpinLock(DeviceExtension,
1197 LockHandle);
1198 break;
1199
1200 default:
1201 DPRINT1("Unsupported Notification %lx\n", NotificationType);
1202 break;
1203 }
1204
1205 va_end(ap);
1206}
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define TRUE
Definition: types.h:120
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
struct _SCSI_REQUEST_BLOCK * PSCSI_REQUEST_BLOCK
@ RequestComplete
Definition: srb.h:531
static VOID PortReleaseSpinLock(PFDO_DEVICE_EXTENSION DeviceExtension, PSTOR_LOCK_HANDLE LockHandle)
Definition: storport.c:139
static VOID PortAcquireSpinLock(PFDO_DEVICE_EXTENSION DeviceExtension, STOR_SPINLOCK SpinLock, PVOID LockContext, PSTOR_LOCK_HANDLE LockHandle)
Definition: storport.c:105
enum _STOR_SPINLOCK STOR_SPINLOCK
BOOLEAN(* PHW_PASSIVE_INITIALIZE_ROUTINE)(_In_ PVOID DeviceExtension)
Definition: storport.h:2254
VOID(* PHW_DPC_ROUTINE)(_In_ PSTOR_DPC Dpc, _In_ PVOID HwDeviceExtension, _In_ PVOID SystemArgument1, _In_ PVOID SystemArgument2)
Definition: storport.h:2259
struct _STOR_LOCK_HANDLE * PSTOR_LOCK_HANDLE
@ InitializeDpc
Definition: storport.h:526
@ AcquireSpinLock
Definition: storport.h:528
@ ReleaseSpinLock
Definition: storport.h:529
@ GetExtendedFunctionTable
Definition: storport.h:524
@ EnablePassiveInitialization
Definition: storport.h:525
struct _STOR_DPC * PSTOR_DPC
PHW_PASSIVE_INITIALIZE_ROUTINE HwPassiveInitRoutine
Definition: precomp.h:111
Definition: ketypes.h:699
PVOID OriginalRequest
Definition: srb.h:266
unsigned char * PBOOLEAN
Definition: typedefs.h:53
void * PVOID
Definition: typedefs.h:50
_In_ WDF_SPECIAL_FILE_TYPE NotificationType
Definition: wdfdevice.h:1024
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:112
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
KDEFERRED_ROUTINE * PKDEFERRED_ROUTINE
Definition: ketypes.h:690

Referenced by AhciCommandCompletionDpcRoutine(), AhciCompleteIssuedSrb(), AhciHwStartIo(), StorPortAcquireSpinLock(), StorPortEnablePassiveInitialization(), StorPortInitializeDpc(), StorPortIssueDpc(), and StorPortReleaseSpinLock().

◆ StorPortPause()

STORPORT_API BOOLEAN NTAPI StorPortPause ( _In_ PVOID  HwDeviceExtension,
_In_ ULONG  TimeOut 
)

Definition at line 1215 of file storport.c.

1218{
1219 DPRINT1("StorPortPause()\n");
1221 return FALSE;
1222}

◆ StorPortPauseDevice()

STORPORT_API BOOLEAN NTAPI StorPortPauseDevice ( _In_ PVOID  HwDeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun,
_In_ ULONG  TimeOut 
)

Definition at line 1231 of file storport.c.

1237{
1238 DPRINT1("StorPortPauseDevice()\n");
1240 return FALSE;
1241}

◆ StorPortReady()

STORPORT_API BOOLEAN NTAPI StorPortReady ( _In_ PVOID  HwDeviceExtension)

Definition at line 1269 of file storport.c.

1271{
1272 DPRINT1("StorPortReady()\n");
1274 return FALSE;
1275}

◆ StorPortRegistryRead()

STORPORT_API BOOLEAN NTAPI StorPortRegistryRead ( _In_ PVOID  HwDeviceExtension,
_In_ PUCHAR  ValueName,
_In_ ULONG  Global,
_In_ ULONG  Type,
_In_ PUCHAR  Buffer,
_In_ PULONG  BufferLength 
)

Definition at line 1284 of file storport.c.

1291{
1292 DPRINT1("StorPortRegistryRead()\n");
1294 return FALSE;
1295}

◆ StorPortRegistryWrite()

STORPORT_API BOOLEAN NTAPI StorPortRegistryWrite ( _In_ PVOID  HwDeviceExtension,
_In_ PUCHAR  ValueName,
_In_ ULONG  Global,
_In_ ULONG  Type,
_In_ PUCHAR  Buffer,
_In_ ULONG  BufferLength 
)

Definition at line 1304 of file storport.c.

1311{
1312 DPRINT1("StorPortRegistryWrite()\n");
1314 return FALSE;
1315}

◆ StorPortResume()

STORPORT_API BOOLEAN NTAPI StorPortResume ( _In_ PVOID  HwDeviceExtension)

Definition at line 1324 of file storport.c.

1326{
1327 DPRINT1("StorPortResume()\n");
1329 return FALSE;
1330}

◆ StorPortResumeDevice()

STORPORT_API BOOLEAN NTAPI StorPortResumeDevice ( _In_ PVOID  HwDeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun 
)

Definition at line 1339 of file storport.c.

1344{
1345 DPRINT1("StorPortResumeDevice()\n");
1347 return FALSE;
1348}

◆ StorPortSetBusDataByOffset()

STORPORT_API ULONG NTAPI StorPortSetBusDataByOffset ( _In_ PVOID  DeviceExtension,
_In_ ULONG  BusDataType,
_In_ ULONG  SystemIoBusNumber,
_In_ ULONG  SlotNumber,
_In_reads_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Offset,
_In_ ULONG  Length 
)

Definition at line 1357 of file storport.c.

1365{
1366 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
1369
1370 DPRINT1("StorPortSetBusData(%p %lu %lu %lu %p %lu %lu)\n",
1371 DeviceExtension, BusDataType, SystemIoBusNumber, SlotNumber, Buffer, Offset, Length);
1372
1373 MiniportExtension = CONTAINING_RECORD(DeviceExtension,
1375 HwDeviceExtension);
1376 DPRINT1("DeviceExtension %p MiniportExtension %p\n",
1377 DeviceExtension, MiniportExtension);
1378
1379 Interface = &MiniportExtension->Miniport->DeviceExtension->BusInterface;
1380
1381 ReturnLength = Interface->SetBusData(Interface->Context,
1382 BusDataType,
1383 Buffer,
1384 Offset,
1385 Length);
1386 DPRINT1("ReturnLength: %lu\n", ReturnLength);
1387
1388 return ReturnLength;
1389}

◆ StorPortSetDeviceQueueDepth()

STORPORT_API BOOLEAN NTAPI StorPortSetDeviceQueueDepth ( _In_ PVOID  HwDeviceExtension,
_In_ UCHAR  PathId,
_In_ UCHAR  TargetId,
_In_ UCHAR  Lun,
_In_ ULONG  Depth 
)

Definition at line 1398 of file storport.c.

1404{
1405 DPRINT1("StorPortSetDeviceQueueDepth()\n");
1407 return FALSE;
1408}

Referenced by AtapiInquiryCompletion(), and InquiryCompletion().

◆ StorPortStallExecution()

STORPORT_API VOID NTAPI StorPortStallExecution ( _In_ ULONG  Delay)

Definition at line 1417 of file storport.c.

1419{
1421}
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81

Referenced by AhciAdapterReset(), AhciPortInitialize(), and AhciStartPort().

◆ StorPortSynchronizeAccess()

STORPORT_API VOID NTAPI StorPortSynchronizeAccess ( _In_ PVOID  HwDeviceExtension,
_In_ PSTOR_SYNCHRONIZED_ACCESS  SynchronizedAccessRoutine,
_In_opt_ PVOID  Context 
)

Definition at line 1430 of file storport.c.

1434{
1435 DPRINT1("StorPortSynchronizeAccess()\n");
1437}

◆ StorPortValidateRange()

STORPORT_API BOOLEAN NTAPI StorPortValidateRange ( _In_ PVOID  HwDeviceExtension,
_In_ INTERFACE_TYPE  BusType,
_In_ ULONG  SystemIoBusNumber,
_In_ STOR_PHYSICAL_ADDRESS  IoAddress,
_In_ ULONG  NumberOfBytes,
_In_ BOOLEAN  InIoSpace 
)

Definition at line 1446 of file storport.c.

1453{
1454 DPRINT1("StorPortValidateRange()\n");
1455 return TRUE;
1456}

Variable Documentation

◆ PortNumber