34 DPRINT(
"FdoSendInquiry() called\n");
41 if (InquiryBuffer ==
NULL)
45 if (SenseBuffer ==
NULL)
70 DPRINT(
"IoBuildDeviceIoControlRequest() failed\n");
113 DPRINT(
"FdoSendInquiry(): Waiting for the driver to process request...\n");
122 DPRINT(
"FdoSendInquiry(): Request processed by driver, status = 0x%08X\n",
Status);
148 LunExtension->
Flags &= ~LUNEX_FROZEN_QUEUE;
185 if ((RetryCount < 2) &&
215 DPRINT(
"FdoSendInquiry() done with Status 0x%08X\n",
Status);
226 UINT32 totalLUNs = PortExtension->TotalLUCount;
228 DPRINT(
"FdoScanAdapter() called\n");
231 for (
UINT8 pathId = 0; pathId < PortExtension->NumberOfBuses; pathId++)
233 DPRINT(
" Scanning bus/pathID %u\n", pathId);
239 for (
UINT8 targetId = 0;
240 targetId < PortExtension->PortConfig->MaximumNumberOfTargets;
252 for (
UINT8 lun = 0; lun < PortExtension->MaxLunCount; lun++)
257 if (lun >= PortExtension->PortConfig->MaximumNumberOfLogicalUnits)
304 DPRINT(
"Add PDO to list: PDO: %p, FDOExt: %p, PDOExt: %p\n", lunPDO, PortExtension, lunExt);
325 lunExt->
Flags &= ~SCSI_PORT_SCAN_IN_PROGRESS;
327 DPRINT1(
"Found device of type %d at controller %d bus %d tid %d lun %d, PDO: %p\n",
328 InquiryData->
DeviceType, PortExtension->PortNumber, pathId, targetId, lun, lunPDO);
353 PortExtension->TotalLUCount = totalLUNs;
374 if (DeviceExtension->HwInterrupt ==
NULL ||
378 DeviceExtension->InterruptCount = 0;
380 DPRINT1(
"Interrupt Count: 0\n");
391 ULONG InterruptVector[2],
i, MappedIrq[2];
392 KIRQL Dirql[2], MaxDirql;
404 DeviceExtension->InterruptCount =
408 for (
i = 0;
i < DeviceExtension->InterruptCount;
i++)
413 DeviceExtension->InterruptLevel[
i], InterruptVector[
i], &Dirql[
i],
417 if (DeviceExtension->InterruptCount == 1 || Dirql[0] > Dirql[1])
426 for (
i = 0;
i < DeviceExtension->InterruptCount;
i++)
432 InterruptShareable =
TRUE;
436 InterruptShareable =
FALSE;
442 &DeviceExtension->IrqLock,
443 MappedIrq[
i], Dirql[
i],
452 DPRINT1(
"Could not connect interrupt %d\n", InterruptVector[
i]);
453 DeviceExtension->Interrupt[
i] =
NULL;
462 DeviceExtension->IoAddress = ((*(PortConfig->
AccessRanges))[0]).RangeStart.LowPart;
464 DPRINT(
"Io Address %x\n", DeviceExtension->IoAddress);
471 DeviceExtension->ActiveRequestCounter = -1;
474 if (DeviceExtension->AdapterObject !=
NULL && PortConfig->
Master &&
477 DeviceExtension->MapRegisters =
TRUE;
481 DeviceExtension->MapRegisters =
FALSE;
488 DeviceExtension->Interrupt[0], DeviceExtension->HwInitialize,
489 DeviceExtension->MiniPortDeviceExtension))
491 DPRINT1(
"HwInitialize() failed!\n");
516 if (DeviceExtension->InterfaceName.Buffer)
525 WCHAR dosNameBuffer[12];
528 swprintf(dosNameBuffer,
L"\\??\\Scsi%lu:", DeviceExtension->PortNumber);
534 if (DeviceExtension->DeviceStarted)
541 while (DeviceExtension->InterruptCount)
543 if (DeviceExtension->Interrupt[--DeviceExtension->InterruptCount])
548 if (DeviceExtension->Buses)
550 for (
UINT8 pathId = 0; pathId < DeviceExtension->NumberOfBuses; pathId++)
565 if (DeviceExtension->PortConfig)
571 if (DeviceExtension->SrbExtensionBuffer !=
NULL && DeviceExtension->CommonBufferLength != 0)
573 if (!DeviceExtension->AdapterObject)
580 DeviceExtension->CommonBufferLength,
581 DeviceExtension->PhysicalAddress,
582 DeviceExtension->SrbExtensionBuffer,
588 if (DeviceExtension->SrbInfo !=
NULL)
592 while (DeviceExtension->MappedAddressList !=
NULL)
595 DeviceExtension->MappedAddressList->NumberOfBytes);
597 PVOID ptr = DeviceExtension->MappedAddressList;
598 DeviceExtension->MappedAddressList = DeviceExtension->MappedAddressList->NextMappedAddress;
612 WCHAR dosNameBuffer[12];
620 swprintf(dosNameBuffer,
L"\\??\\Scsi%u:", PortExtension->PortNumber);
637 &StoragePortClassGuid,
639 &PortExtension->InterfaceName);
640 DPRINT(
"IoRegisterDeviceInterface status: %x, InterfaceName: %wZ\n",
641 status, &PortExtension->InterfaceName);
648 PortExtension->DeviceStarted =
TRUE;
665 DPRINT(
"Found %u PD objects, FDOExt: %p\n", PortExtension->TotalLUCount, PortExtension);
676 if (!deviceRelations)
678 Irp->IoStatus.Information = 0;
684 deviceRelations->
Count = 0;
686 for (
UINT8 pathId = 0; pathId < PortExtension->NumberOfBuses; pathId++)
692 lunEntry = lunEntry->
Flink)
702 ASSERT(deviceRelations->
Count == PortExtension->TotalLUCount);
717 static WCHAR GenScsiAdapterId[] =
L"GEN_SCSIADAPTER";
718 PWCHAR Ids = *PwIds, NewIds;
766 ASSERT(portExt->Common.IsFDO);
788 Irp->IoStatus.Information = 0;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PSCSI_REQUEST_BLOCK Srb
#define IOCTL_SCSI_EXECUTE_IN
#define SENSE_BUFFER_SIZE
#define SCSI_SENSE_ILLEGAL_REQUEST
#define DEVICE_QUALIFIER_NOT_SUPPORTED
#define INQUIRYDATABUFFERSIZE
#define NT_SUCCESS(StatCode)
FORCEINLINE PCHAR GetIRPMinorFunctionString(UCHAR MinorFunction)
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_FUNCTION_EXECUTE_SCSI
#define SRB_STATUS_DATA_OVERRUN
#define SRB_STATUS_BAD_SRB_BLOCK_LENGTH
#define SRB_STATUS_AUTOSENSE_VALID
#define SRB_FLAGS_DATA_IN
#define SRB_STATUS_SELECTION_TIMEOUT
#define SRB_STATUS_BAD_FUNCTION
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
#define SRB_STATUS(Status)
#define SRB_STATUS_QUEUE_FROZEN
#define SRB_STATUS_NO_DEVICE
#define SRB_STATUS_SUCCESS
NTSTATUS RegistryInitAdapterKey(_Inout_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeRaiseIrql(irql, oldIrql)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeLowerIrql(oldIrql)
#define KeAcquireSpinLock(sl, irql)
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
VOID NTAPI HalFreeCommonBuffer(IN PADAPTER_OBJECT AdapterObject, IN ULONG Length, IN PHYSICAL_ADDRESS LogicalAddress, IN PVOID VirtualAddress, IN BOOLEAN CacheEnabled)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
void __cdecl __debugbreak(void)
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Returns a pointer to the I/O manager's global configuration information structure.
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
VOID NTAPI IoStartTimer(IN PDEVICE_OBJECT DeviceObject)
VOID NTAPI IoStopTimer(PDEVICE_OBJECT DeviceObject)
#define ExFreePoolWithTag(_P, _T)
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
static OUT PIO_STATUS_BLOCK IoStatusBlock
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_NullNull_terminated_ WCHAR * PZZWSTR
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define IoSkipCurrentIrpStackLocation(Irp)
#define IoCopyCurrentIrpStackLocationToNext(Irp)
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
#define IoCompleteRequest
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
NTSTATUS NTAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTSTATUS NTAPI IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
BOOLEAN NTAPI KeSynchronizeExecution(IN OUT PKINTERRUPT Interrupt, IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, IN PVOID SynchronizeContext OPTIONAL)
#define STATUS_ADAPTER_HARDWARE_ERROR
_In_opt_ WDFREQUEST _In_ ULONG _In_ BOOLEAN _In_ PCDB Cdb
#define SCSI_PORT_DISCONNECT_ALLOWED
#define SCSI_PORT_SCAN_IN_PROGRESS
#define SCSI_PORT_NOTIFICATION_NEEDED
KSERVICE_ROUTINE ScsiPortIsr
IO_DPC_ROUTINE ScsiPortDpcForIsr
enum _KINTERRUPT_MODE KINTERRUPT_MODE
static NTSTATUS FdoSendInquiry(_In_ PDEVICE_OBJECT DeviceObject)
static NTSTATUS FdoHandleDeviceRelations(_In_ PSCSI_PORT_DEVICE_EXTENSION PortExtension, _Inout_ PIRP Irp)
NTSTATUS FdoStartAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION PortExtension)
VOID FdoScanAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION PortExtension)
NTSTATUS FdoDispatchPnp(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
NTSTATUS FdoCallHWInitialize(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Calls HwInitialize routine of the miniport and sets up interrupts Should be called inside ScsiPortIni...
NTSTATUS FdoRemoveAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
static NTSTATUS FdoHandleQueryCompatibleId(_Inout_ PZZWSTR *PwIds)
PDEVICE_OBJECT PdoCreateLunDevice(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
PSCSI_PORT_LUN_EXTENSION GetLunByPath(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
VOID SpiGetNextRequestFromLun(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension, _Inout_opt_ PKIRQL OldIrql)
PDEVICE_OBJECT Objects[1]
UCHAR DeviceTypeQualifier
struct _IO_STACK_LOCATION::@3979::@4010 QueryId
struct _IO_STACK_LOCATION::@3979::@4001 Scsi
union _IO_STACK_LOCATION::@1580 Parameters
struct _IO_STACK_LOCATION::@3979::@4004 QueryDeviceRelations
struct _LIST_ENTRY * Flink
PDEVICE_OBJECT LowerDevice
PDEVICE_OBJECT DeviceObject
SCSI_PORT_COMMON_EXTENSION Common
UCHAR SenseInfoBufferLength
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_IO_DEVICE_ERROR
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_INSUFFICIENT_RESOURCES
struct _CDB::_CDB6INQUIRY CDB6INQUIRY
_In_ PDEVICE_OBJECT DeviceObject
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG _In_ KIRQL _In_ KIRQL _In_ KINTERRUPT_MODE InterruptMode
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
#define ObReferenceObject