https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4190b4892448cd73574c0886cc189a2a8e106b5a

commit 4190b4892448cd73574c0886cc189a2a8e106b5a
Author:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
AuthorDate: Sun Sep 22 19:00:42 2024 +0200
Commit:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
CommitDate: Wed Sep 25 13:05:07 2024 +0200

    [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/
---
 boot/freeldr/freeldr/arch/i386/pc/pcdisk.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c 
b/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
index 550c424d15d..40492457c86 100644
--- a/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
+++ b/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
@@ -338,14 +338,15 @@ DiskGetExtendedDriveParameters(
     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 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]);
     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)
         {
-            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("physical I/O port base address:          %x\n", 
*(PUSHORT)&SpecPtr[0]);
             TRACE("disk-drive control port address:         %x\n", 
*(PUSHORT)&SpecPtr[2]);

Reply via email to