1 /* 2 * Copyright (c) 2017-2025 Netflix, Inc. 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7 #ifndef _SYS_EFI_EDK2_H_ 8 #define _SYS_EFI_EDK2_H_ 9 10 /* 11 * Defines to adjust the types that EDK2 uses for FreeBSD so we can 12 * use the code and headers mostly unchanged. The headers are imported 13 * all into one directory to avoid case issues with filenames and 14 * included. The actual code is heavily modified since it has too many 15 * annoying dependencies that are difficult to satisfy. 16 */ 17 18 #include <stdlib.h> 19 #include <stdint.h> 20 21 typedef int8_t INT8; 22 typedef int16_t INT16; 23 typedef int32_t INT32; 24 typedef int64_t INT64; 25 typedef intptr_t INTN; 26 typedef uint8_t UINT8; 27 typedef uint16_t UINT16; 28 typedef uint32_t UINT32; 29 typedef uint64_t UINT64; 30 typedef uintptr_t UINTN; 31 //typedef uintptr_t EFI_PHYSICAL_ADDRESS; 32 //typedef uint32_t EFI_IPv4_ADDRESS; 33 //typedef uint8_t EFI_MAC_ADDRESS[6]; 34 //typedef uint8_t EFI_IPv6_ADDRESS[16]; 35 typedef uint8_t CHAR8; 36 typedef uint16_t CHAR16; 37 typedef UINT8 BOOLEAN; 38 typedef void VOID; 39 //typedef uuid_t GUID; 40 //typedef uuid_t EFI_GUID; 41 42 /* We can't actually call this stuff, so snip out API syntactic sugar */ 43 #define INTERFACE_DECL(x) struct x 44 #define EFIAPI 45 #define IN 46 #define OUT 47 #define CONST const 48 #define OPTIONAL 49 //#define TRUE 1 50 //#define FALSE 0 51 52 /* 53 * EDK2 has fine definitions for these, so let it define them. 54 */ 55 #undef NULL 56 #undef EFI_PAGE_SIZE 57 #undef EFI_PAGE_MASK 58 59 /* 60 * Note: the EDK2 code assumed #pragma packed works and PACKED is a 61 * workaround for some old toolchain issues for EDK2 that aren't 62 * relevent to FreeBSD. 63 */ 64 #define PACKED 65 66 /* 67 * Since we're not compiling for the UEFI boot time (which use ms abi 68 * conventions), tell EDK2 to define VA_START correctly. For the boot 69 * loader, this likely needs to be different. 70 */ 71 #define NO_MSABI_VA_FUNCS 1 72 73 /* 74 * Finally, we need to define the processor we are in EDK2 terms. 75 */ 76 #if defined(__i386__) 77 #define MDE_CPU_IA32 78 #elif defined(__amd64__) 79 #define MDE_CPU_X64 80 #elif defined(__arm__) 81 #define MDE_CPU_ARM 82 #elif defined(__aarch64__) 83 #define MDE_CPU_AARCH64 84 #elif defined(__riscv) 85 #define MDE_CPU_RISCV64 86 #endif 87 /* FreeBSD doesn't have/use MDE_CPU_EBC or MDE_CPU_IPF (ia64) */ 88 89 #if __SIZEOF_LONG__ == 4 90 #define MAX_BIT 0x80000000 91 #else 92 #define MAX_BIT 0x8000000000000000 93 #endif 94 95 /* 96 * Sometimes EFI is included after sys/param.h, and that causes a collision. We 97 * get a collision the other way too, so when including both, you have to 98 * include sys/param.h first. 99 */ 100 #undef MAX 101 #undef MIN 102 103 #endif /* _SYS_EFI_EDK2_H_ */ 104