Skip to content

Commit 82b7a61

Browse files
Merge pull request #6485 from cimarronm/fix-chs-write-cylinder-bits
bios_disk: fix chs_write packing high cylinder bits into the sector field
2 parents 89958be + 207b9d0 commit 82b7a61

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ NEXT VERSION:
3636
POD_Load_DOS_Mscdex looping forever on an out-of-range CD drive count, and
3737
mounted drive paths keeping their Windows path separators when a state is
3838
restored on a non-Windows host. (ozy24)
39+
- Fixed chs_write packing the high cylinder bits into the sector field of the
40+
synthesized MBR partition table, which corrupted the end-CHS entry for disks
41+
with an end cylinder above 255. (cimarronm)
3942

4043
2026.08.02
4144
- Debugger: normalize 16-bit segmented offsets for address display/lookup and

src/ints/bios_disk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ struct fatFromDOSDrive
897897
if (head > 0xFF || sector > 0x3F || cylinder > 0x3FF)
898898
LOG_MSG("Warning: Invalid CHS data - %X, %X, %X\n", head, sector, cylinder);
899899
chs[0] = (uint8_t)(head & 0xFF);
900-
chs[1] = (uint8_t)((sector & 0x3F) | ((cylinder >> 8) & 0x3));
900+
chs[1] = (uint8_t)((sector & 0x3F) | ((cylinder >> 2) & 0xC0));
901901
chs[2] = (uint8_t)(cylinder & 0xFF);
902902
}
903903

0 commit comments

Comments
 (0)