forked from reactos/reactos
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FREELDR] Change GEOMETRY "Sectors" to "SectorsPerTrack" and introduc…
…e a new "Sectors" field (reactos#7379) "SectorsPerTrack" is for the legacy Cylinders/Heads/Sectors(PerTrack) scheme. - On BIOS-based PCs, INT 13h can return (for LBA-only drives) an invalid geometry, like: C/H/S = (-1)/(-1)/(-1). This is also what happens in our hwide.c driver (see IdentifyDevice() for ATAPI devices): https://github.com/reactos/reactos/blob/db419efbf26c78e39fb57bcaf4f9e4d915d0c96e/boot/freeldr/freeldr/arch/drivers/hwide.c#L918-L928 as well as on VirtualBox for CD-ROMs: https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Devices/PC/BIOS/disk.c#L155 - Therefore, we cannot reliably calculate a valid total number of sectors by multiplying the Cylinders*Heads*SectorsPerTrack values. In addition, such a multiplication could overflow a 32-bit ULONG. Thus, a separate ULONGLONG Sectors member is required to hold such a value, that is retrieved differently. For example for ATAPI devices, our hwide.c driver does return a valid TotalSectors value, even though CHS values are invalid. Other platforms, like UEFI, just work using logical block addressing (LBA) values (see EFI_BLOCK_IO_MEDIA). - uefidisk.c : Per the spec, EFI_BLOCK_IO_MEDIA::LastBlock contains "The last LBA on the device. [...] For ATA devices, this is reported in IDENTIFY DEVICE data words 60-61 (i.e., Total number of user addressable logical sectors) _minus one_. For SCSI devices, this is reported in the READ CAPACITY parameter data 'Returned Logical Block Address field' _minus one_." In other words, LastBlock is a zero-based LBA index quantity. The corresponding total number of valid "sectors"/blocks of the device is therefore, (LastBlock + 1). - Cleanup some old disabled code.
- Loading branch information
1 parent
0c8c843
commit fe9f837
Showing
11 changed files
with
92 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.