Finish moving global variables into classes
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* FILE: sdk/xtdk/bltypes.h
|
||||
* DESCRIPTION: XT Boot Loader structures definitions
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
* Aiken Harris <harraiken91@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef __XTDK_BLTYPES_H
|
||||
@@ -280,13 +281,10 @@ typedef struct _XTBL_PAGE_MAPPING
|
||||
/* XTLDR Status data */
|
||||
typedef struct _XTBL_STATUS
|
||||
{
|
||||
PBL_XT_BOOT_MENU BootMenu;
|
||||
BOOLEAN BootServices;
|
||||
ULONG DebugPort;
|
||||
PVOID LoaderBase;
|
||||
ULONGLONG LoaderSize;
|
||||
BOOLEAN BootServices;
|
||||
INT_PTR SecureBoot;
|
||||
CPPORT SerialPort;
|
||||
} XTBL_STATUS, *PXTBL_STATUS;
|
||||
|
||||
/* XT framebuffer video mode information structure definition */
|
||||
|
@@ -19,9 +19,9 @@ list(APPEND XTLDR_SOURCE
|
||||
${XTLDR_SOURCE_DIR}/bootutil.cc
|
||||
${XTLDR_SOURCE_DIR}/config.cc
|
||||
${XTLDR_SOURCE_DIR}/console.cc
|
||||
${XTLDR_SOURCE_DIR}/data.cc
|
||||
${XTLDR_SOURCE_DIR}/debug.cc
|
||||
${XTLDR_SOURCE_DIR}/efiutils.cc
|
||||
${XTLDR_SOURCE_DIR}/globals.cc
|
||||
${XTLDR_SOURCE_DIR}/memory.cc
|
||||
${XTLDR_SOURCE_DIR}/protocol.cc
|
||||
${XTLDR_SOURCE_DIR}/shell.cc
|
||||
|
@@ -32,6 +32,8 @@ Memory::BuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
PXTBL_MEMORY_MAPPING Mapping;
|
||||
PXTBL_MODULE_INFO ModuleInfo;
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
PVOID LoaderBase;
|
||||
ULONGLONG LoaderSize;
|
||||
EFI_STATUS Status;
|
||||
|
||||
/* Allocate pages for the Page Map */
|
||||
@@ -86,12 +88,15 @@ Memory::BuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
ModulesListEntry = ModulesListEntry->Flink;
|
||||
}
|
||||
|
||||
/* Get boot loader image information */
|
||||
XtLoader::GetLoaderImageInformation(&LoaderBase, &LoaderSize);
|
||||
|
||||
/* Make sure boot loader image base and size are set */
|
||||
if(BlpStatus.LoaderBase && BlpStatus.LoaderSize)
|
||||
if(LoaderBase && LoaderSize)
|
||||
{
|
||||
/* Map boot loader code as well */
|
||||
Status = MapVirtualMemory(PageMap, BlpStatus.LoaderBase, BlpStatus.LoaderBase,
|
||||
EFI_SIZE_TO_PAGES(BlpStatus.LoaderSize), LoaderFirmwareTemporary);
|
||||
Status = MapVirtualMemory(PageMap, LoaderBase, LoaderBase,
|
||||
EFI_SIZE_TO_PAGES(LoaderSize), LoaderFirmwareTemporary);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Mapping boot loader code failed */
|
||||
|
@@ -29,6 +29,8 @@ Memory::BuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
EFI_PHYSICAL_ADDRESS Address, DirectoryAddress;
|
||||
PXTBL_MODULE_INFO ModuleInfo;
|
||||
PXTBL_MEMORY_MAPPING Mapping;
|
||||
PVOID LoaderBase;
|
||||
ULONGLONG LoaderSize;
|
||||
EFI_STATUS Status;
|
||||
ULONG Index;
|
||||
|
||||
@@ -122,12 +124,15 @@ Memory::BuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
ModulesListEntry = ModulesListEntry->Flink;
|
||||
}
|
||||
|
||||
/* Get boot loader image information */
|
||||
XtLoader::GetLoaderImageInformation(&LoaderBase, &LoaderSize);
|
||||
|
||||
/* Make sure boot loader image base and size are set */
|
||||
if(BlpStatus.LoaderBase && BlpStatus.LoaderSize)
|
||||
if(LoaderBase && LoaderSize)
|
||||
{
|
||||
/* Map boot loader code as well */
|
||||
Status = MapVirtualMemory(PageMap, BlpStatus.LoaderBase, BlpStatus.LoaderBase,
|
||||
EFI_SIZE_TO_PAGES(BlpStatus.LoaderSize), LoaderFirmwareTemporary);
|
||||
Status = MapVirtualMemory(PageMap, LoaderBase, LoaderBase,
|
||||
EFI_SIZE_TO_PAGES(LoaderSize), LoaderFirmwareTemporary);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Mapping boot loader code failed */
|
||||
|
@@ -465,7 +465,8 @@ Configuration::ParseCommandLine(VOID)
|
||||
RTL::LinkedList::InitializeListHead(&Config);
|
||||
|
||||
/* Handle loaded image protocol */
|
||||
Status = EfiSystemTable->BootServices->HandleProtocol(EfiImageHandle, &LIPGuid, (PVOID *)&LoadedImage);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->HandleProtocol(XtLoader::GetEfiImageHandle(),
|
||||
&LIPGuid, (PVOID *)&LoadedImage);
|
||||
if(Status == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Check if launched from UEFI shell */
|
||||
|
@@ -49,7 +49,7 @@ VOID
|
||||
Console::ClearScreen()
|
||||
{
|
||||
/* Clear screen */
|
||||
EfiSystemTable->ConOut->ClearScreen(EfiSystemTable->ConOut);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->ClearScreen(XtLoader::GetEfiSystemTable()->ConOut);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ XTCDECL
|
||||
VOID
|
||||
Console::DisableCursor()
|
||||
{
|
||||
EfiSystemTable->ConOut->EnableCursor(EfiSystemTable->ConOut, FALSE);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->EnableCursor(XtLoader::GetEfiSystemTable()->ConOut, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ XTCDECL
|
||||
VOID
|
||||
Console::EnableCursor()
|
||||
{
|
||||
EfiSystemTable->ConOut->EnableCursor(EfiSystemTable->ConOut, TRUE);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->EnableCursor(XtLoader::GetEfiSystemTable()->ConOut, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,13 +92,13 @@ VOID
|
||||
Console::InitializeConsole()
|
||||
{
|
||||
/* Clear console buffers */
|
||||
EfiSystemTable->ConIn->Reset(EfiSystemTable->ConIn, TRUE);
|
||||
EfiSystemTable->ConOut->Reset(EfiSystemTable->ConOut, TRUE);
|
||||
EfiSystemTable->StdErr->Reset(EfiSystemTable->StdErr, TRUE);
|
||||
XtLoader::GetEfiSystemTable()->ConIn->Reset(XtLoader::GetEfiSystemTable()->ConIn, TRUE);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->Reset(XtLoader::GetEfiSystemTable()->ConOut, TRUE);
|
||||
XtLoader::GetEfiSystemTable()->StdErr->Reset(XtLoader::GetEfiSystemTable()->StdErr, TRUE);
|
||||
|
||||
/* Make sure that current console mode is 80x25 characters, as some broken EFI implementations might
|
||||
* set different mode that do not fit on the screen, causing a text to be displayed offscreen */
|
||||
if(EfiSystemTable->ConOut->Mode->Mode != 0)
|
||||
if(XtLoader::GetEfiSystemTable()->ConOut->Mode->Mode != 0)
|
||||
{
|
||||
/* Set console mode to 0, which is standard, 80x25 text mode */
|
||||
SetMode(0);
|
||||
@@ -142,10 +142,10 @@ Console::Print(IN PCWSTR Format,
|
||||
RTL::WideString::FormatWideString(&ConsolePrintContext, (PWCHAR)Format, Arguments);
|
||||
|
||||
/* Print to serial console only if not running under OVMF */
|
||||
if(RTL::WideString::CompareWideString(EfiSystemTable->FirmwareVendor, L"EDK II", 6) != 0)
|
||||
if(RTL::WideString::CompareWideString(XtLoader::GetEfiSystemTable()->FirmwareVendor, L"EDK II", 6) != 0)
|
||||
{
|
||||
/* Check if debugging enabled and if EFI serial port is fully initialized */
|
||||
if(DEBUG && (BlpStatus.SerialPort.Flags & COMPORT_FLAG_INIT))
|
||||
if(DEBUG && Debug::SerialPortReady())
|
||||
{
|
||||
/* Format and print the string to the serial console */
|
||||
RTL::WideString::FormatWideString(&SerialPrintContext, (PWCHAR)Format, Arguments);
|
||||
@@ -182,7 +182,7 @@ Console::PutChar(IN WCHAR Character)
|
||||
/* Write character to the screen console */
|
||||
Buffer[0] = Character;
|
||||
Buffer[1] = 0;
|
||||
EfiSystemTable->ConOut->OutputString(EfiSystemTable->ConOut, Buffer);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->OutputString(XtLoader::GetEfiSystemTable()->ConOut, Buffer);
|
||||
|
||||
/* Return success */
|
||||
return STATUS_SUCCESS;
|
||||
@@ -206,7 +206,8 @@ VOID
|
||||
Console::QueryMode(OUT PUINT_PTR ResX,
|
||||
OUT PUINT_PTR ResY)
|
||||
{
|
||||
EfiSystemTable->ConOut->QueryMode(EfiSystemTable->ConOut, EfiSystemTable->ConOut->Mode->Mode, ResX, ResY);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->QueryMode(XtLoader::GetEfiSystemTable()->ConOut,
|
||||
XtLoader::GetEfiSystemTable()->ConOut->Mode->Mode, ResX, ResY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +224,7 @@ XTCDECL
|
||||
VOID
|
||||
Console::ReadKeyStroke(OUT PEFI_INPUT_KEY Key)
|
||||
{
|
||||
EfiSystemTable->ConIn->ReadKeyStroke(EfiSystemTable->ConIn, Key);
|
||||
XtLoader::GetEfiSystemTable()->ConIn->ReadKeyStroke(XtLoader::GetEfiSystemTable()->ConIn, Key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,7 +238,7 @@ XTCDECL
|
||||
VOID
|
||||
Console::ResetInputBuffer()
|
||||
{
|
||||
EfiSystemTable->ConIn->Reset(EfiSystemTable->ConIn, FALSE);
|
||||
XtLoader::GetEfiSystemTable()->ConIn->Reset(XtLoader::GetEfiSystemTable()->ConIn, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,7 +255,7 @@ XTCDECL
|
||||
VOID
|
||||
Console::SetAttributes(IN ULONGLONG Attributes)
|
||||
{
|
||||
EfiSystemTable->ConOut->SetAttribute(EfiSystemTable->ConOut, Attributes);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->SetAttribute(XtLoader::GetEfiSystemTable()->ConOut, Attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +276,7 @@ VOID
|
||||
Console::SetCursorPosition(IN ULONGLONG PosX,
|
||||
IN ULONGLONG PosY)
|
||||
{
|
||||
EfiSystemTable->ConOut->SetCursorPosition(EfiSystemTable->ConOut, PosX, PosY);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->SetCursorPosition(XtLoader::GetEfiSystemTable()->ConOut, PosX, PosY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,7 +293,7 @@ XTCDECL
|
||||
EFI_STATUS
|
||||
Console::SetMode(IN ULONGLONG Mode)
|
||||
{
|
||||
return EfiSystemTable->ConOut->SetMode(EfiSystemTable->ConOut, Mode);
|
||||
return XtLoader::GetEfiSystemTable()->ConOut->SetMode(XtLoader::GetEfiSystemTable()->ConOut, Mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,5 +310,5 @@ XTCDECL
|
||||
VOID
|
||||
Console::Write(IN PCWSTR String)
|
||||
{
|
||||
EfiSystemTable->ConOut->OutputString(EfiSystemTable->ConOut, (PWSTR)String);
|
||||
XtLoader::GetEfiSystemTable()->ConOut->OutputString(XtLoader::GetEfiSystemTable()->ConOut, (PWSTR)String);
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
/**
|
||||
* PROJECT: ExectOS
|
||||
* COPYRIGHT: See COPYING.md in the top level directory
|
||||
* FILE: xtldr/globals.cc
|
||||
* DESCRIPTION: XT Boot Loader global variables
|
||||
* FILE: xtldr/data.cc
|
||||
* DESCRIPTION: XT Boot Loader global and static data
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
* Aiken Harris <harraiken91@gmail.com>
|
||||
*/
|
||||
|
||||
#include <xtldr.hh>
|
||||
@@ -28,6 +29,12 @@ PCWSTR Configuration::EditableConfigOptions[] = {
|
||||
/* XT Boot Loader serial ports list */
|
||||
ULONG Debug::ComPortList[COMPORT_COUNT] = COMPORT_ADDRESS;
|
||||
|
||||
/* A list of enabled debug ports */
|
||||
ULONG Debug::EnabledDebugPorts;
|
||||
|
||||
/* XT Boot Loader serial port handle */
|
||||
CPPORT Debug::SerialPort;
|
||||
|
||||
/* XT Boot Loader registered boot protocol list */
|
||||
LIST_ENTRY Protocol::BootProtocols;
|
||||
|
||||
@@ -40,13 +47,14 @@ LIST_ENTRY Protocol::LoadedModules;
|
||||
/* List of available block devices */
|
||||
LIST_ENTRY Volume::EfiBlockDevices;
|
||||
|
||||
|
||||
|
||||
/* XT Boot Loader status data */
|
||||
XTBL_STATUS BlpStatus = {0};
|
||||
/* Pointer to the boot menu callback routine */
|
||||
PBL_XT_BOOT_MENU XtLoader::BootMenu = NULLPTR;
|
||||
|
||||
/* EFI Image Handle */
|
||||
EFI_HANDLE EfiImageHandle;
|
||||
EFI_HANDLE XtLoader::EfiImageHandle;
|
||||
|
||||
/* EFI System Table */
|
||||
PEFI_SYSTEM_TABLE EfiSystemTable;
|
||||
PEFI_SYSTEM_TABLE XtLoader::EfiSystemTable;
|
||||
|
||||
/* XT Boot Loader status data */
|
||||
XTBL_STATUS XtLoader::LoaderStatus = {0};
|
@@ -39,7 +39,8 @@ Debug::ActivateSerialIOController()
|
||||
}
|
||||
|
||||
/* Get all instances of PciRootBridgeIo */
|
||||
Status = EfiSystemTable->BootServices->LocateHandle(ByProtocol, &PciGuid, NULLPTR, &PciHandleSize, PciHandle);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->LocateHandle(ByProtocol, &PciGuid, NULLPTR,
|
||||
&PciHandleSize, PciHandle);
|
||||
if(Status == STATUS_EFI_BUFFER_TOO_SMALL)
|
||||
{
|
||||
/* Reallocate more memory as requested by UEFI */
|
||||
@@ -52,7 +53,8 @@ Debug::ActivateSerialIOController()
|
||||
}
|
||||
|
||||
/* Second attempt to get instances of PciRootBridgeIo */
|
||||
Status = EfiSystemTable->BootServices->LocateHandle(ByProtocol, &PciGuid, NULLPTR, &PciHandleSize, PciHandle);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->LocateHandle(ByProtocol, &PciGuid, NULLPTR,
|
||||
&PciHandleSize, PciHandle);
|
||||
}
|
||||
|
||||
/* Make sure successfully obtained PciRootBridgeIo instances */
|
||||
@@ -66,7 +68,7 @@ Debug::ActivateSerialIOController()
|
||||
for(Index = 0; Index < (PciHandleSize / sizeof(EFI_HANDLE)); Index++)
|
||||
{
|
||||
/* Get inferface from the protocol */
|
||||
Status = EfiSystemTable->BootServices->HandleProtocol(PciHandle[Index], &PciGuid, (PVOID*)&PciDev);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->HandleProtocol(PciHandle[Index], &PciGuid, (PVOID*)&PciDev);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to get interface */
|
||||
@@ -135,7 +137,7 @@ Debug::InitializeDebugConsole()
|
||||
Configuration::GetValue(L"DEBUG", &DebugConfiguration);
|
||||
|
||||
/* Make sure any debug options are provided and debug console is not initialized yet */
|
||||
if(DebugConfiguration && BlpStatus.DebugPort == 0)
|
||||
if(DebugConfiguration && EnabledDebugPorts == 0)
|
||||
{
|
||||
/* Find all debug ports */
|
||||
DebugPort = RTL::WideString::TokenizeWideString(DebugConfiguration, L";", &LastPort);
|
||||
@@ -198,12 +200,12 @@ Debug::InitializeDebugConsole()
|
||||
}
|
||||
|
||||
/* Enable debug port */
|
||||
BlpStatus.DebugPort |= XTBL_DEBUGPORT_SERIAL;
|
||||
EnabledDebugPorts |= XTBL_DEBUGPORT_SERIAL;
|
||||
}
|
||||
else if(RTL::WideString::CompareWideStringInsensitive(DebugPort, L"SCREEN", 5) == 0)
|
||||
{
|
||||
/* Enable debug port */
|
||||
BlpStatus.DebugPort |= XTBL_DEBUGPORT_SCREEN;
|
||||
EnabledDebugPorts |= XTBL_DEBUGPORT_SCREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -217,14 +219,14 @@ Debug::InitializeDebugConsole()
|
||||
}
|
||||
|
||||
/* Check if serial debug port is enabled */
|
||||
if(BlpStatus.DebugPort & XTBL_DEBUGPORT_SERIAL)
|
||||
if(EnabledDebugPorts & XTBL_DEBUGPORT_SERIAL)
|
||||
{
|
||||
/* Try to initialize COM port */
|
||||
Status = InitializeSerialPort(PortNumber, PortAddress, BaudRate);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Remove serial debug port, as COM port initialization failed and return */
|
||||
BlpStatus.DebugPort &= ~XTBL_DEBUGPORT_SERIAL;
|
||||
EnabledDebugPorts &= ~XTBL_DEBUGPORT_SERIAL;
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
@@ -287,7 +289,7 @@ Debug::InitializeSerialPort(IN ULONG PortNumber,
|
||||
}
|
||||
|
||||
/* Initialize COM port */
|
||||
Status = HL::ComPort::InitializeComPort(&BlpStatus.SerialPort, (PUCHAR)UlongToPtr(PortAddress), BaudRate);
|
||||
Status = HL::ComPort::InitializeComPort(&SerialPort, (PUCHAR)UlongToPtr(PortAddress), BaudRate);
|
||||
|
||||
/* Port not found under supplied address */
|
||||
if(Status == STATUS_NOT_FOUND && PortAddress)
|
||||
@@ -298,7 +300,7 @@ Debug::InitializeSerialPort(IN ULONG PortNumber,
|
||||
{
|
||||
/* Try to reinitialize COM port */
|
||||
Console::Print(L"Enabled I/O space access for all PCI(E) serial controllers found\n");
|
||||
Status = HL::ComPort::InitializeComPort(&BlpStatus.SerialPort, (PUCHAR)UlongToPtr(PortAddress), BaudRate);
|
||||
Status = HL::ComPort::InitializeComPort(&SerialPort, (PUCHAR)UlongToPtr(PortAddress), BaudRate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,14 +347,14 @@ Debug::Print(IN PCWSTR Format,
|
||||
VA_START(Arguments, Format);
|
||||
|
||||
/* Check if serial debug port is enabled */
|
||||
if((BlpStatus.DebugPort & XTBL_DEBUGPORT_SERIAL) && (BlpStatus.SerialPort.Flags & COMPORT_FLAG_INIT))
|
||||
if((EnabledDebugPorts & XTBL_DEBUGPORT_SERIAL) && (SerialPort.Flags & COMPORT_FLAG_INIT))
|
||||
{
|
||||
/* Format and print the string to the serial console */
|
||||
RTL::WideString::FormatWideString(&SerialPrintContext, (PWCHAR)Format, Arguments);
|
||||
}
|
||||
|
||||
/* Check if screen debug port is enabled and Boot Services are still available */
|
||||
if((BlpStatus.DebugPort & XTBL_DEBUGPORT_SCREEN) && (BlpStatus.BootServices == TRUE))
|
||||
if((EnabledDebugPorts & XTBL_DEBUGPORT_SCREEN) && (XtLoader::GetBootServicesStatus() == TRUE))
|
||||
{
|
||||
/* Format and print the string to the screen */
|
||||
RTL::WideString::FormatWideString(&ConsolePrintContext, (PWCHAR)Format, Arguments);
|
||||
@@ -382,5 +384,12 @@ Debug::PutChar(IN WCHAR Character)
|
||||
/* Write character to the serial console */
|
||||
Buffer[0] = Character;
|
||||
Buffer[1] = 0;
|
||||
return HL::ComPort::WriteComPort(&BlpStatus.SerialPort, Buffer[0]);
|
||||
return HL::ComPort::WriteComPort(&SerialPort, Buffer[0]);
|
||||
}
|
||||
|
||||
XTCDECL
|
||||
BOOLEAN
|
||||
Debug::SerialPortReady()
|
||||
{
|
||||
return (BOOLEAN)(SerialPort.Flags & COMPORT_FLAG_INIT);
|
||||
}
|
@@ -76,7 +76,7 @@ EfiUtils::ExitBootServices()
|
||||
ULONG Counter;
|
||||
|
||||
/* Boot Services might be partially shutdown, so mark them as unavailable */
|
||||
BlpStatus.BootServices = FALSE;
|
||||
XtLoader::DisableBootServices();
|
||||
|
||||
/* Allocate buffer for EFI memory map */
|
||||
Status = Memory::AllocatePool(sizeof(EFI_MEMORY_MAP), (PVOID*)&MemoryMap);
|
||||
@@ -103,7 +103,8 @@ EfiUtils::ExitBootServices()
|
||||
}
|
||||
|
||||
/* Exit boot services */
|
||||
Status = EfiSystemTable->BootServices->ExitBootServices(EfiImageHandle, MemoryMap->MapKey);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->ExitBootServices(XtLoader::GetEfiImageHandle(),
|
||||
MemoryMap->MapKey);
|
||||
if(Status == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
break;
|
||||
@@ -138,13 +139,14 @@ EfiUtils::GetConfigurationTable(IN PEFI_GUID TableGuid,
|
||||
SIZE_T Index;
|
||||
|
||||
/* Iterate through all system configuration tables */
|
||||
for(Index = 0; Index < EfiSystemTable->NumberOfTableEntries; Index++)
|
||||
for(Index = 0; Index < XtLoader::GetEfiSystemTable()->NumberOfTableEntries; Index++)
|
||||
{
|
||||
/* Check if this table matches requested table */
|
||||
if(RTL::Guid::CompareGuids((PGUID)&(EfiSystemTable->ConfigurationTable[Index].VendorGuid), (PGUID)TableGuid))
|
||||
if(RTL::Guid::CompareGuids((PGUID)&(XtLoader::GetEfiSystemTable()->ConfigurationTable[Index].VendorGuid),
|
||||
(PGUID)TableGuid))
|
||||
{
|
||||
/* Found requested table, return success */
|
||||
*Table = EfiSystemTable->ConfigurationTable[Index].VendorTable;
|
||||
*Table = XtLoader::GetEfiSystemTable()->ConfigurationTable[Index].VendorTable;
|
||||
return STATUS_EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -190,7 +192,8 @@ EfiUtils::GetEfiVariable(IN PEFI_GUID Vendor,
|
||||
}
|
||||
|
||||
/* Attempt to get variable value */
|
||||
Status = EfiSystemTable->RuntimeServices->GetVariable((PWCHAR)VariableName, Vendor, NULLPTR, &Size, Buffer);
|
||||
Status = XtLoader::GetEfiSystemTable()->RuntimeServices->GetVariable((PWCHAR)VariableName, Vendor, NULLPTR,
|
||||
&Size, Buffer);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to get variable, probably not found such one */
|
||||
@@ -244,12 +247,12 @@ EfiUtils::GetSecureBootStatus()
|
||||
UINT_PTR Size;
|
||||
|
||||
Size = sizeof(INT_PTR);
|
||||
if(EfiSystemTable->RuntimeServices->GetVariable((PWCHAR)L"SecureBoot", &VarGuid,
|
||||
if(XtLoader::GetEfiSystemTable()->RuntimeServices->GetVariable((PWCHAR)L"SecureBoot", &VarGuid,
|
||||
NULLPTR, &Size, &VarValue) == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
SecureBootStatus = VarValue;
|
||||
Size = sizeof(INT_PTR);
|
||||
if((EfiSystemTable->RuntimeServices->GetVariable((PWCHAR)L"SetupMode", &VarGuid,
|
||||
if((XtLoader::GetEfiSystemTable()->RuntimeServices->GetVariable((PWCHAR)L"SetupMode", &VarGuid,
|
||||
NULLPTR, &Size, &VarValue) == STATUS_EFI_SUCCESS) && VarValue != 0)
|
||||
{
|
||||
SecureBootStatus = -1;
|
||||
@@ -284,7 +287,7 @@ EfiUtils::InitializeEntropy(PULONGLONG RNGBuffer)
|
||||
Seed = 0;
|
||||
|
||||
/* Locate RNG protocol */
|
||||
Status = EfiSystemTable->BootServices->LocateProtocol(&RngGuid, NULLPTR, (PVOID *)&Rng);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->LocateProtocol(&RngGuid, NULLPTR, (PVOID *)&Rng);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to locate RNG protocol, return status code */
|
||||
@@ -331,7 +334,8 @@ EfiUtils::LoadEfiImage(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath,
|
||||
OUT PEFI_HANDLE ImageHandle)
|
||||
{
|
||||
/* Load EFI image */
|
||||
return EfiSystemTable->BootServices->LoadImage(FALSE, EfiImageHandle, DevicePath, ImageData, ImageSize, ImageHandle);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->LoadImage(FALSE, XtLoader::GetEfiImageHandle(), DevicePath,
|
||||
ImageData, ImageSize, ImageHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +350,7 @@ EFI_STATUS
|
||||
EfiUtils::RebootSystem()
|
||||
{
|
||||
/* Reboot machine */
|
||||
return EfiSystemTable->RuntimeServices->ResetSystem(EfiResetCold, STATUS_EFI_SUCCESS, 0, NULLPTR);
|
||||
return XtLoader::GetEfiSystemTable()->RuntimeServices->ResetSystem(EfiResetCold, STATUS_EFI_SUCCESS, 0, NULLPTR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +383,8 @@ EfiUtils::SetEfiVariable(IN PEFI_GUID Vendor,
|
||||
|
||||
/* Set EFI variable */
|
||||
Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
|
||||
return EfiSystemTable->RuntimeServices->SetVariable((PWCHAR)VariableName, Vendor, Attributes, Size, VariableValue);
|
||||
return XtLoader::GetEfiSystemTable()->RuntimeServices->SetVariable((PWCHAR)VariableName, Vendor, Attributes,
|
||||
Size, VariableValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,7 +399,7 @@ EFI_STATUS
|
||||
EfiUtils::ShutdownSystem()
|
||||
{
|
||||
/* Shutdown machine */
|
||||
return EfiSystemTable->RuntimeServices->ResetSystem(EfiResetShutdown, STATUS_EFI_SUCCESS, 0, NULLPTR);
|
||||
return XtLoader::GetEfiSystemTable()->RuntimeServices->ResetSystem(EfiResetShutdown, STATUS_EFI_SUCCESS, 0, NULLPTR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,7 +416,7 @@ XTCDECL
|
||||
VOID
|
||||
EfiUtils::SleepExecution(IN ULONG_PTR Milliseconds)
|
||||
{
|
||||
EfiSystemTable->BootServices->Stall(Milliseconds * 1000);
|
||||
XtLoader::GetEfiSystemTable()->BootServices->Stall(Milliseconds * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,7 +433,7 @@ XTCDECL
|
||||
EFI_STATUS
|
||||
EfiUtils::StartEfiImage(IN EFI_HANDLE ImageHandle)
|
||||
{
|
||||
return EfiSystemTable->BootServices->StartImage(ImageHandle, NULLPTR, NULLPTR);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->StartImage(ImageHandle, NULLPTR, NULLPTR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,5 +458,5 @@ EfiUtils::WaitForEfiEvent(IN UINT_PTR NumberOfEvents,
|
||||
IN PEFI_EVENT Event,
|
||||
OUT PUINT_PTR Index)
|
||||
{
|
||||
return EfiSystemTable->BootServices->WaitForEvent(NumberOfEvents, Event, Index);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->WaitForEvent(NumberOfEvents, Event, Index);
|
||||
}
|
||||
|
@@ -90,12 +90,15 @@ class Debug
|
||||
{
|
||||
private:
|
||||
STATIC ULONG ComPortList[COMPORT_COUNT];
|
||||
STATIC ULONG EnabledDebugPorts;
|
||||
STATIC CPPORT SerialPort;
|
||||
|
||||
public:
|
||||
STATIC XTCDECL EFI_STATUS InitializeDebugConsole();
|
||||
STATIC XTCDECL VOID Print(IN PCWSTR Format,
|
||||
IN ...);
|
||||
STATIC XTCDECL XTSTATUS PutChar(IN WCHAR Character);
|
||||
STATIC XTCDECL BOOLEAN SerialPortReady();
|
||||
|
||||
private:
|
||||
STATIC XTCDECL EFI_STATUS ActivateSerialIOController();
|
||||
@@ -214,7 +217,6 @@ class Protocol
|
||||
STATIC XTCDECL EFI_STATUS OpenProtocolHandle(IN EFI_HANDLE Handle,
|
||||
OUT PVOID *ProtocolHandler,
|
||||
IN PEFI_GUID ProtocolGuid);
|
||||
STATIC XTCDECL VOID RegisterBootMenu(IN PVOID BootMenuRoutine);
|
||||
STATIC XTCDECL EFI_STATUS RegisterBootProtocol(IN PCWSTR SystemType,
|
||||
IN PEFI_GUID BootProtocolGuid);
|
||||
STATIC XTCDECL EFI_STATUS InstallXtLoaderProtocol();
|
||||
@@ -327,578 +329,24 @@ class Volume
|
||||
|
||||
class XtLoader
|
||||
{
|
||||
private:
|
||||
STATIC PBL_XT_BOOT_MENU BootMenu;
|
||||
STATIC EFI_HANDLE EfiImageHandle;
|
||||
STATIC PEFI_SYSTEM_TABLE EfiSystemTable;
|
||||
STATIC XTBL_STATUS LoaderStatus;
|
||||
|
||||
public:
|
||||
STATIC XTCDECL VOID InitializeBootLoader();
|
||||
STATIC XTCDECL VOID DisableBootServices();
|
||||
STATIC XTCDECL BOOLEAN GetBootServicesStatus();
|
||||
STATIC XTCDECL EFI_HANDLE GetEfiImageHandle();
|
||||
STATIC XTCDECL PEFI_SYSTEM_TABLE GetEfiSystemTable();
|
||||
STATIC XTCDECL VOID GetLoaderImageInformation(PVOID *LoaderBase,
|
||||
PULONGLONG LoaderSize);
|
||||
STATIC XTCDECL INT_PTR GetSecureBootStatus();
|
||||
STATIC XTCDECL VOID InitializeBootLoader(IN EFI_HANDLE ImageHandle,
|
||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||
STATIC XTCDECL VOID RegisterBootMenu(IN PVOID BootMenuRoutine);
|
||||
STATIC XTCDECL VOID ShowBootMenu();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* XTLDR routines forward references */
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlAllocateMemoryPages(IN EFI_ALLOCATE_TYPE AllocationType,
|
||||
IN ULONGLONG NumberOfPages,
|
||||
OUT PEFI_PHYSICAL_ADDRESS Memory);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlAllocateMemoryPool(IN UINT_PTR Size,
|
||||
OUT PVOID *Memory);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlBuildPageMap(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
IN ULONG_PTR SelfMapAddress);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlClearConsoleLine(IN ULONGLONG LineNo);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlClearConsoleScreen();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlCloseProtocol(IN PEFI_HANDLE Handle,
|
||||
IN PEFI_GUID ProtocolGuid);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlCloseVolume(IN PEFI_HANDLE VolumeHandle);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlConsolePrint(IN PCWSTR Format,
|
||||
IN ...);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlConsoleWrite(IN PCWSTR String);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlDebugPrint(IN PCWSTR Format,
|
||||
IN ...);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlDisableConsoleCursor();
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlDisplayBootMenu();
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlDisplayEditMenu(IN PXTBL_BOOTMENU_ITEM MenuEntry);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlDisplayErrorDialog(IN PCWSTR Caption,
|
||||
IN PCWSTR Message);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlDisplayInfoDialog(IN PCWSTR Caption,
|
||||
IN PCWSTR Message);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlDisplayInputDialog(IN PCWSTR Caption,
|
||||
IN PCWSTR Message,
|
||||
IN OUT PWCHAR *InputFieldText);
|
||||
|
||||
XTCDECL
|
||||
XTBL_DIALOG_HANDLE
|
||||
BlDisplayProgressDialog(IN PCWSTR Caption,
|
||||
IN PCWSTR Message,
|
||||
IN UCHAR Percentage);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlEnableConsoleCursor();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlEnterFirmwareSetup();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlEnumerateBlockDevices();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlExitBootServices();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlFindBootProtocol(IN PCWSTR SystemType,
|
||||
OUT PEFI_GUID BootProtocolGuid);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlFindVolumeDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL FsHandle,
|
||||
IN CONST PWCHAR FileSystemPath,
|
||||
OUT PEFI_DEVICE_PATH_PROTOCOL* DevicePath);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlFreeMemoryPages(IN ULONGLONG NumberOfPages,
|
||||
IN EFI_PHYSICAL_ADDRESS Memory);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlFreeMemoryPool(IN PVOID Memory);
|
||||
|
||||
XTCDECL
|
||||
BOOLEAN
|
||||
BlGetBooleanParameter(IN PCWSTR Parameters,
|
||||
IN PCWSTR Needle);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlGetBootOptionValue(IN PLIST_ENTRY Options,
|
||||
IN PCWSTR OptionName,
|
||||
OUT PWCHAR *OptionValue);
|
||||
|
||||
XTCDECL
|
||||
BOOLEAN
|
||||
BlGetConfigBooleanValue(IN PCWSTR ConfigName);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlGetConfigValue(IN PCWSTR ConfigName,
|
||||
OUT PWCHAR *ConfigValue);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlGetConfigurationTable(IN PEFI_GUID TableGuid,
|
||||
OUT PVOID *Table);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlGetEditableOptions(OUT PCWSTR **OptionsArray,
|
||||
OUT PULONG OptionsCount);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlGetEfiPath(IN PWCHAR SystemPath,
|
||||
OUT PWCHAR *EfiPath);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlGetEfiVariable(IN PEFI_GUID Vendor,
|
||||
IN PCWSTR VariableName,
|
||||
OUT PVOID *VariableValue);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlGetMappingsCount(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
OUT PULONG NumberOfMappings);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap);
|
||||
|
||||
XTCDECL
|
||||
PLIST_ENTRY
|
||||
BlGetModulesList();
|
||||
|
||||
XTCDECL
|
||||
ULONGLONG
|
||||
BlGetRandomValue(IN OUT PULONGLONG RNGBuffer);
|
||||
|
||||
XTCDECL
|
||||
INT_PTR
|
||||
BlGetSecureBootStatus();
|
||||
|
||||
XTCDECL
|
||||
PVOID
|
||||
BlGetVirtualAddress(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
IN PVOID PhysicalAddress);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlGetVolumeDevicePath(IN PWCHAR SystemPath,
|
||||
OUT PEFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||
OUT PWCHAR *ArcName,
|
||||
OUT PWCHAR *Path);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlInitializeBootLoader();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlInitializeBootMenuList(IN ULONG MaxNameLength,
|
||||
OUT PXTBL_BOOTMENU_ITEM *MenuEntries,
|
||||
OUT PULONG EntriesCount,
|
||||
OUT PULONG DefaultId);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlInitializeConsole();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlInitializeEntropy(PULONGLONG RNGBuffer);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlInitializePageMap(OUT PXTBL_PAGE_MAPPING PageMap,
|
||||
IN SHORT PageMapLevel,
|
||||
IN PAGE_SIZE PageSize);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlInstallProtocol(IN PVOID Interface,
|
||||
IN PEFI_GUID Guid);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlInvokeBootProtocol(IN PWCHAR ShortName,
|
||||
IN PLIST_ENTRY OptionsList);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlLoadEfiImage(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath,
|
||||
IN PVOID ImageData,
|
||||
IN SIZE_T ImageSize,
|
||||
OUT PEFI_HANDLE ImageHandle);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlLoadModule(IN PWCHAR ModuleName);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlLoadModules(IN PWCHAR ModulesList);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlLocateProtocolHandles(OUT PEFI_HANDLE *Handles,
|
||||
OUT PUINT_PTR Count,
|
||||
IN PEFI_GUID ProtocolGuid);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlMapEfiMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
|
||||
IN OUT PVOID *DesiredVirtualAddress,
|
||||
IN PBL_GET_MEMTYPE_ROUTINE GetMemoryTypeRoutine);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlMapPage(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
IN ULONG_PTR VirtualAddress,
|
||||
IN ULONG_PTR PhysicalAddress,
|
||||
IN ULONG NumberOfPages);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlMapVirtualMemory(IN OUT PXTBL_PAGE_MAPPING PageMap,
|
||||
IN PVOID VirtualAddress,
|
||||
IN PVOID PhysicalAddress,
|
||||
IN ULONGLONG NumberOfPages,
|
||||
IN LOADER_MEMORY_TYPE MemoryType);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlOpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath,
|
||||
OUT PEFI_HANDLE DiskHandle,
|
||||
OUT PEFI_FILE_HANDLE *FsHandle);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlOpenProtocol(OUT PEFI_HANDLE Handle,
|
||||
OUT PVOID *ProtocolHandler,
|
||||
IN PEFI_GUID ProtocolGuid);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlOpenProtocolHandle(IN EFI_HANDLE Handle,
|
||||
OUT PVOID *ProtocolHandler,
|
||||
IN PEFI_GUID ProtocolGuid);
|
||||
|
||||
XTCDECL
|
||||
PVOID
|
||||
BlPhysicalAddressToVirtual(IN PVOID PhysicalAddress,
|
||||
IN PVOID PhysicalBase,
|
||||
IN PVOID VirtualBase);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlPhysicalListToVirtual(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
IN OUT PLIST_ENTRY ListHead,
|
||||
IN PVOID PhysicalBase,
|
||||
IN PVOID VirtualBase);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlQueryConsoleMode(OUT PUINT_PTR ResX,
|
||||
OUT PUINT_PTR ResY);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlReadFile(IN PEFI_FILE_HANDLE DirHandle,
|
||||
IN PCWSTR FileName,
|
||||
OUT PVOID *FileData,
|
||||
OUT PSIZE_T FileSize);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlReadKeyStroke(OUT PEFI_INPUT_KEY Key);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlRebootSystem();
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlRegisterBootMenu(PVOID BootMenuRoutine);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlRegisterBootProtocol(IN PCWSTR SystemType,
|
||||
IN PEFI_GUID BootProtocolGuid);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlResetConsoleInputBuffer();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlSetBootOptionValue(IN PLIST_ENTRY Options,
|
||||
IN PCWSTR OptionName,
|
||||
IN PCWSTR OptionValue);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlSetConfigValue(IN PCWSTR ConfigName,
|
||||
IN PCWSTR ConfigValue);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlSetConsoleAttributes(IN ULONGLONG Attributes);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlSetConsoleMode(IN ULONGLONG Mode);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlSetCursorPosition(IN ULONGLONG PosX,
|
||||
IN ULONGLONG PosY);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlSetEfiVariable(IN PEFI_GUID Vendor,
|
||||
IN PCWSTR VariableName,
|
||||
IN PVOID VariableValue,
|
||||
IN UINT_PTR Size);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlShutdownSystem();
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlSleepExecution(IN ULONG_PTR Milliseconds);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlStartEfiImage(IN EFI_HANDLE ImageHandle);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlStartLoaderShell();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
IN PEFI_SYSTEM_TABLE SystemTable);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlUpdateProgressBar(IN PXTBL_DIALOG_HANDLE Handle,
|
||||
IN PCWSTR Message,
|
||||
IN UCHAR Percentage);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlWaitForEfiEvent(IN UINT_PTR NumberOfEvents,
|
||||
IN PEFI_EVENT Event,
|
||||
OUT PUINT_PTR Index);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpActivateSerialIOController();
|
||||
|
||||
XTCDECL
|
||||
XTSTATUS
|
||||
BlpConsolePutChar(IN WCHAR Character);
|
||||
|
||||
XTCDECL
|
||||
XTSTATUS
|
||||
BlpDebugPutChar(IN WCHAR Character);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDetermineDialogBoxSize(IN OUT PXTBL_DIALOG_HANDLE Handle,
|
||||
IN PCWSTR Message);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpDiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpDissectVolumeArcPath(IN PWCHAR SystemPath,
|
||||
OUT PWCHAR *ArcName,
|
||||
OUT PWCHAR *Path,
|
||||
OUT PUSHORT DriveType,
|
||||
OUT PULONG DriveNumber,
|
||||
OUT PULONG PartNumber);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDrawBootMenu(OUT PXTBL_DIALOG_HANDLE Handle);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDrawBootMenuEntry(IN PXTBL_DIALOG_HANDLE Handle,
|
||||
IN PWCHAR MenuEntry,
|
||||
IN UINT Position,
|
||||
IN BOOLEAN Highlighted);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDrawDialogBox(IN OUT PXTBL_DIALOG_HANDLE Handle,
|
||||
IN PCWSTR Caption,
|
||||
IN PCWSTR Message);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDrawDialogButton(IN PXTBL_DIALOG_HANDLE Handle);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDrawDialogInputField(IN PXTBL_DIALOG_HANDLE Handle,
|
||||
IN PWCHAR InputFieldText);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDrawDialogMessage(IN PXTBL_DIALOG_HANDLE Handle,
|
||||
IN PCWSTR Message);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDrawDialogProgressBar(IN PXTBL_DIALOG_HANDLE Handle,
|
||||
IN UCHAR Percentage);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpDrawEditMenu(OUT PXTBL_DIALOG_HANDLE Handle);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpDrawEditMenuEntry(IN PXTBL_DIALOG_HANDLE Handle,
|
||||
IN PCWSTR OptionName,
|
||||
IN PCWSTR OptionValue,
|
||||
IN UINT Position,
|
||||
IN BOOLEAN Highlighted);
|
||||
|
||||
XTCDECL
|
||||
PEFI_DEVICE_PATH_PROTOCOL
|
||||
BlpDuplicateDevicePath(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpFindLastBlockDeviceNode(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath,
|
||||
OUT PEFI_DEVICE_PATH_PROTOCOL *LastNode);
|
||||
|
||||
XTCDECL
|
||||
BOOLEAN
|
||||
BlpFindParentBlockDevice(IN PLIST_ENTRY BlockDevices,
|
||||
IN PEFI_BLOCK_DEVICE_DATA ChildNode,
|
||||
OUT PEFI_BLOCK_DEVICE_DATA *ParentNode);
|
||||
|
||||
XTCDECL
|
||||
LOADER_MEMORY_TYPE
|
||||
BlpGetLoaderMemoryType(IN EFI_MEMORY_TYPE EfiMemoryType);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpGetModuleInformation(IN PWCHAR SectionData,
|
||||
IN ULONG SectionSize,
|
||||
OUT PXTBL_MODULE_INFO ModuleInfo);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpGetModuleInfoStrings(IN PWCHAR SectionData,
|
||||
IN ULONG SectionSize,
|
||||
OUT PWCHAR **ModInfo,
|
||||
OUT PULONG InfoCount);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpGetNextPageTable(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
IN PVOID PageTable,
|
||||
IN SIZE_T Entry,
|
||||
OUT PVOID *NextPageTable);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpInitializeDebugConsole();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpInitializeSerialPort(IN ULONG PortNumber,
|
||||
IN ULONG PortAddress,
|
||||
IN ULONG BaudRate);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpInstallXtLoaderProtocol();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpLoadConfiguration();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpParseCommandLine(VOID);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpParseConfigFile(IN CONST PCHAR RawConfig,
|
||||
OUT PLIST_ENTRY Configuration);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpPrintShellPrompt();
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpReadConfigFile(IN PCWSTR ConfigDirectory,
|
||||
IN PCWSTR ConfigFile,
|
||||
OUT PCHAR *ConfigData);
|
||||
|
||||
XTCDECL
|
||||
EFI_STATUS
|
||||
BlpSelfMapPml(IN PXTBL_PAGE_MAPPING PageMap,
|
||||
IN ULONG_PTR SelfMapAddress);
|
||||
|
||||
XTCDECL
|
||||
ULONGLONG
|
||||
BlpStringReadPadding(IN PUSHORT *Format);
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
BlpUpdateConfiguration(IN PLIST_ENTRY NewConfig);
|
||||
|
||||
#endif /* __XTLDR_XTLDR_HH */
|
||||
|
@@ -28,7 +28,8 @@ Memory::AllocatePages(IN EFI_ALLOCATE_TYPE AllocationType,
|
||||
IN ULONGLONG NumberOfPages,
|
||||
OUT PEFI_PHYSICAL_ADDRESS Memory)
|
||||
{
|
||||
return EfiSystemTable->BootServices->AllocatePages(AllocationType, EfiLoaderData, NumberOfPages, Memory);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->AllocatePages(AllocationType, EfiLoaderData,
|
||||
NumberOfPages, Memory);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ Memory::AllocatePool(IN UINT_PTR Size,
|
||||
OUT PVOID *Memory)
|
||||
{
|
||||
/* Allocate pool */
|
||||
return EfiSystemTable->BootServices->AllocatePool(EfiLoaderData, Size, Memory);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->AllocatePool(EfiLoaderData, Size, Memory);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ EFI_STATUS
|
||||
Memory::FreePages(IN ULONGLONG NumberOfPages,
|
||||
IN EFI_PHYSICAL_ADDRESS Memory)
|
||||
{
|
||||
return EfiSystemTable->BootServices->FreePages(Memory, NumberOfPages);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->FreePages(Memory, NumberOfPages);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +90,7 @@ EFI_STATUS
|
||||
Memory::FreePool(IN PVOID Memory)
|
||||
{
|
||||
/* Free pool */
|
||||
return EfiSystemTable->BootServices->FreePool(Memory);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->FreePool(Memory);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,8 +191,11 @@ Memory::GetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap)
|
||||
do
|
||||
{
|
||||
/* Attempt do get EFI memory map */
|
||||
Status = EfiSystemTable->BootServices->GetMemoryMap(&MemoryMap->MapSize, MemoryMap->Map, &MemoryMap->MapKey,
|
||||
&MemoryMap->DescriptorSize, &MemoryMap->DescriptorVersion);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->GetMemoryMap(&MemoryMap->MapSize,
|
||||
MemoryMap->Map,
|
||||
&MemoryMap->MapKey,
|
||||
&MemoryMap->DescriptorSize,
|
||||
&MemoryMap->DescriptorVersion);
|
||||
if(Status == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Go further if succeeded */
|
||||
|
@@ -27,7 +27,8 @@ EFI_STATUS
|
||||
Protocol::CloseProtocol(IN PEFI_HANDLE Handle,
|
||||
IN PEFI_GUID ProtocolGuid)
|
||||
{
|
||||
return EfiSystemTable->BootServices->CloseProtocol(Handle, ProtocolGuid, EfiImageHandle, NULLPTR);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->CloseProtocol(Handle, ProtocolGuid,
|
||||
XtLoader::GetEfiImageHandle(), NULLPTR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +121,8 @@ Protocol::InstallProtocol(IN PVOID Interface,
|
||||
EFI_HANDLE Handle = NULLPTR;
|
||||
|
||||
/* Install protocol interface */
|
||||
return EfiSystemTable->BootServices->InstallProtocolInterface(&Handle, Guid, EFI_NATIVE_INTERFACE, Interface);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->InstallProtocolInterface(&Handle, Guid, EFI_NATIVE_INTERFACE,
|
||||
Interface);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -463,7 +465,7 @@ Protocol::LoadModule(IN PWCHAR ModuleName)
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Check if caused by secure boot */
|
||||
if(Status == STATUS_EFI_ACCESS_DENIED && BlpStatus.SecureBoot >= 1)
|
||||
if(Status == STATUS_EFI_ACCESS_DENIED && XtLoader::GetSecureBootStatus() >= 1)
|
||||
{
|
||||
/* SecureBoot signature validation failed */
|
||||
Debug::Print(L"ERROR: SecureBoot signature validation failed, module '%S' will not be loaded\n", ModuleName);
|
||||
@@ -479,8 +481,9 @@ Protocol::LoadModule(IN PWCHAR ModuleName)
|
||||
}
|
||||
|
||||
/* Access module interface for further module type check */
|
||||
Status = EfiSystemTable->BootServices->OpenProtocol(ModuleHandle, &LIPGuid, (PVOID *)&LoadedImage,
|
||||
EfiImageHandle, NULLPTR, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->OpenProtocol(ModuleHandle, &LIPGuid, (PVOID *)&LoadedImage,
|
||||
XtLoader::GetEfiImageHandle(), NULLPTR,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to open LoadedImage protocol */
|
||||
@@ -495,7 +498,7 @@ Protocol::LoadModule(IN PWCHAR ModuleName)
|
||||
Debug::Print(L"ERROR: Loaded module is not a boot system driver\n");
|
||||
|
||||
/* Close protocol and skip module */
|
||||
EfiSystemTable->BootServices->CloseProtocol(LoadedImage, &LIPGuid, LoadedImage, NULLPTR);
|
||||
XtLoader::GetEfiSystemTable()->BootServices->CloseProtocol(LoadedImage, &LIPGuid, LoadedImage, NULLPTR);
|
||||
}
|
||||
|
||||
/* Save additional module information, not found in '.modinfo' section */
|
||||
@@ -506,7 +509,7 @@ Protocol::LoadModule(IN PWCHAR ModuleName)
|
||||
ModuleInfo->UnloadModule = LoadedImage->Unload;
|
||||
|
||||
/* Close loaded image protocol */
|
||||
EfiSystemTable->BootServices->CloseProtocol(LoadedImage, &LIPGuid, LoadedImage, NULLPTR);
|
||||
XtLoader::GetEfiSystemTable()->BootServices->CloseProtocol(LoadedImage, &LIPGuid, LoadedImage, NULLPTR);
|
||||
|
||||
/* Start EFI image */
|
||||
Status = EfiUtils::StartEfiImage(ModuleHandle);
|
||||
@@ -591,7 +594,8 @@ Protocol::LocateProtocolHandles(OUT PEFI_HANDLE *Handles,
|
||||
OUT PUINT_PTR Count,
|
||||
IN PEFI_GUID ProtocolGuid)
|
||||
{
|
||||
return EfiSystemTable->BootServices->LocateHandleBuffer(ByProtocol, ProtocolGuid, NULLPTR, Count, Handles);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->LocateHandleBuffer(ByProtocol, ProtocolGuid, NULLPTR,
|
||||
Count, Handles);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -649,7 +653,7 @@ Protocol::OpenProtocol(OUT PEFI_HANDLE Handle,
|
||||
}
|
||||
|
||||
/* Free handles */
|
||||
EfiSystemTable->BootServices->FreePool(Handles);
|
||||
XtLoader::GetEfiSystemTable()->BootServices->FreePool(Handles);
|
||||
|
||||
/* Make sure the loaded protocol has been found */
|
||||
if(*ProtocolHandler == NULLPTR)
|
||||
@@ -684,28 +688,11 @@ Protocol::OpenProtocolHandle(IN EFI_HANDLE Handle,
|
||||
OUT PVOID *ProtocolHandler,
|
||||
IN PEFI_GUID ProtocolGuid)
|
||||
{
|
||||
return EfiSystemTable->BootServices->OpenProtocol(Handle, ProtocolGuid, ProtocolHandler, EfiImageHandle,
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->OpenProtocol(Handle, ProtocolGuid, ProtocolHandler,
|
||||
XtLoader::GetEfiImageHandle(),
|
||||
NULLPTR, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a boot menu callback routine, that will be used to display alternative boot menu.
|
||||
*
|
||||
* @param BootMenuRoutine
|
||||
* Supplies a pointer to the boot menu callback routine.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
Protocol::RegisterBootMenu(IN PVOID BootMenuRoutine)
|
||||
{
|
||||
/* Set boot menu routine */
|
||||
BlpStatus.BootMenu = (PBL_XT_BOOT_MENU)BootMenuRoutine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a known boot protocol for a specified OS.
|
||||
*
|
||||
@@ -1026,7 +1013,7 @@ Protocol::InstallXtLoaderProtocol()
|
||||
LoaderProtocol.Boot.FindProtocol = FindBootProtocol;
|
||||
LoaderProtocol.Boot.InitializeMenuList = Configuration::InitializeBootMenuList;
|
||||
LoaderProtocol.Boot.InvokeProtocol = InvokeBootProtocol;
|
||||
LoaderProtocol.Boot.RegisterMenu = RegisterBootMenu;
|
||||
LoaderProtocol.Boot.RegisterMenu = XtLoader::RegisterBootMenu;
|
||||
LoaderProtocol.Boot.RegisterProtocol = RegisterBootProtocol;
|
||||
LoaderProtocol.BootUtils.GetBooleanParameter = BootUtils::GetBooleanParameter;
|
||||
LoaderProtocol.BootUtils.GetTrampolineInformation = AR::ProcSup::GetTrampolineInformation;
|
||||
|
@@ -242,11 +242,12 @@ TextUi::DisplayBootMenu()
|
||||
}
|
||||
|
||||
/* Create a timer event for controlling the timeout of the boot menu */
|
||||
Status = EfiSystemTable->BootServices->CreateEvent(EFI_EVENT_TIMER, EFI_TPL_CALLBACK, NULLPTR, NULLPTR, &TimerEvent);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->CreateEvent(EFI_EVENT_TIMER, EFI_TPL_CALLBACK,
|
||||
NULLPTR, NULLPTR, &TimerEvent);
|
||||
if(Status == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Setup new EFI timer */
|
||||
Status = EfiSystemTable->BootServices->SetTimer(TimerEvent, TimerPeriodic, 10000000);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->SetTimer(TimerEvent, TimerPeriodic, 10000000);
|
||||
}
|
||||
|
||||
/* Check is EFI timer was successfully created */
|
||||
@@ -257,11 +258,11 @@ TextUi::DisplayBootMenu()
|
||||
}
|
||||
|
||||
/* Initialize EFI events */
|
||||
Events[0] = EfiSystemTable->ConIn->WaitForKey;
|
||||
Events[0] = XtLoader::GetEfiSystemTable()->ConIn->WaitForKey;
|
||||
Events[1] = TimerEvent;
|
||||
|
||||
/* Flush keyboard buffer out of any keystrokes */
|
||||
EfiSystemTable->ConIn->Reset(EfiSystemTable->ConIn, FALSE);
|
||||
XtLoader::GetEfiSystemTable()->ConIn->Reset(XtLoader::GetEfiSystemTable()->ConIn, FALSE);
|
||||
|
||||
/* Store old highlighted entry */
|
||||
OldHighligtedEntryId = HighligtedEntryId;
|
||||
@@ -282,7 +283,7 @@ TextUi::DisplayBootMenu()
|
||||
TimeOut = -1;
|
||||
|
||||
/* Cancel timer event */
|
||||
EfiSystemTable->BootServices->SetTimer(TimerEvent, TimerCancel, 0);
|
||||
XtLoader::GetEfiSystemTable()->BootServices->SetTimer(TimerEvent, TimerCancel, 0);
|
||||
|
||||
/* Remove the timer message */
|
||||
Console::ClearLine(Handle.PosY + Handle.Height + 4);
|
||||
@@ -575,7 +576,7 @@ TextUi::DisplayEditMenu(IN PXTBL_BOOTMENU_ITEM MenuEntry)
|
||||
}
|
||||
|
||||
/* Wait for EFI event and read key stroke */
|
||||
EfiUtils::WaitForEfiEvent(1, &EfiSystemTable->ConIn->WaitForKey, &EventIndex);
|
||||
EfiUtils::WaitForEfiEvent(1, &(XtLoader::GetEfiSystemTable()->ConIn->WaitForKey), &EventIndex);
|
||||
Console::ReadKeyStroke(&Key);
|
||||
|
||||
/* Check key press scan code */
|
||||
@@ -788,7 +789,7 @@ TextUi::DisplayErrorDialog(IN PCWSTR Caption,
|
||||
while(Key.ScanCode != 0x17 && Key.UnicodeChar != 0x0D)
|
||||
{
|
||||
/* Wait for key press and read key stroke */
|
||||
EfiUtils::WaitForEfiEvent(1, &EfiSystemTable->ConIn->WaitForKey, &Index);
|
||||
EfiUtils::WaitForEfiEvent(1, &(XtLoader::GetEfiSystemTable()->ConIn->WaitForKey), &Index);
|
||||
Console::ReadKeyStroke(&Key);
|
||||
Console::ResetInputBuffer();
|
||||
}
|
||||
@@ -841,7 +842,7 @@ TextUi::DisplayInfoDialog(IN PCWSTR Caption,
|
||||
while(Key.ScanCode != 0x17 && Key.UnicodeChar != 0x0D)
|
||||
{
|
||||
/* Wait for key press and read key stroke */
|
||||
EfiUtils::WaitForEfiEvent(1, &EfiSystemTable->ConIn->WaitForKey, &Index);
|
||||
EfiUtils::WaitForEfiEvent(1, &(XtLoader::GetEfiSystemTable()->ConIn->WaitForKey), &Index);
|
||||
Console::ReadKeyStroke(&Key);
|
||||
Console::ResetInputBuffer();
|
||||
}
|
||||
@@ -925,7 +926,7 @@ TextUi::DisplayInputDialog(IN PCWSTR Caption,
|
||||
while(TRUE)
|
||||
{
|
||||
/* Wait for key press and read key stroke */
|
||||
EfiUtils::WaitForEfiEvent(1, &EfiSystemTable->ConIn->WaitForKey, &Index);
|
||||
EfiUtils::WaitForEfiEvent(1, &(XtLoader::GetEfiSystemTable()->ConIn->WaitForKey), &Index);
|
||||
Console::ReadKeyStroke(&Key);
|
||||
|
||||
/* Check key press scan code */
|
||||
|
@@ -30,7 +30,8 @@ Volume::CloseVolume(IN PEFI_HANDLE VolumeHandle)
|
||||
if(VolumeHandle != NULLPTR)
|
||||
{
|
||||
/* Close a handle */
|
||||
return EfiSystemTable->BootServices->CloseProtocol(VolumeHandle, &LIPGuid, EfiImageHandle, NULLPTR);
|
||||
return XtLoader::GetEfiSystemTable()->BootServices->CloseProtocol(VolumeHandle, &LIPGuid,
|
||||
XtLoader::GetEfiImageHandle(), NULLPTR);
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
@@ -68,7 +69,8 @@ Volume::EnumerateBlockDevices()
|
||||
ULONG CDCount = 0, FDCount = 0, HDCount = 0, RDCount = 0;
|
||||
|
||||
/* Get the device handle of the image that is running */
|
||||
Status = EfiSystemTable->BootServices->HandleProtocol(EfiImageHandle, &LoadedImageProtocolGuid, (VOID**)&LoadedImage);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->HandleProtocol(XtLoader::GetEfiImageHandle(), &LoadedImageProtocolGuid,
|
||||
(VOID**)&LoadedImage);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to get boot device handle */
|
||||
@@ -179,7 +181,7 @@ Volume::EnumerateBlockDevices()
|
||||
if(DevicePath != NULLPTR)
|
||||
{
|
||||
/* Check if this is the boot device */
|
||||
Status = EfiSystemTable->BootServices->LocateDevicePath(&BlockIoGuid, &DevicePath,
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->LocateDevicePath(&BlockIoGuid, &DevicePath,
|
||||
&DeviceHandle);
|
||||
if(Status == STATUS_EFI_SUCCESS && DeviceHandle == BootDeviceHandle)
|
||||
{
|
||||
@@ -533,7 +535,7 @@ Volume::OpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath,
|
||||
if(DevicePath != NULLPTR)
|
||||
{
|
||||
/* Locate the device path */
|
||||
Status = EfiSystemTable->BootServices->LocateDevicePath(&SFSGuid, &DevicePath, DiskHandle);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->LocateDevicePath(&SFSGuid, &DevicePath, DiskHandle);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to locate device path */
|
||||
@@ -543,8 +545,12 @@ Volume::OpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath,
|
||||
else
|
||||
{
|
||||
/* Open the image protocol if no device path specified */
|
||||
Status = EfiSystemTable->BootServices->OpenProtocol(EfiImageHandle, &LIPGuid, (PVOID *)&ImageProtocol,
|
||||
EfiImageHandle, NULLPTR, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->OpenProtocol(XtLoader::GetEfiImageHandle(),
|
||||
&LIPGuid,
|
||||
(PVOID *)&ImageProtocol,
|
||||
XtLoader::GetEfiImageHandle(),
|
||||
NULLPTR,
|
||||
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to open image protocol */
|
||||
@@ -556,8 +562,10 @@ Volume::OpenVolume(IN PEFI_DEVICE_PATH_PROTOCOL DevicePath,
|
||||
}
|
||||
|
||||
/* Open the filesystem protocol */
|
||||
Status = EfiSystemTable->BootServices->OpenProtocol(*DiskHandle, &SFSGuid, (PVOID *)&FileSystemProtocol,
|
||||
EfiImageHandle, NULLPTR, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->OpenProtocol(*DiskHandle, &SFSGuid,
|
||||
(PVOID *)&FileSystemProtocol,
|
||||
XtLoader::GetEfiImageHandle(), NULLPTR,
|
||||
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
|
||||
|
||||
/* Check if filesystem protocol opened successfully */
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
@@ -757,12 +765,14 @@ Volume::DiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices)
|
||||
|
||||
/* Check if DevicePath protocol is supported by this handle */
|
||||
DevicePath = NULLPTR;
|
||||
Status = EfiSystemTable->BootServices->HandleProtocol(Handles[Index], &DevicePathGuid, (PVOID *)&DevicePath);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->HandleProtocol(Handles[Index], &DevicePathGuid,
|
||||
(PVOID *)&DevicePath);
|
||||
if(Status != STATUS_EFI_SUCCESS || DevicePath == NULLPTR)
|
||||
{
|
||||
/* Device failed to handle DP protocol */
|
||||
Debug::Print(L"WARNING: Unable to open DevicePath protocol (Status Code: 0x%zX)\n", Status);
|
||||
EfiSystemTable->BootServices->CloseProtocol(Handles[Index], &IoGuid, EfiImageHandle, NULLPTR);
|
||||
XtLoader::GetEfiSystemTable()->BootServices->CloseProtocol(Handles[Index], &IoGuid,
|
||||
XtLoader::GetEfiImageHandle(), NULLPTR);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -772,8 +782,10 @@ Volume::DiscoverEfiBlockDevices(OUT PLIST_ENTRY BlockDevices)
|
||||
{
|
||||
/* Memory allocation failure */
|
||||
Debug::Print(L"ERROR: Failed to allocate memory pool for block device (Status Code: 0x%zX)\n", Status);
|
||||
EfiSystemTable->BootServices->CloseProtocol(Handles[Index], &DevicePathGuid, EfiImageHandle, NULLPTR);
|
||||
EfiSystemTable->BootServices->CloseProtocol(Handles[Index], &IoGuid, EfiImageHandle, NULLPTR);
|
||||
XtLoader::GetEfiSystemTable()->BootServices->CloseProtocol(Handles[Index], &DevicePathGuid,
|
||||
XtLoader::GetEfiImageHandle(), NULLPTR);
|
||||
XtLoader::GetEfiSystemTable()->BootServices->CloseProtocol(Handles[Index], &IoGuid,
|
||||
XtLoader::GetEfiImageHandle(), NULLPTR);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
118
xtldr/xtldr.cc
118
xtldr/xtldr.cc
@@ -9,6 +9,51 @@
|
||||
#include <xtldr.hh>
|
||||
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
XtLoader::DisableBootServices()
|
||||
{
|
||||
LoaderStatus.BootServices = FALSE;
|
||||
|
||||
}
|
||||
|
||||
XTCDECL
|
||||
BOOLEAN
|
||||
XtLoader::GetBootServicesStatus()
|
||||
{
|
||||
return LoaderStatus.BootServices;
|
||||
}
|
||||
|
||||
XTCDECL
|
||||
EFI_HANDLE
|
||||
XtLoader::GetEfiImageHandle()
|
||||
{
|
||||
return XtLoader::EfiImageHandle;
|
||||
}
|
||||
|
||||
XTCDECL
|
||||
PEFI_SYSTEM_TABLE
|
||||
XtLoader::GetEfiSystemTable()
|
||||
{
|
||||
return XtLoader::EfiSystemTable;
|
||||
}
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
XtLoader::GetLoaderImageInformation(PVOID *LoaderBase,
|
||||
PULONGLONG LoaderSize)
|
||||
{
|
||||
*LoaderBase = XtLoader::LoaderStatus.LoaderBase;
|
||||
*LoaderSize = XtLoader::LoaderStatus.LoaderSize;
|
||||
}
|
||||
|
||||
XTCDECL
|
||||
INT_PTR
|
||||
XtLoader::GetSecureBootStatus()
|
||||
{
|
||||
return LoaderStatus.SecureBoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes EFI Boot Loader (XTLDR).
|
||||
*
|
||||
@@ -18,15 +63,20 @@
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
XtLoader::InitializeBootLoader()
|
||||
XtLoader::InitializeBootLoader(IN EFI_HANDLE ImageHandle,
|
||||
IN PEFI_SYSTEM_TABLE SystemTable)
|
||||
{
|
||||
EFI_GUID LipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||
PEFI_LOADED_IMAGE_PROTOCOL LoadedImage;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_STATUS Status;
|
||||
|
||||
/* Set the system table and image handle */
|
||||
EfiImageHandle = ImageHandle;
|
||||
EfiSystemTable = SystemTable;
|
||||
|
||||
/* Set current XTLDR's EFI BootServices status */
|
||||
BlpStatus.BootServices = TRUE;
|
||||
LoaderStatus.BootServices = TRUE;
|
||||
|
||||
/* Initialize console */
|
||||
Console::InitializeConsole();
|
||||
@@ -41,15 +91,15 @@ XtLoader::InitializeBootLoader()
|
||||
Configuration::InitializeConfiguration();
|
||||
|
||||
/* Store SecureBoot status */
|
||||
BlpStatus.SecureBoot = EfiUtils::GetSecureBootStatus();
|
||||
LoaderStatus.SecureBoot = EfiUtils::GetSecureBootStatus();
|
||||
|
||||
/* Attempt to open EFI LoadedImage protocol */
|
||||
Status = Protocol::OpenProtocol(&Handle, (PVOID *)&LoadedImage, &LipGuid);
|
||||
if(Status == STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Store boot loader image base and size */
|
||||
BlpStatus.LoaderBase = LoadedImage->ImageBase;
|
||||
BlpStatus.LoaderSize = LoadedImage->ImageSize;
|
||||
LoaderStatus.LoaderBase = LoadedImage->ImageBase;
|
||||
LoaderStatus.LoaderSize = LoadedImage->ImageSize;
|
||||
|
||||
/* Check if debug is enabled */
|
||||
if(DEBUG)
|
||||
@@ -66,7 +116,7 @@ XtLoader::InitializeBootLoader()
|
||||
LoadedImage->ImageBase,
|
||||
LoadedImage->ImageSize,
|
||||
LoadedImage->Revision,
|
||||
BlpStatus.SecureBoot);
|
||||
LoaderStatus.SecureBoot);
|
||||
EfiUtils::SleepExecution(3000);
|
||||
}
|
||||
|
||||
@@ -75,6 +125,41 @@ XtLoader::InitializeBootLoader()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a boot menu callback routine, that will be used to display alternative boot menu.
|
||||
*
|
||||
* @param BootMenuRoutine
|
||||
* Supplies a pointer to the boot menu callback routine.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTCDECL
|
||||
VOID
|
||||
XtLoader::RegisterBootMenu(IN PVOID BootMenuRoutine)
|
||||
{
|
||||
/* Set boot menu routine */
|
||||
BootMenu = (PBL_XT_BOOT_MENU)BootMenuRoutine;
|
||||
}
|
||||
|
||||
XTCDECL
|
||||
VOID
|
||||
XtLoader::ShowBootMenu()
|
||||
{
|
||||
/* Check if custom boot menu registered */
|
||||
if(BootMenu != NULLPTR)
|
||||
{
|
||||
/* Display alternative boot menu */
|
||||
BootMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Display default boot menu */
|
||||
TextUi::DisplayBootMenu();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This routine is the entry point of the XT EFI boot loader.
|
||||
*
|
||||
@@ -96,12 +181,8 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
PWCHAR Modules;
|
||||
EFI_STATUS Status;
|
||||
|
||||
/* Set the system table and image handle */
|
||||
EfiImageHandle = ImageHandle;
|
||||
EfiSystemTable = SystemTable;
|
||||
|
||||
/* Initialize XTLDR and */
|
||||
XtLoader::InitializeBootLoader();
|
||||
XtLoader::InitializeBootLoader(ImageHandle, SystemTable);
|
||||
|
||||
/* Parse configuration options passed from UEFI shell */
|
||||
Status = Configuration::ParseCommandLine();
|
||||
@@ -142,7 +223,7 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
}
|
||||
|
||||
/* Disable watchdog timer */
|
||||
Status = EfiSystemTable->BootServices->SetWatchdogTimer(0, 0x10000, 0, NULLPTR);
|
||||
Status = XtLoader::GetEfiSystemTable()->BootServices->SetWatchdogTimer(0, 0x10000, 0, NULLPTR);
|
||||
if(Status != STATUS_EFI_SUCCESS)
|
||||
{
|
||||
/* Failed to disable the timer, print message */
|
||||
@@ -180,17 +261,8 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||
/* Main boot loader loop */
|
||||
while(TRUE)
|
||||
{
|
||||
/* Check if custom boot menu registered */
|
||||
if(BlpStatus.BootMenu != NULLPTR)
|
||||
{
|
||||
/* Display alternative boot menu */
|
||||
BlpStatus.BootMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Display default boot menu */
|
||||
TextUi::DisplayBootMenu();
|
||||
}
|
||||
/* Show boot menu */
|
||||
XtLoader::ShowBootMenu();
|
||||
|
||||
/* Fallback to shell, if boot menu returned */
|
||||
Shell::StartLoaderShell();
|
||||
|
Reference in New Issue
Block a user