Author: fireball
Date: Sun Apr 1 15:17:48 2007
New Revision: 26225
URL:
http://svn.reactos.org/svn/reactos?rev=26225&view=rev
Log:
- More DPRINTs added to ease debugging
- Bugfixes: IOCTL_SCSI_GET_CAPABILITIES fixed, setting inquiry operation in CDB fixed,
storing information about bus scanning fixed
Modified:
trunk/reactos/drivers/storage/scsiport-new/scsiport.c
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 Sun Apr 1 15:17:48 2007
@@ -839,6 +839,7 @@
DriverObject->MajorFunction[IRP_MJ_CREATE] = ScsiPortCreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ScsiPortCreateClose;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ScsiPortDeviceControl;
+ DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
ScsiPortDeviceControl;
DriverObject->MajorFunction[IRP_MJ_SCSI] = ScsiPortDispatchScsi;
/* Obtain configuration information */
@@ -1421,10 +1422,10 @@
+ sizeof(ULONG));
/* Store number of buses there */
- DeviceExtension->BusesConfig->NumberOfBuses =
DeviceExtension->PortConfig->NumberOfBuses;
+ DeviceExtension->BusesConfig->NumberOfBuses = DeviceExtension->BusNum;
/* Scan the adapter for devices */
- SpiScanAdapter (DeviceExtension);
+ SpiScanAdapter(DeviceExtension);
/* Build the registry device map */
SpiBuildDeviceMap(DeviceExtension,
@@ -1572,6 +1573,7 @@
}
/* Finally delete the device object */
+ DPRINT("Deleting device %p\n", DeviceExtension->DeviceObject);
IoDeleteDevice(DeviceExtension->DeviceObject);
}
@@ -2359,19 +2361,18 @@
ScsiPortDeviceControl(IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
- PIO_STACK_LOCATION Stack;
- PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
-
- DPRINT("ScsiPortDeviceControl()\n");
-
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
-
-
- Stack = IoGetCurrentIrpStackLocation(Irp);
- DeviceExtension = DeviceObject->DeviceExtension;
-
- switch (Stack->Parameters.DeviceIoControl.IoControlCode)
+ PIO_STACK_LOCATION Stack;
+ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
+ NTSTATUS Status = STATUS_SUCCESS;;
+
+ DPRINT("ScsiPortDeviceControl()\n");
+
+ Irp->IoStatus.Information = 0;
+
+ Stack = IoGetCurrentIrpStackLocation(Irp);
+ DeviceExtension = DeviceObject->DeviceExtension;
+
+ switch (Stack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_SCSI_GET_DUMP_POINTERS:
{
@@ -2385,24 +2386,36 @@
break;
case IOCTL_SCSI_GET_CAPABILITIES:
- {
- DPRINT(" IOCTL_SCSI_GET_CAPABILITIES\n");
-
- *((PIO_SCSI_CAPABILITIES *)Irp->AssociatedIrp.SystemBuffer) =
- &DeviceExtension->PortCapabilities;
-
- Irp->IoStatus.Information = sizeof(PIO_SCSI_CAPABILITIES);
- }
- break;
+ DPRINT(" IOCTL_SCSI_GET_CAPABILITIES\n");
+ if (Stack->Parameters.DeviceIoControl.OutputBufferLength == sizeof(PVOID))
+ {
+ *((PVOID *)Irp->AssociatedIrp.SystemBuffer) =
&DeviceExtension->PortCapabilities;
+
+ Irp->IoStatus.Information = sizeof(PVOID);
+ Status = STATUS_SUCCESS;
+ break;
+ }
+
+ if (Stack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(IO_SCSI_CAPABILITIES))
+ {
+ Status = STATUS_BUFFER_TOO_SMALL;
+ break;
+ }
+
+ RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
+ &DeviceExtension->PortCapabilities,
+ sizeof(IO_SCSI_CAPABILITIES));
+
+ Irp->IoStatus.Information = sizeof(IO_SCSI_CAPABILITIES);
+ Status = STATUS_SUCCESS;
+ break;
case IOCTL_SCSI_GET_INQUIRY_DATA:
- {
- DPRINT(" IOCTL_SCSI_GET_INQUIRY_DATA\n");
-
- /* Copy inquiry data to the port device extension */
- Irp->IoStatus.Status = SpiGetInquiryData(DeviceExtension, Irp);
- }
- break;
+ DPRINT(" IOCTL_SCSI_GET_INQUIRY_DATA\n");
+
+ /* Copy inquiry data to the port device extension */
+ Status = SpiGetInquiryData(DeviceExtension, Irp);
+ break;
default:
DPRINT1(" unknown ioctl code: 0x%lX\n",
@@ -2410,9 +2423,11 @@
break;
}
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- return(STATUS_SUCCESS);
+ /* Complete the request with the given status */
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return Status;
}
@@ -2832,6 +2847,7 @@
/* Fill in CDB */
Cdb = (PCDB)Srb.Cdb;
+ Cdb->CDB6INQUIRY.OperationCode = SCSIOP_INQUIRY;
Cdb->CDB6INQUIRY.LogicalUnitNumber = LunInfo->Lun;
Cdb->CDB6INQUIRY.AllocationLength = INQUIRYDATABUFFERSIZE;
@@ -2864,6 +2880,7 @@
}
else
{
+ DPRINT("Inquiry SRB failed with SrbStatus 0x%08X\n",
Srb.SrbStatus);
/* Check if the queue is frozen */
if (Srb.SrbStatus & SRB_STATUS_QUEUE_FROZEN)
{
@@ -2893,6 +2910,7 @@
/* Check if data overrun happened */
if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_DATA_OVERRUN)
{
+ DPRINT("Data overrun at TargetId %d\n", LunInfo->TargetId);
/* Nothing dramatic, just copy data, but limiting the size */
RtlCopyMemory(LunInfo->InquiryData,
InquiryBuffer,
@@ -2945,7 +2963,7 @@
ExFreePool(InquiryBuffer);
ExFreePool(SenseBuffer);
- DPRINT("SpiSendInquiry() done\n");
+ DPRINT("SpiSendInquiry() done with Status 0x%08X\n", Status);
return Status;
}
@@ -2966,11 +2984,12 @@
NTSTATUS Status;
ULONG DevicesFound;
- DPRINT ("SpiScanAdapter() called\n");
+ DPRINT("SpiScanAdapter() called\n");
/* Scan all buses */
- for (Bus = 0; Bus < DeviceExtension->PortConfig->NumberOfBuses; Bus++)
- {
+ for (Bus = 0; Bus < DeviceExtension->BusNum; Bus++)
+ {
+ DPRINT(" Scanning bus %d\n", Bus);
DevicesFound = 0;
/* Get pointer to the scan information */
@@ -2998,6 +3017,9 @@
DPRINT1("Out of resources!\n");
return;
}
+
+ /* Store the pointer in the BusScanInfo array */
+ DeviceExtension->BusesConfig->BusScanInfo[Bus] = BusScanInfo;
/* Fill this struct (length and bus ids for now) */
BusScanInfo->Length = sizeof(SCSI_BUS_SCAN_INFO);
@@ -3155,6 +3177,7 @@
/* Sum what we found */
BusScanInfo->LogicalUnitsCount += DevicesFound;
+ DPRINT(" Found %d devices on bus %d\n", DevicesFound, Bus);
}
DPRINT ("SpiScanAdapter() done\n");