C to C++ migration and refactoring #17

Merged
harraiken merged 67 commits from cxxtest into master 2025-09-24 20:18:35 +02:00
32 changed files with 441 additions and 492 deletions
Showing only changes of commit e7425de523 - Show all commits

View File

@@ -1,55 +0,0 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: sdk/xtdk/amd64/arfuncs.h
* DESCRIPTION: AMD64 architecture library routines
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#ifndef __XTDK_AMD64_ARFUNCS_H
#define __XTDK_AMD64_ARFUNCS_H
#include <xtdefs.h>
#include <xtstruct.h>
#include <xttypes.h>
#include <amd64/xtstruct.h>
/* Routines used by XTLDR */
XTCLINK
XTCDECL
VOID
ArClearInterruptFlag(VOID);
XTCLINK
XTCDECL
BOOLEAN
ArCpuId(IN OUT PCPUID_REGISTERS Registers);
XTCLINK
XTCDECL
VOID
ArEnableExtendedPhysicalAddressing(IN ULONG_PTR PageMap);
XTCLINK
XTCDECL
VOID
ArHalt(VOID);
XTCLINK
XTCDECL
ULONG_PTR
ArReadControlRegister(IN USHORT ControlRegister);
XTCLINK
XTCDECL
ULONGLONG
ArReadModelSpecificRegister(IN ULONG Register);
XTCLINK
XTCDECL
VOID
ArWriteControlRegister(IN USHORT ControlRegister,
IN UINT_PTR Value);
#endif /* __XTDK_AMD64_ARFUNCS_H */

View File

@@ -14,6 +14,11 @@
/* XT BootLoader routines forward references */ /* XT BootLoader routines forward references */
XTCLINK
XTCDECL
VOID
ArEnableExtendedPhysicalAddressing(IN ULONG_PTR PageMap);
XTCLINK XTCLINK
XTCDECL XTCDECL
EFI_STATUS EFI_STATUS

View File

@@ -51,6 +51,10 @@ typedef BOOLEAN (*PBL_BOOTUTIL_GET_BOOLEAN_PARAMETER)(IN PCWSTR Parameters, IN P
typedef EFI_STATUS (*PBL_BUILD_PAGE_MAP)(IN PXTBL_PAGE_MAPPING PageMap, IN ULONG_PTR SelfMapAddress); typedef EFI_STATUS (*PBL_BUILD_PAGE_MAP)(IN PXTBL_PAGE_MAPPING PageMap, IN ULONG_PTR SelfMapAddress);
typedef EFI_STATUS (*PBL_CLOSE_VOLUME)(IN PEFI_HANDLE VolumeHandle); typedef EFI_STATUS (*PBL_CLOSE_VOLUME)(IN PEFI_HANDLE VolumeHandle);
typedef VOID (*PBL_CLEAR_CONSOLE_LINE)(IN ULONGLONG LineNo); typedef VOID (*PBL_CLEAR_CONSOLE_LINE)(IN ULONGLONG LineNo);
typedef BOOLEAN (XTCDECL *PBL_CPU_CPUID)(IN OUT PCPUID_REGISTERS Registers);
typedef ULONG_PTR (XTCDECL *PBL_CPU_READ_CONTROL_REGISTER)(IN USHORT ControlRegister);
typedef ULONGLONG (XTCDECL *PBL_CPU_READ_MODEL_SPECIFIC_REGISTER)(IN ULONG Register);
typedef VOID (XTCDECL *PBL_CPU_WRITE_CONTROL_REGISTER)(IN USHORT ControlRegister, IN UINT_PTR Value);
typedef EFI_STATUS (*PBL_CLOSE_XT_PROTOCOL)(IN PEFI_HANDLE Handle, IN PEFI_GUID ProtocolGuid); typedef EFI_STATUS (*PBL_CLOSE_XT_PROTOCOL)(IN PEFI_HANDLE Handle, IN PEFI_GUID ProtocolGuid);
typedef BOOLEAN (*PBL_CONFIG_GET_BOOLEAN_VALUE)(IN PCWSTR ConfigName); typedef BOOLEAN (*PBL_CONFIG_GET_BOOLEAN_VALUE)(IN PCWSTR ConfigName);
typedef EFI_STATUS (*PBL_CONFIG_GET_BOOT_OPTION_VALUE)(IN PLIST_ENTRY Options, IN PCWSTR OptionName, OUT PWCHAR *OptionValue); typedef EFI_STATUS (*PBL_CONFIG_GET_BOOT_OPTION_VALUE)(IN PLIST_ENTRY Options, IN PCWSTR OptionName, OUT PWCHAR *OptionValue);
@@ -67,6 +71,8 @@ typedef VOID (*PBL_CONSOLE_RESET_INPUT_BUFFER)();
typedef VOID (*PBL_CONSOLE_SET_ATTRIBUTES)(IN ULONGLONG Attributes); typedef VOID (*PBL_CONSOLE_SET_ATTRIBUTES)(IN ULONGLONG Attributes);
typedef VOID (*PBL_CONSOLE_SET_CURSOR_POSITION)(IN ULONGLONG PosX, IN ULONGLONG PosY); typedef VOID (*PBL_CONSOLE_SET_CURSOR_POSITION)(IN ULONGLONG PosX, IN ULONGLONG PosY);
typedef VOID (*PBL_CONSOLE_WRITE)(IN PCWSTR String); typedef VOID (*PBL_CONSOLE_WRITE)(IN PCWSTR String);
typedef SIZE_T (*PBL_COMPARE_MEMORY)(IN PCVOID LeftBuffer, IN PCVOID RightBuffer, IN SIZE_T Length);
typedef SIZE_T (XTAPI *PBL_WIDESTRING_COMPARE)(IN PCWSTR String1, IN PCWSTR String2, IN SIZE_T Length);
typedef VOID (XTAPI *PBL_COPY_MEMORY)(OUT PVOID Destination, IN PCVOID Source, IN SIZE_T Length); typedef VOID (XTAPI *PBL_COPY_MEMORY)(OUT PVOID Destination, IN PCVOID Source, IN SIZE_T Length);
typedef VOID (*PBL_DEBUG_PRINT)(IN PCWSTR Format, IN ...); typedef VOID (*PBL_DEBUG_PRINT)(IN PCWSTR Format, IN ...);
typedef EFI_STATUS (*PBL_ENTER_FIRMWARE_SETUP)(); typedef EFI_STATUS (*PBL_ENTER_FIRMWARE_SETUP)();
@@ -88,19 +94,34 @@ typedef EFI_STATUS (*PBL_INSTALL_XT_PROTOCOL)(IN PVOID Interface, IN PEFI_GUID G
typedef EFI_STATUS (*PBL_INVOKE_BOOT_PROTOCOL)(IN PWCHAR ShortName, IN PLIST_ENTRY OptionsList); typedef EFI_STATUS (*PBL_INVOKE_BOOT_PROTOCOL)(IN PWCHAR ShortName, IN PLIST_ENTRY OptionsList);
typedef EFI_STATUS (*PBL_LOCATE_PROTOCOL_HANDLES)(OUT PEFI_HANDLE *Handles, OUT PUINT_PTR Count, IN PEFI_GUID ProtocolGuid); typedef EFI_STATUS (*PBL_LOCATE_PROTOCOL_HANDLES)(OUT PEFI_HANDLE *Handles, OUT PUINT_PTR Count, IN PEFI_GUID ProtocolGuid);
typedef EFI_STATUS (*PBL_LOAD_EFI_IMAGE)(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath, IN PVOID ImageData, IN SIZE_T ImageSize, OUT PEFI_HANDLE ImageHandle); typedef EFI_STATUS (*PBL_LOAD_EFI_IMAGE)(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath, IN PVOID ImageData, IN SIZE_T ImageSize, OUT PEFI_HANDLE ImageHandle);
typedef VOID (XTCDECL *PBL_LLIST_INITIALIZE_HEAD)(IN PLIST_ENTRY ListHead);
typedef VOID (XTCDECL *PBL_LLIST_INSERT_HEAD)(IN OUT PLIST_ENTRY ListHead, IN PLIST_ENTRY Entry);
typedef VOID (XTCDECL *PBL_LLIST_INSERT_TAIL)(IN OUT PLIST_ENTRY ListHead, IN PLIST_ENTRY Entry);
typedef VOID (XTCDECL *PBL_LLIST_REMOVE_ENTRY)(IN PLIST_ENTRY Entry);
typedef EFI_STATUS (*PBL_MAP_EFI_MEMORY)(IN OUT PXTBL_PAGE_MAPPING PageMap, IN OUT PVOID *MemoryMapAddress, IN PBL_GET_MEMTYPE_ROUTINE GetMemoryTypeRoutine); typedef EFI_STATUS (*PBL_MAP_EFI_MEMORY)(IN OUT PXTBL_PAGE_MAPPING PageMap, IN OUT PVOID *MemoryMapAddress, IN PBL_GET_MEMTYPE_ROUTINE GetMemoryTypeRoutine);
typedef EFI_STATUS (*PBL_MAP_PAGE)(IN PXTBL_PAGE_MAPPING PageMap, IN ULONG_PTR VirtualAddress, IN ULONG_PTR PhysicalAddress, IN ULONG NumberOfPages); typedef EFI_STATUS (*PBL_MAP_PAGE)(IN PXTBL_PAGE_MAPPING PageMap, IN ULONG_PTR VirtualAddress, IN ULONG_PTR PhysicalAddress, IN ULONG NumberOfPages);
typedef EFI_STATUS (*PBL_MAP_VIRTUAL_MEMORY)(IN OUT PXTBL_PAGE_MAPPING PageMap, IN PVOID VirtualAddress, IN PVOID PhysicalAddress, IN ULONGLONG NumberOfPages, IN LOADER_MEMORY_TYPE MemoryType); typedef EFI_STATUS (*PBL_MAP_VIRTUAL_MEMORY)(IN OUT PXTBL_PAGE_MAPPING PageMap, IN PVOID VirtualAddress, IN PVOID PhysicalAddress, IN ULONGLONG NumberOfPages, IN LOADER_MEMORY_TYPE MemoryType);
typedef VOID (*PBL_MOVE_MEMORY)(IN OUT PVOID Destination, IN PCVOID Source, IN SIZE_T Length);
typedef EFI_STATUS (*PBL_OPEN_VOLUME)(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath, OUT PEFI_HANDLE DiskHandle, OUT PEFI_FILE_HANDLE *FsHandle); typedef EFI_STATUS (*PBL_OPEN_VOLUME)(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath, OUT PEFI_HANDLE DiskHandle, OUT PEFI_FILE_HANDLE *FsHandle);
typedef EFI_STATUS (*PBL_OPEN_PROTOCOL)(OUT PEFI_HANDLE Handle, OUT PVOID *ProtocolHandler, IN PEFI_GUID ProtocolGuid); typedef EFI_STATUS (*PBL_OPEN_PROTOCOL)(OUT PEFI_HANDLE Handle, OUT PVOID *ProtocolHandler, IN PEFI_GUID ProtocolGuid);
typedef EFI_STATUS (*PBL_OPEN_PROTOCOL_HANDLE)(IN EFI_HANDLE Handle, OUT PVOID *ProtocolHandler, IN PEFI_GUID ProtocolGuid); typedef EFI_STATUS (*PBL_OPEN_PROTOCOL_HANDLE)(IN EFI_HANDLE Handle, OUT PVOID *ProtocolHandler, IN PEFI_GUID ProtocolGuid);
typedef PVOID (*PBL_PHYSICAL_ADDRESS_TO_VIRTUAL)(IN PVOID PhysicalAddress, IN PVOID PhysicalBase, IN PVOID VirtualBase); typedef PVOID (*PBL_PHYSICAL_ADDRESS_TO_VIRTUAL)(IN PVOID PhysicalAddress, IN PVOID PhysicalBase, IN PVOID VirtualBase);
typedef UCHAR (XTCDECL *PBL_IOPORT_READ_8)(IN USHORT Port);
typedef USHORT (XTCDECL *PBL_IOPORT_READ_16)(IN USHORT Port);
typedef ULONG (XTCDECL *PBL_IOPORT_READ_32)(IN USHORT Port);
typedef VOID (XTCDECL *PBL_IOPORT_WRITE_8)(IN USHORT Port, IN UCHAR Value);
typedef VOID (XTCDECL *PBL_IOPORT_WRITE_16)(IN USHORT Port, IN USHORT Value);
typedef VOID (XTCDECL *PBL_IOPORT_WRITE_32)(IN USHORT Port, IN ULONG Value);
typedef EFI_STATUS (*PBL_PHYSICAL_LIST_TO_VIRTUAL)(IN PXTBL_PAGE_MAPPING PageMap, IN OUT PLIST_ENTRY ListHead, IN PVOID PhysicalBase, IN PVOID VirtualBase); typedef EFI_STATUS (*PBL_PHYSICAL_LIST_TO_VIRTUAL)(IN PXTBL_PAGE_MAPPING PageMap, IN OUT PLIST_ENTRY ListHead, IN PVOID PhysicalBase, IN PVOID VirtualBase);
typedef EFI_STATUS (*PBL_POWER_SYSTEM)(); typedef EFI_STATUS (*PBL_POWER_SYSTEM)();
typedef EFI_STATUS (*PBL_READ_FILE)(IN PEFI_FILE_HANDLE DirHandle, IN PCWSTR FileName, OUT PVOID *FileData, OUT PSIZE_T FileSize); typedef EFI_STATUS (*PBL_READ_FILE)(IN PEFI_FILE_HANDLE DirHandle, IN PCWSTR FileName, OUT PVOID *FileData, OUT PSIZE_T FileSize);
typedef EFI_STATUS (*PBL_REGISTER_BOOT_PROTOCOL)(IN PCWSTR SystemType, IN PEFI_GUID BootProtocolGuid); typedef EFI_STATUS (*PBL_REGISTER_BOOT_PROTOCOL)(IN PCWSTR SystemType, IN PEFI_GUID BootProtocolGuid);
typedef VOID (*PBL_REGISTER_XT_BOOT_MENU)(PVOID BootMenuRoutine); typedef VOID (*PBL_REGISTER_XT_BOOT_MENU)(PVOID BootMenuRoutine);
typedef EFI_STATUS (*PBL_SET_EFI_VARIABLE)(IN PEFI_GUID Vendor, IN PCWSTR VariableName, IN PVOID VariableValue, IN UINT_PTR Size); typedef EFI_STATUS (*PBL_SET_EFI_VARIABLE)(IN PEFI_GUID Vendor, IN PCWSTR VariableName, IN PVOID VariableValue, IN UINT_PTR Size);
typedef SIZE_T (XTAPI *PBL_STRING_COMPARE)(IN PCSTR String1, IN PCSTR String2, IN SIZE_T Length);
typedef SIZE_T (XTAPI *PBL_STRING_LENGTH)(IN PCSTR String, IN SIZE_T MaxLength);
typedef SIZE_T (XTAPI *PBL_STRING_TO_WIDESTRING)(OUT PWCHAR Destination, IN PCSTR *Source, IN SIZE_T Length);
typedef PCHAR (XTAPI *PBL_STRING_TRIM)(IN PCHAR String);
typedef VOID (XTAPI *PBL_SET_MEMORY)(OUT PVOID Destination, IN UCHAR Byte, IN SIZE_T Length); typedef VOID (XTAPI *PBL_SET_MEMORY)(OUT PVOID Destination, IN UCHAR Byte, IN SIZE_T Length);
typedef VOID (*PBL_SLEEP_EXECUTION)(IN ULONG_PTR Milliseconds); typedef VOID (*PBL_SLEEP_EXECUTION)(IN ULONG_PTR Milliseconds);
typedef EFI_STATUS (*PBL_START_EFI_IMAGE)(IN EFI_HANDLE ImageHandle); typedef EFI_STATUS (*PBL_START_EFI_IMAGE)(IN EFI_HANDLE ImageHandle);
@@ -109,6 +130,11 @@ typedef VOID (*PBL_TUI_DISPLAY_INFO_DIALOG)(IN PCWSTR Caption, IN PCWSTR Message
typedef VOID (*PBL_TUI_DISPLAY_INPUT_DIALOG)(IN PCWSTR Caption, IN PCWSTR Message, IN OUT PWCHAR *InputFieldText); typedef VOID (*PBL_TUI_DISPLAY_INPUT_DIALOG)(IN PCWSTR Caption, IN PCWSTR Message, IN OUT PWCHAR *InputFieldText);
typedef XTBL_DIALOG_HANDLE (*PBL_TUI_DISPLAY_PROGRESS_DIALOG)(IN PCWSTR Caption, IN PCWSTR Message, IN UCHAR Percentage); typedef XTBL_DIALOG_HANDLE (*PBL_TUI_DISPLAY_PROGRESS_DIALOG)(IN PCWSTR Caption, IN PCWSTR Message, IN UCHAR Percentage);
typedef VOID (*PBL_TUI_UPDATE_PROGRESS_BAR)(IN PXTBL_DIALOG_HANDLE Handle, IN PCWSTR Message, IN UCHAR Percentage); typedef VOID (*PBL_TUI_UPDATE_PROGRESS_BAR)(IN PXTBL_DIALOG_HANDLE Handle, IN PCWSTR Message, IN UCHAR Percentage);
typedef SIZE_T (XTAPI *PBL_WIDESTRING_COMPARE_INSENSITIVE)(IN PCWSTR String1, IN PCWSTR String2, IN SIZE_T Length);
typedef PWCHAR (XTAPI *PBL_WIDESTRING_CONCATENATE)(OUT PWCHAR Destination, IN PWCHAR Source, IN SIZE_T Count);
typedef XTSTATUS (XTAPI *PBL_WIDESTRING_FORMAT)(IN PRTL_PRINT_CONTEXT Context, IN PCWSTR Format, IN VA_LIST ArgumentList);
typedef SIZE_T (XTAPI *PBL_WIDESTRING_LENGTH)(IN PCWSTR String, IN SIZE_T MaxLength);
typedef PWCHAR (XTAPI *PBL_WIDESTRING_TOKENIZE)(IN PWCHAR String, IN PCWSTR Delimiter, IN OUT PWCHAR *SavePtr);
typedef EFI_STATUS (*PBL_WAIT_FOR_EFI_EVENT)(IN UINT_PTR NumberOfEvents, IN PEFI_EVENT Event, OUT PUINT_PTR Index); typedef EFI_STATUS (*PBL_WAIT_FOR_EFI_EVENT)(IN UINT_PTR NumberOfEvents, IN PEFI_EVENT Event, OUT PUINT_PTR Index);
typedef VOID (*PBL_XT_BOOT_MENU)(); typedef VOID (*PBL_XT_BOOT_MENU)();
typedef VOID (XTAPI *PBL_ZERO_MEMORY)(OUT PVOID Destination, IN SIZE_T Length); typedef VOID (XTAPI *PBL_ZERO_MEMORY)(OUT PVOID Destination, IN SIZE_T Length);
@@ -386,6 +412,13 @@ typedef struct _XTBL_LOADER_PROTOCOL
PBL_CONSOLE_WRITE Write; PBL_CONSOLE_WRITE Write;
} Console; } Console;
struct struct
{
PBL_CPU_CPUID CpuId;
PBL_CPU_READ_CONTROL_REGISTER ReadControlRegister;
PBL_CPU_READ_MODEL_SPECIFIC_REGISTER ReadModelSpecificRegister;
PBL_CPU_WRITE_CONTROL_REGISTER WriteControlRegister;
} Cpu;
struct
{ {
PBL_DEBUG_PRINT Print; PBL_DEBUG_PRINT Print;
} Debug; } Debug;
@@ -396,10 +429,27 @@ typedef struct _XTBL_LOADER_PROTOCOL
PBL_READ_FILE ReadFile; PBL_READ_FILE ReadFile;
} Disk; } Disk;
struct struct
{
PBL_IOPORT_READ_8 Read8;
PBL_IOPORT_READ_16 Read16;
PBL_IOPORT_READ_32 Read32;
PBL_IOPORT_WRITE_8 Write8;
PBL_IOPORT_WRITE_16 Write16;
PBL_IOPORT_WRITE_32 Write32;
} IoPort;
struct
{
PBL_LLIST_INITIALIZE_HEAD InitializeHead;
PBL_LLIST_INSERT_HEAD InsertHead;
PBL_LLIST_INSERT_TAIL InsertTail;
PBL_LLIST_REMOVE_ENTRY RemoveEntry;
} LinkedList;
struct
{ {
PBL_ALLOCATE_PAGES AllocatePages; PBL_ALLOCATE_PAGES AllocatePages;
PBL_ALLOCATE_POOL AllocatePool; PBL_ALLOCATE_POOL AllocatePool;
PBL_BUILD_PAGE_MAP BuildPageMap; PBL_BUILD_PAGE_MAP BuildPageMap;
PBL_COMPARE_MEMORY CompareMemory;
PBL_COPY_MEMORY CopyMemory; PBL_COPY_MEMORY CopyMemory;
PBL_FREE_PAGES FreePages; PBL_FREE_PAGES FreePages;
PBL_FREE_POOL FreePool; PBL_FREE_POOL FreePool;
@@ -410,6 +460,7 @@ typedef struct _XTBL_LOADER_PROTOCOL
PBL_MAP_EFI_MEMORY MapEfiMemory; PBL_MAP_EFI_MEMORY MapEfiMemory;
PBL_MAP_PAGE MapPage; PBL_MAP_PAGE MapPage;
PBL_MAP_VIRTUAL_MEMORY MapVirtualMemory; PBL_MAP_VIRTUAL_MEMORY MapVirtualMemory;
PBL_MOVE_MEMORY MoveMemory;
PBL_PHYSICAL_ADDRESS_TO_VIRTUAL PhysicalAddressToVirtual; PBL_PHYSICAL_ADDRESS_TO_VIRTUAL PhysicalAddressToVirtual;
PBL_PHYSICAL_LIST_TO_VIRTUAL PhysicalListToVirtual; PBL_PHYSICAL_LIST_TO_VIRTUAL PhysicalListToVirtual;
PBL_SET_MEMORY SetMemory; PBL_SET_MEMORY SetMemory;
@@ -425,6 +476,13 @@ typedef struct _XTBL_LOADER_PROTOCOL
PBL_OPEN_PROTOCOL_HANDLE OpenHandle; PBL_OPEN_PROTOCOL_HANDLE OpenHandle;
} Protocol; } Protocol;
struct struct
{
PBL_STRING_COMPARE Compare;
PBL_STRING_LENGTH Length;
PBL_STRING_TO_WIDESTRING ToWideString;
PBL_STRING_TRIM Trim;
} String;
struct
{ {
PBL_TUI_DISPLAY_ERROR_DIALOG DisplayErrorDialog; PBL_TUI_DISPLAY_ERROR_DIALOG DisplayErrorDialog;
PBL_TUI_DISPLAY_INFO_DIALOG DisplayInfoDialog; PBL_TUI_DISPLAY_INFO_DIALOG DisplayInfoDialog;
@@ -449,6 +507,15 @@ typedef struct _XTBL_LOADER_PROTOCOL
PBL_START_EFI_IMAGE StartEfiImage; PBL_START_EFI_IMAGE StartEfiImage;
PBL_WAIT_FOR_EFI_EVENT WaitForEfiEvent; PBL_WAIT_FOR_EFI_EVENT WaitForEfiEvent;
} Util; } Util;
struct
{
PBL_WIDESTRING_COMPARE Compare;
PBL_WIDESTRING_COMPARE_INSENSITIVE CompareInsensitive;
PBL_WIDESTRING_CONCATENATE Concatenate;
PBL_WIDESTRING_FORMAT Format;
PBL_WIDESTRING_LENGTH Length;
PBL_WIDESTRING_TOKENIZE Tokenize;
} WideString;
} XTBL_LOADER_PROTOCOL, *PXTBL_LOADER_PROTOCOL; } XTBL_LOADER_PROTOCOL, *PXTBL_LOADER_PROTOCOL;
#endif /* __XTDK_BLTYPES_H */ #endif /* __XTDK_BLTYPES_H */

