mirror of
https://github.com/reactos/reactos.git
synced 2024-09-11 05:12:43 +00:00
Fixed disk size and partition limits
svn path=/trunk/; revision=1312
This commit is contained in:
parent
e7dc6b7c4b
commit
c27ed38f21
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: ide.c,v 1.31 2000/08/21 00:15:53 ekohl Exp $
|
/* $Id: ide.c,v 1.32 2000/08/22 21:09:25 ekohl Exp $
|
||||||
*
|
*
|
||||||
* IDE.C - IDE Disk driver
|
* IDE.C - IDE Disk driver
|
||||||
* written by Rex Jolliff
|
* written by Rex Jolliff
|
||||||
|
@ -460,7 +460,7 @@ IDEResetController(IN WORD CommandPort,
|
||||||
// FALSE no devices were created for this device
|
// FALSE no devices were created for this device
|
||||||
//
|
//
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PCONTROLLER_OBJECT ControllerObject,
|
IN PCONTROLLER_OBJECT ControllerObject,
|
||||||
IN PIDE_CONTROLLER_EXTENSION ControllerExtension,
|
IN PIDE_CONTROLLER_EXTENSION ControllerExtension,
|
||||||
|
@ -470,36 +470,35 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
BOOLEAN CreatedDevices;
|
BOOLEAN CreatedDevices;
|
||||||
char RawDeviceName[IDE_MAX_NAME_LENGTH];
|
char RawDeviceName[IDE_MAX_NAME_LENGTH];
|
||||||
char PrimaryDeviceName[IDE_MAX_NAME_LENGTH];
|
char PrimaryDeviceName[IDE_MAX_NAME_LENGTH];
|
||||||
char LogicalDeviceName[IDE_MAX_NAME_LENGTH];
|
|
||||||
int CommandPort, PartitionIdx, PartitionNum;
|
int CommandPort, PartitionIdx, PartitionNum;
|
||||||
int ExtPartitionIdx, ExtOffset;
|
|
||||||
NTSTATUS RC;
|
NTSTATUS RC;
|
||||||
IDE_DRIVE_IDENTIFY DrvParms;
|
IDE_DRIVE_IDENTIFY DrvParms;
|
||||||
PDEVICE_OBJECT RawDeviceObject;
|
PDEVICE_OBJECT RawDeviceObject;
|
||||||
PDEVICE_OBJECT PrimaryDeviceObject;
|
PDEVICE_OBJECT PrimaryDeviceObject;
|
||||||
PDEVICE_OBJECT LogicalDeviceObject;
|
|
||||||
PIDE_DEVICE_EXTENSION RawDeviceExtension;
|
PIDE_DEVICE_EXTENSION RawDeviceExtension;
|
||||||
PARTITION PrimaryPartitionTable[4], *p;
|
PARTITION PartitionTable[4], *p;
|
||||||
PARTITION ExtendedPartitionTable[4], *ep;
|
|
||||||
char DeviceDirName[IDE_MAX_NAME_LENGTH + 1];
|
char DeviceDirName[IDE_MAX_NAME_LENGTH + 1];
|
||||||
ANSI_STRING AnsiDeviceDirName;
|
ANSI_STRING AnsiDeviceDirName;
|
||||||
UNICODE_STRING UnicodeDeviceDirName;
|
UNICODE_STRING UnicodeDeviceDirName;
|
||||||
OBJECT_ATTRIBUTES DeviceDirAttributes;
|
OBJECT_ATTRIBUTES DeviceDirAttributes;
|
||||||
HANDLE Handle;
|
HANDLE Handle;
|
||||||
|
ULONG SectorCount = 0;
|
||||||
|
BOOLEAN ExtendedPart = FALSE;
|
||||||
|
ULONG PartitionOffset = 0;
|
||||||
|
|
||||||
// Copy I/O port offsets for convenience
|
// Copy I/O port offsets for convenience
|
||||||
CommandPort = ControllerExtension->CommandPortBase;
|
CommandPort = ControllerExtension->CommandPortBase;
|
||||||
// ControlPort = ControllerExtension->ControlPortBase;
|
// ControlPort = ControllerExtension->ControlPortBase;
|
||||||
DPRINT("probing IDE controller %d Addr %04lx Drive %d\n",
|
DPRINT("probing IDE controller %d Addr %04lx Drive %d\n",
|
||||||
ControllerExtension->Number,
|
ControllerExtension->Number,
|
||||||
CommandPort,
|
CommandPort,
|
||||||
DriveIdx);
|
DriveIdx);
|
||||||
|
|
||||||
// Get the Drive Identification Data
|
// Get the Drive Identification Data
|
||||||
if (!IDEGetDriveIdentification(CommandPort, DriveIdx, &DrvParms))
|
if (!IDEGetDriveIdentification(CommandPort, DriveIdx, &DrvParms))
|
||||||
{
|
{
|
||||||
DPRINT("Giving up on drive %d on controller %d...\n",
|
DPRINT("Giving up on drive %d on controller %d...\n",
|
||||||
DriveIdx,
|
DriveIdx,
|
||||||
ControllerExtension->Number);
|
ControllerExtension->Number);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -512,8 +511,8 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
DeviceDirName[strlen(DeviceDirName) + 1] = '\0';
|
DeviceDirName[strlen(DeviceDirName) + 1] = '\0';
|
||||||
DeviceDirName[strlen(DeviceDirName)] = '0' + HarddiskIdx;
|
DeviceDirName[strlen(DeviceDirName)] = '0' + HarddiskIdx;
|
||||||
RtlInitAnsiString(&AnsiDeviceDirName, DeviceDirName);
|
RtlInitAnsiString(&AnsiDeviceDirName, DeviceDirName);
|
||||||
RC = RtlAnsiStringToUnicodeString(&UnicodeDeviceDirName,
|
RC = RtlAnsiStringToUnicodeString(&UnicodeDeviceDirName,
|
||||||
&AnsiDeviceDirName,
|
&AnsiDeviceDirName,
|
||||||
TRUE);
|
TRUE);
|
||||||
if (!NT_SUCCESS(RC))
|
if (!NT_SUCCESS(RC))
|
||||||
{
|
{
|
||||||
|
@ -541,30 +540,42 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
strcat(RawDeviceName, IDE_NT_PARTITION_NAME);
|
strcat(RawDeviceName, IDE_NT_PARTITION_NAME);
|
||||||
RawDeviceName[strlen(RawDeviceName) + 1] = '\0';
|
RawDeviceName[strlen(RawDeviceName) + 1] = '\0';
|
||||||
RawDeviceName[strlen(RawDeviceName)] = '0';
|
RawDeviceName[strlen(RawDeviceName)] = '0';
|
||||||
RC = IDECreateDevice(DriverObject,
|
|
||||||
RawDeviceName,
|
if (DrvParms.Capabilities & IDE_DRID_LBA_SUPPORTED)
|
||||||
&RawDeviceObject,
|
{
|
||||||
ControllerObject,
|
SectorCount =
|
||||||
|
(ULONG)((DrvParms.TMSectorCountHi << 16) + DrvParms.TMSectorCountLo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SectorCount =
|
||||||
|
(ULONG)(DrvParms.LogicalCyls * DrvParms.LogicalHeads * DrvParms.SectorsPerTrack);
|
||||||
|
}
|
||||||
|
|
||||||
|
RC = IDECreateDevice(DriverObject,
|
||||||
|
RawDeviceName,
|
||||||
|
&RawDeviceObject,
|
||||||
|
ControllerObject,
|
||||||
DriveIdx,
|
DriveIdx,
|
||||||
&DrvParms,
|
&DrvParms,
|
||||||
0,
|
0,
|
||||||
DrvParms.LogicalCyls * DrvParms.LogicalHeads * DrvParms.SectorsPerTrack);
|
SectorCount);
|
||||||
if (!NT_SUCCESS(RC))
|
if (!NT_SUCCESS(RC))
|
||||||
{
|
{
|
||||||
DPRINT("IDECreateDevice call failed for raw device\n",0);
|
DPRINT("IDECreateDevice call failed for raw device\n",0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Increase number of available raw disk drives
|
// Increase number of available raw disk drives
|
||||||
IoGetConfigurationInformation()->DiskCount++;
|
IoGetConfigurationInformation()->DiskCount++;
|
||||||
|
|
||||||
CreatedDevices = TRUE;
|
CreatedDevices = TRUE;
|
||||||
RawDeviceExtension = (PIDE_DEVICE_EXTENSION)
|
RawDeviceExtension = (PIDE_DEVICE_EXTENSION)
|
||||||
RawDeviceObject->DeviceExtension;
|
RawDeviceObject->DeviceExtension;
|
||||||
|
|
||||||
// Initialze the controller timer here (since it has to be
|
// Initialze the controller timer here (since it has to be
|
||||||
// tied to a device)...
|
// tied to a device)...
|
||||||
if (DriveIdx == 0)
|
if (DriveIdx == 0)
|
||||||
{
|
{
|
||||||
ControllerExtension->TimerState = IDETimerIdle;
|
ControllerExtension->TimerState = IDETimerIdle;
|
||||||
ControllerExtension->TimerCount = 0;
|
ControllerExtension->TimerCount = 0;
|
||||||
|
@ -573,115 +584,80 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Main partition table for device
|
// read the partition table (chain)
|
||||||
|
PartitionOffset = 0;
|
||||||
PartitionNum = 1;
|
PartitionNum = 1;
|
||||||
if (!IDEGetPartitionTable(CommandPort, DriveIdx, 0, &DrvParms, PrimaryPartitionTable))
|
|
||||||
{
|
|
||||||
DPRINT("drive %d controller %d: Could not get primary partition table\n",
|
|
||||||
DriveIdx,
|
|
||||||
ControllerExtension->Number);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
// build devices for all partitions in table
|
do
|
||||||
DPRINT("partitions on %s:\n", DeviceDirName);
|
{
|
||||||
for (PartitionIdx = 0; PartitionIdx < 4; PartitionIdx++)
|
ExtendedPart = FALSE;
|
||||||
|
|
||||||
|
// Get Main partition table for device
|
||||||
|
if (!IDEGetPartitionTable(CommandPort, DriveIdx, PartitionOffset, &DrvParms, PartitionTable))
|
||||||
{
|
{
|
||||||
|
DPRINT("drive %d controller %d offset %lu: Could not get primary partition table\n",
|
||||||
// copy partition pointer for convenience
|
DriveIdx,
|
||||||
p = &PrimaryPartitionTable[PartitionIdx];
|
ControllerExtension->Number,
|
||||||
|
PartitionOffset);
|
||||||
// if the partition entry is in use, create a device for it
|
}
|
||||||
if (IsRecognizedPartition(p->PartitionType))
|
else
|
||||||
|
{
|
||||||
|
// build devices for all partitions in table
|
||||||
|
DPRINT("partitions on %s:\n", DeviceDirName);
|
||||||
|
for (PartitionIdx = 0; PartitionIdx < 4; PartitionIdx++)
|
||||||
{
|
{
|
||||||
DPRINT("%s ptbl entry:%d type:%02x Offset:%d Size:%d\n",
|
// copy partition pointer for convenience
|
||||||
DeviceDirName,
|
p = &PartitionTable[PartitionIdx];
|
||||||
PartitionIdx,
|
|
||||||
p->PartitionType,
|
|
||||||
p->StartingBlock,
|
|
||||||
p->SectorCount);
|
|
||||||
|
|
||||||
// Create Device for partition
|
// if the partition entry is in use, create a device for it
|
||||||
strcpy(PrimaryDeviceName, IDE_NT_ROOTDIR_NAME);
|
if (IsRecognizedPartition(p->PartitionType))
|
||||||
strcat(PrimaryDeviceName, IDE_NT_DEVICE_NAME);
|
|
||||||
PrimaryDeviceName[strlen(PrimaryDeviceName) + 1] = '\0';
|
|
||||||
PrimaryDeviceName[strlen(PrimaryDeviceName)] = '0' + HarddiskIdx;
|
|
||||||
strcat(PrimaryDeviceName, IDE_NT_PARTITION_NAME);
|
|
||||||
PrimaryDeviceName[strlen(PrimaryDeviceName) + 1] = '\0';
|
|
||||||
PrimaryDeviceName[strlen(PrimaryDeviceName)] = '0' + PartitionNum++;
|
|
||||||
TotalPartitions++;
|
|
||||||
RC = IDECreateDevice(DriverObject,
|
|
||||||
PrimaryDeviceName,
|
|
||||||
&PrimaryDeviceObject,
|
|
||||||
ControllerObject,
|
|
||||||
DriveIdx,
|
|
||||||
&DrvParms,
|
|
||||||
p->StartingBlock,
|
|
||||||
p->SectorCount);
|
|
||||||
if (!NT_SUCCESS(RC))
|
|
||||||
{
|
{
|
||||||
DPRINT("IDECreateDevice call failed\n",0);
|
DPRINT("%s ptbl entry:%d type:%02x Start:%lu Size:%lu\n",
|
||||||
break;
|
DeviceDirName,
|
||||||
}
|
PartitionIdx,
|
||||||
|
p->PartitionType,
|
||||||
|
p->StartingBlock,
|
||||||
|
p->SectorCount);
|
||||||
|
|
||||||
// Create devices for logical partitions within an extended partition
|
// Create Device for partition
|
||||||
}
|
strcpy(PrimaryDeviceName, IDE_NT_ROOTDIR_NAME);
|
||||||
else if (IsExtendedPartition(p->PartitionType))
|
strcat(PrimaryDeviceName, IDE_NT_DEVICE_NAME);
|
||||||
{
|
PrimaryDeviceName[strlen(PrimaryDeviceName) + 1] = '\0';
|
||||||
ExtOffset = p->StartingBlock;
|
PrimaryDeviceName[strlen(PrimaryDeviceName)] = '0' + HarddiskIdx;
|
||||||
|
strcat(PrimaryDeviceName, IDE_NT_PARTITION_NAME);
|
||||||
// Get the Extended partition table
|
PrimaryDeviceName[strlen(PrimaryDeviceName) + 1] = '\0';
|
||||||
if (!IDEGetPartitionTable(CommandPort,
|
PrimaryDeviceName[strlen(PrimaryDeviceName)] = '0' + PartitionNum++;
|
||||||
DriveIdx,
|
TotalPartitions++;
|
||||||
ExtOffset,
|
RC = IDECreateDevice(DriverObject,
|
||||||
&DrvParms,
|
PrimaryDeviceName,
|
||||||
ExtendedPartitionTable))
|
&PrimaryDeviceObject,
|
||||||
{
|
ControllerObject,
|
||||||
DPRINT("Harddisk%d: could not get extended partition table at offset %d",
|
DriveIdx,
|
||||||
HarddiskIdx, ExtOffset);
|
&DrvParms,
|
||||||
}
|
p->StartingBlock + PartitionOffset,
|
||||||
else
|
p->SectorCount);
|
||||||
{
|
if (!NT_SUCCESS(RC))
|
||||||
for (ExtPartitionIdx = 0; ExtPartitionIdx < 4; ExtPartitionIdx++)
|
|
||||||
{
|
{
|
||||||
ep = &ExtendedPartitionTable[ExtPartitionIdx];
|
DPRINT("IDECreateDevice call failed\n",0);
|
||||||
if (IsRecognizedPartition(ep->PartitionType))
|
break;
|
||||||
{
|
|
||||||
DPRINT("Harddisk%d: Type:%02x Offset:%d Size:%d\n",
|
|
||||||
HarddiskIdx,
|
|
||||||
ep->PartitionType,
|
|
||||||
ep->StartingBlock + ExtOffset,
|
|
||||||
ep->SectorCount);
|
|
||||||
|
|
||||||
// Create device for logical partition
|
|
||||||
strcpy(LogicalDeviceName, IDE_NT_ROOTDIR_NAME);
|
|
||||||
strcat(LogicalDeviceName, IDE_NT_DEVICE_NAME);
|
|
||||||
LogicalDeviceName[strlen(LogicalDeviceName) + 1] = '\0';
|
|
||||||
LogicalDeviceName[strlen(LogicalDeviceName)] = '0' + HarddiskIdx;
|
|
||||||
strcat(LogicalDeviceName, IDE_NT_PARTITION_NAME);
|
|
||||||
LogicalDeviceName[strlen(LogicalDeviceName) + 1] = '\0';
|
|
||||||
LogicalDeviceName[strlen(LogicalDeviceName)] = '0' + PartitionNum++;
|
|
||||||
TotalPartitions++;
|
|
||||||
RC = IDECreateDevice(DriverObject,
|
|
||||||
LogicalDeviceName,
|
|
||||||
&LogicalDeviceObject,
|
|
||||||
ControllerObject,
|
|
||||||
DriveIdx,
|
|
||||||
&DrvParms,
|
|
||||||
ep->StartingBlock + ExtOffset,
|
|
||||||
ep->SectorCount);
|
|
||||||
if (!NT_SUCCESS(RC))
|
|
||||||
{
|
|
||||||
DPRINT("IDECreateDevice call failed\n",0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
PartitionOffset += (p->StartingBlock + p->SectorCount);
|
||||||
|
}
|
||||||
|
else if (IsExtendedPartition(p->PartitionType))
|
||||||
|
{
|
||||||
|
// Create devices for logical partitions within an extended partition
|
||||||
|
DPRINT("%s ptbl entry:%d type:%02x Start:%lu Size:%lu\n",
|
||||||
|
DeviceDirName,
|
||||||
|
PartitionIdx,
|
||||||
|
p->PartitionType,
|
||||||
|
p->StartingBlock,
|
||||||
|
p->SectorCount);
|
||||||
|
ExtendedPart = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (ExtendedPart == TRUE);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -743,11 +719,15 @@ IDEGetDriveIdentification(IN int CommandPort,
|
||||||
(DrvParms->Capabilities & IDE_DRID_DMA_SUPPORTED) ? 1 : 0,
|
(DrvParms->Capabilities & IDE_DRID_DMA_SUPPORTED) ? 1 : 0,
|
||||||
DrvParms->MinPIOTransTime,
|
DrvParms->MinPIOTransTime,
|
||||||
DrvParms->MinDMATransTime);
|
DrvParms->MinDMATransTime);
|
||||||
DPRINT("TM:Cyls:%d Heads:%d Sectors/Trk:%d Capacity:%d\n",
|
DPRINT("TM:Cyls:%d Heads:%d Sectors/Trk:%d Capacity:%ld\n",
|
||||||
DrvParms->TMCylinders,
|
DrvParms->TMCylinders,
|
||||||
DrvParms->TMHeads,
|
DrvParms->TMHeads,
|
||||||
DrvParms->TMSectorsPerTrk,
|
DrvParms->TMSectorsPerTrk,
|
||||||
DrvParms->TMCapacity);
|
(ULONG)(DrvParms->TMCapacityLo + (DrvParms->TMCapacityHi << 16)));
|
||||||
|
DPRINT("TM:SectorCount: 0x%04x%04x = %lu\n",
|
||||||
|
DrvParms->TMSectorCountHi,
|
||||||
|
DrvParms->TMSectorCountLo,
|
||||||
|
(ULONG)((DrvParms->TMSectorCountHi << 16) + DrvParms->TMSectorCountLo));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,8 +221,12 @@ typedef struct _IDE_DRIVE_IDENTIFY {
|
||||||
WORD TMCylinders; /*54*/
|
WORD TMCylinders; /*54*/
|
||||||
WORD TMHeads; /*55*/
|
WORD TMHeads; /*55*/
|
||||||
WORD TMSectorsPerTrk; /*56*/
|
WORD TMSectorsPerTrk; /*56*/
|
||||||
WORD TMCapacity; /*57*/
|
WORD TMCapacityLo; /*57*/
|
||||||
WORD Reserved53[198]; /*58*/
|
WORD TMCapacityHi; /*58*/
|
||||||
|
WORD Reserved59; /*59*/
|
||||||
|
WORD TMSectorCountLo; /*60*/
|
||||||
|
WORD TMSectorCountHi; /*61*/
|
||||||
|
WORD Reserved62[194]; /*62*/
|
||||||
} IDE_DRIVE_IDENTIFY, *PIDE_DRIVE_IDENTIFY;
|
} IDE_DRIVE_IDENTIFY, *PIDE_DRIVE_IDENTIFY;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue