Fixed timeout for unpopulated ide channels.

Fixed inquiry data block for unpopulated ide channels.
Minor cleanup.

svn path=/trunk/; revision=2979
This commit is contained in:
Eric Kohl 2002-05-25 13:30:53 +00:00
parent 66bc07c8b9
commit a9f79206fa
6 changed files with 219 additions and 65 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS ATAPI miniport driver * PROJECT: ReactOS ATAPI miniport driver
@ -254,7 +254,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
HW_INITIALIZATION_DATA InitData; HW_INITIALIZATION_DATA InitData;
NTSTATUS Status; NTSTATUS Status;
DbgPrint("ATAPI Driver %s\n", VERSION); DPRINT("ATAPI Driver %s\n", VERSION);
/* Initialize data structure */ /* Initialize data structure */
RtlZeroMemory(&InitData, RtlZeroMemory(&InitData,
@ -496,7 +496,7 @@ AtapiFindIsaBusController(PVOID DeviceExtension,
if (ConfigInfo->AtdiskPrimaryClaimed == FALSE) if (ConfigInfo->AtdiskPrimaryClaimed == FALSE)
{ {
/* Both channels unclaimed: Claim primary channel */ /* Both channels unclaimed: Claim primary channel */
DPRINT1("Primary channel!\n"); DPRINT("Primary channel!\n");
DevExt->CommandPortBase = 0x01F0; DevExt->CommandPortBase = 0x01F0;
DevExt->ControlPortBase = 0x03F6; DevExt->ControlPortBase = 0x03F6;
@ -520,7 +520,7 @@ AtapiFindIsaBusController(PVOID DeviceExtension,
else if (ConfigInfo->AtdiskSecondaryClaimed == FALSE) else if (ConfigInfo->AtdiskSecondaryClaimed == FALSE)
{ {
/* Primary channel already claimed: claim secondary channel */ /* Primary channel already claimed: claim secondary channel */
DPRINT1("Secondary channel!\n"); DPRINT("Secondary channel!\n");
DevExt->CommandPortBase = 0x0170; DevExt->CommandPortBase = 0x0170;
DevExt->ControlPortBase = 0x0376; DevExt->ControlPortBase = 0x0376;
@ -916,8 +916,9 @@ AtapiFindDevices(PATAPI_MINIPORT_EXTENSION DeviceExtension,
} }
if (Retries >= 20000) if (Retries >= 20000)
{ {
DbgPrint("Timeout on drive %lu\n", UnitNumber); DPRINT("Timeout on drive %lu\n", UnitNumber);
return(DeviceFound); DeviceExtension->DevicePresent[UnitNumber] = FALSE;
continue;
} }
High = IDEReadCylinderHigh(CommandPortBase); 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); return(DeviceFound);
} }
@ -1012,14 +1014,11 @@ AtapiResetController(IN ULONG CommandPort,
ScsiPortStallExecution(10); ScsiPortStallExecution(10);
} }
CHECKPOINT;
if (Retries >= IDE_RESET_BUSY_TIMEOUT * 1000) if (Retries >= IDE_RESET_BUSY_TIMEOUT * 1000)
{ {
return(FALSE); return(FALSE);
} }
CHECKPOINT;
// return TRUE if controller came back to life. and // return TRUE if controller came back to life. and
// the registers are initialized correctly // the registers are initialized correctly
return(IDEReadError(CommandPort) == 1); return(IDEReadError(CommandPort) == 1);
@ -1070,8 +1069,8 @@ AtapiIdentifyDevice(IN ULONG CommandPort,
(Atapi ? IDE_CMD_IDENT_ATAPI_DRV : IDE_CMD_IDENT_ATA_DRV), (Atapi ? IDE_CMD_IDENT_ATAPI_DRV : IDE_CMD_IDENT_ATA_DRV),
(BYTE *)DrvParms) != 0) (BYTE *)DrvParms) != 0)
{ {
DPRINT1("IDEPolledRead() failed\n"); DPRINT("IDEPolledRead() failed\n");
return FALSE; return(FALSE);
} }
/* Report on drive parameters if debug mode */ /* Report on drive parameters if debug mode */
@ -1114,7 +1113,8 @@ AtapiIdentifyDevice(IN ULONG CommandPort,
DPRINT("BytesPerSector %d\n", DrvParms->BytesPerSector); DPRINT("BytesPerSector %d\n", DrvParms->BytesPerSector);
if (DrvParms->BytesPerSector == 0) if (DrvParms->BytesPerSector == 0)
DrvParms->BytesPerSector = 512; DrvParms->BytesPerSector = 512;
return TRUE;
return(TRUE);
} }
@ -1312,12 +1312,28 @@ AtapiSendAtapiCommand(IN PATAPI_MINIPORT_EXTENSION DeviceExtension,
DPRINT("AtapiSendAtapiCommand() called!\n"); DPRINT("AtapiSendAtapiCommand() called!\n");
if ((Srb->PathId != 0) || if (Srb->PathId != 0)
(Srb->TargetId > 1) ||
(Srb->Lun != 0) ||
(DeviceExtension->DevicePresent[Srb->TargetId] == FALSE))
{ {
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", DPRINT("AtapiSendAtapiCommand(): TargetId: %lu\n",
@ -1514,15 +1530,31 @@ AtapiInquiry(PATAPI_MINIPORT_EXTENSION DeviceExtension,
PINQUIRYDATA InquiryData; PINQUIRYDATA InquiryData;
ULONG i; ULONG i;
DPRINT1("SCSIOP_INQUIRY: DeviceExtension %p TargetId: %lu\n", DPRINT("SCSIOP_INQUIRY: DeviceExtension %p TargetId: %lu\n",
DeviceExtension, Srb->TargetId); DeviceExtension, Srb->TargetId);
if ((Srb->PathId != 0) || if (Srb->PathId != 0)
(Srb->TargetId > 1) ||
(Srb->Lun != 0) ||
(DeviceExtension->DevicePresent[Srb->TargetId] == FALSE))
{ {
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; InquiryData = Srb->DataBuffer;
@ -1575,8 +1607,9 @@ AtapiInquiry(PATAPI_MINIPORT_EXTENSION DeviceExtension,
((PUCHAR)DeviceParams->FirmwareRev)[i+1]; ((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); return(SRB_STATUS_SUCCESS);
} }
@ -1591,14 +1624,29 @@ AtapiReadCapacity(PATAPI_MINIPORT_EXTENSION DeviceExtension,
DPRINT("SCSIOP_READ_CAPACITY: TargetId: %lu\n", Srb->TargetId); DPRINT("SCSIOP_READ_CAPACITY: TargetId: %lu\n", Srb->TargetId);
if ((Srb->PathId != 0) || if (Srb->PathId != 0)
(Srb->TargetId > 1) ||
(Srb->Lun != 0) ||
(DeviceExtension->DevicePresent[Srb->TargetId] == FALSE))
{ {
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; CapacityData = (PREAD_CAPACITY_DATA)Srb->DataBuffer;
DeviceParams = &DeviceExtension->DeviceParams[Srb->TargetId]; DeviceParams = &DeviceExtension->DeviceParams[Srb->TargetId];
@ -1629,6 +1677,7 @@ AtapiReadCapacity(PATAPI_MINIPORT_EXTENSION DeviceExtension,
LastSector, LastSector,
CapacityData->LogicalBlockAddress); CapacityData->LogicalBlockAddress);
Srb->SrbStatus = SRB_STATUS_SUCCESS;
return(SRB_STATUS_SUCCESS); return(SRB_STATUS_SUCCESS);
} }
@ -1650,12 +1699,28 @@ AtapiReadWrite(PATAPI_MINIPORT_EXTENSION DeviceExtension,
DPRINT("AtapiReadWrite() called!\n"); DPRINT("AtapiReadWrite() called!\n");
if ((Srb->PathId != 0) || if (Srb->PathId != 0)
(Srb->TargetId > 1) ||
(Srb->Lun != 0) ||
(DeviceExtension->DevicePresent[Srb->TargetId] == FALSE))
{ {
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", DPRINT("SCSIOP_WRITE: TargetId: %lu\n",
@ -1898,7 +1963,7 @@ AtapiErrorToScsi(PVOID DeviceExtension,
UCHAR ScsiStatus; UCHAR ScsiStatus;
UCHAR SrbStatus; UCHAR SrbStatus;
DPRINT1("AtapiErrorToScsi() called\n"); DPRINT("AtapiErrorToScsi() called\n");
DevExt = (PATAPI_MINIPORT_EXTENSION)DeviceExtension; DevExt = (PATAPI_MINIPORT_EXTENSION)DeviceExtension;
@ -2008,7 +2073,7 @@ AtapiErrorToScsi(PVOID DeviceExtension,
Srb->ScsiStatus = ScsiStatus; Srb->ScsiStatus = ScsiStatus;
DPRINT1("AtapiErrorToScsi() done\n"); DPRINT("AtapiErrorToScsi() done\n");
return(SrbStatus); return(SrbStatus);
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -553,10 +553,8 @@ CdromClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
break; break;
default: default:
DPRINT1("Unhandled control code: %lx\n", ControlCode); /* Call the common device control function */
Status = STATUS_INVALID_DEVICE_REQUEST; return(ScsiClassDeviceControl(DeviceObject, Irp));
Information = 0;
break;
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -96,7 +96,7 @@ NTSTATUS STDCALL
DriverEntry(IN PDRIVER_OBJECT DriverObject, DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath) IN PUNICODE_STRING RegistryPath)
{ {
DbgPrint("Class Driver %s\n", VERSION); DPRINT("Class Driver %s\n", VERSION);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -412,7 +412,66 @@ NTSTATUS STDCALL
ScsiClassDeviceControl(PDEVICE_OBJECT DeviceObject, ScsiClassDeviceControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp) 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; ULONG UnclaimedDevices = 0;
NTSTATUS Status; NTSTATUS Status;
DPRINT("ScsiClassFindUnclaimedDevices() called!\n"); DPRINT("ScsiClassFindUnclaimedDevices() called\n");
DPRINT("NumberOfBuses: %lu\n",AdapterInformation->NumberOfBuses); DPRINT("NumberOfBuses: %lu\n",AdapterInformation->NumberOfBuses);
Buffer = (PUCHAR)AdapterInformation; Buffer = (PUCHAR)AdapterInformation;
@ -890,7 +949,7 @@ ScsiClassIoComplete(PDEVICE_OBJECT DeviceObject,
ExFreePool(IrpStack->Parameters.Scsi.Srb); ExFreePool(IrpStack->Parameters.Scsi.Srb);
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;
#if 0 //#if 0
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
@ -900,7 +959,8 @@ ScsiClassIoComplete(PDEVICE_OBJECT DeviceObject,
DeviceObject); DeviceObject);
} }
} }
//#endif
#if 0
if (Irp->PendingReturned) if (Irp->PendingReturned)
{ {
IoMarkIrpPending(Irp); IoMarkIrpPending(Irp);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -111,7 +111,7 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject,
{ {
CLASS_INIT_DATA InitData; CLASS_INIT_DATA InitData;
DbgPrint("Disk Class Driver %s\n", DPRINT("Disk Class Driver %s\n",
VERSION); VERSION);
DPRINT("RegistryPath '%wZ'\n", DPRINT("RegistryPath '%wZ'\n",
RegistryPath); RegistryPath);
@ -217,7 +217,7 @@ DiskClassFindDevices(PDRIVER_OBJECT DriverObject,
AdapterBusInfo); AdapterBusInfo);
if (DeviceCount == 0) if (DeviceCount == 0)
{ {
DPRINT1("No unclaimed devices!\n"); DPRINT("No unclaimed devices!\n");
return(FALSE); return(FALSE);
} }
@ -449,7 +449,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
InitializationData); InitializationData);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("ScsiClassCreateDeviceObject() failed (Status %x)\n", Status); DPRINT("ScsiClassCreateDeviceObject() failed (Status %x)\n", Status);
/* Release (unclaim) the disk */ /* Release (unclaim) the disk */
ScsiClassClaimDevice(PortDeviceObject, ScsiClassClaimDevice(PortDeviceObject,
@ -501,7 +501,7 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
sizeof(DISK_GEOMETRY)); sizeof(DISK_GEOMETRY));
if (DiskDeviceExtension->DiskGeometry == NULL) if (DiskDeviceExtension->DiskGeometry == NULL)
{ {
DPRINT1("Failed to allocate geometry buffer!\n"); DPRINT("Failed to allocate geometry buffer!\n");
IoDeleteDevice(DiskDeviceObject); IoDeleteDevice(DiskDeviceObject);
@ -810,13 +810,15 @@ DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
case IOCTL_DISK_HISTOGRAM_RESET: case IOCTL_DISK_HISTOGRAM_RESET:
case IOCTL_DISK_REQUEST_STRUCTURE: case IOCTL_DISK_REQUEST_STRUCTURE:
case IOCTL_DISK_REQUEST_DATA: case IOCTL_DISK_REQUEST_DATA:
/* If we get here, something went wrong. inform the requestor */ /* If we get here, something went wrong. inform the requestor */
default:
DPRINT1("Unhandled control code: %lx\n", ControlCode); DPRINT1("Unhandled control code: %lx\n", ControlCode);
Status = STATUS_INVALID_DEVICE_REQUEST; Status = STATUS_INVALID_DEVICE_REQUEST;
Information = 0; Information = 0;
break; break;
default:
/* Call the common device control function */
return(ScsiClassDeviceControl(DeviceObject, Irp));
} }
Irp->IoStatus.Status = Status; Irp->IoStatus.Status = Status;

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -76,6 +76,17 @@ typedef struct _SCSI_INQUIRY_DATA
}SCSI_INQUIRY_DATA, *PSCSI_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 */ #endif /* __STORAGE_INCLUDE_NTDDSCSI_H */
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -705,7 +705,8 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
ULONG DataSize = 0; ULONG DataSize = 0;
DPRINT("ScsiPortDispatchScsi()\n"); DPRINT("ScsiPortDispatchScsi(DeviceObject %p Irp %p)\n",
DeviceObject, Irp);
DeviceExtension = DeviceObject->DeviceExtension; DeviceExtension = DeviceObject->DeviceExtension;
Stack = IoGetCurrentIrpStackLocation(Irp); Stack = IoGetCurrentIrpStackLocation(Irp);
@ -749,6 +750,7 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
DPRINT("Srb: %p\n", Srb); DPRINT("Srb: %p\n", Srb);
DPRINT("Srb->Function: %lu\n", Srb->Function); DPRINT("Srb->Function: %lu\n", Srb->Function);
DPRINT("PathId: %lu TargetId: %lu Lun: %lu\n", Srb->PathId, Srb->TargetId, Srb->Lun);
switch (Srb->Function) switch (Srb->Function)
{ {
@ -765,11 +767,17 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
PINQUIRYDATA InquiryData; PINQUIRYDATA InquiryData;
DPRINT(" SRB_FUNCTION_CLAIM_DEVICE\n"); 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) if (DeviceExtension->PortBusInfo != NULL)
{ {
AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)DeviceExtension->PortBusInfo; AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)DeviceExtension->PortBusInfo;
if (AdapterInfo->BusData[Srb->PathId].NumberOfLogicalUnits == 0)
break;
UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo + UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo +
AdapterInfo->BusData[Srb->PathId].InquiryDataOffset); AdapterInfo->BusData[Srb->PathId].InquiryDataOffset);
@ -783,6 +791,10 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
{ {
UnitInfo->DeviceClaimed = TRUE; UnitInfo->DeviceClaimed = TRUE;
DPRINT("Claimed device!\n"); DPRINT("Claimed device!\n");
/* FIXME: Hack!!!!! */
Srb->DataBuffer = DeviceObject;
break; break;
} }
@ -792,9 +804,6 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo + UnitInfo->NextInquiryDataOffset); UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo + UnitInfo->NextInquiryDataOffset);
} }
} }
/* FIXME: Hack!!!!! */
Srb->DataBuffer = DeviceObject;
} }
break; break;
@ -805,15 +814,18 @@ ScsiPortDispatchScsi(IN PDEVICE_OBJECT DeviceObject,
PINQUIRYDATA InquiryData; PINQUIRYDATA InquiryData;
DPRINT(" SRB_FUNCTION_RELEASE_DEVICE\n"); DPRINT(" SRB_FUNCTION_RELEASE_DEVICE\n");
DPRINT("PathId: %lu TargetId: %lu Lun: %lu\n", Srb->PathId, Srb->TargetId, Srb->Lun);
if (DeviceExtension->PortBusInfo != NULL) if (DeviceExtension->PortBusInfo != NULL)
{ {
AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)DeviceExtension->PortBusInfo; AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)DeviceExtension->PortBusInfo;
if (AdapterInfo->BusData[Srb->PathId].NumberOfLogicalUnits == 0)
break;
UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo + UnitInfo = (PSCSI_INQUIRY_DATA)((PUCHAR)AdapterInfo +
AdapterInfo->BusData[Srb->PathId].InquiryDataOffset); AdapterInfo->BusData[Srb->PathId].InquiryDataOffset);
while (AdapterInfo->BusData[Srb->PathId].InquiryDataOffset) while (AdapterInfo->BusData[Srb->PathId].InquiryDataOffset)
{ {
InquiryData = (PINQUIRYDATA)UnitInfo->InquiryData; InquiryData = (PINQUIRYDATA)UnitInfo->InquiryData;
@ -1235,9 +1247,12 @@ ScsiPortInquire(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
{ {
Srb.TargetId = Target; Srb.TargetId = Target;
Srb.Lun = 0; Srb.Lun = 0;
Srb.SrbStatus = SRB_STATUS_SUCCESS;
Result = DeviceExtension->HwStartIo(&DeviceExtension->MiniPortDeviceExtension, Result = DeviceExtension->HwStartIo(&DeviceExtension->MiniPortDeviceExtension,
&Srb); &Srb);
DPRINT("Result: %s Srb.SrbStatus %lx\n", (Result)?"True":"False", Srb.SrbStatus);
if (Result == TRUE && Srb.SrbStatus == SRB_STATUS_SUCCESS) if (Result == TRUE && Srb.SrbStatus == SRB_STATUS_SUCCESS)
{ {
UnitInfo->PathId = Bus; UnitInfo->PathId = Bus;
@ -1254,7 +1269,10 @@ ScsiPortInquire(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
UnitCount++; UnitCount++;
} }
} }
DPRINT("UnitCount: %lu\n", UnitCount);
AdapterInfo->BusData[Bus].NumberOfLogicalUnits = UnitCount; AdapterInfo->BusData[Bus].NumberOfLogicalUnits = UnitCount;
if (UnitCount == 0)
AdapterInfo->BusData[Bus].InquiryDataOffset = 0;
} }
DataSize = (ULONG)((PUCHAR)UnitInfo-(PUCHAR)AdapterInfo); DataSize = (ULONG)((PUCHAR)UnitInfo-(PUCHAR)AdapterInfo);