ReactOS 0.4.17-dev-1196-gb6224c3
precomp.h File Reference
#include <wdm.h>
#include <ntddk.h>
#include <ntintsafe.h>
#include <ntstrsafe.h>
#include <stdio.h>
#include <memory.h>
#include <storport.h>
#include <ntddscsi.h>
#include <ntdddisk.h>
#include <mountdev.h>
#include <wdmguid.h>
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DRIVER_INIT_DATA
 
struct  _DRIVER_OBJECT_EXTENSION
 
struct  _MINIPORT_DEVICE_EXTENSION
 
struct  _MINIPORT
 
struct  _UNIT_DATA
 
struct  _TIMER_ENTRY
 
struct  _PDO_IO_FLOW_CONTROL
 
struct  _FDO_IO_FLOW_CONTROL
 
struct  _STARVED_REQUEST_QUEUE
 
struct  _FDO_DEVICE_EXTENSION
 
struct  _PDO_DEVICE_EXTENSION
 
struct  _QUEUED_REQUEST_REFERENCE
 
struct  _LUN_DESCRIPTOR
 
struct  _REPORT_LUNS_DATA
 

Macros

#define _STORPORT_
 
#define TAG_GLOBAL_DATA   'DGtS'
 
#define TAG_INIT_DATA   'DItS'
 
#define TAG_DEVICE_RELATION   'RDtS'
 
#define TAG_DEVICE_ID   'DItS'
 
#define TAG_DEVICE_TEXT   'XTtS'
 
#define TAG_MINIPORT_DATA   'DMtS'
 
#define TAG_ACCRESS_RANGE   'RAtS'
 
#define TAG_RESOURCE_LIST   'LRtS'
 
#define TAG_ADDRESS_MAPPING   'MAtS'
 
#define TAG_INQUIRY_DATA   'QItS'
 
#define TAG_REPORT_LUN_DATA   'LRtS'
 
#define TAG_SENSE_DATA   'NStS'
 
#define TAG_QUEUED_REQUEST   'RQtS'
 
#define TAG_SRB_EXTENSION   'XStS'
 
#define SET_FLAG(Flags, Bit)   ((Flags) |= (Bit))
 
#define CLEAR_FLAG(Flags, Bit)   ((Flags) &= ~(Bit))
 
#define TEST_FLAG(Flags, Bit)   (((Flags) & (Bit)) != 0)
 

Typedefs

typedef struct _DRIVER_INIT_DATA DRIVER_INIT_DATA
 
typedef struct _DRIVER_INIT_DATA * PDRIVER_INIT_DATA
 
typedef struct _DRIVER_OBJECT_EXTENSION DRIVER_OBJECT_EXTENSION
 
typedef struct _DRIVER_OBJECT_EXTENSION * PDRIVER_OBJECT_EXTENSION
 
typedef struct _MINIPORT_DEVICE_EXTENSION MINIPORT_DEVICE_EXTENSION
 
typedef struct _MINIPORT_DEVICE_EXTENSION * PMINIPORT_DEVICE_EXTENSION
 
typedef struct _MINIPORT MINIPORT
 
typedef struct _MINIPORT * PMINIPORT
 
typedef struct _UNIT_DATA UNIT_DATA
 
typedef struct _UNIT_DATA * PUNIT_DATA
 
typedef struct _TIMER_ENTRY TIMER_ENTRY
 
typedef struct _TIMER_ENTRY * PTIMER_ENTRY
 
typedef struct _PDO_IO_FLOW_CONTROL PDO_IO_FLOW_CONTROL
 
typedef struct _PDO_IO_FLOW_CONTROL * PPDO_IO_FLOW_CONTROL
 
typedef struct _FDO_IO_FLOW_CONTROL FDO_IO_FLOW_CONTROL
 
typedef struct _FDO_IO_FLOW_CONTROL * PFDO_IO_FLOW_CONTROL
 
typedef struct _STARVED_REQUEST_QUEUE STARVED_REQUEST_QUEUE
 
typedef struct _STARVED_REQUEST_QUEUE * PSTARVED_REQUEST_QUEUE
 
typedef struct _FDO_DEVICE_EXTENSION FDO_DEVICE_EXTENSION
 
typedef struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
 
typedef struct _PDO_DEVICE_EXTENSION PDO_DEVICE_EXTENSION
 
typedef struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
 
typedef struct _QUEUED_REQUEST_REFERENCE QUEUED_REQUEST_REFERENCE
 
typedef struct _QUEUED_REQUEST_REFERENCE * PQUEUED_REQUEST_REFERENCE
 
typedef struct _LUN_DESCRIPTOR LUN_DESCRIPTOR
 
typedef struct _LUN_DESCRIPTOR * PLUN_DESCRIPTOR
 
typedef struct _REPORT_LUNS_DATA REPORT_LUNS_DATA
 
typedef struct _REPORT_LUNS_DATA * PREPORT_LUNS_DATA
 

Enumerations

enum  DEVICE_STATE {
  dsStopped , dsStarted , dsPaused , dsRemoved ,
  dsSurpriseRemoved , NotStarted = 0 , Started , StopPending ,
  Stopped , RemovePending , SurpriseRemovePending , Deleted ,
  dsStopped , dsStarted , dsPaused , dsRemoved ,
  dsSurpriseRemoved , dsStopped , dsStarted , dsPaused ,
  dsRemoved , dsSurpriseRemoved
}
 
enum  EXTENSION_TYPE { InvalidExtension = 0 , DriverExtension , FdoExtension , PdoExtension }
 

Functions

NTSTATUS PortInitializeStarvedRequestQueue (_In_ PSTARVED_REQUEST_QUEUE Queue)
 
VOID PortQueueStarvedRequest (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PIRP Irp)
 Queues a request that could not allocate its private contexts.
 
