// FUNCTIONS
/////////////////////////////////////////////////////////////////////////////////////////////
-static BOOLEAN PcDiskResetController(ULONG DriveNumber)
+static BOOLEAN PcDiskResetController(UCHAR DriveNumber)
{
REGS RegsIn;
REGS RegsOut;
return INT386_SUCCESS(RegsOut);
}
-static BOOLEAN PcDiskReadLogicalSectorsLBA(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
+static BOOLEAN PcDiskReadLogicalSectorsLBA(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
REGS RegsIn;
REGS RegsOut;
PI386_DISK_ADDRESS_PACKET Packet = (PI386_DISK_ADDRESS_PACKET)(BIOSCALLBUFFER);
DPRINTM(DPRINT_DISK, "PcDiskReadLogicalSectorsLBA() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer);
+ ASSERT(((ULONG_PTR)Buffer) <= 0xFFFFF);
// BIOS int 0x13, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ
RegsIn.b.ah = 0x42; // Subfunction 42h
RtlZeroMemory(Packet, sizeof(I386_DISK_ADDRESS_PACKET));
Packet->PacketSize = sizeof(I386_DISK_ADDRESS_PACKET);
Packet->Reserved = 0;
- Packet->LBABlockCount = SectorCount;
+ Packet->LBABlockCount = (USHORT)SectorCount;
+ ASSERT(Packet->LBABlockCount == SectorCount);
Packet->TransferBufferOffset = ((ULONG_PTR)Buffer) & 0x0F;
- Packet->TransferBufferSegment = ((ULONG_PTR)Buffer) >> 4;
+ Packet->TransferBufferSegment = (USHORT)(((ULONG_PTR)Buffer) >> 4);
Packet->LBAStartBlock = SectorNumber;
// BIOS int 0x13, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ
return FALSE;
}
-static BOOLEAN PcDiskReadLogicalSectorsCHS(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
+static BOOLEAN PcDiskReadLogicalSectorsCHS(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
- ULONG PhysicalSector;
- ULONG PhysicalHead;
+ UCHAR PhysicalSector;
+ UCHAR PhysicalHead;
ULONG PhysicalTrack;
GEOMETRY DriveGeometry;
ULONG NumberOfSectorsToRead;
//
// Calculate the physical disk offsets
+ // Note: DriveGeometry.Sectors < 64
//
- PhysicalSector = 1 + (SectorNumber % DriveGeometry.Sectors);
- PhysicalHead = (SectorNumber / DriveGeometry.Sectors) % DriveGeometry.Heads;
- PhysicalTrack = (SectorNumber / DriveGeometry.Sectors) / DriveGeometry.Heads;
+ PhysicalSector = 1 + (UCHAR)(SectorNumber % DriveGeometry.Sectors);
+ PhysicalHead = (UCHAR)((SectorNumber / DriveGeometry.Sectors) % DriveGeometry.Heads);
+ PhysicalTrack = (ULONG)((SectorNumber / DriveGeometry.Sectors) / DriveGeometry.Heads);
//
// Calculate how many sectors we need to read this round
// AL = number of sectors transferred
// (only valid if CF set for some BIOSes)
RegsIn.b.ah = 0x02;
- RegsIn.b.al = NumberOfSectorsToRead;
+ RegsIn.b.al = (UCHAR)NumberOfSectorsToRead;
RegsIn.b.ch = (PhysicalTrack & 0xFF);
- RegsIn.b.cl = (PhysicalSector + ((PhysicalTrack & 0x300) >> 2));
+ RegsIn.b.cl = (UCHAR)(PhysicalSector + ((PhysicalTrack & 0x300) >> 2));
RegsIn.b.dh = PhysicalHead;
RegsIn.b.dl = DriveNumber;
- RegsIn.w.es = ((ULONG_PTR)Buffer) >> 4;
+ RegsIn.w.es = (USHORT)(((ULONG_PTR)Buffer) >> 4);
RegsIn.w.bx = ((ULONG_PTR)Buffer) & 0x0F;
//
return TRUE;
}
-BOOLEAN PcDiskReadLogicalSectors(ULONG DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
+BOOLEAN PcDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
DPRINTM(DPRINT_DISK, "PcDiskReadLogicalSectors() DriveNumber: 0x%x SectorNumber: %I64d SectorCount: %d Buffer: 0x%x\n", DriveNumber, SectorNumber, SectorCount, Buffer);
}
BOOLEAN
-PcDiskGetDriveGeometry(ULONG DriveNumber, PGEOMETRY Geometry)
+PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY Geometry)
{
REGS RegsIn;
REGS RegsOut;
}
ULONG
-PcDiskGetCacheableBlockCount(ULONG DriveNumber)
+PcDiskGetCacheableBlockCount(UCHAR DriveNumber)
{
GEOMETRY Geometry;