为什么我的AdapterControl虚拟小端口驱动程序( StorPort,KMDF)在第一次调用它的StorPort函数之后停止工作?
当前,在实现驱动程序(WinDbg)之后发生了以下情况:
SRB_TYPE_STORAGE_REQUEST_BLOCK
).SRB_FUNCTION_STORAGE_REQUEST_BLOCK
(这对我来说没问题,因为在HwFindAdapter例程中,我定义了PPORT_CONFIGURATION_INFORMATION
-> SrbType以等于SRB_FUNCTION_STORAGE_REQUEST_BLOCK
。没有错误。参数SCSI_ADAPTER_CONTROL_TYPE
是用ControlType ScsiQuerySupportedControlTypes
调用的(根据第一次调用的MS文档,默认行为是这样的)。AdapterControl
例程,并“要求”我定义一个设备。--
请注意,以下不是实际的完整代码,而是结构概述:
DriverEntry (
_In_ PVOID DriverObject,
_In_ PVOID RegistryPath
)
{
HW_INITIALIZATION_DATA initdata = { 0 }
initdata.HwFindAdapter = HwFindAdapter;
initdata.HwInitialize = HwInitialize;
initdata.HwAdapterControl = AdapterControl;
initdata.HwResetBus = HwResetBus;
initdata.HwStartIo = HwStartIo;
initdata.HwFreeAdapterResources = HwFreeAdapterResources;
initdata.AdapterInterfaceType = Internal;
initdata.MultipleRequestPerLu = TRUE;
initdata.PortVersionFlags = 0;
status = StorPortInitialize(
DriverObject,
RegistryPath,
&initdata,
NULL
);
return status;
}
|
HwFindAdapter (AdapterExtension, HwContext, BusInformation, ArgumentString, ConfigInfo, Reserved3)
{
//ConfigInfo is referenced to PPORT_CONFIGURATION_INFORMATION in the parameters above.
ConfigInfo->AlignmentMask = FILE_BYTE_ALIGNMENT;
ConfigInfo->NumberOfBuses = 1
ConfigInfo->CachesData = FALSE;
ConfigInfo->MapBuffers = STOR_MAP_ALL_BUFFERS_INCLUDING_READ_WRITE;
ConfigInfo->MaximumNumberOfTargets = 255;
ConfigInfo->SrbType = SRB_TYPE_STORAGE_REQUEST_BLOCK;
ConfigInfo->AddressType = STORAGE_ADDRESS_TYPE_BTL8;
ConfigInfo->SynchronizationModel = StorSynchronizeFullDuplex;
ConfigInfo->HwMSInterruptRoutine = NULL;
ConfigInfo->InterruptSynchronizationMode = InterruptSupportNone;
ConfigInfo->VirtualDevice = TRUE;
ConfigInfo->DumpMode = DUMP_MODE_RESUME;
ConfigInfo->MaxNumberOfIO = 100;
ConfigInfo->BusResetHoldTime = 0;
ConfigInfo->FeatureSupport = 0x7f;
return SP_RETURN_FOUND;
}
HwInitialize在那里,但除了返回STATUS_SUCCESS之外什么也不做。
|
HwStartIo (
_In_ PVOID DeviceExtension,
_In_ PSCSI_REQUEST_BLOCK Srb
)
{
//Currently does nothing with data, as is not needed for now.
StorPortNotification(RequestComplete, DeviceExtension, Srb);
return TRUE;
}
|
AdapterControl (
_In_ PVOID DeviceExtension,
_In_ SCSI_ADAPTER_CONTROL_TYPE ControlType,
_In_ PVOID Parameters
)
{
PSCSI_SUPPORTED_CONTROL_TYPE_LIST controlTypeList;
switch (ControlType)
{
case ScsiQuerySupportedControlTypes:
controlTypeList = (PSCSI_SUPPORTED_CONTROL_TYPE_LIST)Parameters; // get pointer to control type list
controlTypeList->SupportedTypeList[ScsiQuerySupportedControlTypes] = TRUE;
controlTypeList->SupportedTypeList[ScsiStopAdapter] = TRUE;
controlTypeList->SupportedTypeList[ScsiRestartAdapter] = TRUE;
controlTypeList->SupportedTypeList[ScsiSetBootConfig] = TRUE;
//referenced cases are defined but not relevant for now.
}
return ScsiAdapterControlSuccess;
}
HwFreeAdapterResources在那里,但什么也不做,也什么也不返回,因为它是一个空的。
发布于 2022-01-17 19:01:21
好吧,所以我发现了出了什么问题。
调用了HwStartIo,但是使用了值PSCSI_REQUEST_BLOCK->Function == "SRB_FUNCTION_PNP"
。
这表示在预先调用的任何函数上都存在错误,在我的示例中,返回代码集错误(函数HwInitialize:我返回了"STATUS_SUCCESS" (0xL) instead of "TRUE" (0x0)
)。
在正常工作中,在第一次初始化时,PSCSI_REQUEST_BLOCK->Function
应该等于"SRB_FUNCTION_EXECUTE_SCSI"
来收集SCSI总线、目标和LUN信息。
https://stackoverflow.com/questions/70725556
复制相似问题