VOID PortRetryStarvedRequest (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 Retries one queued request, so each completion lets exactly one through.
 
VOID PortFlushStarvedRequests (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 Fails every queued request, for when the adapter goes away.
 
VOID PortAllocateRequestReserve (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 Reserves the memory a single request needs, so IO can still be issued out of pool.
 
VOID PortFreeRequestReserve (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 Releases the reserve. No request may be using it anymore.
 
PPDO_DEVICE_EXTENSION FdoFindLun (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Bus, _In_ ULONG Target, _In_ ULONG Lun)
 
NTSTATUS NTAPI PortFdoScsi (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
NTSTATUS NTAPI PortFdoPnp (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
NTSTATUS NTAPI PortFdoDeviceControl (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
NTSTATUS NTAPI PortPdoDeviceControl (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
NTSTATUS MiniportInitialize (_In_ PMINIPORT Miniport, _In_ PFDO_DEVICE_EXTENSION DeviceExtension, _In_ PHW_INITIALIZATION_DATA HwInitializationData)
 
NTSTATUS MiniportFindAdapter (_In_ PMINIPORT Miniport)
 
NTSTATUS MiniportHwInitialize (_In_ PMINIPORT Miniport)
 
BOOLEAN MiniportHwInterrupt (_In_ PMINIPORT Miniport)
 
BOOLEAN MiniportStartIo (_In_ PMINIPORT Miniport, _In_ PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS NTAPI ForwardIrpAndForget (_In_ PDEVICE_OBJECT LowerDevice, _In_ PIRP Irp)
 
INTERFACE_TYPE GetBusInterface (PDEVICE_OBJECT DeviceObject)
 
PCM_RESOURCE_LIST CopyResourceList (POOL_TYPE PoolType, PCM_RESOURCE_LIST Source)
 
NTSTATUS QueryBusInterface (PDEVICE_OBJECT DeviceObject, PGUID Guid, USHORT Size, USHORT Version, PBUS_INTERFACE_STANDARD Interface, PVOID InterfaceSpecificData)
 
BOOLEAN TranslateResourceListAddress (PFDO_DEVICE_EXTENSION DeviceExtension, INTERFACE_TYPE BusType, ULONG SystemIoBusNumber, STOR_PHYSICAL_ADDRESS IoAddress, ULONG NumberOfBytes, BOOLEAN InIoSpace, PPHYSICAL_ADDRESS TranslatedAddress)
 
NTSTATUS GetResourceListInterrupt (PFDO_DEVICE_EXTENSION DeviceExtension, PULONG Vector, PKIRQL Irql, KINTERRUPT_MODE *InterruptMode, PBOOLEAN ShareVector, PKAFFINITY Affinity)
 
NTSTATUS AllocateAddressMapping (PMAPPED_ADDRESS *MappedAddressList, STOR_PHYSICAL_ADDRESS IoAddress, PVOID MappedAddress, ULONG NumberOfBytes, ULONG BusNumber)
 
VOID NTAPI SimpleTimerCallbackDpcRoutine (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 
VOID NTAPI TimerCallbackDpcRoutine (PKDPC Dpc, PVOID DeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
 
PCSTR GetDeviceType (_In_ PINQUIRYDATA InquiryData)
 
PCSTR GetGenericType (_In_ PINQUIRYDATA InquiryData)
 
NTSTATUS PortCreatePdo (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Bus, _In_ ULONG Target, _In_ ULONG Lun, _Out_ PPDO_DEVICE_EXTENSION *PdoExtension)
 
NTSTATUS PortDeletePdo (_In_ PPDO_DEVICE_EXTENSION PdoExtension)
 
NTSTATUS NTAPI PortPdoPnp (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
VOID StorpSrbFreeRequestReference (_In_ PSCSI_REQUEST_BLOCK Srb)
 Frees an SRB's Request Reference and restore Srb->OriginalRequest field to IRP. This function does not check if Srb->OriginalRequest is actually an request reference, and you must determine it by other means.
 
NTSTATUS PortPdoIssueRequest (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PQUEUED_REQUEST_REFERENCE RequestReference)
 
BOOLEAN PortPdoScheduleRequestFlowControlled (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PQUEUED_REQUEST_REFERENCE RequestReference)
 Schedules an outstanding request and return a boolean value to indicate if the request can be immediately issued.
 
NTSTATUS NTAPI PortPdoScsi (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
 
VOID NTAPI PortCompletionDpc (_In_ PKDPC Dpc, _In_ PVOID Context, _In_ PVOID SystemArgument1, _In_ PVOID SystemArgument2)
 
PHW_INITIALIZATION_DATA PortGetDriverInitData (PDRIVER_OBJECT_EXTENSION DriverExtension, INTERFACE_TYPE InterfaceType)
 
NTSTATUS NTAPI DriverEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
 

Macro Definition Documentation

◆ _STORPORT_

#define _STORPORT_

Definition at line 19 of file precomp.h.

◆ CLEAR_FLAG

#define CLEAR_FLAG (   Flags,
  Bit 
)    ((Flags) &= ~(Bit))

Definition at line 44 of file precomp.h.

◆ SET_FLAG

#define SET_FLAG (   Flags,
  Bit 
)    ((Flags) |= (Bit))

Definition at line 43 of file precomp.h.

◆ TAG_ACCRESS_RANGE

#define TAG_ACCRESS_RANGE   'RAtS'

Definition at line 34 of file precomp.h.

◆ TAG_ADDRESS_MAPPING

#define TAG_ADDRESS_MAPPING   'MAtS'

Definition at line 36 of file precomp.h.

◆ TAG_DEVICE_ID

#define TAG_DEVICE_ID   'DItS'

Definition at line 31 of file precomp.h.

◆ TAG_DEVICE_RELATION

#define TAG_DEVICE_RELATION   'RDtS'

Definition at line 30 of file precomp.h.

◆ TAG_DEVICE_TEXT

#define TAG_DEVICE_TEXT   'XTtS'

Definition at line 32 of file precomp.h.

◆ TAG_GLOBAL_DATA

#define TAG_GLOBAL_DATA   'DGtS'

Definition at line 28 of file precomp.h.

◆ TAG_INIT_DATA

#define TAG_INIT_DATA   'DItS'

Definition at line 29 of file precomp.h.

◆ TAG_INQUIRY_DATA

#define TAG_INQUIRY_DATA   'QItS'

Definition at line 37 of file precomp.h.

◆ TAG_MINIPORT_DATA

#define TAG_MINIPORT_DATA   'DMtS'

Definition at line 33 of file precomp.h.

◆ TAG_QUEUED_REQUEST

#define TAG_QUEUED_REQUEST   'RQtS'

Definition at line 40 of file precomp.h.

◆ TAG_REPORT_LUN_DATA

#define TAG_REPORT_LUN_DATA   'LRtS'

Definition at line 38 of file precomp.h.

◆ TAG_RESOURCE_LIST

#define TAG_RESOURCE_LIST   'LRtS'

Definition at line 35 of file precomp.h.

◆ TAG_SENSE_DATA

#define TAG_SENSE_DATA   'NStS'

Definition at line 39 of file precomp.h.

◆ TAG_SRB_EXTENSION

#define TAG_SRB_EXTENSION   'XStS'

Definition at line 41 of file precomp.h.

◆ TEST_FLAG

#define TEST_FLAG (   Flags,
  Bit 
)    (((Flags) & (Bit)) != 0)

Definition at line 45 of file precomp.h.

Typedef Documentation

◆ DRIVER_INIT_DATA

◆ DRIVER_OBJECT_EXTENSION

◆ FDO_DEVICE_EXTENSION

◆ FDO_IO_FLOW_CONTROL

◆ LUN_DESCRIPTOR

◆ MINIPORT

◆ MINIPORT_DEVICE_EXTENSION

◆ PDO_DEVICE_EXTENSION

◆ PDO_IO_FLOW_CONTROL

◆ PDRIVER_INIT_DATA

◆ PDRIVER_OBJECT_EXTENSION

◆ PFDO_DEVICE_EXTENSION

◆ PFDO_IO_FLOW_CONTROL

◆ PLUN_DESCRIPTOR

◆ PMINIPORT

◆ PMINIPORT_DEVICE_EXTENSION

◆ PPDO_DEVICE_EXTENSION

◆ PPDO_IO_FLOW_CONTROL

◆ PQUEUED_REQUEST_REFERENCE

◆ PREPORT_LUNS_DATA

◆ PSTARVED_REQUEST_QUEUE

◆ PTIMER_ENTRY

◆ PUNIT_DATA

◆ QUEUED_REQUEST_REFERENCE

◆ REPORT_LUNS_DATA

◆ STARVED_REQUEST_QUEUE

◆ TIMER_ENTRY

◆ UNIT_DATA

Enumeration Type Documentation

◆ DEVICE_STATE

Enumerator
dsStopped 
dsStarted 
dsPaused 
dsRemoved 
dsSurpriseRemoved 
NotStarted 
Started 
StopPending 
Stopped 
RemovePending 
SurpriseRemovePending 
Deleted 
dsStopped 
dsStarted 
dsPaused 
dsRemoved 
dsSurpriseRemoved 
dsStopped 
dsStarted 
dsPaused 
dsRemoved 
dsSurpriseRemoved 

Definition at line 47 of file precomp.h.

48{
DEVICE_STATE
Definition: precomp.h:48
@ dsSurpriseRemoved
Definition: precomp.h:53
@ dsStopped
Definition: precomp.h:49
@ dsPaused
Definition: precomp.h:51
@ dsStarted
Definition: precomp.h:50
@ dsRemoved
Definition: precomp.h:52

◆ EXTENSION_TYPE

Enumerator
InvalidExtension 
DriverExtension 
FdoExtension 
PdoExtension 

Definition at line 56 of file precomp.h.

57{
EXTENSION_TYPE
Definition: precomp.h:57
@ InvalidExtension
Definition: precomp.h:58
@ PdoExtension
Definition: precomp.h:61
@ DriverExtension
Definition: precomp.h:59
@ FdoExtension
Definition: precomp.h:60

Function Documentation

◆ AllocateAddressMapping()

NTSTATUS AllocateAddressMapping ( PMAPPED_ADDRESS *  MappedAddressList,
STOR_PHYSICAL_ADDRESS  IoAddress,
PVOID  MappedAddress,
ULONG  NumberOfBytes,
ULONG  BusNumber 
)

Definition at line 291 of file misc.c.

297{
299
300 DPRINT1("AllocateAddressMapping()\n");
301
303 sizeof(MAPPED_ADDRESS),
305 if (Mapping == NULL)
306 {
307 DPRINT1("No memory!\n");
308 return STATUS_NO_MEMORY;
309 }
310
312
313 Mapping->NextMappedAddress = *MappedAddressList;
314 *MappedAddressList = Mapping;
315
316 Mapping->IoAddress = IoAddress;
317 Mapping->MappedAddress = MappedAddress;
318 Mapping->NumberOfBytes = NumberOfBytes;
319 Mapping->BusNumber = BusNumber;
320
321 return STATUS_SUCCESS;
322}
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NULL
Definition: types.h:112
#define TAG_ADDRESS_MAPPING
Definition: precomp.h:36
static PVOID Mapping[EMS_PHYSICAL_PAGES]
Definition: emsdrv.c:41
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
_In_ ULONG BusNumber
Definition: pciidex.h:65
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

Referenced by StorPortGetDeviceBase().

◆ CopyResourceList()

PCM_RESOURCE_LIST CopyResourceList ( POOL_TYPE  PoolType,
PCM_RESOURCE_LIST  Source 
)

Definition at line 92 of file misc.c.

95{
97 ULONG Size;
98
99 DPRINT1("CopyResourceList(%lu %p)\n",
101
102 /* Get the size of the resource list */
104
105 /* Allocate a new buffer */
107 Size,
109 if (Destination == NULL)
110 return NULL;
111
112 /* Copy the resource list */
114 Source,
115 Size);
116
117 return Destination;
118}
static ULONG GetResourceListSize(PCM_RESOURCE_LIST ResourceList)
Definition: misc.c:61
#define TAG_RESOURCE_LIST
Definition: precomp.h:35
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3051
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3821
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

Referenced by PortFdoStartDevice().

◆ DriverEntry()

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

Definition at line 1771 of file compbatt.c.

1774{
1775 /* Register add device routine */
1776 DriverObject->DriverExtension->AddDevice = CompBattAddDevice;
1777
1778 /* Register other handlers */
1785 return STATUS_SUCCESS;
1786}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
NTSTATUS NTAPI CompBattSystemControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: compbatt.c:42
NTSTATUS NTAPI CompBattIoctl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: compbatt.c:428
NTSTATUS NTAPI CompBattOpenClose(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: compbatt.c:23
NTSTATUS NTAPI CompBattPnpDispatch(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: comppnp.c:412
NTSTATUS NTAPI CompBattPowerDispatch(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: comppnp.c:18
NTSTATUS NTAPI CompBattAddDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT PdoDeviceObject)
Definition: comppnp.c:328
#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_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_POWER

◆ FdoFindLun()

PPDO_DEVICE_EXTENSION FdoFindLun ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ ULONG  Bus,
_In_ ULONG  Target,
_In_ ULONG  Lun 
)

Definition at line 1078 of file fdo.c.

1083{
1086 PLIST_ENTRY PdoEntry;
1087
1089
1090 for (PdoEntry = FdoExtension->PdoListHead.Flink;
1091 PdoEntry != &FdoExtension->PdoListHead;
1092 PdoEntry = PdoEntry->Flink)
1093 {
1094 PdoExtension = CONTAINING_RECORD(PdoEntry, PDO_DEVICE_EXTENSION, PdoListEntry);
1095
1096 if (PdoExtension->Bus == Bus && PdoExtension->Target == Target &&
1097 PdoExtension->Lun == Lun)
1098 {
1100 return PdoExtension;
1101 }
1102 }
1103
1105 return NULL;
1106}
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1315
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
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:717

Referenced by StorPortDeviceBusy(), StorPortDeviceReady(), and StorPortSetDeviceQueueDepth().

◆ ForwardIrpAndForget()

NTSTATUS NTAPI ForwardIrpAndForget ( _In_ PDEVICE_OBJECT  LowerDevice,
_In_ PIRP  Irp 
)

Definition at line 5 of file utils.c.

8{
9 // this part of a structure is identical in both FDO and PDO
10 PDEVICE_OBJECT LowerDevice = ((PFDO_EXTENSION)DeviceObject->DeviceExtension)->LowerDevice;
11
12 ASSERT(LowerDevice);
13
15 return IoCallDriver(LowerDevice, Irp);
16}
_In_ PIRP Irp
Definition: kse.h:79
#define ASSERT(a)
Definition: mode.c:44
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1257
struct _FDO_EXTENSION * PFDO_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061

◆ GetBusInterface()

INTERFACE_TYPE GetBusInterface ( PDEVICE_OBJECT  DeviceObject)

Definition at line 33 of file misc.c.

35{
36 GUID Guid;
39
42 sizeof(Guid),
43 &Guid,
44 &Length);
45 if (!NT_SUCCESS(Status))
47
48 if (RtlCompareMemory(&Guid, &GUID_BUS_TYPE_PCMCIA, sizeof(GUID)) == sizeof(GUID))
49 return PCMCIABus;
50 else if (RtlCompareMemory(&Guid, &GUID_BUS_TYPE_PCI, sizeof(GUID)) == sizeof(GUID))
51 return PCIBus;
52 else if (RtlCompareMemory(&Guid, &GUID_BUS_TYPE_ISAPNP, sizeof(GUID)) == sizeof(GUID))
53 return PNPISABus;
54
56}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
Status
Definition: gdiplustypes.h:24
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1382
@ InterfaceTypeUndefined
Definition: restypes.h:121
@ PCIBus
Definition: restypes.h:127
@ PNPISABus
Definition: restypes.h:136
@ PCMCIABus
Definition: restypes.h:130
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
@ DevicePropertyBusTypeGuid
Definition: iotypes.h:1207

Referenced by PortFdoStartMiniport().

◆ GetDeviceType()

PCSTR GetDeviceType ( _In_ PINQUIRYDATA  InquiryData)

Definition at line 7 of file scsitypes.h.

9{
10 switch (InquiryData->DeviceType)
11 {
13 return "Disk";
15 return "Sequential";
16 case PRINTER_DEVICE:
17 return "Printer";
19 return "Processor";
21 return "Worm";
23 return "CdRom";
24 case SCANNER_DEVICE:
25 return "Scanner";
26 case OPTICAL_DEVICE:
27 return "Optical";
28 case MEDIUM_CHANGER:
29 return "Changer";
31 return "Net";
33 return "Array";
35 return "Enclosure";
37 return "RBC";
39 return "CardReader";
41 return "Bridge";
42 default:
43 return "Other";
44 }
45}
#define COMMUNICATION_DEVICE
Definition: cdrw_hw.h:1153
#define WRITE_ONCE_READ_MULTIPLE_DEVICE
Definition: cdrw_hw.h:1148
#define DIRECT_ACCESS_DEVICE
Definition: cdrw_hw.h:1144
#define PRINTER_DEVICE
Definition: cdrw_hw.h:1146
#define OPTICAL_DEVICE
Definition: cdrw_hw.h:1151
#define READ_ONLY_DIRECT_ACCESS_DEVICE
Definition: cdrw_hw.h:1149
#define SEQUENTIAL_ACCESS_DEVICE
Definition: cdrw_hw.h:1145
#define PROCESSOR_DEVICE
Definition: cdrw_hw.h:1147
#define MEDIUM_CHANGER
Definition: cdrw_hw.h:1152
#define SCANNER_DEVICE
Definition: cdrw_hw.h:1150
#define BRIDGE_CONTROLLER_DEVICE
Definition: scsi.h:555
#define OPTICAL_CARD_READER_WRITER_DEVICE
Definition: scsi.h:554
#define REDUCED_BLOCK_DEVICE
Definition: scsi.h:553
#define ARRAY_CONTROLLER_DEVICE
Definition: scsi.h:551
#define SCSI_ENCLOSURE_DEVICE
Definition: scsi.h:552

◆ GetGenericType()

PCSTR GetGenericType ( _In_ PINQUIRYDATA  InquiryData)

Definition at line 49 of file scsitypes.h.

51{
52 switch (InquiryData->DeviceType)
53 {
55 return "GenDisk";
56 case PRINTER_DEVICE:
57 return "GenPrinter";
59 return "GenWorm";
61 return "GenCdRom";
62 case SCANNER_DEVICE:
63 return "GenScanner";
64 case OPTICAL_DEVICE:
65 return "GenOptical";
66 case MEDIUM_CHANGER:
67 return "ScsiChanger";
69 return "ScsiNet";
71 return "ScsiArray";
73 return "ScsiEnclosure";
75 return "ScsiRBC";
77 return "ScsiCardReader";
79 return "ScsiBridge";
80 default:
81 return "ScsiOther";
82 }
83}

◆ GetResourceListInterrupt()

NTSTATUS GetResourceListInterrupt ( PFDO_DEVICE_EXTENSION  DeviceExtension,
PULONG  Vector,
PKIRQL  Irql,
KINTERRUPT_MODE *  InterruptMode,
PBOOLEAN  ShareVector,
PKAFFINITY  Affinity 
)

Definition at line 242 of file misc.c.

249{
250 PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptor;
251 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
252 INT i, j;
253
254 DPRINT1("GetResourceListInterrupt(%p)\n",
255 DeviceExtension);
256
257 FullDescriptor = DeviceExtension->TranslatedResources->List;
258 for (i = 0; i < DeviceExtension->TranslatedResources->Count; i++)
259 {
260 for (j = 0; j < FullDescriptor->PartialResourceList.Count; j++)
261 {
262 PartialDescriptor = FullDescriptor->PartialResourceList.PartialDescriptors + j;
263
264 switch (PartialDescriptor->Type)
265 {
267 DPRINT1("Interrupt: Level %lu Vector %lu\n",
268 PartialDescriptor->u.Interrupt.Level,
269 PartialDescriptor->u.Interrupt.Vector);
270
271 *Vector = PartialDescriptor->u.Interrupt.Vector;
272 *Irql = (KIRQL)PartialDescriptor->u.Interrupt.Level;
274 *ShareVector = (PartialDescriptor->ShareDisposition == CmResourceShareShared) ? TRUE : FALSE;
275 *Affinity = PartialDescriptor->u.Interrupt.Affinity;
276
277 return STATUS_SUCCESS;
278 }
279 }
280
281 /* Advance to next CM_FULL_RESOURCE_DESCRIPTOR block in memory. */
282 FullDescriptor = (PCM_FULL_RESOURCE_DESCRIPTOR)(FullDescriptor->PartialResourceList.PartialDescriptors +
283 FullDescriptor->PartialResourceList.Count);
284 }
285
286 return STATUS_NOT_FOUND;
287}
_Out_ PKIRQL Irql
Definition: csq.h:179
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UCHAR KIRQL
Definition: env_spec_w32.h:591
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
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 GLint GLint j
Definition: glfuncs.h:250
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: restypes.h:117
#define CmResourceTypeInterrupt
Definition: restypes.h:105
@ Latched
Definition: miniport.h:81
@ LevelSensitive
Definition: miniport.h:80
#define STATUS_NOT_FOUND
Definition: shellext.h:72
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: restypes.h:145
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@497 Interrupt
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: restypes.h:150
PCM_RESOURCE_LIST TranslatedResources
Definition: precomp.h:243
int32_t INT
Definition: typedefs.h:58
@ CmResourceShareShared
Definition: cmtypes.h:243
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE InterruptMode
Definition: iofuncs.h:806
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE _In_ BOOLEAN ShareVector
Definition: iofuncs.h:807

Referenced by PortFdoConnectInterrupt().

◆ MiniportFindAdapter()

NTSTATUS MiniportFindAdapter ( _In_ PMINIPORT  Miniport)

Definition at line 294 of file miniport.c.

296{
300
301 DPRINT1("MiniportFindAdapter(%p)\n", Miniport);
302
303 /* Call the miniport HwFindAdapter routine */
304 Result = Miniport->InitData->HwFindAdapter(&Miniport->MiniportExtension->HwDeviceExtension,
305 NULL,
306 NULL,
307 NULL,
308 &Miniport->PortConfig,
309 &Reserved);
310 DPRINT1("HwFindAdapter() returned %lu\n", Result);
311
312 /* Convert the result to a status code */
313 switch (Result)
314 {
316 DPRINT1("SP_RETURN_NOT_FOUND\n");
318 break;
319
320 case SP_RETURN_FOUND:
321 DPRINT1("SP_RETURN_FOUND\n");
323 break;
324
325 case SP_RETURN_ERROR:
326 DPRINT1("SP_RETURN_ERROR\n");
328 break;
329
331 DPRINT1("SP_RETURN_BAD_CONFIG\n");
333 break;
334
335 default:
336 DPRINT1("Unknown result: %lu\n", Result);
338 break;
339 }
340
341 return Status;
342}
unsigned char BOOLEAN
Definition: actypes.h:127
#define SP_RETURN_ERROR
Definition: srb.h:523
#define SP_RETURN_FOUND
Definition: srb.h:522
#define SP_RETURN_BAD_CONFIG
Definition: srb.h:524
#define SP_RETURN_NOT_FOUND
Definition: srb.h:521
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:559
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:713
#define STATUS_ADAPTER_HARDWARE_ERROR
Definition: ntstatus.h:524
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
_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

Referenced by PortFdoStartMiniport().

◆ MiniportHwInitialize()

NTSTATUS MiniportHwInitialize ( _In_ PMINIPORT  Miniport)

Definition at line 346 of file miniport.c.

348{
350
351 DPRINT("MiniportHwInitialize(%p)\n", Miniport);
352
353 /* Call the miniport HwInitialize routine */
354 Result = Miniport->InitData->HwInitialize(&Miniport->MiniportExtension->HwDeviceExtension);
355 DPRINT("HwInitialize() returned %u\n", Result);
356
358}
#define DPRINT
Definition: sndvol32.h:73
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by PortFdoStartMiniport().

◆ MiniportHwInterrupt()

BOOLEAN MiniportHwInterrupt ( _In_ PMINIPORT  Miniport)

Definition at line 362 of file miniport.c.

364{
366
367 DPRINT("MiniportHwInterrupt(%p)\n",
368 Miniport);
369
370 Result = Miniport->InitData->HwInterrupt(&Miniport->MiniportExtension->HwDeviceExtension);
371 DPRINT("HwInterrupt() returned %u\n", Result);
372
373 return Result;
374}

Referenced by PortFdoInterruptRoutine().

◆ MiniportInitialize()

NTSTATUS MiniportInitialize ( _In_ PMINIPORT  Miniport,
_In_ PFDO_DEVICE_EXTENSION  DeviceExtension,
_In_ PHW_INITIALIZATION_DATA  HwInitializationData 
)

Definition at line 239 of file miniport.c.

243{
244 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
245 ULONG Size;
247
248 DPRINT1("MiniportInitialize(%p %p %p)\n",
249 Miniport, DeviceExtension, InitData);
250
251 Miniport->DeviceExtension = DeviceExtension;
252 Miniport->InitData = InitData;
253
254 /* Calculate the miniport device extension size */
255 Status = RtlULongAdd(sizeof(*MiniportExtension),
256 Miniport->InitData->DeviceExtensionSize,
257 &Size);
258 if (!NT_SUCCESS(Status))
259 {
260 DPRINT1("Invalid miniport extension size %lx\n", Miniport->InitData->DeviceExtensionSize);
261 return Status;
262 }
263
264 /* Allocate and initialize the miniport device extension */
265 MiniportExtension = ExAllocatePoolWithTag(NonPagedPool,
266 Size,
268 if (MiniportExtension == NULL)
269 return STATUS_NO_MEMORY;
270
271 RtlZeroMemory(MiniportExtension, Size);
272
273 MiniportExtension->Miniport = Miniport;
274 Miniport->MiniportExtension = MiniportExtension;
275
276 /* Initialize the port configuration */
277 Status = InitializeConfiguration(&Miniport->PortConfig,
278 InitData,
279 DeviceExtension->BusNumber,
280 DeviceExtension->SlotNumber);
281 if (!NT_SUCCESS(Status))
282 return Status;
283
284 /* Assign the resources to the port configuration */
285 AssignResourcesToConfiguration(&Miniport->PortConfig,
286 DeviceExtension->AllocatedResources,
287 InitData->NumberOfAccessRanges);
288
289 return STATUS_SUCCESS;
290}
#define TAG_MINIPORT_DATA
Definition: precomp.h:33
static VOID AssignResourcesToConfiguration(_In_ PPORT_CONFIGURATION_INFORMATION PortConfiguration, _In_ PCM_RESOURCE_LIST ResourceList, _In_ ULONG NumberOfAccessRanges)
Definition: miniport.c:99
static NTSTATUS InitializeConfiguration(_In_ PPORT_CONFIGURATION_INFORMATION PortConfig, _In_ PHW_INITIALIZATION_DATA InitData, _In_ ULONG BusNumber, _In_ ULONG SlotNumber)
Definition: miniport.c:20
struct _MINIPORT * Miniport
Definition: precomp.h:84

◆ MiniportStartIo()

BOOLEAN MiniportStartIo ( _In_ PMINIPORT  Miniport,
_In_ PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 378 of file miniport.c.

381{
383
384 DPRINT("MiniportHwStartIo(%p %p)\n",
385 Miniport, Srb);
386
387 Result = Miniport->InitData->HwStartIo(&Miniport->MiniportExtension->HwDeviceExtension, Srb);
388 DPRINT("HwStartIo() returned %u\n", Result);
389
390 return Result;
391}
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989

◆ PortAllocateRequestReserve()

VOID PortAllocateRequestReserve ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)

Reserves the memory a single request needs, so IO can still be issued out of pool.

Definition at line 168 of file fdo.c.

170{
171 ULONG SrbExtensionSize = FdoExtension->HwInitData->SrbExtensionSize;
172
173 FdoExtension->ReservedRequestReference =
175 sizeof(*FdoExtension->ReservedRequestReference),
177 if (FdoExtension->ReservedRequestReference == NULL)
178 {
179 DPRINT1("Failed to reserve a request packet\n");
180 return;
181 }
182
183 if (SrbExtensionSize == 0)
184 {
185 return;
186 }
187
188 FdoExtension->ReservedSrbExtension = ExAllocatePoolWithTag(NonPagedPool,
189 SrbExtensionSize,
191 if (FdoExtension->ReservedSrbExtension == NULL)
192 {
193 DPRINT1("Failed to reserve an SRB extension\n");
194
195 /* A packet alone is useless if the miniport wants an SRB extension */
196 ExFreePoolWithTag(FdoExtension->ReservedRequestReference, TAG_QUEUED_REQUEST);
197 FdoExtension->ReservedRequestReference = NULL;
198 }
199}
#define TAG_SRB_EXTENSION
Definition: precomp.h:41
#define TAG_QUEUED_REQUEST
Definition: precomp.h:40
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109

Referenced by PortFdoStartDevice().

◆ PortCompletionDpc()

VOID NTAPI PortCompletionDpc ( _In_ PKDPC  Dpc,
_In_ PVOID  Context,
_In_ PVOID  SystemArgument1,
_In_ PVOID  SystemArgument2 
)

Definition at line 894 of file srb.c.

899{
900 PQUEUED_REQUEST_REFERENCE RequestReference;
904 ULONG Count = 0;
905
906 DPRINT("PortCompletionDpc(%p %p %p %p)\n", Dpc, Context, SystemArgument1, SystemArgument2);
907
908 /* Take context pointer as FDO extension */
910
911 /* Flush all entries in the list and complete all requests */
912 Entry = InterlockedFlushSList(&FdoExtension->CompletionList);
913 while (Entry)
914 {
915 /* Prepare Next pointer first (Completion routine will free the memory that contains it) */
916 Next = Entry->Next;
917
918 /* Get original request */
919 RequestReference = CONTAINING_RECORD(Entry, QUEUED_REQUEST_REFERENCE, CompletionEntry);
920
921 /* Call real completion routine */
922 PortCompleteRequest(RequestReference);
923
924 /* Move on to next one */
925 Entry = Next;
926 ++Count;
927 }
928
929 DPRINT("Completed %d requests\n", Count);
930}
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
int Count
Definition: noreturn.cpp:7
Entry
Definition: section.c:5216
STDMETHOD() Next(THIS_ ULONG celt, IAssociationElement *pElement, ULONG *pceltFetched) PURE
static VOID PortCompleteRequest(_In_ PQUEUED_REQUEST_REFERENCE RequestReference)
Definition: srb.c:740
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:112
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:756
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:757
#define InterlockedFlushSList(SListHead)
Definition: rtlfuncs.h:3419
#define PSLIST_ENTRY
Definition: rtltypes.h:134

Referenced by PortAddDevice().

◆ PortCreatePdo()

NTSTATUS PortCreatePdo ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ ULONG  Bus,
_In_ ULONG  Target,
_In_ ULONG  Lun,
_Out_ PPDO_DEVICE_EXTENSION *  PdoExtension 
)

Definition at line 21 of file pdo.c.

27{
28 PPDO_DEVICE_EXTENSION DeviceExtension = NULL;
31
32 DPRINT("PortCreatePdo(%p %p)\n",
33 FdoDeviceExtension, PdoDeviceExtension);
34
35 /* Create the port device */
36 Status = IoCreateDevice(FdoDeviceExtension->Device->DriverObject,
38 NULL,
41 FALSE,
42 &Pdo);
43 if (!NT_SUCCESS(Status))
44 {
45 DPRINT1("IoCreateDevice() failed (Status 0x%lX)\n", Status);
46 return Status;
47 }
48
49 /* Initialize the device */
50 Pdo->Flags |= DO_DIRECT_IO;
51 Pdo->Flags |= DO_POWER_PAGABLE;
52
53 DeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
54 RtlZeroMemory(DeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
55
56 DeviceExtension->ExtensionType = PdoExtension;
57
58 DeviceExtension->Device = Pdo;
59 DeviceExtension->FdoExtension = FdoDeviceExtension;
60 DeviceExtension->PnpState = dsStopped;
61
62 /* Add the PDO to the PDO list*/
63 StorpInterlockedInsertHeadListCounted(&FdoDeviceExtension->PdoListLock,
64 &FdoDeviceExtension->PdoListHead,
65 &DeviceExtension->PdoListEntry,
66 &FdoDeviceExtension->PdoCount);
67
68 DeviceExtension->Bus = Bus;
69 DeviceExtension->Target = Target;
70 DeviceExtension->Lun = Lun;
71
72 /* Initialize IO flow control structure */
73 // KeInitializeSpinLock(&DeviceExtension->FlowControl.Lock);
74 DeviceExtension->FlowControl.IsBusy = FALSE;
75 DeviceExtension->FlowControl.IsPaused = FALSE;
76 DeviceExtension->FlowControl.IsWaitingQueueClear = FALSE;
77 DeviceExtension->FlowControl.StrongOrderedCount = 0;
78 DeviceExtension->FlowControl.RemainingBusyRequests = 0;
79 DeviceExtension->FlowControl.RemainingPauseTime = 0;
80
81 /* Beginning from Windows 8, when you specified SRB_TYPE_STORAGE_REQUEST_BLOCK, you can increase
82 maximum number of outstanding requests to (254, MaxNumberOfIO) range. We do not support
83 STORAGE_REQUEST_BLOCKs so we're not implementing it.
84 */
86 // InitializeListHead(&DeviceExtension->FlowControl.ApprovedRequestsListHead);
88 DeviceExtension->FlowControl.OutstandingRequestCount = 0;
89 DeviceExtension->OutstandingRequestMax = 254;
90 DeviceExtension->TagCounter = -1;
91
92 DeviceExtension->IsClaimed = 0;
93
94 // FIXME: More initialization
95
96 DeviceExtension->SpecialRequestCounter = 0; /* FIXME: DELETE AFTER DEBUG */
97
98 /* The device has been initialized */
99 Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
100
101 *PdoDeviceExtension = DeviceExtension;
102
103 return STATUS_SUCCESS;
104}
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_In_ UCXUSBDEVICE _In_ PDEVICE_OBJECT Pdo
Definition: hubucx.h:280
FORCEINLINE ULONG StorpInterlockedInsertHeadListCounted(_In_ PKSPIN_LOCK SpinLock, _In_ PLIST_ENTRY ListHead, _In_ PLIST_ENTRY Entry, _In_ PULONG Counter)
InsertHeadList and increment element counter with a corresponding spin lock held.
Definition: inline.h:71
@ dsStopped
Definition: isapnp.h:30
#define FILE_DEVICE_MASS_STORAGE
Definition: imports.h:60
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:142
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:1038
PFDO_DEVICE_EXTENSION FdoExtension
Definition: precomp.h:303
PDO_IO_FLOW_CONTROL FlowControl
Definition: precomp.h:315
LIST_ENTRY PdoListEntry
Definition: precomp.h:305
PDEVICE_OBJECT Device
Definition: precomp.h:302
ULONG OutstandingRequestMax
Definition: precomp.h:316
DEVICE_STATE PnpState
Definition: precomp.h:304
EXTENSION_TYPE ExtensionType
Definition: precomp.h:300
LONG SpecialRequestCounter
Definition: precomp.h:319
LIST_ENTRY ActiveRequestsListHead
Definition: precomp.h:180
BOOLEAN IsWaitingQueueClear
Definition: precomp.h:162
ULONG RemainingBusyRequests
Definition: precomp.h:174
ULONG OutstandingRequestCount
Definition: precomp.h:171
ULONG StrongOrderedCount
Definition: precomp.h:168
ULONG RemainingPauseTime
Definition: precomp.h:177
LIST_ENTRY AwaitingRequestsListHead
Definition: precomp.h:186
#define DO_POWER_PAGABLE

Referenced by PortFdoScanBus().

◆ PortDeletePdo()

NTSTATUS PortDeletePdo ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension)

Definition at line 108 of file pdo.c.

110{
111 DPRINT("PortDeletePdo(%p)\n", PdoExtension);
112
113 /* Remove the PDO from the PDO list*/
114 StorpInterlockedRemoveEntryListCounted(&PdoExtension->FdoExtension->PdoListLock,
115 &PdoExtension->PdoListEntry,
116 &PdoExtension->FdoExtension->PdoCount);
117
118 if (PdoExtension->InquiryBuffer)
119 {
121 PdoExtension->InquiryBuffer = NULL;
122 }
123
124
125 // FIXME: More uninitialization
126
127
128 /* Delete the PDO */
130
131 return STATUS_SUCCESS;
132}
#define TAG_INQUIRY_DATA
Definition: precomp.h:37
FORCEINLINE BOOLEAN StorpInterlockedRemoveEntryListCounted(_In_ PKSPIN_LOCK SpinLock, _In_ PLIST_ENTRY Entry, _In_ PULONG Counter)
RemoveEntryList and decrement element counter with a corresponding spin lock held.
Definition: inline.h:126
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1261

Referenced by PortFdoScanBus().

◆ PortFdoDeviceControl()

NTSTATUS NTAPI PortFdoDeviceControl ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 146 of file ioctl.c.

149{
150 PIO_STACK_LOCATION IoStack;
152
154
155 switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
156 {
158 return FdoDeviceControlQueryProperty(DeviceObject->DeviceExtension, Irp);
159
160 default:
161 // __debugbreak();
162 Status = Irp->IoStatus.Status;
163 break;
164 }
165
166 Irp->IoStatus.Status = Status;
167 Irp->IoStatus.Information = 0;
169
170 return Status;
171}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
static NTSTATUS FdoDeviceControlQueryProperty(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PIRP Irp)
Definition: ioctl.c:44
#define IoCompleteRequest
Definition: irp.c:1272
#define IOCTL_STORAGE_QUERY_PROPERTY
Definition: ntddstor.h:178
union _IO_STACK_LOCATION::@1814 Parameters
struct _IO_STACK_LOCATION::@1814::@1815 DeviceIoControl
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by PortDispatchDeviceControl().

◆ PortFdoPnp()

NTSTATUS NTAPI PortFdoPnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 1139 of file fdo.c.

1142{
1143 PFDO_DEVICE_EXTENSION DeviceExtension;
1147
1148 DPRINT1("PortFdoPnp(%p %p)\n",
1149 DeviceObject, Irp);
1150
1151 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
1152 ASSERT(DeviceExtension);
1153 ASSERT(DeviceExtension->ExtensionType == FdoExtension);
1154
1156
1157 switch (Stack->MinorFunction)
1158 {
1159 case IRP_MN_START_DEVICE: /* 0x00 */
1160 DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
1161 Status = PortFdoStartDevice(DeviceExtension, Irp);
1162 break;
1163
1164 case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
1165 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_REMOVE_DEVICE\n");
1166 break;
1167
1168 case IRP_MN_REMOVE_DEVICE: /* 0x02 */
1169 DPRINT1("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
1170 PortFlushStarvedRequests(DeviceExtension);
1171 PortFreeRequestReserve(DeviceExtension);
1173 break;
1174
1175 case IRP_MN_CANCEL_REMOVE_DEVICE: /* 0x03 */
1176 DPRINT1("IRP_MJ_PNP / IRP_MN_CANCEL_REMOVE_DEVICE\n");
1177 break;
1178
1179 case IRP_MN_STOP_DEVICE: /* 0x04 */
1180 DPRINT1("IRP_MJ_PNP / IRP_MN_STOP_DEVICE\n");
1181 break;
1182
1183 case IRP_MN_QUERY_STOP_DEVICE: /* 0x05 */
1184 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_STOP_DEVICE\n");
1185 break;
1186
1187 case IRP_MN_CANCEL_STOP_DEVICE: /* 0x06 */
1188 DPRINT1("IRP_MJ_PNP / IRP_MN_CANCEL_STOP_DEVICE\n");
1189 break;
1190
1191 case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
1192 switch (Stack->Parameters.QueryDeviceRelations.Type)
1193 {
1194 case BusRelations:
1195 DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
1196 Status = PortFdoQueryBusRelations(DeviceExtension, &Information);
1197 break;
1198
1199 case RemovalRelations:
1200 DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
1201 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1202
1203 default:
1204 DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
1205 Stack->Parameters.QueryDeviceRelations.Type);
1206 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1207 }
1208 break;
1209
1211 DPRINT("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
1212 PortFdoFilterRequirements(DeviceExtension, Irp);
1213 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1214
1215 case IRP_MN_QUERY_PNP_DEVICE_STATE: /* 0x14 */
1216 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_PNP_DEVICE_STATE\n");
1217 break;
1218
1219 case IRP_MN_DEVICE_USAGE_NOTIFICATION: /* 0x16 */
1220 DPRINT1("IRP_MJ_PNP / IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
1221 break;
1222
1223 case IRP_MN_SURPRISE_REMOVAL: /* 0x17 */
1224 DPRINT1("IRP_MJ_PNP / IRP_MN_SURPRISE_REMOVAL\n");
1225 break;
1226
1227 default:
1228 DPRINT1("IRP_MJ_PNP / Unknown IOCTL 0x%lx\n", Stack->MinorFunction);
1229 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1230 }
1231
1232 Irp->IoStatus.Information = Information;
1233 Irp->IoStatus.Status = Status;
1235
1236 return Status;
1237}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
DRIVER_DISPATCH ForwardIrpAndForget
Definition: i8042prt.h:341
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:170
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
VOID PortFlushStarvedRequests(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Fails every queued request, for when the adapter goes away.
Definition: fdo.c:153
static NTSTATUS PortFdoFilterRequirements(PFDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp)
Definition: fdo.c:1057
VOID PortFreeRequestReserve(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Releases the reserve. No request may be using it anymore.
Definition: fdo.c:205
static NTSTATUS PortFdoStartDevice(_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _In_ PIRP Irp)
Definition: fdo.c:381
static NTSTATUS PortFdoQueryBusRelations(_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _Out_ PULONG_PTR Information)
Definition: fdo.c:990
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
NPAGED_LOOKASIDE_LIST RequestReferenceLookaside
Definition: precomp.h:281
EXTENSION_TYPE ExtensionType
Definition: precomp.h:230
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
#define IRP_MN_CANCEL_STOP_DEVICE
@ RemovalRelations
Definition: iotypes.h:2157
@ BusRelations
Definition: iotypes.h:2154
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_START_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by PortDispatchPnp().

◆ PortFdoScsi()

NTSTATUS NTAPI PortFdoScsi ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 1111 of file fdo.c.

1114{
1115 PFDO_DEVICE_EXTENSION DeviceExtension;
1116// PIO_STACK_LOCATION Stack;
1119
1120 DPRINT("PortFdoScsi(%p %p)\n", DeviceObject, Irp);
1121
1122 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
1123 ASSERT(DeviceExtension);
1124 ASSERT(DeviceExtension->ExtensionType == FdoExtension);
1125
1126// Stack = IoGetCurrentIrpStackLocation(Irp);
1127
1128
1129 Irp->IoStatus.Information = Information;
1130 Irp->IoStatus.Status = Status;
1132
1133 return Status;
1134}

Referenced by PortDispatchScsi().

◆ PortFlushStarvedRequests()

VOID PortFlushStarvedRequests ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)

Fails every queued request, for when the adapter goes away.

Definition at line 153 of file fdo.c.

155{
156 PIRP Irp;
157
158 while ((Irp = IoCsqRemoveNextIrp(&FdoExtension->StarvedRequests.Csq, NULL)) != NULL)
159 {
161 }
162}
NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp(_Inout_ PIO_CSQ Csq, _In_opt_ PVOID PeekContext)
IoCsqRemoveNextIrp - Removes the next IRP from the queue.
Definition: csq.c:398
#define SRB_STATUS_NO_DEVICE
Definition: srb.h:348
FORCEINLINE VOID StorpCompleteRequest(_In_ PIRP Irp, _In_ UCHAR SrbStatus, _In_ NTSTATUS IrpStatus)
Completes a request with specified SRB status and IRP status.
Definition: inline.h:19
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

Referenced by PortFdoPnp().

◆ PortFreeRequestReserve()

VOID PortFreeRequestReserve ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)

Releases the reserve. No request may be using it anymore.

Definition at line 205 of file fdo.c.

207{
208 if (FdoExtension->ReservedSrbExtension != NULL)
209 {
210 ExFreePoolWithTag(FdoExtension->ReservedSrbExtension, TAG_SRB_EXTENSION);
211 FdoExtension->ReservedSrbExtension = NULL;
212 }
213
214 if (FdoExtension->ReservedRequestReference != NULL)
215 {
216 ExFreePoolWithTag(FdoExtension->ReservedRequestReference, TAG_QUEUED_REQUEST);
217 FdoExtension->ReservedRequestReference = NULL;
218 }
219}

Referenced by PortFdoPnp().

◆ PortGetDriverInitData()

PHW_INITIALIZATION_DATA PortGetDriverInitData ( PDRIVER_OBJECT_EXTENSION  DriverExtension,
INTERFACE_TYPE  InterfaceType 
)

Definition at line 81 of file storport.c.

84{
85 PDRIVER_INIT_DATA InitData;
86 PLIST_ENTRY ListEntry;
87
88 DPRINT1("PortGetDriverInitData()\n");
89
90 ListEntry = DriverExtension->InitDataListHead.Flink;
91 while (ListEntry != &DriverExtension->InitDataListHead)
92 {
93 InitData = CONTAINING_RECORD(ListEntry,
95 Entry);
97 return &InitData->HwInitData;
98
99 ListEntry = ListEntry->Flink;
100 }
101
102 return NULL;
103}
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
HW_INITIALIZATION_DATA HwInitData
Definition: precomp.h:67
INTERFACE_TYPE AdapterInterfaceType
Definition: srb.h:565
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463

Referenced by PortFdoStartMiniport(), and StorPortGetUncachedExtension().

◆ PortInitializeStarvedRequestQueue()

NTSTATUS PortInitializeStarvedRequestQueue ( _In_ PSTARVED_REQUEST_QUEUE  Queue)

Definition at line 105 of file fdo.c.

107{
109 InitializeListHead(&Queue->ListHead);
110
111 return IoCsqInitialize(&Queue->Csq,
118}
NTKERNELAPI NTSTATUS NTAPI IoCsqInitialize(_Out_ PIO_CSQ Csq, _In_ PIO_CSQ_INSERT_IRP CsqInsertIrp, _In_ PIO_CSQ_REMOVE_IRP CsqRemoveIrp, _In_ PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, _In_ PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, _In_ PIO_CSQ_RELEASE_LOCK CsqReleaseLock, _In_ PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp)
Set up a CSQ struct to initialize the queue.
Definition: csq.c:103
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
static VOID NTAPI PortStarvedCsqInsertIrp(_In_ PIO_CSQ Csq, _In_ PIRP Irp)
Definition: fdo.c:24
static VOID NTAPI PortStarvedCsqAcquireLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: fdo.c:71
static PIRP NTAPI PortStarvedCsqPeekNextIrp(_In_ PIO_CSQ Csq, _In_ PIRP Irp, _In_ PVOID PeekContext)
Definition: fdo.c:48
static VOID NTAPI PortStarvedCsqRemoveIrp(_In_ PIO_CSQ Csq, _In_ PIRP Irp)
Definition: fdo.c:36
static VOID NTAPI PortStarvedCsqCompleteCanceledIrp(_In_ PIO_CSQ Csq, _In_ PIRP Irp)
Definition: fdo.c:95
static VOID NTAPI PortStarvedCsqReleaseLock(_In_ PIO_CSQ Csq, _In_ KIRQL Irql)
Definition: fdo.c:83
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2231

Referenced by PortAddDevice().

◆ PortPdoDeviceControl()

NTSTATUS NTAPI PortPdoDeviceControl ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 378 of file ioctl.c.

381{
383 PIO_STACK_LOCATION IoStack;
384
386
387 switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
388 {
390 return PdoDeviceControlQueryProperty(DeviceObject->DeviceExtension, Irp);
391
393 return PdoDeviceControlScsiGetAddress(DeviceObject->DeviceExtension, Irp);
394
395 default:
396 // DbgBreakPoint();
398 break;
399 }
400
401 Irp->IoStatus.Status = Status;
402 Irp->IoStatus.Information = 0;
404
405 return Status;
406}
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
static NTSTATUS PdoDeviceControlQueryProperty(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: ioctl.c:176
static NTSTATUS PdoDeviceControlScsiGetAddress(_In_ PPDO_DEVICE_EXTENSION DeviceExtension, _In_ PIRP Irp)
Definition: ioctl.c:328
#define IOCTL_SCSI_GET_ADDRESS
Definition: scsi_port.h:52

Referenced by PortDispatchDeviceControl().

◆ PortPdoIssueRequest()

NTSTATUS PortPdoIssueRequest ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PQUEUED_REQUEST_REFERENCE  RequestReference 
)

Definition at line 290 of file srb.c.

293{
294 PIRP Irp;
297 PHW_INITIALIZATION_DATA HwInitData;
299
300 Irp = RequestReference->Irp;
301 FdoExtension = PdoExtension->FdoExtension;
302 HwInitData = FdoExtension->Miniport.InitData;
303
304 NT_ASSERT(HwInitData);
305
306 /* Fill in SCSI address data */
307 /* FIXME: Not sure if this is the best place for it. */
308 RequestReference->Srb->PathId = PdoExtension->Bus;
309 RequestReference->Srb->TargetId = PdoExtension->Target;
310 RequestReference->Srb->Lun = PdoExtension->Lun;
311
312 /* FIXME: Delete after debug */
313 // PSCSI_REQUEST_BLOCK Srb = RequestReference->Srb;
314 // if (Srb->Function == SRB_FUNCTION_EXECUTE_SCSI &&
315 // (Srb->Cdb[0] == SCSIOP_GET_EVENT_STATUS || Srb->Cdb[0] == SCSIOP_TEST_UNIT_READY))
316 // {
317 // RequestReference->DumpSpecialRequest = TRUE;
318 // StorpDumpRequest(RequestReference);
319 // }
320
321 /* Start an DMA if IO subsystem allocated an MDL for us */
322 /* FIXME: Does this strategy work? */
323 if (RequestReference->Irp->MdlAddress)
324 {
325 /*
326 * Lock the buffer so that it stays in physical memory.
327 * In the two cases avoided here the memory has already been locked
328 */
329 if (!TEST_FLAG(Irp->MdlAddress->MdlFlags, MDL_SOURCE_IS_NONPAGED_POOL) &&
330 !TEST_FLAG(Irp->MdlAddress->MdlFlags, MDL_MAPPED_TO_SYSTEM_VA) &&
331 !TEST_FLAG(Irp->MdlAddress->MdlFlags, MDL_PAGES_LOCKED) &&
332 !TEST_FLAG(Irp->MdlAddress->MdlFlags, MDL_PARTIAL))
333 {
334 RequestReference->MappedSystemVa = (PVOID)1; /* FIXME: CHANGE ITS NAME */
336 }
337
338 /* Following call requires DISPATCH_LEVEL. */
340
341 /* Make up the scatter gather list */
342 /* FIXME: I don't know if we actually hit it */
343 NT_ASSERT((RequestReference->Srb->SrbFlags & SRB_FLAGS_UNSPECIFIED_DIRECTION) !=
345 RequestReference->WriteToDevice =
346 TEST_FLAG(RequestReference->Srb->SrbFlags, SRB_FLAGS_DATA_OUT);
347
348 FdoExtension->DmaAdapter->DmaOperations->
349 GetScatterGatherList(FdoExtension->DmaAdapter,
350 FdoExtension->Device,
351 RequestReference->Irp->MdlAddress,
352 MmGetMdlVirtualAddress(RequestReference->Irp->MdlAddress),
353 RequestReference->Srb->DataTransferLength,
355 (PVOID)RequestReference,
356 RequestReference->WriteToDevice);
357
358 /* Restore IRQL */
360 } else {
361 /* Otherwise just start the IO with a NULL scatter gather list */
363 RequestReference->Irp,
364 NULL,
365 RequestReference);
366 }
367
368 /* FIXME: Is this correct? */
370
371 return Status;
372}
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
#define SRB_FLAGS_DATA_OUT
Definition: srb.h:401
#define SRB_FLAGS_UNSPECIFIED_DIRECTION
Definition: srb.h:403
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
KIRQL FASTCALL KfRaiseIrql(IN KIRQL NewIrql)
Definition: pic.c:187
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:928
#define KernelMode
Definition: asm.h:38
VOID NTAPI PortPdoAfterBuildingScatterGatherList(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PSCATTER_GATHER_LIST ScatterGatherList, _In_ PVOID Context)
Definition: srb.c:168
#define STATUS_PENDING
Definition: telnetd.h:14
void * PVOID
Definition: typedefs.h:50
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ IoModifyAccess
Definition: ketypes.h:933
#define MmGetMdlVirtualAddress(_Mdl)
#define MDL_PAGES_LOCKED
Definition: mmtypes.h:19
#define MDL_PARTIAL
Definition: mmtypes.h:22
#define MDL_SOURCE_IS_NONPAGED_POOL
Definition: mmtypes.h:20
#define MDL_MAPPED_TO_SYSTEM_VA
Definition: mmtypes.h:18
#define NT_ASSERT
Definition: rtlfuncs.h:3334

Referenced by PortPdoScsi(), and PortScheduleComingRequestsOnCompletion().

◆ PortPdoPnp()

NTSTATUS NTAPI PortPdoPnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 681 of file pdo.c.

684{
687 PPDO_DEVICE_EXTENSION DeviceExtension;
688
689 DPRINT1("PortPdoPnp(%p %p)\n", DeviceObject, Irp);
690
691 DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
692 ASSERT(DeviceExtension->ExtensionType == PdoExtension);
693
695
696 switch (Stack->MinorFunction)
697 {
699 {
700 // RegistryInitLunKey(lunExt);
701 DeviceExtension->PnpState = dsStarted;
703 break;
704 }
707 {
708 DeviceExtension->PnpState = (Stack->MinorFunction == IRP_MN_REMOVE_DEVICE)
711 break;
712 }
716 {
718 break;
719 }
721 {
722 Status = PdoHandleDeviceRelations(DeviceExtension, Irp);
723 break;
724 }
726 {
727 Status = PdoHandleQueryDeviceText(DeviceExtension, Irp);
728 break;
729 }
730 case IRP_MN_QUERY_ID:
731 {
732 DPRINT("IRP_MN_QUERY_ID IdType %s\n",
733 DbgGetDeviceIDString(Stack->Parameters.QueryId.IdType));
734
735 if (Stack->Parameters.QueryId.IdType == BusQueryDeviceID)
736 {
737 Status = PdoHandleQueryDeviceId(DeviceExtension, Irp);
738 break;
739 }
740 else if (Stack->Parameters.QueryId.IdType == BusQueryHardwareIDs)
741 {
742 Status = PdoHandleQueryHardwareId(DeviceExtension, Irp);
743 break;
744 }
745 else if (Stack->Parameters.QueryId.IdType == BusQueryInstanceID)
746 {
747 Status = PdoHandleQueryInstanceId(DeviceExtension, Irp);
748 break;
749 }
750 else if (Stack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
751 {
752 Status = PdoHandleQueryCompatibleId(DeviceExtension, Irp);
753 break;
754 }
755
757 }
758 default:
759 {
760 // do nothing
761 Status = Irp->IoStatus.Status;
762 break;
763 }
764 }
765
766 if (Status != STATUS_PENDING)
767 {
768 Irp->IoStatus.Status = Status;
770 }
771
772 return Status;
773}
PCHAR DbgGetDeviceIDString(BUS_QUERY_ID_TYPE Type)
Definition: driverdbg.h:93
@ dsSurpriseRemoved
Definition: pci.h:39
@ dsRemoved
Definition: pci.h:38
@ dsStarted
Definition: isapnp.h:31
#define __fallthrough
Definition: sal_old.h:314
static NTSTATUS PdoHandleDeviceRelations(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:649
static NTSTATUS PdoHandleQueryInstanceId(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:495
static NTSTATUS PdoHandleQueryDeviceId(_In_ PPDO_DEVICE_EXTENSION DeviceExtension, _Inout_ PIRP Irp)
Definition: pdo.c:175
static NTSTATUS PdoHandleQueryHardwareId(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:249
static NTSTATUS PdoHandleQueryCompatibleId(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:426
static NTSTATUS PdoHandleQueryDeviceText(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:535
#define IRP_MN_QUERY_ID
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_CAPABILITIES
@ BusQueryCompatibleIDs
Definition: iotypes.h:2953
@ BusQueryInstanceID
Definition: iotypes.h:2954
@ BusQueryDeviceID
Definition: iotypes.h:2951
@ BusQueryHardwareIDs
Definition: iotypes.h:2952

Referenced by PortDispatchPnp().

◆ PortPdoScheduleRequestFlowControlled()

BOOLEAN PortPdoScheduleRequestFlowControlled ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ PQUEUED_REQUEST_REFERENCE  RequestReference 
)

Schedules an outstanding request and return a boolean value to indicate if the request can be immediately issued.

Parameters
PdoExtensionPDO device extension.
FdoExtensionFDO device extension.
RequestReferenceRequestReference must be allocated beforehand.
Returns
BOOLEAN When TRUE, you can call PortPdoIssueRequest to issue request right away; When FALSE, the request is already queued in flow control structures and you can safely go on without further processing, it will be issued upon completions.

Definition at line 397 of file srb.c.

401{
402 PPDO_IO_FLOW_CONTROL FlowControl = &PdoExtension->FlowControl;
404 PSCSI_REQUEST_BLOCK Srb = RequestReference->Srb;
405 BOOLEAN StrongOrderedRequest = FALSE;
406 BOOLEAN IssueRequest = TRUE;
407
408 /* Set outstanding flag */
409 RequestReference->IsOutstanding = TRUE;
410
411 /* Check if we can issue this request. */
412 /* Acquire the HBA global flow control lock first */
415
416 do
417 {
418 /* Check PDO flow control conditions */
419
420 /* Sanity check */
421 NT_ASSERT(FlowControl->OutstandingRequestCount <= PdoExtension->OutstandingRequestMax);
422
423 /* If PDO is not suitable to receive a request, make it wait */
424 if (FlowControl->IsBusy || FlowControl->IsPaused ||
427 FlowControl->StrongOrderedCount ||
428 FlowControl->OutstandingRequestCount == PdoExtension->OutstandingRequestMax ||
429 (!IsListEmpty(&FlowControl->AwaitingRequestsListHead)))
430 {
432 &RequestReference->PdoEntry);
433 IssueRequest = FALSE;
434 break;
435 }
436
437 /* Check if this request is strong-ordered */
440 {
441 RequestReference->StrongOrdered = TRUE;
442 StrongOrderedRequest = TRUE;
443 ++FlowControl->StrongOrderedCount;
444 }
445
446 /*
447 * If this request is strong ordered and the LUN's active/approved list is not
448 * drained, the request must wait.
449 */
450 if (StrongOrderedRequest && !IsListEmpty(&FlowControl->ActiveRequestsListHead))
451 {
453 &RequestReference->PdoEntry);
454 IssueRequest = FALSE;
455 break;
456 }
457
458 /*
459 * If any break's triggered before this point, the request is in PDO waiting queue.
460 * Going past this point meant PDO approves this request. Put it into active list.
461 */
463 {
465 &RequestReference->PdoEntry);
466 } else {
468 &RequestReference->PdoEntry);
469 }
470
471 /* A new outstanding request is added to this LUN */
472 ++FlowControl->OutstandingRequestCount;
473
474 /* Check FDO flow control status. */
475
476 /* If the FDO can't handle more requests, then the request should be queued. */
477 if (FlowControl->IsBusy || FlowControl->IsPaused ||
478 FlowControl->OutstandingRequestCount == FdoExtension->OutstandingRequestMax)
479 {
480 /* Put into FDO queue */
481 InsertHeadList(&FdoExtension->FlowControl.FdoBlockedRequestsListHead,
482 &RequestReference->FdoEntry);
483
484 /*
485 * Now the request is in PDO active list, in FDO awaiting queue, not issued.
486 * Let it wait until another completion event schedules it.
487 */
488 break;
489 }
490
491 /* Seems good, increment FDO request count */
492 ++FdoExtension->FlowControl.OutstandingRequestCount;
493
494 /*
495 * Now the request is counted in FDO & PDO, and is put into PDO active list,
496 * next step we're going to issue it.
497 */
498 } while (0);
499
500 // FIXME: The port driver indicates that an LU-specific queue has been frozen by
501 // returning a request with SRB_STATUS_QUEUE_FROZEN in the SrbStatus member. New
502 // requests from the class driver can be inserted into the queue, but only autosense
503 // requests are sent to the logical unit as long as its queue is frozen.
504 // https://learn.microsoft.com/en-us/windows-hardware/drivers/storage/storage-class-driver-s-releasequeue-routine
505
506 /* We've determined where the request goes. Release the flow control lock */
509
510 return IssueRequest;
511}
#define SRB_FLAGS_BYPASS_FROZEN_QUEUE
Definition: srb.h:398
#define SRB_ORDERED_QUEUE_TAG_REQUEST
Definition: srb.h:425
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:395
#define SRB_HEAD_OF_QUEUE_TAG_REQUEST
Definition: srb.h:424
#define SRB_FLAGS_BYPASS_LOCKED_QUEUE
Definition: srb.h:410
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define StorpCheckFlowControl(...)
Definition: inline.h:252
UCHAR QueueAction
Definition: srb.h:257
ULONG SrbFlags
Definition: srb.h:260

Referenced by PortPdoScsi().

◆ PortPdoScsi()

NTSTATUS NTAPI PortPdoScsi ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp 
)

Definition at line 516 of file srb.c.

519{
525 PMINIPORT Miniport;
526 PHW_INITIALIZATION_DATA HwInitData;
527
528 DPRINT("PortPdoScsi(%p %p)\n", DeviceObject, Irp);
529
531 Srb = Stack->Parameters.Scsi.Srb;
532
533 if (Srb == NULL) {
534 DPRINT1("Srb is NULL!");
537
538 Irp->IoStatus.Information = 0;
539 Irp->IoStatus.Status = Status;
540
542 return Status;
543 }
544
547 FdoExtension = PdoExtension->FdoExtension;
549 Miniport = &FdoExtension->Miniport;
550 HwInitData = Miniport->InitData;
551
552 switch (Srb->Function) {
553 /* Both of these should be sent to device and let themselves process this */
556 {
557 PQUEUED_REQUEST_REFERENCE RequestReference;
558 BOOLEAN IssueRequest;
559
560 /* Mark IRP as pending */
562
563 /* Allocate private contexts */
565 if (Status != STATUS_SUCCESS)
566 {
567 break;
568 }
569 RequestReference = (PQUEUED_REQUEST_REFERENCE)Srb->OriginalRequest;
570
571 /* Assign a tag to the SRB if it supports tagging */
573
574 DPRINT("New request (%d:%d:%d) ReqRef %p Srb %p Irp %p Tag %x SrbExt %p(%d)\n",
576 RequestReference, Srb, Irp, Srb->QueueTag,
577 Srb->SrbExtension, HwInitData->SrbExtensionSize);
578
579 /*
580 * Do the scheduling. If returns TRUE, we should issue this request to the hardware.
581 * Otherwise it will keep waiting until next completion schedules it, or be cancelled on
582 * an error, etc.
583 */
586 RequestReference);
587
588 /* This request is viable to be issued. */
589 if (IssueRequest)
590 {
591 Status = PortPdoIssueRequest(PdoExtension, RequestReference);
592 } else {
594 }
595
596 break;
597 }
598
599 /*
600 * These requests are actually sent to adapters and are not outstanding requests for devices
601 * so we simply pass them down to miniport
602 */
605 {
606 PQUEUED_REQUEST_REFERENCE RequestReference;
607
608 /* Mark IRP as pending */
610
611 /* Allocate private contexts */
613 if (Status != STATUS_SUCCESS)
614 {
615 break;
616 }
617 RequestReference = (PQUEUED_REQUEST_REFERENCE)Srb->OriginalRequest;
618
619 /*
620 * Call the non-flow-controlled scheduling function (it does nothing but the model is
621 * preserved for consistency)
622 */
624
625 /* Fire up the request immediately */
626 PortPdoIssueRequest(PdoExtension, RequestReference);
627
628 break;
629 }
630
632 {
633 if (InterlockedCompareExchange(&PdoExtension->IsClaimed, 1, 0))
634 {
637 break;
638 }
639
640 /* The claimed device object is handed back to the class driver here */
641 Srb->DataBuffer = PdoExtension->Device;
644 break;
645 }
646
648 {
649 InterlockedExchange(&PdoExtension->IsClaimed, 0);
650
653 break;
654 }
655
656 default:
657 DPRINT1("Unsupported Srb Function %02X!", Srb->Function);
658 // DbgBreakPoint();
661 break;
662 }
663
664 return Status;
665}
#define InterlockedExchange
Definition: armddk.h:54
#define SRB_FUNCTION_RELEASE_DEVICE
Definition: srb.h:321
#define SRB_FUNCTION_CLAIM_DEVICE
Definition: srb.h:316
#define SRB_FUNCTION_IO_CONTROL
Definition: srb.h:317
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_FUNCTION_FLUSH
Definition: srb.h:323
#define SRB_FUNCTION_SHUTDOWN
Definition: srb.h:322
#define SRB_STATUS_BUSY
Definition: srb.h:345
#define SRB_STATUS_SUCCESS
Definition: srb.h:341
#define SRB_STATUS_INVALID_REQUEST
Definition: srb.h:346
struct _QUEUED_REQUEST_REFERENCE * PQUEUED_REQUEST_REFERENCE
#define InterlockedCompareExchange
Definition: interlocked.h:119
IoMarkIrpPending(Irp)
FORCEINLINE BOOLEAN StorpAssignTagToSrb(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PSCSI_REQUEST_BLOCK Srb)
Assigns a queue tag to a request if it stated it supports one.
Definition: srb.c:136
BOOLEAN PortPdoScheduleRequestFlowControlled(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PQUEUED_REQUEST_REFERENCE RequestReference)
Schedules an outstanding request and return a boolean value to indicate if the request can be immedia...
Definition: srb.c:397
VOID PortPdoScheduleRequestNoFlowControl(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PQUEUED_REQUEST_REFERENCE RequestReference)
Definition: srb.c:376
NTSTATUS PortPdoSrbAllocatePrivateContexts(_In_ PSCSI_REQUEST_BLOCK Srb, _In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: srb.c:240
NTSTATUS PortPdoIssueRequest(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PQUEUED_REQUEST_REFERENCE RequestReference)
Definition: srb.c:290
ULONG SrbExtensionSize
Definition: srb.h:576
PHW_INITIALIZATION_DATA InitData
Definition: precomp.h:91
UCHAR QueueTag
Definition: srb.h:256
UCHAR TargetId
Definition: srb.h:254
PVOID OriginalRequest
Definition: srb.h:266
PVOID DataBuffer
Definition: srb.h:263
UCHAR PathId
Definition: srb.h:253
UCHAR Function
Definition: srb.h:250
PVOID SrbExtension
Definition: srb.h:267
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
NTSYSAPI void WINAPI DbgBreakPoint(void)

Referenced by PortDispatchScsi(), and PortRetryStarvedRequest().

◆ PortQueueStarvedRequest()

VOID PortQueueStarvedRequest ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ PIRP  Irp 
)

Queues a request that could not allocate its private contexts.

Definition at line 124 of file fdo.c.

127{
128 IoCsqInsertIrp(&FdoExtension->StarvedRequests.Csq, Irp, NULL);
129}
NTKERNELAPI VOID NTAPI IoCsqInsertIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context)
Insert an IRP into the CSQ.
Definition: csq.c:177

Referenced by PortPdoStarveRequest().

◆ PortRetryStarvedRequest()

VOID PortRetryStarvedRequest ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)

Retries one queued request, so each completion lets exactly one through.

Definition at line 135 of file fdo.c.

137{
138 PIRP Irp;
139
140 Irp = IoCsqRemoveNextIrp(&FdoExtension->StarvedRequests.Csq, NULL);
141 if (Irp == NULL)
142 {
143 return;
144 }
145
147}
NTSTATUS NTAPI PortPdoScsi(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: srb.c:516

Referenced by PortCompleteRequest().

◆ QueryBusInterface()

NTSTATUS QueryBusInterface ( PDEVICE_OBJECT  DeviceObject,
PGUID  Guid,
USHORT  Size,
USHORT  Version,
PBUS_INTERFACE_STANDARD  Interface,
PVOID  InterfaceSpecificData 
)

Definition at line 122 of file misc.c.

129{
132 PIRP Irp;
135
137
140 NULL,
141 0,
142 NULL,
143 &Event,
144 &IoStatus);
145 if (Irp == NULL)
147
149
150 Stack->MajorFunction = IRP_MJ_PNP;
151 Stack->MinorFunction = IRP_MN_QUERY_INTERFACE;
152 Stack->Parameters.QueryInterface.InterfaceType = Guid;
153 Stack->Parameters.QueryInterface.Size = Size;
154 Stack->Parameters.QueryInterface.Version = Version;
155 Stack->Parameters.QueryInterface.Interface = (PINTERFACE)Interface;
156 Stack->Parameters.QueryInterface.InterfaceSpecificData = InterfaceSpecificData;
157
158 Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
159
161 if (Status == STATUS_PENDING)
162 {
164
165 Status=IoStatus.Status;
166 }
167
168 return Status;
169}
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
nsresult QueryInterface(nsIIDRef riid, void **result)
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
@ NotificationEvent
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1101
struct _INTERFACE * PINTERFACE
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT _In_opt_ PVOID InterfaceSpecificData
Definition: wdffdo.h:472
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2702
#define IRP_MN_QUERY_INTERFACE
@ Executive
Definition: ketypes.h:467

Referenced by PortFdoStartDevice().

◆ SimpleTimerCallbackDpcRoutine()

VOID NTAPI SimpleTimerCallbackDpcRoutine ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)

Definition at line 327 of file misc.c.

332{
336
338
340 NT_ASSERT(FdoExtension->Miniport.MiniportExtension);
341
342 FdoExtension->TimerCallback(&FdoExtension->Miniport.MiniportExtension->HwDeviceExtension);
343}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:755

Referenced by PortAddDevice().

◆ StorpSrbFreeRequestReference()

VOID StorpSrbFreeRequestReference ( _In_ PSCSI_REQUEST_BLOCK  Srb)

Frees an SRB's Request Reference and restore Srb->OriginalRequest field to IRP. This function does not check if Srb->OriginalRequest is actually an request reference, and you must determine it by other means.

Parameters
Srb

Definition at line 106 of file srb.c.

108{
109 PQUEUED_REQUEST_REFERENCE RequestReference;
111
112 RequestReference = (PQUEUED_REQUEST_REFERENCE)Srb->OriginalRequest;
113 Srb->OriginalRequest = RequestReference->Irp;
114 FdoExtension = RequestReference->PdoExtension->FdoExtension;
115
116 if (RequestReference->FromReserve)
117 {
118 InterlockedExchange(&FdoExtension->ReserveInUse, 0);
119 }
120 else
121 {
122 ExFreeToNPagedLookasideList(&FdoExtension->RequestReferenceLookaside, RequestReference);
123 }
124}
if(dx< 0)
Definition: linetemp.h:194
PPDO_DEVICE_EXTENSION PdoExtension
Definition: precomp.h:342

Referenced by PortCompleteRequest(), and PortPdoSrbAllocatePrivateContexts().

◆ TimerCallbackDpcRoutine()

VOID NTAPI TimerCallbackDpcRoutine ( PKDPC  Dpc,
PVOID  DeferredContext,
PVOID  SystemArgument1,
PVOID  SystemArgument2 
)

Definition at line 348 of file misc.c.

353{
357
359
360 /*
361 * Miniport can schedule a new timer event inside of callback, we should clear timer activated
362 * status here to ensure timer can be correctly scheduled
363 */
364 TimerEntry->TimerAlreadySet = 0;
365
366 TimerEntry->TimerCallback(TimerEntry->HwDeviceExtension,
367 TimerEntry->Context);
368}
struct _TIMER_ENTRY * PTIMER_ENTRY
Definition: precomp.h:103
PVOID Context
Definition: precomp.h:110
LONG TimerAlreadySet
Definition: precomp.h:107
PHW_TIMER_EX TimerCallback
Definition: precomp.h:109
PVOID HwDeviceExtension
Definition: precomp.h:108

Referenced by StorPortExtendedFunction().

◆ TranslateResourceListAddress()

BOOLEAN TranslateResourceListAddress ( PFDO_DEVICE_EXTENSION  DeviceExtension,
INTERFACE_TYPE  BusType,
ULONG  SystemIoBusNumber,
STOR_PHYSICAL_ADDRESS  IoAddress,
ULONG  NumberOfBytes,
BOOLEAN  InIoSpace,
PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 173 of file misc.c.

181{
182 PCM_FULL_RESOURCE_DESCRIPTOR FullDescriptorA, FullDescriptorT;
183 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptorA, PartialDescriptorT;
184 INT i, j;
185
186 DPRINT1("TranslateResourceListAddress(%p)\n", DeviceExtension);
187
188 FullDescriptorA = DeviceExtension->AllocatedResources->List;
189 FullDescriptorT = DeviceExtension->TranslatedResources->List;
190 for (i = 0; i < DeviceExtension->AllocatedResources->Count; i++)
191 {
192 for (j = 0; j < FullDescriptorA->PartialResourceList.Count; j++)
193 {
194 PartialDescriptorA = FullDescriptorA->PartialResourceList.PartialDescriptors + j;
195 PartialDescriptorT = FullDescriptorT->PartialResourceList.PartialDescriptors + j;
196
197 switch (PartialDescriptorA->Type)
198 {
200 DPRINT1("Port: 0x%I64x (0x%lx)\n",
201 PartialDescriptorA->u.Port.Start.QuadPart,
202 PartialDescriptorA->u.Port.Length);
203 if (InIoSpace &&
204 IoAddress.QuadPart >= PartialDescriptorA->u.Port.Start.QuadPart &&
205 IoAddress.QuadPart + NumberOfBytes <= PartialDescriptorA->u.Port.Start.QuadPart + PartialDescriptorA->u.Port.Length)
206 {
207 TranslatedAddress->QuadPart = PartialDescriptorT->u.Port.Start.QuadPart +
208 (IoAddress.QuadPart - PartialDescriptorA->u.Port.Start.QuadPart);
209 return TRUE;
210 }
211 break;
212
214 DPRINT1("Memory: 0x%I64x (0x%lx)\n",
215 PartialDescriptorA->u.Memory.Start.QuadPart,
216 PartialDescriptorA->u.Memory.Length);
217 if (!InIoSpace &&
218 IoAddress.QuadPart >= PartialDescriptorA->u.Memory.Start.QuadPart &&
219 IoAddress.QuadPart + NumberOfBytes <= PartialDescriptorA->u.Memory.Start.QuadPart + PartialDescriptorA->u.Memory.Length)
220 {
221 TranslatedAddress->QuadPart = PartialDescriptorT->u.Memory.Start.QuadPart +
222 (IoAddress.QuadPart - PartialDescriptorA->u.Memory.Start.QuadPart);
223 return TRUE;
224 }
225 break;
226 }
227 }
228
229 /* Advance to next CM_FULL_RESOURCE_DESCRIPTOR block in memory. */
230 FullDescriptorA = (PCM_FULL_RESOURCE_DESCRIPTOR)(FullDescriptorA->PartialResourceList.PartialDescriptors +
231 FullDescriptorA->PartialResourceList.Count);
232
233 FullDescriptorT = (PCM_FULL_RESOURCE_DESCRIPTOR)(FullDescriptorT->PartialResourceList.PartialDescriptors +
234 FullDescriptorT->PartialResourceList.Count);
235 }
236
237 return FALSE;
238}
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 * u
Definition: glfuncs.h:240
#define CmResourceTypeMemory
Definition: restypes.h:106
#define CmResourceTypePort
Definition: restypes.h:104
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@496 Port
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@499 Memory
PCM_RESOURCE_LIST AllocatedResources
Definition: precomp.h:242
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275

Referenced by StorPortGetDeviceBase().