#ifndef __UEFI_H__
#define __UEFI_H__
/* Common UEFI type definitions for HR650X BIOS source reconstruction */
#include <stdint.h>
/* Basic UEFI types */
typedef uint8_t UINT8;
typedef uint16_t UINT16;
typedef uint32_t UINT32;
typedef uint64_t UINT64;
typedef int8_t INT8;
typedef int16_t INT16;
typedef int32_t INT32;
typedef int64_t INT64;
typedef void VOID;
typedef UINT8 BOOLEAN;
typedef INT8 CHAR8;
/* UINTN is the pointer-width unsigned integer type */
#ifdef __LP64__
typedef uint64_t UINTN;
#else
typedef uint32_t UINTN;
#endif
typedef intptr_t INTN;
/* UEFI status codes */
typedef UINTN EFI_STATUS;
#define EFI_SUCCESS 0
#define EFI_LOAD_ERROR ((EFI_STATUS)(1ULL << 63))
#define EFI_INVALID_PARAMETER ((EFI_STATUS)(2ULL << 63))
#define EFI_UNSUPPORTED ((EFI_STATUS)(3ULL << 63))
#define EFI_BAD_BUFFER_SIZE ((EFI_STATUS)(4ULL << 63))
#define EFI_BUFFER_TOO_SMALL ((EFI_STATUS)(5ULL << 63))
#define EFI_NOT_READY ((EFI_STATUS)(6ULL << 63))
#define EFI_DEVICE_ERROR ((EFI_STATUS)(7ULL << 63))
#define EFI_WRITE_PROTECTED ((EFI_STATUS)(8ULL << 63))
#define EFI_OUT_OF_RESOURCES ((EFI_STATUS)(9ULL << 63))
#define EFI_NOT_FOUND ((EFI_STATUS)(14ULL << 63))
#define EFI_ACCESS_DENIED ((EFI_STATUS)(15ULL << 63))
#define EFI_ALREADY_STARTED ((EFI_STATUS)(20ULL << 63))
#define EFI_ERROR(Status) (((EFI_STATUS)(Status)) >> 63)
/* UEFI handle types */
typedef VOID *EFI_HANDLE;
typedef VOID *EFI_EVENT;
/* GUID definition */
typedef struct {
UINT32 Data1;
UINT16 Data2;
UINT16 Data3;
UINT8 Data4[8];
} EFI_GUID;
/* Time definition */
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;
/* Table header */
typedef struct {
UINT64 Signature;
UINT32 Revision;
UINT32 HeaderSize;
UINT32 CRC32;
UINT32 Reserved;
} EFI_TABLE_HEADER;
/* Forward declarations */
typedef struct _EFI_SYSTEM_TABLE EFI_SYSTEM_TABLE;
typedef struct _EFI_BOOT_SERVICES EFI_BOOT_SERVICES;
typedef struct _EFI_RUNTIME_SERVICES EFI_RUNTIME_SERVICES;
/* Memory descriptor */
typedef struct {
UINT32 Type;
UINT64 PhysicalStart;
UINT64 VirtualStart;
UINT64 NumberOfPages;
UINT64 Attribute;
} EFI_MEMORY_DESCRIPTOR;
/* Memory type enum */
#define EfiReservedMemoryType 0
#define EfiLoaderCode 1
#define EfiLoaderData 2
#define EfiBootServicesCode 3
#define EfiBootServicesData 4
#define EfiRuntimeServicesCode 5
#define EfiRuntimeServicesData 6
#define EfiConventionalMemory 7
#define EfiUnusableMemory 8
#define EfiACPIReclaimMemory 9
#define EfiACPIMemoryNVS 10
#define EfiMemoryMappedIO 11
#define EfiMemoryMappedIOPortSpace 12
#define EfiPalCode 13
#define EfiPersistentMemory 14
#define EfiMaxMemoryType 15
/* CHAR16 is a 16-bit Unicode character */
typedef uint16_t CHAR16;
typedef uint64_t EFI_PHYSICAL_ADDRESS;
typedef UINTN EFI_EVENT_NOTIFY;
typedef UINTN EFI_MEMORY_TYPE;
/* CONST macro needed by forward declarations below */
#ifndef CONST
#define CONST const
#endif
/* Forward declarations for protocol structs used in function pointer typedefs */
typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
typedef struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
typedef struct _EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH_PROTOCOL;
typedef struct _EFI_OPEN_PROTOCOL_INFORMATION_ENTRY EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
typedef struct _EFI_RUNTIME_SERVICES EFI_RUNTIME_SERVICES;
/* EFI_BOOT_SERVICES member types */
/* EFI_RAISE_TPL, EFI_RESTORE_TPL, EFI_LOCATE_DEVICE_PATH, etc. are defined
* later in this file alongside their complete function pointer typedefs.
* The forward declarations below are needed only for the struct member list. */
typedef UINTN (EFIAPI *EFI_RAISE_TPL)(UINTN NewTpl);
typedef UINTN (EFIAPI *EFI_RESTORE_TPL)(UINTN OldTpl);
typedef EFI_STATUS (EFIAPI *EFI_LOCATE_DEVICE_PATH)(
IN EFI_GUID *Protocol,
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
OUT EFI_HANDLE *Device);
typedef EFI_STATUS (EFIAPI *EFI_LOAD_IMAGE)(
IN BOOLEAN BootPolicy,
IN EFI_HANDLE ParentImageHandle,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN VOID *SourceBuffer,
IN UINTN SourceSize,
OUT EFI_HANDLE *ImageHandle);
typedef EFI_STATUS (EFIAPI *EFI_CONNECT_CONTROLLER)(
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE *DriverImageHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath,
IN BOOLEAN Recursive);
typedef EFI_STATUS (EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION)(
IN EFI_HANDLE Handle,
IN EFI_GUID *Protocol,
OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
OUT UINTN *EntryCount);
typedef EFI_STATUS (EFIAPI *EFI_CREATE_EVENT_EX)(
IN UINT32 Type,
IN UINTN NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction,
IN CONST VOID *NotifyContext,
IN EFI_GUID *EventGroup,
OUT EFI_EVENT *Event);
/* Open protocol attributes */
#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
/* Boot services - key function prototypes */
typedef EFI_STATUS (EFIAPI *EFI_ALLOCATE_PAGES)(
IN UINTN Type,
IN UINTN MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
);
typedef EFI_STATUS (EFIAPI *EFI_FREE_PAGES)(
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN Pages
);
typedef EFI_STATUS (EFIAPI *EFI_GET_MEMORY_MAP)(
IN OUT UINTN *MemoryMapSize,
IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
OUT UINTN *MapKey,
OUT UINTN *DescriptorSize,
OUT UINT32 *DescriptorVersion
);
typedef EFI_STATUS (EFIAPI *EFI_ALLOCATE_POOL)(
IN UINTN PoolType,
IN UINTN Size,
OUT VOID **Buffer
);
typedef EFI_STATUS (EFIAPI *EFI_FREE_POOL)(
IN VOID *Buffer
);
typedef EFI_STATUS (EFIAPI *EFI_CREATE_EVENT)(
IN UINT32 Type,
IN UINTN NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction,
IN VOID *NotifyContext,
OUT EFI_EVENT *Event
);
typedef EFI_STATUS (EFIAPI *EFI_SET_TIMER)(
IN EFI_EVENT Event,
IN UINTN Type,
IN UINT64 TriggerTime
);
typedef EFI_STATUS (EFIAPI *EFI_WAIT_FOR_EVENT)(
IN UINTN NumberOfEvents,
IN EFI_EVENT *Event,
OUT UINTN *Index
);
typedef EFI_STATUS (EFIAPI *EFI_SIGNAL_EVENT)(
IN EFI_EVENT Event
);
typedef EFI_STATUS (EFIAPI *EFI_CLOSE_EVENT)(
IN EFI_EVENT Event
);
typedef EFI_STATUS (EFIAPI *EFI_CHECK_EVENT)(
IN EFI_EVENT Event
);
typedef EFI_STATUS (EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE)(
IN OUT EFI_HANDLE *Handle,
IN EFI_GUID *Protocol,
IN UINTN InterfaceType,
IN VOID *Interface
);
typedef EFI_STATUS (EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE)(
IN EFI_HANDLE Handle,
IN EFI_GUID *Protocol,
IN VOID *OldInterface,
IN VOID *NewInterface
);
typedef EFI_STATUS (EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE)(
IN EFI_HANDLE Handle,
IN EFI_GUID *Protocol,
IN VOID *Interface
);
typedef EFI_STATUS (EFIAPI *EFI_HANDLE_PROTOCOL)(
IN EFI_HANDLE Handle,
IN EFI_GUID *Protocol,
OUT VOID **Interface
);
typedef EFI_STATUS (EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY)(
IN EFI_GUID *Protocol,
IN EFI_EVENT Event,
OUT VOID **Registration
);
typedef EFI_STATUS (EFIAPI *EFI_LOCATE_HANDLE)(
IN UINTN SearchType,
IN EFI_GUID *Protocol,
IN VOID *SearchKey,
IN OUT UINTN *BufferSize,
OUT EFI_HANDLE *Buffer
);
/* EFI_LOCATE_DEVICE_PATH already defined above (forward declaration at line 134)
-- removing duplicate */
typedef EFI_STATUS (EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE)(
IN EFI_GUID *Guid,
IN VOID *Table
);
/* EFI_LOAD_IMAGE already defined above (forward declaration at line 138)
-- removing duplicate */
typedef EFI_STATUS (EFIAPI *EFI_START_IMAGE)(
IN EFI_HANDLE ImageHandle,
OUT UINTN *ExitDataSize,
OUT CHAR16 **ExitData
);
typedef EFI_STATUS (EFIAPI *EFI_EXIT)(
IN EFI_HANDLE ImageHandle,
IN EFI_STATUS ExitStatus,
IN UINTN ExitDataSize,
IN CHAR16 *ExitData
);
typedef EFI_STATUS (EFIAPI *EFI_UNLOAD_IMAGE)(
IN EFI_HANDLE ImageHandle
);
typedef EFI_STATUS (EFIAPI *EFI_EXIT_BOOT_SERVICES)(
IN EFI_HANDLE ImageHandle,
IN UINTN MapKey
);
typedef EFI_STATUS (EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT)(
OUT UINT64 *Count
);
typedef EFI_STATUS (EFIAPI *EFI_STALL)(
IN UINTN Microseconds
);
typedef EFI_STATUS (EFIAPI *EFI_SET_WATCHDOG_TIMER)(
IN UINTN Timeout,
IN UINT64 WatchdogCode,
IN UINTN DataSize,
IN CHAR16 *WatchdogData
);
/* EFI_CONNECT_CONTROLLER already defined above (forward declaration at line 145)
-- removing duplicate */
typedef EFI_STATUS (EFIAPI *EFI_DISCONNECT_CONTROLLER)(
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE DriverImageHandle,
IN EFI_HANDLE ChildHandle
);
typedef EFI_STATUS (EFIAPI *EFI_OPEN_PROTOCOL)(
IN EFI_HANDLE Handle,
IN EFI_GUID *Protocol,
OUT VOID **Interface,
IN EFI_HANDLE AgentHandle,
IN EFI_HANDLE ControllerHandle,
IN UINT32 Attributes
);
typedef EFI_STATUS (EFIAPI *EFI_CLOSE_PROTOCOL)(
IN EFI_HANDLE Handle,
IN EFI_GUID *Protocol,
IN EFI_HANDLE AgentHandle,
IN EFI_HANDLE ControllerHandle
);
/* EFI_OPEN_PROTOCOL_INFORMATION already defined above (forward declaration at line 150)
-- removing duplicate */
typedef EFI_STATUS (EFIAPI *EFI_PROTOCOLS_PER_HANDLE)(
IN EFI_HANDLE Handle,
OUT EFI_GUID ***ProtocolBuffer,
OUT UINTN *ProtocolBufferCount
);
typedef EFI_STATUS (EFIAPI *EFI_LOCATE_HANDLE_BUFFER)(
IN UINTN SearchType,
IN EFI_GUID *Protocol,
IN VOID *SearchKey,
IN OUT UINTN *NoHandles,
OUT EFI_HANDLE **Buffer
);
typedef EFI_STATUS (EFIAPI *EFI_LOCATE_PROTOCOL)(
IN EFI_GUID *Protocol,
IN VOID *Registration,
OUT VOID **Interface
);
typedef EFI_STATUS (EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)(
IN OUT EFI_HANDLE *Handle,
...
);
typedef EFI_STATUS (EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)(
IN EFI_HANDLE Handle,
...
);
typedef EFI_STATUS (EFIAPI *EFI_CALCULATE_CRC32)(
IN VOID *Data,
IN UINTN DataSize,
OUT UINT32 *Crc32
);
typedef VOID (EFIAPI *EFI_COPY_MEM)(
IN VOID *Destination,
IN VOID *Source,
IN UINTN Length
);
typedef VOID (EFIAPI *EFI_SET_MEM)(
IN VOID *Buffer,
IN UINTN Size,
IN UINT8 Value
);
/* Device Path protocol */
typedef struct _EFI_DEVICE_PATH_PROTOCOL {
UINT8 Type;
UINT8 SubType;
UINT8 Length[2];
} EFI_DEVICE_PATH_PROTOCOL;
/* Loaded Image protocol */
typedef struct _EFI_LOADED_IMAGE_PROTOCOL {
UINT32 Revision;
EFI_HANDLE ParentHandle;
EFI_SYSTEM_TABLE *SystemTable;
EFI_HANDLE DeviceHandle;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
VOID *Reserved;
UINT32 LoadOptionsSize;
VOID *LoadOptions;
VOID *ImageBase;
UINT64 ImageSize;
EFI_MEMORY_TYPE ImageCodeType;
EFI_MEMORY_TYPE ImageDataType;
EFI_STATUS (EFIAPI *Unload)(IN EFI_HANDLE ImageHandle);
} EFI_LOADED_IMAGE_PROTOCOL;
/* Boot services structure */
struct _EFI_BOOT_SERVICES {
EFI_TABLE_HEADER Hdr;
EFI_RAISE_TPL RaiseTPL;
EFI_RESTORE_TPL RestoreTPL;
EFI_ALLOCATE_PAGES AllocatePages;
EFI_FREE_PAGES FreePages;
EFI_GET_MEMORY_MAP GetMemoryMap;
EFI_ALLOCATE_POOL AllocatePool;
EFI_FREE_POOL FreePool;
EFI_CREATE_EVENT CreateEvent;
EFI_SET_TIMER SetTimer;
EFI_WAIT_FOR_EVENT WaitForEvent;
EFI_SIGNAL_EVENT SignalEvent;
EFI_CLOSE_EVENT CloseEvent;
EFI_CHECK_EVENT CheckEvent;
EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface;
EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
EFI_HANDLE_PROTOCOL HandleProtocol;
EFI_HANDLE_PROTOCOL PCHandleProtocol;
EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;
EFI_LOCATE_HANDLE LocateHandle;
EFI_LOCATE_DEVICE_PATH LocateDevicePath;
EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
EFI_LOAD_IMAGE LoadImage;
EFI_START_IMAGE StartImage;
EFI_EXIT Exit;
EFI_UNLOAD_IMAGE UnloadImage;
EFI_EXIT_BOOT_SERVICES ExitBootServices;
EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
EFI_STALL Stall;
EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
EFI_CONNECT_CONTROLLER ConnectController;
EFI_DISCONNECT_CONTROLLER DisconnectController;
EFI_OPEN_PROTOCOL OpenProtocol;
EFI_CLOSE_PROTOCOL CloseProtocol;
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation;
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle;
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer;
EFI_LOCATE_PROTOCOL LocateProtocol;
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
EFI_CALCULATE_CRC32 CalculateCrc32;
EFI_COPY_MEM CopyMem;
EFI_SET_MEM SetMem;
EFI_CREATE_EVENT_EX CreateEventEx;
};
/* Configuration table entry */
typedef struct {
EFI_GUID VendorGuid;
VOID *Table;
} EFI_CONFIGURATION_TABLE;
/* System table */
struct _EFI_SYSTEM_TABLE {
EFI_TABLE_HEADER Hdr;
CHAR16 *FirmwareVendor;
UINT32 FirmwareRevision;
EFI_HANDLE ConsoleInHandle;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
EFI_HANDLE ConsoleOutHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
EFI_HANDLE StandardErrorHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *StdErr;
EFI_RUNTIME_SERVICES *RuntimeServices;
EFI_BOOT_SERVICES *BootServices;
UINTN NumberOfTableEntries;
EFI_CONFIGURATION_TABLE *ConfigurationTable;
};
/* Driver entry point signature */
typedef EFI_STATUS (EFIAPI *EFI_DRIVER_ENTRY_POINT)(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
/* IN/OUT/OPTIONAL macros */
#ifndef IN
#define IN
#endif
#ifndef OUT
#define OUT
#endif
#ifndef OPTIONAL
#define OPTIONAL
#endif
/* CONST macro */
#ifndef CONST
#define CONST const
#endif
/* BOOLEAN truth values */
#ifndef TRUE
#define TRUE ((BOOLEAN)1)
#endif
#ifndef FALSE
#define FALSE ((BOOLEAN)0)
#endif
/* EFIAPI calling convention */
#ifndef EFIAPI
#define EFIAPI __attribute__((ms_abi))
#endif
#endif /* __UEFI_H__ */