reactos/boot
Hermès Bélusca-Maïto 3a7fe56a5d
[FREELDR] Change GEOMETRY "Sectors" to "SectorsPerTrack" and introduce a new "Sectors" field (#7379)
----
Thanks to the following testers!
- Dmitry Borisov (@disean) for testing on NEC PC-98 emulator;
- Justin Miller (@DarkFire01) for testing on UEFI platform;
- Stanislav Motylkov (@binarymaster) for testing on Xbox emulator
  (xemu), both livecd and bootcd.
----

"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):
db419efbf2/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.
2024-09-30 12:11:15 +02:00
..
armllb [FORMATTING] Remove trailing whitespace. Addendum to 34593d93. 2021-09-13 03:52:22 +02:00
bcd Add .keep guard files in order to restore lost but empty directories we had with SVN. 2017-10-04 10:28:36 +02:00
bgfx Add .keep guard files in order to restore lost but empty directories we had with SVN. 2017-10-04 10:28:36 +02:00
bootdata [BOOTDATA] Fix LiveCD autorun (#7282) 2024-08-30 10:16:31 +03:00
environ [ROSLOAD] Use CmCheckRegistry to purge volatile data 2023-11-19 20:44:28 +01:00
freeldr [FREELDR] Change GEOMETRY "Sectors" to "SectorsPerTrack" and introduce a new "Sectors" field (#7379) 2024-09-30 12:11:15 +02:00
rtl [CMAKE] Elimitate the use of GCC and CLANG variables 2022-05-27 01:37:34 +03:00
boot_images.cmake Revert "[BOOT] Don't create CSIDL_ADMINTOOLS folder in initial (#6551)" (#7017) 2024-06-14 11:08:14 +09:00
CMakeLists.txt [BOOT][SDK:RTL] Compile a reduced RTL library for FreeLdr / NT bootloader... 2022-04-07 03:19:09 +02:00