[FREELDR] Better fix for x64. Addendum to 268cdf57.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Wed, 7 Aug 2019 17:30:55 +0000 (19:30 +0200)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Wed, 7 Aug 2019 17:30:55 +0000 (19:30 +0200)
boot/freeldr/freeldr/CMakeLists.txt
boot/freeldr/freeldr/arch/i386/drivemap.c
boot/freeldr/freeldr/include/arch/i386/drivemap.h
boot/freeldr/freeldr/include/freeldr.h

index 05489b3..d426305 100644 (file)
@@ -154,7 +154,7 @@ elseif(ARCH STREQUAL "amd64")
     list(APPEND FREELDR_ARC_SOURCE
         lib/fs/pxe.c
         arch/i386/ntoskrnl.c
     list(APPEND FREELDR_ARC_SOURCE
         lib/fs/pxe.c
         arch/i386/ntoskrnl.c
-        arch/i386/drivemap.c
+        arch/i386/drivemap.c
         arch/i386/hardware.c
         arch/i386/hwacpi.c
         arch/i386/hwapm.c
         arch/i386/hardware.c
         arch/i386/hwacpi.c
         arch/i386/hwapm.c
index f03d14e..2d38f34 100644 (file)
 
 DBG_DEFAULT_CHANNEL(DISK);
 
 
 DBG_DEFAULT_CHANNEL(DISK);
 
+#ifdef _M_IX86
+
 BOOLEAN      DriveMapInstalled = FALSE;    // Tells us if we have already installed our drive map int 13h handler code
 ULONG        OldInt13HandlerAddress = 0;   // Address of BIOS int 13h handler
 ULONG        DriveMapHandlerAddress = 0;   // Linear address of our drive map handler
 ULONG        DriveMapHandlerSegOff = 0;    // Segment:offset style address of our drive map handler
 
 BOOLEAN      DriveMapInstalled = FALSE;    // Tells us if we have already installed our drive map int 13h handler code
 ULONG        OldInt13HandlerAddress = 0;   // Address of BIOS int 13h handler
 ULONG        DriveMapHandlerAddress = 0;   // Linear address of our drive map handler
 ULONG        DriveMapHandlerSegOff = 0;    // Segment:offset style address of our drive map handler
 
+#endif // _M_IX86
+
+BOOLEAN DriveMapIsValidDriveString(PCSTR DriveString)
+{
+    ULONG Index;
+
+    // Now verify that the user has given us appropriate strings
+    if ((strlen(DriveString) < 3) ||
+        ((DriveString[0] != 'f') && (DriveString[0] != 'F') &&
+         (DriveString[0] != 'h') && (DriveString[0] != 'H')) ||
+        ((DriveString[1] != 'd') && (DriveString[1] != 'D')))
+    {
+        return FALSE;
+    }
+
+    // Now verify that the user has given us appropriate numbers
+    // Make sure that only numeric characters were given
+    for (Index = 2; Index < strlen(DriveString); Index++)
+    {
+        if (DriveString[Index] < '0' || DriveString[Index] > '9')
+        {
+            return FALSE;
+        }
+    }
+
+    // Now make sure that they are not outrageous values (i.e. hd90874)
+    if ((atoi(&DriveString[2]) < 0) || (atoi(&DriveString[2]) > 0xff))
+    {
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+UCHAR DriveMapGetBiosDriveNumber(PCSTR DeviceName)
+{
+    UCHAR BiosDriveNumber = 0;
+
+    TRACE("DriveMapGetBiosDriveNumber(%s)\n", DeviceName);
+
+    // If they passed in a number string then just
+    // convert it to decimal and return it
+    if (DeviceName[0] >= '0' && DeviceName[0] <= '9')
+    {
+        return (UCHAR)strtoul(DeviceName, NULL, 0);
+    }
+
+    // Convert the drive number string into a number
+    // 'hd1' = 1
+    BiosDriveNumber = atoi(&DeviceName[2]);
+
+    // If it's a hard disk then set the high bit
+    if ((DeviceName[0] == 'h' || DeviceName[0] == 'H') &&
+        (DeviceName[1] == 'd' || DeviceName[1] == 'D'))
+    {
+        BiosDriveNumber |= 0x80;
+    }
+
+    return BiosDriveNumber;
+}
+
+#ifdef _M_IX86
+
 VOID DriveMapMapDrivesInSection(PCSTR SectionName)
 {
     CHAR           SettingName[80];
 VOID DriveMapMapDrivesInSection(PCSTR SectionName)
 {
     CHAR           SettingName[80];
@@ -111,65 +176,6 @@ VOID DriveMapMapDrivesInSection(PCSTR SectionName)
     }
 }
 
     }
 }
 
-BOOLEAN DriveMapIsValidDriveString(PCSTR DriveString)
-{
-    ULONG Index;
-
-    // Now verify that the user has given us appropriate strings
-    if ((strlen(DriveString) < 3) ||
-        ((DriveString[0] != 'f') && (DriveString[0] != 'F') &&
-         (DriveString[0] != 'h') && (DriveString[0] != 'H')) ||
-        ((DriveString[1] != 'd') && (DriveString[1] != 'D')))
-    {
-        return FALSE;
-    }
-
-    // Now verify that the user has given us appropriate numbers
-    // Make sure that only numeric characters were given
-    for (Index = 2; Index < strlen(DriveString); Index++)
-    {
-        if (DriveString[Index] < '0' || DriveString[Index] > '9')
-        {
-            return FALSE;
-        }
-    }
-
-    // Now make sure that they are not outrageous values (i.e. hd90874)
-    if ((atoi(&DriveString[2]) < 0) || (atoi(&DriveString[2]) > 0xff))
-    {
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-UCHAR DriveMapGetBiosDriveNumber(PCSTR DeviceName)
-{
-    UCHAR BiosDriveNumber = 0;
-
-    TRACE("DriveMapGetBiosDriveNumber(%s)\n", DeviceName);
-
-    // If they passed in a number string then just
-    // convert it to decimal and return it
-    if (DeviceName[0] >= '0' && DeviceName[0] <= '9')
-    {
-        return (UCHAR)strtoul(DeviceName, NULL, 0);
-    }
-
-    // Convert the drive number string into a number
-    // 'hd1' = 1
-    BiosDriveNumber = atoi(&DeviceName[2]);
-
-    // If it's a hard disk then set the high bit
-    if ((DeviceName[0] == 'h' || DeviceName[0] == 'H') &&
-        (DeviceName[1] == 'd' || DeviceName[1] == 'D'))
-    {
-        BiosDriveNumber |= 0x80;
-    }
-
-    return BiosDriveNumber;
-}
-
 VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
 {
     ULONG*  RealModeIVT = (ULONG*)UlongToPtr(0x00000000);
 VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap)
 {
     ULONG*  RealModeIVT = (ULONG*)UlongToPtr(0x00000000);
@@ -225,3 +231,5 @@ VOID DriveMapRemoveInt13Handler(VOID)
         DriveMapInstalled = FALSE;
     }
 }
         DriveMapInstalled = FALSE;
     }
 }
+
+#endif // _M_IX86
index c999649..8c1d108 100644 (file)
 
 #pragma once
 
 
 #pragma once
 
+#ifdef _M_IX86
+
 #include <pshpack1.h>
 typedef struct
 {
 #include <pshpack1.h>
 typedef struct
 {
-    UCHAR        DriveMapCount;        // Count of drives currently mapped
-    CHAR        DriveMap[8];        // Map of BIOS drives
+    UCHAR DriveMapCount;    // Count of drives currently mapped
+    CHAR  DriveMap[8];      // Map of BIOS drives
 } DRIVE_MAP_LIST, *PDRIVE_MAP_LIST;
 #include <poppack.h>
 
 } DRIVE_MAP_LIST, *PDRIVE_MAP_LIST;
 #include <poppack.h>
 
-VOID    DriveMapMapDrivesInSection(PCSTR SectionName);
-BOOLEAN    DriveMapIsValidDriveString(PCSTR DriveString);            // Checks the drive string ("hd0") for validity
-UCHAR        DriveMapGetBiosDriveNumber(PCSTR DeviceName);            // Returns a BIOS drive number for any given device name (e.g. 0x80 for 'hd0')
-VOID    DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap);    // Installs the int 13h handler for the drive mapper
-VOID    DriveMapRemoveInt13Handler(VOID);                        // Removes a previously installed int 13h drive map handler
+#endif // _M_IX86
+
+BOOLEAN DriveMapIsValidDriveString(PCSTR DriveString);  // Checks the drive string ("hd0") for validity
+UCHAR   DriveMapGetBiosDriveNumber(PCSTR DeviceName);   // Returns a BIOS drive number for any given device name (e.g. 0x80 for 'hd0')
+
+#ifdef _M_IX86
+
+VOID DriveMapMapDrivesInSection(PCSTR SectionName);
+VOID DriveMapInstallInt13Handler(PDRIVE_MAP_LIST DriveMap); // Installs the int 13h handler for the drive mapper
+VOID DriveMapRemoveInt13Handler(VOID);                      // Removes a previously installed int 13h drive map handler
 
 extern PVOID            DriveMapInt13HandlerStart;
 extern PVOID            DriveMapInt13HandlerEnd;
 
 extern PVOID            DriveMapInt13HandlerStart;
 extern PVOID            DriveMapInt13HandlerEnd;
-extern ULONG                DriveMapOldInt13HandlerAddress;
-extern DRIVE_MAP_LIST    DriveMapInt13HandlerMapList;
+extern ULONG            DriveMapOldInt13HandlerAddress;
+extern DRIVE_MAP_LIST   DriveMapInt13HandlerMapList;
+
+#endif // _M_IX86
index 0ef42e4..841fd4c 100644 (file)
 #include <arch/pc/machpc.h>
 #include <arch/pc/x86common.h>
 #include <arch/pc/pxe.h>
 #include <arch/pc/machpc.h>
 #include <arch/pc/x86common.h>
 #include <arch/pc/pxe.h>
+#include <arch/i386/drivemap.h>
 #endif
 #if defined(_M_IX86)
 #include <arch/i386/i386.h>
 #endif
 #if defined(_M_IX86)
 #include <arch/i386/i386.h>
-#include <arch/i386/drivemap.h>
 #include <arch/i386/machxbox.h>
 #include <internal/i386/intrin_i.h>
 #elif defined(_M_AMD64)
 #include <arch/i386/machxbox.h>
 #include <internal/i386/intrin_i.h>
 #elif defined(_M_AMD64)