mirror of
https://github.com/reactos/reactos.git
synced 2026-06-09 01:12:59 +08:00
[FREELDR] Better fix for x64. Addendum to 268cdf57.
This commit is contained in:
@@ -154,7 +154,7 @@ elseif(ARCH STREQUAL "amd64")
|
||||
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
|
||||
|
||||
@@ -22,11 +22,76 @@
|
||||
|
||||
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
|
||||
|
||||
#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];
|
||||
@@ -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);
|
||||
@@ -225,3 +231,5 @@ VOID DriveMapRemoveInt13Handler(VOID)
|
||||
DriveMapInstalled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _M_IX86
|
||||
|
||||
@@ -19,21 +19,30 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _M_IX86
|
||||
|
||||
#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>
|
||||
|
||||
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 ULONG DriveMapOldInt13HandlerAddress;
|
||||
extern DRIVE_MAP_LIST DriveMapInt13HandlerMapList;
|
||||
extern ULONG DriveMapOldInt13HandlerAddress;
|
||||
extern DRIVE_MAP_LIST DriveMapInt13HandlerMapList;
|
||||
|
||||
#endif // _M_IX86
|
||||
|
||||
@@ -107,10 +107,10 @@
|
||||
#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>
|
||||
#include <arch/i386/drivemap.h>
|
||||
#include <arch/i386/machxbox.h>
|
||||
#include <internal/i386/intrin_i.h>
|
||||
#elif defined(_M_AMD64)
|
||||
|
||||
Reference in New Issue
Block a user