[BOOT] Add EFI headers and entry point
This commit is contained in:
parent
88449693d4
commit
8e7c2d02bb
60
BOOT/ENVIRON/APP/BOOTMGR/EFI/efientry.c
Normal file
60
BOOT/ENVIRON/APP/BOOTMGR/EFI/efientry.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
entry.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Boot manager entry point on EFI systems.
|
||||
|
||||
--*/
|
||||
|
||||
#include "bootmgr.h"
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiEntry (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Boot manager entry point from EFI firmware.
|
||||
|
||||
Arguments:
|
||||
|
||||
ImageHandle - Handle for the boot manager image.
|
||||
|
||||
SystemTable - Pointer to the EFI system table.
|
||||
|
||||
Return Value:
|
||||
|
||||
EFI_SUCCESS if successful.
|
||||
EFI_INVALID_PARAMEER if input parameter structure creation fails.
|
||||
Any other value defined in efierr.h.
|
||||
|
||||
--*/
|
||||
|
||||
{
|
||||
PBOOT_APPLICATION_PARAMETERS InputParameters;
|
||||
|
||||
//
|
||||
// Create firmware-independent input structure from EFI parameters.
|
||||
//
|
||||
InputParameters = EfiInitCreateInputParameters(ImageHandle, SystemTable);
|
||||
if (InputParameters == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Transfer control to the firmware-independent boot manager.
|
||||
//
|
||||
return EfiGetEfiStatusCode(BmMain(InputParameters));
|
||||
}
|
44
BOOT/ENVIRON/APP/BOOTMGR/bootmgr.c
Normal file
44
BOOT/ENVIRON/APP/BOOTMGR/bootmgr.c
Normal file
@ -0,0 +1,44 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
bootmgr.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Main functions of the boot manager.
|
||||
|
||||
--*/
|
||||
|
||||
#include "bootmgr.h"
|
||||
|
||||
NTSTATUS
|
||||
BmMain (
|
||||
IN PBOOT_APPLICATION_PARAMETERS Parameters
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Firmware-independent boot manager entry point.
|
||||
|
||||
Arguments:
|
||||
|
||||
Parameters - Input parameters for the boot manager.
|
||||
|
||||
Return Value:
|
||||
|
||||
Error code on failure.
|
||||
Does not return on success, as control is transferred to the OS loader.
|
||||
|
||||
--*/
|
||||
|
||||
{
|
||||
/* TODO: Implement BmMain() */
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
76
BOOT/ENVIRON/INC/AMD64/efibind.h
Normal file
76
BOOT/ENVIRON/INC/AMD64/efibind.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
efibind.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides definitions specific to AMD64 EFI systems.
|
||||
|
||||
--*/
|
||||
|
||||
#if defined(_MSC_EXTENSIONS)
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int8 int8_t;
|
||||
#elif defined(UNIX_LP64)
|
||||
typedef unsigned long uint64_t;
|
||||
typedef long int64_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef char int8_t;
|
||||
#else
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef int int32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef char int8_t;
|
||||
#endif
|
||||
|
||||
typedef uint64_t UINT64;
|
||||
typedef int64_t INT64;
|
||||
typedef uint32_t UINT32;
|
||||
typedef int32_t INT32;
|
||||
typedef uint16_t UINT16;
|
||||
typedef int16_t INT16;
|
||||
typedef uint8_t UINT8;
|
||||
typedef int8_t INT8;
|
||||
|
||||
typedef int64_t INTN;
|
||||
typedef uint64_t UINTN;
|
||||
|
||||
#define EFI_ERROR_MASK 0x8000000000000000
|
||||
#define EFI_ERROR_MASK_OEM 0xc000000000000000
|
||||
#define EFIERR(e) (EFI_ERROR_MASK | e)
|
||||
#define EFIERR_OEM(e) (EFI_ERROR_MASK_OEM | e)
|
||||
|
||||
#ifndef EFIAPI
|
||||
#if defined(_MSC_EXTENSIONS)
|
||||
#define EFIAPI __cdecl
|
||||
#else
|
||||
#define EFIAPI __attribute__((ms_abi))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define VOLATILE volatile
|
||||
|
||||
#if defined(__GNUC__) || defined(_MSC_EXTENSIONS)
|
||||
#define INTERFACE_DECL(n) struct n
|
||||
#else
|
||||
#define INTERFACE_DECL(n) typedef struct n
|
||||
#endif
|
32
BOOT/ENVIRON/INC/efi.h
Normal file
32
BOOT/ENVIRON/INC/efi.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
efi.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides EFI header files.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFI_H
|
||||
#define _EFI_H
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#include "AMD64/efibind.h"
|
||||
#else
|
||||
#error Unsupported architecture
|
||||
#endif
|
||||
|
||||
#include "efidef.h"
|
||||
#include "efidevp.h"
|
||||
#include "efiprot.h"
|
||||
#include "eficon.h"
|
||||
#include "efiapi.h"
|
||||
#include "efierr.h"
|
||||
|
||||
#endif
|
236
BOOT/ENVIRON/INC/efiapi.h
Normal file
236
BOOT/ENVIRON/INC/efiapi.h
Normal file
@ -0,0 +1,236 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
efiapi.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides EFI API definitions.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFIAPI_H
|
||||
#define _EFIAPI_H
|
||||
|
||||
#define EFI_SPECIFICATION_MAJOR_REVISION 1
|
||||
#define EFI_SPECIFICATION_MINOR_REVISION 02
|
||||
#define EFI_SPECIFICATION_VERSION ((EFI_SPECIFICATION_MAJOR_REVISION << 16) || EFI_SPECIFICATION_MINOR_REVISION)
|
||||
|
||||
INTERFACE_DECL(_EFI_SYSTEM_TABLE);
|
||||
|
||||
/*
|
||||
* Loaded image protocol definitions.
|
||||
*/
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_IMAGE_UNLOAD) (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
#define EFI_LOADED_IMAGE_PROTOCOL_GUID \
|
||||
{ 0x5b1b31a1, 0x9562, 0x11d2, { 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } }
|
||||
#define LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE_PROTOCOL_GUID
|
||||
|
||||
#define EFI_IMAGE_INFORMATION_REVISION 0x1000
|
||||
|
||||
typedef struct {
|
||||
UINT32 Revision;
|
||||
EFI_HANDLE ParentHandle;
|
||||
struct _EFI_SYSTEM_TABLE *SystemTable;
|
||||
|
||||
EFI_HANDLE DeviceHandle;
|
||||
EFI_DEVICE_PATH *FilePath;
|
||||
VOID *Reserved;
|
||||
|
||||
UINT32 LoadOptionsSize;
|
||||
VOID *LoadOptions;
|
||||
|
||||
VOID *ImageBase;
|
||||
UINT64 ImageSize;
|
||||
EFI_MEMORY_TYPE ImageCodeType;
|
||||
EFI_MEMORY_TYPE ImageDataType;
|
||||
|
||||
EFI_IMAGE_UNLOAD Unload;
|
||||
} EFI_LOADED_IMAGE;
|
||||
|
||||
/*
|
||||
* EFI table header.
|
||||
*/
|
||||
|
||||
typedef struct _EFI_TABLE_HEADER {
|
||||
UINT64 Signature;
|
||||
UINT32 Revision;
|
||||
UINT32 HeaderSize;
|
||||
UINT32 CRC32;
|
||||
UINT32 Reserved;
|
||||
} EFI_TABLE_HEADER;
|
||||
|
||||
/*
|
||||
* EFI runtime services table definitions.
|
||||
*/
|
||||
|
||||
#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552
|
||||
#define EFI_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_VERSION
|
||||
|
||||
typedef struct {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
|
||||
EFI_HANDLE GetTime;
|
||||
EFI_HANDLE SetTime;
|
||||
EFI_HANDLE GetWakeupTime;
|
||||
EFI_HANDLE SetWakeupTime;
|
||||
|
||||
EFI_HANDLE SetVirtualAddressMap;
|
||||
EFI_HANDLE ConvertPointer;
|
||||
|
||||
EFI_HANDLE GetVariable;
|
||||
EFI_HANDLE GetNextVariableName;
|
||||
EFI_HANDLE SetVariable;
|
||||
|
||||
EFI_HANDLE GetNextHighMonotonicCount;
|
||||
EFI_HANDLE ResetSystem;
|
||||
|
||||
EFI_HANDLE UpdateCapsule;
|
||||
EFI_HANDLE QueryCapsuleCapabilities;
|
||||
EFI_HANDLE QueryVariableInfo;
|
||||
} EFI_RUNTIME_SERVICES;
|
||||
|
||||
/*
|
||||
* EFI boot services table definitions.
|
||||
*/
|
||||
|
||||
#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
|
||||
#define EFI_BOOT_SERVICES_REVISION EFI_SPECIFICATION_VERSION
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_HANDLE_PROTOCOL) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_GUID *Protocol,
|
||||
OUT VOID **Interface
|
||||
);
|
||||
|
||||
typedef struct _EFI_BOOT_SERVICES {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
|
||||
EFI_HANDLE RaiseTPL;
|
||||
EFI_HANDLE RestoreTPL;
|
||||
|
||||
EFI_HANDLE AllocatePages;
|
||||
EFI_HANDLE FreePages;
|
||||
EFI_HANDLE GetMemoryMap;
|
||||
EFI_HANDLE AllocatePool;
|
||||
EFI_HANDLE FreePool;
|
||||
|
||||
EFI_HANDLE CreateEvent;
|
||||
EFI_HANDLE SetTimer;
|
||||
EFI_HANDLE WaitForEvent;
|
||||
EFI_HANDLE SignalEvent;
|
||||
EFI_HANDLE CloseEvent;
|
||||
EFI_HANDLE CheckEvent;
|
||||
|
||||
EFI_HANDLE InstallProtocolInterface;
|
||||
EFI_HANDLE ReinstallProtocolInterface;
|
||||
EFI_HANDLE UninstallProtocolInterface;
|
||||
EFI_HANDLE_PROTOCOL HandleProtocol;
|
||||
EFI_HANDLE AlternateHandleProtocol;
|
||||
EFI_HANDLE RegisterProtocolNotify;
|
||||
EFI_HANDLE LocateHandle;
|
||||
EFI_HANDLE LocateDevicePath;
|
||||
EFI_HANDLE InstallConfigurationTable;
|
||||
|
||||
EFI_HANDLE LoadImage;
|
||||
EFI_HANDLE StartImage;
|
||||
EFI_HANDLE Exit;
|
||||
EFI_HANDLE UnloadImage;
|
||||
EFI_HANDLE ExitBootServices;
|
||||
|
||||
EFI_HANDLE GetNextHighMonotonicCount;
|
||||
EFI_HANDLE Stall;
|
||||
EFI_HANDLE SetWatchdogTimer;
|
||||
|
||||
EFI_HANDLE ConnectController;
|
||||
EFI_HANDLE DisconnectController;
|
||||
|
||||
EFI_HANDLE OpenProtocol;
|
||||
EFI_HANDLE CloseProtocol;
|
||||
EFI_HANDLE OpenProtocolInformation;
|
||||
|
||||
EFI_HANDLE ProtocolsPerHandle;
|
||||
EFI_HANDLE LocateHandleBuffer;
|
||||
EFI_HANDLE LocateProtocol;
|
||||
EFI_HANDLE InstallMultipleProtocolInterfaces;
|
||||
EFI_HANDLE UninstallMultipleProtocolInterfaces;
|
||||
|
||||
EFI_HANDLE CalculateCrc32;
|
||||
|
||||
EFI_HANDLE CopyMem;
|
||||
EFI_HANDLE SetMem;
|
||||
EFI_HANDLE CreateEventEx;
|
||||
} EFI_BOOT_SERVICES;
|
||||
|
||||
/*
|
||||
* EFI configuration table definitions.
|
||||
*/
|
||||
|
||||
#define MPS_TABLE_GUID \
|
||||
{ 0xeb9d2d2f, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
|
||||
|
||||
#define ACPI_TABLE_GUID \
|
||||
{ 0x8868e871, 0xe4f1, 0x11d3, { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
|
||||
|
||||
#define ACPI_20_TABLE_GUID \
|
||||
{ 0x8868e871, 0xe4f1, 0x11d3, { 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
|
||||
|
||||
#define SMBIOS_TABLE_GUID \
|
||||
{ 0xeb9d2d31, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
|
||||
|
||||
#define SMBIOS3_TABLE_GUID \
|
||||
{ 0xf2fd1544, 0x9794, 0x4a2c, { 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } }
|
||||
|
||||
#define SAL_SYSTEM_TABLE_GUID \
|
||||
{ 0xeb9d2d32, 0x2d88, 0x11d3, { 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } }
|
||||
|
||||
#define EFI_DTB_TABLE_GUID \
|
||||
{ 0xb1b621d5, 0xf19c, 0x41a5, { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }
|
||||
|
||||
typedef struct _EFI_CONFIGURATION_TABLE {
|
||||
EFI_GUID VendorGuid;
|
||||
VOID *VendorTable;
|
||||
} EFI_CONFIGURATION_TABLE;
|
||||
|
||||
/*
|
||||
* EFI system table definitions.
|
||||
*/
|
||||
|
||||
#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
|
||||
#define EFI_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_VERSION
|
||||
|
||||
typedef struct _EFI_SYSTEM_TABLE {
|
||||
EFI_TABLE_HEADER Hdr;
|
||||
|
||||
CHAR16 *FirmwareVendor;
|
||||
UINT32 FirmwareRevision;
|
||||
|
||||
EFI_HANDLE ConsoleInHandle;
|
||||
SIMPLE_INPUT_INTERFACE *ConIn;
|
||||
|
||||
EFI_HANDLE ConsoleOutHandle;
|
||||
SIMPLE_TEXT_OUTPUT_INTERFACE *ConOut;
|
||||
|
||||
EFI_HANDLE StandardErrorHandle;
|
||||
SIMPLE_TEXT_OUTPUT_INTERFACE *StdErr;
|
||||
|
||||
EFI_RUNTIME_SERVICES *RuntimeServices;
|
||||
EFI_BOOT_SERVICES *BootServices;
|
||||
|
||||
UINTN NumberOfTableEntries;
|
||||
EFI_CONFIGURATION_TABLE *ConfigurationTable;
|
||||
} EFI_SYSTEM_TABLE;
|
||||
|
||||
#endif
|
308
BOOT/ENVIRON/INC/eficon.h
Normal file
308
BOOT/ENVIRON/INC/eficon.h
Normal file
@ -0,0 +1,308 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
eficon.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides EFI console protocol definitions.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFICON_H
|
||||
#define _EFICON_H
|
||||
|
||||
/*
|
||||
* Text output protocol definitions.
|
||||
*/
|
||||
|
||||
INTERFACE_DECL(_SIMPLE_TEXT_OUTPUT_INTERFACE);
|
||||
|
||||
#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
|
||||
{ 0x387477c2, 0x69c7, 0x11d2, { 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } }
|
||||
#define SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_RESET) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_OUTPUT_STRING) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN CHAR16 *String
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_TEST_STRING) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN CHAR16 *String
|
||||
);
|
||||
|
||||
/*
|
||||
* Text attribute definitions.
|
||||
*/
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN UINTN Attribute
|
||||
);
|
||||
|
||||
#define EFI_TEXT_ATTR(f,b) ((f) | ((b) << 4))
|
||||
|
||||
#define EFI_BLACK 0x00
|
||||
#define EFI_BLUE 0x01
|
||||
#define EFI_GREEN 0x02
|
||||
#define EFI_RED 0x04
|
||||
#define EFI_BRIGHT 0x08
|
||||
#define EFI_CYAN (EFI_BLUE | EFI_GREEN)
|
||||
#define EFI_MAGENTA (EFI_BLUE | EFI_RED)
|
||||
#define EFI_BROWN (EFI_GREEN | EFI_RED)
|
||||
#define EFI_LIGHTGRAY (EFI_BLUE | EFI_GREEN | EFI_RED)
|
||||
#define EFI_DARKGRAY (EFI_BRIGHT)
|
||||
#define EFI_LIGHTBLUE (EFI_BLUE | EFI_BRIGHT)
|
||||
#define EFI_LIGHTGREEN (EFI_GREEN | EFI_BRIGHT)
|
||||
#define EFI_LIGHTCYAN (EFI_CYAN | EFI_BRIGHT)
|
||||
#define EFI_LIGHTRED (EFI_RED | EFI_BRIGHT)
|
||||
#define EFI_LIGHTMAGENTA (EFI_MAGENTA | EFI_BRIGHT)
|
||||
#define EFI_YELLOW (EFI_BROWN | EFI_BRIGHT)
|
||||
#define EFI_WHITE (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)
|
||||
|
||||
#define EFI_BACKGROUND_BLACK 0x00
|
||||
#define EFI_BACKGROUND_BLUE 0x10
|
||||
#define EFI_BACKGROUND_GREEN 0x20
|
||||
#define EFI_BACKGROUND_RED 0x40
|
||||
#define EFI_BACKGROUND_CYAN (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
|
||||
#define EFI_BACKGROUND_MAGENTA (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
|
||||
#define EFI_BACKGROUND_BROWN (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
|
||||
#define EFI_BACKGROUND_LIGHTGRAY (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
|
||||
|
||||
/*
|
||||
* Mode/cursor definitions.
|
||||
*/
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_QUERY_MODE) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN UINTN ModeNumber,
|
||||
OUT UINTN *Columns,
|
||||
OUT UINTN *Rows
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_SET_MODE) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN UINTN ModeNumber
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_CLEAR_SCREEN) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN UINTN Column,
|
||||
IN UINTN Row
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_TEXT_ENABLE_CURSOR) (
|
||||
IN struct _SIMPLE_TEXT_OUTPUT_INTERFACE *This,
|
||||
IN BOOLEAN Enable
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
INT32 MaxMode;
|
||||
INT32 Mode;
|
||||
INT32 Attribute;
|
||||
INT32 CursorColumn;
|
||||
INT32 CursorRow;
|
||||
BOOLEAN CursorVisible;
|
||||
} SIMPLE_TEXT_OUTPUT_MODE;
|
||||
|
||||
typedef struct _SIMPLE_TEXT_OUTPUT_INTERFACE {
|
||||
EFI_TEXT_RESET Reset;
|
||||
|
||||
EFI_TEXT_OUTPUT_STRING OutputString;
|
||||
EFI_TEXT_TEST_STRING TestString;
|
||||
|
||||
EFI_TEXT_QUERY_MODE QueryMode;
|
||||
EFI_TEXT_SET_MODE SetMode;
|
||||
EFI_TEXT_SET_ATTRIBUTE SetAttribute;
|
||||
|
||||
EFI_TEXT_CLEAR_SCREEN ClearScreen;
|
||||
EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition;
|
||||
EFI_TEXT_ENABLE_CURSOR EnableCursor;
|
||||
|
||||
SIMPLE_TEXT_OUTPUT_MODE *Mode;
|
||||
} SIMPLE_TEXT_OUTPUT_INTERFACE, EFI_SIMPLE_TEXT_OUT_PROTOCOL;
|
||||
|
||||
/*
|
||||
* Unicode Box Draw definitions.
|
||||
*/
|
||||
|
||||
#define BOXDRAW_HORIZONTAL 0x2500
|
||||
#define BOXDRAW_VERTICAL 0x2502
|
||||
#define BOXDRAW_DOWN_RIGHT 0x250c
|
||||
#define BOXDRAW_DOWN_LEFT 0x2510
|
||||
#define BOXDRAW_UP_RIGHT 0x2514
|
||||
#define BOXDRAW_UP_LEFT 0x2518
|
||||
#define BOXDRAW_VERTICAL_RIGHT 0x251c
|
||||
#define BOXDRAW_VERTICAL_LEFT 0x2524
|
||||
#define BOXDRAW_DOWN_HORIZONTAL 0x252c
|
||||
#define BOXDRAW_UP_HORIZONTAL 0x2534
|
||||
#define BOXDRAW_VERTICAL_HORIZONTAL 0x253c
|
||||
|
||||
#define BOXDRAW_DOUBLE_HORIZONTAL 0x2550
|
||||
#define BOXDRAW_DOUBLE_VERTICAL 0x2551
|
||||
#define BOXDRAW_DOWN_RIGHT_DOUBLE 0x2552
|
||||
#define BOXDRAW_DOWN_DOUBLE_RIGHT 0x2553
|
||||
#define BOXDRAW_DOUBLE_DOWN_RIGHT 0x2554
|
||||
|
||||
#define BOXDRAW_DOWN_LEFT_DOUBLE 0x2555
|
||||
#define BOXDRAW_DOWN_DOUBLE_LEFT 0x2556
|
||||
#define BOXDRAW_DOUBLE_DOWN_LEFT 0x2557
|
||||
|
||||
#define BOXDRAW_UP_RIGHT_DOUBLE 0x2558
|
||||
#define BOXDRAW_UP_DOUBLE_RIGHT 0x2559
|
||||
#define BOXDRAW_DOUBLE_UP_RIGHT 0x255a
|
||||
|
||||
#define BOXDRAW_UP_LEFT_DOUBLE 0x255b
|
||||
#define BOXDRAW_UP_DOUBLE_LEFT 0x255c
|
||||
#define BOXDRAW_DOUBLE_UP_LEFT 0x255d
|
||||
|
||||
#define BOXDRAW_VERTICAL_RIGHT_DOUBLE 0x255e
|
||||
#define BOXDRAW_VERTICAL_DOUBLE_RIGHT 0x255f
|
||||
#define BOXDRAW_DOUBLE_VERTICAL_RIGHT 0x2560
|
||||
|
||||
#define BOXDRAW_VERTICAL_LEFT_DOUBLE 0x2561
|
||||
#define BOXDRAW_VERTICAL_DOUBLE_LEFT 0x2562
|
||||
#define BOXDRAW_DOUBLE_VERTICAL_LEFT 0x2563
|
||||
|
||||
#define BOXDRAW_DOWN_HORIZONTAL_DOUBLE 0x2564
|
||||
#define BOXDRAW_DOWN_DOUBLE_HORIZONTAL 0x2565
|
||||
#define BOXDRAW_DOUBLE_DOWN_HORIZONTAL 0x2566
|
||||
|
||||
#define BOXDRAW_UP_HORIZONTAL_DOUBLE 0x2567
|
||||
#define BOXDRAW_UP_DOUBLE_HORIZONTAL 0x2568
|
||||
#define BOXDRAW_DOUBLE_UP_HORIZONTAL 0x2569
|
||||
|
||||
#define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE 0x256a
|
||||
#define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL 0x256b
|
||||
#define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL 0x256c
|
||||
|
||||
/*
|
||||
* Required Block Elements definitions.
|
||||
*/
|
||||
|
||||
#define BLOCKELEMENT_FULL_BLOCK 0x2588
|
||||
#define BLOCKELEMENT_LIGHT_SHADE 0x2591
|
||||
|
||||
/*
|
||||
* Required Geometric Shapes definitions.
|
||||
*/
|
||||
|
||||
#define GEOMETRICSHAPE_UP_TRIANGLE 0x25b2
|
||||
#define GEOMETRICSHAPE_RIGHT_TRIANGLE 0x25ba
|
||||
#define GEOMETRICSHAPE_DOWN_TRIANGLE 0x25bc
|
||||
#define GEOMETRICSHAPE_LEFT_TRIANGLE 0x25c4
|
||||
|
||||
/*
|
||||
* Required Arrow Shapes definitions.
|
||||
*/
|
||||
|
||||
#define ARROW_UP 0x2191
|
||||
#define ARROW_DOWN 0x2193
|
||||
|
||||
/*
|
||||
* Text input protocol definitions.
|
||||
*/
|
||||
|
||||
INTERFACE_DECL(_SIMPLE_INPUT_INTERFACE);
|
||||
|
||||
#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
|
||||
{ 0x387477c1, 0x69c7, 0x11d2, { 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } }
|
||||
#define SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID
|
||||
|
||||
typedef struct {
|
||||
UINT16 ScanCode;
|
||||
CHAR16 UnicodeChar;
|
||||
} EFI_INPUT_KEY;
|
||||
|
||||
/*
|
||||
* Unicode control definitions.
|
||||
*/
|
||||
|
||||
#define CHAR_NULL 0x0000
|
||||
#define CHAR_BACKSPACE 0x0008
|
||||
#define CHAR_TAB 0x0009
|
||||
#define CHAR_LINEFEED 0x000A
|
||||
#define CHAR_CARRIAGE_RETURN 0x000D
|
||||
|
||||
/*
|
||||
* Scancode definitions.
|
||||
*/
|
||||
|
||||
#define SCAN_NULL 0x0000
|
||||
#define SCAN_UP 0x0001
|
||||
#define SCAN_DOWN 0x0002
|
||||
#define SCAN_RIGHT 0x0003
|
||||
#define SCAN_LEFT 0x0004
|
||||
#define SCAN_HOME 0x0005
|
||||
#define SCAN_END 0x0006
|
||||
#define SCAN_INSERT 0x0007
|
||||
#define SCAN_DELETE 0x0008
|
||||
#define SCAN_PAGE_UP 0x0009
|
||||
#define SCAN_PAGE_DOWN 0x000A
|
||||
#define SCAN_F1 0x000B
|
||||
#define SCAN_F2 0x000C
|
||||
#define SCAN_F3 0x000D
|
||||
#define SCAN_F4 0x000E
|
||||
#define SCAN_F5 0x000F
|
||||
#define SCAN_F6 0x0010
|
||||
#define SCAN_F7 0x0011
|
||||
#define SCAN_F8 0x0012
|
||||
#define SCAN_F9 0x0013
|
||||
#define SCAN_F10 0x0014
|
||||
#define SCAN_F11 0x0015
|
||||
#define SCAN_F12 0x0016
|
||||
#define SCAN_ESC 0x0017
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_RESET) (
|
||||
IN struct _SIMPLE_INPUT_INTERFACE *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_READ_KEY) (
|
||||
IN struct _SIMPLE_INPUT_INTERFACE *This,
|
||||
OUT EFI_INPUT_KEY *Key
|
||||
);
|
||||
|
||||
typedef struct _SIMPLE_INPUT_INTERFACE {
|
||||
EFI_INPUT_RESET Reset;
|
||||
EFI_INPUT_READ_KEY ReadKeyStroke;
|
||||
EFI_EVENT WaitForKey;
|
||||
} SIMPLE_INPUT_INTERFACE, EFI_SIMPLE_TEXT_IN_PROTOCOL;
|
||||
|
||||
#endif
|
196
BOOT/ENVIRON/INC/efidef.h
Normal file
196
BOOT/ENVIRON/INC/efidef.h
Normal file
@ -0,0 +1,196 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
efidef.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides basic EFI type/structure definitions.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFIDEF_H
|
||||
#define _EFIDEF_H
|
||||
|
||||
#ifndef VOID
|
||||
#define VOID void
|
||||
#endif
|
||||
|
||||
#ifndef CONST
|
||||
#define CONST const
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#if defined(__cplusplus)
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((VOID *) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
typedef bool BOOLEAN;
|
||||
#else
|
||||
typedef UINT8 BOOLEAN;
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#if defined(__cplusplus)
|
||||
typedef bool BOOLEAN;
|
||||
#define TRUE true
|
||||
#define FALSE false
|
||||
#else
|
||||
typedef UINT8 BOOLEAN;
|
||||
#define TRUE ((BOOLEAN) 1)
|
||||
#define FALSE ((BOOLEAN) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef UINT16 CHAR16;
|
||||
typedef UINT8 CHAR8;
|
||||
|
||||
typedef UINTN EFI_STATUS;
|
||||
typedef UINT64 EFI_LBA;
|
||||
typedef UINTN EFI_TPL;
|
||||
typedef VOID *EFI_HANDLE;
|
||||
typedef VOID *EFI_EVENT;
|
||||
|
||||
/*
|
||||
* Decorators to show parameter direction.
|
||||
*
|
||||
* IN - argument passed into routine.
|
||||
* OUT - argument pointer returned by routine.
|
||||
* OPTIONAL - argument is not required.
|
||||
*/
|
||||
|
||||
#ifndef IN
|
||||
#define IN
|
||||
#define OUT
|
||||
#define OPTIONAL
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Globally Unique IDentifier.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
UINT32 Data1;
|
||||
UINT16 Data2;
|
||||
UINT16 Data3;
|
||||
UINT8 Data4[8];
|
||||
} EFI_GUID;
|
||||
|
||||
/*
|
||||
* Time definitons.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
UINT16 Year;
|
||||
UINT8 Month;
|
||||
UINT8 Day;
|
||||
UINT8 Hour;
|
||||
UINT8 Minute;
|
||||
UINT8 Second;
|
||||
UINT8 Pad1;
|
||||
UINT32 Nanosecond;
|
||||
INT16 Timezone;
|
||||
UINT8 Daylight;
|
||||
UINT8 Pad2;
|
||||
} EFI_TIME;
|
||||
|
||||
/* For EFI_TIME.Daylight */
|
||||
#define EFI_TIME_ADJUST_DAYLIGHT 0x01
|
||||
#define EFI_TIME_IN_DAYLIGHT 0x02
|
||||
|
||||
/* For EFI_TIME.TimeZone */
|
||||
#define EFI_UNSPECIFIED_TIMEZONE 0x07FF
|
||||
|
||||
/*
|
||||
* Networking definitions.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
UINT8 Addr[4];
|
||||
} EFI_IPv4_ADDRESS;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Addr[16];
|
||||
} EFI_IPv6_ADDRESS;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Addr[32];
|
||||
} EFI_MAC_ADDRESS;
|
||||
|
||||
/*
|
||||
* Memory definitions.
|
||||
*/
|
||||
|
||||
typedef UINT64 EFI_PHYSICAL_ADDRESS;
|
||||
typedef UINT64 EFI_VIRTUAL_ADDRESS;
|
||||
|
||||
typedef enum {
|
||||
AllocateAnyPages,
|
||||
AllocateMaxAddress,
|
||||
AllocateAddress,
|
||||
MaxAllocateType
|
||||
} EFI_ALLOCATE_TYPE;
|
||||
|
||||
typedef enum {
|
||||
EfiReservedMemoryType,
|
||||
EfiLoaderCode,
|
||||
EfiLoaderData,
|
||||
EfiBootServicesCode,
|
||||
EfiBootServicesData,
|
||||
EfiRuntimeServicesCode,
|
||||
EfiRuntimeServicesData,
|
||||
EfiConventionalMemory,
|
||||
EfiUnusableMemory,
|
||||
EfiACPIReclaimMemory,
|
||||
EfiACPIMemoryNVS,
|
||||
EfiMemoryMappedIO,
|
||||
EfiMemoryMappedIOPortSpace,
|
||||
EfiPalCode,
|
||||
EfiPersistentMemory,
|
||||
EfiUnacceptedMemoryType,
|
||||
EfiMaxMemoryType
|
||||
} EFI_MEMORY_TYPE;
|
||||
|
||||
/* Memory range caching types */
|
||||
#define EFI_MEMORY_UC 0x0000000000000001
|
||||
#define EFI_MEMORY_WC 0x0000000000000002
|
||||
#define EFI_MEMORY_WT 0x0000000000000004
|
||||
#define EFI_MEMORY_WB 0x0000000000000008
|
||||
#define EFI_MEMORY_UCE 0x0000000000000010
|
||||
|
||||
/* Memory range protection flags */
|
||||
#define EFI_MEMORY_WP 0x0000000000001000
|
||||
#define EFI_MEMORY_RP 0x0000000000002000
|
||||
#define EFI_MEMORY_XP 0x0000000000004000
|
||||
#define EFI_MEMORY_RO 0x0000000000020000
|
||||
|
||||
/* Memory type runtime mapping flags */
|
||||
#define EFI_MEMORY_NV 0x0000000000008000
|
||||
#define EFI_MEMORY_RUNTIME 0x8000000000000000
|
||||
|
||||
#define EFI_MEMORY_DESCRIPTOR_VERSION 1
|
||||
|
||||
typedef struct {
|
||||
UINT32 Type;
|
||||
UINT32 Pad;
|
||||
EFI_PHYSICAL_ADDRESS PhysicalStart;
|
||||
EFI_VIRTUAL_ADDRESS VirtualStart;
|
||||
UINT64 NumberOfPages;
|
||||
UINT64 Attribute;
|
||||
} EFI_MEMORY_DESCRIPTOR;
|
||||
|
||||
#define EFI_PAGE_SIZE 4096
|
||||
#define EFI_PAGE_MASK 0xFFF
|
||||
#define EFI_PAGE_SHIFT 12
|
||||
|
||||
#define EFI_SIZE_TO_PAGES(s) (((s) >> EFI_PAGE_SHIFT) + ((s) & EFI_PAGE_MASK ? 1 : 0))
|
||||
|
||||
#endif
|
28
BOOT/ENVIRON/INC/efidevp.h
Normal file
28
BOOT/ENVIRON/INC/efidevp.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
efidevp.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides EFI device path definitions.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFIDEVP_H
|
||||
#define _EFIDEVP_H
|
||||
|
||||
typedef struct _EFI_DEVICE_PATH_PROTOCOL {
|
||||
UINT8 Type;
|
||||
UINT8 SubType;
|
||||
UINT8 Length[2];
|
||||
} EFI_DEVICE_PATH_PROTOCOL;
|
||||
|
||||
typedef struct _EFI_DEVICE_PATH_PROTOCOL _EFI_DEVICE_PATH;
|
||||
typedef EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH;
|
||||
|
||||
#endif
|
65
BOOT/ENVIRON/INC/efierr.h
Normal file
65
BOOT/ENVIRON/INC/efierr.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
efierr.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides EFI error definitions.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFIERR_H
|
||||
#define _EFIERR_H
|
||||
|
||||
#define EFIWARN(a) (a)
|
||||
#define EFI_ERROR(a) (((INTN) a) < 0)
|
||||
|
||||
#define EFI_SUCCESS 0
|
||||
#define EFI_LOAD_ERROR EFIERR(1)
|
||||
#define EFI_INVALID_PARAMETER EFIERR(2)
|
||||
#define EFI_UNSUPPORTED EFIERR(3)
|
||||
#define EFI_BAD_BUFFER_SIZE EFIERR(4)
|
||||
#define EFI_BUFFER_TOO_SMALL EFIERR(5)
|
||||
#define EFI_NOT_READY EFIERR(6)
|
||||
#define EFI_DEVICE_ERROR EFIERR(7)
|
||||
#define EFI_WRITE_PROTECTED EFIERR(8)
|
||||
#define EFI_OUT_OF_RESOURCES EFIERR(9)
|
||||
#define EFI_VOLUME_CORRUPTED EFIERR(10)
|
||||
#define EFI_VOLUME_FULL EFIERR(11)
|
||||
#define EFI_NO_MEDIA EFIERR(12)
|
||||
#define EFI_MEDIA_CHANGED EFIERR(13)
|
||||
#define EFI_NOT_FOUND EFIERR(14)
|
||||
#define EFI_ACCESS_DENIED EFIERR(15)
|
||||
#define EFI_NO_RESPONSE EFIERR(16)
|
||||
#define EFI_NO_MAPPING EFIERR(17)
|
||||
#define EFI_TIMEOUT EFIERR(18)
|
||||
#define EFI_NOT_STARTED EFIERR(19)
|
||||
#define EFI_ALREADY_STARTED EFIERR(20)
|
||||
#define EFI_ABORTED EFIERR(21)
|
||||
#define EFI_ICMP_ERROR EFIERR(22)
|
||||
#define EFI_TFTP_ERROR EFIERR(23)
|
||||
#define EFI_PROTOCOL_ERROR EFIERR(24)
|
||||
#define EFI_INCOMPATIBLE_VERSION EFIERR(25)
|
||||
#define EFI_SECURITY_VIOLATION EFIERR(26)
|
||||
#define EFI_CRC_ERROR EFIERR(27)
|
||||
#define EFI_END_OF_MEDIA EFIERR(28)
|
||||
#define EFI_END_OF_FILE EFIERR(31)
|
||||
#define EFI_INVALID_LANGUAGE EFIERR(32)
|
||||
#define EFI_COMPROMISED_DATA EFIERR(33)
|
||||
#define EFI_IP_ADDRESS_CONFLICT EFIERR(34)
|
||||
#define EFI_HTTP_ERROR EFIERR(35)
|
||||
|
||||
#define EFI_WARN_UNKOWN_GLYPH EFIWARN(1)
|
||||
#define EFI_WARN_DELETE_FAILURE EFIWARN(2)
|
||||
#define EFI_WARN_WRITE_FAILURE EFIWARN(3)
|
||||
#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4)
|
||||
#define EFI_WARN_STALE_DATA EFIWARN(5)
|
||||
#define EFI_WARN_FILE_SYSTEM EFIWARN(6)
|
||||
#define EFI_WARN_RESET_REQUESTED EFIWARN(7)
|
||||
|
||||
#endif
|
27
BOOT/ENVIRON/INC/efiprot.h
Normal file
27
BOOT/ENVIRON/INC/efiprot.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
efiprot.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides EFI protocol definitions.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _EFIPROT_H
|
||||
#define _EFIPROT_H
|
||||
|
||||
/*
|
||||
* Device path protocol definitions.
|
||||
*/
|
||||
|
||||
#define EFI_DEVICE_PATH_PROTOCOL_GUID \
|
||||
{ 0x9576e91, 0x6d3f, 0x11d2, { 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } }
|
||||
#define DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH_PROTOCOL_GUID
|
||||
|
||||
#endif
|
23
BOOT/ENVIRON/INC/nt.h
Normal file
23
BOOT/ENVIRON/INC/nt.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
nt.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides NT header files.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _NT_H
|
||||
#define _NT_H
|
||||
|
||||
#include <ntdef.h>
|
||||
#include <ntstatus.h>
|
||||
#include <ntimage.h>
|
||||
|
||||
#endif
|
146
BOOT/ENVIRON/INC/ntdef.h
Normal file
146
BOOT/ENVIRON/INC/ntdef.h
Normal file
@ -0,0 +1,146 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
ntdef.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides basic NT definitions.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _NTDEF_H
|
||||
#define _NTDEF_H
|
||||
|
||||
#ifndef VOID
|
||||
#define VOID void
|
||||
#endif
|
||||
|
||||
#ifndef CONST
|
||||
#define CONST const
|
||||
#endif
|
||||
|
||||
#ifndef IN
|
||||
#define IN
|
||||
#define OUT
|
||||
#define OPTIONAL
|
||||
#endif
|
||||
|
||||
#ifndef ANYSIZE_ARRAY
|
||||
#define ANYSIZE_ARRAY 1
|
||||
#endif
|
||||
|
||||
#ifndef FORCEINLINE
|
||||
#if defined(_MSC_EXTENSIONS)
|
||||
#define FORCEINLINE __inline
|
||||
#else
|
||||
#define FORCEINLINE static inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef FASTCALL
|
||||
#define FASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef NTAPI
|
||||
#define NTAPI
|
||||
#endif
|
||||
|
||||
//
|
||||
// Basic types.
|
||||
//
|
||||
typedef char CHAR;
|
||||
typedef short SHORT;
|
||||
typedef long LONG;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned long ULONG;
|
||||
|
||||
//
|
||||
// Basic type pointers.
|
||||
//
|
||||
typedef void *PVOID;
|
||||
typedef CHAR *PCHAR;
|
||||
typedef SHORT *PSHORT;
|
||||
typedef UCHAR *PUCHAR;
|
||||
typedef USHORT *PUSHORT;
|
||||
typedef ULONG *PULONG;
|
||||
|
||||
//
|
||||
// Wide characters.
|
||||
//
|
||||
typedef USHORT WCHAR;
|
||||
typedef WCHAR *PWCHAR;
|
||||
|
||||
//
|
||||
// Logical values.
|
||||
//
|
||||
typedef ULONG LOGICAL;
|
||||
typedef ULONG *PLOGICAL;
|
||||
|
||||
//
|
||||
// Status codes.
|
||||
//
|
||||
typedef LONG NTSTATUS;
|
||||
typedef NTSTATUS *PNTSTATUS;
|
||||
|
||||
//
|
||||
// Status code utilities.
|
||||
//
|
||||
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
|
||||
#define NT_INFORMATION(Status) ((ULONG)(Status) >> 30 == 1)
|
||||
#define NT_WARNING(Status) ((ULONG)(Status) >> 30 == 2)
|
||||
#define NT_ERROR(Status) ((ULONG)(Status) >> 30 == 3)
|
||||
|
||||
//
|
||||
// Long long type definitions.
|
||||
//
|
||||
#if defined(_MSC_EXTENSIONS)
|
||||
typedef unsigned __int64 ULONGLONG;
|
||||
typedef __int64 LONGLONG;
|
||||
#elif defined(UNIX_LP64)
|
||||
typedef unsigned long ULONGLONG;
|
||||
typedef long LONGLONG;
|
||||
#else
|
||||
typedef unsigned long long ULONGLONG;
|
||||
typedef long long LONGLONG;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Large (64-bit) integer value.
|
||||
//
|
||||
typedef union LARGE_INTEGER {
|
||||
struct {
|
||||
ULONG LowPart;
|
||||
LONG HighPart;
|
||||
};
|
||||
|
||||
LONGLONG QuadPart;
|
||||
} LARGE_INTEGER, *PLARGE_INTEGER;
|
||||
|
||||
//
|
||||
// Large (64-bit) unsigned integer value.
|
||||
//
|
||||
typedef union ULARGE_INTEGER {
|
||||
struct {
|
||||
ULONG LowPart;
|
||||
ULONG HighPart;
|
||||
};
|
||||
|
||||
ULONGLONG QuadPart;
|
||||
} ULARGE_INTEGER, *PULARGE_INTEGER;
|
||||
|
||||
//
|
||||
// Struct field offset helper.
|
||||
//
|
||||
#if !defined(__GNUC__) && !defined(__clang__)
|
||||
#define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field))
|
||||
#else
|
||||
#define FIELD_OFFSET(type, field) ((ULONG)__builtin_offsetof(type, field))
|
||||
#endif
|
||||
|
||||
#endif
|
26
BOOT/ENVIRON/INC/ntimage.h
Normal file
26
BOOT/ENVIRON/INC/ntimage.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
ntimage.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides NT image file definitions.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _NTIMAGE_H
|
||||
#define _NTIMAGE_H
|
||||
|
||||
//
|
||||
// Machine type values.
|
||||
//
|
||||
#define IMAGE_FILE_MACHINE_UNKNOWN 0
|
||||
#define IMAGE_FILE_MACHINE_I386 0x014c
|
||||
#define IMAGE_FILE_MACHINE_AMD64 0x8664
|
||||
|
||||
#endif
|
44
BOOT/ENVIRON/INC/ntstatus.h
Normal file
44
BOOT/ENVIRON/INC/ntstatus.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
ntstatus.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides NT status code values.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _NTSTATUS_H
|
||||
#define _NTSTATUS_H
|
||||
|
||||
#define STATUS_SUCCESS ((NTSTATUS) 0x00000000L)
|
||||
|
||||
//
|
||||
// TODO: There are an insane amount of status values.
|
||||
//
|
||||
#define STATUS_MEDIA_CHANGED ((NTSTATUS) 0x8000001CL)
|
||||
#define STATUS_INVALID_PARAMETER ((NTSTATUS) 0xC000000DL)
|
||||
#define STATUS_ACCESS_DENIED ((NTSTATUS) 0xC0000022L)
|
||||
#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS) 0xC0000023L)
|
||||
#define STATUS_DISK_CORRUPT_ERROR ((NTSTATUS) 0xC0000032L)
|
||||
#define STATUS_DEVICE_ALREADY_ATTACHED ((NTSTATUS) 0xC0000038L)
|
||||
#define STATUS_DISK_FULL ((NTSTATUS) 0xC000007FL)
|
||||
#define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS) 0xC000009AL)
|
||||
#define STATUS_MEDIA_WRITE_PROTECTED ((NTSTATUS) 0xC00000A2L)
|
||||
#define STATUS_DEVICE_NOT_READY ((NTSTATUS) 0xC00000A3L)
|
||||
#define STATUS_NOT_SUPPORTED ((NTSTATUS) 0xC00000BBL)
|
||||
#define STATUS_TIMEOUT ((NTSTATUS) 0x00000102L)
|
||||
#define STATUS_NO_MEDIA ((NTSTATUS) 0xC0000178L)
|
||||
#define STATUS_IO_DEVICE_ERROR ((NTSTATUS) 0xC0000185L)
|
||||
#define STATUS_INVALID_BUFFER_SIZE ((NTSTATUS) 0xC0000206L)
|
||||
#define STATUS_NOT_FOUND ((NTSTATUS) 0xC0000225L)
|
||||
#define STATUS_REQUEST_ABORTED ((NTSTATUS) 0xC0000240L)
|
||||
#define STATUS_DRIVER_UNABLE_TO_LOAD ((NTSTATUS) 0xC000026CL)
|
||||
#define STATUS_NO_MATCH ((NTSTATUS) 0xC0000272L)
|
||||
|
||||
#endif
|
84
BOOT/ENVIRON/LIB/EFI/efistatus.c
Normal file
84
BOOT/ENVIRON/LIB/EFI/efistatus.c
Normal file
@ -0,0 +1,84 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, the LibreXP developers.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
efistatus.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides EFI status code utilities.
|
||||
|
||||
--*/
|
||||
|
||||
#include "bootmgr.h"
|
||||
|
||||
EFI_STATUS
|
||||
EfiGetEfiStatusCode (
|
||||
IN NTSTATUS Status
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Converts an NT status code into an EFI status code.
|
||||
|
||||
Arguments:
|
||||
|
||||
Status - The NT status code to be converted.
|
||||
|
||||
Return Value:
|
||||
|
||||
The EFI status code.
|
||||
|
||||
--*/
|
||||
|
||||
{
|
||||
switch (Status) {
|
||||
case STATUS_SUCCESS:
|
||||
return EFI_SUCCESS;
|
||||
case STATUS_DRIVER_UNABLE_TO_LOAD:
|
||||
return EFI_LOAD_ERROR;
|
||||
case STATUS_INVALID_PARAMETER:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
case STATUS_NOT_SUPPORTED:
|
||||
return EFI_UNSUPPORTED;
|
||||
case STATUS_INVALID_BUFFER_SIZE:
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
case STATUS_BUFFER_TOO_SMALL:
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
case STATUS_IO_DEVICE_ERROR:
|
||||
return EFI_DEVICE_ERROR;
|
||||
case STATUS_MEDIA_WRITE_PROTECTED:
|
||||
return EFI_WRITE_PROTECTED;
|
||||
case STATUS_INSUFFICIENT_RESOURCES:
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
case STATUS_DISK_CORRUPT_ERROR:
|
||||
return EFI_VOLUME_CORRUPTED;
|
||||
case STATUS_DISK_FULL:
|
||||
return EFI_VOLUME_FULL;
|
||||
case STATUS_NO_MEDIA:
|
||||
return EFI_NO_MEDIA;
|
||||
case STATUS_MEDIA_CHANGED:
|
||||
return EFI_MEDIA_CHANGED;
|
||||
case STATUS_NOT_FOUND:
|
||||
return EFI_NOT_FOUND;
|
||||
case STATUS_ACCESS_DENIED:
|
||||
return EFI_ACCESS_DENIED;
|
||||
case STATUS_NO_MATCH:
|
||||
return EFI_NO_MAPPING;
|
||||
case STATUS_TIMEOUT:
|
||||
return EFI_TIMEOUT;
|
||||
case STATUS_DEVICE_NOT_READY:
|
||||
return EFI_NOT_STARTED;
|
||||
case STATUS_DEVICE_ALREADY_ATTACHED:
|
||||
return EFI_ALREADY_STARTED;
|
||||
case STATUS_REQUEST_ABORTED:
|
||||
return EFI_ABORTED;
|
||||
default:
|
||||
return EFI_NO_MAPPING;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user