Author: fireball
Date: Wed Mar 28 23:26:41 2007
New Revision: 26198
URL:
http://svn.reactos.org/svn/reactos?rev=26198&view=rev
Log:
- 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.
Modified:
trunk/reactos/drivers/storage/scsiport-new/scsiport.c
trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h
Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
==============================================================================
--- trunk/reactos/drivers/storage/scsiport-new/scsiport.c (original)
+++ trunk/reactos/drivers/storage/scsiport-new/scsiport.c Wed Mar 28 23:26:41 2007
@@ -638,54 +638,60 @@
IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
IN PVOID HwContext)
{
- PDRIVER_OBJECT DriverObject = (PDRIVER_OBJECT)Argument1;
-// PUNICODE_STRING RegistryPath = (PUNICODE_STRING)Argument2;
- PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
- PCONFIGURATION_INFORMATION SystemConfig;
- PPORT_CONFIGURATION_INFORMATION PortConfig;
- ULONG DeviceExtensionSize;
- ULONG PortConfigSize;
- BOOLEAN Again;
- BOOLEAN DeviceFound = FALSE;
- ULONG i;
- ULONG Result;
- NTSTATUS Status;
- ULONG MaxBus;
- ULONG BusNumber;
- PCI_SLOT_NUMBER SlotNumber;
-
- PDEVICE_OBJECT PortDeviceObject;
- WCHAR NameBuffer[80];
- UNICODE_STRING DeviceName;
- WCHAR DosNameBuffer[80];
- UNICODE_STRING DosDeviceName;
- PIO_SCSI_CAPABILITIES PortCapabilities;
- ULONG MappedIrq;
- KIRQL Dirql;
- KAFFINITY Affinity;
-
-
- DPRINT ("ScsiPortInitialize() called!\n");
-
- if ((HwInitializationData->HwInitialize == NULL) ||
- (HwInitializationData->HwStartIo == NULL) ||
- (HwInitializationData->HwInterrupt == NULL) ||
- (HwInitializationData->HwFindAdapter == NULL) ||
- (HwInitializationData->HwResetBus == NULL))
- return(STATUS_INVALID_PARAMETER);
-
- DriverObject->DriverStartIo = ScsiPortStartIo;
- DriverObject->MajorFunction[IRP_MJ_CREATE] = ScsiPortCreateClose;
- DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScsiPortCreateClose;
- DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScsiPortDeviceControl;
- DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiPortDispatchScsi;
-
- SystemConfig = IoGetConfigurationInformation();
-
- DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) +
- HwInitializationData->DeviceExtensionSize;
- PortConfigSize = sizeof(PORT_CONFIGURATION_INFORMATION) +
- HwInitializationData->NumberOfAccessRanges * sizeof(ACCESS_RANGE);
+ PDRIVER_OBJECT DriverObject = (PDRIVER_OBJECT)Argument1;
+ // PUNICODE_STRING RegistryPath = (PUNICODE_STRING)Argument2;
+ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
+ PCONFIGURATION_INFORMATION SystemConfig;
+ PPORT_CONFIGURATION_INFORMATION PortConfig;
+ ULONG DeviceExtensionSize;
+ ULONG PortConfigSize;
+ BOOLEAN Again;
+ BOOLEAN DeviceFound = FALSE;
+ ULONG i;
+ ULONG Result;
+ NTSTATUS Status;
+ ULONG MaxBus;
+ ULONG BusNumber;
+ PCI_SLOT_NUMBER SlotNumber;
+
+ PDEVICE_OBJECT PortDeviceObject;
+ WCHAR NameBuffer[80];
+ UNICODE_STRING DeviceName;
+ WCHAR DosNameBuffer[80];
+ UNICODE_STRING DosDeviceName;
+ PIO_SCSI_CAPABILITIES PortCapabilities;
+ ULONG MappedIrq;
+ KIRQL Dirql;
+ KAFFINITY Affinity;
+
+
+ DPRINT ("ScsiPortInitialize() called!\n");
+
+ /* Check params for validity */
+ if ((HwInitializationData->HwInitialize == NULL) ||
+ (HwInitializationData->HwStartIo == NULL) ||
+ (HwInitializationData->HwInterrupt == NULL) ||
+ (HwInitializationData->HwFindAdapter == NULL) ||
+ (HwInitializationData->HwResetBus == NULL))
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Set handlers */
+ DriverObject->DriverStartIo = ScsiPortStartIo;
+ DriverObject->MajorFunction[IRP_MJ_CREATE] = ScsiPortCreateClose;
+ DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScsiPortCreateClose;
+ DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScsiPortDeviceControl;
+ DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiPortDispatchScsi;
+
+ /* Obtain configuration information */
+ SystemConfig = IoGetConfigurationInformation();
+
+ /* Calculate sizes of DeviceExtension and PortConfig */
+ DeviceExtensionSize = sizeof(SCSI_PORT_DEVICE_EXTENSION) +
+ HwInitializationData->DeviceExtensionSize;
+ PortConfigSize = sizeof(PORT_CONFIGURATION_INFORMATION) +
+ HwInitializationData->NumberOfAccessRanges * sizeof(ACCESS_RANGE);
MaxBus = (HwInitializationData->AdapterInterfaceType == PCIBus) ? 8 : 1;
@@ -762,7 +768,7 @@
/* Initialize the device timer */
DeviceExtension->TimerState = IDETimerIdle;
- DeviceExtension->TimerCount = 0;
+ DeviceExtension->TimerCount = -1;
IoInitializeTimer (PortDeviceObject,
ScsiPortIoTimer,
DeviceExtension);
@@ -885,6 +891,9 @@
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) */
DeviceExtension->ActiveRequestCounter = -1;
@@ -1187,6 +1196,9 @@
}
va_end(ap);
+
+ /* Request a DPC after we're done with the interrupt */
+ DeviceExtension->InterruptData.Flags |= SCSI_PORT_NOTIFICATION_NEEDED;
}
@@ -1836,7 +1848,7 @@
}
/* Set the time out value */
- DeviceExtension->TimeOutCount = Srb->TimeOutValue;
+ DeviceExtension->TimerCount = Srb->TimeOutValue;
/* We are busy */
DeviceExtension->Flags |= SCSI_PORT_DEVICE_BUSY;
@@ -1863,7 +1875,7 @@
if (Srb->SrbFlags & SRB_FLAGS_DISABLE_DISCONNECT)
{
/* 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;
@@ -2051,6 +2063,7 @@
/* Wait for it to complete */
if (Status == STATUS_PENDING)
{
+ DPRINT("SpiSendInquiry(): Waiting for the driver to process
request...\n");
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
@@ -2058,6 +2071,8 @@
NULL);
Status = IoStatusBlock.Status;
}
+
+ DPRINT("SpiSendInquiry(): Request processed by driver, status =
0x%08X\n", Status);
if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_SUCCESS)
{
@@ -2133,6 +2148,8 @@
/* Free buffers */
ExFreePool(InquiryBuffer);
ExFreePool(SenseBuffer);
+
+ DPRINT("SpiSendInquiry() done\n");
return Status;
}
Modified: trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/scsiport-n…
==============================================================================
--- trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h (original)
+++ trunk/reactos/drivers/storage/scsiport-new/scsiport_int.h Wed Mar 28 23:26:41 2007
@@ -26,7 +26,7 @@
#define SCSI_PORT_NEXT_REQUEST_READY 0x0008
#define SCSI_PORT_RESET 0x0080
#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_SCAN_IN_PROGRESS 0x8000
@@ -142,7 +142,6 @@
LONG ActiveRequestCounter;
ULONG Flags;
- LONG TimeOutCount;
KSPIN_LOCK IrpLock;
KSPIN_LOCK SpinLock;