Drop C wrappers and switch to C++ API
Some checks failed
Builds / ExectOS (amd64, debug) (push) Successful in 36s
Builds / ExectOS (amd64, release) (push) Successful in 34s
Builds / ExectOS (i686, debug) (push) Failing after 23s
Builds / ExectOS (i686, release) (push) Failing after 21s

This commit is contained in:
2025-09-19 12:56:06 +02:00
parent b2c8fa3e62
commit e7425de523
32 changed files with 441 additions and 492 deletions

View File

@@ -44,7 +44,7 @@ BlBuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
/* Assign and zero-fill memory used by page mappings */
PageMap->PtePointer = (PVOID)(UINT_PTR)Address;
RtlZeroMemory(PageMap->PtePointer, EFI_PAGE_SIZE);
RTL::Memory::ZeroMemory(PageMap->PtePointer, EFI_PAGE_SIZE);
/* Add page mapping itself to memory mapping */
Status = BlpSelfMapPml(PageMap, SelfMapAddress);
@@ -228,7 +228,7 @@ BlMapPage(IN PXTBL_PAGE_MAPPING PageMap,
/* Set paging entry settings */
PmlTable = (PHARDWARE_PTE)Pml1;
RtlZeroMemory(&PmlTable[Pml1Entry], sizeof(HARDWARE_PTE));
RTL::Memory::ZeroMemory(&PmlTable[Pml1Entry], sizeof(HARDWARE_PTE));
PmlTable[Pml1Entry].PageFrameNumber = PageFrameNumber;
PmlTable[Pml1Entry].Valid = 1;
PmlTable[Pml1Entry].Writable = 1;
@@ -304,7 +304,7 @@ BlpGetNextPageTable(IN PXTBL_PAGE_MAPPING PageMap,
}
/* Fill allocated memory with zeros */
RtlZeroMemory((PVOID)(ULONGLONG)Address, EFI_PAGE_SIZE);
RTL::Memory::ZeroMemory((PVOID)(ULONGLONG)Address, EFI_PAGE_SIZE);
/* Set paging entry settings */
PmlTable[Entry].PageFrameNumber = Address / EFI_PAGE_SIZE;
@@ -357,7 +357,7 @@ BlpSelfMapPml(IN PXTBL_PAGE_MAPPING PageMap,
}
/* Add self-mapping */
RtlZeroMemory(&PmlBase[PmlIndex], sizeof(HARDWARE_PTE));
RTL::Memory::ZeroMemory(&PmlBase[PmlIndex], sizeof(HARDWARE_PTE));
PmlBase[PmlIndex].PageFrameNumber = (UINT_PTR)PageMap->PtePointer / EFI_PAGE_SIZE;
PmlBase[PmlIndex].Valid = 1;
PmlBase[PmlIndex].Writable = 1;

View File

@@ -45,7 +45,7 @@ BlBuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
/* Assign the allocated page to the page map and zero it out */
PageMap->PtePointer = (PVOID)(UINT_PTR)Address;
RtlZeroMemory(PageMap->PtePointer, EFI_PAGE_SIZE);
RTL::Memory::ZeroMemory(PageMap->PtePointer, EFI_PAGE_SIZE);
/* Allocate 4 pages for the Page Directories (PDs) */
Status = BlAllocateMemoryPages(AllocateAnyPages, 4, &DirectoryAddress);
@@ -56,12 +56,12 @@ BlBuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
}
/* Zero-fill the allocated memory for the Page Directories */
RtlZeroMemory((PVOID)DirectoryAddress, EFI_PAGE_SIZE * 4);
RTL::Memory::ZeroMemory((PVOID)DirectoryAddress, EFI_PAGE_SIZE * 4);
/* Fill the PDPT with pointers to the Page Directories */
for(Index = 0; Index < 4; Index++)
{
RtlZeroMemory(&((PHARDWARE_MODERN_PTE)PageMap->PtePointer)[Index], sizeof(HARDWARE_MODERN_PTE));
RTL::Memory::ZeroMemory(&((PHARDWARE_MODERN_PTE)PageMap->PtePointer)[Index], sizeof(HARDWARE_MODERN_PTE));
((PHARDWARE_MODERN_PTE)PageMap->PtePointer)[Index].PageFrameNumber = DirectoryAddress / EFI_PAGE_SIZE;
((PHARDWARE_MODERN_PTE)PageMap->PtePointer)[Index].Valid = 1;
DirectoryAddress += EFI_PAGE_SIZE;
@@ -79,7 +79,7 @@ BlBuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
/* Assign the allocated page to the page map and zero it out */
PageMap->PtePointer = (PVOID)(UINT_PTR)Address;
RtlZeroMemory(PageMap->PtePointer, EFI_PAGE_SIZE);
RTL::Memory::ZeroMemory(PageMap->PtePointer, EFI_PAGE_SIZE);
}
/* Add page mapping itself to memory mapping */
@@ -241,7 +241,7 @@ BlMapPage(IN PXTBL_PAGE_MAPPING PageMap,
/* Set the 64-bit PTE entry */
PmlTable = (PHARDWARE_MODERN_PTE)Pml1;
RtlZeroMemory(&PmlTable[Pml1Entry], sizeof(HARDWARE_MODERN_PTE));
RTL::Memory::ZeroMemory(&PmlTable[Pml1Entry], sizeof(HARDWARE_MODERN_PTE));
PmlTable[Pml1Entry].PageFrameNumber = PageFrameNumber;
PmlTable[Pml1Entry].Valid = 1;
PmlTable[Pml1Entry].Writable = 1;
@@ -265,7 +265,7 @@ BlMapPage(IN PXTBL_PAGE_MAPPING PageMap,
/* Set the 32-bit PTE entry */
LegacyPmlTable = (PHARDWARE_LEGACY_PTE)Pml1;
RtlZeroMemory(&LegacyPmlTable[Pml1Entry], sizeof(HARDWARE_LEGACY_PTE));
RTL::Memory::ZeroMemory(&LegacyPmlTable[Pml1Entry], sizeof(HARDWARE_LEGACY_PTE));
LegacyPmlTable[Pml1Entry].PageFrameNumber = (UINT32)PageFrameNumber;
LegacyPmlTable[Pml1Entry].Valid = 1;
LegacyPmlTable[Pml1Entry].Writable = 1;
@@ -365,7 +365,7 @@ BlpGetNextPageTable(IN PXTBL_PAGE_MAPPING PageMap,
}
/* Fill allocated memory with zeros */
RtlZeroMemory((PVOID)(ULONGLONG)Address, EFI_PAGE_SIZE);
RTL::Memory::ZeroMemory((PVOID)(ULONGLONG)Address, EFI_PAGE_SIZE);
/* Set paging entry settings based on level */
if(PageMap->PageMapLevel >= 3)
@@ -431,7 +431,7 @@ BlpSelfMapPml(IN PXTBL_PAGE_MAPPING PageMap,
/* Add self-mapping for PML3 (PAE enabled) */
for(Index = 0; Index < 4; Index++)
{
RtlZeroMemory(&Pml[PmlIndex + Index], sizeof(HARDWARE_MODERN_PTE));
RTL::Memory::ZeroMemory(&Pml[PmlIndex + Index], sizeof(HARDWARE_MODERN_PTE));
Pml[PmlIndex + Index].PageFrameNumber = ((PHARDWARE_MODERN_PTE)PageMap->PtePointer)[Index].PageFrameNumber;
Pml[PmlIndex + Index].Valid = 1;
Pml[PmlIndex + Index].Writable = 1;
@@ -445,7 +445,7 @@ BlpSelfMapPml(IN PXTBL_PAGE_MAPPING PageMap,
PmlIndex = (SelfMapAddress >> MM_PDI_LEGACY_SHIFT);
/* Add self-mapping for PML2 (PAE disabled) */
RtlZeroMemory(&LegacyPml[PmlIndex], sizeof(HARDWARE_LEGACY_PTE));
RTL::Memory::ZeroMemory(&LegacyPml[PmlIndex], sizeof(HARDWARE_LEGACY_PTE));
LegacyPml[PmlIndex].PageFrameNumber = (UINT_PTR)PageMap->PtePointer / EFI_PAGE_SIZE;
LegacyPml[PmlIndex].Valid = 1;
LegacyPml[PmlIndex].Writable = 1;

View File

@@ -38,7 +38,7 @@ BlGetBooleanParameter(IN PCWSTR Parameters,
}
CurrentPosition = Parameters;
NeedleLength = RtlWideStringLength(Needle, 0);
NeedleLength = RTL::WideString::WideStringLength(Needle, 0);
/* Iterate through the entire parameters string */
while(*CurrentPosition != L'\0')
@@ -71,7 +71,7 @@ BlGetBooleanParameter(IN PCWSTR Parameters,
if(TokenLength == NeedleLength)
{
/* Length matches, compare the strings */
if(RtlCompareWideStringInsensitive(TokenStart, Needle, NeedleLength) == 0)
if(RTL::WideString::CompareWideStringInsensitive(TokenStart, Needle, NeedleLength) == 0)
{
/* A match was found */
return TRUE;

View File

@@ -41,7 +41,7 @@ BlGetBootOptionValue(IN PLIST_ENTRY Options,
*OptionValue = NULLPTR;
/* Get the length of the option name we are looking for */
KeyLength = RtlWideStringLength(OptionName, 0);
KeyLength = RTL::WideString::WideStringLength(OptionName, 0);
/* Start iterating from the first entry in the options list */
ConfigList = Options->Flink;
@@ -51,10 +51,10 @@ BlGetBootOptionValue(IN PLIST_ENTRY Options,
ConfigEntry = CONTAIN_RECORD(ConfigList, XTBL_CONFIG_ENTRY, Flink);
/* Compare the current entry's name with the requested option name */
if(RtlCompareWideStringInsensitive(ConfigEntry->Name, OptionName, KeyLength) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ConfigEntry->Name, OptionName, KeyLength) == 0)
{
/* Found the option, now prepare to copy its value */
ValueLength = RtlWideStringLength(ConfigEntry->Value, 0);
ValueLength = RTL::WideString::WideStringLength(ConfigEntry->Value, 0);
/* Allocate memory for the output value string */
Status = BlAllocateMemoryPool((ValueLength + 1) * sizeof(WCHAR), (PVOID *)OptionValue);
@@ -67,7 +67,7 @@ BlGetBootOptionValue(IN PLIST_ENTRY Options,
}
/* Copy the value and NULL-terminate the new string */
RtlCopyMemory(*OptionValue, ConfigEntry->Value, ValueLength * sizeof(WCHAR));
RTL::Memory::CopyMemory(*OptionValue, ConfigEntry->Value, ValueLength * sizeof(WCHAR));
(*OptionValue)[ValueLength] = L'\0';
/* Successfully retrieved the option value, return success */
@@ -102,10 +102,10 @@ BlGetConfigBooleanValue(IN PCWSTR ConfigName)
BlGetConfigValue(ConfigName, &Value);
/* Check if option is enabled */
if(RtlCompareWideStringInsensitive(Value, L"ENABLED", 0) == 0 ||
RtlCompareWideStringInsensitive(Value, L"ON", 0) == 0 ||
RtlCompareWideStringInsensitive(Value, L"TRUE", 0) == 0 ||
RtlCompareWideStringInsensitive(Value, L"YES", 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(Value, L"ENABLED", 0) == 0 ||
RTL::WideString::CompareWideStringInsensitive(Value, L"ON", 0) == 0 ||
RTL::WideString::CompareWideStringInsensitive(Value, L"TRUE", 0) == 0 ||
RTL::WideString::CompareWideStringInsensitive(Value, L"YES", 0) == 0)
{
/* This option is enabled */
return TRUE;
@@ -140,7 +140,7 @@ BlGetConfigValue(IN PCWSTR ConfigName,
*ConfigValue = NULLPTR;
/* Get config entry name length */
KeyLength = RtlWideStringLength(ConfigName, 0);
KeyLength = RTL::WideString::WideStringLength(ConfigName, 0);
/* Iterate through config entries */
ConfigListEntry = BlpConfig.Flink;
@@ -150,10 +150,10 @@ BlGetConfigValue(IN PCWSTR ConfigName,
ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink);
/* Check if requested configuration found */
if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, KeyLength) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ConfigEntry->Name, ConfigName, KeyLength) == 0)
{
/* Get value length */
ValueLength = RtlWideStringLength(ConfigEntry->Value, 0);
ValueLength = RTL::WideString::WideStringLength(ConfigEntry->Value, 0);
/* Allocate memory for value */
Status = BlAllocateMemoryPool((ValueLength + 1) * sizeof(WCHAR), (PVOID *)&Value);
@@ -165,7 +165,7 @@ BlGetConfigValue(IN PCWSTR ConfigName,
}
/* Copy value and return it */
RtlCopyMemory(Value, ConfigEntry->Value, ValueLength * sizeof(WCHAR));
RTL::Memory::CopyMemory(Value, ConfigEntry->Value, ValueLength * sizeof(WCHAR));
Value[ValueLength] = L'\0';
*ConfigValue = Value;
return STATUS_EFI_SUCCESS;
@@ -240,7 +240,7 @@ BlSetBootOptionValue(IN PLIST_ENTRY Options,
EFI_STATUS Status;
/* Get the length of the option name we are looking for */
Length = RtlWideStringLength(OptionName, 0);
Length = RTL::WideString::WideStringLength(OptionName, 0);
/* Start iterating from the first entry in the options list */
ConfigList = Options->Flink;
@@ -250,10 +250,10 @@ BlSetBootOptionValue(IN PLIST_ENTRY Options,
ConfigEntry = CONTAIN_RECORD(ConfigList, XTBL_CONFIG_ENTRY, Flink);
/* Compare the current entry's name with the requested option name */
if(RtlCompareWideStringInsensitive(ConfigEntry->Name, OptionName, Length) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ConfigEntry->Name, OptionName, Length) == 0)
{
/* Found the option, get its length */
Length = RtlWideStringLength(OptionValue, 0);
Length = RTL::WideString::WideStringLength(OptionValue, 0);
/* Reallocate memory for the new value */
Status = BlFreeMemoryPool(ConfigEntry->Value);
@@ -273,7 +273,7 @@ BlSetBootOptionValue(IN PLIST_ENTRY Options,
}
/* Copy the value and NULL-terminate the new string */
RtlCopyMemory(ConfigEntry->Value, OptionValue, Length * sizeof(WCHAR));
RTL::Memory::CopyMemory(ConfigEntry->Value, OptionValue, Length * sizeof(WCHAR));
ConfigEntry->Value[Length] = L'\0';
return STATUS_EFI_SUCCESS;
}
@@ -292,7 +292,7 @@ BlSetBootOptionValue(IN PLIST_ENTRY Options,
}
/* Allocate memory for the option name */
Length = RtlWideStringLength(OptionName, 0);
Length = RTL::WideString::WideStringLength(OptionName, 0);
Status = BlAllocateMemoryPool((Length + 1) * sizeof(WCHAR), (PVOID *)&ConfigEntry->Name);
if(Status != STATUS_EFI_SUCCESS)
{
@@ -303,11 +303,11 @@ BlSetBootOptionValue(IN PLIST_ENTRY Options,
}
/* Copy the option name and NULL-terminate the new string */
RtlCopyMemory(ConfigEntry->Name, OptionName, Length * sizeof(WCHAR));
RTL::Memory::CopyMemory(ConfigEntry->Name, OptionName, Length * sizeof(WCHAR));
ConfigEntry->Name[Length] = L'\0';
/* Allocate memory for the option value */
Length = RtlWideStringLength(OptionValue, 0);
Length = RTL::WideString::WideStringLength(OptionValue, 0);
Status = BlAllocateMemoryPool((Length + 1) * sizeof(WCHAR), (PVOID *)&ConfigEntry->Value);
if(Status != STATUS_EFI_SUCCESS)
{
@@ -319,11 +319,11 @@ BlSetBootOptionValue(IN PLIST_ENTRY Options,
}
/* Copy the value and NULL-terminate the new string */
RtlCopyMemory(ConfigEntry->Value, OptionValue, Length * sizeof(WCHAR));
RTL::Memory::CopyMemory(ConfigEntry->Value, OptionValue, Length * sizeof(WCHAR));
ConfigEntry->Value[Length] = L'\0';
/* Insert the new config entry at the end of the options list */
RtlInsertTailList(Options, &ConfigEntry->Flink);
RTL::LinkedList::InsertTailList(Options, &ConfigEntry->Flink);
/* Return success */
return STATUS_EFI_SUCCESS;
@@ -353,7 +353,7 @@ BlSetConfigValue(IN PCWSTR ConfigName,
SIZE_T Length;
/* Get config entry name length */
Length = RtlWideStringLength(ConfigName, 0);
Length = RTL::WideString::WideStringLength(ConfigName, 0);
/* Iterate through config entries */
ConfigListEntry = BlpConfig.Flink;
@@ -363,10 +363,10 @@ BlSetConfigValue(IN PCWSTR ConfigName,
ConfigEntry = CONTAIN_RECORD(ConfigListEntry, XTBL_CONFIG_ENTRY, Flink);
/* Check if requested configuration found */
if(RtlCompareWideStringInsensitive(ConfigEntry->Name, ConfigName, Length) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ConfigEntry->Name, ConfigName, Length) == 0)
{
/* Check new config value length */
Length = RtlWideStringLength(ConfigValue, 0);
Length = RTL::WideString::WideStringLength(ConfigValue, 0);
/* Reallocate memory for new config value */
Status = BlFreeMemoryPool(ConfigEntry->Value);
@@ -384,7 +384,7 @@ BlSetConfigValue(IN PCWSTR ConfigName,
}
/* Update config value */
RtlCopyMemory(ConfigEntry->Value, ConfigValue, Length * sizeof(WCHAR));
RTL::Memory::CopyMemory(ConfigEntry->Value, ConfigValue, Length * sizeof(WCHAR));
ConfigEntry->Value[Length] = L'\0';
/* Return success */
@@ -415,7 +415,7 @@ BlpLoadConfiguration()
PCHAR ConfigData;
/* Initialize configuration pointer */
RtlInitializeListHead(&BlpConfigSections);
RTL::LinkedList::InitializeListHead(&BlpConfigSections);
/* Read data from configuration file */
Status = BlpReadConfigFile(XTBL_LOADER_DIRECTORY_PATH, L"XTLDR.INI", &ConfigData);
@@ -450,13 +450,13 @@ BlpLoadConfiguration()
PXTBL_CONFIG_SECTION Section = CONTAIN_RECORD(SectionListEntry, XTBL_CONFIG_SECTION, Flink);
/* Look for global XTLDR configuration section */
if(RtlCompareWideStringInsensitive(Section->SectionName, L"XTLDR", 5) == 0)
if(RTL::WideString::CompareWideStringInsensitive(Section->SectionName, L"XTLDR", 5) == 0)
{
/* Update global configuration */
BlpUpdateConfiguration(&Section->Options);
/* Remove XTLDR section from the list */
RtlRemoveEntryList(SectionListEntry);
RTL::LinkedList::RemoveEntryList(SectionListEntry);
break;
}
@@ -491,7 +491,7 @@ BlpParseCommandLine(VOID)
LIST_ENTRY Config;
/* Initialize configuration list */
RtlInitializeListHead(&Config);
RTL::LinkedList::InitializeListHead(&Config);
/* Handle loaded image protocol */
Status = EfiSystemTable->BootServices->HandleProtocol(EfiImageHandle, &LIPGuid, (PVOID *)&LoadedImage);
@@ -501,7 +501,7 @@ BlpParseCommandLine(VOID)
if(LoadedImage && LoadedImage->LoadOptions)
{
/* Tokenize provided options */
Argument = RtlTokenizeWideString((PWCHAR)LoadedImage->LoadOptions, L" ", &LastArg);
Argument = RTL::WideString::TokenizeWideString((PWCHAR)LoadedImage->LoadOptions, L" ", &LastArg);
/* Iterate over all arguments passed to boot loader */
while(Argument != NULLPTR)
@@ -535,8 +535,8 @@ BlpParseCommandLine(VOID)
Argument++;
/* Get length of the key and its value */
KeyLength = RtlWideStringLength(Key, 0);
ValueLength = RtlWideStringLength(Value, 0);
KeyLength = RTL::WideString::WideStringLength(Key, 0);
ValueLength = RTL::WideString::WideStringLength(Value, 0);
/* Check if argument is valid */
if(KeyLength == 0 || ValueLength == 0)
@@ -564,16 +564,16 @@ BlpParseCommandLine(VOID)
}
/* Set entry name and value */
RtlCopyMemory(Option->Name, Key, (KeyLength * sizeof(WCHAR)));
RtlCopyMemory(Option->Value, Value, (ValueLength * sizeof(WCHAR)));
RTL::Memory::CopyMemory(Option->Name, Key, (KeyLength * sizeof(WCHAR)));
RTL::Memory::CopyMemory(Option->Value, Value, (ValueLength * sizeof(WCHAR)));
Option->Name[KeyLength] = L'\0';
Option->Value[ValueLength] = L'\0';
/* Add entry to the list */
RtlInsertTailList(&Config, &Option->Flink);
RTL::LinkedList::InsertTailList(&Config, &Option->Flink);
/* Take next argument */
Argument = RtlTokenizeWideString(NULLPTR, L" ", &LastArg);
Argument = RTL::WideString::TokenizeWideString(NULLPTR, L" ", &LastArg);
}
/* Update global configuration */
@@ -661,10 +661,10 @@ BlpParseConfigFile(IN CONST PCHAR RawConfig,
InputData++;
/* Remove leading and trailing spaces from section name */
SectionName = RtlTrimString(SectionName);
SectionName = RTL::String::TrimString(SectionName);
/* Find length of the section name */
SectionLength = RtlStringLength(SectionName, 0);
SectionLength = RTL::String::StringLength(SectionName, 0);
/* Allocate memory for new section */
Status = BlAllocateMemoryPool(sizeof(XTBL_CONFIG_SECTION), (PVOID*)&Section);
@@ -680,12 +680,12 @@ BlpParseConfigFile(IN CONST PCHAR RawConfig,
}
/* Initialize new section and convert its name to wide string */
RtlInitializeListHead(&Section->Options);
RtlStringToWideString(Section->SectionName, (PCSTR*)&SectionName, SectionLength);
RTL::LinkedList::InitializeListHead(&Section->Options);
RTL::String::StringToWideString(Section->SectionName, (PCSTR*)&SectionName, SectionLength);
/* Ensure string is NULL-terminated and add new section to the configuration list */
Section->SectionName[SectionLength] = L'\0';
RtlInsertTailList(Configuration, &Section->Flink);
RTL::LinkedList::InsertTailList(Configuration, &Section->Flink);
}
else
{
@@ -732,12 +732,12 @@ BlpParseConfigFile(IN CONST PCHAR RawConfig,
InputData++;
/* Remove leading and trailing spaces from key and value */
Key = RtlTrimString(Key);
Value = RtlTrimString(Value);
Key = RTL::String::TrimString(Key);
Value = RTL::String::TrimString(Value);
/* Find length of the key and its value */
KeyLength = RtlStringLength(Key, 0);
ValueLength = RtlStringLength(Value, 0);
KeyLength = RTL::String::StringLength(Key, 0);
ValueLength = RTL::String::StringLength(Value, 0);
/* Allocate memory for new option */
Status = BlAllocateMemoryPool(sizeof(XTBL_CONFIG_ENTRY), (PVOID*)&Option);
@@ -770,13 +770,13 @@ BlpParseConfigFile(IN CONST PCHAR RawConfig,
}
/* Convert key and value to wide strings */
RtlStringToWideString(Option->Name, (PCSTR*)&Key, RtlStringLength(Key, 0) + 1);
RtlStringToWideString(Option->Value, (PCSTR*)&Value, RtlStringLength(Value, 0) + 1);
RTL::String::StringToWideString(Option->Name, (PCSTR*)&Key, RTL::String::StringLength(Key, 0) + 1);
RTL::String::StringToWideString(Option->Value, (PCSTR*)&Value, RTL::String::StringLength(Value, 0) + 1);
/* Ensure strings are NULL-terminated and add new option to the list */
Option->Name[KeyLength] = L'\0';
Option->Value[ValueLength] = L'\0';
RtlInsertTailList(&Section->Options, &Option->Flink);
RTL::LinkedList::InsertTailList(&Section->Options, &Option->Flink);
}
}
@@ -875,8 +875,8 @@ BlpUpdateConfiguration(IN PLIST_ENTRY NewConfig)
if(ConfigValue == NULLPTR)
{
/* Remove new config entry from input list and put it into global config list */
RtlRemoveEntryList(&ConfigEntry->Flink);
RtlInsertTailList(&BlpConfig, &ConfigEntry->Flink);
RTL::LinkedList::RemoveEntryList(&ConfigEntry->Flink);
RTL::LinkedList::InsertTailList(&BlpConfig, &ConfigEntry->Flink);
}
/* Move to the next new config entry */

View File

@@ -109,16 +109,16 @@ BlConsolePrint(IN PCWSTR Format,
VA_START(Arguments, Format);
/* Format and print the string to the stdout */
RtlFormatWideString(&ConsolePrintContext, (PWCHAR)Format, Arguments);
RTL::WideString::FormatWideString(&ConsolePrintContext, (PWCHAR)Format, Arguments);
/* Print to serial console only if not running under OVMF */
if(RtlCompareWideString(EfiSystemTable->FirmwareVendor, L"EDK II", 6) != 0)
if(RTL::WideString::CompareWideString(EfiSystemTable->FirmwareVendor, L"EDK II", 6) != 0)
{
/* Check if debugging enabled and if EFI serial port is fully initialized */
if(DEBUG && (BlpStatus.SerialPort.Flags & COMPORT_FLAG_INIT))
{
/* Format and print the string to the serial console */
RtlFormatWideString(&SerialPrintContext, (PWCHAR)Format, Arguments);
RTL::WideString::FormatWideString(&SerialPrintContext, (PWCHAR)Format, Arguments);
}
}

View File

@@ -44,14 +44,14 @@ BlDebugPrint(IN PCWSTR Format,
if((BlpStatus.DebugPort & XTBL_DEBUGPORT_SERIAL) && (BlpStatus.SerialPort.Flags & COMPORT_FLAG_INIT))
{
/* Format and print the string to the serial console */
RtlFormatWideString(&SerialPrintContext, (PWCHAR)Format, Arguments);
RTL::WideString::FormatWideString(&SerialPrintContext, (PWCHAR)Format, Arguments);
}
/* Check if screen debug port is enabled and Boot Services are still available */
if((BlpStatus.DebugPort & XTBL_DEBUGPORT_SCREEN) && (BlpStatus.BootServices == TRUE))
{
/* Format and print the string to the screen */
RtlFormatWideString(&ConsolePrintContext, (PWCHAR)Format, Arguments);
RTL::WideString::FormatWideString(&ConsolePrintContext, (PWCHAR)Format, Arguments);
}
/* Clean up the va_list */
@@ -78,7 +78,7 @@ BlpDebugPutChar(IN WCHAR Character)
/* Write character to the serial console */
Buffer[0] = Character;
Buffer[1] = 0;
return HlWriteComPort(&BlpStatus.SerialPort, Buffer[0]);
return HL::ComPort::WriteComPort(&BlpStatus.SerialPort, Buffer[0]);
}
/**
@@ -108,13 +108,13 @@ BlpInitializeDebugConsole()
if(DebugConfiguration && BlpStatus.DebugPort == 0)
{
/* Find all debug ports */
DebugPort = RtlTokenizeWideString(DebugConfiguration, L";", &LastPort);
DebugPort = RTL::WideString::TokenizeWideString(DebugConfiguration, L";", &LastPort);
/* Iterate over all debug ports */
while(DebugPort != NULLPTR)
{
/* Check what port is set for debugging */
if(RtlCompareWideStringInsensitive(DebugPort, L"COM", 3) == 0)
if(RTL::WideString::CompareWideStringInsensitive(DebugPort, L"COM", 3) == 0)
{
/* Read COM port number */
DebugPort += 3;
@@ -127,7 +127,7 @@ BlpInitializeDebugConsole()
}
/* Check if custom COM port address supplied */
if(PortNumber == 0 && RtlCompareWideStringInsensitive(DebugPort, L":0x", 3) == 0)
if(PortNumber == 0 && RTL::WideString::CompareWideStringInsensitive(DebugPort, L":0x", 3) == 0)
{
/* COM port address provided */
DebugPort += 3;
@@ -170,7 +170,7 @@ BlpInitializeDebugConsole()
/* Enable debug port */
BlpStatus.DebugPort |= XTBL_DEBUGPORT_SERIAL;
}
else if(RtlCompareWideStringInsensitive(DebugPort, L"SCREEN", 5) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(DebugPort, L"SCREEN", 5) == 0)
{
/* Enable debug port */
BlpStatus.DebugPort |= XTBL_DEBUGPORT_SCREEN;
@@ -183,7 +183,7 @@ BlpInitializeDebugConsole()
}
/* Take next debug port */
DebugPort = RtlTokenizeWideString(NULLPTR, L";", &LastPort);
DebugPort = RTL::WideString::TokenizeWideString(NULLPTR, L";", &LastPort);
}
/* Check if serial debug port is enabled */
@@ -257,7 +257,7 @@ BlpInitializeSerialPort(IN ULONG PortNumber,
}
/* Initialize COM port */
Status = HlInitializeComPort(&BlpStatus.SerialPort, (PUCHAR)UlongToPtr(PortAddress), BaudRate);
Status = HL::ComPort::InitializeComPort(&BlpStatus.SerialPort, (PUCHAR)UlongToPtr(PortAddress), BaudRate);
/* Port not found under supplied address */
if(Status == STATUS_NOT_FOUND && PortAddress)
@@ -268,7 +268,7 @@ BlpInitializeSerialPort(IN ULONG PortNumber,
{
/* Try to reinitialize COM port */
BlConsolePrint(L"Enabled I/O space access for all PCI(E) serial controllers found\n");
Status = HlInitializeComPort(&BlpStatus.SerialPort, (PUCHAR)UlongToPtr(PortAddress), BaudRate);
Status = HL::ComPort::InitializeComPort(&BlpStatus.SerialPort, (PUCHAR)UlongToPtr(PortAddress), BaudRate);
}
}

View File

@@ -88,7 +88,7 @@ BlExitBootServices()
}
/* Zero fill the buffer and initialize counter */
RtlZeroMemory(MemoryMap, sizeof(EFI_MEMORY_MAP));
RTL::Memory::ZeroMemory(MemoryMap, sizeof(EFI_MEMORY_MAP));
Counter = 0xFF;
/* Attempt to exit boot services */
@@ -141,7 +141,7 @@ BlGetConfigurationTable(IN PEFI_GUID TableGuid,
for(Index = 0; Index < EfiSystemTable->NumberOfTableEntries; Index++)
{
/* Check if this table matches requested table */
if(RtlCompareGuids((PGUID)&(EfiSystemTable->ConfigurationTable[Index].VendorGuid), (PGUID)TableGuid))
if(RTL::Guid::CompareGuids((PGUID)&(EfiSystemTable->ConfigurationTable[Index].VendorGuid), (PGUID)TableGuid))
{
/* Found requested table, return success */
*Table = EfiSystemTable->ConfigurationTable[Index].VendorTable;

134
xtldr/includes/libxtos.hh Normal file
View File

@@ -0,0 +1,134 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/includes/libxtos.hh
* DESCRIPTION: XT Loader to LIBXTOS interface
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
*/
#ifndef __XTLDR_LIBXTOS_HH
#define __XTLDR_LIBXTOS_HH
#include <xtblapi.h>
/* Minimal forward references for AR classes used by XTLDR */
namespace AR
{
class CpuFunc
{
public:
STATIC XTCDECL BOOLEAN CpuId(IN OUT PCPUID_REGISTERS Registers);
STATIC XTCDECL ULONG_PTR ReadControlRegister(IN USHORT ControlRegister);
STATIC XTCDECL ULONGLONG ReadModelSpecificRegister(IN ULONG Register);
STATIC XTCDECL VOID WriteControlRegister(IN USHORT ControlRegister,
IN UINT_PTR Value);
};
}
/* Minimal forward references for HL classes used by XTLDR */
namespace HL
{
class ComPort
{
public:
STATIC XTCDECL XTSTATUS InitializeComPort(IN OUT PCPPORT Port,
IN PUCHAR PortAddress,
IN ULONG BaudRate);
STATIC XTCDECL XTSTATUS WriteComPort(IN PCPPORT Port,
IN UCHAR Byte);
};
class IoPort
{
public:
STATIC XTCDECL UCHAR ReadPort8(IN USHORT Port);
STATIC XTCDECL USHORT ReadPort16(IN USHORT Port);
STATIC XTCDECL ULONG ReadPort32(IN USHORT Port);
STATIC XTCDECL VOID WritePort8(IN USHORT Port,
IN UCHAR Value);
STATIC XTCDECL VOID WritePort16(IN USHORT Port,
IN USHORT Value);
STATIC XTCDECL VOID WritePort32(IN USHORT Port,
IN ULONG Value);
};
}
/* Minimal forward references for RTL classes used by XTLDR */
namespace RTL
{
class Guid
{
public:
STATIC XTAPI BOOLEAN CompareGuids(IN PGUID Guid1,
IN PGUID Guid2);
};
class LinkedList
{
public:
STATIC XTCDECL VOID InitializeListHead(IN PLIST_ENTRY ListHead);
STATIC XTCDECL VOID InsertHeadList(IN OUT PLIST_ENTRY ListHead,
IN PLIST_ENTRY Entry);
STATIC XTCDECL VOID InsertTailList(IN OUT PLIST_ENTRY ListHead,
IN PLIST_ENTRY Entry);
STATIC XTCDECL VOID RemoveEntryList(IN PLIST_ENTRY Entry);
};
class Memory
{
public:
STATIC XTAPI SIZE_T CompareMemory(IN PCVOID LeftBuffer,
IN PCVOID RightBuffer,
IN SIZE_T Length);
STATIC XTAPI VOID CopyMemory(OUT PVOID Destination,
IN PCVOID Source,
IN SIZE_T Length);
STATIC XTAPI VOID MoveMemory(OUT PVOID Destination,
IN PCVOID Source,
IN SIZE_T Length);
STATIC XTAPI VOID SetMemory(OUT PVOID Destination,
IN UCHAR Byte,
IN SIZE_T Length);
STATIC XTAPI VOID ZeroMemory(OUT PVOID Destination,
IN SIZE_T Length);
};
class String
{
public:
STATIC XTAPI SIZE_T CompareString(IN PCSTR String1,
IN PCSTR String2,
IN SIZE_T Length);
STATIC XTAPI SIZE_T StringLength(IN PCSTR String,
IN SIZE_T MaxLength);
STATIC XTAPI SIZE_T StringToWideString(OUT PWCHAR Destination,
IN PCSTR *Source,
IN SIZE_T Length);
STATIC XTAPI PCHAR TrimString(IN PCHAR String);
};
class WideString
{
public:
STATIC XTAPI SIZE_T CompareWideString(IN PCWSTR String1,
IN PCWSTR String2,
IN SIZE_T Length);
STATIC XTAPI SIZE_T CompareWideStringInsensitive(IN PCWSTR String1,
IN PCWSTR String2,
IN SIZE_T Length);
STATIC XTAPI PWCHAR ConcatenateWideString(OUT PWCHAR Destination,
IN PWCHAR Source,
IN SIZE_T Count);
STATIC XTAPI XTSTATUS FormatWideString(IN PRTL_PRINT_CONTEXT Context,
IN PCWSTR Format,
IN VA_LIST ArgumentList);
STATIC XTAPI PWCHAR TokenizeWideString(IN PWCHAR String,
IN PCWSTR Delimiter,
IN OUT PWCHAR *SavePtr);
STATIC XTAPI SIZE_T WideStringLength(IN PCWSTR String,
IN SIZE_T MaxLength);
};
}
#endif /* __XTLDR_LIBXTOS_HH */

View File

@@ -12,6 +12,7 @@
#include <xtblapi.h>
#include <xtver.h>
#include <libxtos.hh>
#include <globals.hh>

View File

@@ -248,7 +248,7 @@ BlInitializePageMap(OUT PXTBL_PAGE_MAPPING PageMap,
IN PAGE_SIZE PageSize)
{
/* Initialize memory mappings */
RtlInitializeListHead(&PageMap->MemoryMap);
RTL::LinkedList::InitializeListHead(&PageMap->MemoryMap);
PageMap->MapSize = 0;
/* Set page map size/level and memory map address */
@@ -298,7 +298,7 @@ BlMapEfiMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
/* Allocate and zero-fill buffer for EFI memory map */
BlAllocateMemoryPool(sizeof(EFI_MEMORY_MAP), (PVOID*)&MemoryMap);
RtlZeroMemory(MemoryMap, sizeof(EFI_MEMORY_MAP));
RTL::Memory::ZeroMemory(MemoryMap, sizeof(EFI_MEMORY_MAP));
/* Get EFI memory map */
Status = BlGetMemoryMap(MemoryMap);
@@ -503,7 +503,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
Mapping3->VirtualAddress = NULLPTR;
Mapping3->NumberOfPages = NumberOfMappedPages;
Mapping3->MemoryType = Mapping2->MemoryType;
RtlInsertHeadList(&Mapping2->ListEntry, &Mapping3->ListEntry);
RTL::LinkedList::InsertHeadList(&Mapping2->ListEntry, &Mapping3->ListEntry);
}
/* Calculate number of pages and the end of the physical address */
@@ -539,7 +539,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
Mapping3->VirtualAddress = NULLPTR;
Mapping3->NumberOfPages = NumberOfMappedPages;
Mapping3->MemoryType = Mapping2->MemoryType;
RtlInsertHeadList(&Mapping2->ListEntry, &Mapping3->ListEntry);
RTL::LinkedList::InsertHeadList(&Mapping2->ListEntry, &Mapping3->ListEntry);
}
/* Calculate number of pages and the end of the physical address */
@@ -563,7 +563,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
MappingListEntry = ListEntry->Flink;
/* Remove mapping from the list and free up it's memory */
RtlRemoveEntryList(&Mapping2->ListEntry);
RTL::LinkedList::RemoveEntryList(&Mapping2->ListEntry);
Status = BlFreeMemoryPool(Mapping2);
ListEntry = MappingListEntry;
@@ -575,7 +575,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
if(Mapping2->PhysicalAddress > Mapping1->PhysicalAddress)
{
/* Insert new mapping in front */
RtlInsertHeadList(Mapping2->ListEntry.Blink, &Mapping1->ListEntry);
RTL::LinkedList::InsertHeadList(Mapping2->ListEntry.Blink, &Mapping1->ListEntry);
return STATUS_EFI_SUCCESS;
}
@@ -584,7 +584,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
}
/* Insert new mapping to the list and increase page map size */
RtlInsertTailList(&PageMap->MemoryMap, &Mapping1->ListEntry);
RTL::LinkedList::InsertTailList(&PageMap->MemoryMap, &Mapping1->ListEntry);
PageMap->MapSize++;
/* Return success */

View File

@@ -189,11 +189,11 @@ Acpi::GetApicBase(OUT PVOID *ApicBase)
CPUID_REGISTERS CpuRegisters;
/* Prepare CPUID registers to query for APIC support */
RtlZeroMemory(&CpuRegisters, sizeof(CPUID_REGISTERS));
XtLdrProtocol->Memory.ZeroMemory(&CpuRegisters, sizeof(CPUID_REGISTERS));
CpuRegisters.Leaf = CPUID_GET_STANDARD1_FEATURES;
/* Query CPUID */
ArCpuId(&CpuRegisters);
XtLdrProtocol->Cpu.CpuId(&CpuRegisters);
/* Check if APIC present */
if((CpuRegisters.Edx & CPUID_FEATURES_EDX_APIC) == 0)
@@ -203,7 +203,7 @@ Acpi::GetApicBase(OUT PVOID *ApicBase)
}
/* Get APIC base address */
*ApicBase = (PVOID)((UINT_PTR)ArReadModelSpecificRegister(0x1B) & 0xFFFFF000);
*ApicBase = (PVOID)((UINT_PTR)XtLdrProtocol->Cpu.ReadModelSpecificRegister(0x1B) & 0xFFFFF000);
/* Return success */
return STATUS_EFI_SUCCESS;

View File

@@ -30,8 +30,8 @@ Beep::DisableToneBeep()
UCHAR Status;
/* Stop the PC speaker */
Status = HlReadPort8(0x61);
HlWritePort8(0x61, Status & 0xFC);
Status = XtLdrProtocol->IoPort.Read8(0x61);
XtLdrProtocol->IoPort.Write8(0x61, Status & 0xFC);
}
/**
@@ -63,14 +63,14 @@ Beep::EnableToneBeep(IN UINT Pitch)
/* Set the desired frequency of the PIT clock */
Counter = 0x1234DD / Pitch;
HlWritePort8(0x43, 0xB6);
HlWritePort8(0x43, 0xB6);
HlWritePort8(0x42, (UCHAR) Counter & 0xFF);
HlWritePort8(0x42, (UCHAR) (Counter >> 8) & 0xFF);
XtLdrProtocol->IoPort.Write8(0x43, 0xB6);
XtLdrProtocol->IoPort.Write8(0x43, 0xB6);
XtLdrProtocol->IoPort.Write8(0x42, (UCHAR) Counter & 0xFF);
XtLdrProtocol->IoPort.Write8(0x42, (UCHAR) (Counter >> 8) & 0xFF);
/* Start the PC speaker */
Status = HlReadPort8(0x61);
HlWritePort8(0x61, Status | 0x03);
Status = XtLdrProtocol->IoPort.Read8(0x61);
XtLdrProtocol->IoPort.Write8(0x61, Status | 0x03);
}
/**
@@ -133,7 +133,7 @@ Beep::PlayTune(IN PWCHAR Arguments)
Tempo = -1;
/* Tokenize provided list of arguments */
Argument = RtlTokenizeWideString(Arguments, L" ", &LastArgument);
Argument = XtLdrProtocol->WideString.Tokenize(Arguments, L" ", &LastArgument);
/* Iterate over all arguments */
while(Argument != NULLPTR)
@@ -175,7 +175,7 @@ Beep::PlayTune(IN PWCHAR Arguments)
}
/* Get next argument */
Argument = RtlTokenizeWideString(NULLPTR, L" ", &LastArgument);
Argument = XtLdrProtocol->WideString.Tokenize(NULLPTR, L" ", &LastArgument);
}
/* Stop emitting beep tone */

View File

@@ -113,7 +113,7 @@ ChainLoader::BootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
if(Parameters->Parameters)
{
/* Pass arguments to chainloaded image */
LoadedImage->LoadOptionsSize = RtlWideStringLength(Parameters->Parameters, 0) * sizeof(WCHAR);
LoadedImage->LoadOptionsSize = XtLdrProtocol->WideString.Length(Parameters->Parameters, 0) * sizeof(WCHAR);
LoadedImage->LoadOptions = Parameters->Parameters;
}

View File

@@ -219,13 +219,13 @@ PeCoff::GetSection(IN PVOID ImagePointer,
}
/* Get section name length */
SectionNameLength = RtlStringLength(SectionName, 0);
SectionNameLength = XtLdrProtocol->String.Length(SectionName, 0);
/* Iterate through all image sections */
for(SectionIndex = 0; SectionIndex < Image->PeHeader->FileHeader.NumberOfSections; SectionIndex++)
{
/* Check section name */
if(RtlCompareString((PCHAR)SectionHeader[SectionIndex].Name, SectionName, SectionNameLength) == 0)
if(XtLdrProtocol->String.Compare((PCHAR)SectionHeader[SectionIndex].Name, SectionName, SectionNameLength) == 0)
{
/* Store section address and return */
*RawData = (PULONG)((PUCHAR)Image->Data + SectionHeader[SectionIndex].PointerToRawData);

View File

@@ -27,21 +27,21 @@ Xtos::DeterminePagingLevel(IN CONST PWCHAR Parameters)
CPUID_REGISTERS CpuRegisters;
/* Prepare CPUID registers to query for STD7 features */
RtlZeroMemory(&CpuRegisters, sizeof(CPUID_REGISTERS));
XtLdrProtocol->Memory.ZeroMemory(&CpuRegisters, sizeof(CPUID_REGISTERS));
CpuRegisters.Leaf = CPUID_GET_VENDOR_STRING;
/* Query CPUID */
ArCpuId(&CpuRegisters);
XtLdrProtocol->Cpu.CpuId(&CpuRegisters);
/* Verify if the CPU supports the STD7 feature leaf (0x00000007) */
if(CpuRegisters.Eax >= CPUID_GET_STANDARD7_FEATURES)
{
/* Prepare CPUID registers to query for LA57 support */
RtlZeroMemory(&CpuRegisters, sizeof(CPUID_REGISTERS));
XtLdrProtocol->Memory.ZeroMemory(&CpuRegisters, sizeof(CPUID_REGISTERS));
CpuRegisters.Leaf = CPUID_GET_STANDARD7_FEATURES;
/* Query CPUID */
ArCpuId(&CpuRegisters);
XtLdrProtocol->Cpu.CpuId(&CpuRegisters);
/* Check if eXtended Physical Addressing (XPA) is enabled and if LA57 is supported by the CPU */
if((CpuRegisters.Ecx & CPUID_FEATURES_ECX_LA57) &&
@@ -113,7 +113,7 @@ Xtos::EnablePaging(IN PXTBL_PAGE_MAPPING PageMap)
/* Set the trampoline entry point and copy its code into the allocated buffer */
TrampolineEntry = (PXT_TRAMPOLINE_ENTRY)(UINT_PTR)TrampolineAddress;
RtlCopyMemory((PVOID)TrampolineEntry, (PVOID)ArEnableExtendedPhysicalAddressing, TrampolineSize);
XtLdrProtocol->Memory.CopyMemory((PVOID)TrampolineEntry, (PVOID)ArEnableExtendedPhysicalAddressing, TrampolineSize);
}
/* Exit EFI Boot Services */
@@ -141,8 +141,8 @@ Xtos::EnablePaging(IN PXTBL_PAGE_MAPPING PageMap)
XtLdrProtocol->Debug.Print(L"Disabling Linear Address 57-bit (LA57)\n");
/* Write PML4 to CR3 and enable paging */
ArWriteControlRegister(3, (UINT_PTR)PageMap->PtePointer);
ArWriteControlRegister(0, ArReadControlRegister(0) | CR0_PG);
XtLdrProtocol->Cpu.WriteControlRegister(3, (UINT_PTR)PageMap->PtePointer);
XtLdrProtocol->Cpu.WriteControlRegister(0, XtLdrProtocol->Cpu.ReadControlRegister(0) | CR0_PG);
}
/* Return success */
@@ -184,7 +184,7 @@ Xtos::MapHardwareMemoryPool(IN PXTBL_PAGE_MAPPING PageMap)
}
/* Zero fill memory used by P5E */
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
XtLdrProtocol->Memory.ZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
/* Make P5E valid */
P5eBase[(MM_HARDWARE_VA_START >> MM_P5I_SHIFT) & 0x1FF].Valid = 1;
@@ -218,7 +218,7 @@ Xtos::MapHardwareMemoryPool(IN PXTBL_PAGE_MAPPING PageMap)
}
/* Zero fill memory used by PXE */
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
XtLdrProtocol->Memory.ZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
/* Make PXE valid */
PxeBase[(MM_HARDWARE_VA_START >> MM_PXI_SHIFT) & 0x1FF].Valid = 1;
@@ -246,7 +246,7 @@ Xtos::MapHardwareMemoryPool(IN PXTBL_PAGE_MAPPING PageMap)
}
/* Zero fill memory used by PPE */
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
XtLdrProtocol->Memory.ZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
/* Make PPE valid */
PpeBase[(MM_HARDWARE_VA_START >> MM_PPI_SHIFT) & 0x1FF].Valid = 1;
@@ -277,7 +277,7 @@ Xtos::MapHardwareMemoryPool(IN PXTBL_PAGE_MAPPING PageMap)
}
/* Zero fill memory used by PDE */
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
XtLdrProtocol->Memory.ZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
/* Make PDE valid */
PdeBase[((MM_HARDWARE_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].Valid = 1;

View File

@@ -122,7 +122,7 @@ Xtos::BootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
}
/* System path has to point to the boot directory */
RtlConcatenateWideString(Parameters->SystemPath, (PWCHAR)L"\\Boot", 0);
XtLdrProtocol->WideString.Concatenate(Parameters->SystemPath, (PWCHAR)L"\\Boot", 0);
/* Open XTOS system boot directory */
Status = FsHandle->Open(FsHandle, &BootDir, Parameters->SystemPath, EFI_FILE_MODE_READ, 0);
@@ -226,7 +226,7 @@ Xtos::GetMemoryDescriptorList(IN PXTBL_PAGE_MAPPING PageMap,
MemoryDescriptor->BasePage = (UINT_PTR)MemoryMapping->PhysicalAddress / EFI_PAGE_SIZE;
MemoryDescriptor->PageCount = MemoryMapping->NumberOfPages;
RtlInsertTailList(MemoryDescriptorList, &MemoryDescriptor->ListEntry);
XtLdrProtocol->LinkedList.InsertTail(MemoryDescriptorList, &MemoryDescriptor->ListEntry);
Address = Address + sizeof(LOADER_MEMORY_DESCRIPTOR);
ListEntry = ListEntry->Flink;
@@ -281,7 +281,7 @@ Xtos::GetSystemResourcesList(IN PXTBL_PAGE_MAPPING PageMap,
AcpiResource = (PSYSTEM_RESOURCE_ACPI)Address;
RtlZeroMemory(AcpiResource, sizeof(SYSTEM_RESOURCE_ACPI));
XtLdrProtocol->Memory.ZeroMemory(AcpiResource, sizeof(SYSTEM_RESOURCE_ACPI));
/* Load FrameBuffer protocol */
Status = XtLdrProtocol->Protocol.Open(&ProtocolHandle, (PVOID*)&AcpiProtocol, &AcpiGuid);
@@ -300,7 +300,7 @@ Xtos::GetSystemResourcesList(IN PXTBL_PAGE_MAPPING PageMap,
/* No need to map ACPI */
AcpiResource->Header.VirtualAddress = 0;
RtlInsertTailList(SystemResourcesList, &AcpiResource->Header.ListEntry);
XtLdrProtocol->LinkedList.InsertTail(SystemResourcesList, &AcpiResource->Header.ListEntry);
/* Close FrameBuffer protocol */
XtLdrProtocol->Protocol.Close(&ProtocolHandle, &FrameBufGuid);
@@ -309,7 +309,7 @@ Xtos::GetSystemResourcesList(IN PXTBL_PAGE_MAPPING PageMap,
FrameBufferResource = (PSYSTEM_RESOURCE_FRAMEBUFFER)Address;
RtlZeroMemory(FrameBufferResource, sizeof(SYSTEM_RESOURCE_FRAMEBUFFER));
XtLdrProtocol->Memory.ZeroMemory(FrameBufferResource, sizeof(SYSTEM_RESOURCE_FRAMEBUFFER));
/* Load FrameBuffer protocol */
Status = XtLdrProtocol->Protocol.Open(&ProtocolHandle, (PVOID*)&FrameBufProtocol, &FrameBufGuid);
@@ -345,7 +345,7 @@ Xtos::GetSystemResourcesList(IN PXTBL_PAGE_MAPPING PageMap,
*VirtualAddress = (PUINT8)*VirtualAddress + (FrameBufferPages * EFI_PAGE_SIZE);
RtlInsertTailList(SystemResourcesList, &FrameBufferResource->Header.ListEntry);
XtLdrProtocol->LinkedList.InsertTail(SystemResourcesList, &FrameBufferResource->Header.ListEntry);
XtLdrProtocol->Memory.PhysicalListToVirtual(PageMap, SystemResourcesList, PhysicalBase, VirtualBase);
@@ -420,7 +420,7 @@ Xtos::InitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
UINT ParametersSize;
/* Calculate size of parameters */
ParametersSize = (RtlWideStringLength(Parameters->Parameters, 0) + 1) * sizeof(WCHAR);
ParametersSize = (XtLdrProtocol->WideString.Length(Parameters->Parameters, 0) + 1) * sizeof(WCHAR);
/* Calculate number of pages needed for initialization block */
BlockPages = EFI_SIZE_TO_PAGES(sizeof(KERNEL_INITIALIZATION_BLOCK) + ParametersSize);
@@ -435,7 +435,7 @@ Xtos::InitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
/* Initialize and zero-fill kernel initialization block */
LoaderBlock = (PKERNEL_INITIALIZATION_BLOCK)(UINT_PTR)Address;
RtlZeroMemory(LoaderBlock, sizeof(KERNEL_INITIALIZATION_BLOCK) + ParametersSize);
XtLdrProtocol->Memory.ZeroMemory(LoaderBlock, sizeof(KERNEL_INITIALIZATION_BLOCK) + ParametersSize);
/* Set basic loader block properties */
LoaderBlock->BlockSize = sizeof(KERNEL_INITIALIZATION_BLOCK);
@@ -462,7 +462,7 @@ Xtos::InitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
/* Copy parameters to kernel initialization block */
LoaderBlock->KernelParameters = (PWCHAR)((UINT_PTR)*VirtualAddress + sizeof(KERNEL_INITIALIZATION_BLOCK));
RtlCopyMemory((PVOID)((UINT_PTR)LoaderBlock + sizeof(KERNEL_INITIALIZATION_BLOCK)),
XtLdrProtocol->Memory.CopyMemory((PVOID)((UINT_PTR)LoaderBlock + sizeof(KERNEL_INITIALIZATION_BLOCK)),
Parameters->Parameters,
ParametersSize);
@@ -473,11 +473,11 @@ Xtos::InitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
/* Calculate next valid virtual address */
*VirtualAddress = (PUINT8)*VirtualAddress + (BlockPages * EFI_PAGE_SIZE);
RtlInitializeListHead(&LoaderBlock->SystemResourcesListHead);
XtLdrProtocol->LinkedList.InitializeHead(&LoaderBlock->SystemResourcesListHead);
GetSystemResourcesList(PageMap, VirtualAddress, &LoaderBlock->SystemResourcesListHead);
/* Initialize memory descriptor list */
RtlInitializeListHead(&LoaderBlock->MemoryDescriptorListHead);
XtLdrProtocol->LinkedList.InitializeHead(&LoaderBlock->MemoryDescriptorListHead);
GetMemoryDescriptorList(PageMap, VirtualAddress, &LoaderBlock->MemoryDescriptorListHead);
/* Return success */

View File

@@ -58,7 +58,7 @@ BlFindBootProtocol(IN PCWSTR SystemType,
ProtocolEntry = CONTAIN_RECORD(ProtocolListEntry, XTBL_KNOWN_BOOT_PROTOCOL, Flink);
/* Check if this boot protocol supports specified system */
if(RtlCompareWideStringInsensitive(ProtocolEntry->SystemType, SystemType, 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ProtocolEntry->SystemType, SystemType, 0) == 0)
{
/* Boot protocol matched, return success */
*BootProtocolGuid = ProtocolEntry->Guid;
@@ -152,7 +152,7 @@ BlLoadModule(IN PWCHAR ModuleName)
/* Get module information */
ModuleInfo = CONTAIN_RECORD(ModuleListEntry, XTBL_MODULE_INFO, Flink);
if(RtlCompareWideStringInsensitive(ModuleInfo->ModuleName, ModuleName, 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ModuleInfo->ModuleName, ModuleName, 0) == 0)
{
/* Module already loaded */
BlDebugPrint(L"WARNING: Module '%S' already loaded!\n", ModuleName);
@@ -167,8 +167,8 @@ BlLoadModule(IN PWCHAR ModuleName)
BlDebugPrint(L"Loading module '%S' ...\n", ModuleName);
/* Set module path */
RtlCopyMemory(ModuleFileName, ModuleName, (RtlWideStringLength(ModuleName, 0) + 1) * sizeof(WCHAR));
RtlConcatenateWideString(ModuleFileName, (PWCHAR)L".EFI", 0);
RTL::Memory::CopyMemory(ModuleFileName, ModuleName, (RTL::WideString::WideStringLength(ModuleName, 0) + 1) * sizeof(WCHAR));
RTL::WideString::ConcatenateWideString(ModuleFileName, (PWCHAR)L".EFI", 0);
/* Open EFI volume */
Status = BlOpenVolume(NULLPTR, &DiskHandle, &FsHandle);
@@ -218,7 +218,7 @@ BlLoadModule(IN PWCHAR ModuleName)
}
/* Zero module information block */
RtlZeroMemory(ModuleInfo, sizeof(XTBL_MODULE_INFO));
RTL::Memory::ZeroMemory(ModuleInfo, sizeof(XTBL_MODULE_INFO));
/* Setup PE/COFF EFI image headers */
DosHeader = (PPECOFF_IMAGE_DOS_HEADER)ModuleData;
@@ -241,7 +241,7 @@ BlLoadModule(IN PWCHAR ModuleName)
/* Look for .modinfo section */
for(SectionIndex = 0; SectionIndex < PeHeader->FileHeader.NumberOfSections; SectionIndex++)
{
if(RtlCompareString((PCHAR)SectionHeader[SectionIndex].Name, ".modinfo", 8) == 0)
if(RTL::String::CompareString((PCHAR)SectionHeader[SectionIndex].Name, ".modinfo", 8) == 0)
{
/* Module information section found */
SectionData = (PWCHAR)((PUCHAR)ModuleData + SectionHeader[SectionIndex].PointerToRawData);
@@ -358,7 +358,7 @@ BlLoadModule(IN PWCHAR ModuleName)
}
/* Add module to the list of loaded modules */
RtlInsertTailList(&BlpLoadedModules, &ModuleInfo->Flink);
RTL::LinkedList::InsertTailList(&BlpLoadedModules, &ModuleInfo->Flink);
/* Return success */
return STATUS_EFI_SUCCESS;
@@ -387,7 +387,7 @@ BlLoadModules(IN PWCHAR ModulesList)
if(ModulesList != NULLPTR)
{
/* Tokenize provided list of modules */
Module = RtlTokenizeWideString(ModulesList, L" ", &LastModule);
Module = RTL::WideString::TokenizeWideString(ModulesList, L" ", &LastModule);
/* Iterate over all arguments passed to boot loader */
while(Module != NULLPTR)
@@ -401,7 +401,7 @@ BlLoadModules(IN PWCHAR ModulesList)
}
/* Take next module from the list */
Module = RtlTokenizeWideString(NULLPTR, L" ", &LastModule);
Module = RTL::WideString::TokenizeWideString(NULLPTR, L" ", &LastModule);
}
}
@@ -575,7 +575,7 @@ BlRegisterBootProtocol(IN PCWSTR SystemType,
ProtocolEntry = CONTAIN_RECORD(ProtocolListEntry, XTBL_KNOWN_BOOT_PROTOCOL, Flink);
/* Check if boot protocol already registered for specified system */
if(RtlCompareWideStringInsensitive(ProtocolEntry->SystemType, SystemType, 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ProtocolEntry->SystemType, SystemType, 0) == 0)
{
/* Boot protocol already registered */
return STATUS_EFI_ABORTED;
@@ -596,7 +596,7 @@ BlRegisterBootProtocol(IN PCWSTR SystemType,
/* Set protocol properties and add it to the list */
ProtocolEntry->SystemType = (PWCHAR)SystemType;
ProtocolEntry->Guid = *BootProtocolGuid;
RtlInsertTailList(&BlpBootProtocols, &ProtocolEntry->Flink);
RTL::LinkedList::InsertTailList(&BlpBootProtocols, &ProtocolEntry->Flink);
/* Return success */
return STATUS_EFI_SUCCESS;
@@ -632,8 +632,8 @@ BlpGetModuleInformation(IN PWCHAR SectionData,
PWCHAR *Strings;
/* Initialize authors and dependencies lists */
RtlInitializeListHead(&ModuleInfo->Authors);
RtlInitializeListHead(&ModuleInfo->Dependencies);
RTL::LinkedList::InitializeListHead(&ModuleInfo->Authors);
RTL::LinkedList::InitializeListHead(&ModuleInfo->Dependencies);
/* Get information strings from '.modinfo' section */
Status = BlpGetModuleInfoStrings(SectionData, SectionSize, &Strings, &Count);
@@ -661,7 +661,7 @@ BlpGetModuleInformation(IN PWCHAR SectionData,
Strings[Index]++;
/* Parse information string key */
if(RtlCompareWideString(Key, L"author", 6) == 0)
if(RTL::WideString::CompareWideString(Key, L"author", 6) == 0)
{
/* Allocate memory for module author */
Status = BlAllocateMemoryPool(sizeof(XTBL_MODULE_AUTHORS), (PVOID*)&ModuleAuthors);
@@ -673,22 +673,22 @@ BlpGetModuleInformation(IN PWCHAR SectionData,
/* Store module's author */
ModuleAuthors->AuthorName = Strings[Index];
RtlInsertTailList(&ModuleInfo->Authors, &ModuleAuthors->Flink);
RTL::LinkedList::InsertTailList(&ModuleInfo->Authors, &ModuleAuthors->Flink);
}
else if(RtlCompareWideString(Key, L"description", 11) == 0)
else if(RTL::WideString::CompareWideString(Key, L"description", 11) == 0)
{
/* Store module's description */
ModuleInfo->ModuleDescription = Strings[Index];
}
else if(RtlCompareWideString(Key, L"license", 7) == 0)
else if(RTL::WideString::CompareWideString(Key, L"license", 7) == 0)
{
/* Store module's license */
ModuleInfo->License = Strings[Index];
}
else if(RtlCompareWideString(Key, L"softdeps", 6) == 0)
else if(RTL::WideString::CompareWideString(Key, L"softdeps", 6) == 0)
{
/* Tokenize value to get module's single dependency */
Dependency = RtlTokenizeWideString(Strings[Index], L" ", &LastStr);
Dependency = RTL::WideString::TokenizeWideString(Strings[Index], L" ", &LastStr);
while(Dependency != NULLPTR)
{
/* Allocate memory for module dependency */
@@ -701,13 +701,13 @@ BlpGetModuleInformation(IN PWCHAR SectionData,
/* Store module's dependency */
ModuleDependencies->ModuleName = Dependency;
RtlInsertTailList(&ModuleInfo->Dependencies, &ModuleDependencies->Flink);
RTL::LinkedList::InsertTailList(&ModuleInfo->Dependencies, &ModuleDependencies->Flink);
/* Get next dependency from single value if available */
Dependency = RtlTokenizeWideString(NULLPTR, L" ", &LastStr);
Dependency = RTL::WideString::TokenizeWideString(NULLPTR, L" ", &LastStr);
}
}
else if(RtlCompareWideString(Key, L"version", 7) == 0)
else if(RTL::WideString::CompareWideString(Key, L"version", 7) == 0)
{
/* Store module's version */
ModuleInfo->Version = Strings[Index];
@@ -812,7 +812,7 @@ BlpGetModuleInfoStrings(IN PWCHAR SectionData,
String = (PWCHAR)(Array + Count + 1);
/* Copy the raw string data */
RtlCopyMemory(String, InfoStrings, DataSize * sizeof(WCHAR));
RTL::Memory::CopyMemory(String, InfoStrings, DataSize * sizeof(WCHAR));
/* Ensure the entire buffer is NULL-terminated for safety */
String[DataSize] = L'\0';
@@ -885,14 +885,29 @@ BlpInstallXtLoaderProtocol()
BlpLdrProtocol.Console.SetAttributes = BlSetConsoleAttributes;
BlpLdrProtocol.Console.SetCursorPosition = BlSetCursorPosition;
BlpLdrProtocol.Console.Write = BlConsoleWrite;
BlpLdrProtocol.Cpu.CpuId = AR::CpuFunc::CpuId;
BlpLdrProtocol.Cpu.ReadControlRegister = AR::CpuFunc::ReadControlRegister;
BlpLdrProtocol.Cpu.ReadModelSpecificRegister = AR::CpuFunc::ReadModelSpecificRegister;
BlpLdrProtocol.Cpu.WriteControlRegister = AR::CpuFunc::WriteControlRegister;
BlpLdrProtocol.Debug.Print = BlDebugPrint;
BlpLdrProtocol.Disk.CloseVolume = BlCloseVolume;
BlpLdrProtocol.Disk.OpenVolume = BlOpenVolume;
BlpLdrProtocol.Disk.ReadFile = BlReadFile;
BlpLdrProtocol.IoPort.Read8 = HL::IoPort::ReadPort8;
BlpLdrProtocol.IoPort.Read16 = HL::IoPort::ReadPort16;
BlpLdrProtocol.IoPort.Read32 = HL::IoPort::ReadPort32;
BlpLdrProtocol.IoPort.Write8 = HL::IoPort::WritePort8;
BlpLdrProtocol.IoPort.Write16 = HL::IoPort::WritePort16;
BlpLdrProtocol.IoPort.Write32 = HL::IoPort::WritePort32;
BlpLdrProtocol.LinkedList.InitializeHead = RTL::LinkedList::InitializeListHead;
BlpLdrProtocol.LinkedList.InsertHead = RTL::LinkedList::InsertHeadList;
BlpLdrProtocol.LinkedList.InsertTail = RTL::LinkedList::InsertTailList;
BlpLdrProtocol.LinkedList.RemoveEntry = RTL::LinkedList::RemoveEntryList;
BlpLdrProtocol.Memory.AllocatePages = BlAllocateMemoryPages;
BlpLdrProtocol.Memory.AllocatePool = BlAllocateMemoryPool;
BlpLdrProtocol.Memory.BuildPageMap = BlBuildPageMap;
BlpLdrProtocol.Memory.CopyMemory = RtlCopyMemory;
BlpLdrProtocol.Memory.CompareMemory = RTL::Memory::CompareMemory;
BlpLdrProtocol.Memory.CopyMemory = RTL::Memory::CopyMemory;
BlpLdrProtocol.Memory.FreePages = BlFreeMemoryPages;
BlpLdrProtocol.Memory.FreePool = BlFreeMemoryPool;
BlpLdrProtocol.Memory.GetMappingsCount = BlGetMappingsCount;
@@ -902,16 +917,21 @@ BlpInstallXtLoaderProtocol()
BlpLdrProtocol.Memory.MapEfiMemory = BlMapEfiMemory;
BlpLdrProtocol.Memory.MapPage = BlMapPage;
BlpLdrProtocol.Memory.MapVirtualMemory = BlMapVirtualMemory;
BlpLdrProtocol.Memory.MoveMemory = RTL::Memory::MoveMemory;
BlpLdrProtocol.Memory.PhysicalAddressToVirtual = BlPhysicalAddressToVirtual;
BlpLdrProtocol.Memory.PhysicalListToVirtual = BlPhysicalListToVirtual;
BlpLdrProtocol.Memory.SetMemory = RtlSetMemory;
BlpLdrProtocol.Memory.ZeroMemory = RtlZeroMemory;
BlpLdrProtocol.Memory.SetMemory = RTL::Memory::SetMemory;
BlpLdrProtocol.Memory.ZeroMemory = RTL::Memory::ZeroMemory;
BlpLdrProtocol.Protocol.Close = BlCloseProtocol;
BlpLdrProtocol.Protocol.GetModulesList = BlGetModulesList;
BlpLdrProtocol.Protocol.Install = BlInstallProtocol;
BlpLdrProtocol.Protocol.LocateHandles = BlLocateProtocolHandles;
BlpLdrProtocol.Protocol.Open = BlOpenProtocol;
BlpLdrProtocol.Protocol.OpenHandle = BlOpenProtocolHandle;
BlpLdrProtocol.String.Compare = RTL::String::CompareString;
BlpLdrProtocol.String.Length = RTL::String::StringLength;
BlpLdrProtocol.String.ToWideString = RTL::String::StringToWideString;
BlpLdrProtocol.String.Trim = RTL::String::TrimString;
BlpLdrProtocol.Tui.DisplayErrorDialog = BlDisplayErrorDialog;
BlpLdrProtocol.Tui.DisplayInfoDialog = BlDisplayInfoDialog;
BlpLdrProtocol.Tui.DisplayInputDialog = BlDisplayInputDialog;
@@ -931,6 +951,12 @@ BlpInstallXtLoaderProtocol()
BlpLdrProtocol.Util.SleepExecution = BlSleepExecution;
BlpLdrProtocol.Util.StartEfiImage = BlStartEfiImage;
BlpLdrProtocol.Util.WaitForEfiEvent = BlWaitForEfiEvent;
BlpLdrProtocol.WideString.Compare = RTL::WideString::CompareWideString;
BlpLdrProtocol.WideString.CompareInsensitive = RTL::WideString::CompareWideStringInsensitive;
BlpLdrProtocol.WideString.Concatenate = RTL::WideString::ConcatenateWideString;
BlpLdrProtocol.WideString.Format = RTL::WideString::FormatWideString;
BlpLdrProtocol.WideString.Length = RTL::WideString::WideStringLength;
BlpLdrProtocol.WideString.Tokenize = RTL::WideString::TokenizeWideString;
/* Register XTLDR loader protocol */
BlDebugPrint(L"Registering XT loader protocol\n");

View File

@@ -781,7 +781,7 @@ BlDisplayInputDialog(IN PCWSTR Caption,
Key.UnicodeChar = 0;
/* Determine input field length */
InputFieldLength = RtlWideStringLength(*InputFieldText, 0);
InputFieldLength = RTL::WideString::WideStringLength(*InputFieldText, 0);
/* Allocate a buffer for storing the input field text */
Status = BlAllocateMemoryPool(2048 * sizeof(WCHAR), (PVOID *)&InputFieldBuffer);
@@ -794,7 +794,7 @@ BlDisplayInputDialog(IN PCWSTR Caption,
}
/* Copy input text into edit buffer */
RtlCopyMemory(InputFieldBuffer, *InputFieldText, InputFieldLength * sizeof(WCHAR));
RTL::Memory::CopyMemory(InputFieldBuffer, *InputFieldText, InputFieldLength * sizeof(WCHAR));
InputFieldBuffer[InputFieldLength] = L'\0';
/* Start at first character */
@@ -861,7 +861,7 @@ BlDisplayInputDialog(IN PCWSTR Caption,
if(InputFieldLength > 0 && TextPosition < InputFieldLength)
{
/* Delete character */
RtlMoveMemory(InputFieldBuffer + TextPosition, InputFieldBuffer + TextPosition + 1,
RTL::Memory::MoveMemory(InputFieldBuffer + TextPosition, InputFieldBuffer + TextPosition + 1,
(InputFieldLength - TextPosition) * sizeof(WCHAR));
/* Decrement length and NULL terminate string */
@@ -879,7 +879,7 @@ BlDisplayInputDialog(IN PCWSTR Caption,
if(InputFieldLength > 0 && TextPosition > 0 && TextPosition <= InputFieldLength)
{
/* Move memory to overwrite the character to the left of the cursor */
RtlMoveMemory(InputFieldBuffer + TextPosition - 1, InputFieldBuffer + TextPosition,
RTL::Memory::MoveMemory(InputFieldBuffer + TextPosition - 1, InputFieldBuffer + TextPosition,
(InputFieldLength - TextPosition + 1) * sizeof(WCHAR));
/* Decrement length, position and NULL terminate string */
@@ -904,7 +904,7 @@ BlDisplayInputDialog(IN PCWSTR Caption,
if(InputFieldLength < 2047)
{
/* Insert character at current position */
RtlMoveMemory(InputFieldBuffer + TextPosition + 1, InputFieldBuffer + TextPosition,
RTL::Memory::MoveMemory(InputFieldBuffer + TextPosition + 1, InputFieldBuffer + TextPosition,
(InputFieldLength - TextPosition) * sizeof(WCHAR));
InputFieldBuffer[TextPosition] = Key.UnicodeChar;
@@ -1080,7 +1080,7 @@ BlpDetermineDialogBoxSize(IN OUT PXTBL_DIALOG_HANDLE Handle,
}
/* Get message length and count dialog window dimensions */
MessageLength = RtlWideStringLength(Message, 0);
MessageLength = RTL::WideString::WideStringLength(Message, 0);
for(Index = 0; Index < MessageLength; Index++)
{
/* Check if this is multiline message */
@@ -1308,7 +1308,7 @@ BlpDrawDialogBox(IN OUT PXTBL_DIALOG_HANDLE Handle,
if(Caption != NULLPTR)
{
/* Get caption length */
CaptionLength = RtlWideStringLength(Caption, 0);
CaptionLength = RTL::WideString::WideStringLength(Caption, 0);
/* Start caption area with vertical line */
BoxLine[1] = EFI_TEXT_BOX_VERTICAL_LEFT;
@@ -1500,7 +1500,7 @@ BlpDrawDialogInputField(IN PXTBL_DIALOG_HANDLE Handle,
BlConsoleWrite(InputField);
/* Check input field text length */
Length = RtlWideStringLength(InputFieldText, 0);
Length = RTL::WideString::WideStringLength(InputFieldText, 0);
if(Length > (Handle->Width - 9))
{
/* Text longer than input field width, display only part of it */
@@ -1553,7 +1553,7 @@ BlpDrawDialogMessage(IN PXTBL_DIALOG_HANDLE Handle,
ULONG Line;
/* Allocate memory for dialog box message */
Length = RtlWideStringLength(Message, 0);
Length = RTL::WideString::WideStringLength(Message, 0);
Status = BlAllocateMemoryPool(Length * sizeof(WCHAR), (PVOID *)&Msg);
if(Status != STATUS_EFI_SUCCESS)
{
@@ -1563,18 +1563,18 @@ BlpDrawDialogMessage(IN PXTBL_DIALOG_HANDLE Handle,
}
/* Make a copy of dialog box message */
RtlCopyMemory(Msg, Message, Length * sizeof(WCHAR));
RTL::Memory::CopyMemory(Msg, Message, Length * sizeof(WCHAR));
Msg[Length] = 0;
/* Tokenize dialog box message */
MsgLine = RtlTokenizeWideString(Msg, L"\n", &LastMsgLine);
MsgLine = RTL::WideString::TokenizeWideString(Msg, L"\n", &LastMsgLine);
/* Iterate through message lines */
Line = 0;
while(MsgLine)
{
/* Determine line length */
LineLength = RtlWideStringLength(MsgLine, 0);
LineLength = RTL::WideString::WideStringLength(MsgLine, 0);
/* Write line in the dialog box */
BlSetCursorPosition(Handle->PosX + 2, Handle->PosY + 2 + Line);
@@ -1592,7 +1592,7 @@ BlpDrawDialogMessage(IN PXTBL_DIALOG_HANDLE Handle,
}
/* Get next line */
MsgLine = RtlTokenizeWideString(NULLPTR, L"\n", &LastMsgLine);
MsgLine = RTL::WideString::TokenizeWideString(NULLPTR, L"\n", &LastMsgLine);
Line++;
}
}
@@ -1751,8 +1751,8 @@ BlpDrawEditMenuEntry(IN PXTBL_DIALOG_HANDLE Handle,
DisplayValue = (OptionValue != NULLPTR) ? OptionValue : L"";
/* Determine lengths */
OptionNameLength = RtlWideStringLength(OptionName, 0);
OptionValueLength = RtlWideStringLength(DisplayValue, 0);
OptionNameLength = RTL::WideString::WideStringLength(OptionName, 0);
OptionValueLength = RTL::WideString::WideStringLength(DisplayValue, 0);
OptionWidth = Handle->Width - 4 - (OptionNameLength + 2);
/* Check if value needs to be truncated */
@@ -1768,8 +1768,8 @@ BlpDrawEditMenuEntry(IN PXTBL_DIALOG_HANDLE Handle,
}
/* Copy a desired value length into the allocated buffer and append "..." */
RtlCopyMemory((PWCHAR)ShortValue, DisplayValue, (OptionWidth - 3) * sizeof(WCHAR));
RtlCopyMemory((PWCHAR)ShortValue + OptionWidth - 3, L"...", 3 * sizeof(WCHAR));
RTL::Memory::CopyMemory((PWCHAR)ShortValue, DisplayValue, (OptionWidth - 3) * sizeof(WCHAR));
RTL::Memory::CopyMemory((PWCHAR)ShortValue + OptionWidth - 3, L"...", 3 * sizeof(WCHAR));
((PWCHAR)ShortValue)[OptionWidth] = L'\0';
/* Mark that allocation was made and set new display value */

View File

@@ -80,8 +80,8 @@ BlEnumerateBlockDevices()
BootDeviceHandle = LoadedImage->DeviceHandle;
/* Initialize list entries */
RtlInitializeListHead(&BlockDevices);
RtlInitializeListHead(&EfiBlockDevices);
RTL::LinkedList::InitializeListHead(&BlockDevices);
RTL::LinkedList::InitializeListHead(&EfiBlockDevices);
/* Discover EFI block devices and store them in linked list */
Status = BlpDiscoverEfiBlockDevices(&BlockDevices);
@@ -227,7 +227,7 @@ BlEnumerateBlockDevices()
BlockDevice->PartitionGuid = PartitionGuid;
/* Add block device to global list */
RtlInsertTailList(&EfiBlockDevices, &BlockDevice->ListEntry);
RTL::LinkedList::InsertTailList(&EfiBlockDevices, &BlockDevice->ListEntry);
}
/* Get next entry from linked list */
@@ -291,7 +291,7 @@ BlFindVolumeDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL FsHandle,
}
/* Check real path length */
FsPathLength = RtlWideStringLength(FileSystemPath, 0) * sizeof(WCHAR);
FsPathLength = RTL::WideString::WideStringLength(FileSystemPath, 0) * sizeof(WCHAR);
/* Allocate memory pool for device path */
Status = BlAllocateMemoryPool(FsPathLength + DevicePathLength + sizeof(EFI_DEVICE_PATH_PROTOCOL),
@@ -303,7 +303,7 @@ BlFindVolumeDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL FsHandle,
}
/* Set file path */
RtlCopyMemory(*DevicePath, FsHandle, DevicePathLength);
RTL::Memory::CopyMemory(*DevicePath, FsHandle, DevicePathLength);
FilePath = (PEFI_FILEPATH_DEVICE_PATH)((PUCHAR)*DevicePath + DevicePathLength);
FilePath->Header.Type = EFI_MEDIA_DEVICE_PATH;
FilePath->Header.SubType = EFI_MEDIA_FILEPATH_DP;
@@ -311,7 +311,7 @@ BlFindVolumeDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL FsHandle,
FilePath->Header.Length[1] = FilePath->Header.Length[0] >> 8;
/* Set device path end node */
RtlCopyMemory(FilePath->PathName, FileSystemPath, FsPathLength + sizeof(WCHAR));
RTL::Memory::CopyMemory(FilePath->PathName, FileSystemPath, FsPathLength + sizeof(WCHAR));
EndDevicePath = (PEFI_DEVICE_PATH_PROTOCOL)&FilePath->PathName[(FsPathLength / sizeof(WCHAR)) + 1];
EndDevicePath->Type = EFI_END_DEVICE_PATH;
EndDevicePath->SubType = EFI_END_ENTIRE_DP;
@@ -344,7 +344,7 @@ BlGetEfiPath(IN PWCHAR SystemPath,
EFI_STATUS Status;
/* Get system path length */
PathLength = RtlWideStringLength(SystemPath, 0);
PathLength = RTL::WideString::WideStringLength(SystemPath, 0);
/* Allocate memory for storing EFI path */
Status = BlAllocateMemoryPool(sizeof(WCHAR) * (PathLength + 1), (PVOID *)EfiPath);
@@ -356,7 +356,7 @@ BlGetEfiPath(IN PWCHAR SystemPath,
}
/* Make a copy of SystemPath string */
RtlCopyMemory(*EfiPath, SystemPath, sizeof(WCHAR) * (PathLength + 1));
RTL::Memory::CopyMemory(*EfiPath, SystemPath, sizeof(WCHAR) * (PathLength + 1));
/* Replace directory separator if needed to comply with EFI standard */
for(Index = 0; Index < PathLength; Index++)
@@ -678,7 +678,7 @@ BlReadFile(IN PEFI_FILE_HANDLE DirHandle,
/* Calculate number of bytes to read and zero memory */
ReadSize = Pages * EFI_PAGE_SIZE;
*FileData = (PCHAR)(UINT_PTR)Address;
RtlZeroMemory(*FileData, ReadSize);
RTL::Memory::ZeroMemory(*FileData, ReadSize);
/* Read data from the file */
Status = FileHandle->Read(FileHandle, &ReadSize, *FileData);
@@ -780,7 +780,7 @@ BlpDiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices)
/* Store new block device into a linked list */
BlockDevice->BlockIo = Io;
BlockDevice->DevicePath = DevicePath;
RtlInsertTailList(BlockDevices, &BlockDevice->ListEntry);
RTL::LinkedList::InsertTailList(BlockDevices, &BlockDevice->ListEntry);
}
/* Free handles buffer */
@@ -830,26 +830,26 @@ BlpDissectVolumeArcPath(IN PWCHAR SystemPath,
*PartNumber = 0;
/* Look for the ARC path */
if(RtlCompareWideStringInsensitive(SystemPath, L"ramdisk(0)", 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"ramdisk(0)", 0) == 0)
{
/* This is RAM disk */
ArcLength = 10;
*DriveType = XTBL_BOOT_DEVICE_RAMDISK;
}
else if(RtlCompareWideStringInsensitive(SystemPath, L"multi(0)esp(0)", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"multi(0)esp(0)", 0) == 0)
{
/* This is ESP */
ArcLength = 14;
*DriveType = XTBL_BOOT_DEVICE_ESP;
}
else if(RtlCompareWideStringInsensitive(SystemPath, L"multi(0)disk(0)", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(SystemPath, L"multi(0)disk(0)", 0) == 0)
{
/* This is a multi-disk port */
ArcLength = 15;
ArcPath = SystemPath + ArcLength;
/* Check for disk type */
if(RtlCompareWideStringInsensitive(ArcPath, L"cdrom(", 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"cdrom(", 0) == 0)
{
/* This is an optical drive */
ArcLength += 6;
@@ -870,7 +870,7 @@ BlpDissectVolumeArcPath(IN PWCHAR SystemPath,
*DriveType = XTBL_BOOT_DEVICE_CDROM;
ArcLength++;
}
else if(RtlCompareWideStringInsensitive(ArcPath, L"fdisk(", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"fdisk(", 0) == 0)
{
/* This is a floppy drive */
ArcLength += 6;
@@ -891,7 +891,7 @@ BlpDissectVolumeArcPath(IN PWCHAR SystemPath,
*DriveType = XTBL_BOOT_DEVICE_FLOPPY;
ArcLength++;
}
else if(RtlCompareWideStringInsensitive(ArcPath, L"rdisk(", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"rdisk(", 0) == 0)
{
/* This is a hard disk */
ArcLength += 6;
@@ -914,7 +914,7 @@ BlpDissectVolumeArcPath(IN PWCHAR SystemPath,
ArcPath = SystemPath + ArcLength;
/* Look for a partition */
if(RtlCompareWideStringInsensitive(ArcPath, L"partition(", 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(ArcPath, L"partition(", 0) == 0)
{
/* Partition information found */
ArcLength += 10;
@@ -955,7 +955,7 @@ BlpDissectVolumeArcPath(IN PWCHAR SystemPath,
if(ArcName)
{
BlAllocateMemoryPool(ArcLength * sizeof(WCHAR), (PVOID *)&LocalArcName);
RtlCopyMemory(LocalArcName, SystemPath, ArcLength * sizeof(WCHAR));
RTL::Memory::CopyMemory(LocalArcName, SystemPath, ArcLength * sizeof(WCHAR));
LocalArcName[ArcLength] = '\0';
*ArcName = LocalArcName;
}
@@ -1021,7 +1021,7 @@ BlpDuplicateDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath)
}
/* Copy the device path */
RtlCopyMemory(DevicePathClone, DevicePath, Length);
RTL::Memory::CopyMemory(DevicePathClone, DevicePath, Length);
/* Return the cloned object */
return DevicePathClone;
@@ -1131,7 +1131,7 @@ BlpFindParentBlockDevice(IN PLIST_ENTRY BlockDevices,
/* Check if nodes match */
if((ChildLength != ParentLength) ||
(RtlCompareMemory(ChildDevicePath, ParentDevicePath, ParentLength) != ParentLength))
(RTL::Memory::CompareMemory(ChildDevicePath, ParentDevicePath, ParentLength) != ParentLength))
{
/* Nodes do not match, this is not a valid parent */
break;

View File

@@ -35,9 +35,9 @@ BlInitializeBootLoader()
BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION);
/* Initialize XTLDR configuration linked lists */
RtlInitializeListHead(&BlpBootProtocols);
RtlInitializeListHead(&BlpConfig);
RtlInitializeListHead(&BlpLoadedModules);
RTL::LinkedList::InitializeListHead(&BlpBootProtocols);
RTL::LinkedList::InitializeListHead(&BlpConfig);
RTL::LinkedList::InitializeListHead(&BlpLoadedModules);
/* Store SecureBoot status */
BlpStatus.SecureBoot = BlGetSecureBootStatus();
@@ -154,8 +154,8 @@ BlInitializeBootMenuList(IN ULONG MaxNameLength,
MenuEntrySection = CONTAIN_RECORD(MenuEntrySectionList, XTBL_CONFIG_SECTION, Flink);
/* Check if this is the default menu entry */
if((RtlWideStringLength(MenuEntrySection->SectionName, 0) == RtlWideStringLength(DefaultMenuEntry, 0)) &&
(RtlCompareWideStringInsensitive(MenuEntrySection->SectionName, DefaultMenuEntry, 0) == 0))
if((RTL::WideString::WideStringLength(MenuEntrySection->SectionName, 0) == RTL::WideString::WideStringLength(DefaultMenuEntry, 0)) &&
(RTL::WideString::CompareWideStringInsensitive(MenuEntrySection->SectionName, DefaultMenuEntry, 0) == 0))
{
/* Set default OS ID */
DefaultOS = NumberOfEntries;
@@ -169,7 +169,7 @@ BlInitializeBootMenuList(IN ULONG MaxNameLength,
MenuEntryOption = CONTAIN_RECORD(MenuEntryList, XTBL_CONFIG_ENTRY, Flink);
/* Check if this is the menu entry display name */
if(RtlCompareWideStringInsensitive(MenuEntryOption->Name, L"SYSTEMNAME", 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(MenuEntryOption->Name, L"SYSTEMNAME", 0) == 0)
{
/* Set menu entry display name */
MenuEntryName = MenuEntryOption->Value;
@@ -185,7 +185,7 @@ BlInitializeBootMenuList(IN ULONG MaxNameLength,
OsList[NumberOfEntries].Options = &MenuEntrySection->Options;
/* Check if the menu entry name fits the maximum length */
NameLength = RtlWideStringLength(MenuEntryName, 0);
NameLength = RTL::WideString::WideStringLength(MenuEntryName, 0);
if(NameLength > MaxNameLength)
{
/* Menu entry name is too long, allocate memory for shorter name visible in the boot menu */
@@ -197,8 +197,8 @@ BlInitializeBootMenuList(IN ULONG MaxNameLength,
}
/* Copy shorter name and append "..." at the end */
RtlCopyMemory(VisibleName, MenuEntryName, (MaxNameLength - 3) * sizeof(WCHAR));
RtlCopyMemory(VisibleName + MaxNameLength - 3, L"...", 3 * sizeof(WCHAR));
RTL::Memory::CopyMemory(VisibleName, MenuEntryName, (MaxNameLength - 3) * sizeof(WCHAR));
RTL::Memory::CopyMemory(VisibleName + MaxNameLength - 3, L"...", 3 * sizeof(WCHAR));
VisibleName[MaxNameLength] = L'\0';
/* Set visible menu entry name */
@@ -254,7 +254,7 @@ BlInvokeBootProtocol(IN PWCHAR ShortName,
EFI_STATUS Status;
/* Initialize boot parameters and a list of modules */
RtlZeroMemory(&BootParameters, sizeof(XTBL_BOOT_PARAMETERS));
RTL::Memory::ZeroMemory(&BootParameters, sizeof(XTBL_BOOT_PARAMETERS));
ModulesList = NULLPTR;
/* Iterate through all options provided by boot menu entry and propagate boot parameters */
@@ -265,10 +265,10 @@ BlInvokeBootProtocol(IN PWCHAR ShortName,
Option = CONTAIN_RECORD(OptionsListEntry, XTBL_CONFIG_ENTRY, Flink);
/* Look for boot protocol and modules list */
if(RtlCompareWideStringInsensitive(Option->Name, L"BOOTMODULES", 0) == 0)
if(RTL::WideString::CompareWideStringInsensitive(Option->Name, L"BOOTMODULES", 0) == 0)
{
/* Check a length of modules list */
ModuleListLength = RtlWideStringLength(Option->Value, 0);
ModuleListLength = RTL::WideString::WideStringLength(Option->Value, 0);
Status = BlAllocateMemoryPool(sizeof(WCHAR) * (ModuleListLength + 1), (PVOID *)&ModulesList);
if(Status != STATUS_EFI_SUCCESS)
@@ -279,14 +279,14 @@ BlInvokeBootProtocol(IN PWCHAR ShortName,
}
/* Make a copy of modules list */
RtlCopyMemory(ModulesList, Option->Value, sizeof(WCHAR) * (ModuleListLength + 1));
RTL::Memory::CopyMemory(ModulesList, Option->Value, sizeof(WCHAR) * (ModuleListLength + 1));
}
else if(RtlCompareWideStringInsensitive(Option->Name, L"SYSTEMTYPE", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(Option->Name, L"SYSTEMTYPE", 0) == 0)
{
/* Boot protocol found */
BootParameters.SystemType = Option->Value;
}
else if(RtlCompareWideStringInsensitive(Option->Name, L"SYSTEMPATH", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(Option->Name, L"SYSTEMPATH", 0) == 0)
{
/* System path found, get volume device path */
Status = BlGetVolumeDevicePath(Option->Value, &BootParameters.DevicePath,
@@ -307,22 +307,22 @@ BlInvokeBootProtocol(IN PWCHAR ShortName,
return Status;
}
}
else if(RtlCompareWideStringInsensitive(Option->Name, L"KERNELFILE", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(Option->Name, L"KERNELFILE", 0) == 0)
{
/* Kernel file name found */
BootParameters.KernelFile = Option->Value;
}
else if(RtlCompareWideStringInsensitive(Option->Name, L"INITRDFILE", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(Option->Name, L"INITRDFILE", 0) == 0)
{
/* Initrd file name found */
BootParameters.InitrdFile = Option->Value;
}
else if(RtlCompareWideStringInsensitive(Option->Name, L"HALFILE", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(Option->Name, L"HALFILE", 0) == 0)
{
/* Hal file name found */
BootParameters.HalFile = Option->Value;
}
else if(RtlCompareWideStringInsensitive(Option->Name, L"PARAMETERS", 0) == 0)
else if(RTL::WideString::CompareWideStringInsensitive(Option->Name, L"PARAMETERS", 0) == 0)
{
/* Kernel parameters found */
BootParameters.Parameters = Option->Value;
@@ -363,7 +363,7 @@ BlInvokeBootProtocol(IN PWCHAR ShortName,
if(BlGetConfigBooleanValue(L"KEEPLASTBOOT"))
{
/* Save chosen operating system in NVRAM */
Status = BlSetEfiVariable(&VendorGuid, L"XtLdrLastBootOS", (PVOID)ShortName, RtlWideStringLength(ShortName, 0) * sizeof(WCHAR));
Status = BlSetEfiVariable(&VendorGuid, L"XtLdrLastBootOS", (PVOID)ShortName, RTL::WideString::WideStringLength(ShortName, 0) * sizeof(WCHAR));
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to save chosen Operating System */