Skip to content

Conversation

HBelusca
Copy link
Contributor

@HBelusca HBelusca commented Sep 26, 2025

Purpose & Proposed changes

This PR is necessary for PR #8399 to work.

JIRA issue: CORE-14603

For example, ATAPI devices like CD-ROMs, detected as such by the BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry (number of sectors) for such devices, for example:

  • VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

  • Dell Latitude D531 BIOS claims that the drive is NOT removable (although is an ATAPI device), returns a hardcoded CHS=680/64/32, and total sectors = 348160 for 2048 bytes per sectors, corresponding to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being removable IF it is detected as an ATAPI device by the INT 13h,AH=48h "Get drive parameters" function.
In that case also, we redetermine a suitable geometry. First we assume the drive may be a CD-ROM, and attempt to read the ISO-9660 volume size from its ISO Primary Volume Descriptor, if any. If none is found, we fall back to size detection by bisecting over valid and invalid sectors.

Testing

  • PRs [FREELDR] disk/fs: Improve some TRACEs and comments #8400 and this one ([FREELDR] Perform disk geometry fixups for "enhanced" removable drives #8401) need to be combined together for better testing with traces.
  • A test on real hardware and/or in a virtual machine is strongly advised, with a serial port available.
  • Build either a bootcd or a livecd, then boot the resulting media up to the FreeLdr menu, while monitoring the serial port output.
  • Remember that FreeLdr serial debugging selects the highest available serial port of the machine, e.g. if both COM1 and COM2 are available, FreeLdr debugging goes to COM2. If only COM1 is available, FreeLdr debugging goes to COM1.

Examples

@HBelusca HBelusca self-assigned this Sep 26, 2025
@HBelusca HBelusca added the enhancement For PRs with an enhancement/new feature. label Sep 26, 2025
@HBelusca HBelusca added the freeldr Freeloader changes label Sep 26, 2025
HBelusca added a commit to HBelusca/reactos that referenced this pull request Sep 26, 2025
reactos#8401)

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry. First we assume
the drive may be a CD-ROM, and attempt to read the ISO-9660 volume size
from its ISO Primary Volume Descriptor, if any. If none is found, we
fall back to size detection by bisecting over valid and invalid sectors.
@HBelusca HBelusca force-pushed the freeldr_extint13_removable_geometry_fixup branch from 4c7864d to fd9e637 Compare September 26, 2025 15:33
@HBelusca
Copy link
Contributor Author

Cc @disean too for review.

@HBelusca HBelusca marked this pull request as draft September 29, 2025 19:09
@HBelusca
Copy link
Contributor Author

Switching PR to draft because of a change of design being done.

HBelusca added a commit to HBelusca/reactos that referenced this pull request Sep 29, 2025
reactos#8401)

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry. First we assume
the drive may be a CD-ROM, and attempt to read the ISO-9660 volume size
from its ISO Primary Volume Descriptor, if any. If none is found, we
fall back to size detection by bisecting over valid and invalid sectors.
@HBelusca HBelusca force-pushed the freeldr_extint13_removable_geometry_fixup branch from 000be17 to d4f35e6 Compare September 29, 2025 19:28
HBelusca added a commit to HBelusca/reactos that referenced this pull request Oct 4, 2025
reactos#8401)

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry, by bisecting
over valid and invalid sectors.
@HBelusca HBelusca force-pushed the freeldr_extint13_removable_geometry_fixup branch from d4f35e6 to 45f0b66 Compare October 4, 2025 16:39
HBelusca added a commit to HBelusca/reactos that referenced this pull request Oct 4, 2025
reactos#8401)

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry, by bisecting
over valid and invalid sectors.
@HBelusca HBelusca force-pushed the freeldr_extint13_removable_geometry_fixup branch from 45f0b66 to 7f90cb8 Compare October 4, 2025 21:20
HBelusca added a commit to HBelusca/reactos that referenced this pull request Oct 5, 2025
reactos#8401)

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry, by bisecting
over valid and invalid sectors.
@HBelusca HBelusca force-pushed the freeldr_extint13_removable_geometry_fixup branch from 7f90cb8 to e41a65f Compare October 5, 2025 19:00
HBelusca added a commit to HBelusca/reactos that referenced this pull request Oct 6, 2025
reactos#8401)

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry, by bisecting
over valid and invalid sectors.
@HBelusca HBelusca force-pushed the freeldr_extint13_removable_geometry_fixup branch from e41a65f to 260cfa7 Compare October 6, 2025 12:27
HBelusca added a commit to HBelusca/reactos that referenced this pull request Oct 7, 2025
reactos#8401)

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry, by bisecting
over valid and invalid sectors.
@HBelusca HBelusca force-pushed the freeldr_extint13_removable_geometry_fixup branch from 260cfa7 to 1e78cdc Compare October 7, 2025 20:11
HBelusca added a commit to HBelusca/reactos that referenced this pull request Oct 9, 2025
reactos#8401)

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry, by bisecting
over valid and invalid sectors.
@HBelusca HBelusca force-pushed the freeldr_extint13_removable_geometry_fixup branch 2 times, most recently from 3032323 to 274ab3e Compare October 10, 2025 15:03
HBelusca added a commit to HBelusca/reactos that referenced this pull request Oct 10, 2025
reactos#8401)

CORE-9023

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry, by bisecting
over valid and invalid sectors.
reactos#8401)

CORE-9023

For example, ATAPI devices like CD-ROMs, detected as such by the
BIOS INT 13h extensions.

The motivation is that some hardware would report unusable geometry
(number of sectors) for such devices, for example:

- VBOX returns CHS=(-1)/(-1)/(-1) and total sectors = 0xFFFFFFFF`FFFFFFFF;

- Dell Latitude D531 BIOS claims that the drive is *NOT* removable
  (although is an ATAPI device), returns a hardcoded CHS=680/64/32,
  and total sectors = 348160 for 2048 bytes per sectors, corresponding
  to a fixed 680 MiB disk.

All this, even though a CD-ROM is present and may contain much less data.

In order to fix these problems, we always report a drive as being
removable *IF* it is detected as an ATAPI device by the INT 13h,AH=48h
"Get drive parameters" function.
In that case also, we redetermine a suitable geometry, by bisecting
over valid and invalid sectors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement For PRs with an enhancement/new feature. freeldr Freeloader changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant