VOID
HalpCalculateChsValues(
IN PLARGE_INTEGER PartitionOffset,
IN PLARGE_INTEGER PartitionLength,
IN CCHAR ShiftCount,
IN ULONG SectorsPerTrack,
IN ULONG NumberOfTracks,
IN ULONG ConventionalCylinders,
OUT PPARTITION_DESCRIPTOR PartitionDescriptor
);
Routine Description:
This routine will determine the cylinder, head, and sector (CHS) values
that should be placed in a partition table entry, given the partition's
location on the disk and its size. The values calculated are packed into
int13 format -- the high two bits of the sector byte contain bits 8 and 9
of the 10 bit cylinder value, the low 6 bits of the sector byte contain
the 6 bit sector value; the cylinder byte contains the low 8 bits
of the cylinder value; and the head byte contains the 8-bit head value.
Both the start and end CHS values are calculated.
Arguments:
PartitionOffset - Byte offset of the partition, relative to the entire
physical disk.
PartitionLength - Size in bytes of the partition.
ShiftCount - Shift count to convert from byte counts to sector counts.
SectorsPerTrack - Number of sectors in a track on the media on which
the partition resides.
NumberOfTracks - Number of tracks in a cylinder on the media on which
the partition resides.
ConventionalCylinders - The "normalized" disk cylinders. We will never
set the cylinders greater than this.
PartitionDescriptor - Structure to be filled in with the start and
end CHS values. Other fields in the structure are not referenced
or modified.
Return Value:
None.
Note:
The Cylinder and Head values are 0-based but the Sector value is 1-based.
If the start or end cylinder overflows 10 bits (ie, > 1023), CHS values
will be set to all 1's.
No checking is done on the SectorsPerTrack and NumberOfTrack values.