ReactOS 0.4.17-dev-1343-g8fe3cee
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  _EXTENDED_REQUEST
 
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_LUN_EXTENSION   'ELtS'
 
#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)
 
#define HW_INIT_DATA_SIZE_PHYSICAL   FIELD_OFFSET(HW_INITIALIZATION_DATA, HwFreeAdapterResources)
 
#define HW_INIT_DATA_SIZE_VIRTUAL_LEGACY   FIELD_OFFSET(HW_INITIALIZATION_DATA, HwTracingEnabled)
 

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 _EXTENDED_REQUEST EXTENDED_REQUEST
 
typedef struct _EXTENDED_REQUEST * PEXTENDED_REQUEST
 
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)
 
PPDO_DEVICE_EXTENSION NTAPI FdoFindLunAboveDispatch (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Bus, _In_ ULONG Target, _In_ ULONG Lun)
 Finds a unit from an interrupt service routine or any other caller above DISPATCH_LEVEL.
 
VOID NTAPI PortFdoLinkPdo (_Inout_ PFDO_DEVICE_EXTENSION FdoExtension, _Inout_ PPDO_DEVICE_EXTENSION PdoExtension)
 Adds a PDO where both the list lock and the interrupt service routines respect it.
 
VOID NTAPI PortFdoUnlinkPdo (_Inout_ PFDO_DEVICE_EXTENSION FdoExtension, _Inout_ PPDO_DEVICE_EXTENSION PdoExtension)
 
VOID NTAPI PortFdoBusChangeDpc (_In_ PKDPC Dpc, _In_opt_ PVOID DeferredContext, _In_opt_ PVOID SystemArgument1, _In_opt_ PVOID SystemArgument2)
 
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)
 
VOID NTAPI MiniportFreeAdapterResources (_In_ PMINIPORT Miniport)
 Tells the miniport the adapter is going away.
 
BOOLEAN NTAPI MiniportHwMSInterrupt (_In_ PMINIPORT Miniport, _In_ ULONG MessageId)
 
VOID NTAPI MiniportQueryAdapterControl (_In_ PMINIPORT Miniport)
 Asks the miniport which adapter control requests it handles.
 
SCSI_ADAPTER_CONTROL_STATUS NTAPI MiniportAdapterControl (_In_ PMINIPORT Miniport, _In_ SCSI_ADAPTER_CONTROL_TYPE ControlType, _In_opt_ PVOID Parameters)
 Sends one adapter control request, if the miniport claimed it.
 
VOID NTAPI MiniportQueryUnitControl (_In_ PMINIPORT Miniport)
 Asks the miniport which unit control requests it handles.
 
SCSI_UNIT_CONTROL_STATUS NTAPI MiniportUnitControl (_In_ PMINIPORT Miniport, _In_ SCSI_UNIT_CONTROL_TYPE ControlType, _In_opt_ PVOID Parameters)
 Sends one unit control request, if the miniport claimed it.
 
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)
 
VOID NTAPI StorpBuildUnitAddress (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Out_ PSTOR_ADDR_BTL8 Address)
 Fills in the bus, target and LUN address of a logical unit.
 
BOOLEAN NTAPI StorpIsExtendedSrb (_In_ PVOID Srb)
 Tells whether a request block is in the extended format.
 
PQUEUED_REQUEST_REFERENCE NTAPI StorpRequestReference (_In_ PSCSI_REQUEST_BLOCK Srb)
 Finds the request reference behind an SRB in either format.
 
PVOID NTAPI StorpSrbDataBuffer (_In_ PSCSI_REQUEST_BLOCK Srb)
 Finds the data buffer of a request in either format.
 
VOID NTAPI StorpBuildExtendedSrb (_In_ PSCSI_REQUEST_BLOCK Srb, _Out_ PEXTENDED_REQUEST Request)
 Fills in the extended request a miniport will be given.
 
VOID NTAPI StorpCompleteExtendedSrb (_In_ PSCSI_REQUEST_BLOCK Srb, _In_ PEXTENDED_REQUEST Request)
 Carries the miniport's answer back to the original request block.
 
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 45 of file precomp.h.

◆ HW_INIT_DATA_SIZE_PHYSICAL

#define HW_INIT_DATA_SIZE_PHYSICAL   FIELD_OFFSET(HW_INITIALIZATION_DATA, HwFreeAdapterResources)

Definition at line 72 of file precomp.h.

◆ HW_INIT_DATA_SIZE_VIRTUAL_LEGACY

#define HW_INIT_DATA_SIZE_VIRTUAL_LEGACY   FIELD_OFFSET(HW_INITIALIZATION_DATA, HwTracingEnabled)

Definition at line 75 of file precomp.h.

◆ SET_FLAG

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

Definition at line 44 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_LUN_EXTENSION

#define TAG_LUN_EXTENSION   'ELtS'

Definition at line 38 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 41 of file precomp.h.

◆ TAG_REPORT_LUN_DATA

#define TAG_REPORT_LUN_DATA   'LRtS'

Definition at line 39 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 40 of file precomp.h.

◆ TAG_SRB_EXTENSION

#define TAG_SRB_EXTENSION   'XStS'

Definition at line 42 of file precomp.h.

◆ TEST_FLAG

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

Definition at line 46 of file precomp.h.

Typedef Documentation

◆ DRIVER_INIT_DATA

◆ DRIVER_OBJECT_EXTENSION

◆ EXTENDED_REQUEST

◆ 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

◆ PEXTENDED_REQUEST

◆ 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 48 of file precomp.h.

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

◆ EXTENSION_TYPE

Enumerator
InvalidExtension 
DriverExtension 
FdoExtension 
PdoExtension 

Definition at line 57 of file precomp.h.

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

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:3171
_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 1306 of file fdo.c.

1311{
1314
1318
1319 return PdoExtension;
1320}
_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
static PPDO_DEVICE_EXTENSION FdoScanPdoList(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Bus, _In_ ULONG Target, _In_ ULONG Lun)
Walks the PDO list for a unit, the caller keeps the list from changing.
Definition: fdo.c:1279
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
Definition: kefuncs.h:717

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

◆ FdoFindLunAboveDispatch()

PPDO_DEVICE_EXTENSION NTAPI FdoFindLunAboveDispatch ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ ULONG  Bus,
_In_ ULONG  Target,
_In_ ULONG  Lun 
)

Finds a unit from an interrupt service routine or any other caller above DISPATCH_LEVEL.

Definition at line 1405 of file fdo.c.