View File

@@ -14,20 +14,6 @@
#include <xttypes.h> #include <xttypes.h>
/* Routines used by XTLDR */
XTCLINK
XTCDECL
XTSTATUS
HlWriteComPort(IN PCPPORT Port,
IN UCHAR Byte);
XTCLINK
XTCDECL
XTSTATUS
HlInitializeComPort(IN OUT PCPPORT Port,
IN PUCHAR PortAddress,
IN ULONG BaudRate);
/* Hardware layer routines forward references */ /* Hardware layer routines forward references */
XTCLINK XTCLINK
XTAPI XTAPI

View File

@@ -1,50 +0,0 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: sdk/xtdk/i686/arfuncs.h
* DESCRIPTION: I686 architecture library routines
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#ifndef __XTDK_I686_ARFUNCS_H
#define __XTDK_I686_ARFUNCS_H
#include <xtdefs.h>
#include <xtstruct.h>
#include <xttypes.h>
#include <i686/xtstruct.h>
/* Routines used by XTLDR */
XTCLINK
XTCDECL
VOID
ArClearInterruptFlag(VOID);
XTCLINK
XTCDECL
BOOLEAN
ArCpuId(IN OUT PCPUID_REGISTERS Registers);
XTCLINK
XTCDECL
VOID
ArHalt(VOID);
XTCLINK
XTCDECL
ULONG_PTR
ArReadControlRegister(IN USHORT ControlRegister);
XTCLINK
XTCDECL
ULONGLONG
ArReadModelSpecificRegister(IN ULONG Register);
XTCLINK
XTCDECL
VOID
ArWriteControlRegister(IN USHORT ControlRegister,
IN UINT_PTR Value);
#endif /* __XTDK_I686_ARFUNCS_H */

