diff --git a/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c b/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c index 40492457c86..28e7fd66a76 100644 --- a/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c +++ b/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c @@ -570,14 +570,13 @@ PcDiskReadLogicalSectorsLBA( RtlZeroMemory(Packet, sizeof(*Packet)); Packet->PacketSize = sizeof(*Packet); Packet->Reserved = 0; - Packet->LBABlockCount = (USHORT)SectorCount; - ASSERT(Packet->LBABlockCount == SectorCount); + // Packet->LBABlockCount set in the loop. Packet->TransferBufferOffset = ((ULONG_PTR)Buffer) & 0x0F; Packet->TransferBufferSegment = (USHORT)(((ULONG_PTR)Buffer) >> 4); Packet->LBAStartBlock = SectorNumber; /* - * BIOS int 0x13, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ + * BIOS Int 13h, function 42h - IBM/MS INT 13 Extensions - EXTENDED READ * Return: * CF clear if successful * AH = 00h @@ -586,7 +585,7 @@ PcDiskReadLogicalSectorsLBA( * Disk address packet's block count field set to the * number of blocks successfully transferred. */ - RegsIn.b.ah = 0x42; // Subfunction 42h + RegsIn.b.ah = 0x42; RegsIn.b.dl = DriveNumber; // Drive number in DL (0 - floppy, 0x80 - harddisk) RegsIn.x.ds = BIOSCALLBUFSEGMENT; // DS:SI -> disk address packet RegsIn.w.si = BIOSCALLBUFOFFSET; @@ -594,6 +593,12 @@ PcDiskReadLogicalSectorsLBA( /* Retry 3 times */ for (RetryCount = 0; RetryCount < 3; ++RetryCount) { + /* Restore the number of blocks to transfer, since it gets reset + * on failure with the number of blocks that were successfully + * transferred (and which could be zero). */ + Packet->LBABlockCount = (USHORT)SectorCount; + ASSERT(Packet->LBABlockCount == SectorCount); + Int386(0x13, &RegsIn, &RegsOut); /* If it worked return TRUE */