-/* $Id: ide.c,v 1.39 2001/03/27 21:43:43 dwelch Exp $
+/* $Id: ide.c,v 1.40 2001/04/30 05:28:17 rex Exp $
*
* IDE.C - IDE Disk driver
* written by Rex Jolliff
if (!IDEResetController(ControllerParams->CommandPortBase,
ControllerParams->ControlPortBase))
{
- DPRINT("Could not find controller %d at %04lx\n",
- ControllerIdx, ControllerParams->CommandPortBase);
- return FALSE;
+ DbgPrint ("Could not find controller %d at %04lx\n",
+ ControllerIdx,
+ ControllerParams->CommandPortBase);
+ return FALSE;
}
ControllerObject = IoCreateController(sizeof(IDE_CONTROLLER_EXTENSION));
if (ControllerObject == NULL)
{
- DPRINT("Could not create controller object for controller %d\n",
- ControllerIdx);
- return FALSE;
+ DbgPrint ("Could not create controller object for controller %d\n",
+ ControllerIdx);
+ return FALSE;
}
// Fill out Controller extension data
FALSE);
if (!NT_SUCCESS(RC))
{
- DPRINT("Could not Connect Interrupt %d\n", ControllerExtension->Vector);
- IoDeleteController(ControllerObject);
- return FALSE;
+ DbgPrint ("Could not Connect Interrupt %d\n",
+ ControllerExtension->Vector);
+ IoDeleteController (ControllerObject);
+ return FALSE;
}
// Create device objects for each raw device (and for partitions)
if (!CreatedDevices)
{
- DPRINT("Did not find any devices for controller %d\n", ControllerIdx);
- IoDisconnectInterrupt(ControllerExtension->Interrupt);
- IoDeleteController(ControllerObject);
+ DbgPrint ("Did not find any devices for controller %d\n",
+ ControllerIdx);
+ IoDisconnectInterrupt (ControllerExtension->Interrupt);
+ IoDeleteController (ControllerObject);
}
else
{
ULONG SectorCount = 0;
BOOLEAN ExtendedPart = FALSE;
ULONG PartitionOffset = 0;
+ ULONG offsetToNextPartition = 0;
// Copy I/O port offsets for convenience
CommandPort = ControllerExtension->CommandPortBase;
SectorCount);
if (!NT_SUCCESS(RC))
{
- DPRINT("IDECreateDevice call failed for raw device\n",0);
+ DbgPrint ("IDECreateDevice call failed for raw device\n", 0);
}
else
{
else
{
// build devices for all partitions in table
- DPRINT("Read partition on %wZ at %ld\n", &UnicodeDeviceDirName, PartitionOffset);
+ DPRINT("Read partition on %wZ at %ld\n",
+ &UnicodeDeviceDirName,
+ PartitionOffset);
for (PartitionIdx = 0; PartitionIdx < 4; PartitionIdx++)
{
// copy partition pointer for convenience
// if the partition entry is in use, create a device for it
if (IsRecognizedPartition(p->PartitionType))
{
- DPRINT("%wZ ptbl entry:%d type:%02x Start:%lu Size:%lu\n",
- &UnicodeDeviceDirName,
+ DPRINT("%wZ ptbl entry:%d type:%02x Start:%lu Size:%lu\n", &UnicodeDeviceDirName,
PartitionIdx,
p->PartitionType,
p->StartingBlock,
p->SectorCount);
if (!NT_SUCCESS(RC))
{
- DPRINT("IDECreateDevice call failed\n",0);
+ DbgPrint ("IDECreateDevice call failed\n", 0);
break;
}
PartitionNum++;
else if (IsExtendedPartition(p->PartitionType))
{
// Create devices for logical partitions within an extended partition
- DPRINT("%wZ ptbl entry:%d type:%02x Start:%lu Size:%lu\n",
- &UnicodeDeviceDirName,
+ DPRINT("Extended found: entry:%d type:%02x Start:%lu Size:%lu\n", &UnicodeDeviceDirName,
PartitionIdx,
p->PartitionType,
p->StartingBlock,
p->SectorCount);
ExtendedPart = TRUE;
- //TODO: If it is possible for partitions to appear after chain, this code is wrong.
- PartitionOffset += p->StartingBlock;
- break;
+ offsetToNextPartition = p->StartingBlock;
}
}
+ PartitionOffset += offsetToNextPartition;
}
}
while (ExtendedPart == TRUE);
SectorBuf);
if (RC != 0)
{
- DPRINT("read failed: port %04x drive %d sector %d rc %d\n",
- CommandPort,
- DriveNum,
- Offset,
- RC);
+ DbgPrint ("read failed: port %04x drive %d sector %d rc %d\n",
+ CommandPort,
+ DriveNum,
+ Offset,
+ RC);
return FALSE;
}
else if (*((WORD *)(SectorBuf + PART_MAGIC_OFFSET)) != PARTITION_MAGIC)
{
- DPRINT("Bad partition magic: port %04x drive %d offset %d magic %d\n",
- CommandPort,
- DriveNum,
- Offset,
- *((short *)(SectorBuf + PART_MAGIC_OFFSET)));
+ DbgPrint ("Bad partition magic: port %04x drive %d offset %d magic %d\n",
+ CommandPort,
+ DriveNum,
+ Offset,
+ *((short *)(SectorBuf + PART_MAGIC_OFFSET)));
return FALSE;
}
RtlCopyMemory(PartitionTable, SectorBuf + PARTITION_OFFSET, sizeof(PARTITION) * 4);
&DeviceName, FILE_DEVICE_DISK, 0, TRUE, DeviceObject);
if (!NT_SUCCESS(RC))
{
- DPRINT("IoCreateDevice call failed\n",0);
- return RC;
+ DbgPrint ("IoCreateDevice call failed\n");
+ return RC;
}
// Set the buffering strategy here...
&DeviceName);
if (!NT_SUCCESS(RC))
{
- DPRINT("IoAssignArcName (%wZ) failed (Status %x)\n",
- &ArcName, RC);
+ DbgPrint ("IoAssignArcName (%wZ) failed (Status %x)\n", &ArcName, RC);
}
-
return RC;
}
if ((AdjustedExtent.QuadPart > PartitionExtent.QuadPart) ||
(IrpStack->Parameters.Read.Length & (DeviceExtension->BytesPerSector - 1)))
{
- DPRINT("Request failed on bad parameters\n",0);
- DPRINT("AdjustedExtent=%d:%d PartitionExtent=%d:%d ReadLength=%d\n",
- (unsigned int) AdjustedExtent.u.HighPart,
- (unsigned int) AdjustedExtent.u.LowPart,
- (unsigned int) PartitionExtent.u.HighPart,
- (unsigned int) PartitionExtent.u.LowPart,
- IrpStack->Parameters.Read.Length);
+ DbgPrint ("Request failed on bad parameters\n");
+ DbgPrint ("AdjustedExtent=%d:%d PartitionExtent=%d:%d ReadLength=%d\n",
+ (unsigned int) AdjustedExtent.u.HighPart,
+ (unsigned int) AdjustedExtent.u.LowPart,
+ (unsigned int) PartitionExtent.u.HighPart,
+ (unsigned int) PartitionExtent.u.LowPart,
+ IrpStack->Parameters.Read.Length);
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_INVALID_PARAMETER;
DPRINT ("Drive is BUSY for too long\n");
if (++ControllerExtension->Retries > IDE_MAX_CMD_RETRIES)
{
- DPRINT ("Max Retries on Drive reset reached, returning failure\n");
+ DbgPrint ("Max Retries on Drive reset reached, returning failure\n");
Irp = ControllerExtension->CurrentIrp;
Irp->IoStatus.Status = STATUS_DISK_OPERATION_FAILED;
Irp->IoStatus.Information = 0;
DPRINT ("Drive is BUSY for too long after drive select\n");
if (ControllerExtension->Retries++ > IDE_MAX_CMD_RETRIES)
{
- DPRINT ("Max Retries on Drive reset reached, returning failure\n");
+ DbgPrint ("Max Retries on Drive reset reached, returning failure\n");
Irp = ControllerExtension->CurrentIrp;
Irp->IoStatus.Status = STATUS_DISK_OPERATION_FAILED;
Irp->IoStatus.Information = 0;
SectorCount = IDEReadSectorCount(ControllerExtension->CommandPortBase);
SectorNum = IDEReadSectorNum(ControllerExtension->CommandPortBase);
// FIXME: should use the NT error logging facility
- DPRINT("IDE Error: OP:%02x STAT:%02x ERR:%02x CYLLO:%02x CYLHI:%02x SCNT:%02x SNUM:%02x\n",
- DeviceExtension->Operation,
- ControllerExtension->DeviceStatus,
- ErrorReg,
- CylinderLow,
- CylinderHigh,
- SectorCount,
- SectorNum);
+ DbgPrint ("IDE Error: OP:%02x STAT:%02x ERR:%02x CYLLO:%02x CYLHI:%02x SCNT:%02x SNUM:%02x\n",
+ DeviceExtension->Operation,
+ ControllerExtension->DeviceStatus,
+ ErrorReg,
+ CylinderLow,
+ CylinderHigh,
+ SectorCount,
+ SectorNum);
// FIXME: should retry the command and perhaps recalibrate the drive
DPRINT("Timeout waiting for command completion\n");
if (++ControllerExtension->Retries > IDE_MAX_CMD_RETRIES)
{
- DPRINT("Max retries has been reached, IRP finished with error\n");
if (ControllerExtension->CurrentIrp != NULL)
{
+ DbgPrint ("Max retries has been reached, IRP finished with error\n");
ControllerExtension->CurrentIrp->IoStatus.Status = STATUS_IO_TIMEOUT;
ControllerExtension->CurrentIrp->IoStatus.Information = 0;
IDEFinishOperation(ControllerExtension);
case IDETimerResetWaitForBusyNegate:
case IDETimerResetWaitForDrdyAssert:
- DPRINT("Timeout waiting for drive reset, giving up on IRP\n");
if (ControllerExtension->CurrentIrp != NULL)
{
+ DbgPrint ("Timeout waiting for drive reset, giving up on IRP\n");
ControllerExtension->CurrentIrp->IoStatus.Status =
STATUS_IO_TIMEOUT;
ControllerExtension->CurrentIrp->IoStatus.Information = 0;