View File

@@ -172,13 +172,6 @@ PCWSTR
RtlFindWideStringInsensitive(IN PCWSTR Source, RtlFindWideStringInsensitive(IN PCWSTR Source,
IN PCWSTR Search); IN PCWSTR Search);
XTCLINK
XTAPI
XTSTATUS
RtlFormatWideString(IN PRTL_PRINT_CONTEXT Context,
IN PCWSTR Format,
IN VA_LIST ArgumentList);
XTCLINK XTCLINK
XTAPI XTAPI
VOID VOID

View File

@@ -38,14 +38,6 @@
#include ARCH_HEADER(ketypes.h) #include ARCH_HEADER(ketypes.h)
#include ARCH_HEADER(mmtypes.h) #include ARCH_HEADER(mmtypes.h)
/* XT Kernel runtime routines */
#include <hlfuncs.h>
#include <rtlfuncs.h>
/* Architecture specific XT kernel routines */
#include ARCH_HEADER(arfuncs.h)
#include ARCH_HEADER(hlfuncs.h)
/* Boot Manager specific structures */ /* Boot Manager specific structures */
#include <bltarget.h> #include <bltarget.h>
#include <bltypes.h> #include <bltypes.h>

View File

@@ -53,5 +53,4 @@
#include <rtlfuncs.h> #include <rtlfuncs.h>
/* Architecture specific XT routines */ /* Architecture specific XT routines */
#include ARCH_HEADER(arfuncs.h)
#include ARCH_HEADER(hlfuncs.h) #include ARCH_HEADER(hlfuncs.h)

