Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Extensible Firmware Interface |
| 3 | * Based on 'Extensible Firmware Interface Specification' version 0.9, |
| 4 | * April 30, 1999 |
| 5 | * |
| 6 | * Copyright (C) 1999 VA Linux Systems |
| 7 | * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> |
| 8 | * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co. |
| 9 | * David Mosberger-Tang <davidm@hpl.hp.com> |
| 10 | * Stephane Eranian <eranian@hpl.hp.com> |
| 11 | * |
| 12 | * From include/linux/efi.h in kernel 4.1 with some additions/subtractions |
| 13 | */ |
| 14 | |
| 15 | #ifndef _EFI_H |
| 16 | #define _EFI_H |
| 17 | |
Simon Glass | cc02256 | 2016-09-25 15:27:31 -0600 | [diff] [blame] | 18 | #include <linux/linkage.h> |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 19 | #include <linux/string.h> |
| 20 | #include <linux/types.h> |
| 21 | |
Alexander Graf | ff592b2 | 2018-06-22 01:38:26 -0700 | [diff] [blame] | 22 | /* |
| 23 | * EFI on x86_64 uses the Microsoft ABI which is not the default for GCC. |
| 24 | * |
| 25 | * There are two scenarios for EFI on x86_64: building a 64-bit EFI stub |
| 26 | * codes (CONFIG_EFI_STUB_64BIT) and building a 64-bit U-Boot (CONFIG_X86_64). |
| 27 | * Either needs to be properly built with the '-m64' compiler flag, and hence |
| 28 | * it is enough to only check the compiler provided define __x86_64__ here. |
| 29 | */ |
| 30 | #ifdef __x86_64__ |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 31 | #define EFIAPI __attribute__((ms_abi)) |
Alexander Graf | 404a7c8 | 2018-06-18 17:23:05 +0200 | [diff] [blame] | 32 | #define efi_va_list __builtin_ms_va_list |
| 33 | #define efi_va_start __builtin_ms_va_start |
| 34 | #define efi_va_arg __builtin_va_arg |
| 35 | #define efi_va_end __builtin_ms_va_end |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 36 | #else |
Simon Glass | cc02256 | 2016-09-25 15:27:31 -0600 | [diff] [blame] | 37 | #define EFIAPI asmlinkage |
Alexander Graf | 404a7c8 | 2018-06-18 17:23:05 +0200 | [diff] [blame] | 38 | #define efi_va_list va_list |
| 39 | #define efi_va_start va_start |
| 40 | #define efi_va_arg va_arg |
| 41 | #define efi_va_end va_end |
Alexander Graf | ff592b2 | 2018-06-22 01:38:26 -0700 | [diff] [blame] | 42 | #endif /* __x86_64__ */ |
Simon Glass | ce62a25 | 2015-08-04 12:33:56 -0600 | [diff] [blame] | 43 | |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 44 | struct efi_device_path; |
| 45 | |
Rob Clark | 224ee84 | 2017-09-13 18:05:24 -0400 | [diff] [blame] | 46 | typedef struct { |
| 47 | u8 b[16]; |
| 48 | } efi_guid_t; |
| 49 | |
Alexander Graf | ff592b2 | 2018-06-22 01:38:26 -0700 | [diff] [blame] | 50 | #define EFI_BITS_PER_LONG (sizeof(long) * 8) |
Bin Meng | e20a69c | 2016-08-25 01:47:18 -0700 | [diff] [blame] | 51 | |
xypron.glpk@gmx.de | b343d93 | 2017-07-04 23:15:22 +0200 | [diff] [blame] | 52 | /* Bit mask for EFI status code with error */ |
| 53 | #define EFI_ERROR_MASK (1UL << (EFI_BITS_PER_LONG - 1)) |
| 54 | /* Status codes returned by EFI protocols */ |
| 55 | #define EFI_SUCCESS 0 |
| 56 | #define EFI_LOAD_ERROR (EFI_ERROR_MASK | 1) |
| 57 | #define EFI_INVALID_PARAMETER (EFI_ERROR_MASK | 2) |
| 58 | #define EFI_UNSUPPORTED (EFI_ERROR_MASK | 3) |
| 59 | #define EFI_BAD_BUFFER_SIZE (EFI_ERROR_MASK | 4) |
| 60 | #define EFI_BUFFER_TOO_SMALL (EFI_ERROR_MASK | 5) |
| 61 | #define EFI_NOT_READY (EFI_ERROR_MASK | 6) |
| 62 | #define EFI_DEVICE_ERROR (EFI_ERROR_MASK | 7) |
| 63 | #define EFI_WRITE_PROTECTED (EFI_ERROR_MASK | 8) |
| 64 | #define EFI_OUT_OF_RESOURCES (EFI_ERROR_MASK | 9) |
| 65 | #define EFI_VOLUME_CORRUPTED (EFI_ERROR_MASK | 10) |
| 66 | #define EFI_VOLUME_FULL (EFI_ERROR_MASK | 11) |
| 67 | #define EFI_NO_MEDIA (EFI_ERROR_MASK | 12) |
| 68 | #define EFI_MEDIA_CHANGED (EFI_ERROR_MASK | 13) |
| 69 | #define EFI_NOT_FOUND (EFI_ERROR_MASK | 14) |
| 70 | #define EFI_ACCESS_DENIED (EFI_ERROR_MASK | 15) |
| 71 | #define EFI_NO_RESPONSE (EFI_ERROR_MASK | 16) |
| 72 | #define EFI_NO_MAPPING (EFI_ERROR_MASK | 17) |
| 73 | #define EFI_TIMEOUT (EFI_ERROR_MASK | 18) |
| 74 | #define EFI_NOT_STARTED (EFI_ERROR_MASK | 19) |
| 75 | #define EFI_ALREADY_STARTED (EFI_ERROR_MASK | 20) |
| 76 | #define EFI_ABORTED (EFI_ERROR_MASK | 21) |
| 77 | #define EFI_ICMP_ERROR (EFI_ERROR_MASK | 22) |
| 78 | #define EFI_TFTP_ERROR (EFI_ERROR_MASK | 23) |
| 79 | #define EFI_PROTOCOL_ERROR (EFI_ERROR_MASK | 24) |
| 80 | #define EFI_INCOMPATIBLE_VERSION (EFI_ERROR_MASK | 25) |
| 81 | #define EFI_SECURITY_VIOLATION (EFI_ERROR_MASK | 26) |
| 82 | #define EFI_CRC_ERROR (EFI_ERROR_MASK | 27) |
| 83 | #define EFI_END_OF_MEDIA (EFI_ERROR_MASK | 28) |
| 84 | #define EFI_END_OF_FILE (EFI_ERROR_MASK | 31) |
| 85 | #define EFI_INVALID_LANGUAGE (EFI_ERROR_MASK | 32) |
| 86 | #define EFI_COMPROMISED_DATA (EFI_ERROR_MASK | 33) |
| 87 | #define EFI_IP_ADDRESS_CONFLICT (EFI_ERROR_MASK | 34) |
| 88 | #define EFI_HTTP_ERROR (EFI_ERROR_MASK | 35) |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 89 | |
Rob Clark | 5314203 | 2017-09-13 18:05:34 -0400 | [diff] [blame] | 90 | #define EFI_WARN_DELETE_FAILURE 2 |
| 91 | |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 92 | typedef unsigned long efi_status_t; |
| 93 | typedef u64 efi_physical_addr_t; |
| 94 | typedef u64 efi_virtual_addr_t; |
| 95 | typedef void *efi_handle_t; |
| 96 | |
| 97 | #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 98 | {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \ |
| 99 | ((a) >> 24) & 0xff, \ |
| 100 | (b) & 0xff, ((b) >> 8) & 0xff, \ |
| 101 | (c) & 0xff, ((c) >> 8) & 0xff, \ |
Heinrich Schuchardt | fac7867 | 2018-06-09 17:50:18 +0200 | [diff] [blame] | 102 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } } |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 103 | |
| 104 | /* Generic EFI table header */ |
| 105 | struct efi_table_hdr { |
| 106 | u64 signature; |
| 107 | u32 revision; |
| 108 | u32 headersize; |
| 109 | u32 crc32; |
| 110 | u32 reserved; |
| 111 | }; |
| 112 | |
| 113 | /* Enumeration of memory types introduced in UEFI */ |
| 114 | enum efi_mem_type { |
| 115 | EFI_RESERVED_MEMORY_TYPE, |
| 116 | /* |
| 117 | * The code portions of a loaded application. |
| 118 | * (Note that UEFI OS loaders are UEFI applications.) |
| 119 | */ |
| 120 | EFI_LOADER_CODE, |
| 121 | /* |
| 122 | * The data portions of a loaded application and |
| 123 | * the default data allocation type used by an application |
| 124 | * to allocate pool memory. |
| 125 | */ |
| 126 | EFI_LOADER_DATA, |
| 127 | /* The code portions of a loaded Boot Services Driver */ |
| 128 | EFI_BOOT_SERVICES_CODE, |
| 129 | /* |
Heinrich Schuchardt | 514b91f | 2017-09-18 07:54:50 +0200 | [diff] [blame] | 130 | * The data portions of a loaded Boot Services Driver and |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 131 | * the default data allocation type used by a Boot Services |
| 132 | * Driver to allocate pool memory. |
| 133 | */ |
| 134 | EFI_BOOT_SERVICES_DATA, |
| 135 | /* The code portions of a loaded Runtime Services Driver */ |
| 136 | EFI_RUNTIME_SERVICES_CODE, |
| 137 | /* |
| 138 | * The data portions of a loaded Runtime Services Driver and |
| 139 | * the default data allocation type used by a Runtime Services |
| 140 | * Driver to allocate pool memory. |
| 141 | */ |
| 142 | EFI_RUNTIME_SERVICES_DATA, |
| 143 | /* Free (unallocated) memory */ |
| 144 | EFI_CONVENTIONAL_MEMORY, |
| 145 | /* Memory in which errors have been detected */ |
| 146 | EFI_UNUSABLE_MEMORY, |
| 147 | /* Memory that holds the ACPI tables */ |
| 148 | EFI_ACPI_RECLAIM_MEMORY, |
| 149 | /* Address space reserved for use by the firmware */ |
| 150 | EFI_ACPI_MEMORY_NVS, |
| 151 | /* |
| 152 | * Used by system firmware to request that a memory-mapped IO region |
| 153 | * be mapped by the OS to a virtual address so it can be accessed by |
| 154 | * EFI runtime services. |
| 155 | */ |
| 156 | EFI_MMAP_IO, |
| 157 | /* |
| 158 | * System memory-mapped IO region that is used to translate |
| 159 | * memory cycles to IO cycles by the processor. |
| 160 | */ |
| 161 | EFI_MMAP_IO_PORT, |
| 162 | /* |
| 163 | * Address space reserved by the firmware for code that is |
| 164 | * part of the processor. |
| 165 | */ |
| 166 | EFI_PAL_CODE, |
| 167 | |
| 168 | EFI_MAX_MEMORY_TYPE, |
| 169 | EFI_TABLE_END, /* For efi_build_mem_table() */ |
| 170 | }; |
| 171 | |
| 172 | /* Attribute values */ |
| 173 | enum { |
| 174 | EFI_MEMORY_UC_SHIFT = 0, /* uncached */ |
| 175 | EFI_MEMORY_WC_SHIFT = 1, /* write-coalescing */ |
| 176 | EFI_MEMORY_WT_SHIFT = 2, /* write-through */ |
| 177 | EFI_MEMORY_WB_SHIFT = 3, /* write-back */ |
| 178 | EFI_MEMORY_UCE_SHIFT = 4, /* uncached, exported */ |
| 179 | EFI_MEMORY_WP_SHIFT = 12, /* write-protect */ |
| 180 | EFI_MEMORY_RP_SHIFT = 13, /* read-protect */ |
| 181 | EFI_MEMORY_XP_SHIFT = 14, /* execute-protect */ |
| 182 | EFI_MEMORY_RUNTIME_SHIFT = 63, /* range requires runtime mapping */ |
| 183 | |
| 184 | EFI_MEMORY_RUNTIME = 1ULL << EFI_MEMORY_RUNTIME_SHIFT, |
| 185 | EFI_MEM_DESC_VERSION = 1, |
| 186 | }; |
| 187 | |
| 188 | #define EFI_PAGE_SHIFT 12 |
| 189 | #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) |
Alexander Graf | 3ad57b4 | 2016-03-04 01:09:57 +0100 | [diff] [blame] | 190 | #define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1) |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 191 | |
| 192 | struct efi_mem_desc { |
| 193 | u32 type; |
| 194 | u32 reserved; |
| 195 | efi_physical_addr_t physical_start; |
| 196 | efi_virtual_addr_t virtual_start; |
| 197 | u64 num_pages; |
| 198 | u64 attribute; |
| 199 | }; |
| 200 | |
Mian Yousaf Kaukab | 338cf56 | 2016-09-05 23:59:22 +0200 | [diff] [blame] | 201 | #define EFI_MEMORY_DESCRIPTOR_VERSION 1 |
| 202 | |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 203 | /* Allocation types for calls to boottime->allocate_pages*/ |
| 204 | #define EFI_ALLOCATE_ANY_PAGES 0 |
| 205 | #define EFI_ALLOCATE_MAX_ADDRESS 1 |
| 206 | #define EFI_ALLOCATE_ADDRESS 2 |
| 207 | #define EFI_MAX_ALLOCATE_TYPE 3 |
| 208 | |
| 209 | /* Types and defines for Time Services */ |
| 210 | #define EFI_TIME_ADJUST_DAYLIGHT 0x1 |
| 211 | #define EFI_TIME_IN_DAYLIGHT 0x2 |
| 212 | #define EFI_UNSPECIFIED_TIMEZONE 0x07ff |
| 213 | |
| 214 | struct efi_time { |
| 215 | u16 year; |
| 216 | u8 month; |
| 217 | u8 day; |
| 218 | u8 hour; |
| 219 | u8 minute; |
| 220 | u8 second; |
| 221 | u8 pad1; |
| 222 | u32 nanosecond; |
| 223 | s16 timezone; |
| 224 | u8 daylight; |
| 225 | u8 pad2; |
| 226 | }; |
| 227 | |
| 228 | struct efi_time_cap { |
| 229 | u32 resolution; |
| 230 | u32 accuracy; |
| 231 | u8 sets_to_zero; |
| 232 | }; |
| 233 | |
| 234 | enum efi_locate_search_type { |
Heinrich Schuchardt | 68845f0 | 2017-11-06 21:17:42 +0100 | [diff] [blame] | 235 | ALL_HANDLES, |
| 236 | BY_REGISTER_NOTIFY, |
| 237 | BY_PROTOCOL |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | struct efi_open_protocol_info_entry { |
| 241 | efi_handle_t agent_handle; |
| 242 | efi_handle_t controller_handle; |
| 243 | u32 attributes; |
| 244 | u32 open_count; |
| 245 | }; |
| 246 | |
| 247 | enum efi_entry_t { |
| 248 | EFIET_END, /* Signals this is the last (empty) entry */ |
| 249 | EFIET_MEMORY_MAP, |
Bin Meng | cb787cb | 2018-06-12 08:36:21 -0700 | [diff] [blame] | 250 | EFIET_GOP_MODE, |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 251 | |
| 252 | /* Number of entries */ |
| 253 | EFIET_MEMORY_COUNT, |
| 254 | }; |
| 255 | |
| 256 | #define EFI_TABLE_VERSION 1 |
| 257 | |
| 258 | /** |
| 259 | * struct efi_info_hdr - Header for the EFI info table |
| 260 | * |
| 261 | * @version: EFI_TABLE_VERSION |
| 262 | * @hdr_size: Size of this struct in bytes |
| 263 | * @total_size: Total size of this header plus following data |
| 264 | * @spare: Spare space for expansion |
| 265 | */ |
| 266 | struct efi_info_hdr { |
| 267 | u32 version; |
| 268 | u32 hdr_size; |
| 269 | u32 total_size; |
| 270 | u32 spare[5]; |
| 271 | }; |
| 272 | |
| 273 | /** |
| 274 | * struct efi_entry_hdr - Header for a table entry |
| 275 | * |
| 276 | * @type: enum eft_entry_t |
| 277 | * @size size of entry bytes excluding header and padding |
| 278 | * @addr: address of this entry (0 if it follows the header ) |
| 279 | * @link: size of entry including header and padding |
| 280 | * @spare1: Spare space for expansion |
| 281 | * @spare2: Spare space for expansion |
| 282 | */ |
| 283 | struct efi_entry_hdr { |
| 284 | u32 type; |
| 285 | u32 size; |
| 286 | u64 addr; |
| 287 | u32 link; |
| 288 | u32 spare1; |
| 289 | u64 spare2; |
| 290 | }; |
| 291 | |
| 292 | /** |
| 293 | * struct efi_entry_memmap - a memory map table passed to U-Boot |
| 294 | * |
| 295 | * @version: EFI's memory map table version |
| 296 | * @desc_size: EFI's size of each memory descriptor |
| 297 | * @spare: Spare space for expansion |
| 298 | * @desc: An array of descriptors, each @desc_size bytes apart |
| 299 | */ |
| 300 | struct efi_entry_memmap { |
| 301 | u32 version; |
| 302 | u32 desc_size; |
| 303 | u64 spare; |
| 304 | struct efi_mem_desc desc[]; |
| 305 | }; |
| 306 | |
Bin Meng | cb787cb | 2018-06-12 08:36:21 -0700 | [diff] [blame] | 307 | /** |
| 308 | * struct efi_entry_gopmode - a GOP mode table passed to U-Boot |
| 309 | * |
| 310 | * @fb_base: EFI's framebuffer base address |
| 311 | * @fb_size: EFI's framebuffer size |
| 312 | * @info_size: GOP mode info structure size |
| 313 | * @info: Start address of the GOP mode info structure |
| 314 | */ |
| 315 | struct efi_entry_gopmode { |
| 316 | efi_physical_addr_t fb_base; |
| 317 | /* |
| 318 | * Not like the ones in 'struct efi_gop_mode' which are 'unsigned |
| 319 | * long', @fb_size and @info_size have to be 'u64' here. As the EFI |
| 320 | * stub codes may have different bit size from the U-Boot payload, |
| 321 | * using 'long' will cause mismatch between the producer (stub) and |
| 322 | * the consumer (payload). |
| 323 | */ |
| 324 | u64 fb_size; |
| 325 | u64 info_size; |
| 326 | /* |
| 327 | * We cannot directly use 'struct efi_gop_mode_info info[]' here as |
| 328 | * it causes compiler to complain: array type has incomplete element |
| 329 | * type 'struct efi_gop_mode_info'. |
| 330 | */ |
| 331 | struct /* efi_gop_mode_info */ { |
| 332 | u32 version; |
| 333 | u32 width; |
| 334 | u32 height; |
| 335 | u32 pixel_format; |
| 336 | u32 pixel_bitmask[4]; |
| 337 | u32 pixels_per_scanline; |
| 338 | } info[]; |
| 339 | }; |
| 340 | |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 341 | static inline struct efi_mem_desc *efi_get_next_mem_desc( |
| 342 | struct efi_entry_memmap *map, struct efi_mem_desc *desc) |
| 343 | { |
| 344 | return (struct efi_mem_desc *)((ulong)desc + map->desc_size); |
| 345 | } |
| 346 | |
| 347 | struct efi_priv { |
| 348 | efi_handle_t parent_image; |
| 349 | struct efi_device_path *device_path; |
| 350 | struct efi_system_table *sys_table; |
| 351 | struct efi_boot_services *boot; |
| 352 | struct efi_runtime_services *run; |
| 353 | bool use_pool_for_malloc; |
| 354 | unsigned long ram_base; |
| 355 | unsigned int image_data_type; |
| 356 | struct efi_info_hdr *info; |
| 357 | unsigned int info_size; |
| 358 | void *next_hdr; |
| 359 | }; |
| 360 | |
| 361 | /* Base address of the EFI image */ |
| 362 | extern char image_base[]; |
| 363 | |
Simon Glass | 63f581f | 2015-08-04 12:33:52 -0600 | [diff] [blame] | 364 | /* Start and end of U-Boot image (for payload) */ |
Bin Meng | 7c78bf9 | 2016-08-25 01:47:17 -0700 | [diff] [blame] | 365 | extern char _binary_u_boot_bin_start[], _binary_u_boot_bin_end[]; |
Simon Glass | 63f581f | 2015-08-04 12:33:52 -0600 | [diff] [blame] | 366 | |
Rob Clark | 15f3d74 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 367 | /* |
| 368 | * Variable Attributes |
| 369 | */ |
| 370 | #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001 |
| 371 | #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002 |
| 372 | #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004 |
| 373 | #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008 |
| 374 | #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010 |
| 375 | #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020 |
| 376 | #define EFI_VARIABLE_APPEND_WRITE 0x0000000000000040 |
| 377 | |
| 378 | #define EFI_VARIABLE_MASK (EFI_VARIABLE_NON_VOLATILE | \ |
| 379 | EFI_VARIABLE_BOOTSERVICE_ACCESS | \ |
| 380 | EFI_VARIABLE_RUNTIME_ACCESS | \ |
| 381 | EFI_VARIABLE_HARDWARE_ERROR_RECORD | \ |
| 382 | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \ |
| 383 | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \ |
| 384 | EFI_VARIABLE_APPEND_WRITE) |
| 385 | |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 386 | /** |
| 387 | * efi_get_sys_table() - Get access to the main EFI system table |
| 388 | * |
| 389 | * @return pointer to EFI system table |
| 390 | */ |
Simon Glass | 63f581f | 2015-08-04 12:33:52 -0600 | [diff] [blame] | 391 | |
Simon Glass | 9539e69 | 2015-07-31 09:31:36 -0600 | [diff] [blame] | 392 | struct efi_system_table *efi_get_sys_table(void); |
| 393 | |
| 394 | /** |
| 395 | * efi_get_ram_base() - Find the base of RAM |
| 396 | * |
| 397 | * This is used when U-Boot is built as an EFI application. |
| 398 | * |
| 399 | * @return the base of RAM as known to U-Boot |
| 400 | */ |
| 401 | unsigned long efi_get_ram_base(void); |
| 402 | |
| 403 | /** |
| 404 | * efi_init() - Set up ready for use of EFI boot services |
| 405 | * |
| 406 | * @priv: Pointer to our private EFI structure to fill in |
| 407 | * @banner: Banner to display when starting |
| 408 | * @image: The image handle passed to efi_main() |
| 409 | * @sys_table: The EFI system table pointer passed to efi_main() |
| 410 | */ |
| 411 | int efi_init(struct efi_priv *priv, const char *banner, efi_handle_t image, |
| 412 | struct efi_system_table *sys_table); |
| 413 | |
| 414 | /** |
| 415 | * efi_malloc() - Allocate some memory from EFI |
| 416 | * |
| 417 | * @priv: Pointer to private EFI structure |
| 418 | * @size: Number of bytes to allocate |
| 419 | * @retp: Return EFI status result |
| 420 | * @return pointer to memory allocated, or NULL on error |
| 421 | */ |
| 422 | void *efi_malloc(struct efi_priv *priv, int size, efi_status_t *retp); |
| 423 | |
| 424 | /** |
| 425 | * efi_free() - Free memory allocated from EFI |
| 426 | * |
| 427 | * @priv: Pointer to private EFI structure |
| 428 | * @ptr: Pointer to memory to free |
| 429 | */ |
| 430 | void efi_free(struct efi_priv *priv, void *ptr); |
| 431 | |
| 432 | /** |
| 433 | * efi_puts() - Write out a string to the EFI console |
| 434 | * |
| 435 | * @priv: Pointer to private EFI structure |
| 436 | * @str: String to write (note this is a ASCII, not unicode) |
| 437 | */ |
| 438 | void efi_puts(struct efi_priv *priv, const char *str); |
| 439 | |
| 440 | /** |
| 441 | * efi_putc() - Write out a character to the EFI console |
| 442 | * |
| 443 | * @priv: Pointer to private EFI structure |
| 444 | * @ch: Character to write (note this is not unicode) |
| 445 | */ |
| 446 | void efi_putc(struct efi_priv *priv, const char ch); |
| 447 | |
| 448 | /** |
| 449 | * efi_info_get() - get an entry from an EFI table |
| 450 | * |
| 451 | * @type: Entry type to search for |
| 452 | * @datap: Returns pointer to entry data |
| 453 | * @sizep: Returns pointer to entry size |
| 454 | * @return 0 if OK, -ENODATA if there is no table, -ENOENT if there is no entry |
| 455 | * of the requested type, -EPROTONOSUPPORT if the table has the wrong version |
| 456 | */ |
| 457 | int efi_info_get(enum efi_entry_t type, void **datap, int *sizep); |
| 458 | |
| 459 | /** |
| 460 | * efi_build_mem_table() - make a sorted copy of the memory table |
| 461 | * |
| 462 | * @map: Pointer to EFI memory map table |
| 463 | * @size: Size of table in bytes |
| 464 | * @skip_bs: True to skip boot-time memory and merge it with conventional |
| 465 | * memory. This will significantly reduce the number of table |
| 466 | * entries. |
| 467 | * @return pointer to the new table. It should be freed with free() by the |
| 468 | * caller |
| 469 | */ |
| 470 | void *efi_build_mem_table(struct efi_entry_memmap *map, int size, bool skip_bs); |
| 471 | |
| 472 | #endif /* _LINUX_EFI_H */ |