mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
BUGFIX: Primary partitions that appeared after extended in table were incorrectly mounted
changed some error messages from DPRINT to DbgPrint svn path=/trunk/; revision=1841
This commit is contained in:
parent
7e0bfac662
commit
fdfb9053d9
1 changed files with 58 additions and 57 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $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
|
* IDE.C - IDE Disk driver
|
||||||
* written by Rex Jolliff
|
* written by Rex Jolliff
|
||||||
|
@ -300,15 +300,16 @@ IDECreateController(IN PDRIVER_OBJECT DriverObject,
|
||||||
if (!IDEResetController(ControllerParams->CommandPortBase,
|
if (!IDEResetController(ControllerParams->CommandPortBase,
|
||||||
ControllerParams->ControlPortBase))
|
ControllerParams->ControlPortBase))
|
||||||
{
|
{
|
||||||
DPRINT("Could not find controller %d at %04lx\n",
|
DbgPrint ("Could not find controller %d at %04lx\n",
|
||||||
ControllerIdx, ControllerParams->CommandPortBase);
|
ControllerIdx,
|
||||||
|
ControllerParams->CommandPortBase);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerObject = IoCreateController(sizeof(IDE_CONTROLLER_EXTENSION));
|
ControllerObject = IoCreateController(sizeof(IDE_CONTROLLER_EXTENSION));
|
||||||
if (ControllerObject == NULL)
|
if (ControllerObject == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("Could not create controller object for controller %d\n",
|
DbgPrint ("Could not create controller object for controller %d\n",
|
||||||
ControllerIdx);
|
ControllerIdx);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +342,8 @@ IDECreateController(IN PDRIVER_OBJECT DriverObject,
|
||||||
FALSE);
|
FALSE);
|
||||||
if (!NT_SUCCESS(RC))
|
if (!NT_SUCCESS(RC))
|
||||||
{
|
{
|
||||||
DPRINT("Could not Connect Interrupt %d\n", ControllerExtension->Vector);
|
DbgPrint ("Could not Connect Interrupt %d\n",
|
||||||
|
ControllerExtension->Vector);
|
||||||
IoDeleteController (ControllerObject);
|
IoDeleteController (ControllerObject);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +365,8 @@ IDECreateController(IN PDRIVER_OBJECT DriverObject,
|
||||||
|
|
||||||
if (!CreatedDevices)
|
if (!CreatedDevices)
|
||||||
{
|
{
|
||||||
DPRINT("Did not find any devices for controller %d\n", ControllerIdx);
|
DbgPrint ("Did not find any devices for controller %d\n",
|
||||||
|
ControllerIdx);
|
||||||
IoDisconnectInterrupt (ControllerExtension->Interrupt);
|
IoDisconnectInterrupt (ControllerExtension->Interrupt);
|
||||||
IoDeleteController (ControllerObject);
|
IoDeleteController (ControllerObject);
|
||||||
}
|
}
|
||||||
|
@ -488,6 +491,7 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
ULONG SectorCount = 0;
|
ULONG SectorCount = 0;
|
||||||
BOOLEAN ExtendedPart = FALSE;
|
BOOLEAN ExtendedPart = FALSE;
|
||||||
ULONG PartitionOffset = 0;
|
ULONG PartitionOffset = 0;
|
||||||
|
ULONG offsetToNextPartition = 0;
|
||||||
|
|
||||||
// Copy I/O port offsets for convenience
|
// Copy I/O port offsets for convenience
|
||||||
CommandPort = ControllerExtension->CommandPortBase;
|
CommandPort = ControllerExtension->CommandPortBase;
|
||||||
|
@ -549,7 +553,7 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
SectorCount);
|
SectorCount);
|
||||||
if (!NT_SUCCESS(RC))
|
if (!NT_SUCCESS(RC))
|
||||||
{
|
{
|
||||||
DPRINT("IDECreateDevice call failed for raw device\n",0);
|
DbgPrint ("IDECreateDevice call failed for raw device\n", 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -590,7 +594,9 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// build devices for all partitions in table
|
// 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++)
|
for (PartitionIdx = 0; PartitionIdx < 4; PartitionIdx++)
|
||||||
{
|
{
|
||||||
// copy partition pointer for convenience
|
// copy partition pointer for convenience
|
||||||
|
@ -599,8 +605,7 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
// if the partition entry is in use, create a device for it
|
// if the partition entry is in use, create a device for it
|
||||||
if (IsRecognizedPartition(p->PartitionType))
|
if (IsRecognizedPartition(p->PartitionType))
|
||||||
{
|
{
|
||||||
DPRINT("%wZ ptbl entry:%d type:%02x Start:%lu Size:%lu\n",
|
DPRINT("%wZ ptbl entry:%d type:%02x Start:%lu Size:%lu\n", &UnicodeDeviceDirName,
|
||||||
&UnicodeDeviceDirName,
|
|
||||||
PartitionIdx,
|
PartitionIdx,
|
||||||
p->PartitionType,
|
p->PartitionType,
|
||||||
p->StartingBlock,
|
p->StartingBlock,
|
||||||
|
@ -619,7 +624,7 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
p->SectorCount);
|
p->SectorCount);
|
||||||
if (!NT_SUCCESS(RC))
|
if (!NT_SUCCESS(RC))
|
||||||
{
|
{
|
||||||
DPRINT("IDECreateDevice call failed\n",0);
|
DbgPrint ("IDECreateDevice call failed\n", 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PartitionNum++;
|
PartitionNum++;
|
||||||
|
@ -627,18 +632,16 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
else if (IsExtendedPartition(p->PartitionType))
|
else if (IsExtendedPartition(p->PartitionType))
|
||||||
{
|
{
|
||||||
// Create devices for logical partitions within an extended partition
|
// Create devices for logical partitions within an extended partition
|
||||||
DPRINT("%wZ ptbl entry:%d type:%02x Start:%lu Size:%lu\n",
|
DPRINT("Extended found: entry:%d type:%02x Start:%lu Size:%lu\n", &UnicodeDeviceDirName,
|
||||||
&UnicodeDeviceDirName,
|
|
||||||
PartitionIdx,
|
PartitionIdx,
|
||||||
p->PartitionType,
|
p->PartitionType,
|
||||||
p->StartingBlock,
|
p->StartingBlock,
|
||||||
p->SectorCount);
|
p->SectorCount);
|
||||||
ExtendedPart = TRUE;
|
ExtendedPart = TRUE;
|
||||||
//TODO: If it is possible for partitions to appear after chain, this code is wrong.
|
offsetToNextPartition = p->StartingBlock;
|
||||||
PartitionOffset += p->StartingBlock;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PartitionOffset += offsetToNextPartition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (ExtendedPart == TRUE);
|
while (ExtendedPart == TRUE);
|
||||||
|
@ -783,7 +786,7 @@ IDEGetPartitionTable(IN int CommandPort,
|
||||||
SectorBuf);
|
SectorBuf);
|
||||||
if (RC != 0)
|
if (RC != 0)
|
||||||
{
|
{
|
||||||
DPRINT("read failed: port %04x drive %d sector %d rc %d\n",
|
DbgPrint ("read failed: port %04x drive %d sector %d rc %d\n",
|
||||||
CommandPort,
|
CommandPort,
|
||||||
DriveNum,
|
DriveNum,
|
||||||
Offset,
|
Offset,
|
||||||
|
@ -792,7 +795,7 @@ IDEGetPartitionTable(IN int CommandPort,
|
||||||
}
|
}
|
||||||
else if (*((WORD *)(SectorBuf + PART_MAGIC_OFFSET)) != PARTITION_MAGIC)
|
else if (*((WORD *)(SectorBuf + PART_MAGIC_OFFSET)) != PARTITION_MAGIC)
|
||||||
{
|
{
|
||||||
DPRINT("Bad partition magic: port %04x drive %d offset %d magic %d\n",
|
DbgPrint ("Bad partition magic: port %04x drive %d offset %d magic %d\n",
|
||||||
CommandPort,
|
CommandPort,
|
||||||
DriveNum,
|
DriveNum,
|
||||||
Offset,
|
Offset,
|
||||||
|
@ -880,7 +883,7 @@ IDECreateDevice(IN PDRIVER_OBJECT DriverObject,
|
||||||
&DeviceName, FILE_DEVICE_DISK, 0, TRUE, DeviceObject);
|
&DeviceName, FILE_DEVICE_DISK, 0, TRUE, DeviceObject);
|
||||||
if (!NT_SUCCESS(RC))
|
if (!NT_SUCCESS(RC))
|
||||||
{
|
{
|
||||||
DPRINT("IoCreateDevice call failed\n",0);
|
DbgPrint ("IoCreateDevice call failed\n");
|
||||||
return RC;
|
return RC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -939,11 +942,9 @@ IDECreateDevice(IN PDRIVER_OBJECT DriverObject,
|
||||||
&DeviceName);
|
&DeviceName);
|
||||||
if (!NT_SUCCESS(RC))
|
if (!NT_SUCCESS(RC))
|
||||||
{
|
{
|
||||||
DPRINT("IoAssignArcName (%wZ) failed (Status %x)\n",
|
DbgPrint ("IoAssignArcName (%wZ) failed (Status %x)\n", &ArcName, RC);
|
||||||
&ArcName, RC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return RC;
|
return RC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1180,8 +1181,8 @@ DPRINT("AdjOffset:%ld:%ld + Length:%ld = AdjExtent:%ld:%ld\n",
|
||||||
if ((AdjustedExtent.QuadPart > PartitionExtent.QuadPart) ||
|
if ((AdjustedExtent.QuadPart > PartitionExtent.QuadPart) ||
|
||||||
(IrpStack->Parameters.Read.Length & (DeviceExtension->BytesPerSector - 1)))
|
(IrpStack->Parameters.Read.Length & (DeviceExtension->BytesPerSector - 1)))
|
||||||
{
|
{
|
||||||
DPRINT("Request failed on bad parameters\n",0);
|
DbgPrint ("Request failed on bad parameters\n");
|
||||||
DPRINT("AdjustedExtent=%d:%d PartitionExtent=%d:%d ReadLength=%d\n",
|
DbgPrint ("AdjustedExtent=%d:%d PartitionExtent=%d:%d ReadLength=%d\n",
|
||||||
(unsigned int) AdjustedExtent.u.HighPart,
|
(unsigned int) AdjustedExtent.u.HighPart,
|
||||||
(unsigned int) AdjustedExtent.u.LowPart,
|
(unsigned int) AdjustedExtent.u.LowPart,
|
||||||
(unsigned int) PartitionExtent.u.HighPart,
|
(unsigned int) PartitionExtent.u.HighPart,
|
||||||
|
@ -1470,7 +1471,7 @@ IDEStartController(IN OUT PVOID Context)
|
||||||
DPRINT ("Drive is BUSY for too long\n");
|
DPRINT ("Drive is BUSY for too long\n");
|
||||||
if (++ControllerExtension->Retries > IDE_MAX_CMD_RETRIES)
|
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 = ControllerExtension->CurrentIrp;
|
||||||
Irp->IoStatus.Status = STATUS_DISK_OPERATION_FAILED;
|
Irp->IoStatus.Status = STATUS_DISK_OPERATION_FAILED;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
|
@ -1505,7 +1506,7 @@ IDEStartController(IN OUT PVOID Context)
|
||||||
DPRINT ("Drive is BUSY for too long after drive select\n");
|
DPRINT ("Drive is BUSY for too long after drive select\n");
|
||||||
if (ControllerExtension->Retries++ > IDE_MAX_CMD_RETRIES)
|
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 = ControllerExtension->CurrentIrp;
|
||||||
Irp->IoStatus.Status = STATUS_DISK_OPERATION_FAILED;
|
Irp->IoStatus.Status = STATUS_DISK_OPERATION_FAILED;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
|
@ -1686,7 +1687,7 @@ IDEIsr(IN PKINTERRUPT Interrupt,
|
||||||
SectorCount = IDEReadSectorCount(ControllerExtension->CommandPortBase);
|
SectorCount = IDEReadSectorCount(ControllerExtension->CommandPortBase);
|
||||||
SectorNum = IDEReadSectorNum(ControllerExtension->CommandPortBase);
|
SectorNum = IDEReadSectorNum(ControllerExtension->CommandPortBase);
|
||||||
// FIXME: should use the NT error logging facility
|
// 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",
|
DbgPrint ("IDE Error: OP:%02x STAT:%02x ERR:%02x CYLLO:%02x CYLHI:%02x SCNT:%02x SNUM:%02x\n",
|
||||||
DeviceExtension->Operation,
|
DeviceExtension->Operation,
|
||||||
ControllerExtension->DeviceStatus,
|
ControllerExtension->DeviceStatus,
|
||||||
ErrorReg,
|
ErrorReg,
|
||||||
|
@ -2006,9 +2007,9 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
|
||||||
DPRINT("Timeout waiting for command completion\n");
|
DPRINT("Timeout waiting for command completion\n");
|
||||||
if (++ControllerExtension->Retries > IDE_MAX_CMD_RETRIES)
|
if (++ControllerExtension->Retries > IDE_MAX_CMD_RETRIES)
|
||||||
{
|
{
|
||||||
DPRINT("Max retries has been reached, IRP finished with error\n");
|
|
||||||
if (ControllerExtension->CurrentIrp != NULL)
|
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.Status = STATUS_IO_TIMEOUT;
|
||||||
ControllerExtension->CurrentIrp->IoStatus.Information = 0;
|
ControllerExtension->CurrentIrp->IoStatus.Information = 0;
|
||||||
IDEFinishOperation(ControllerExtension);
|
IDEFinishOperation(ControllerExtension);
|
||||||
|
@ -2024,9 +2025,9 @@ IDEIoTimer(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
case IDETimerResetWaitForBusyNegate:
|
case IDETimerResetWaitForBusyNegate:
|
||||||
case IDETimerResetWaitForDrdyAssert:
|
case IDETimerResetWaitForDrdyAssert:
|
||||||
DPRINT("Timeout waiting for drive reset, giving up on IRP\n");
|
|
||||||
if (ControllerExtension->CurrentIrp != NULL)
|
if (ControllerExtension->CurrentIrp != NULL)
|
||||||
{
|
{
|
||||||
|
DbgPrint ("Timeout waiting for drive reset, giving up on IRP\n");
|
||||||
ControllerExtension->CurrentIrp->IoStatus.Status =
|
ControllerExtension->CurrentIrp->IoStatus.Status =
|
||||||
STATUS_IO_TIMEOUT;
|
STATUS_IO_TIMEOUT;
|
||||||
ControllerExtension->CurrentIrp->IoStatus.Information = 0;
|
ControllerExtension->CurrentIrp->IoStatus.Information = 0;
|
||||||
|
|
Loading…
Reference in a new issue