View File

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

View File

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

View File

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

View File

@@ -109,16 +109,16 @@ BlConsolePrint(IN PCWSTR Format,
VA_START(Arguments, Format); VA_START(Arguments, Format);
/* Format and print the string to the stdout */ /* 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 */ /* 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 */ /* Check if debugging enabled and if EFI serial port is fully initialized */
if(DEBUG && (BlpStatus.SerialPort.Flags & COMPORT_FLAG_INIT)) if(DEBUG && (BlpStatus.SerialPort.Flags & COMPORT_FLAG_INIT))
{ {
/* Format and print the string to the serial console */ /* 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)) if((BlpStatus.DebugPort & XTBL_DEBUGPORT_SERIAL) && (BlpStatus.SerialPort.Flags & COMPORT_FLAG_INIT))
{ {
/* Format and print the string to the serial console */ /* 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 */ /* Check if screen debug port is enabled and Boot Services are still available */
if((BlpStatus.DebugPort & XTBL_DEBUGPORT_SCREEN) && (BlpStatus.BootServices == TRUE)) if((BlpStatus.DebugPort & XTBL_DEBUGPORT_SCREEN) && (BlpStatus.BootServices == TRUE))
{ {
/* Format and print the string to the screen */ /* 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 */ /* Clean up the va_list */
@@ -78,7 +78,7 @@ BlpDebugPutChar(IN WCHAR Character)
/* Write character to the serial console */ /* Write character to the serial console */
Buffer[0] = Character; Buffer[0] = Character;
Buffer[1] = 0; 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) if(DebugConfiguration && BlpStatus.DebugPort == 0)
{ {
/* Find all debug ports */ /* Find all debug ports */
DebugPort = RtlTokenizeWideString(DebugConfiguration, L";", &LastPort); DebugPort = RTL::WideString::TokenizeWideString(DebugConfiguration, L";", &LastPort);
/* Iterate over all debug ports */ /* Iterate over all debug ports */
while(DebugPort != NULLPTR) while(DebugPort != NULLPTR)
{ {
/* Check what port is set for debugging */ /* 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 */ /* Read COM port number */
DebugPort += 3; DebugPort += 3;
@@ -127,7 +127,7 @@ BlpInitializeDebugConsole()
} }
/* Check if custom COM port address supplied */ /* 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 */ /* COM port address provided */
DebugPort += 3; DebugPort += 3;
@@ -170,7 +170,7 @@ BlpInitializeDebugConsole()
/* Enable debug port */ /* Enable debug port */
BlpStatus.DebugPort |= XTBL_DEBUGPORT_SERIAL; 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 */ /* Enable debug port */
BlpStatus.DebugPort |= XTBL_DEBUGPORT_SCREEN; BlpStatus.DebugPort |= XTBL_DEBUGPORT_SCREEN;
@@ -183,7 +183,7 @@ BlpInitializeDebugConsole()
} }
/* Take next debug port */ /* Take next debug port */
DebugPort = RtlTokenizeWideString(NULLPTR, L";", &LastPort); DebugPort = RTL::WideString::TokenizeWideString(NULLPTR, L";", &LastPort);
} }
/* Check if serial debug port is enabled */ /* Check if serial debug port is enabled */
@@ -257,7 +257,7 @@ BlpInitializeSerialPort(IN ULONG PortNumber,
} }
/* Initialize COM port */ /* 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 */ /* Port not found under supplied address */
if(Status == STATUS_NOT_FOUND && PortAddress) if(Status == STATUS_NOT_FOUND && PortAddress)
@@ -268,7 +268,7 @@ BlpInitializeSerialPort(IN ULONG PortNumber,
{ {
/* Try to reinitialize COM port */ /* Try to reinitialize COM port */
BlConsolePrint(L"Enabled I/O space access for all PCI(E) serial controllers found\n"); 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 */ /* Zero fill the buffer and initialize counter */
RtlZeroMemory(MemoryMap, sizeof(EFI_MEMORY_MAP)); RTL::Memory::ZeroMemory(MemoryMap, sizeof(EFI_MEMORY_MAP));
Counter = 0xFF; Counter = 0xFF;
/* Attempt to exit boot services */ /* Attempt to exit boot services */
@@ -141,7 +141,7 @@ BlGetConfigurationTable(IN PEFI_GUID TableGuid,
for(Index = 0; Index < EfiSystemTable->NumberOfTableEntries; Index++) for(Index = 0; Index < EfiSystemTable->NumberOfTableEntries; Index++)
{ {
/* Check if this table matches requested table */ /* 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 */ /* Found requested table, return success */
*Table = EfiSystemTable->ConfigurationTable[Index].VendorTable; *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 <xtblapi.h>
#include <xtver.h> #include <xtver.h>
#include <libxtos.hh>
#include <globals.hh> #include <globals.hh>

View File

@@ -248,7 +248,7 @@ BlInitializePageMap(OUT PXTBL_PAGE_MAPPING PageMap,
IN PAGE_SIZE PageSize) IN PAGE_SIZE PageSize)
{ {
/* Initialize memory mappings */ /* Initialize memory mappings */
RtlInitializeListHead(&PageMap->MemoryMap); RTL::LinkedList::InitializeListHead(&PageMap->MemoryMap);
PageMap->MapSize = 0; PageMap->MapSize = 0;
/* Set page map size/level and memory map address */ /* 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 */ /* Allocate and zero-fill buffer for EFI memory map */
BlAllocateMemoryPool(sizeof(EFI_MEMORY_MAP), (PVOID*)&MemoryMap); 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 */ /* Get EFI memory map */
Status = BlGetMemoryMap(MemoryMap); Status = BlGetMemoryMap(MemoryMap);
@@ -503,7 +503,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
Mapping3->VirtualAddress = NULLPTR; Mapping3->VirtualAddress = NULLPTR;
Mapping3->NumberOfPages = NumberOfMappedPages; Mapping3->NumberOfPages = NumberOfMappedPages;
Mapping3->MemoryType = Mapping2->MemoryType; 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 */ /* 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->VirtualAddress = NULLPTR;
Mapping3->NumberOfPages = NumberOfMappedPages; Mapping3->NumberOfPages = NumberOfMappedPages;
Mapping3->MemoryType = Mapping2->MemoryType; 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 */ /* 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; MappingListEntry = ListEntry->Flink;
/* Remove mapping from the list and free up it's memory */ /* Remove mapping from the list and free up it's memory */
RtlRemoveEntryList(&Mapping2->ListEntry); RTL::LinkedList::RemoveEntryList(&Mapping2->ListEntry);
Status = BlFreeMemoryPool(Mapping2); Status = BlFreeMemoryPool(Mapping2);
ListEntry = MappingListEntry; ListEntry = MappingListEntry;
@@ -575,7 +575,7 @@ BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
if(Mapping2->PhysicalAddress > Mapping1->PhysicalAddress) if(Mapping2->PhysicalAddress > Mapping1->PhysicalAddress)
{ {
/* Insert new mapping in front */ /* Insert new mapping in front */
RtlInsertHeadList(Mapping2->ListEntry.Blink, &Mapping1->ListEntry); RTL::LinkedList::InsertHeadList(Mapping2->ListEntry.Blink, &Mapping1->ListEntry);
return STATUS_EFI_SUCCESS; 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 */ /* 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++; PageMap->MapSize++;
/* Return success */ /* Return success */

View File

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

View File

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

View File

@@ -113,7 +113,7 @@ ChainLoader::BootSystem(IN PXTBL_BOOT_PARAMETERS Parameters)
if(Parameters->Parameters) if(Parameters->Parameters)
{ {
/* Pass arguments to chainloaded image */ /* 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; LoadedImage->LoadOptions = Parameters->Parameters;
} }

View File

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

View File

@@ -27,21 +27,21 @@ Xtos::DeterminePagingLevel(IN CONST PWCHAR Parameters)
CPUID_REGISTERS CpuRegisters; CPUID_REGISTERS CpuRegisters;
/* Prepare CPUID registers to query for STD7 features */ /* 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; CpuRegisters.Leaf = CPUID_GET_VENDOR_STRING;
/* Query CPUID */ /* Query CPUID */
ArCpuId(&CpuRegisters); XtLdrProtocol->Cpu.CpuId(&CpuRegisters);
/* Verify if the CPU supports the STD7 feature leaf (0x00000007) */ /* Verify if the CPU supports the STD7 feature leaf (0x00000007) */
if(CpuRegisters.Eax >= CPUID_GET_STANDARD7_FEATURES) if(CpuRegisters.Eax >= CPUID_GET_STANDARD7_FEATURES)
{ {
/* Prepare CPUID registers to query for LA57 support */ /* 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; CpuRegisters.Leaf = CPUID_GET_STANDARD7_FEATURES;
/* Query CPUID */ /* Query CPUID */
ArCpuId(&CpuRegisters); XtLdrProtocol->Cpu.CpuId(&CpuRegisters);
/* Check if eXtended Physical Addressing (XPA) is enabled and if LA57 is supported by the CPU */ /* Check if eXtended Physical Addressing (XPA) is enabled and if LA57 is supported by the CPU */
if((CpuRegisters.Ecx & CPUID_FEATURES_ECX_LA57) && 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 */ /* Set the trampoline entry point and copy its code into the allocated buffer */
TrampolineEntry = (PXT_TRAMPOLINE_ENTRY)(UINT_PTR)TrampolineAddress; 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 */ /* 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"); XtLdrProtocol->Debug.Print(L"Disabling Linear Address 57-bit (LA57)\n");
/* Write PML4 to CR3 and enable paging */ /* Write PML4 to CR3 and enable paging */
ArWriteControlRegister(3, (UINT_PTR)PageMap->PtePointer); XtLdrProtocol->Cpu.WriteControlRegister(3, (UINT_PTR)PageMap->PtePointer);
ArWriteControlRegister(0, ArReadControlRegister(0) | CR0_PG); XtLdrProtocol->Cpu.WriteControlRegister(0, XtLdrProtocol->Cpu.ReadControlRegister(0) | CR0_PG);
} }
/* Return success */ /* Return success */
@@ -184,7 +184,7 @@ Xtos::MapHardwareMemoryPool(IN PXTBL_PAGE_MAPPING PageMap)
} }
/* Zero fill memory used by P5E */ /* Zero fill memory used by P5E */
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE); XtLdrProtocol->Memory.ZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
/* Make P5E valid */ /* Make P5E valid */
P5eBase[(MM_HARDWARE_VA_START >> MM_P5I_SHIFT) & 0x1FF].Valid = 1; 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 */ /* Zero fill memory used by PXE */
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE); XtLdrProtocol->Memory.ZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
/* Make PXE valid */ /* Make PXE valid */
PxeBase[(MM_HARDWARE_VA_START >> MM_PXI_SHIFT) & 0x1FF].Valid = 1; 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 */ /* Zero fill memory used by PPE */
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE); XtLdrProtocol->Memory.ZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
/* Make PPE valid */ /* Make PPE valid */
PpeBase[(MM_HARDWARE_VA_START >> MM_PPI_SHIFT) & 0x1FF].Valid = 1; 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 */ /* Zero fill memory used by PDE */
RtlZeroMemory((PVOID)Address, EFI_PAGE_SIZE); XtLdrProtocol->Memory.ZeroMemory((PVOID)Address, EFI_PAGE_SIZE);
/* Make PDE valid */ /* Make PDE valid */
PdeBase[((MM_HARDWARE_VA_START >> MM_PDI_SHIFT) & 0x1FF) + Index].Valid = 1; 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 */ /* 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 */ /* Open XTOS system boot directory */
Status = FsHandle->Open(FsHandle, &BootDir, Parameters->SystemPath, EFI_FILE_MODE_READ, 0); 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->BasePage = (UINT_PTR)MemoryMapping->PhysicalAddress / EFI_PAGE_SIZE;
MemoryDescriptor->PageCount = MemoryMapping->NumberOfPages; MemoryDescriptor->PageCount = MemoryMapping->NumberOfPages;
RtlInsertTailList(MemoryDescriptorList, &MemoryDescriptor->ListEntry); XtLdrProtocol->LinkedList.InsertTail(MemoryDescriptorList, &MemoryDescriptor->ListEntry);
Address = Address + sizeof(LOADER_MEMORY_DESCRIPTOR); Address = Address + sizeof(LOADER_MEMORY_DESCRIPTOR);
ListEntry = ListEntry->Flink; ListEntry = ListEntry->Flink;
@@ -281,7 +281,7 @@ Xtos::GetSystemResourcesList(IN PXTBL_PAGE_MAPPING PageMap,
AcpiResource = (PSYSTEM_RESOURCE_ACPI)Address; AcpiResource = (PSYSTEM_RESOURCE_ACPI)Address;
RtlZeroMemory(AcpiResource, sizeof(SYSTEM_RESOURCE_ACPI)); XtLdrProtocol->Memory.ZeroMemory(AcpiResource, sizeof(SYSTEM_RESOURCE_ACPI));
/* Load FrameBuffer protocol */ /* Load FrameBuffer protocol */
Status = XtLdrProtocol->Protocol.Open(&ProtocolHandle, (PVOID*)&AcpiProtocol, &AcpiGuid); Status = XtLdrProtocol->Protocol.Open(&ProtocolHandle, (PVOID*)&AcpiProtocol, &AcpiGuid);
@@ -300,7 +300,7 @@ Xtos::GetSystemResourcesList(IN PXTBL_PAGE_MAPPING PageMap,
/* No need to map ACPI */ /* No need to map ACPI */
AcpiResource->Header.VirtualAddress = 0; AcpiResource->Header.VirtualAddress = 0;
RtlInsertTailList(SystemResourcesList, &AcpiResource->Header.ListEntry); XtLdrProtocol->LinkedList.InsertTail(SystemResourcesList, &AcpiResource->Header.ListEntry);
/* Close FrameBuffer protocol */ /* Close FrameBuffer protocol */
XtLdrProtocol->Protocol.Close(&ProtocolHandle, &FrameBufGuid); XtLdrProtocol->Protocol.Close(&ProtocolHandle, &FrameBufGuid);
@@ -309,7 +309,7 @@ Xtos::GetSystemResourcesList(IN PXTBL_PAGE_MAPPING PageMap,
FrameBufferResource = (PSYSTEM_RESOURCE_FRAMEBUFFER)Address; FrameBufferResource = (PSYSTEM_RESOURCE_FRAMEBUFFER)Address;
RtlZeroMemory(FrameBufferResource, sizeof(SYSTEM_RESOURCE_FRAMEBUFFER)); XtLdrProtocol->Memory.ZeroMemory(FrameBufferResource, sizeof(SYSTEM_RESOURCE_FRAMEBUFFER));
/* Load FrameBuffer protocol */ /* Load FrameBuffer protocol */
Status = XtLdrProtocol->Protocol.Open(&ProtocolHandle, (PVOID*)&FrameBufProtocol, &FrameBufGuid); 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); *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); XtLdrProtocol->Memory.PhysicalListToVirtual(PageMap, SystemResourcesList, PhysicalBase, VirtualBase);
@@ -420,7 +420,7 @@ Xtos::InitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
UINT ParametersSize; UINT ParametersSize;
/* Calculate size of parameters */ /* 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 */ /* Calculate number of pages needed for initialization block */
BlockPages = EFI_SIZE_TO_PAGES(sizeof(KERNEL_INITIALIZATION_BLOCK) + ParametersSize); 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 */ /* Initialize and zero-fill kernel initialization block */
LoaderBlock = (PKERNEL_INITIALIZATION_BLOCK)(UINT_PTR)Address; 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 */ /* Set basic loader block properties */
LoaderBlock->BlockSize = sizeof(KERNEL_INITIALIZATION_BLOCK); LoaderBlock->BlockSize = sizeof(KERNEL_INITIALIZATION_BLOCK);
@@ -462,7 +462,7 @@ Xtos::InitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
/* Copy parameters to kernel initialization block */ /* Copy parameters to kernel initialization block */
LoaderBlock->KernelParameters = (PWCHAR)((UINT_PTR)*VirtualAddress + sizeof(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, Parameters->Parameters,
ParametersSize); ParametersSize);
@@ -473,11 +473,11 @@ Xtos::InitializeLoaderBlock(IN PXTBL_PAGE_MAPPING PageMap,
/* Calculate next valid virtual address */ /* Calculate next valid virtual address */
*VirtualAddress = (PUINT8)*VirtualAddress + (BlockPages * EFI_PAGE_SIZE); *VirtualAddress = (PUINT8)*VirtualAddress + (BlockPages * EFI_PAGE_SIZE);
RtlInitializeListHead(&LoaderBlock->SystemResourcesListHead); XtLdrProtocol->LinkedList.InitializeHead(&LoaderBlock->SystemResourcesListHead);
GetSystemResourcesList(PageMap, VirtualAddress, &LoaderBlock->SystemResourcesListHead); GetSystemResourcesList(PageMap, VirtualAddress, &LoaderBlock->SystemResourcesListHead);
/* Initialize memory descriptor list */ /* Initialize memory descriptor list */
RtlInitializeListHead(&LoaderBlock->MemoryDescriptorListHead); XtLdrProtocol->LinkedList.InitializeHead(&LoaderBlock->MemoryDescriptorListHead);
GetMemoryDescriptorList(PageMap, VirtualAddress, &LoaderBlock->MemoryDescriptorListHead); GetMemoryDescriptorList(PageMap, VirtualAddress, &LoaderBlock->MemoryDescriptorListHead);
/* Return success */ /* Return success */

View File

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

View File

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

View File

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

View File

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

View File

@@ -937,60 +937,3 @@ AR::CpuFunc::YieldProcessor(VOID)
: :
: "memory"); : "memory");
} }
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
VOID
ArClearInterruptFlag(VOID)
{
AR::CpuFunc::ClearInterruptFlag();
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
BOOLEAN
ArCpuId(IN OUT PCPUID_REGISTERS Registers)
{
return AR::CpuFunc::CpuId(Registers);
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
VOID
ArHalt(VOID)
{
AR::CpuFunc::Halt();
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
ULONG_PTR
ArReadControlRegister(IN USHORT ControlRegister)
{
return AR::CpuFunc::ReadControlRegister(ControlRegister);
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
ULONGLONG
ArReadModelSpecificRegister(IN ULONG Register)
{
return AR::CpuFunc::ReadModelSpecificRegister(Register);
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
VOID
ArWriteControlRegister(IN USHORT ControlRegister,
IN UINT_PTR Value)
{
AR::CpuFunc::WriteControlRegister(ControlRegister, Value);
}

View File

@@ -888,60 +888,3 @@ AR::CpuFunc::YieldProcessor(VOID)
: :
: "memory"); : "memory");
} }
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
VOID
ArClearInterruptFlag(VOID)
{
AR::CpuFunc::ClearInterruptFlag();
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
BOOLEAN
ArCpuId(IN OUT PCPUID_REGISTERS Registers)
{
return AR::CpuFunc::CpuId(Registers);
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
VOID
ArHalt(VOID)
{
AR::CpuFunc::Halt();
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
ULONG_PTR
ArReadControlRegister(IN USHORT ControlRegister)
{
return AR::CpuFunc::ReadControlRegister(ControlRegister);
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
ULONGLONG
ArReadModelSpecificRegister(IN ULONG Register)
{
return AR::CpuFunc::ReadModelSpecificRegister(Register);
}
/* NEEDED BY XTLDR */
XTCLINK
XTCDECL
VOID
ArWriteControlRegister(IN USHORT ControlRegister,
IN UINT_PTR Value)
{
AR::CpuFunc::WriteControlRegister(ControlRegister, Value);
}

View File

@@ -287,24 +287,3 @@ HL::ComPort::WriteComPort(IN PCPPORT Port,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* TEMPORARY FOR XTLDR */
XTCDECL
XTSTATUS
HlWriteComPort(IN PCPPORT Port,
IN UCHAR Byte)
{
return HL::ComPort::WriteComPort(Port, Byte);
}
/* TEMPORARY FOR XTLDR */
XTCDECL
XTSTATUS
HlInitializeComPort(IN OUT PCPPORT Port,
IN PUCHAR PortAddress,
IN ULONG BaudRate)
{
return HL::ComPort::InitializeComPort(Port, PortAddress, BaudRate);
}

View File

@@ -3060,17 +3060,3 @@ RTL::WideString::WriteValue(PRTL_PRINT_CONTEXT Context,
/* Return success */ /* Return success */
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/* XTLDR API */
XTCLINK
XTAPI
XTSTATUS
RtlFormatWideString(IN PRTL_PRINT_CONTEXT Context,
IN PCWSTR Format,
IN VA_LIST ArgumentList)
{
return RTL::WideString::FormatWideString(Context, Format, ArgumentList);
}