1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2016 Toomas Soome <tsoome@me.com> 14 */ 15 16 #ifndef _SYS_EFI_H 17 #define _SYS_EFI_H 18 19 /* 20 * UEFI related data. Based on UEFI 2.5 specs. 21 */ 22 #include <sys/uuid.h> 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /* EFI GUIDS */ 29 30 #define EFI_GLOBAL_VARIABLE \ 31 { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \ 32 { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } } 33 34 #define MPS_TABLE_GUID \ 35 { 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, \ 36 { 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } 37 38 #define ACPI_10_TABLE_GUID \ 39 { 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, \ 40 { 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } 41 42 #define EFI_ACPI_TABLE_GUID \ 43 { 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, \ 44 { 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } 45 46 #define SMBIOS_TABLE_GUID \ 47 { 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, \ 48 { 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } 49 50 #define SAL_SYSTEM_TABLE_GUID \ 51 { 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, \ 52 { 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } 53 54 #define SMBIOS3_TABLE_GUID \ 55 { 0xf2fd1544, 0x9794, 0x4a2c, 0x99, 0x2e, \ 56 { 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 } } 57 58 #define FDT_TABLE_GUID \ 59 { 0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, \ 60 { 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } } 61 62 #define DXE_SERVICES_TABLE_GUID \ 63 { 0x5ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, \ 64 { 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } } 65 66 #define HOB_LIST_TABLE_GUID \ 67 { 0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a, \ 68 { 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } 69 70 #define MEMORY_TYPE_INFORMATION_TABLE_GUID \ 71 { 0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, \ 72 { 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } } 73 74 #define DEBUG_IMAGE_INFO_TABLE_GUID \ 75 { 0x49152e77, 0x1ada, 0x4764, 0xb7, 0xa2, \ 76 { 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } } 77 78 #define EFI_PROPERTIES_TABLE_GUID \ 79 { 0x880aaca3, 0x4adc, 0x4a04, 0x90, 0x79, \ 80 { 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5 } } 81 82 typedef struct uuid efi_guid_t __aligned(8); 83 84 /* Memory data */ 85 typedef uint64_t EFI_PHYSICAL_ADDRESS; 86 typedef uint64_t EFI_VIRTUAL_ADDRESS; 87 88 /* 89 * EFI_MEMORY_TYPE enum is defined in UEFI Specification, Version 2.9 page 167. 90 */ 91 typedef enum { 92 EfiReservedMemoryType, 93 EfiLoaderCode, 94 EfiLoaderData, 95 EfiBootServicesCode, 96 EfiBootServicesData, 97 EfiRuntimeServicesCode, 98 EfiRuntimeServicesData, 99 EfiConventionalMemory, 100 EfiUnusableMemory, 101 EfiACPIReclaimMemory, 102 EfiACPIMemoryNVS, 103 EfiMemoryMappedIO, 104 EfiMemoryMappedIOPortSpace, 105 EfiPalCode, 106 EfiPersistentMemory, 107 EfiUnacceptedMemoryType, 108 EfiMaxMemoryType 109 } EFI_MEMORY_TYPE; 110 111 /* Possible caching types for the memory range */ 112 #define EFI_MEMORY_UC 0x0000000000000001 113 #define EFI_MEMORY_WC 0x0000000000000002 114 #define EFI_MEMORY_WT 0x0000000000000004 115 #define EFI_MEMORY_WB 0x0000000000000008 116 #define EFI_MEMORY_UCE 0x0000000000000010 117 118 /* Physical memory protection on range */ 119 #define EFI_MEMORY_WP 0x0000000000001000 120 #define EFI_MEMORY_RP 0x0000000000002000 121 #define EFI_MEMORY_XP 0x0000000000004000 122 #define EFI_MEMORY_NV 0x0000000000008000 123 #define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000 124 #define EFI_MEMORY_RO 0x0000000000020000 125 126 /* Range requires a runtime mapping */ 127 #define EFI_MEMORY_RUNTIME 0x8000000000000000 128 129 #define EFI_MEMORY_DESCRIPTOR_VERSION 1 130 typedef struct { 131 uint32_t Type; 132 uint32_t Pad; 133 EFI_PHYSICAL_ADDRESS PhysicalStart; 134 EFI_VIRTUAL_ADDRESS VirtualStart; 135 uint64_t NumberOfPages; 136 uint64_t Attribute; 137 } __packed EFI_MEMORY_DESCRIPTOR; 138 139 /* Tables */ 140 141 typedef struct { 142 uint64_t Signature; 143 uint32_t Revision; 144 uint32_t HeaderSize; 145 uint32_t CRC32; 146 uint32_t Reserved; 147 } EFI_TABLE_HEADER; 148 149 /* 150 * The upper 16 bits of the revision contain the major revision value, 151 * and the lower 16 bits contain the minor revision value. The minor revision 152 * values are binary coded decimals and are limited to the range of 00..99. 153 * If the lower digit of the minor revision is 0, the version is printed as: 154 * major.minor upper decimal 155 * Otherwise the version is printed as: 156 * major.minor upper decimal.minor lower decimal 157 */ 158 #define EFI_REV(x, y) (((x) << 16) || (y)) 159 #define EFI_REV_MAJOR(x) (((x) >> 16) & 0xffff) 160 #define EFI_REV_MINOR(x) ((x) & 0xffff) 161 #define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249 162 163 typedef uint32_t efiptr32_t; 164 typedef uint64_t efiptr64_t; 165 166 typedef struct _EFI_CONFIGURATION_TABLE32 { 167 efi_guid_t VendorGuid; 168 efiptr32_t VendorTable; 169 } __packed EFI_CONFIGURATION_TABLE32; 170 171 typedef struct _EFI_CONFIGURATION_TABLE64 { 172 efi_guid_t VendorGuid; 173 efiptr64_t VendorTable; 174 } __packed EFI_CONFIGURATION_TABLE64; 175 176 typedef struct _EFI_SYSTEM_TABLE32 { 177 EFI_TABLE_HEADER Hdr; 178 179 efiptr32_t FirmwareVendor; 180 uint32_t FirmwareRevision; 181 182 efiptr32_t ConsoleInHandle; 183 efiptr32_t ConIn; 184 185 efiptr32_t ConsoleOutHandle; 186 efiptr32_t ConOut; 187 188 efiptr32_t StandardErrorHandle; 189 efiptr32_t StdErr; 190 191 efiptr32_t RuntimeServices; 192 efiptr32_t BootServices; 193 194 uint32_t NumberOfTableEntries; 195 efiptr32_t ConfigurationTable; 196 } __packed EFI_SYSTEM_TABLE32; 197 198 typedef struct _EFI_SYSTEM_TABLE64 { 199 EFI_TABLE_HEADER Hdr; 200 201 efiptr64_t FirmwareVendor; 202 uint32_t FirmwareRevision; 203 uint32_t Pad; 204 205 efiptr64_t ConsoleInHandle; 206 efiptr64_t ConIn; 207 208 efiptr64_t ConsoleOutHandle; 209 efiptr64_t ConOut; 210 211 efiptr64_t StandardErrorHandle; 212 efiptr64_t StdErr; 213 214 efiptr64_t RuntimeServices; 215 efiptr64_t BootServices; 216 217 uint64_t NumberOfTableEntries; 218 efiptr64_t ConfigurationTable; 219 } __packed EFI_SYSTEM_TABLE64; 220 221 #ifdef __cplusplus 222 } 223 #endif 224 225 #endif /* _SYS_EFI_H */ 226