[FREELDR] Fix the seg:off values when dumping the extended drive parameters (#7367)

(By the way, it's "EDD": "Enhanced Disk Drive", not "EED"...)

The 13th and 14th USHORTs (at offsets 0x1A-0x1D) in the retrieved buffer
from the INT 13h, AH=48h "Get Extended Drive Parameters" function,
correspond respectively to the offset and the segment of the "EDD
configuration parameters", see http://www.ctyme.com/intr/rb-0715.htm

Fixes code introduced in commit b3f11cfb38 (r17484).

----

16 years ago, these values were wrongly stored in the returned buffer
by VirtualBox, see https://www.virtualbox.org/ticket/2848 .
This has been fixed since VBox 2.1.0 in commit 15712 (22 Dec. 2008):
https://www.virtualbox.org/changeset/15712/vbox
This problem was also noticed earlier (07 Mar. 2008) and fixed in Xen:
https://lists.xenproject.org/archives/html/xen-devel/2008-03/msg00229.html

This bug originated from Bochs, from which the two projects above
adapted their rombios.c code. It was fixed on 08-09 Oct. 2007 by
Myles Watson, see https://sourceforge.net/p/bochs/mailman/message/13777090/
and included in Bochs 1.15x and 1.185+
https://sourceforge.net/p/bochs/mailman/message/12953093/
https://sourceforge.net/p/bochs/mailman/message/12953094/
This commit is contained in:
Hermès Bélusca-Maïto 2024-09-22 19:00:42 +02:00
parent e2d0c7de30
commit 4190b48924
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -338,14 +338,15 @@ DiskGetExtendedDriveParameters(
TRACE("number of physical cylinders on drive: %u\n", *(PULONG)&Ptr[2]); TRACE("number of physical cylinders on drive: %u\n", *(PULONG)&Ptr[2]);
TRACE("number of physical heads on drive: %u\n", *(PULONG)&Ptr[4]); TRACE("number of physical heads on drive: %u\n", *(PULONG)&Ptr[4]);
TRACE("number of physical sectors per track: %u\n", *(PULONG)&Ptr[6]); TRACE("number of physical sectors per track: %u\n", *(PULONG)&Ptr[6]);
TRACE("total number of sectors on drive: %I64u\n", *(unsigned long long*)&Ptr[8]); TRACE("total number of sectors on drive: %I64u\n", *(PULONGLONG)&Ptr[8]);
TRACE("bytes per sector: %u\n", Ptr[12]); TRACE("bytes per sector: %u\n", Ptr[12]);
if (Ptr[0] >= 0x1e) if (Ptr[0] >= 0x1e)
{ {
TRACE("EED configuration parameters: %x:%x\n", Ptr[13], Ptr[14]); // Ptr[13]: offset, Ptr[14]: segment
TRACE("EDD configuration parameters: %x:%x\n", Ptr[14], Ptr[13]);
if (Ptr[13] != 0xffff && Ptr[14] != 0xffff) if (Ptr[13] != 0xffff && Ptr[14] != 0xffff)
{ {
PUCHAR SpecPtr = (PUCHAR)(ULONG_PTR)((Ptr[13] << 4) + Ptr[14]); PUCHAR SpecPtr = (PUCHAR)(ULONG_PTR)((Ptr[14] << 4) + Ptr[13]);
TRACE("SpecPtr: %x\n", SpecPtr); TRACE("SpecPtr: %x\n", SpecPtr);
TRACE("physical I/O port base address: %x\n", *(PUSHORT)&SpecPtr[0]); TRACE("physical I/O port base address: %x\n", *(PUSHORT)&SpecPtr[0]);
TRACE("disk-drive control port address: %x\n", *(PUSHORT)&SpecPtr[2]); TRACE("disk-drive control port address: %x\n", *(PUSHORT)&SpecPtr[2]);