1410{
1412 KIRQL OldIrql;
1413
1414 /* At device IRQL the caller is an ISR or synchronized routine and already holds a lock */
1415 if (KeGetCurrentIrql() >= FdoExtension->InterruptIrql)
1416 return FdoScanPdoList(FdoExtension, Bus, Target, Lun);
1417
1421
1422 return PdoExtension;
1423}
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
static VOID PortFdoReleaseInterruptLocks(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ KIRQL OldIrql)
Definition: fdo.c:1361
static KIRQL PortFdoAcquireInterruptLocks(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Keeps every interrupt service routine of the adapter from running.
Definition: fdo.c:1330
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by StorPortGetLogicalUnit().

◆ 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
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:257
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:1124
_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:1125

Referenced by PortFdoConnectInterrupt().

◆ MiniportAdapterControl()

SCSI_ADAPTER_CONTROL_STATUS NTAPI MiniportAdapterControl ( _In_ PMINIPORT  Miniport,
_In_ SCSI_ADAPTER_CONTROL_TYPE  ControlType,
_In_opt_ PVOID  Parameters 
)

Sends one adapter control request, if the miniport claimed it.

Definition at line 504 of file miniport.c.

508{
509 DPRINT("MiniportAdapterControl(%p %u %p)\n",
510 Miniport, ControlType, Parameters);
511
512 ASSERT(ControlType < ScsiAdapterControlMax);
513 if (!(Miniport->AdapterControlSupportedBitmap & (1 << ControlType)))
514 {
516 }
517
518 return Miniport->InitData->HwAdapterControl(&Miniport->MiniportExtension->HwDeviceExtension,
519 ControlType,
520 Parameters);
521}
_In_ HANDLE _In_ CONST PDXGKMDT_OPM_GET_INFO_PARAMETERS Parameters
Definition: dispmprt.h:321
@ ScsiAdapterControlMax
Definition: srb.h:182
@ ScsiAdapterControlUnsuccessful
Definition: srb.h:192
#define DPRINT
Definition: sndvol32.h:73

Referenced by PortFdoStopAdapter().

◆ MiniportFindAdapter()

NTSTATUS MiniportFindAdapter ( _In_ PMINIPORT  Miniport)

Definition at line 325 of file miniport.c.

327{
328 PFDO_DEVICE_EXTENSION DeviceExtension = Miniport->DeviceExtension;
332
333 DPRINT1("MiniportFindAdapter(%p)\n", Miniport);
334
335 /* HwFindAdapter is typeless since Win8, a virtual miniport puts a PVIRTUAL_HW_FIND_ADAPTER there */
336 if (Miniport->IsVirtual)
337 {
338 PVIRTUAL_HW_FIND_ADAPTER FindAdapter;
339
340 FindAdapter = (PVIRTUAL_HW_FIND_ADAPTER)Miniport->InitData->HwFindAdapter;
341
342 Result = FindAdapter(&Miniport->MiniportExtension->HwDeviceExtension,
343 DeviceExtension->PhysicalDevice,
344 DeviceExtension->Device,
345 DeviceExtension->LowerDevice,
346 NULL,
347 &Miniport->PortConfig,
348 &Reserved);
349 }
350 else
351 {
352 PHW_FIND_ADAPTER FindAdapter;
353
354 FindAdapter = (PHW_FIND_ADAPTER)Miniport->InitData->HwFindAdapter;
355
356 Result = FindAdapter(&Miniport->MiniportExtension->HwDeviceExtension,
357 NULL,
358 NULL,
359 NULL,
360 &Miniport->PortConfig,
361 &Reserved);
362 }
363 DPRINT1("HwFindAdapter() returned %lu\n", Result);
364
365 /* Convert the result to a status code */
366 switch (Result)
367 {
369 DPRINT1("SP_RETURN_NOT_FOUND\n");
371 break;
372
373 case SP_RETURN_FOUND:
374 DPRINT1("SP_RETURN_FOUND\n");
376 break;
377
378 case SP_RETURN_ERROR:
379 DPRINT1("SP_RETURN_ERROR\n");
381 break;
382
384 DPRINT1("SP_RETURN_BAD_CONFIG\n");
386 break;
387
388 default:
389 DPRINT1("Unknown result: %lu\n", Result);
391 break;
392 }
393
394 return Status;
395}
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
ULONG(NTAPI * PHW_FIND_ADAPTER)(IN PVOID DeviceExtension, IN PVOID HwContext, IN PVOID BusInformation, IN PCHAR ArgumentString, IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, OUT PBOOLEAN Again)
Definition: srb.h:468
#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
ULONG(NTAPI * PVIRTUAL_HW_FIND_ADAPTER)(_In_ PVOID DeviceExtension, _In_ PVOID HwContext, _In_ PVOID BusInformation, _In_ PVOID LowerDevice, _In_ PCHAR ArgumentString, _Inout_ PPORT_CONFIGURATION_INFORMATION ConfigInfo, _In_ PBOOLEAN Again)
Definition: storport.h:7123
PDEVICE_OBJECT LowerDevice
Definition: i8042prt.h:130
PDEVICE_OBJECT PhysicalDevice
Definition: precomp.h:248
PDEVICE_OBJECT Device
Definition: precomp.h:246
_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().

◆ MiniportFreeAdapterResources()

VOID NTAPI MiniportFreeAdapterResources ( _In_ PMINIPORT  Miniport)

Tells the miniport the adapter is going away.

Definition at line 419 of file miniport.c.

421{
422 if (Miniport->MiniportExtension == NULL ||
423 Miniport->InitData->HwInitializationDataSize != sizeof(*Miniport->InitData) ||
424 Miniport->InitData->HwFreeAdapterResources == NULL)
425 {
426 return;
427 }
428
429 DPRINT1("MiniportFreeAdapterResources(%p)\n", Miniport);
430
431 Miniport->InitData->HwFreeAdapterResources(&Miniport->MiniportExtension->HwDeviceExtension);
432}

Referenced by PortFdoPnp().

◆ MiniportHwInitialize()

NTSTATUS MiniportHwInitialize ( _In_ PMINIPORT  Miniport)

Definition at line 399 of file miniport.c.

401{
403
404 DPRINT("MiniportHwInitialize(%p)\n", Miniport);
405
406 /* Call the miniport HwInitialize routine */
407 Result = Miniport->InitData->HwInitialize(&Miniport->MiniportExtension->HwDeviceExtension);
408 DPRINT("HwInitialize() returned %u\n", Result);
409
411}
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by PortFdoStartMiniport().

◆ MiniportHwInterrupt()

BOOLEAN MiniportHwInterrupt ( _In_ PMINIPORT  Miniport)

Definition at line 436 of file miniport.c.

438{
440
441 DPRINT("MiniportHwInterrupt(%p)\n",
442 Miniport);
443
444 Result = Miniport->InitData->HwInterrupt(&Miniport->MiniportExtension->HwDeviceExtension);
445 DPRINT("HwInterrupt() returned %u\n", Result);
446
447 return Result;
448}

Referenced by PortFdoInterruptRoutine().

◆ MiniportHwMSInterrupt()

BOOLEAN NTAPI MiniportHwMSInterrupt ( _In_ PMINIPORT  Miniport,
_In_ ULONG  MessageId 
)

Definition at line 603 of file miniport.c.

606{
608
609 DPRINT("MiniportHwMSInterrupt(%p %lu)\n",
610 Miniport, MessageId);
611
612 Result = Miniport->PortConfig.HwMSInterruptRoutine(&Miniport->MiniportExtension->HwDeviceExtension,
613 MessageId);
614 DPRINT("HwMSInterruptRoutine() returned %u\n", Result);
615
616 return Result;
617}
_In_ ULONG MessageId
Definition: hubioctl.cpp:1369

Referenced by PortFdoMessageInterruptRoutine().

◆ MiniportInitialize()

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

Definition at line 264 of file miniport.c.

268{
269 PMINIPORT_DEVICE_EXTENSION MiniportExtension;
270 ULONG Size;
272
273 DPRINT1("MiniportInitialize(%p %p %p)\n",
274 Miniport, DeviceExtension, InitData);
275
276 Miniport->DeviceExtension = DeviceExtension;
277 Miniport->InitData = InitData;
278
279 /* Win7 virtual miniports used a shorter structure, Win8 ones set a feature flag */
280 Miniport->IsVirtual = (InitData->HwInitializationDataSize == HW_INIT_DATA_SIZE_VIRTUAL_LEGACY) ||
281 ((InitData->HwInitializationDataSize == sizeof(*InitData)) &&
282 (InitData->FeatureSupport & STOR_FEATURE_VIRTUAL_MINIPORT));
283 DPRINT1("Miniport is %s\n", Miniport->IsVirtual ? "virtual" : "physical");
284
285 /* Calculate the miniport device extension size */
286 Status = RtlULongAdd(sizeof(*MiniportExtension),
287 Miniport->InitData->DeviceExtensionSize,
288 &Size);
289 if (!NT_SUCCESS(Status))
290 {
291 DPRINT1("Invalid miniport extension size %lx\n", Miniport->InitData->DeviceExtensionSize);
292 return Status;
293 }
294
295 /* Allocate and initialize the miniport device extension */
296 MiniportExtension = ExAllocatePoolWithTag(NonPagedPool,
297 Size,
299 if (MiniportExtension == NULL)
300 return STATUS_NO_MEMORY;
301
302 RtlZeroMemory(MiniportExtension, Size);
303
304 MiniportExtension->Miniport = Miniport;
305 Miniport->MiniportExtension = MiniportExtension;
306
307 /* Initialize the port configuration */
308 Status = InitializeConfiguration(&Miniport->PortConfig,
309 InitData,
310 DeviceExtension->BusNumber,
311 DeviceExtension->SlotNumber);
312 if (!NT_SUCCESS(Status))
313 return Status;
314
315 /* Assign the resources to the port configuration */
316 AssignResourcesToConfiguration(&Miniport->PortConfig,
317 DeviceExtension->AllocatedResources,
318 InitData->NumberOfAccessRanges);
319
320 return STATUS_SUCCESS;
321}
#define TAG_MINIPORT_DATA
Definition: precomp.h:33
#define HW_INIT_DATA_SIZE_VIRTUAL_LEGACY
Definition: precomp.h:75
static VOID AssignResourcesToConfiguration(_In_ PPORT_CONFIGURATION_INFORMATION PortConfiguration, _In_ PCM_RESOURCE_LIST ResourceList, _In_ ULONG NumberOfAccessRanges)
Definition: miniport.c:113
static NTSTATUS InitializeConfiguration(_In_ PPORT_CONFIGURATION_INFORMATION PortConfig, _In_ PHW_INITIALIZATION_DATA InitData, _In_ ULONG BusNumber, _In_ ULONG SlotNumber)
Definition: miniport.c:20
#define STOR_FEATURE_VIRTUAL_MINIPORT
Definition: storport.h:2280
struct _MINIPORT * Miniport
Definition: precomp.h:91

◆ MiniportQueryAdapterControl()

VOID NTAPI MiniportQueryAdapterControl ( _In_ PMINIPORT  Miniport)

Asks the miniport which adapter control requests it handles.

Definition at line 456 of file miniport.c.

458{
462 ULONG Type;
463
464 Miniport->AdapterControlSupportedBitmap = 0;
465
466 if (Miniport->InitData->HwAdapterControl == NULL)
467 return;
468
469 Length = sizeof(*List) +
470 (ScsiAdapterControlMax * sizeof(List->SupportedTypeList[0]));
471
473 if (List == NULL)
474 return;
475
476 List->MaxControlType = ScsiAdapterControlMax;
477
478 Result = Miniport->InitData->HwAdapterControl(&Miniport->MiniportExtension->HwDeviceExtension,
480 List);
482 {
483 for (Type = 0; Type < ScsiAdapterControlMax; Type++)
484 {
485 C_ASSERT(ScsiAdapterControlMax <= RTL_BITS_OF(Miniport->AdapterControlSupportedBitmap));
486
487 if (List->SupportedTypeList[Type])
488 {
489 DPRINT1("Adapter control %lu supported\n", Type);
490 Miniport->AdapterControlSupportedBitmap |= 1 << Type;
491 }
492 }
493 }
494
496}
Type
Definition: Type.h:7
@ ScsiQuerySupportedControlTypes
Definition: srb.h:177
@ ScsiAdapterControlSuccess
Definition: srb.h:191
enum _SCSI_ADAPTER_CONTROL_STATUS SCSI_ADAPTER_CONTROL_STATUS
#define C_ASSERT(e)
Definition: intsafe.h:73
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define RTL_BITS_OF(sizeOfArg)
Definition: ntbasedef.h:680
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by PortFdoStartMiniport().

◆ MiniportQueryUnitControl()

VOID NTAPI MiniportQueryUnitControl ( _In_ PMINIPORT  Miniport)

Asks the miniport which unit control requests it handles.

Definition at line 529 of file miniport.c.

531{
535 ULONG Type;
536
537 Miniport->UnitControlSupportedBitmap = 0;
538
539 if (Miniport->InitData->HwInitializationDataSize <
541 Miniport->InitData->HwUnitControl == NULL)
542 {
543 return;
544 }
545
546 Length = sizeof(*List) +
547 (ScsiUnitControlMax * sizeof(List->SupportedTypeList[0]));
548
550 if (List == NULL)
551 return;
552
553 List->MaxControlType = ScsiUnitControlMax;
554
555 Result = Miniport->InitData->HwUnitControl(&Miniport->MiniportExtension->HwDeviceExtension,
557 List);
559 {
560 for (Type = 0; Type < ScsiUnitControlMax; Type++)
561 {
562 C_ASSERT(ScsiUnitControlMax <= RTL_BITS_OF(Miniport->UnitControlSupportedBitmap));
563
564 if (List->SupportedTypeList[Type])
565 {
566 DPRINT1("Unit control %lu supported\n", Type);
567 Miniport->UnitControlSupportedBitmap |= 1 << Type;
568 }
569 }
570 }
571
573}
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:684
enum _SCSI_UNIT_CONTROL_STATUS SCSI_UNIT_CONTROL_STATUS
@ ScsiUnitControlSuccess
Definition: storport.h:1591
@ ScsiQuerySupportedUnitControlTypes
Definition: storport.h:1568
@ ScsiUnitControlMax
Definition: storport.h:1585

Referenced by PortFdoStartMiniport().

◆ MiniportStartIo()

BOOLEAN MiniportStartIo ( _In_ PMINIPORT  Miniport,
_In_ PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 621 of file miniport.c.

624{
626
627 DPRINT("MiniportHwStartIo(%p %p)\n",
628 Miniport, Srb);
629
630 Result = Miniport->InitData->HwStartIo(&Miniport->MiniportExtension->HwDeviceExtension, Srb);
631 DPRINT("HwStartIo() returned %u\n", Result);
632
633 return Result;
634}
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989

◆ MiniportUnitControl()

SCSI_UNIT_CONTROL_STATUS NTAPI MiniportUnitControl ( _In_ PMINIPORT  Miniport,
_In_ SCSI_UNIT_CONTROL_TYPE  ControlType,
_In_opt_ PVOID  Parameters 
)

Sends one unit control request, if the miniport claimed it.

Definition at line 581 of file miniport.c.

585{
586 DPRINT("MiniportUnitControl(%p %u %p)\n",
587 Miniport, ControlType, Parameters);
588
589 ASSERT(ControlType < ScsiUnitControlMax);
590 if (!(Miniport->UnitControlSupportedBitmap & (1 << ControlType)))
591 {
593 }
594
595 return Miniport->InitData->HwUnitControl(&Miniport->MiniportExtension->HwDeviceExtension,
596 ControlType,
597 Parameters);
598}
@ ScsiUnitControlNotSupported
Definition: storport.h:1593

Referenced by PortCreatePdo(), and PortDeletePdo().

◆ 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->Miniport.PortConfig.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:42
#define TAG_QUEUED_REQUEST
Definition: precomp.h:41

Referenced by PortFdoStartDevice().

◆ PortCompletionDpc()

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

Definition at line 920 of file srb.c.

925{
926 PQUEUED_REQUEST_REFERENCE RequestReference;
930 ULONG Count = 0;
931
932 DPRINT("PortCompletionDpc(%p %p %p %p)\n", Dpc, Context, SystemArgument1, SystemArgument2);
933
934 /* Take context pointer as FDO extension */
936
937 /* Flush all entries in the list and complete all requests */
938 Entry = InterlockedFlushSList(&FdoExtension->CompletionList);
939 while (Entry)
940 {
941 /* Prepare Next pointer first (Completion routine will free the memory that contains it) */
942 Next = Entry->Next;
943
944 /* Get original request */
945 RequestReference = CONTAINING_RECORD(Entry, QUEUED_REQUEST_REFERENCE, CompletionEntry);
946
947 /* Call real completion routine */
948 PortCompleteRequest(RequestReference);
949
950 /* Move on to next one */
951 Entry = Next;
952 ++Count;
953 }
954
955 DPRINT("Completed %d requests\n", Count);
956}
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
PACPI_METHOD_ARGUMENT Next
Definition: slotdev.cpp:96
static VOID PortCompleteRequest(_In_ PQUEUED_REQUEST_REFERENCE RequestReference)
Definition: srb.c:770
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
USHORT Count
Definition: userreq.cpp:200
_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;
32
33 DPRINT("PortCreatePdo(%p %p)\n",
34 FdoDeviceExtension, PdoDeviceExtension);
35
36 /* Create the port device */
37 Status = IoCreateDevice(FdoDeviceExtension->Device->DriverObject,
39 NULL,
42 FALSE,
43 &Pdo);
44 if (!NT_SUCCESS(Status))
45 {
46 DPRINT1("IoCreateDevice() failed (Status 0x%lX)\n", Status);
47 return Status;
48 }
49
50 /* Initialize the device */
51 Pdo->Flags |= DO_DIRECT_IO;
52 Pdo->Flags |= DO_POWER_PAGABLE;
53
54 DeviceExtension = (PPDO_DEVICE_EXTENSION)Pdo->DeviceExtension;
55 RtlZeroMemory(DeviceExtension, sizeof(PDO_DEVICE_EXTENSION));
56
57 DeviceExtension->ExtensionType = PdoExtension;
58
59 DeviceExtension->Device = Pdo;
60 DeviceExtension->FdoExtension = FdoDeviceExtension;
61 DeviceExtension->PnpState = dsStopped;
62
63 /* Allocate the miniport's per unit extension before the unit is reachable */
64 if (FdoDeviceExtension->HwInitData != NULL &&
65 FdoDeviceExtension->HwInitData->SpecificLuExtensionSize != 0)
66 {
67 DeviceExtension->LunExtension =
69 FdoDeviceExtension->HwInitData->SpecificLuExtensionSize,
71 if (DeviceExtension->LunExtension == NULL)
72 {
73 DPRINT1("No pool for the unit extension\n");
76 }
77 }
78
79 DeviceExtension->Bus = Bus;
80 DeviceExtension->Target = Target;
81 DeviceExtension->Lun = Lun;
82
83 /* Initialize IO flow control structure */
84 // KeInitializeSpinLock(&DeviceExtension->FlowControl.Lock);
85 DeviceExtension->FlowControl.IsBusy = FALSE;
86 DeviceExtension->FlowControl.IsPaused = FALSE;
87 DeviceExtension->FlowControl.IsWaitingQueueClear = FALSE;
88 DeviceExtension->FlowControl.StrongOrderedCount = 0;
89 DeviceExtension->FlowControl.RemainingBusyRequests = 0;
90 DeviceExtension->FlowControl.RemainingPauseTime = 0;
91
92 /* Beginning from Windows 8, when you specified SRB_TYPE_STORAGE_REQUEST_BLOCK, you can increase
93 maximum number of outstanding requests to (254, MaxNumberOfIO) range. We do not support
94 STORAGE_REQUEST_BLOCKs so we're not implementing it.
95 */
97 // InitializeListHead(&DeviceExtension->FlowControl.ApprovedRequestsListHead);
99 DeviceExtension->FlowControl.OutstandingRequestCount = 0;
100 DeviceExtension->OutstandingRequestMax = 254;
101 DeviceExtension->TagCounter = -1;
102
103 DeviceExtension->IsClaimed = 0;
104
105 // FIXME: More initialization
106
107 DeviceExtension->SpecialRequestCounter = 0; /* FIXME: DELETE AFTER DEBUG */
108
109 /* Add the PDO to the PDO list only once a lookup can match its address */
110 PortFdoLinkPdo(FdoDeviceExtension, DeviceExtension);
111
112 /* Let the miniport know the unit is coming up */
113 StorpBuildUnitAddress(DeviceExtension, &Address);
114 MiniportUnitControl(&FdoDeviceExtension->Miniport, ScsiUnitStart, &Address);
115
116 /* The device has been initialized */
117 Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
118
119 *PdoDeviceExtension = DeviceExtension;
120
121 return STATUS_SUCCESS;
122}
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
#define TAG_LUN_EXTENSION
Definition: precomp.h:38
VOID NTAPI StorpBuildUnitAddress(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Out_ PSTOR_ADDR_BTL8 Address)
Fills in the bus, target and LUN address of a logical unit.
Definition: srbex.c:28
#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
@ 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
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1261
static WCHAR Address[46]
Definition: ping.c:68
struct STOR_ADDRESS_ALIGN _STOR_ADDR_BTL8 STOR_ADDR_BTL8
VOID NTAPI PortFdoLinkPdo(_Inout_ PFDO_DEVICE_EXTENSION FdoExtension, _Inout_ PPDO_DEVICE_EXTENSION PdoExtension)
Adds a PDO where both the list lock and the interrupt service routines respect it.
Definition: fdo.c:1431
SCSI_UNIT_CONTROL_STATUS NTAPI MiniportUnitControl(_In_ PMINIPORT Miniport, _In_ SCSI_UNIT_CONTROL_TYPE ControlType, _In_opt_ PVOID Parameters)
Sends one unit control request, if the miniport claimed it.
Definition: miniport.c:581
@ ScsiUnitStart
Definition: storport.h:1570
PFDO_DEVICE_EXTENSION FdoExtension
Definition: precomp.h:325
PDO_IO_FLOW_CONTROL FlowControl
Definition: precomp.h:337
PDEVICE_OBJECT Device
Definition: precomp.h:324
ULONG OutstandingRequestMax
Definition: precomp.h:338
DEVICE_STATE PnpState
Definition: precomp.h:326
EXTENSION_TYPE ExtensionType
Definition: precomp.h:322
LONG SpecialRequestCounter
Definition: precomp.h:341
LIST_ENTRY ActiveRequestsListHead
Definition: precomp.h:194
BOOLEAN IsWaitingQueueClear
Definition: precomp.h:176
ULONG RemainingBusyRequests
Definition: precomp.h:188
ULONG OutstandingRequestCount
Definition: precomp.h:185
ULONG StrongOrderedCount
Definition: precomp.h:182
ULONG RemainingPauseTime
Definition: precomp.h:191
LIST_ENTRY AwaitingRequestsListHead
Definition: precomp.h:200
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define DO_POWER_PAGABLE

Referenced by PortFdoScanBus().

◆ PortDeletePdo()

NTSTATUS PortDeletePdo ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension)

Definition at line 126 of file pdo.c.

128{
130
131 DPRINT("PortDeletePdo(%p)\n", PdoExtension);
132
133 /* Tell the miniport before the unit goes away under it */
135 MiniportUnitControl(&PdoExtension->FdoExtension->Miniport, ScsiUnitRemove, &Address);
136
137 /* Remove the PDO from the PDO list*/
139
140 if (PdoExtension->InquiryBuffer)
141 {
143 PdoExtension->InquiryBuffer = NULL;
144 }
145
146 /* The miniport was just told the unit is going, so what it kept goes too */
147 if (PdoExtension->LunExtension)
148 {
150 PdoExtension->LunExtension = NULL;
151 }
152
153
154 // FIXME: More uninitialization
155
156
157 /* Delete the PDO */
159
160 return STATUS_SUCCESS;
161}
#define TAG_INQUIRY_DATA
Definition: precomp.h:37
VOID NTAPI PortFdoUnlinkPdo(_Inout_ PFDO_DEVICE_EXTENSION FdoExtension, _Inout_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: fdo.c:1451
@ ScsiUnitRemove
Definition: storport.h:1577

Referenced by PortFdoScanBus().

◆ PortFdoBusChangeDpc()

VOID NTAPI PortFdoBusChangeDpc ( _In_ PKDPC  Dpc,
_In_opt_ PVOID  DeferredContext,
_In_opt_ PVOID  SystemArgument1,
_In_opt_ PVOID  SystemArgument2 
)

Definition at line 1471 of file fdo.c.

1476{
1478
1482
1483 DPRINT1("Bus change, invalidating bus relations\n");
1484
1486}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
VOID NTAPI IoInvalidateDeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type)
Definition: pnpmgr.c:1770
@ BusRelations
Definition: iotypes.h:2154
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:755

Referenced by PortAddDevice().

◆ PortFdoDeviceControl()

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

Definition at line 147 of file ioctl.c.

150{
151 PIO_STACK_LOCATION IoStack;
153
155
156 switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
157 {
159 return FdoDeviceControlQueryProperty(DeviceObject->DeviceExtension, Irp);
160
161 default:
162 // __debugbreak();
163 Status = Irp->IoStatus.Status;
164 break;
165 }
166
167 Irp->IoStatus.Status = Status;
168 Irp->IoStatus.Information = 0;
170
171 return Status;
172}
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::@1823 Parameters
struct _IO_STACK_LOCATION::@1823::@1824 DeviceIoControl
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by PortDispatchDeviceControl().

◆ PortFdoLinkPdo()

VOID NTAPI PortFdoLinkPdo ( _Inout_ PFDO_DEVICE_EXTENSION  FdoExtension,
_Inout_ PPDO_DEVICE_EXTENSION  PdoExtension 
)

Adds a PDO where both the list lock and the interrupt service routines respect it.

Definition at line 1431 of file fdo.c.

1434{
1436 KIRQL OldIrql;
1437
1440
1441 InsertHeadList(&FdoExtension->PdoListHead, &PdoExtension->PdoListEntry);
1442 FdoExtension->PdoCount++;
1443
1446}
#define InsertHeadList(ListHead, Entry)

Referenced by PortCreatePdo().

◆ PortFdoPnp()

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

Definition at line 1519 of file fdo.c.

1522{
1523 PFDO_DEVICE_EXTENSION DeviceExtension;
1527
1528 DPRINT1("PortFdoPnp(%p %p)\n",
1529 DeviceObject, Irp);
1530
1531 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
1532 ASSERT(DeviceExtension);
1533 ASSERT(DeviceExtension->ExtensionType == FdoExtension);
1534
1536
1537 switch (Stack->MinorFunction)
1538 {
1539 case IRP_MN_START_DEVICE: /* 0x00 */
1540 DPRINT("IRP_MJ_PNP / IRP_MN_START_DEVICE\n");
1541 Status = PortFdoStartDevice(DeviceExtension, Irp);
1542 break;
1543
1544 case IRP_MN_QUERY_REMOVE_DEVICE: /* 0x01 */
1545 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_REMOVE_DEVICE\n");
1546 break;
1547
1548 case IRP_MN_REMOVE_DEVICE: /* 0x02 */
1549 DPRINT1("IRP_MJ_PNP / IRP_MN_REMOVE_DEVICE\n");
1550 PortFdoStopAdapter(DeviceExtension);
1551 PortFdoDisconnectInterrupt(DeviceExtension);
1552
1553 /* Nothing may tell PnP about this adapter once it is gone */
1554 KeRemoveQueueDpc(&DeviceExtension->BusChangeDpc);
1555 KeFlushQueuedDpcs();
1556 MiniportFreeAdapterResources(&DeviceExtension->Miniport);
1557 PortFlushStarvedRequests(DeviceExtension);
1558 PortFreeRequestReserve(DeviceExtension);
1559 if (DeviceExtension->RequestReferenceLookasideInitialized)
1560 {
1563 }
1564 DeviceExtension->PnpState = dsRemoved;
1565 break;
1566
1567 case IRP_MN_CANCEL_REMOVE_DEVICE: /* 0x03 */
1568 DPRINT1("IRP_MJ_PNP / IRP_MN_CANCEL_REMOVE_DEVICE\n");
1569 break;
1570
1571 case IRP_MN_STOP_DEVICE: /* 0x04 */
1572 DPRINT1("IRP_MJ_PNP / IRP_MN_STOP_DEVICE\n");
1573 PortFdoStopAdapter(DeviceExtension);
1574 PortFdoDisconnectInterrupt(DeviceExtension);
1575 MiniportFreeAdapterResources(&DeviceExtension->Miniport);
1576 DeviceExtension->PnpState = dsStopped;
1577 break;
1578
1579 case IRP_MN_QUERY_STOP_DEVICE: /* 0x05 */
1580 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_STOP_DEVICE\n");
1581 break;
1582
1583 case IRP_MN_CANCEL_STOP_DEVICE: /* 0x06 */
1584 DPRINT1("IRP_MJ_PNP / IRP_MN_CANCEL_STOP_DEVICE\n");
1585 break;
1586
1587 case IRP_MN_QUERY_DEVICE_RELATIONS: /* 0x07 */
1588 switch (Stack->Parameters.QueryDeviceRelations.Type)
1589 {
1590 case BusRelations:
1591 DPRINT(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
1592 Status = PortFdoQueryBusRelations(DeviceExtension, &Information);
1593 break;
1594
1595 case RemovalRelations:
1596 DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / RemovalRelations\n");
1597 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1598
1599 default:
1600 DPRINT1(" IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
1601 Stack->Parameters.QueryDeviceRelations.Type);
1602 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1603 }
1604 break;
1605
1607 DPRINT("IRP_MJ_PNP / IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
1608 PortFdoFilterRequirements(DeviceExtension, Irp);
1609 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1610
1611 case IRP_MN_QUERY_PNP_DEVICE_STATE: /* 0x14 */
1612 DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_PNP_DEVICE_STATE\n");
1613 break;
1614
1615 case IRP_MN_DEVICE_USAGE_NOTIFICATION: /* 0x16 */
1616 DPRINT1("IRP_MJ_PNP / IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
1617 break;
1618
1619 case IRP_MN_SURPRISE_REMOVAL: /* 0x17 */
1620 DPRINT1("IRP_MJ_PNP / IRP_MN_SURPRISE_REMOVAL\n");
1621 break;
1622
1623 default:
1624 DPRINT1("IRP_MJ_PNP / Unknown IOCTL 0x%lx\n", Stack->MinorFunction);
1625 return ForwardIrpAndForget(DeviceExtension->LowerDevice, Irp);
1626 }
1627
1628 Irp->IoStatus.Information = Information;
1629 Irp->IoStatus.Status = Status;
1631
1632 return Status;
1633}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
BOOLEAN NTAPI KeRemoveQueueDpc(IN PKDPC Dpc)
Definition: dpc.c:878
@ dsRemoved
Definition: pci.h:38
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 VOID PortFdoStopAdapter(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Tells the miniport to stop the adapter with its interrupt service routines held off.
Definition: fdo.c:1389
static NTSTATUS PortFdoFilterRequirements(PFDO_DEVICE_EXTENSION DeviceExtension, PIRP Irp)
Definition: fdo.c:1254
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:519
static NTSTATUS PortFdoQueryBusRelations(_In_ PFDO_DEVICE_EXTENSION DeviceExtension, _Out_ PULONG_PTR Information)
Definition: fdo.c:1187
static VOID PortFdoDisconnectInterrupt(_In_ PFDO_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:384
VOID NTAPI MiniportFreeAdapterResources(_In_ PMINIPORT Miniport)
Tells the miniport the adapter is going away.
Definition: miniport.c:419
NPAGED_LOOKASIDE_LIST RequestReferenceLookaside
Definition: precomp.h:302
DEVICE_STATE PnpState
Definition: i8042prt.h:132
EXTENSION_TYPE ExtensionType
Definition: precomp.h:244
BOOLEAN RequestReferenceLookasideInitialized
Definition: precomp.h:303
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
#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 1491 of file fdo.c.

1494{
1495 PFDO_DEVICE_EXTENSION DeviceExtension;
1496// PIO_STACK_LOCATION Stack;
1499
1500 DPRINT("PortFdoScsi(%p %p)\n", DeviceObject, Irp);
1501
1502 DeviceExtension = (PFDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
1503 ASSERT(DeviceExtension);
1504 ASSERT(DeviceExtension->ExtensionType == FdoExtension);
1505
1506// Stack = IoGetCurrentIrpStackLocation(Irp);
1507
1508
1509 Irp->IoStatus.Information = Information;
1510 Irp->IoStatus.Status = Status;
1512
1513 return Status;
1514}

Referenced by PortDispatchScsi().

◆ PortFdoUnlinkPdo()

VOID NTAPI PortFdoUnlinkPdo ( _Inout_ PFDO_DEVICE_EXTENSION  FdoExtension,
_Inout_ PPDO_DEVICE_EXTENSION  PdoExtension 
)

Definition at line 1451 of file fdo.c.

Referenced by PortDeletePdo().

◆ 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 87 of file storport.c.

90{
91 PDRIVER_INIT_DATA InitData;
92 PLIST_ENTRY ListEntry;
93
94 DPRINT1("PortGetDriverInitData()\n");
95
96 ListEntry = DriverExtension->InitDataListHead.Flink;
97 while (ListEntry != &DriverExtension->InitDataListHead)
98 {
99 InitData = CONTAINING_RECORD(ListEntry,
101 Entry);
103 return &InitData->HwInitData;
104
105 ListEntry = ListEntry->Flink;
106 }
107
108 return NULL;
109}
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
HW_INITIALIZATION_DATA HwInitData
Definition: precomp.h:68
INTERFACE_TYPE AdapterInterfaceType
Definition: srb.h:565
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
_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 379 of file ioctl.c.

382{
384 PIO_STACK_LOCATION IoStack;
385
387
388 switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
389 {
391 return PdoDeviceControlQueryProperty(DeviceObject->DeviceExtension, Irp);
392
394 return PdoDeviceControlScsiGetAddress(DeviceObject->DeviceExtension, Irp);
395
396 default:
397 // DbgBreakPoint();
399 break;
400 }
401
402 Irp->IoStatus.Status = Status;
403 Irp->IoStatus.Information = 0;
405
406 return Status;
407}
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
static NTSTATUS PdoDeviceControlQueryProperty(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: ioctl.c:177
static NTSTATUS PdoDeviceControlScsiGetAddress(_In_ PPDO_DEVICE_EXTENSION DeviceExtension, _In_ PIRP Irp)
Definition: ioctl.c:329
#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 311 of file srb.c.

314{
315 PIRP Irp;
318 PHW_INITIALIZATION_DATA HwInitData;
320
321 Irp = RequestReference->Irp;
322 FdoExtension = PdoExtension->FdoExtension;
323 HwInitData = FdoExtension->Miniport.InitData;
324
325 NT_ASSERT(HwInitData);
326
327 /* Fill in SCSI address data */
328 /* FIXME: Not sure if this is the best place for it. */
329 RequestReference->Srb->PathId = PdoExtension->Bus;
330 RequestReference->Srb->TargetId = PdoExtension->Target;
331 RequestReference->Srb->Lun = PdoExtension->Lun;
332
333 /* FIXME: Delete after debug */
334 // PSCSI_REQUEST_BLOCK Srb = RequestReference->Srb;
335 // if (Srb->Function == SRB_FUNCTION_EXECUTE_SCSI &&
336 // (Srb->Cdb[0] == SCSIOP_GET_EVENT_STATUS || Srb->Cdb[0] == SCSIOP_TEST_UNIT_READY))
337 // {
338 // RequestReference->DumpSpecialRequest = TRUE;
339 // StorpDumpRequest(RequestReference);
340 // }
341
342 /* Start an DMA if IO subsystem allocated an MDL for us */
343 /* FIXME: Does this strategy work? */
344 if (RequestReference->Irp->MdlAddress)
345 {
346 /*
347 * Lock the buffer so that it stays in physical memory.
348 * In the two cases avoided here the memory has already been locked
349 */
350 if (!TEST_FLAG(Irp->MdlAddress->MdlFlags, MDL_SOURCE_IS_NONPAGED_POOL) &&
351 !TEST_FLAG(Irp->MdlAddress->MdlFlags, MDL_MAPPED_TO_SYSTEM_VA) &&
352 !TEST_FLAG(Irp->MdlAddress->MdlFlags, MDL_PAGES_LOCKED) &&
353 !TEST_FLAG(Irp->MdlAddress->MdlFlags, MDL_PARTIAL))
354 {
355 RequestReference->MappedSystemVa = (PVOID)1; /* FIXME: CHANGE ITS NAME */
357 }
358
359 RequestReference->WriteToDevice =
360 TEST_FLAG(RequestReference->Srb->SrbFlags, SRB_FLAGS_DATA_OUT);
361
362 /* A virtual miniport has no DMA adapter and moves the buffer itself through the MDL */
363 if (FdoExtension->Miniport.IsVirtual)
364 {
366 RequestReference->Irp,
367 NULL,
368 RequestReference);
369 return STATUS_PENDING;
370 }
371
372 /* Following call requires DISPATCH_LEVEL. */
374
375 /* Make up the scatter gather list */
376 /* FIXME: I don't know if we actually hit it */
377 NT_ASSERT((RequestReference->Srb->SrbFlags & SRB_FLAGS_UNSPECIFIED_DIRECTION) !=
379
380 FdoExtension->DmaAdapter->DmaOperations->
381 GetScatterGatherList(FdoExtension->DmaAdapter,
382 FdoExtension->Device,
383 RequestReference->Irp->MdlAddress,
384 MmGetMdlVirtualAddress(RequestReference->Irp->MdlAddress),
385 RequestReference->Srb->DataTransferLength,
387 (PVOID)RequestReference,
388 RequestReference->WriteToDevice);
389
390 /* Restore IRQL */
392 } else {
393 /* Otherwise just start the IO with a NULL scatter gather list */
395 RequestReference->Irp,
396 NULL,
397 RequestReference);
398 }
399
400 /* FIXME: Is this correct? */
402
403 return Status;
404}
#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:174
#define STATUS_PENDING
Definition: telnetd.h:14
void * PVOID
Definition: typedefs.h:50
@ 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 710 of file pdo.c.

713{
716 PPDO_DEVICE_EXTENSION DeviceExtension;
717
718 DPRINT1("PortPdoPnp(%p %p)\n", DeviceObject, Irp);
719
720 DeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
721 ASSERT(DeviceExtension->ExtensionType == PdoExtension);
722
724
725 switch (Stack->MinorFunction)
726 {
728 {
729 // RegistryInitLunKey(lunExt);
730 DeviceExtension->PnpState = dsStarted;
732 break;
733 }
736 {
737 DeviceExtension->PnpState = (Stack->MinorFunction == IRP_MN_REMOVE_DEVICE)
740 break;
741 }
745 {
747 break;
748 }
750 {
751 Status = PdoHandleDeviceRelations(DeviceExtension, Irp);
752 break;
753 }
755 {
756 Status = PdoHandleQueryDeviceText(DeviceExtension, Irp);
757 break;
758 }
759 case IRP_MN_QUERY_ID:
760 {
761 DPRINT("IRP_MN_QUERY_ID IdType %s\n",
762 DbgGetDeviceIDString(Stack->Parameters.QueryId.IdType));
763
764 if (Stack->Parameters.QueryId.IdType == BusQueryDeviceID)
765 {
766 Status = PdoHandleQueryDeviceId(DeviceExtension, Irp);
767 break;
768 }
769 else if (Stack->Parameters.QueryId.IdType == BusQueryHardwareIDs)
770 {
771 Status = PdoHandleQueryHardwareId(DeviceExtension, Irp);
772 break;
773 }
774 else if (Stack->Parameters.QueryId.IdType == BusQueryInstanceID)
775 {
776 Status = PdoHandleQueryInstanceId(DeviceExtension, Irp);
777 break;
778 }
779 else if (Stack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
780 {
781 Status = PdoHandleQueryCompatibleId(DeviceExtension, Irp);
782 break;
783 }
784
786 }
787 default:
788 {
789 // do nothing
790 Status = Irp->IoStatus.Status;
791 break;
792 }
793 }
794
795 if (Status != STATUS_PENDING)
796 {
797 Irp->IoStatus.Status = Status;
799 }
800
801 return Status;
802}
PCHAR DbgGetDeviceIDString(BUS_QUERY_ID_TYPE Type)
Definition: driverdbg.h:93
@ dsSurpriseRemoved
Definition: pci.h:39
@ 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:678
static NTSTATUS PdoHandleQueryInstanceId(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:524
static NTSTATUS PdoHandleQueryDeviceId(_In_ PPDO_DEVICE_EXTENSION DeviceExtension, _Inout_ PIRP Irp)
Definition: pdo.c:204
static NTSTATUS PdoHandleQueryHardwareId(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:278
static NTSTATUS PdoHandleQueryCompatibleId(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:455
static NTSTATUS PdoHandleQueryDeviceText(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:564
#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 429 of file srb.c.

433{
434 PPDO_IO_FLOW_CONTROL FlowControl = &PdoExtension->FlowControl;
436 PSCSI_REQUEST_BLOCK Srb = RequestReference->Srb;
437 BOOLEAN StrongOrderedRequest = FALSE;
438 BOOLEAN IssueRequest = TRUE;
439
440 /* Set outstanding flag */
441 RequestReference->IsOutstanding = TRUE;
442
443 /* Check if we can issue this request. */
444 /* Acquire the HBA global flow control lock first */
447
448 do
449 {
450 /* Check PDO flow control conditions */
451
452 /* Sanity check */
453 NT_ASSERT(FlowControl->OutstandingRequestCount <= PdoExtension->OutstandingRequestMax);
454
455 /* If PDO is not suitable to receive a request, make it wait */
456 if (FlowControl->IsBusy || FlowControl->IsPaused ||
459 FlowControl->StrongOrderedCount ||
460 FlowControl->OutstandingRequestCount == PdoExtension->OutstandingRequestMax ||
461 (!IsListEmpty(&FlowControl->AwaitingRequestsListHead)))
462 {
464 &RequestReference->PdoEntry);
465 IssueRequest = FALSE;
466 break;
467 }
468
469 /* Check if this request is strong-ordered */
472 {
473 RequestReference->StrongOrdered = TRUE;
474 StrongOrderedRequest = TRUE;
475 ++FlowControl->StrongOrderedCount;
476 }
477
478 /*
479 * If this request is strong ordered and the LUN's active/approved list is not
480 * drained, the request must wait.
481 */
482 if (StrongOrderedRequest && !IsListEmpty(&FlowControl->ActiveRequestsListHead))
483 {
485 &RequestReference->PdoEntry);
486 IssueRequest = FALSE;
487 break;
488 }
489
490 /*
491 * If any break's triggered before this point, the request is in PDO waiting queue.
492 * Going past this point meant PDO approves this request. Put it into active list.
493 */
495 {
497 &RequestReference->PdoEntry);
498 } else {
500 &RequestReference->PdoEntry);
501 }
502
503 /* A new outstanding request is added to this LUN */
504 ++FlowControl->OutstandingRequestCount;
505
506 /* Check FDO flow control status. */
507
508 /* If the FDO can't handle more requests, then the request should be queued. */
509 if (FlowControl->IsBusy || FlowControl->IsPaused ||
510 FlowControl->OutstandingRequestCount == FdoExtension->OutstandingRequestMax)
511 {
512 /* Put into FDO queue */
513 InsertHeadList(&FdoExtension->FlowControl.FdoBlockedRequestsListHead,
514 &RequestReference->FdoEntry);
515
516 /*
517 * Now the request is in PDO active list, in FDO awaiting queue, not issued.
518 * Let it wait until another completion event schedules it.
519 */
520 break;
521 }
522
523 /* Seems good, increment FDO request count */
524 ++FdoExtension->FlowControl.OutstandingRequestCount;
525
526 /*
527 * Now the request is counted in FDO & PDO, and is put into PDO active list,
528 * next step we're going to issue it.
529 */
530 } while (0);
531
532 // FIXME: The port driver indicates that an LU-specific queue has been frozen by
533 // returning a request with SRB_STATUS_QUEUE_FROZEN in the SrbStatus member. New
534 // requests from the class driver can be inserted into the queue, but only autosense
535 // requests are sent to the logical unit as long as its queue is frozen.
536 // https://learn.microsoft.com/en-us/windows-hardware/drivers/storage/storage-class-driver-s-releasequeue-routine
537
538 /* We've determined where the request goes. Release the flow control lock */
541
542 return IssueRequest;
543}
#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 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 548 of file srb.c.

551{
557 PMINIPORT Miniport;
558
559 DPRINT("PortPdoScsi(%p %p)\n", DeviceObject, Irp);
560
562 Srb = Stack->Parameters.Scsi.Srb;
563
564 if (Srb == NULL) {
565 DPRINT1("Srb is NULL!");
568
569 Irp->IoStatus.Information = 0;
570 Irp->IoStatus.Status = Status;
571
573 return Status;
574 }
575
578 FdoExtension = PdoExtension->FdoExtension;
580 Miniport = &FdoExtension->Miniport;
581
582 switch (Srb->Function) {
583 /* Both of these should be sent to device and let themselves process this */
586 {
587 PQUEUED_REQUEST_REFERENCE RequestReference;
588 BOOLEAN IssueRequest;
589
590 /* Mark IRP as pending */
592
593 /* Allocate private contexts */
595 if (Status != STATUS_SUCCESS)
596 {
597 break;
598 }
599 RequestReference = (PQUEUED_REQUEST_REFERENCE)Srb->OriginalRequest;
600
601 /* Assign a tag to the SRB if it supports tagging */
603
604 DPRINT("New request (%d:%d:%d) ReqRef %p Srb %p Irp %p Tag %x SrbExt %p(%d)\n",
606 RequestReference, Srb, Irp, Srb->QueueTag,
608
609 /*
610 * Do the scheduling. If returns TRUE, we should issue this request to the hardware.
611 * Otherwise it will keep waiting until next completion schedules it, or be cancelled on
612 * an error, etc.
613 */
616 RequestReference);
617
618 /* This request is viable to be issued. */
619 if (IssueRequest)
620 {
621 Status = PortPdoIssueRequest(PdoExtension, RequestReference);
622 } else {
624 }
625
626 break;
627 }
628
629 /*
630 * These requests are actually sent to adapters and are not outstanding requests for devices
631 * so we simply pass them down to miniport
632 */
635 {
636 PQUEUED_REQUEST_REFERENCE RequestReference;
637
638 /* Mark IRP as pending */
640
641 /* Allocate private contexts */
643 if (Status != STATUS_SUCCESS)
644 {
645 break;
646 }
647 RequestReference = (PQUEUED_REQUEST_REFERENCE)Srb->OriginalRequest;
648
649 /*
650 * Call the non-flow-controlled scheduling function (it does nothing but the model is
651 * preserved for consistency)
652 */
654
655 /* Fire up the request immediately */
656 Status = PortPdoIssueRequest(PdoExtension, RequestReference);
657
658 break;
659 }
660
662 {
663 if (InterlockedCompareExchange(&PdoExtension->IsClaimed, 1, 0))
664 {
667 break;
668 }
669
670 /* The claimed device object is handed back to the class driver here */
671 Srb->DataBuffer = PdoExtension->Device;
674 break;
675 }
676
678 {
679 InterlockedExchange(&PdoExtension->IsClaimed, 0);
680
683 break;
684 }
685
686 default:
687 DPRINT1("Unsupported Srb Function %02X!", Srb->Function);
688 // DbgBreakPoint();
691 break;
692 }
693
694 return Status;
695}
#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:142
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:429
VOID PortPdoScheduleRequestNoFlowControl(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PQUEUED_REQUEST_REFERENCE RequestReference)
Definition: srb.c:408
NTSTATUS PortPdoSrbAllocatePrivateContexts(_In_ PSCSI_REQUEST_BLOCK Srb, _In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: srb.c:258
NTSTATUS PortPdoIssueRequest(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PQUEUED_REQUEST_REFERENCE RequestReference)
Definition: srb.c:311
PORT_CONFIGURATION_INFORMATION PortConfig
Definition: precomp.h:99
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:548

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
_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:3020
#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}

Referenced by PortAddDevice().

◆ StorpBuildExtendedSrb()

VOID NTAPI StorpBuildExtendedSrb ( _In_ PSCSI_REQUEST_BLOCK  Srb,
_Out_ PEXTENDED_REQUEST  Request 
)

Fills in the extended request a miniport will be given.

Parameters
SrbThe request as the class layer built it.
RequestStorage for the translated request, already zeroed.

Definition at line 102 of file srbex.c.

105{
106 PSTORAGE_REQUEST_BLOCK Extended = &Request->Srb;
107
108 Extended->Length = sizeof(*Extended);
109 Extended->Function = SRB_FUNCTION_STORAGE_REQUEST_BLOCK;
110 Extended->SrbStatus = SRB_STATUS_PENDING;
111 Extended->Signature = SRB_SIGNATURE;
112 Extended->Version = STORAGE_REQUEST_BLOCK_VERSION_1;
113 Extended->SrbLength = sizeof(*Request);
114 Extended->SrbFunction = Srb->Function;
115 Extended->SrbFlags = Srb->SrbFlags;
116 Extended->RequestTag = Srb->QueueTag;
117 Extended->RequestAttribute = Srb->QueueAction;
118 Extended->TimeOutValue = Srb->TimeOutValue;
119 Extended->DataTransferLength = Srb->DataTransferLength;
120 Extended->DataBuffer = Srb->DataBuffer;
121
122 /* The miniport hands this straight back to us on completion */
123 Extended->OriginalRequest = Srb->OriginalRequest;
124 Extended->MiniportContext = Srb->SrbExtension;
125
126 Extended->AddressOffset = FIELD_OFFSET(EXTENDED_REQUEST, Address);
127
128 Request->Address.Type = STOR_ADDRESS_TYPE_BTL8;
129 Request->Address.AddressLength = STOR_ADDR_BTL8_ADDRESS_LENGTH;
130 Request->Address.Path = Srb->PathId;
131 Request->Address.Target = Srb->TargetId;
132 Request->Address.Lun = Srb->Lun;
133
134 /* Only SRB_FUNCTION_EXECUTE_SCSI carries a CDB */
136 return;
137
138 Extended->NumSrbExData = 1;
139 Extended->SrbExDataOffset[0] = FIELD_OFFSET(EXTENDED_REQUEST, Cdb);
140
143 Request->Cdb.ScsiStatus = Srb->ScsiStatus;
144 Request->Cdb.SenseInfoBufferLength = Srb->SenseInfoBufferLength;
145 Request->Cdb.CdbLength = Srb->CdbLength;
146 Request->Cdb.SenseInfoBuffer = Srb->SenseInfoBuffer;
147
148 RtlCopyMemory(Request->Cdb.Cdb, Srb->Cdb, sizeof(Request->Cdb.Cdb));
149}
#define SRB_STATUS_PENDING
Definition: srb.h:340
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
Definition: scratch.h:159
#define STOR_ADDRESS_TYPE_BTL8
Definition: scsi.h:3571
#define STOR_ADDR_BTL8_ADDRESS_LENGTH
Definition: scsi.h:3574
#define SRB_SIGNATURE
Definition: srb.h:616
#define STORAGE_REQUEST_BLOCK_VERSION_1
Definition: srb.h:617
#define SRB_FUNCTION_STORAGE_REQUEST_BLOCK
Definition: srb.h:108
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:661
@ SrbExDataTypeScsiCdb16
Definition: srb.h:459
#define SRBEX_DATA_SCSI_CDB16_LENGTH
Definition: srb.h:489
ULONG TimeOutValue
Definition: srb.h:262
UCHAR SenseInfoBufferLength
Definition: srb.h:259
UCHAR CdbLength
Definition: srb.h:258
UCHAR Cdb[16]
Definition: srb.h:279
PVOID SenseInfoBuffer
Definition: srb.h:264
UCHAR ScsiStatus
Definition: srb.h:252
ULONG DataTransferLength
Definition: srb.h:261
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request

Referenced by PortPdoAfterBuildingScatterGatherList().

◆ StorpBuildUnitAddress()

VOID NTAPI StorpBuildUnitAddress ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_Out_ PSTOR_ADDR_BTL8  Address 
)

Fills in the bus, target and LUN address of a logical unit.

Definition at line 28 of file srbex.c.

31{
32 RtlZeroMemory(Address, sizeof(*Address));
33
36 Address->Path = (UCHAR)PdoExtension->Bus;
37 Address->Target = (UCHAR)PdoExtension->Target;
38 Address->Lun = (UCHAR)PdoExtension->Lun;
39}
unsigned char UCHAR
Definition: typedefs.h:53

Referenced by PortCreatePdo(), and PortDeletePdo().

◆ StorpCompleteExtendedSrb()

VOID NTAPI StorpCompleteExtendedSrb ( _In_ PSCSI_REQUEST_BLOCK  Srb,
_In_ PEXTENDED_REQUEST  Request 
)

Carries the miniport's answer back to the original request block.

Definition at line 157 of file srbex.c.

160{
161 PSTORAGE_REQUEST_BLOCK Extended = &Request->Srb;
162
163 Srb->SrbStatus = Extended->SrbStatus;
164 Srb->DataTransferLength = Extended->DataTransferLength;
165
166 if (Extended->NumSrbExData == 0)
167 return;
168
169 Srb->ScsiStatus = Request->Cdb.ScsiStatus;
170 Srb->SenseInfoBufferLength = Request->Cdb.SenseInfoBufferLength;
171}
UCHAR SrbStatus
Definition: srb.h:251

Referenced by StorPortNotification().

◆ StorpIsExtendedSrb()

BOOLEAN NTAPI StorpIsExtendedSrb ( _In_ PVOID  Srb)

Tells whether a request block is in the extended format.

Definition at line 47 of file srbex.c.

49{
51
52 return (Header->Function == SRB_FUNCTION_STORAGE_REQUEST_BLOCK);
53}
Definition: Header.h:9
struct SRB_ALIGN _STORAGE_REQUEST_BLOCK_HEADER * PSTORAGE_REQUEST_BLOCK_HEADER

Referenced by StorPortNotification(), StorpRequestReference(), and StorpSrbDataBuffer().

◆ StorpRequestReference()

PQUEUED_REQUEST_REFERENCE NTAPI StorpRequestReference ( _In_ PSCSI_REQUEST_BLOCK  Srb)

Finds the request reference behind an SRB in either format.

Definition at line 61 of file srbex.c.

63{
65 {
67
69 }
70
72}
BOOLEAN NTAPI StorpIsExtendedSrb(_In_ PVOID Srb)
Tells whether a request block is in the extended format.
Definition: srbex.c:47

Referenced by StorPortExtendedFunction(), StorPortGetScatterGatherList(), and StorPortNotification().

◆ StorpSrbDataBuffer()

PVOID NTAPI StorpSrbDataBuffer ( _In_ PSCSI_REQUEST_BLOCK  Srb)

Finds the data buffer of a request in either format.

Definition at line 80 of file srbex.c.

82{
84 {
86
87 return Extended->DataBuffer;
88 }
89
90 return Srb->DataBuffer;
91}

Referenced by StorPortExtendedFunction().

◆ 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 112 of file srb.c.

114{
115 PQUEUED_REQUEST_REFERENCE RequestReference;
117
118 RequestReference = (PQUEUED_REQUEST_REFERENCE)Srb->OriginalRequest;
119 Srb->OriginalRequest = RequestReference->Irp;
120 FdoExtension = RequestReference->PdoExtension->FdoExtension;
121
122 if (RequestReference->FromReserve)
123 {
124 InterlockedExchange(&FdoExtension->ReserveInUse, 0);
125 }
126 else
127 {
128 ExFreeToNPagedLookasideList(&FdoExtension->RequestReferenceLookaside, RequestReference);
129 }
130}
if(dx< 0)
Definition: linetemp.h:194
PPDO_DEVICE_EXTENSION PdoExtension
Definition: precomp.h:375

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:117
PVOID Context
Definition: precomp.h:124
LONG TimerAlreadySet
Definition: precomp.h:121
PHW_TIMER_EX TimerCallback
Definition: precomp.h:123
PVOID HwDeviceExtension
Definition: precomp.h:122

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:256
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2593

Referenced by StorPortGetDeviceBase().