From a9f79206fabb8482a6ad8b751f1359371320b53c Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sat, 25 May 2002 13:30:53 +0000 Subject: [PATCH] Fixed timeout for unpopulated ide channels. Fixed inquiry data block for unpopulated ide channels. Minor cleanup. svn path=/trunk/; revision=2979 --- reactos/drivers/storage/atapi/atapi.c | 141 ++++++++++++++------ reactos/drivers/storage/cdrom/cdrom.c | 8 +- reactos/drivers/storage/class2/class2.c | 72 +++++++++- reactos/drivers/storage/disk/disk.c | 20 +-- reactos/drivers/storage/include/ntddscsi.h | 13 +- reactos/drivers/storage/scsiport/scsiport.c | 30 ++++- 6 files changed, 219 insertions(+), 65 deletions(-) diff --git a/reactos/drivers/storage/atapi/atapi.c b/reactos/drivers/storage/atapi/atapi.c index 635a5face29..f4297e5a50b 100644 --- a/reactos/drivers/storage/atapi/atapi.c +++ b/reactos/drivers/storage/atapi/atapi.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: atapi.c,v 1.21 2002/05/24 22:27:48 ekohl Exp $ +/* $Id: atapi.c,v 1.22 2002/05/25 13:28:42 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS ATAPI miniport driver @@ -254,7 +254,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject, HW_INITIALIZATION_DATA InitData; NTSTATUS Status; - DbgPrint("ATAPI Driver %s\n", VERSION); + DPRINT("ATAPI Driver %s\n", VERSION); /* Initialize data structure */ RtlZeroMemory(&InitData, @@ -496,7 +496,7 @@ AtapiFindIsaBusController(PVOID DeviceExtension, if (ConfigInfo->AtdiskPrimaryClaimed == FALSE) { /* Both channels unclaimed: Claim primary channel */ - DPRINT1("Primary channel!\n"); + DPRINT("Primary channel!\n"); DevExt->CommandPortBase = 0x01F0; DevExt->ControlPortBase = 0x03F6; @@ -520,7 +520,7 @@ AtapiFindIsaBusController(PVOID DeviceExtension, else if (ConfigInfo->AtdiskSecondaryClaimed == FALSE) { /* Primary channel already claimed: claim secondary channel */ - DPRINT1("Secondary channel!\n"); + DPRINT("Secondary channel!\n"); DevExt->CommandPortBase = 0x0170; DevExt->ControlPortBase = 0x0376; @@ -916,8 +916,9 @@ AtapiFindDevices(PATAPI_MINIPORT_EXTENSION DeviceExtension, } if (Retries >= 20000) { - DbgPrint("Timeout on drive %lu\n", UnitNumber); - return(DeviceFound); + DPRINT("Timeout on drive %lu\n", UnitNumber); + DeviceExtension->DevicePresent[UnitNumber] = FALSE; + continue; } High = IDEReadCylinderHigh(CommandPortBase); @@ -966,7 +967,8 @@ AtapiFindDevices(PATAPI_MINIPORT_EXTENSION DeviceExtension, } } - DPRINT("AtapiFindDrives() done\n"); + + DPRINT("AtapiFindDrives() done (DeviceFound %s)\n", (DeviceFound) ? "TRUE" : "FALSE"); return(DeviceFound); } @@ -1012,14 +1014,11 @@ AtapiResetController(IN ULONG CommandPort, ScsiPortStallExecution(10); } - CHECKPOINT; if (Retries >= IDE_RESET_BUSY_TIMEOUT * 1000) { return(FALSE); } - CHECKPOINT; - // return TRUE if controller came back to life. and // the registers are initialized correctly return(IDEReadError(CommandPort) == 1); @@ -1070,8 +1069,8 @@ AtapiIdentifyDevice(IN ULONG CommandPort, (Atapi ? IDE_CMD_IDENT_ATAPI_DRV : IDE_CMD_IDENT_ATA_DRV), (BYTE *)DrvParms) != 0) { - DPRINT1("IDEPolledRead() failed\n"); - return FALSE; + DPRINT("IDEPolledRead() failed\n"); + return(FALSE); } /* Report on drive parameters if debug mode */ @@ -1114,7 +1113,8 @@ AtapiIdentifyDevice(IN ULONG CommandPort, DPRINT("BytesPerSector %d\n", DrvParms->BytesPerSector); if (DrvParms->BytesPerSector == 0) DrvParms->BytesPerSector = 512; - return TRUE; + + return(TRUE); } @@ -1312,12 +1312,28 @@ AtapiSendAtapiCommand(IN PATAPI_MINIPORT_EXTENSION DeviceExtension, DPRINT("AtapiSendAtapiCommand() called!\n"); - if ((Srb->PathId != 0) || - (Srb->TargetId > 1) || - (Srb->Lun != 0) || - (DeviceExtension->DevicePresent[Srb->TargetId] == FALSE)) + if (Srb->PathId != 0) { - return(SRB_STATUS_SELECTION_TIMEOUT); + Srb->SrbStatus = SRB_STATUS_INVALID_PATH_ID; + return(SRB_STATUS_INVALID_PATH_ID); + } + + if (Srb->TargetId > 1) + { + Srb->SrbStatus = SRB_STATUS_INVALID_TARGET_ID; + return(SRB_STATUS_INVALID_TARGET_ID); + } + + if (Srb->Lun != 0) + { + Srb->SrbStatus = SRB_STATUS_INVALID_LUN; + return(SRB_STATUS_INVALID_LUN); + } + + if (DeviceExtension->DevicePresent[Srb->TargetId] == FALSE) + { + Srb->SrbStatus = SRB_STATUS_NO_DEVICE; + return(SRB_STATUS_NO_DEVICE); } DPRINT("AtapiSendAtapiCommand(): TargetId: %lu\n", @@ -1514,15 +1530,31 @@ AtapiInquiry(PATAPI_MINIPORT_EXTENSION DeviceExtension, PINQUIRYDATA InquiryData; ULONG i; - DPRINT1("SCSIOP_INQUIRY: DeviceExtension %p TargetId: %lu\n", - DeviceExtension, Srb->TargetId); + DPRINT("SCSIOP_INQUIRY: DeviceExtension %p TargetId: %lu\n", + DeviceExtension, Srb->TargetId); - if ((Srb->PathId != 0) || - (Srb->TargetId > 1) || - (Srb->Lun != 0) || - (DeviceExtension->DevicePresent[Srb->TargetId] == FALSE)) + if (Srb->PathId != 0) { - return(SRB_STATUS_SELECTION_TIMEOUT); + Srb->SrbStatus = SRB_STATUS_INVALID_PATH_ID; + return(SRB_STATUS_INVALID_PATH_ID); + } + + if (Srb->TargetId > 1) + { + Srb->SrbStatus = SRB_STATUS_INVALID_TARGET_ID; + return(SRB_STATUS_INVALID_TARGET_ID); + } + + if (Srb->Lun != 0) + { + Srb->SrbStatus = SRB_STATUS_INVALID_LUN; + return(SRB_STATUS_INVALID_LUN); + } + + if (DeviceExtension->DevicePresent[Srb->TargetId] == FALSE) + { + Srb->SrbStatus = SRB_STATUS_NO_DEVICE; + return(SRB_STATUS_NO_DEVICE); } InquiryData = Srb->DataBuffer; @@ -1575,8 +1607,9 @@ AtapiInquiry(PATAPI_MINIPORT_EXTENSION DeviceExtension, ((PUCHAR)DeviceParams->FirmwareRev)[i+1]; } - DPRINT1("VendorId: '%.20s'\n", InquiryData->VendorId); + DPRINT("VendorId: '%.20s'\n", InquiryData->VendorId); + Srb->SrbStatus = SRB_STATUS_SUCCESS; return(SRB_STATUS_SUCCESS); } @@ -1591,14 +1624,29 @@ AtapiReadCapacity(PATAPI_MINIPORT_EXTENSION DeviceExtension, DPRINT("SCSIOP_READ_CAPACITY: TargetId: %lu\n", Srb->TargetId); - if ((Srb->PathId != 0) || - (Srb->TargetId > 1) || - (Srb->Lun != 0) || - (DeviceExtension->DevicePresent[Srb->TargetId] == FALSE)) + if (Srb->PathId != 0) { - return(SRB_STATUS_SELECTION_TIMEOUT); + Srb->SrbStatus = SRB_STATUS_INVALID_PATH_ID; + return(SRB_STATUS_INVALID_PATH_ID); } + if (Srb->TargetId > 1) + { + Srb->SrbStatus = SRB_STATUS_INVALID_TARGET_ID; + return(SRB_STATUS_INVALID_TARGET_ID); + } + + if (Srb->Lun != 0) + { + Srb->SrbStatus = SRB_STATUS_INVALID_LUN; + return(SRB_STATUS_INVALID_LUN); + } + + if (DeviceExtension->DevicePresent[Srb->TargetId] == FALSE) + { + Srb->SrbStatus = SRB_STATUS_NO_DEVICE; + return(SRB_STATUS_NO_DEVICE); + } CapacityData = (PREAD_CAPACITY_DATA)Srb->DataBuffer; DeviceParams = &DeviceExtension->DeviceParams[Srb->TargetId]; @@ -1629,6 +1677,7 @@ AtapiReadCapacity(PATAPI_MINIPORT_EXTENSION DeviceExtension, LastSector, CapacityData->LogicalBlockAddress); + Srb->SrbStatus = SRB_STATUS_SUCCESS; return(SRB_STATUS_SUCCESS); } @@ -1650,12 +1699,28 @@ AtapiReadWrite(PATAPI_MINIPORT_EXTENSION DeviceExtension, DPRINT("AtapiReadWrite() called!\n"); - if ((Srb->PathId != 0) || - (Srb->TargetId > 1) || - (Srb->Lun != 0) || - (DeviceExtension->DevicePresent[Srb->TargetId] == FALSE)) + if (Srb->PathId != 0) { - return(SRB_STATUS_SELECTION_TIMEOUT); + Srb->SrbStatus = SRB_STATUS_INVALID_PATH_ID; + return(SRB_STATUS_INVALID_PATH_ID); + } + + if (Srb->TargetId > 1) + { + Srb->SrbStatus = SRB_STATUS_INVALID_TARGET_ID; + return(SRB_STATUS_INVALID_TARGET_ID); + } + + if (Srb->Lun != 0) + { + Srb->SrbStatus = SRB_STATUS_INVALID_LUN; + return(SRB_STATUS_INVALID_LUN); + } + + if (DeviceExtension->DevicePresent[Srb->TargetId] == FALSE) + { + Srb->SrbStatus = SRB_STATUS_NO_DEVICE; + return(SRB_STATUS_NO_DEVICE); } DPRINT("SCSIOP_WRITE: TargetId: %lu\n", @@ -1898,7 +1963,7 @@ AtapiErrorToScsi(PVOID DeviceExtension, UCHAR ScsiStatus; UCHAR SrbStatus; - DPRINT1("AtapiErrorToScsi() called\n"); + DPRINT("AtapiErrorToScsi() called\n"); DevExt = (PATAPI_MINIPORT_EXTENSION)DeviceExtension; @@ -2008,7 +2073,7 @@ AtapiErrorToScsi(PVOID DeviceExtension, Srb->ScsiStatus = ScsiStatus; - DPRINT1("AtapiErrorToScsi() done\n"); + DPRINT("AtapiErrorToScsi() done\n"); return(SrbStatus); } diff --git a/reactos/drivers/storage/cdrom/cdrom.c b/reactos/drivers/storage/cdrom/cdrom.c index d6b69bdef33..daad42b6670 100644 --- a/reactos/drivers/storage/cdrom/cdrom.c +++ b/reactos/drivers/storage/cdrom/cdrom.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cdrom.c,v 1.8 2002/04/10 17:02:22 ekohl Exp $ +/* $Id: cdrom.c,v 1.9 2002/05/25 13:29:58 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -553,10 +553,8 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject, break; default: - DPRINT1("Unhandled control code: %lx\n", ControlCode); - Status = STATUS_INVALID_DEVICE_REQUEST; - Information = 0; - break; + /* Call the common device control function */ + return(ScsiClassDeviceControl(DeviceObject, Irp)); } diff --git a/reactos/drivers/storage/class2/class2.c b/reactos/drivers/storage/class2/class2.c index 3bfa2660c6d..c04ab792399 100644 --- a/reactos/drivers/storage/class2/class2.c +++ b/reactos/drivers/storage/class2/class2.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: class2.c,v 1.17 2002/04/27 19:01:24 ekohl Exp $ +/* $Id: class2.c,v 1.18 2002/05/25 13:30:12 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -96,7 +96,7 @@ NTSTATUS STDCALL DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { - DbgPrint("Class Driver %s\n", VERSION); + DPRINT("Class Driver %s\n", VERSION); return(STATUS_SUCCESS); } @@ -412,7 +412,66 @@ NTSTATUS STDCALL ScsiClassDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) { - UNIMPLEMENTED; + PDEVICE_EXTENSION DeviceExtension; + PIO_STACK_LOCATION Stack; + ULONG IoControlCode; + ULONG OutputBufferLength; + + DPRINT1("ScsiClassDeviceControl() called\n"); + + DeviceExtension = DeviceObject->DeviceExtension; + Stack = IoGetCurrentIrpStackLocation(Irp); + + IoControlCode = Stack->Parameters.DeviceIoControl.IoControlCode; + OutputBufferLength = Stack->Parameters.DeviceIoControl.OutputBufferLength; + + if (IoControlCode == IOCTL_SCSI_GET_ADDRESS) + { + PSCSI_ADDRESS ScsiAddress; + + if (OutputBufferLength < sizeof(SCSI_ADDRESS)) + { + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return(STATUS_BUFFER_TOO_SMALL); + } + + ScsiAddress = Irp->AssociatedIrp.SystemBuffer; + ScsiAddress->Length = sizeof(SCSI_ADDRESS); + ScsiAddress->PortNumber = DeviceExtension->PortNumber; + ScsiAddress->PathId = DeviceExtension->PathId; + ScsiAddress->TargetId = DeviceExtension->TargetId; + ScsiAddress->Lun = DeviceExtension->Lun; + + Irp->IoStatus.Information = sizeof(SCSI_ADDRESS); + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return(STATUS_SUCCESS); + } + + if (IoControlCode == IOCTL_SCSI_PASS_THROUGH || + IoControlCode == IOCTL_SCSI_PASS_THROUGH_DIRECT) + { + DPRINT1("Fixme: IOCTL_SCSI_PASS_THROUGH/IOCTL_SCSI_PASS_THROUGH_DIRECT\n"); + + + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return(STATUS_UNSUCCESSFUL); + } + + DPRINT1("Fixme: unknown device io control code\n"); + + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + return(STATUS_UNSUCCESSFUL); } @@ -437,7 +496,7 @@ ScsiClassFindUnclaimedDevices(PCLASS_INIT_DATA InitializationData, ULONG UnclaimedDevices = 0; NTSTATUS Status; - DPRINT("ScsiClassFindUnclaimedDevices() called!\n"); + DPRINT("ScsiClassFindUnclaimedDevices() called\n"); DPRINT("NumberOfBuses: %lu\n",AdapterInformation->NumberOfBuses); Buffer = (PUCHAR)AdapterInformation; @@ -890,7 +949,7 @@ ScsiClassIoComplete(PDEVICE_OBJECT DeviceObject, ExFreePool(IrpStack->Parameters.Scsi.Srb); Irp->IoStatus.Status = Status; -#if 0 +//#if 0 if (!NT_SUCCESS(Status)) { Irp->IoStatus.Information = 0; @@ -900,7 +959,8 @@ ScsiClassIoComplete(PDEVICE_OBJECT DeviceObject, DeviceObject); } } - +//#endif +#if 0 if (Irp->PendingReturned) { IoMarkIrpPending(Irp); diff --git a/reactos/drivers/storage/disk/disk.c b/reactos/drivers/storage/disk/disk.c index 9bc3f955ba5..6216dfcf015 100644 --- a/reactos/drivers/storage/disk/disk.c +++ b/reactos/drivers/storage/disk/disk.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: disk.c,v 1.12 2002/03/22 23:07:40 ekohl Exp $ +/* $Id: disk.c,v 1.13 2002/05/25 13:30:28 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -111,8 +111,8 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject, { CLASS_INIT_DATA InitData; - DbgPrint("Disk Class Driver %s\n", - VERSION); + DPRINT("Disk Class Driver %s\n", + VERSION); DPRINT("RegistryPath '%wZ'\n", RegistryPath); @@ -217,7 +217,7 @@ DiskClassFindDevices(PDRIVER_OBJECT DriverObject, AdapterBusInfo); if (DeviceCount == 0) { - DPRINT1("No unclaimed devices!\n"); + DPRINT("No unclaimed devices!\n"); return(FALSE); } @@ -449,7 +449,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject, InitializationData); if (!NT_SUCCESS(Status)) { - DPRINT1("ScsiClassCreateDeviceObject() failed (Status %x)\n", Status); + DPRINT("ScsiClassCreateDeviceObject() failed (Status %x)\n", Status); /* Release (unclaim) the disk */ ScsiClassClaimDevice(PortDeviceObject, @@ -501,7 +501,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject, sizeof(DISK_GEOMETRY)); if (DiskDeviceExtension->DiskGeometry == NULL) { - DPRINT1("Failed to allocate geometry buffer!\n"); + DPRINT("Failed to allocate geometry buffer!\n"); IoDeleteDevice(DiskDeviceObject); @@ -810,13 +810,15 @@ DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject, case IOCTL_DISK_HISTOGRAM_RESET: case IOCTL_DISK_REQUEST_STRUCTURE: case IOCTL_DISK_REQUEST_DATA: - - /* If we get here, something went wrong. inform the requestor */ - default: + /* If we get here, something went wrong. inform the requestor */ DPRINT1("Unhandled control code: %lx\n", ControlCode); Status = STATUS_INVALID_DEVICE_REQUEST; Information = 0; break; + + default: + /* Call the common device control function */ + return(ScsiClassDeviceControl(DeviceObject, Irp)); } Irp->IoStatus.Status = Status; diff --git a/reactos/drivers/storage/include/ntddscsi.h b/reactos/drivers/storage/include/ntddscsi.h index 9291062ad5a..91a52f814a5 100644 --- a/reactos/drivers/storage/include/ntddscsi.h +++ b/reactos/drivers/storage/include/ntddscsi.h @@ -1,4 +1,4 @@ -/* $Id: ntddscsi.h,v 1.2 2002/01/14 01:44:18 ekohl Exp $ +/* $Id: ntddscsi.h,v 1.3 2002/05/25 13:30:39 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -76,6 +76,17 @@ typedef struct _SCSI_INQUIRY_DATA }SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA; +/* Used by IOCTL_SCSI_GET_ADDRESS */ + +typedef struct _SCSI_ADDRESS +{ + ULONG Length; + UCHAR PortNumber; + UCHAR PathId; + UCHAR TargetId; + UCHAR Lun; +} SCSI_ADDRESS, *PSCSI_ADDRESS; + #endif /* __STORAGE_INCLUDE_NTDDSCSI_H */ /* EOF */ \ No newline at end of file diff --git a/reactos/drivers/storage/scsiport/scsiport.c b/reactos/drivers/storage/scsiport/scsiport.c index 9a4f4177f48..0ab89d6060d 100644 --- a/reactos/drivers/storage/scsiport/scsiport.c +++ b/reactos/drivers/storage/scsiport/scsiport.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: scsiport.c,v 1.13 2002/05/07 23:13:24 hbirr Exp $ +/* $Id: scsiport.c,v 1.14 2002/05/25 13:30:53 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -705,7 +705,8 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, ULONG DataSize = 0; - DPRINT("ScsiPortDispatchScsi()\n"); + DPRINT("ScsiPortDispatchScsi(DeviceObject %p Irp %p)\n", + DeviceObject, Irp); DeviceExtension = DeviceObject->DeviceExtension; Stack = IoGetCurrentIrpStackLocation(Irp); @@ -749,6 +750,7 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, DPRINT("Srb: %p\n", Srb); DPRINT("Srb->Function: %lu\n", Srb->Function); + DPRINT("PathId: %lu TargetId: %lu Lun: %lu\n", Srb->PathId, Srb->TargetId, Srb->Lun); switch (Srb->Function) { @@ -765,11 +767,17 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, PINQUIRYDATA InquiryData; DPRINT(" SRB_FUNCTION_CLAIM_DEVICE\n"); + DPRINT("PathId: %lu TargetId: %lu Lun: %lu\n", Srb->PathId, Srb->TargetId, Srb->Lun); + + Srb->DataBuffer = NULL; if (DeviceExtension->PortBusInfo != NULL) { AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)DeviceExtension->PortBusInfo; + if (AdapterInfo->BusData[Srb->PathId].NumberOfLogicalUnits == 0) + break; + UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo + AdapterInfo->BusData[Srb->PathId].InquiryDataOffset); @@ -783,6 +791,10 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, { UnitInfo->DeviceClaimed = TRUE; DPRINT("Claimed device!\n"); + + /* FIXME: Hack!!!!! */ + Srb->DataBuffer = DeviceObject; + break; } @@ -792,9 +804,6 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo + UnitInfo->NextInquiryDataOffset); } } - - /* FIXME: Hack!!!!! */ - Srb->DataBuffer = DeviceObject; } break; @@ -805,15 +814,18 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject, PINQUIRYDATA InquiryData; DPRINT(" SRB_FUNCTION_RELEASE_DEVICE\n"); + DPRINT("PathId: %lu TargetId: %lu Lun: %lu\n", Srb->PathId, Srb->TargetId, Srb->Lun); if (DeviceExtension->PortBusInfo != NULL) { AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)DeviceExtension->PortBusInfo; + if (AdapterInfo->BusData[Srb->PathId].NumberOfLogicalUnits == 0) + break; + UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo + AdapterInfo->BusData[Srb->PathId].InquiryDataOffset); - while (AdapterInfo->BusData[Srb->PathId].InquiryDataOffset) { InquiryData = (PINQUIRYDATA)UnitInfo->InquiryData; @@ -1235,9 +1247,12 @@ ScsiPortInquire(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension) { Srb.TargetId = Target; Srb.Lun = 0; + Srb.SrbStatus = SRB_STATUS_SUCCESS; Result = DeviceExtension->HwStartIo(&DeviceExtension->MiniPortDeviceExtension, &Srb); + DPRINT("Result: %s Srb.SrbStatus %lx\n", (Result)?"True":"False", Srb.SrbStatus); + if (Result == TRUE && Srb.SrbStatus == SRB_STATUS_SUCCESS) { UnitInfo->PathId = Bus; @@ -1254,7 +1269,10 @@ ScsiPortInquire(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension) UnitCount++; } } + DPRINT("UnitCount: %lu\n", UnitCount); AdapterInfo->BusData[Bus].NumberOfLogicalUnits = UnitCount; + if (UnitCount == 0) + AdapterInfo->BusData[Bus].InquiryDataOffset = 0; } DataSize = (ULONG)((PUCHAR)UnitInfo-(PUCHAR)AdapterInfo);