exectos/xtldr2/xtldr.c
Rafal Kupiec 6983b2eeac
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 26s
Builds / ExectOS (i686) (push) Successful in 26s
Make a use of TUI dialogs to inform user about errors
2023-12-18 23:22:54 +01:00

105 lines
3.1 KiB
C

/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtldr/xtldr.c
* DESCRIPTION: XTOS UEFI Boot Loader
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <xtldr.h>
/**
* This routine is the entry point of the XT EFI boot loader.
*
* @param ImageHandle
* Firmware-allocated handle that identifies the image.
*
* @param SystemTable
* Provides the EFI system table.
*
* @return This routine returns status code.
*
* @since XT 1.0
*/
XTCDECL
EFI_STATUS
BlStartXtLoader(IN EFI_HANDLE ImageHandle,
IN PEFI_SYSTEM_TABLE SystemTable)
{
EFI_STATUS Status;
/* Set the system table and image handle */
EfiImageHandle = ImageHandle;
EfiSystemTable = SystemTable;
/* Initialize XTLDR and early print XTLDR version */
BlpInitializeEfiBootLoader();
BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION);
/* Parse configuration options passed from UEFI shell */
Status = BlpParseCommandLine();
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to parse command line options */
BlDisplayErrorDialog(L"XTLDR", L"Failed to parse command line parameters.");
}
/* Attempt to early initialize debug console */
if(DEBUG)
{
Status = BlpInitializeDebugConsole();
if(Status != STATUS_EFI_SUCCESS)
{
/* Initialization failed, notify user on stdout */
BlDisplayErrorDialog(L"XTLDR", L"Failed to initialize debug console.");
}
}
/* Load XTLDR configuration file */
Status = BlpLoadConfiguration();
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to load/parse config file */
BlDisplayErrorDialog(L"XTLDR", L"Failed to load and parse configuration file.");
}
/* Reinitialize debug console if it was not initialized earlier */
if(DEBUG)
{
Status = BlpInitializeDebugConsole();
if(Status != STATUS_EFI_SUCCESS)
{
/* Initialization failed, notify user on stdout */
BlDisplayErrorDialog(L"XTLDR", L"Failed to initialize debug console.");
}
}
/* Disable watchdog timer */
Status = EfiSystemTable->BootServices->SetWatchdogTimer(0, 0x10000, 0, NULL);
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to disable the timer, print message */
BlDebugPrint(L"WARNING: Failed to disable watchdog timer\n");
}
/* Register loader protocol */
Status = BlpRegisterXtLoaderProtocol();
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to register loader protocol */
BlDebugPrint(L"ERROR: Failed to register XTLDR boot protocol\n");
}
/* Discover and enumerate EFI block devices */
Status = BlEnumerateBlockDevices();
if(Status != STATUS_EFI_SUCCESS)
{
/* Failed to enumerate block devices */
BlDebugPrint(L"ERROR: Failed to discover and enumerate block devices\n");
}
/* This point should be never reached, if this happen return error code */
return STATUS_EFI_LOAD_ERROR;
}