Add XTLDR protocol support
Some checks failed
Builds / ExectOS (amd64) (push) Failing after 15s
Builds / ExectOS (i686) (push) Failing after 15s

This commit is contained in:
Rafal Kupiec 2023-12-04 18:49:34 +01:00
parent aea69a33b9
commit 02cd8efde9
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 90 additions and 3 deletions

View File

@ -13,11 +13,27 @@
#include <xtuefi.h>
/* XTLDR Debug port type definitions */
/* XTLDR Debug Port type definitions */
#define XTBL_DEBUGPORT_SCREEN 1
#define XTBL_DEBUGPORT_SERIAL 2
/* XTLDR configuration data */
/* Loader protocol routine pointers */
typedef EFI_STATUS (*PBL_ALLOCATE_PAGES)(IN UINT64 Size, OUT PEFI_PHYSICAL_ADDRESS Memory);
typedef EFI_STATUS (*PBL_ALLOCATE_POOL)(IN UINT_PTR Size, OUT PVOID *Memory);
typedef VOID (*PBL_CONSOLE_CLEAR_SCREEN)();
typedef VOID (*PBL_CONSOLE_DISABLE_CURSOR)();
typedef VOID (*PBL_CONSOLE_ENABLE_CURSOR)();
typedef VOID (*PBL_CONSOLE_PRINT)(IN PUINT16 Format, IN ...);
typedef VOID (*PBL_DEBUG_PRINT)(IN PUINT16 Format, IN ...);
typedef EFI_STATUS (*PBL_EXIT_BOOT_SERVICES)(IN UINT_PTR MapKey);
typedef EFI_STATUS (*PBL_FREE_PAGES)(IN UINT64 Size, IN EFI_PHYSICAL_ADDRESS Memory);
typedef EFI_STATUS (*PBL_FREE_POOL)(IN PVOID Memory);
typedef EFI_HANDLE (*PBL_GET_EFI_IMAGE_HANDLE)();
typedef PEFI_SYSTEM_TABLE (*PBL_GET_EFI_SYSTEM_TABLE)();
typedef EFI_STATUS (*PBL_OPEN_XT_PROTOCOL)(OUT PVOID *ProtocolHandler, IN PEFI_GUID ProtocolGuid);
typedef VOID (*PBL_SLEEP_EXECUTION)(IN ULONG_PTR Milliseconds);
/* XTLDR Configuration data */
typedef struct _XTBL_CONFIGURATION
{
PWCHAR Default;
@ -29,7 +45,7 @@ typedef struct _XTBL_CONFIGURATION
PWCHAR Tune;
} XTBL_CONFIGURATION, *PXTBL_CONFIGURATION;
/* XTLDR status data */
/* XTLDR Status data */
typedef struct _XTBL_STATUS
{
BOOLEAN BootServices;
@ -37,4 +53,38 @@ typedef struct _XTBL_STATUS
PEFI_SYSTEM_TABLE SystemTable;
} XTBL_STATUS, *PXTBL_STATUS;
/* XTLDR Loader protocol */
typedef struct _XTBL_LOADER_PROTOCOL
{
struct
{
PBL_CONSOLE_CLEAR_SCREEN ClearScreen;
PBL_CONSOLE_DISABLE_CURSOR DisableCursor;
PBL_CONSOLE_ENABLE_CURSOR EnableCursor;
PBL_CONSOLE_PRINT Print;
} Console;
struct
{
PBL_DEBUG_PRINT Print;
} Debug;
struct
{
PBL_ALLOCATE_PAGES AllocatePages;
PBL_ALLOCATE_POOL AllocatePool;
PBL_FREE_PAGES FreePages;
PBL_FREE_POOL FreePool;
} Memory;
struct
{
PBL_OPEN_XT_PROTOCOL Open;
} Protocol;
struct
{
PBL_EXIT_BOOT_SERVICES ExitBootServices;
PBL_GET_EFI_IMAGE_HANDLE GetImageHandle;
PBL_GET_EFI_SYSTEM_TABLE GetSystemTable;
PBL_SLEEP_EXECUTION SleepExecution;
} Util;
} XTBL_LOADER_PROTOCOL, *PXTBL_LOADER_PROTOCOL;
#endif /* __XTDK_BMTYPES_H */

View File

@ -15,6 +15,7 @@ list(APPEND XTLDR_SOURCE
${XTLDR_SOURCE_DIR}/globals.c
${XTLDR_SOURCE_DIR}/hardware.c
${XTLDR_SOURCE_DIR}/memory.c
${XTLDR_SOURCE_DIR}/protocol.c
${XTLDR_SOURCE_DIR}/string.c
${XTLDR_SOURCE_DIR}/xtldr.c)

View File

@ -44,6 +44,34 @@ BlExitBootServices(IN UINT_PTR MapKey)
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.
*

View File

@ -52,6 +52,14 @@ VOID
BlDebugPrint(IN PUINT16 Format,
IN ...);
XTCDECL
EFI_HANDLE
BlGetEfiImageHandle();
XTCDECL
PEFI_SYSTEM_TABLE
BlGetEfiSystemTable();
XTCDECL
EFI_STATUS
BlMemoryFreePages(IN UINT64 Pages,