mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 23:13:04 +00:00
- Change unclear flag name to a better one.
- Set needed flags in a few places (which I forgot to set) - this fixes the hang introduced by the previous commit. - Further code prettification. svn path=/trunk/; revision=26198
This commit is contained in:
parent
e2ab9cb060
commit
3d4fc31db6
2 changed files with 62 additions and 46 deletions
|
@ -638,54 +638,60 @@ ScsiPortInitialize(IN PVOID Argument1,
|
||||||
IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
|
IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
|
||||||
IN PVOID HwContext)
|
IN PVOID HwContext)
|
||||||
{
|
{
|
||||||
PDRIVER_OBJECT DriverObject = (PDRIVER_OBJECT)Argument1;
|
PDRIVER_OBJECT DriverObject = (PDRIVER_OBJECT)Argument1;
|
||||||
// PUNICODE_STRING RegistryPath = (PUNICODE_STRING)Argument2;
|
// PUNICODE_STRING RegistryPath = (PUNICODE_STRING)Argument2;
|
||||||
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
|
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
|
||||||
PCONFIGURATION_INFORMATION SystemConfig;
|
PCONFIGURATION_INFORMATION SystemConfig;
|
||||||
PPORT_CONFIGURATION_INFORMATION PortConfig;
|
PPORT_CONFIGURATION_INFORMATION PortConfig;
|
||||||
ULONG DeviceExtensionSize;
|
ULONG DeviceExtensionSize;
|
||||||
ULONG PortConfigSize;
|
ULONG PortConfigSize;
|
||||||
BOOLEAN Again;
|
BOOLEAN Again;
|
||||||
BOOLEAN DeviceFound = FALSE;
|
BOOLEAN DeviceFound = FALSE;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG Result;
|
ULONG Result;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG MaxBus;
|
ULONG MaxBus;
|
||||||
ULONG BusNumber;
|
ULONG BusNumber;
|
||||||
PCI_SLOT_NUMBER SlotNumber;
|
PCI_SLOT_NUMBER SlotNumber;
|
||||||
|
|
||||||
PDEVICE_OBJECT PortDeviceObject;
|
PDEVICE_OBJECT PortDeviceObject;
|
||||||
WCHAR NameBuffer[80];
|
WCHAR NameBuffer[80];
|
||||||
UNICODE_STRING DeviceName;
|
UNICODE_STRING DeviceName;
|
||||||
WCHAR DosNameBuffer[80];
|
WCHAR DosNameBuffer[80];
|
||||||
UNICODE_STRING DosDeviceName;
|
UNICODE_STRING DosDeviceName;
|
||||||
PIO_SCSI_CAPABILITIES PortCapabilities;
|
PIO_SCSI_CAPABILITIES PortCapabilities;
|
||||||
ULONG MappedIrq;
|
ULONG MappedIrq;
|
||||||
KIRQL Dirql;
|
KIRQL Dirql;
|
||||||
KAFFINITY Affinity;
|
KAFFINITY Affinity;
|
||||||
|
|
||||||
|
|
||||||
DPRINT ("ScsiPortInitialize() called!\n");
|
DPRINT ("ScsiPortInitialize() called!\n");
|
||||||
|
|
||||||
if ((HwInitializationData->HwInitialize == NULL) ||
|
/* Check params for validity */
|
||||||
(HwInitializationData->HwStartIo == NULL) ||
|
if ((HwInitializationData->HwInitialize == NULL) ||
|
||||||
(HwInitializationData->HwInterrupt == NULL) ||
|
(HwInitializationData->HwStartIo == NULL) ||
|
||||||
(HwInitializationData->HwFindAdapter == NULL) ||
|
(HwInitializationData->HwInterrupt == NULL) ||
|
||||||
(HwInitializationData->HwResetBus == NULL))
|
(HwInitializationData->HwFindAdapter == NULL) ||
|
||||||
return(STATUS_INVALID_PARAMETER);
|
(HwInitializationData->HwResetBus == NULL))
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
DriverObject->DriverStartIo = ScsiPortStartIo;
|
/* Set handlers */
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = ScsiPortCreateClose;
|
DriverObject->DriverStartIo = ScsiPortStartIo;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScsiPortCreateClose;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = ScsiPortCreateClose;
|
||||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScsiPortDeviceControl;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScsiPortCreateClose;
|
||||||
DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiPortDispatchScsi;
|
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScsiPortDeviceControl;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiPortDispatchScsi;
|
||||||
|
|
||||||
SystemConfig = IoGetConfigurationInformation();
|
/* Obtain configuration information */
|
||||||
|
SystemConfig = IoGetConfigurationInformation();
|
||||||
|
|
||||||
DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) +
|
/* Calculate sizes of DeviceExtension and PortConfig */
|
||||||
HwInitializationData->DeviceExtensionSize;
|
DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) +
|
||||||
PortConfigSize = sizeof(PORT_CONFIGURATION_INFORMATION) +
|
HwInitializationData->DeviceExtensionSize;
|
||||||
HwInitializationData->NumberOfAccessRanges * sizeof(ACCESS_RANGE);
|
PortConfigSize = sizeof(PORT_CONFIGURATION_INFORMATION) +
|
||||||
|
HwInitializationData->NumberOfAccessRanges * sizeof(ACCESS_RANGE);
|
||||||
|
|
||||||
|
|
||||||
MaxBus = (HwInitializationData->AdapterInterfaceType == PCIBus) ? 8 : 1;
|
MaxBus = (HwInitializationData->AdapterInterfaceType == PCIBus) ? 8 : 1;
|
||||||
|
@ -762,7 +768,7 @@ ScsiPortInitialize(IN PVOID Argument1,
|
||||||
|
|
||||||
/* Initialize the device timer */
|
/* Initialize the device timer */
|
||||||
DeviceExtension->TimerState = IDETimerIdle;
|
DeviceExtension->TimerState = IDETimerIdle;
|
||||||
DeviceExtension->TimerCount = 0;
|
DeviceExtension->TimerCount = -1;
|
||||||
IoInitializeTimer (PortDeviceObject,
|
IoInitializeTimer (PortDeviceObject,
|
||||||
ScsiPortIoTimer,
|
ScsiPortIoTimer,
|
||||||
DeviceExtension);
|
DeviceExtension);
|
||||||
|
@ -885,6 +891,9 @@ ScsiPortInitialize(IN PVOID Argument1,
|
||||||
goto ByeBye;
|
goto ByeBye;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set flag that it's allowed to disconnect during this command */
|
||||||
|
DeviceExtension->Flags |= SCSI_PORT_DISCONNECT_ALLOWED;
|
||||||
|
|
||||||
/* Initialize counter of active requests (-1 means there are none) */
|
/* Initialize counter of active requests (-1 means there are none) */
|
||||||
DeviceExtension->ActiveRequestCounter = -1;
|
DeviceExtension->ActiveRequestCounter = -1;
|
||||||
|
|
||||||
|
@ -1187,6 +1196,9 @@ ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType,
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
/* Request a DPC after we're done with the interrupt */
|
||||||
|
DeviceExtension->InterruptData.Flags |= SCSI_PORT_NOTIFICATION_NEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1836,7 +1848,7 @@ ScsiPortStartPacket(IN OUT PVOID Context)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the time out value */
|
/* Set the time out value */
|
||||||
DeviceExtension->TimeOutCount = Srb->TimeOutValue;
|
DeviceExtension->TimerCount = Srb->TimeOutValue;
|
||||||
|
|
||||||
/* We are busy */
|
/* We are busy */
|
||||||
DeviceExtension->Flags |= SCSI_PORT_DEVICE_BUSY;
|
DeviceExtension->Flags |= SCSI_PORT_DEVICE_BUSY;
|
||||||
|
@ -1863,7 +1875,7 @@ ScsiPortStartPacket(IN OUT PVOID Context)
|
||||||
if (Srb->SrbFlags & SRB_FLAGS_DISABLE_DISCONNECT)
|
if (Srb->SrbFlags & SRB_FLAGS_DISABLE_DISCONNECT)
|
||||||
{
|
{
|
||||||
/* It's a disconnect, so no more requests can go */
|
/* It's a disconnect, so no more requests can go */
|
||||||
DeviceExtension->Flags &= ~SCSI_PORT_DISCONNECT_IN_PROGRESS;
|
DeviceExtension->Flags &= ~SCSI_PORT_DISCONNECT_ALLOWED;
|
||||||
}
|
}
|
||||||
|
|
||||||
LunExtension->Flags |= SCSI_PORT_LU_ACTIVE;
|
LunExtension->Flags |= SCSI_PORT_LU_ACTIVE;
|
||||||
|
@ -2051,6 +2063,7 @@ SpiSendInquiry (IN PDEVICE_OBJECT DeviceObject,
|
||||||
/* Wait for it to complete */
|
/* Wait for it to complete */
|
||||||
if (Status == STATUS_PENDING)
|
if (Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
|
DPRINT("SpiSendInquiry(): Waiting for the driver to process request...\n");
|
||||||
KeWaitForSingleObject(&Event,
|
KeWaitForSingleObject(&Event,
|
||||||
Executive,
|
Executive,
|
||||||
KernelMode,
|
KernelMode,
|
||||||
|
@ -2059,6 +2072,8 @@ SpiSendInquiry (IN PDEVICE_OBJECT DeviceObject,
|
||||||
Status = IoStatusBlock.Status;
|
Status = IoStatusBlock.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DPRINT("SpiSendInquiry(): Request processed by driver, status = 0x%08X\n", Status);
|
||||||
|
|
||||||
if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_SUCCESS)
|
if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
/* All fine, copy data over */
|
/* All fine, copy data over */
|
||||||
|
@ -2134,6 +2149,8 @@ SpiSendInquiry (IN PDEVICE_OBJECT DeviceObject,
|
||||||
ExFreePool(InquiryBuffer);
|
ExFreePool(InquiryBuffer);
|
||||||
ExFreePool(SenseBuffer);
|
ExFreePool(SenseBuffer);
|
||||||
|
|
||||||
|
DPRINT("SpiSendInquiry() done\n");
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define SCSI_PORT_NEXT_REQUEST_READY 0x0008
|
#define SCSI_PORT_NEXT_REQUEST_READY 0x0008
|
||||||
#define SCSI_PORT_RESET 0x0080
|
#define SCSI_PORT_RESET 0x0080
|
||||||
#define SCSI_PORT_RESET_REQUEST 0x0100
|
#define SCSI_PORT_RESET_REQUEST 0x0100
|
||||||
#define SCSI_PORT_DISCONNECT_IN_PROGRESS 0x1000
|
#define SCSI_PORT_DISCONNECT_ALLOWED 0x1000
|
||||||
#define SCSI_PORT_DISABLE_INTERRUPTS 0x4000
|
#define SCSI_PORT_DISABLE_INTERRUPTS 0x4000
|
||||||
#define SCSI_PORT_SCAN_IN_PROGRESS 0x8000
|
#define SCSI_PORT_SCAN_IN_PROGRESS 0x8000
|
||||||
|
|
||||||
|
@ -142,7 +142,6 @@ typedef struct _SCSI_PORT_DEVICE_EXTENSION
|
||||||
|
|
||||||
LONG ActiveRequestCounter;
|
LONG ActiveRequestCounter;
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
LONG TimeOutCount;
|
|
||||||
|
|
||||||
KSPIN_LOCK IrpLock;
|
KSPIN_LOCK IrpLock;
|
||||||
KSPIN_LOCK SpinLock;
|
KSPIN_LOCK SpinLock;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue