[efi] Update to current EDK2 headers

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/968/head
Michael Brown 2023-06-07 12:24:42 +01:00
parent 9cb0a4b8ec
commit 3184ff74eb
8 changed files with 265 additions and 39 deletions

View File

@ -188,6 +188,40 @@ typedef INT64 INTN;
#define GCC_ASM_IMPORT(func__) \
.extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
#if defined (__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
#define AARCH64_BTI_NOTE() \
.ifndef .Lgnu_bti_notesize ;\
.pushsection .note.gnu.property, "a" ;\
.set NT_GNU_PROPERTY_TYPE_0, 0x5 ;\
.set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 ;\
.set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, 0x1 ;\
.align 3 ;\
.long .Lnamesize ;\
.long .Lgnu_bti_notesize ;\
.long NT_GNU_PROPERTY_TYPE_0 ;\
0: .asciz "GNU" ;\
.set .Lnamesize, . - 0b ;\
.align 3 ;\
1: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND ;\
.long .Lvalsize ;\
2: .long GNU_PROPERTY_AARCH64_FEATURE_1_BTI ;\
.set .Lvalsize, . - 2b ;\
.align 3 ;\
.set .Lgnu_bti_notesize, . - 1b ;\
.popsection ;\
.endif
#define AARCH64_BTI(__type) \
AARCH64_BTI_NOTE() ;\
bti __type
#endif
#endif
#ifndef AARCH64_BTI
#define AARCH64_BTI_NOTE()
#define AARCH64_BTI(__type)
#endif
/**

View File

@ -760,6 +760,40 @@ typedef UINTN *BASE_LIST;
#define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
#endif
/**
Returns the alignment requirement of a type.
@param TYPE The name of the type to retrieve the alignment requirement of.
@return Alignment requirement, in Bytes, of TYPE.
**/
#if defined (__cplusplus)
//
// Standard C++ operator.
//
#define ALIGNOF(TYPE) alignof (TYPE)
#elif defined (__GNUC__) || defined (__clang__) || (defined (_MSC_VER) && _MSC_VER >= 1900)
//
// All supported versions of GCC and Clang, as well as MSVC 2015 and later,
// support the standard operator _Alignof.
//
#define ALIGNOF(TYPE) _Alignof (TYPE)
#elif defined (_MSC_EXTENSIONS)
//
// Earlier versions of MSVC, at least MSVC 2008 and later, support the vendor
// extension __alignof.
//
#define ALIGNOF(TYPE) __alignof (TYPE)
#else
//
// For compilers that do not support inbuilt alignof operators, use OFFSET_OF.
// CHAR8 is known to have both a size and an alignment requirement of 1 Byte.
// As such, A must be located exactly at the offset equal to its alignment
// requirement.
//
#define ALIGNOF(TYPE) OFFSET_OF (struct { CHAR8 C; TYPE A; }, A)
#endif
/**
Portable definition for compile time assertions.
Equivalent to C11 static_assert macro from assert.h.
@ -795,12 +829,27 @@ STATIC_ASSERT (sizeof (CHAR16) == 2, "sizeof (CHAR16) does not meet UEFI Specif
STATIC_ASSERT (sizeof (L'A') == 2, "sizeof (L'A') does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (sizeof (L"A") == 4, "sizeof (L\"A\") does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (BOOLEAN) == sizeof (BOOLEAN), "Alignment of BOOLEAN does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (INT8) == sizeof (INT8), "Alignment of INT8 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (UINT8) == sizeof (UINT8), "Alignment of INT16 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (INT16) == sizeof (INT16), "Alignment of INT16 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (UINT16) == sizeof (UINT16), "Alignment of UINT16 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (INT32) == sizeof (INT32), "Alignment of INT32 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (UINT32) == sizeof (UINT32), "Alignment of UINT32 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (INT64) == sizeof (INT64), "Alignment of INT64 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (UINT64) == sizeof (UINT64), "Alignment of UINT64 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (CHAR8) == sizeof (CHAR8), "Alignment of CHAR8 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (CHAR16) == sizeof (CHAR16), "Alignment of CHAR16 does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (INTN) == sizeof (INTN), "Alignment of INTN does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (UINTN) == sizeof (UINTN), "Alignment of UINTN does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (VOID *) == sizeof (VOID *), "Alignment of VOID * does not meet UEFI Specification Data Type requirements");
//
// The following three enum types are used to verify that the compiler
// configuration for enum types is compliant with Section 2.3.1 of the
// UEFI 2.3 Specification. These enum types and enum values are not
// intended to be used. A prefix of '__' is used avoid conflicts with
// other types.
// UEFI 2.3.1 Errata C Specification. These enum types and enum values
// are not intended to be used. A prefix of '__' is used avoid
// conflicts with other types.
//
typedef enum {
__VerifyUint8EnumValue = 0xff
@ -811,12 +860,16 @@ typedef enum {
} __VERIFY_UINT16_ENUM_SIZE;
typedef enum {
__VerifyUint32EnumValue = 0xffffffff
} __VERIFY_UINT32_ENUM_SIZE;
__VerifyInt32EnumValue = 0x7fffffff
} __VERIFY_INT32_ENUM_SIZE;
STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (__VERIFY_UINT8_ENUM_SIZE) == sizeof (__VERIFY_UINT8_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (__VERIFY_UINT16_ENUM_SIZE) == sizeof (__VERIFY_UINT16_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
STATIC_ASSERT (ALIGNOF (__VERIFY_INT32_ENUM_SIZE) == sizeof (__VERIFY_INT32_ENUM_SIZE), "Alignment of enum does not meet UEFI Specification Data Type requirements");
/**
Macro that returns a pointer to the data structure that contains a specified field of
@ -839,6 +892,49 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not m
**/
#define BASE_CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - OFFSET_OF (TYPE, Field)))
/**
Checks whether a value is a power of two.
@param Value The value to check.
@retval TRUE Value is a power of two.
@retval FALSE Value is not a power of two.
**/
#define IS_POW2(Value) ((Value) != 0U && ((Value) & ((Value) - 1U)) == 0U)
/**
Checks whether a value is aligned by a specified alignment.
@param Value The value to check.
@param Alignment The alignment boundary used to check against.
@retval TRUE Value is aligned by Alignment.
@retval FALSE Value is not aligned by Alignment.
**/
#define IS_ALIGNED(Value, Alignment) (((Value) & ((Alignment) - 1U)) == 0U)
/**
Checks whether a pointer or address is aligned by a specified alignment.
@param Address The pointer or address to check.
@param Alignment The alignment boundary used to check against.
@retval TRUE Address is aligned by Alignment.
@retval FALSE Address is not aligned by Alignment.
**/
#define ADDRESS_IS_ALIGNED(Address, Alignment) IS_ALIGNED ((UINTN) (Address), Alignment)
/**
Determines the addend to add to a value to round it up to the next boundary of
a specified alignment.
@param Value The value to round up.
@param Alignment The alignment boundary used to return the addend.
@return Addend to round Value up to alignment boundary Alignment.
**/
#define ALIGN_VALUE_ADDEND(Value, Alignment) (((Alignment) - (Value)) & ((Alignment) - 1U))
/**
Rounds a value up to the next boundary using a specified alignment.
@ -851,7 +947,7 @@ STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not m
@return A value up to the next boundary.
**/
#define ALIGN_VALUE(Value, Alignment) ((Value) + (((Alignment) - (Value)) & ((Alignment) - 1)))
#define ALIGN_VALUE(Value, Alignment) ((Value) + ALIGN_VALUE_ADDEND (Value, Alignment))
/**
Adjust a pointer by adding the minimum offset required for it to be aligned on

View File

@ -90,19 +90,15 @@ FILE_LICENCE ( BSD2_PATENT );
#if defined (_MSC_VER) && _MSC_VER >= 1800
//
// Disable these warnings for VS2013.
//
//
// This warning is for potentially uninitialized local variable, and it may cause false
// positive issues in VS2013 and VS2015 build
// positive issues in VS2015 build
//
#pragma warning ( disable : 4701 )
//
// This warning is for potentially uninitialized local pointer variable, and it may cause
// false positive issues in VS2013 and VS2015 build
// false positive issues in VS2015 build
//
#pragma warning ( disable : 4703 )

View File

@ -103,6 +103,7 @@ typedef struct {
#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE BIT1 ///< 0x0002 File is executable (i.e. no unresolved externel references).
#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED BIT2 ///< 0x0004 Line numbers stripped from file.
#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED BIT3 ///< 0x0008 Local symbols stripped from file.
#define EFI_IMAGE_FILE_LARGE_ADDRESS_AWARE BIT5 ///< 0x0020 Supports addresses > 2-GB
#define EFI_IMAGE_FILE_BYTES_REVERSED_LO BIT7 ///< 0x0080 Bytes of machine word are reversed.
#define EFI_IMAGE_FILE_32BIT_MACHINE BIT8 ///< 0x0100 32 bit word machine.
#define EFI_IMAGE_FILE_DEBUG_STRIPPED BIT9 ///< 0x0200 Debugging info stripped from file in .DBG file.
@ -579,6 +580,13 @@ typedef struct {
UINT32 AddressOfNameOrdinals;
} EFI_IMAGE_EXPORT_DIRECTORY;
//
// Based export types.
//
#define EFI_IMAGE_EXPORT_ORDINAL_BASE 1
#define EFI_IMAGE_EXPORT_ADDR_SIZE 4
#define EFI_IMAGE_EXPORT_ORDINAL_SIZE 2
///
/// Hint/Name Table.
///
@ -627,7 +635,8 @@ typedef struct {
UINT32 FileOffset; ///< The file pointer to the debug data.
} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;
#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information.
#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information.
#define EFI_IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS 20
///
/// Debug Data Structure defined in Microsoft C++.
@ -671,6 +680,39 @@ typedef struct {
//
} EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY;
// avoid conflict with windows header files
#ifndef RUNTIME_FUNCTION_INDIRECT
//
// .pdata entries for X64
//
typedef struct {
UINT32 FunctionStartAddress;
UINT32 FunctionEndAddress;
UINT32 UnwindInfoAddress;
} RUNTIME_FUNCTION;
#endif
typedef struct {
UINT8 Version : 3;
UINT8 Flags : 5;
UINT8 SizeOfProlog;
UINT8 CountOfUnwindCodes;
UINT8 FrameRegister : 4;
UINT8 FrameRegisterOffset : 4;
} UNWIND_INFO;
///
/// Extended DLL Characteristics
///
#define EFI_IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT 0x0001
#define EFI_IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT 0x0040
typedef struct {
UINT32 DllCharacteristicsEx;
} EFI_IMAGE_DEBUG_EX_DLLCHARACTERISTICS_ENTRY;
///
/// Resource format.
///

View File

@ -153,6 +153,56 @@ typedef struct {
#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
VOID
RiscVSetSupervisorScratch (
IN UINT64
);
UINT64
RiscVGetSupervisorScratch (
VOID
);
VOID
RiscVSetSupervisorStvec (
IN UINT64
);
UINT64
RiscVGetSupervisorStvec (
VOID
);
UINT64
RiscVGetSupervisorTrapCause (
VOID
);
VOID
RiscVSetSupervisorAddressTranslationRegister (
IN UINT64
);
UINT64
RiscVReadTimer (
VOID
);
VOID
RiscVEnableTimerInterrupt (
VOID
);
VOID
RiscVDisableTimerInterrupt (
VOID
);
VOID
RiscVClearPendingTimerInterrupt (
VOID
);
#endif // defined (MDE_CPU_RISCV64)
#if defined (MDE_CPU_LOONGARCH64)

View File

@ -615,11 +615,34 @@ typedef struct {
#define EXCEPT_RISCV_STORE_AMO_ACCESS_FAULT 7
#define EXCEPT_RISCV_ENV_CALL_FROM_UMODE 8
#define EXCEPT_RISCV_ENV_CALL_FROM_SMODE 9
#define EXCEPT_RISCV_ENV_CALL_FROM_HMODE 10
#define EXCEPT_RISCV_ENV_CALL_FROM_VS_MODE 10
#define EXCEPT_RISCV_ENV_CALL_FROM_MMODE 11
#define EXCEPT_RISCV_INST_ACCESS_PAGE_FAULT 12
#define EXCEPT_RISCV_LOAD_ACCESS_PAGE_FAULT 13
#define EXCEPT_RISCV_14 14
#define EXCEPT_RISCV_STORE_ACCESS_PAGE_FAULT 15
#define EXCEPT_RISCV_16 16
#define EXCEPT_RISCV_17 17
#define EXCEPT_RISCV_18 18
#define EXCEPT_RISCV_19 19
#define EXCEPT_RISCV_INST_GUEST_PAGE_FAULT 20
#define EXCEPT_RISCV_LOAD_GUEST_PAGE_FAULT 21
#define EXCEPT_RISCV_VIRTUAL_INSTRUCTION 22
#define EXCEPT_RISCV_STORE_GUEST_PAGE_FAULT 23
#define EXCEPT_RISCV_MAX_EXCEPTIONS (EXCEPT_RISCV_STORE_GUEST_PAGE_FAULT)
#define EXCEPT_RISCV_SOFTWARE_INT 0x0
#define EXCEPT_RISCV_TIMER_INT 0x1
///
/// RISC-V processor exception types for interrupts.
///
#define EXCEPT_RISCV_IS_IRQ(x) ((x & 0x8000000000000000UL) != 0)
#define EXCEPT_RISCV_IRQ_INDEX(x) (x & 0x7FFFFFFFFFFFFFFFUL)
#define EXCEPT_RISCV_IRQ_0 0x8000000000000000UL
#define EXCEPT_RISCV_IRQ_SOFT_FROM_SMODE 0x8000000000000001UL
#define EXCEPT_RISCV_IRQ_SOFT_FROM_VSMODE 0x8000000000000002UL
#define EXCEPT_RISCV_IRQ_SOFT_FROM_MMODE 0x8000000000000003UL
#define EXCEPT_RISCV_IRQ_4 0x8000000000000004UL
#define EXCEPT_RISCV_IRQ_TIMER_FROM_SMODE 0x8000000000000005UL
#define EXCEPT_RISCV_MAX_IRQS (EXCEPT_RISCV_IRQ_INDEX(EXCEPT_RISCV_IRQ_TIMER_FROM_SMODE))
typedef struct {
UINT64 X0;
@ -654,6 +677,9 @@ typedef struct {
UINT64 X29;
UINT64 X30;
UINT64 X31;
UINT64 SEPC;
UINT32 SSTATUS;
UINT32 STVAL;
} EFI_SYSTEM_CONTEXT_RISCV64;
//

View File

@ -467,8 +467,8 @@ EFI_STATUS
(EFIAPI *EFI_CREATE_EVENT)(
IN UINT32 Type,
IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction,
IN VOID *NotifyContext,
IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
IN VOID *NotifyContext OPTIONAL,
OUT EFI_EVENT *Event
);

View File

@ -23,20 +23,6 @@ FILE_LICENCE ( BSD2_PATENT );
#pragma pack()
#endif
#if defined (__GNUC__) && defined (__pic__) && !defined (USING_LTO) && !defined (__APPLE__)
//
// Mark all symbol declarations and references as hidden, meaning they will
// not be subject to symbol preemption. This allows the compiler to refer to
// symbols directly using relative references rather than via the GOT, which
// contains absolute symbol addresses that are subject to runtime relocation.
//
// The LTO linker will not emit GOT based relocations when all symbol
// references can be resolved locally, and so there is no need to set the
// pragma in that case (and doing so will cause other issues).
//
#pragma GCC visibility push (hidden)
#endif
#if defined (__INTEL_COMPILER)
//
// Disable ICC's remark #869: "Parameter" was never referenced warning.
@ -104,19 +90,15 @@ FILE_LICENCE ( BSD2_PATENT );
#if defined (_MSC_VER) && _MSC_VER >= 1800
//
// Disable these warnings for VS2013.
//
//
// This warning is for potentially uninitialized local variable, and it may cause false
// positive issues in VS2013 and VS2015 build
// positive issues in VS2015 build
//
#pragma warning ( disable : 4701 )
//
// This warning is for potentially uninitialized local pointer variable, and it may cause
// false positive issues in VS2013 and VS2015 build
// false positive issues in VS2015 build
//
#pragma warning ( disable : 4703 )