111 lines
2.3 KiB
C
111 lines
2.3 KiB
C
/**
|
|
* PROJECT: ExectOS
|
|
* COPYRIGHT: See COPYING.md in the top level directory
|
|
* FILE: xtldr/efiutils.c
|
|
* DESCRIPTION: EFI related routines for XT Boot Loader
|
|
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
*/
|
|
|
|
#include <xtldr.h>
|
|
|
|
|
|
/**
|
|
* Exits EFI boot services.
|
|
*
|
|
* @param MapKey
|
|
* Identifies the current memory map of the system.
|
|
*
|
|
* @return This routine returns status code.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
EFI_STATUS
|
|
BlExitBootServices(IN UINT_PTR MapKey)
|
|
{
|
|
EFI_STATUS Status;
|
|
|
|
/* Attempt to exit boot services */
|
|
Status = EfiSystemTable->BootServices->ExitBootServices(BlpStatus.ImageHandle, MapKey);
|
|
if(Status != STATUS_EFI_SUCCESS)
|
|
{
|
|
/* Retry as UEFI spec says to do it twice */
|
|
Status = EfiSystemTable->BootServices->ExitBootServices(BlpStatus.ImageHandle, MapKey);
|
|
}
|
|
|
|
/* Make sure boot services were successfully exited */
|
|
if(Status == STATUS_EFI_SUCCESS)
|
|
{
|
|
/* Mark EFI Boot Services as no longer available */
|
|
BlpStatus.BootServices = FALSE;
|
|
}
|
|
|
|
/* Return EFI status code */
|
|
return Status;
|
|
}
|
|
|
|
/**
|
|
* Returns the EFI image handle.
|
|
*
|
|
* @return This routine returns the current EFI image handle.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
EFI_HANDLE
|
|
BlGetEfiImageHandle()
|
|
{
|
|
return BlpStatus.ImageHandle;
|
|
}
|
|
|
|
/**
|
|
* Returns the EFI system table.
|
|
*
|
|
* @return This routine returns the current EFI system table.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
PEFI_SYSTEM_TABLE
|
|
BlGetEfiSystemTable()
|
|
{
|
|
return BlpStatus.SystemTable;
|
|
}
|
|
|
|
/**
|
|
* Puts the system to sleep for the specified number of milliseconds.
|
|
*
|
|
* @param Milliseconds
|
|
* Supplies the number of milliseconds to sleep.
|
|
*
|
|
* @return This routine does not return any value.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlSleepExecution(IN ULONG_PTR Milliseconds)
|
|
{
|
|
EfiSystemTable->BootServices->Stall(Milliseconds * 1000);
|
|
}
|
|
|
|
/**
|
|
* Initializes EFI Boot Loader (XTLDR).
|
|
*
|
|
* @return This routine does not return any value.
|
|
*
|
|
* @since XT 1.0
|
|
*/
|
|
XTCDECL
|
|
VOID
|
|
BlpInitializeEfiBootLoader()
|
|
{
|
|
/* Set current XTLDR status */
|
|
BlpStatus.BootServices = TRUE;
|
|
BlpStatus.ImageHandle = EfiImageHandle;
|
|
BlpStatus.SystemTable = EfiSystemTable;
|
|
|
|
/* Initialize console */
|
|
BlpConsoleInitialize();
|
|
}
|