1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds #ifndef _LINUX_EFI_H 31da177e4SLinus Torvalds #define _LINUX_EFI_H 41da177e4SLinus Torvalds 51da177e4SLinus Torvalds /* 61da177e4SLinus Torvalds * Extensible Firmware Interface 71da177e4SLinus Torvalds * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999 81da177e4SLinus Torvalds * 91da177e4SLinus Torvalds * Copyright (C) 1999 VA Linux Systems 101da177e4SLinus Torvalds * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> 111da177e4SLinus Torvalds * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co. 121da177e4SLinus Torvalds * David Mosberger-Tang <davidm@hpl.hp.com> 131da177e4SLinus Torvalds * Stephane Eranian <eranian@hpl.hp.com> 141da177e4SLinus Torvalds */ 151da177e4SLinus Torvalds #include <linux/init.h> 161da177e4SLinus Torvalds #include <linux/string.h> 171da177e4SLinus Torvalds #include <linux/time.h> 181da177e4SLinus Torvalds #include <linux/types.h> 191da177e4SLinus Torvalds #include <linux/proc_fs.h> 201da177e4SLinus Torvalds #include <linux/rtc.h> 211da177e4SLinus Torvalds #include <linux/ioport.h> 224a3575fdSHuang, Ying #include <linux/pfn.h> 235ee9c198SMatthew Garrett #include <linux/pstore.h> 2460863c0dSMatt Fleming #include <linux/range.h> 258562c99cSMatt Fleming #include <linux/reboot.h> 26ba7e34b1SAndy Shevchenko #include <linux/uuid.h> 272c23b73cSArd Biesheuvel #include <linux/screen_info.h> 281da177e4SLinus Torvalds 291da177e4SLinus Torvalds #include <asm/page.h> 301da177e4SLinus Torvalds 311da177e4SLinus Torvalds #define EFI_SUCCESS 0 321da177e4SLinus Torvalds #define EFI_LOAD_ERROR ( 1 | (1UL << (BITS_PER_LONG-1))) 331da177e4SLinus Torvalds #define EFI_INVALID_PARAMETER ( 2 | (1UL << (BITS_PER_LONG-1))) 341da177e4SLinus Torvalds #define EFI_UNSUPPORTED ( 3 | (1UL << (BITS_PER_LONG-1))) 351da177e4SLinus Torvalds #define EFI_BAD_BUFFER_SIZE ( 4 | (1UL << (BITS_PER_LONG-1))) 361da177e4SLinus Torvalds #define EFI_BUFFER_TOO_SMALL ( 5 | (1UL << (BITS_PER_LONG-1))) 375d9db883SMatthew Garrett #define EFI_NOT_READY ( 6 | (1UL << (BITS_PER_LONG-1))) 385d9db883SMatthew Garrett #define EFI_DEVICE_ERROR ( 7 | (1UL << (BITS_PER_LONG-1))) 395d9db883SMatthew Garrett #define EFI_WRITE_PROTECTED ( 8 | (1UL << (BITS_PER_LONG-1))) 405d9db883SMatthew Garrett #define EFI_OUT_OF_RESOURCES ( 9 | (1UL << (BITS_PER_LONG-1))) 411da177e4SLinus Torvalds #define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG-1))) 42dce48e35SArd Biesheuvel #define EFI_ABORTED (21 | (1UL << (BITS_PER_LONG-1))) 435d9db883SMatthew Garrett #define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG-1))) 441da177e4SLinus Torvalds 451da177e4SLinus Torvalds typedef unsigned long efi_status_t; 461da177e4SLinus Torvalds typedef u8 efi_bool_t; 471da177e4SLinus Torvalds typedef u16 efi_char16_t; /* UNICODE character */ 48ed37ddffSRoy Franz typedef u64 efi_physical_addr_t; 49ed37ddffSRoy Franz typedef void *efi_handle_t; 501da177e4SLinus Torvalds 5189ed4865SArd Biesheuvel #if defined(CONFIG_X86_64) 528f24f8c2SArd Biesheuvel #define __efiapi __attribute__((ms_abi)) 5389ed4865SArd Biesheuvel #elif defined(CONFIG_X86_32) 5489ed4865SArd Biesheuvel #define __efiapi __attribute__((regparm(0))) 558f24f8c2SArd Biesheuvel #else 568f24f8c2SArd Biesheuvel #define __efiapi 578f24f8c2SArd Biesheuvel #endif 588f24f8c2SArd Biesheuvel 592732ea0dSArd Biesheuvel #define efi_get_handle_at(array, idx) \ 60f958efe9SArd Biesheuvel (efi_is_native() ? (array)[idx] \ 612732ea0dSArd Biesheuvel : (efi_handle_t)(unsigned long)((u32 *)(array))[idx]) 622732ea0dSArd Biesheuvel 632732ea0dSArd Biesheuvel #define efi_get_handle_num(size) \ 64f958efe9SArd Biesheuvel ((size) / (efi_is_native() ? sizeof(efi_handle_t) : sizeof(u32))) 652732ea0dSArd Biesheuvel 662732ea0dSArd Biesheuvel #define for_each_efi_handle(handle, array, size, i) \ 672732ea0dSArd Biesheuvel for (i = 0; \ 682732ea0dSArd Biesheuvel i < efi_get_handle_num(size) && \ 692732ea0dSArd Biesheuvel ((handle = efi_get_handle_at((array), i)) || true); \ 702732ea0dSArd Biesheuvel i++) 712732ea0dSArd Biesheuvel 72494c704fSArd Biesheuvel /* 73494c704fSArd Biesheuvel * The UEFI spec and EDK2 reference implementation both define EFI_GUID as 74494c704fSArd Biesheuvel * struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment 75494c704fSArd Biesheuvel * is 32 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM), 76494c704fSArd Biesheuvel * this means that firmware services invoked by the kernel may assume that 77494c704fSArd Biesheuvel * efi_guid_t* arguments are 32-bit aligned, and use memory accessors that 78494c704fSArd Biesheuvel * do not tolerate misalignment. So let's set the minimum alignment to 32 bits. 79494c704fSArd Biesheuvel * 80494c704fSArd Biesheuvel * Note that the UEFI spec as well as some comments in the EDK2 code base 81494c704fSArd Biesheuvel * suggest that EFI_GUID should be 64-bit aligned, but this appears to be 82494c704fSArd Biesheuvel * a mistake, given that no code seems to exist that actually enforces that 83494c704fSArd Biesheuvel * or relies on it. 84494c704fSArd Biesheuvel */ 85494c704fSArd Biesheuvel typedef guid_t efi_guid_t __aligned(__alignof__(u32)); 861da177e4SLinus Torvalds 871da177e4SLinus Torvalds #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ 88c0020756SAndy Shevchenko GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) 891da177e4SLinus Torvalds 901da177e4SLinus Torvalds /* 911da177e4SLinus Torvalds * Generic EFI table header 921da177e4SLinus Torvalds */ 931da177e4SLinus Torvalds typedef struct { 941da177e4SLinus Torvalds u64 signature; 951da177e4SLinus Torvalds u32 revision; 961da177e4SLinus Torvalds u32 headersize; 971da177e4SLinus Torvalds u32 crc32; 981da177e4SLinus Torvalds u32 reserved; 991da177e4SLinus Torvalds } efi_table_hdr_t; 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds /* 1021da177e4SLinus Torvalds * Memory map descriptor: 1031da177e4SLinus Torvalds */ 1041da177e4SLinus Torvalds 1051da177e4SLinus Torvalds /* Memory types: */ 1061da177e4SLinus Torvalds #define EFI_RESERVED_TYPE 0 1071da177e4SLinus Torvalds #define EFI_LOADER_CODE 1 1081da177e4SLinus Torvalds #define EFI_LOADER_DATA 2 1091da177e4SLinus Torvalds #define EFI_BOOT_SERVICES_CODE 3 1101da177e4SLinus Torvalds #define EFI_BOOT_SERVICES_DATA 4 1111da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_CODE 5 1121da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_DATA 6 1131da177e4SLinus Torvalds #define EFI_CONVENTIONAL_MEMORY 7 1141da177e4SLinus Torvalds #define EFI_UNUSABLE_MEMORY 8 1151da177e4SLinus Torvalds #define EFI_ACPI_RECLAIM_MEMORY 9 1161da177e4SLinus Torvalds #define EFI_ACPI_MEMORY_NVS 10 1171da177e4SLinus Torvalds #define EFI_MEMORY_MAPPED_IO 11 1181da177e4SLinus Torvalds #define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12 1191da177e4SLinus Torvalds #define EFI_PAL_CODE 13 120ad5fb870SDan Williams #define EFI_PERSISTENT_MEMORY 14 121ad5fb870SDan Williams #define EFI_MAX_MEMORY_TYPE 15 1221da177e4SLinus Torvalds 1231da177e4SLinus Torvalds /* Attribute values: */ 1241da177e4SLinus Torvalds #define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */ 1251da177e4SLinus Torvalds #define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */ 1261da177e4SLinus Torvalds #define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */ 1271da177e4SLinus Torvalds #define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */ 1289c97e0bdSLaszlo Ersek #define EFI_MEMORY_UCE ((u64)0x0000000000000010ULL) /* uncached, exported */ 1291da177e4SLinus Torvalds #define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */ 1301da177e4SLinus Torvalds #define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */ 1311da177e4SLinus Torvalds #define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */ 132c016ca08SRobert Elliott #define EFI_MEMORY_NV ((u64)0x0000000000008000ULL) /* non-volatile */ 133b05b9f5fSTony Luck #define EFI_MEMORY_MORE_RELIABLE \ 134b05b9f5fSTony Luck ((u64)0x0000000000010000ULL) /* higher reliability */ 13587db73aeSArd Biesheuvel #define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */ 136fe3e5e65SDan Williams #define EFI_MEMORY_SP ((u64)0x0000000000040000ULL) /* soft reserved */ 1371da177e4SLinus Torvalds #define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ 1381da177e4SLinus Torvalds #define EFI_MEMORY_DESCRIPTOR_VERSION 1 1391da177e4SLinus Torvalds 1401da177e4SLinus Torvalds #define EFI_PAGE_SHIFT 12 141ed37ddffSRoy Franz #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) 1420100a3e6SPeter Jones #define EFI_PAGES_MAX (U64_MAX >> EFI_PAGE_SHIFT) 1431da177e4SLinus Torvalds 1441da177e4SLinus Torvalds typedef struct { 1451da177e4SLinus Torvalds u32 type; 1461da177e4SLinus Torvalds u32 pad; 1471da177e4SLinus Torvalds u64 phys_addr; 1481da177e4SLinus Torvalds u64 virt_addr; 1491da177e4SLinus Torvalds u64 num_pages; 1501da177e4SLinus Torvalds u64 attribute; 1511da177e4SLinus Torvalds } efi_memory_desc_t; 1521da177e4SLinus Torvalds 1533b370237SMatthew Garrett typedef struct { 1543b370237SMatthew Garrett efi_guid_t guid; 1553b370237SMatthew Garrett u32 headersize; 1563b370237SMatthew Garrett u32 flags; 1573b370237SMatthew Garrett u32 imagesize; 1583b370237SMatthew Garrett } efi_capsule_header_t; 1593b370237SMatthew Garrett 160dadb57abSJeffrey Hugo struct efi_boot_memmap { 161dadb57abSJeffrey Hugo efi_memory_desc_t **map; 162dadb57abSJeffrey Hugo unsigned long *map_size; 163dadb57abSJeffrey Hugo unsigned long *desc_size; 164dadb57abSJeffrey Hugo u32 *desc_ver; 165dadb57abSJeffrey Hugo unsigned long *key_ptr; 166dadb57abSJeffrey Hugo unsigned long *buff_size; 167dadb57abSJeffrey Hugo }; 168dadb57abSJeffrey Hugo 169bb05e4baSMatt Fleming /* 170f0133f3cSMatt Fleming * EFI capsule flags 171f0133f3cSMatt Fleming */ 172f0133f3cSMatt Fleming #define EFI_CAPSULE_PERSIST_ACROSS_RESET 0x00010000 173f0133f3cSMatt Fleming #define EFI_CAPSULE_POPULATE_SYSTEM_TABLE 0x00020000 174f0133f3cSMatt Fleming #define EFI_CAPSULE_INITIATE_RESET 0x00040000 175f0133f3cSMatt Fleming 1763fabd628SArd Biesheuvel struct capsule_info { 1773fabd628SArd Biesheuvel efi_capsule_header_t header; 178f24c4d47SArd Biesheuvel efi_capsule_header_t *capsule; 1793fabd628SArd Biesheuvel int reset_type; 1803fabd628SArd Biesheuvel long index; 1813fabd628SArd Biesheuvel size_t count; 1823fabd628SArd Biesheuvel size_t total_size; 183f24c4d47SArd Biesheuvel struct page **pages; 184f24c4d47SArd Biesheuvel phys_addr_t *phys; 1853fabd628SArd Biesheuvel size_t page_bytes_remain; 1863fabd628SArd Biesheuvel }; 1873fabd628SArd Biesheuvel 1883fabd628SArd Biesheuvel int __efi_capsule_setup_info(struct capsule_info *cap_info); 1893fabd628SArd Biesheuvel 190f0133f3cSMatt Fleming /* 191bb05e4baSMatt Fleming * Allocation types for calls to boottime->allocate_pages. 192bb05e4baSMatt Fleming */ 193bb05e4baSMatt Fleming #define EFI_ALLOCATE_ANY_PAGES 0 194bb05e4baSMatt Fleming #define EFI_ALLOCATE_MAX_ADDRESS 1 195bb05e4baSMatt Fleming #define EFI_ALLOCATE_ADDRESS 2 196bb05e4baSMatt Fleming #define EFI_MAX_ALLOCATE_TYPE 3 197bb05e4baSMatt Fleming 198e088a4adSMatthew Wilcox typedef int (*efi_freemem_callback_t) (u64 start, u64 end, void *arg); 1991da177e4SLinus Torvalds 2001da177e4SLinus Torvalds /* 2011da177e4SLinus Torvalds * Types and defines for Time Services 2021da177e4SLinus Torvalds */ 2031da177e4SLinus Torvalds #define EFI_TIME_ADJUST_DAYLIGHT 0x1 2041da177e4SLinus Torvalds #define EFI_TIME_IN_DAYLIGHT 0x2 2051da177e4SLinus Torvalds #define EFI_UNSPECIFIED_TIMEZONE 0x07ff 2061da177e4SLinus Torvalds 2071da177e4SLinus Torvalds typedef struct { 2081da177e4SLinus Torvalds u16 year; 2091da177e4SLinus Torvalds u8 month; 2101da177e4SLinus Torvalds u8 day; 2111da177e4SLinus Torvalds u8 hour; 2121da177e4SLinus Torvalds u8 minute; 2131da177e4SLinus Torvalds u8 second; 2141da177e4SLinus Torvalds u8 pad1; 2151da177e4SLinus Torvalds u32 nanosecond; 2161da177e4SLinus Torvalds s16 timezone; 2171da177e4SLinus Torvalds u8 daylight; 2181da177e4SLinus Torvalds u8 pad2; 2191da177e4SLinus Torvalds } efi_time_t; 2201da177e4SLinus Torvalds 2211da177e4SLinus Torvalds typedef struct { 2221da177e4SLinus Torvalds u32 resolution; 2231da177e4SLinus Torvalds u32 accuracy; 2241da177e4SLinus Torvalds u8 sets_to_zero; 2251da177e4SLinus Torvalds } efi_time_cap_t; 2261da177e4SLinus Torvalds 227677703ceSMatt Fleming typedef struct { 228677703ceSMatt Fleming efi_table_hdr_t hdr; 229677703ceSMatt Fleming u32 raise_tpl; 230677703ceSMatt Fleming u32 restore_tpl; 231677703ceSMatt Fleming u32 allocate_pages; 232677703ceSMatt Fleming u32 free_pages; 233677703ceSMatt Fleming u32 get_memory_map; 234677703ceSMatt Fleming u32 allocate_pool; 235677703ceSMatt Fleming u32 free_pool; 236677703ceSMatt Fleming u32 create_event; 237677703ceSMatt Fleming u32 set_timer; 238677703ceSMatt Fleming u32 wait_for_event; 239677703ceSMatt Fleming u32 signal_event; 240677703ceSMatt Fleming u32 close_event; 241677703ceSMatt Fleming u32 check_event; 242677703ceSMatt Fleming u32 install_protocol_interface; 243677703ceSMatt Fleming u32 reinstall_protocol_interface; 244677703ceSMatt Fleming u32 uninstall_protocol_interface; 245677703ceSMatt Fleming u32 handle_protocol; 246677703ceSMatt Fleming u32 __reserved; 247677703ceSMatt Fleming u32 register_protocol_notify; 248677703ceSMatt Fleming u32 locate_handle; 249677703ceSMatt Fleming u32 locate_device_path; 250677703ceSMatt Fleming u32 install_configuration_table; 251677703ceSMatt Fleming u32 load_image; 252677703ceSMatt Fleming u32 start_image; 253677703ceSMatt Fleming u32 exit; 254677703ceSMatt Fleming u32 unload_image; 255677703ceSMatt Fleming u32 exit_boot_services; 256677703ceSMatt Fleming u32 get_next_monotonic_count; 257677703ceSMatt Fleming u32 stall; 258677703ceSMatt Fleming u32 set_watchdog_timer; 259677703ceSMatt Fleming u32 connect_controller; 260677703ceSMatt Fleming u32 disconnect_controller; 261677703ceSMatt Fleming u32 open_protocol; 262677703ceSMatt Fleming u32 close_protocol; 263677703ceSMatt Fleming u32 open_protocol_information; 264677703ceSMatt Fleming u32 protocols_per_handle; 265677703ceSMatt Fleming u32 locate_handle_buffer; 266677703ceSMatt Fleming u32 locate_protocol; 267677703ceSMatt Fleming u32 install_multiple_protocol_interfaces; 268677703ceSMatt Fleming u32 uninstall_multiple_protocol_interfaces; 269677703ceSMatt Fleming u32 calculate_crc32; 270677703ceSMatt Fleming u32 copy_mem; 271677703ceSMatt Fleming u32 set_mem; 272677703ceSMatt Fleming u32 create_event_ex; 273677703ceSMatt Fleming } __packed efi_boot_services_32_t; 274677703ceSMatt Fleming 2751da177e4SLinus Torvalds /* 276f30ca6baSMatt Fleming * EFI Boot Services table 277f30ca6baSMatt Fleming */ 2781786e830SArd Biesheuvel typedef union { 2791786e830SArd Biesheuvel struct { 280f30ca6baSMatt Fleming efi_table_hdr_t hdr; 281f30ca6baSMatt Fleming void *raise_tpl; 282f30ca6baSMatt Fleming void *restore_tpl; 2838f24f8c2SArd Biesheuvel efi_status_t (__efiapi *allocate_pages)(int, int, unsigned long, 284ed37ddffSRoy Franz efi_physical_addr_t *); 2858f24f8c2SArd Biesheuvel efi_status_t (__efiapi *free_pages)(efi_physical_addr_t, 2868f24f8c2SArd Biesheuvel unsigned long); 2878f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_memory_map)(unsigned long *, void *, 2888f24f8c2SArd Biesheuvel unsigned long *, 289ed37ddffSRoy Franz unsigned long *, u32 *); 2908f24f8c2SArd Biesheuvel efi_status_t (__efiapi *allocate_pool)(int, unsigned long, 2918f24f8c2SArd Biesheuvel void **); 2928f24f8c2SArd Biesheuvel efi_status_t (__efiapi *free_pool)(void *); 293f30ca6baSMatt Fleming void *create_event; 294f30ca6baSMatt Fleming void *set_timer; 295f30ca6baSMatt Fleming void *wait_for_event; 296f30ca6baSMatt Fleming void *signal_event; 297f30ca6baSMatt Fleming void *close_event; 298f30ca6baSMatt Fleming void *check_event; 299f30ca6baSMatt Fleming void *install_protocol_interface; 300f30ca6baSMatt Fleming void *reinstall_protocol_interface; 301f30ca6baSMatt Fleming void *uninstall_protocol_interface; 3028f24f8c2SArd Biesheuvel efi_status_t (__efiapi *handle_protocol)(efi_handle_t, 3038f24f8c2SArd Biesheuvel efi_guid_t *, void **); 304f30ca6baSMatt Fleming void *__reserved; 305f30ca6baSMatt Fleming void *register_protocol_notify; 3068f24f8c2SArd Biesheuvel efi_status_t (__efiapi *locate_handle)(int, efi_guid_t *, 3078f24f8c2SArd Biesheuvel void *, unsigned long *, 3088f24f8c2SArd Biesheuvel efi_handle_t *); 309f30ca6baSMatt Fleming void *locate_device_path; 3108f24f8c2SArd Biesheuvel efi_status_t (__efiapi *install_configuration_table)(efi_guid_t *, 3118f24f8c2SArd Biesheuvel void *); 312f30ca6baSMatt Fleming void *load_image; 313f30ca6baSMatt Fleming void *start_image; 314f30ca6baSMatt Fleming void *exit; 315f30ca6baSMatt Fleming void *unload_image; 3168f24f8c2SArd Biesheuvel efi_status_t (__efiapi *exit_boot_services)(efi_handle_t, 3178f24f8c2SArd Biesheuvel unsigned long); 318f30ca6baSMatt Fleming void *get_next_monotonic_count; 319f30ca6baSMatt Fleming void *stall; 320f30ca6baSMatt Fleming void *set_watchdog_timer; 321f30ca6baSMatt Fleming void *connect_controller; 3224444f854SMatthew Garrett efi_status_t (__efiapi *disconnect_controller)(efi_handle_t, 3234444f854SMatthew Garrett efi_handle_t, 3244444f854SMatthew Garrett efi_handle_t); 325f30ca6baSMatt Fleming void *open_protocol; 326f30ca6baSMatt Fleming void *close_protocol; 327f30ca6baSMatt Fleming void *open_protocol_information; 328f30ca6baSMatt Fleming void *protocols_per_handle; 329f30ca6baSMatt Fleming void *locate_handle_buffer; 3308f24f8c2SArd Biesheuvel efi_status_t (__efiapi *locate_protocol)(efi_guid_t *, void *, 3318f24f8c2SArd Biesheuvel void **); 332f30ca6baSMatt Fleming void *install_multiple_protocol_interfaces; 333f30ca6baSMatt Fleming void *uninstall_multiple_protocol_interfaces; 334f30ca6baSMatt Fleming void *calculate_crc32; 335f30ca6baSMatt Fleming void *copy_mem; 336f30ca6baSMatt Fleming void *set_mem; 337f30ca6baSMatt Fleming void *create_event_ex; 3381786e830SArd Biesheuvel }; 3391786e830SArd Biesheuvel efi_boot_services_32_t mixed_mode; 340f30ca6baSMatt Fleming } efi_boot_services_t; 341f30ca6baSMatt Fleming 342dd5fc854SMatthew Garrett typedef enum { 343dd5fc854SMatthew Garrett EfiPciIoWidthUint8, 344dd5fc854SMatthew Garrett EfiPciIoWidthUint16, 345dd5fc854SMatthew Garrett EfiPciIoWidthUint32, 346dd5fc854SMatthew Garrett EfiPciIoWidthUint64, 347dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint8, 348dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint16, 349dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint32, 350dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint64, 351dd5fc854SMatthew Garrett EfiPciIoWidthFillUint8, 352dd5fc854SMatthew Garrett EfiPciIoWidthFillUint16, 353dd5fc854SMatthew Garrett EfiPciIoWidthFillUint32, 354dd5fc854SMatthew Garrett EfiPciIoWidthFillUint64, 355dd5fc854SMatthew Garrett EfiPciIoWidthMaximum 356dd5fc854SMatthew Garrett } EFI_PCI_IO_PROTOCOL_WIDTH; 357dd5fc854SMatthew Garrett 358dd5fc854SMatthew Garrett typedef enum { 359dd5fc854SMatthew Garrett EfiPciIoAttributeOperationGet, 360dd5fc854SMatthew Garrett EfiPciIoAttributeOperationSet, 361dd5fc854SMatthew Garrett EfiPciIoAttributeOperationEnable, 362dd5fc854SMatthew Garrett EfiPciIoAttributeOperationDisable, 363dd5fc854SMatthew Garrett EfiPciIoAttributeOperationSupported, 364dd5fc854SMatthew Garrett EfiPciIoAttributeOperationMaximum 365dd5fc854SMatthew Garrett } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; 366dd5fc854SMatthew Garrett 367677703ceSMatt Fleming typedef struct { 368677703ceSMatt Fleming u32 read; 369677703ceSMatt Fleming u32 write; 370677703ceSMatt Fleming } efi_pci_io_protocol_access_32_t; 371677703ceSMatt Fleming 3721786e830SArd Biesheuvel typedef union efi_pci_io_protocol efi_pci_io_protocol_t; 3731786e830SArd Biesheuvel 3741786e830SArd Biesheuvel typedef 3758f24f8c2SArd Biesheuvel efi_status_t (__efiapi *efi_pci_io_protocol_cfg_t)(efi_pci_io_protocol_t *, 3761786e830SArd Biesheuvel EFI_PCI_IO_PROTOCOL_WIDTH, 3778f24f8c2SArd Biesheuvel u32 offset, 3788f24f8c2SArd Biesheuvel unsigned long count, 3791786e830SArd Biesheuvel void *buffer); 3801786e830SArd Biesheuvel 381dd5fc854SMatthew Garrett typedef struct { 382dd5fc854SMatthew Garrett void *read; 383dd5fc854SMatthew Garrett void *write; 384dd5fc854SMatthew Garrett } efi_pci_io_protocol_access_t; 385dd5fc854SMatthew Garrett 386dd5fc854SMatthew Garrett typedef struct { 3871786e830SArd Biesheuvel efi_pci_io_protocol_cfg_t read; 3881786e830SArd Biesheuvel efi_pci_io_protocol_cfg_t write; 3891786e830SArd Biesheuvel } efi_pci_io_protocol_config_access_t; 3901786e830SArd Biesheuvel 3911786e830SArd Biesheuvel union efi_pci_io_protocol { 3921786e830SArd Biesheuvel struct { 393dd5fc854SMatthew Garrett void *poll_mem; 394dd5fc854SMatthew Garrett void *poll_io; 395dd5fc854SMatthew Garrett efi_pci_io_protocol_access_t mem; 396dd5fc854SMatthew Garrett efi_pci_io_protocol_access_t io; 3971786e830SArd Biesheuvel efi_pci_io_protocol_config_access_t pci; 398dd5fc854SMatthew Garrett void *copy_mem; 399dd5fc854SMatthew Garrett void *map; 400dd5fc854SMatthew Garrett void *unmap; 401dd5fc854SMatthew Garrett void *allocate_buffer; 402dd5fc854SMatthew Garrett void *free_buffer; 403dd5fc854SMatthew Garrett void *flush; 4048f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_location)(efi_pci_io_protocol_t *, 405960a8d01SArd Biesheuvel unsigned long *segment_nr, 406960a8d01SArd Biesheuvel unsigned long *bus_nr, 407960a8d01SArd Biesheuvel unsigned long *device_nr, 4088f24f8c2SArd Biesheuvel unsigned long *func_nr); 409dd5fc854SMatthew Garrett void *attributes; 410dd5fc854SMatthew Garrett void *get_bar_attributes; 411dd5fc854SMatthew Garrett void *set_bar_attributes; 412dd5fc854SMatthew Garrett uint64_t romsize; 413dd5fc854SMatthew Garrett void *romimage; 4141786e830SArd Biesheuvel }; 4151786e830SArd Biesheuvel struct { 4161786e830SArd Biesheuvel u32 poll_mem; 4171786e830SArd Biesheuvel u32 poll_io; 4181786e830SArd Biesheuvel efi_pci_io_protocol_access_32_t mem; 4191786e830SArd Biesheuvel efi_pci_io_protocol_access_32_t io; 4201786e830SArd Biesheuvel efi_pci_io_protocol_access_32_t pci; 4211786e830SArd Biesheuvel u32 copy_mem; 4221786e830SArd Biesheuvel u32 map; 4231786e830SArd Biesheuvel u32 unmap; 4241786e830SArd Biesheuvel u32 allocate_buffer; 4251786e830SArd Biesheuvel u32 free_buffer; 4261786e830SArd Biesheuvel u32 flush; 4271786e830SArd Biesheuvel u32 get_location; 4281786e830SArd Biesheuvel u32 attributes; 4291786e830SArd Biesheuvel u32 get_bar_attributes; 4301786e830SArd Biesheuvel u32 set_bar_attributes; 4311786e830SArd Biesheuvel u64 romsize; 4321786e830SArd Biesheuvel u32 romimage; 4331786e830SArd Biesheuvel } mixed_mode; 4341786e830SArd Biesheuvel }; 435dd5fc854SMatthew Garrett 436dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 437dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 438dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 439dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 440dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 441dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 442dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 443dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 444dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 445dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 446dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 447dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 448dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 449dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 450dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 451dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 452dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 453dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 454dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 455dd5fc854SMatthew Garrett 4561786e830SArd Biesheuvel struct efi_dev_path; 4571786e830SArd Biesheuvel 4581786e830SArd Biesheuvel typedef union apple_properties_protocol apple_properties_protocol_t; 4591786e830SArd Biesheuvel 4601786e830SArd Biesheuvel union apple_properties_protocol { 4611786e830SArd Biesheuvel struct { 4621786e830SArd Biesheuvel unsigned long version; 4638f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get)(apple_properties_protocol_t *, 4648f24f8c2SArd Biesheuvel struct efi_dev_path *, 4658f24f8c2SArd Biesheuvel efi_char16_t *, void *, u32 *); 4668f24f8c2SArd Biesheuvel efi_status_t (__efiapi *set)(apple_properties_protocol_t *, 4678f24f8c2SArd Biesheuvel struct efi_dev_path *, 4688f24f8c2SArd Biesheuvel efi_char16_t *, void *, u32); 4698f24f8c2SArd Biesheuvel efi_status_t (__efiapi *del)(apple_properties_protocol_t *, 4708f24f8c2SArd Biesheuvel struct efi_dev_path *, 4718f24f8c2SArd Biesheuvel efi_char16_t *); 4728f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_all)(apple_properties_protocol_t *, 4731786e830SArd Biesheuvel void *buffer, u32 *); 4741786e830SArd Biesheuvel }; 4751786e830SArd Biesheuvel struct { 4761786e830SArd Biesheuvel u32 version; 4771786e830SArd Biesheuvel u32 get; 4781786e830SArd Biesheuvel u32 set; 4791786e830SArd Biesheuvel u32 del; 4801786e830SArd Biesheuvel u32 get_all; 4811786e830SArd Biesheuvel } mixed_mode; 4821786e830SArd Biesheuvel }; 4831786e830SArd Biesheuvel 48433b6d034SThiebaud Weksteen typedef u32 efi_tcg2_event_log_format; 48533b6d034SThiebaud Weksteen 4861786e830SArd Biesheuvel typedef union efi_tcg2_protocol efi_tcg2_protocol_t; 4871786e830SArd Biesheuvel 4881786e830SArd Biesheuvel union efi_tcg2_protocol { 4891786e830SArd Biesheuvel struct { 49033b6d034SThiebaud Weksteen void *get_capability; 4918f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_event_log)(efi_handle_t, 4921786e830SArd Biesheuvel efi_tcg2_event_log_format, 4931786e830SArd Biesheuvel efi_physical_addr_t *, 4941786e830SArd Biesheuvel efi_physical_addr_t *, 4951786e830SArd Biesheuvel efi_bool_t *); 49633b6d034SThiebaud Weksteen void *hash_log_extend_event; 49733b6d034SThiebaud Weksteen void *submit_command; 49833b6d034SThiebaud Weksteen void *get_active_pcr_banks; 49933b6d034SThiebaud Weksteen void *set_active_pcr_banks; 50033b6d034SThiebaud Weksteen void *get_result_of_set_active_pcr_banks; 5011786e830SArd Biesheuvel }; 5021786e830SArd Biesheuvel struct { 5031786e830SArd Biesheuvel u32 get_capability; 5041786e830SArd Biesheuvel u32 get_event_log; 5051786e830SArd Biesheuvel u32 hash_log_extend_event; 5061786e830SArd Biesheuvel u32 submit_command; 5071786e830SArd Biesheuvel u32 get_active_pcr_banks; 5081786e830SArd Biesheuvel u32 set_active_pcr_banks; 5091786e830SArd Biesheuvel u32 get_result_of_set_active_pcr_banks; 5101786e830SArd Biesheuvel } mixed_mode; 5111786e830SArd Biesheuvel }; 51233b6d034SThiebaud Weksteen 513f30ca6baSMatt Fleming /* 5141da177e4SLinus Torvalds * Types and defines for EFI ResetSystem 5151da177e4SLinus Torvalds */ 5161da177e4SLinus Torvalds #define EFI_RESET_COLD 0 5171da177e4SLinus Torvalds #define EFI_RESET_WARM 1 5181da177e4SLinus Torvalds #define EFI_RESET_SHUTDOWN 2 5191da177e4SLinus Torvalds 5201da177e4SLinus Torvalds /* 5211da177e4SLinus Torvalds * EFI Runtime Services table 5221da177e4SLinus Torvalds */ 5231da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL) 5241da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_REVISION 0x00010000 5251da177e4SLinus Torvalds 5261da177e4SLinus Torvalds typedef struct { 5271da177e4SLinus Torvalds efi_table_hdr_t hdr; 528677703ceSMatt Fleming u32 get_time; 529677703ceSMatt Fleming u32 set_time; 530677703ceSMatt Fleming u32 get_wakeup_time; 531677703ceSMatt Fleming u32 set_wakeup_time; 532677703ceSMatt Fleming u32 set_virtual_address_map; 533677703ceSMatt Fleming u32 convert_pointer; 534677703ceSMatt Fleming u32 get_variable; 535677703ceSMatt Fleming u32 get_next_variable; 536677703ceSMatt Fleming u32 set_variable; 537677703ceSMatt Fleming u32 get_next_high_mono_count; 538677703ceSMatt Fleming u32 reset_system; 539677703ceSMatt Fleming u32 update_capsule; 540677703ceSMatt Fleming u32 query_capsule_caps; 541677703ceSMatt Fleming u32 query_variable_info; 542677703ceSMatt Fleming } efi_runtime_services_32_t; 543677703ceSMatt Fleming 5441da177e4SLinus Torvalds typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc); 5451da177e4SLinus Torvalds typedef efi_status_t efi_set_time_t (efi_time_t *tm); 5461da177e4SLinus Torvalds typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending, 5471da177e4SLinus Torvalds efi_time_t *tm); 5481da177e4SLinus Torvalds typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm); 5491da177e4SLinus Torvalds typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr, 5501da177e4SLinus Torvalds unsigned long *data_size, void *data); 5511da177e4SLinus Torvalds typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name, 5521da177e4SLinus Torvalds efi_guid_t *vendor); 5531da177e4SLinus Torvalds typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor, 554f7a2d73fSMatthew Garrett u32 attr, unsigned long data_size, 5551da177e4SLinus Torvalds void *data); 5561da177e4SLinus Torvalds typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count); 5571da177e4SLinus Torvalds typedef void efi_reset_system_t (int reset_type, efi_status_t status, 5581da177e4SLinus Torvalds unsigned long data_size, efi_char16_t *data); 5591da177e4SLinus Torvalds typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size, 5601da177e4SLinus Torvalds unsigned long descriptor_size, 5611da177e4SLinus Torvalds u32 descriptor_version, 5621da177e4SLinus Torvalds efi_memory_desc_t *virtual_map); 5633b370237SMatthew Garrett typedef efi_status_t efi_query_variable_info_t(u32 attr, 5643b370237SMatthew Garrett u64 *storage_space, 5653b370237SMatthew Garrett u64 *remaining_space, 5663b370237SMatthew Garrett u64 *max_variable_size); 5673b370237SMatthew Garrett typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **capsules, 5683b370237SMatthew Garrett unsigned long count, 5693b370237SMatthew Garrett unsigned long sg_list); 5703b370237SMatthew Garrett typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules, 5713b370237SMatthew Garrett unsigned long count, 5723b370237SMatthew Garrett u64 *max_size, 5733b370237SMatthew Garrett int *reset_type); 574ca0e30dcSArd Biesheuvel typedef efi_status_t efi_query_variable_store_t(u32 attributes, 575ca0e30dcSArd Biesheuvel unsigned long size, 576ca0e30dcSArd Biesheuvel bool nonblocking); 5771da177e4SLinus Torvalds 5781786e830SArd Biesheuvel typedef union { 5791786e830SArd Biesheuvel struct { 580c4c39c70SArd Biesheuvel efi_table_hdr_t hdr; 5818f24f8c2SArd Biesheuvel efi_get_time_t __efiapi *get_time; 5828f24f8c2SArd Biesheuvel efi_set_time_t __efiapi *set_time; 5838f24f8c2SArd Biesheuvel efi_get_wakeup_time_t __efiapi *get_wakeup_time; 5848f24f8c2SArd Biesheuvel efi_set_wakeup_time_t __efiapi *set_wakeup_time; 5858f24f8c2SArd Biesheuvel efi_set_virtual_address_map_t __efiapi *set_virtual_address_map; 586c4c39c70SArd Biesheuvel void *convert_pointer; 5878f24f8c2SArd Biesheuvel efi_get_variable_t __efiapi *get_variable; 5888f24f8c2SArd Biesheuvel efi_get_next_variable_t __efiapi *get_next_variable; 5898f24f8c2SArd Biesheuvel efi_set_variable_t __efiapi *set_variable; 5908f24f8c2SArd Biesheuvel efi_get_next_high_mono_count_t __efiapi *get_next_high_mono_count; 5918f24f8c2SArd Biesheuvel efi_reset_system_t __efiapi *reset_system; 5928f24f8c2SArd Biesheuvel efi_update_capsule_t __efiapi *update_capsule; 5938f24f8c2SArd Biesheuvel efi_query_capsule_caps_t __efiapi *query_capsule_caps; 5948f24f8c2SArd Biesheuvel efi_query_variable_info_t __efiapi *query_variable_info; 5951786e830SArd Biesheuvel }; 5961786e830SArd Biesheuvel efi_runtime_services_32_t mixed_mode; 597c4c39c70SArd Biesheuvel } efi_runtime_services_t; 598c4c39c70SArd Biesheuvel 599022ee6c5SArd Biesheuvel void efi_native_runtime_setup(void); 600022ee6c5SArd Biesheuvel 6011da177e4SLinus Torvalds /* 6021da177e4SLinus Torvalds * EFI Configuration Table and GUID definitions 60354fd11feSPeter Jones * 6047fb2b43cSIngo Molnar * These are all defined in a single line to make them easier to 6057fb2b43cSIngo Molnar * grep for and to see them at a glance - while still having a 6067fb2b43cSIngo Molnar * similar structure to the definitions in the spec. 6077fb2b43cSIngo Molnar * 6087fb2b43cSIngo Molnar * Here's how they are structured: 60954fd11feSPeter Jones * 61054fd11feSPeter Jones * GUID: 12345678-1234-1234-1234-123456789012 61154fd11feSPeter Jones * Spec: 61254fd11feSPeter Jones * #define EFI_SOME_PROTOCOL_GUID \ 61354fd11feSPeter Jones * {0x12345678,0x1234,0x1234,\ 61454fd11feSPeter Jones * {0x12,0x34,0x12,0x34,0x56,0x78,0x90,0x12}} 61554fd11feSPeter Jones * Here: 6167fb2b43cSIngo Molnar * #define SOME_PROTOCOL_GUID EFI_GUID(0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12) 6177fb2b43cSIngo Molnar * ^ tabs ^extra space 6187fb2b43cSIngo Molnar * 6197fb2b43cSIngo Molnar * Note that the 'extra space' separates the values at the same place 6207fb2b43cSIngo Molnar * where the UEFI SPEC breaks the line. 6211da177e4SLinus Torvalds */ 6227fb2b43cSIngo Molnar #define NULL_GUID EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) 6237fb2b43cSIngo Molnar #define MPS_TABLE_GUID EFI_GUID(0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 6247fb2b43cSIngo Molnar #define ACPI_TABLE_GUID EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 6257fb2b43cSIngo Molnar #define ACPI_20_TABLE_GUID EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81) 6267fb2b43cSIngo Molnar #define SMBIOS_TABLE_GUID EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 6277fb2b43cSIngo Molnar #define SMBIOS3_TABLE_GUID EFI_GUID(0xf2fd1544, 0x9794, 0x4a2c, 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94) 6287fb2b43cSIngo Molnar #define SAL_SYSTEM_TABLE_GUID EFI_GUID(0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 6297fb2b43cSIngo Molnar #define HCDP_TABLE_GUID EFI_GUID(0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98) 6307fb2b43cSIngo Molnar #define UGA_IO_PROTOCOL_GUID EFI_GUID(0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0x0b, 0x07, 0xa2) 6317fb2b43cSIngo Molnar #define EFI_GLOBAL_VARIABLE_GUID EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c) 6327fb2b43cSIngo Molnar #define UV_SYSTEM_TABLE_GUID EFI_GUID(0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93) 6337fb2b43cSIngo Molnar #define LINUX_EFI_CRASH_GUID EFI_GUID(0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0) 6347fb2b43cSIngo Molnar #define LOADED_IMAGE_PROTOCOL_GUID EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 6357fb2b43cSIngo Molnar #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a) 6367fb2b43cSIngo Molnar #define EFI_UGA_PROTOCOL_GUID EFI_GUID(0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39) 6377fb2b43cSIngo Molnar #define EFI_PCI_IO_PROTOCOL_GUID EFI_GUID(0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a) 6387fb2b43cSIngo Molnar #define EFI_FILE_INFO_ID EFI_GUID(0x09576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 6397fb2b43cSIngo Molnar #define EFI_SYSTEM_RESOURCE_TABLE_GUID EFI_GUID(0xb122a263, 0x3661, 0x4f68, 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80) 6407fb2b43cSIngo Molnar #define EFI_FILE_SYSTEM_GUID EFI_GUID(0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 6417fb2b43cSIngo Molnar #define DEVICE_TREE_GUID EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0) 6427fb2b43cSIngo Molnar #define EFI_PROPERTIES_TABLE_GUID EFI_GUID(0x880aaca3, 0x4adc, 0x4a04, 0x90, 0x79, 0xb7, 0x47, 0x34, 0x08, 0x25, 0xe5) 6437fb2b43cSIngo Molnar #define EFI_RNG_PROTOCOL_GUID EFI_GUID(0x3152bca5, 0xeade, 0x433d, 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44) 644568bc4e8SArd Biesheuvel #define EFI_RNG_ALGORITHM_RAW EFI_GUID(0xe43176d7, 0xb6e8, 0x4827, 0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61) 6457fb2b43cSIngo Molnar #define EFI_MEMORY_ATTRIBUTES_TABLE_GUID EFI_GUID(0xdcfa911d, 0x26eb, 0x469f, 0xa2, 0x20, 0x38, 0xb7, 0xdc, 0x46, 0x12, 0x20) 6467fb2b43cSIngo Molnar #define EFI_CONSOLE_OUT_DEVICE_GUID EFI_GUID(0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 64758c5475aSLukas Wunner #define APPLE_PROPERTIES_PROTOCOL_GUID EFI_GUID(0x91bd12fe, 0xf6c3, 0x44fb, 0xa5, 0xb7, 0x51, 0x22, 0xab, 0x30, 0x3a, 0xe0) 64833b6d034SThiebaud Weksteen #define EFI_TCG2_PROTOCOL_GUID EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f) 649fc372064SArd Biesheuvel 650e58910cdSJosh Boyer #define EFI_IMAGE_SECURITY_DATABASE_GUID EFI_GUID(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f) 651e58910cdSJosh Boyer #define EFI_SHIM_LOCK_GUID EFI_GUID(0x605dab50, 0xe046, 0x4300, 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23) 652e58910cdSJosh Boyer 6535c126ba2SDave Howells #define EFI_CERT_SHA256_GUID EFI_GUID(0xc1c41626, 0x504c, 0x4092, 0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28) 6545c126ba2SDave Howells #define EFI_CERT_X509_GUID EFI_GUID(0xa5c059a1, 0x94e4, 0x4aa7, 0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72) 6555c126ba2SDave Howells #define EFI_CERT_X509_SHA256_GUID EFI_GUID(0x3bd2a492, 0x96c0, 0x4079, 0xb4, 0x20, 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed) 6565c126ba2SDave Howells 657801820beSArd Biesheuvel /* 658801820beSArd Biesheuvel * This GUID is used to pass to the kernel proper the struct screen_info 659801820beSArd Biesheuvel * structure that was populated by the stub based on the GOP protocol instance 660801820beSArd Biesheuvel * associated with ConOut 661801820beSArd Biesheuvel */ 6627fb2b43cSIngo Molnar #define LINUX_EFI_ARM_SCREEN_INFO_TABLE_GUID EFI_GUID(0xe03fc20a, 0x85dc, 0x406e, 0xb9, 0x0e, 0x4a, 0xb5, 0x02, 0x37, 0x1d, 0x95) 6637fb2b43cSIngo Molnar #define LINUX_EFI_LOADER_ENTRY_GUID EFI_GUID(0x4a67b082, 0x0a4c, 0x41cf, 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f) 66463625988SArd Biesheuvel #define LINUX_EFI_RANDOM_SEED_TABLE_GUID EFI_GUID(0x1ce1e5bc, 0x7ceb, 0x42f2, 0x81, 0xe5, 0x8a, 0xad, 0xf1, 0x80, 0xf5, 0x7b) 66533b6d034SThiebaud Weksteen #define LINUX_EFI_TPM_EVENT_LOG_GUID EFI_GUID(0xb7799cb0, 0xeca2, 0x4943, 0x96, 0x67, 0x1f, 0xae, 0x07, 0xb7, 0x47, 0xfa) 666c46f3405SMatthew Garrett #define LINUX_EFI_TPM_FINAL_LOG_GUID EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25) 66771e0940dSArd Biesheuvel #define LINUX_EFI_MEMRESERVE_TABLE_GUID EFI_GUID(0x888eb0c6, 0x8ede, 0x4ff5, 0xa8, 0xf0, 0x9a, 0xee, 0x5c, 0xb9, 0x77, 0xc2) 66806f7d4a1SCompostella, Jeremy 6691c5fecb6SNarendra K /* OEM GUIDs */ 6701c5fecb6SNarendra K #define DELLEMC_EFI_RCI2_TABLE_GUID EFI_GUID(0x2d9f28a2, 0xa886, 0x456a, 0x97, 0xa8, 0xf1, 0x1e, 0xf2, 0x4f, 0xf4, 0x55) 6711c5fecb6SNarendra K 6721da177e4SLinus Torvalds typedef struct { 6731da177e4SLinus Torvalds efi_guid_t guid; 6741adbfa35SOlof Johansson u64 table; 6751adbfa35SOlof Johansson } efi_config_table_64_t; 6761adbfa35SOlof Johansson 6771adbfa35SOlof Johansson typedef struct { 6781adbfa35SOlof Johansson efi_guid_t guid; 6791adbfa35SOlof Johansson u32 table; 6801adbfa35SOlof Johansson } efi_config_table_32_t; 6811adbfa35SOlof Johansson 6821786e830SArd Biesheuvel typedef union { 6831786e830SArd Biesheuvel struct { 6841adbfa35SOlof Johansson efi_guid_t guid; 685f958efe9SArd Biesheuvel void *table; 6861786e830SArd Biesheuvel }; 6871786e830SArd Biesheuvel efi_config_table_32_t mixed_mode; 6881da177e4SLinus Torvalds } efi_config_table_t; 6891da177e4SLinus Torvalds 690272686bfSLeif Lindholm typedef struct { 691272686bfSLeif Lindholm efi_guid_t guid; 692272686bfSLeif Lindholm const char *name; 693272686bfSLeif Lindholm unsigned long *ptr; 694272686bfSLeif Lindholm } efi_config_table_type_t; 695272686bfSLeif Lindholm 6961da177e4SLinus Torvalds #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) 6971da177e4SLinus Torvalds 6983b370237SMatthew Garrett #define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30)) 6993b370237SMatthew Garrett #define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20)) 7003b370237SMatthew Garrett #define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10)) 7013b370237SMatthew Garrett #define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00)) 7023b370237SMatthew Garrett #define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10)) 7033b370237SMatthew Garrett #define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02)) 7043b370237SMatthew Garrett 7051da177e4SLinus Torvalds typedef struct { 7061da177e4SLinus Torvalds efi_table_hdr_t hdr; 7071adbfa35SOlof Johansson u64 fw_vendor; /* physical addr of CHAR16 vendor string */ 7081adbfa35SOlof Johansson u32 fw_revision; 7091adbfa35SOlof Johansson u32 __pad1; 7101adbfa35SOlof Johansson u64 con_in_handle; 7111adbfa35SOlof Johansson u64 con_in; 7121adbfa35SOlof Johansson u64 con_out_handle; 7131adbfa35SOlof Johansson u64 con_out; 7141adbfa35SOlof Johansson u64 stderr_handle; 7151adbfa35SOlof Johansson u64 stderr; 7161adbfa35SOlof Johansson u64 runtime; 7171adbfa35SOlof Johansson u64 boottime; 7181adbfa35SOlof Johansson u32 nr_tables; 7191adbfa35SOlof Johansson u32 __pad2; 7201adbfa35SOlof Johansson u64 tables; 7211adbfa35SOlof Johansson } efi_system_table_64_t; 7221adbfa35SOlof Johansson 7231adbfa35SOlof Johansson typedef struct { 7241adbfa35SOlof Johansson efi_table_hdr_t hdr; 7251adbfa35SOlof Johansson u32 fw_vendor; /* physical addr of CHAR16 vendor string */ 7261adbfa35SOlof Johansson u32 fw_revision; 7271adbfa35SOlof Johansson u32 con_in_handle; 7281adbfa35SOlof Johansson u32 con_in; 7291adbfa35SOlof Johansson u32 con_out_handle; 7301adbfa35SOlof Johansson u32 con_out; 7311adbfa35SOlof Johansson u32 stderr_handle; 7321adbfa35SOlof Johansson u32 stderr; 7331adbfa35SOlof Johansson u32 runtime; 7341adbfa35SOlof Johansson u32 boottime; 7351adbfa35SOlof Johansson u32 nr_tables; 7361adbfa35SOlof Johansson u32 tables; 7371adbfa35SOlof Johansson } efi_system_table_32_t; 7381adbfa35SOlof Johansson 739960a8d01SArd Biesheuvel typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t; 740960a8d01SArd Biesheuvel 7411786e830SArd Biesheuvel typedef union { 7421786e830SArd Biesheuvel struct { 7431adbfa35SOlof Johansson efi_table_hdr_t hdr; 7441da177e4SLinus Torvalds unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */ 7451da177e4SLinus Torvalds u32 fw_revision; 7461da177e4SLinus Torvalds unsigned long con_in_handle; 7471da177e4SLinus Torvalds unsigned long con_in; 7481da177e4SLinus Torvalds unsigned long con_out_handle; 749960a8d01SArd Biesheuvel efi_simple_text_output_protocol_t *con_out; 7501da177e4SLinus Torvalds unsigned long stderr_handle; 7511da177e4SLinus Torvalds unsigned long stderr; 7521da177e4SLinus Torvalds efi_runtime_services_t *runtime; 753f30ca6baSMatt Fleming efi_boot_services_t *boottime; 7541da177e4SLinus Torvalds unsigned long nr_tables; 7551da177e4SLinus Torvalds unsigned long tables; 7561786e830SArd Biesheuvel }; 7571786e830SArd Biesheuvel efi_system_table_32_t mixed_mode; 7581da177e4SLinus Torvalds } efi_system_table_t; 7591da177e4SLinus Torvalds 7609479c7ceSMatt Fleming /* 7619479c7ceSMatt Fleming * Architecture independent structure for describing a memory map for the 7621db91035SDan Williams * benefit of efi_memmap_init_early(), and for passing context between 7631db91035SDan Williams * efi_memmap_alloc() and efi_memmap_install(). 7649479c7ceSMatt Fleming */ 7659479c7ceSMatt Fleming struct efi_memory_map_data { 7669479c7ceSMatt Fleming phys_addr_t phys_map; 7679479c7ceSMatt Fleming unsigned long size; 7689479c7ceSMatt Fleming unsigned long desc_version; 7699479c7ceSMatt Fleming unsigned long desc_size; 77026c0e44aSDan Williams unsigned long flags; 7719479c7ceSMatt Fleming }; 7729479c7ceSMatt Fleming 7731da177e4SLinus Torvalds struct efi_memory_map { 77444511fb9SArd Biesheuvel phys_addr_t phys_map; 7757ae65fd3SMatt Tolentino void *map; 7767ae65fd3SMatt Tolentino void *map_end; 7771da177e4SLinus Torvalds int nr_map; 7781da177e4SLinus Torvalds unsigned long desc_version; 7797ae65fd3SMatt Tolentino unsigned long desc_size; 78026c0e44aSDan Williams #define EFI_MEMMAP_LATE (1UL << 0) 7811db91035SDan Williams #define EFI_MEMMAP_MEMBLOCK (1UL << 1) 7821db91035SDan Williams #define EFI_MEMMAP_SLAB (1UL << 2) 78326c0e44aSDan Williams unsigned long flags; 7841da177e4SLinus Torvalds }; 7851da177e4SLinus Torvalds 78660863c0dSMatt Fleming struct efi_mem_range { 78760863c0dSMatt Fleming struct range range; 78860863c0dSMatt Fleming u64 attribute; 7891da177e4SLinus Torvalds }; 7901da177e4SLinus Torvalds 7910302f71cSMark Salter struct efi_fdt_params { 7920302f71cSMark Salter u64 system_table; 7930302f71cSMark Salter u64 mmap; 7940302f71cSMark Salter u32 mmap_size; 7950302f71cSMark Salter u32 desc_size; 7960302f71cSMark Salter u32 desc_ver; 7970302f71cSMark Salter }; 7980302f71cSMark Salter 79914e900c7SArd Biesheuvel typedef struct { 800677703ceSMatt Fleming u32 revision; 8019fa76ca7SArvind Sankar efi_handle_t parent_handle; 8028e84f345SMatt Fleming efi_system_table_t *system_table; 8039fa76ca7SArvind Sankar efi_handle_t device_handle; 8048e84f345SMatt Fleming void *file_path; 8058e84f345SMatt Fleming void *reserved; 8068e84f345SMatt Fleming u32 load_options_size; 8078e84f345SMatt Fleming void *load_options; 8088e84f345SMatt Fleming void *image_base; 8098e84f345SMatt Fleming __aligned_u64 image_size; 8108e84f345SMatt Fleming unsigned int image_code_type; 8118e84f345SMatt Fleming unsigned int image_data_type; 8128f24f8c2SArd Biesheuvel efi_status_t ( __efiapi *unload)(efi_handle_t image_handle); 81314e900c7SArd Biesheuvel } efi_loaded_image_t; 81455839d51SMatt Fleming 81555839d51SMatt Fleming typedef struct { 81655839d51SMatt Fleming u64 size; 81755839d51SMatt Fleming u64 file_size; 81855839d51SMatt Fleming u64 phys_size; 81955839d51SMatt Fleming efi_time_t create_time; 82055839d51SMatt Fleming efi_time_t last_access_time; 82155839d51SMatt Fleming efi_time_t modification_time; 82255839d51SMatt Fleming __aligned_u64 attribute; 82355839d51SMatt Fleming efi_char16_t filename[1]; 82455839d51SMatt Fleming } efi_file_info_t; 82555839d51SMatt Fleming 82614e900c7SArd Biesheuvel typedef struct efi_file_handle efi_file_handle_t; 8271786e830SArd Biesheuvel 82814e900c7SArd Biesheuvel struct efi_file_handle { 82955839d51SMatt Fleming u64 revision; 8308f24f8c2SArd Biesheuvel efi_status_t (__efiapi *open)(efi_file_handle_t *, 8311786e830SArd Biesheuvel efi_file_handle_t **, 832ed37ddffSRoy Franz efi_char16_t *, u64, u64); 8338f24f8c2SArd Biesheuvel efi_status_t (__efiapi *close)(efi_file_handle_t *); 83455839d51SMatt Fleming void *delete; 8358f24f8c2SArd Biesheuvel efi_status_t (__efiapi *read)(efi_file_handle_t *, 8368f24f8c2SArd Biesheuvel unsigned long *, void *); 83755839d51SMatt Fleming void *write; 83855839d51SMatt Fleming void *get_position; 83955839d51SMatt Fleming void *set_position; 8408f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_info)(efi_file_handle_t *, 8418f24f8c2SArd Biesheuvel efi_guid_t *, unsigned long *, 8428f24f8c2SArd Biesheuvel void *); 84355839d51SMatt Fleming void *set_info; 84455839d51SMatt Fleming void *flush; 8451786e830SArd Biesheuvel }; 84655839d51SMatt Fleming 84714e900c7SArd Biesheuvel typedef struct efi_file_io_interface efi_file_io_interface_t; 8481786e830SArd Biesheuvel 84914e900c7SArd Biesheuvel struct efi_file_io_interface { 850ed37ddffSRoy Franz u64 revision; 8518f24f8c2SArd Biesheuvel int (__efiapi *open_volume)(efi_file_io_interface_t *, 852ed37ddffSRoy Franz efi_file_handle_t **); 8531786e830SArd Biesheuvel }; 854ed37ddffSRoy Franz 85555839d51SMatt Fleming #define EFI_FILE_MODE_READ 0x0000000000000001 85655839d51SMatt Fleming #define EFI_FILE_MODE_WRITE 0x0000000000000002 85755839d51SMatt Fleming #define EFI_FILE_MODE_CREATE 0x8000000000000000 85855839d51SMatt Fleming 859bf924863SArd Biesheuvel typedef struct { 860bf924863SArd Biesheuvel u32 version; 861bf924863SArd Biesheuvel u32 length; 862bf924863SArd Biesheuvel u64 memory_protection_attribute; 863bf924863SArd Biesheuvel } efi_properties_table_t; 864bf924863SArd Biesheuvel 865bf924863SArd Biesheuvel #define EFI_PROPERTIES_TABLE_VERSION 0x00010000 866bf924863SArd Biesheuvel #define EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA 0x1 867bf924863SArd Biesheuvel 868b2c99e3cSBjorn Helgaas #define EFI_INVALID_TABLE_ADDR (~0UL) 869b2c99e3cSBjorn Helgaas 870a604af07SArd Biesheuvel typedef struct { 871a604af07SArd Biesheuvel u32 version; 872a604af07SArd Biesheuvel u32 num_entries; 873a604af07SArd Biesheuvel u32 desc_size; 874a604af07SArd Biesheuvel u32 reserved; 875a604af07SArd Biesheuvel efi_memory_desc_t entry[0]; 876a604af07SArd Biesheuvel } efi_memory_attributes_table_t; 877a604af07SArd Biesheuvel 8785c126ba2SDave Howells typedef struct { 8795c126ba2SDave Howells efi_guid_t signature_owner; 8805c126ba2SDave Howells u8 signature_data[]; 8815c126ba2SDave Howells } efi_signature_data_t; 8825c126ba2SDave Howells 8835c126ba2SDave Howells typedef struct { 8845c126ba2SDave Howells efi_guid_t signature_type; 8855c126ba2SDave Howells u32 signature_list_size; 8865c126ba2SDave Howells u32 signature_header_size; 8875c126ba2SDave Howells u32 signature_size; 8885c126ba2SDave Howells u8 signature_header[]; 8895c126ba2SDave Howells /* efi_signature_data_t signatures[][] */ 8905c126ba2SDave Howells } efi_signature_list_t; 8915c126ba2SDave Howells 8925c126ba2SDave Howells typedef u8 efi_sha256_hash_t[32]; 8935c126ba2SDave Howells 8945c126ba2SDave Howells typedef struct { 8955c126ba2SDave Howells efi_sha256_hash_t to_be_signed_hash; 8965c126ba2SDave Howells efi_time_t time_of_revocation; 8975c126ba2SDave Howells } efi_cert_x509_sha256_t; 8985c126ba2SDave Howells 8991da177e4SLinus Torvalds /* 9001da177e4SLinus Torvalds * All runtime access to EFI goes through this structure: 9011da177e4SLinus Torvalds */ 9021da177e4SLinus Torvalds extern struct efi { 9031da177e4SLinus Torvalds efi_system_table_t *systab; /* EFI system table */ 9043b370237SMatthew Garrett unsigned int runtime_version; /* Runtime services version */ 905b2c99e3cSBjorn Helgaas unsigned long mps; /* MPS table */ 906b2c99e3cSBjorn Helgaas unsigned long acpi; /* ACPI table (IA64 ext 0.71) */ 907b2c99e3cSBjorn Helgaas unsigned long acpi20; /* ACPI table (ACPI 2.0) */ 908e1ccbbc9SArd Biesheuvel unsigned long smbios; /* SMBIOS table (32 bit entry point) */ 909e1ccbbc9SArd Biesheuvel unsigned long smbios3; /* SMBIOS table (64 bit entry point) */ 910b2c99e3cSBjorn Helgaas unsigned long boot_info; /* boot info table */ 911b2c99e3cSBjorn Helgaas unsigned long hcdp; /* HCDP table */ 912b2c99e3cSBjorn Helgaas unsigned long uga; /* UGA table */ 913a0998eb1SDave Young unsigned long fw_vendor; /* fw_vendor */ 914a0998eb1SDave Young unsigned long runtime; /* runtime table */ 915a0998eb1SDave Young unsigned long config_table; /* config tables */ 9160bb54905SPeter Jones unsigned long esrt; /* ESRT table */ 917bf924863SArd Biesheuvel unsigned long properties_table; /* properties table */ 918a604af07SArd Biesheuvel unsigned long mem_attr_table; /* memory attributes table */ 91963625988SArd Biesheuvel unsigned long rng_seed; /* UEFI firmware random seed */ 92033b6d034SThiebaud Weksteen unsigned long tpm_log; /* TPM2 Event Log table */ 921c46f3405SMatthew Garrett unsigned long tpm_final_log; /* TPM2 Final Events Log table */ 92271e0940dSArd Biesheuvel unsigned long mem_reserve; /* Linux EFI memreserve table */ 9231da177e4SLinus Torvalds efi_get_time_t *get_time; 9241da177e4SLinus Torvalds efi_set_time_t *set_time; 9251da177e4SLinus Torvalds efi_get_wakeup_time_t *get_wakeup_time; 9261da177e4SLinus Torvalds efi_set_wakeup_time_t *set_wakeup_time; 9271da177e4SLinus Torvalds efi_get_variable_t *get_variable; 9281da177e4SLinus Torvalds efi_get_next_variable_t *get_next_variable; 9291da177e4SLinus Torvalds efi_set_variable_t *set_variable; 93070d2a3cfSArd Biesheuvel efi_set_variable_t *set_variable_nonblocking; 9313b370237SMatthew Garrett efi_query_variable_info_t *query_variable_info; 932d3cac1f8SArd Biesheuvel efi_query_variable_info_t *query_variable_info_nonblocking; 9333b370237SMatthew Garrett efi_update_capsule_t *update_capsule; 9343b370237SMatthew Garrett efi_query_capsule_caps_t *query_capsule_caps; 9351da177e4SLinus Torvalds efi_get_next_high_mono_count_t *get_next_high_mono_count; 9361da177e4SLinus Torvalds efi_reset_system_t *reset_system; 937884f4f66SMatt Fleming struct efi_memory_map memmap; 9383e909599SMatt Fleming unsigned long flags; 9391da177e4SLinus Torvalds } efi; 9401da177e4SLinus Torvalds 9417e904a91SSai Praneeth extern struct mm_struct efi_mm; 9427e904a91SSai Praneeth 9431da177e4SLinus Torvalds static inline int 9441da177e4SLinus Torvalds efi_guidcmp (efi_guid_t left, efi_guid_t right) 9451da177e4SLinus Torvalds { 9461da177e4SLinus Torvalds return memcmp(&left, &right, sizeof (efi_guid_t)); 9471da177e4SLinus Torvalds } 9481da177e4SLinus Torvalds 9491da177e4SLinus Torvalds static inline char * 95026e02272SBorislav Petkov efi_guid_to_str(efi_guid_t *guid, char *out) 9511da177e4SLinus Torvalds { 952925ede0bSJoe Perches sprintf(out, "%pUl", guid->b); 9531da177e4SLinus Torvalds return out; 9541da177e4SLinus Torvalds } 9551da177e4SLinus Torvalds 9561da177e4SLinus Torvalds extern void efi_init (void); 9571da177e4SLinus Torvalds extern void *efi_get_pal_addr (void); 9581da177e4SLinus Torvalds extern void efi_map_pal_code (void); 9591da177e4SLinus Torvalds extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg); 96070f4f935SArnd Bergmann extern void efi_gettimeofday (struct timespec64 *ts); 9611da177e4SLinus Torvalds extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */ 96278510792SJosh Triplett #ifdef CONFIG_X86 963ca0e30dcSArd Biesheuvel extern efi_status_t efi_query_variable_store(u32 attributes, 964ca0e30dcSArd Biesheuvel unsigned long size, 965ca0e30dcSArd Biesheuvel bool nonblocking); 96678510792SJosh Triplett #else 967a6e4d5a0SMatt Fleming 968ca0e30dcSArd Biesheuvel static inline efi_status_t efi_query_variable_store(u32 attributes, 969ca0e30dcSArd Biesheuvel unsigned long size, 970ca0e30dcSArd Biesheuvel bool nonblocking) 971a6e4d5a0SMatt Fleming { 972a6e4d5a0SMatt Fleming return EFI_SUCCESS; 973a6e4d5a0SMatt Fleming } 97478510792SJosh Triplett #endif 9757bc90e01SJosh Triplett extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); 9769479c7ceSMatt Fleming 9771db91035SDan Williams extern int __init efi_memmap_alloc(unsigned int num_entries, 9781db91035SDan Williams struct efi_memory_map_data *data); 979484a418dSDan Williams extern void __efi_memmap_free(u64 phys, unsigned long size, 980484a418dSDan Williams unsigned long flags); 9819479c7ceSMatt Fleming extern int __init efi_memmap_init_early(struct efi_memory_map_data *data); 982dca0f971SMatt Fleming extern int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size); 9839479c7ceSMatt Fleming extern void __init efi_memmap_unmap(void); 9841db91035SDan Williams extern int __init efi_memmap_install(struct efi_memory_map_data *data); 98560863c0dSMatt Fleming extern int __init efi_memmap_split_count(efi_memory_desc_t *md, 98660863c0dSMatt Fleming struct range *range); 98760863c0dSMatt Fleming extern void __init efi_memmap_insert(struct efi_memory_map *old_memmap, 98860863c0dSMatt Fleming void *buf, struct efi_mem_range *mem); 9899479c7ceSMatt Fleming 990272686bfSLeif Lindholm extern int efi_config_init(efi_config_table_type_t *arch_tables); 9913846c158SPeter Jones #ifdef CONFIG_EFI_ESRT 9920bb54905SPeter Jones extern void __init efi_esrt_init(void); 9933846c158SPeter Jones #else 9943846c158SPeter Jones static inline void efi_esrt_init(void) { } 9953846c158SPeter Jones #endif 9967bb68410SArd Biesheuvel extern int efi_config_parse_tables(void *config_tables, int count, int sz, 9977bb68410SArd Biesheuvel efi_config_table_type_t *arch_tables); 9981da177e4SLinus Torvalds extern u64 efi_get_iobase (void); 999f99afd08STom Lendacky extern int efi_mem_type(unsigned long phys_addr); 10001da177e4SLinus Torvalds extern u64 efi_mem_attributes (unsigned long phys_addr); 100132e62c63SBjorn Helgaas extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size); 10021da177e4SLinus Torvalds extern int __init efi_uart_console_only (void); 10030bb54905SPeter Jones extern u64 efi_mem_desc_end(efi_memory_desc_t *md); 10040bb54905SPeter Jones extern int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md); 1005816e7612SMatt Fleming extern void efi_mem_reserve(phys_addr_t addr, u64 size); 1006a23d3bb0SArd Biesheuvel extern int efi_mem_reserve_persistent(phys_addr_t addr, u64 size); 10071da177e4SLinus Torvalds extern void efi_initialize_iomem_resources(struct resource *code_resource, 100800bf4098SBernhard Walle struct resource *data_resource, struct resource *bss_resource); 10097968c0e3SLeif Lindholm extern int efi_get_fdt_params(struct efi_fdt_params *params); 10100bb54905SPeter Jones extern struct kobject *efi_kobj; 10111da177e4SLinus Torvalds 101244be28e9SMatt Fleming extern int efi_reboot_quirk_mode; 10130c5ed61aSMatt Fleming extern bool efi_poweroff_required(void); 10140c5ed61aSMatt Fleming 10150f96a99dSTaku Izumi #ifdef CONFIG_EFI_FAKE_MEMMAP 10160f96a99dSTaku Izumi extern void __init efi_fake_memmap(void); 10170f96a99dSTaku Izumi #else 10180f96a99dSTaku Izumi static inline void efi_fake_memmap(void) { } 10190f96a99dSTaku Izumi #endif 10200f96a99dSTaku Izumi 102110f0d2f5SArd Biesheuvel /* 102210f0d2f5SArd Biesheuvel * efi_memattr_perm_setter - arch specific callback function passed into 102310f0d2f5SArd Biesheuvel * efi_memattr_apply_permissions() that updates the 102410f0d2f5SArd Biesheuvel * mapping permissions described by the second 102510f0d2f5SArd Biesheuvel * argument in the page tables referred to by the 102610f0d2f5SArd Biesheuvel * first argument. 102710f0d2f5SArd Biesheuvel */ 102810f0d2f5SArd Biesheuvel typedef int (*efi_memattr_perm_setter)(struct mm_struct *, efi_memory_desc_t *); 102910f0d2f5SArd Biesheuvel 103010f0d2f5SArd Biesheuvel extern int efi_memattr_init(void); 103110f0d2f5SArd Biesheuvel extern int efi_memattr_apply_permissions(struct mm_struct *mm, 103210f0d2f5SArd Biesheuvel efi_memattr_perm_setter fn); 103310f0d2f5SArd Biesheuvel 103402e43c2dSBaoquan He /* 103502e43c2dSBaoquan He * efi_early_memdesc_ptr - get the n-th EFI memmap descriptor 103602e43c2dSBaoquan He * @map: the start of efi memmap 103702e43c2dSBaoquan He * @desc_size: the size of space for each EFI memmap descriptor 103802e43c2dSBaoquan He * @n: the index of efi memmap descriptor 103902e43c2dSBaoquan He * 104002e43c2dSBaoquan He * EFI boot service provides the GetMemoryMap() function to get a copy of the 104102e43c2dSBaoquan He * current memory map which is an array of memory descriptors, each of 104202e43c2dSBaoquan He * which describes a contiguous block of memory. It also gets the size of the 104302e43c2dSBaoquan He * map, and the size of each descriptor, etc. 104402e43c2dSBaoquan He * 104502e43c2dSBaoquan He * Note that per section 6.2 of UEFI Spec 2.6 Errata A, the returned size of 104602e43c2dSBaoquan He * each descriptor might not be equal to sizeof(efi_memory_memdesc_t), 104702e43c2dSBaoquan He * since efi_memory_memdesc_t may be extended in the future. Thus the OS 104802e43c2dSBaoquan He * MUST use the returned size of the descriptor to find the start of each 104902e43c2dSBaoquan He * efi_memory_memdesc_t in the memory map array. This should only be used 105002e43c2dSBaoquan He * during bootup since for_each_efi_memory_desc_xxx() is available after the 105102e43c2dSBaoquan He * kernel initializes the EFI subsystem to set up struct efi_memory_map. 105202e43c2dSBaoquan He */ 105302e43c2dSBaoquan He #define efi_early_memdesc_ptr(map, desc_size, n) \ 105402e43c2dSBaoquan He (efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size))) 105502e43c2dSBaoquan He 1056e885cd80SMark Salter /* Iterate through an efi_memory_map */ 105778ce248fSMatt Fleming #define for_each_efi_memory_desc_in_map(m, md) \ 1058e885cd80SMark Salter for ((md) = (m)->map; \ 1059d4c4fed0SJan Beulich (md) && ((void *)(md) + (m)->desc_size) <= (m)->map_end; \ 1060e885cd80SMark Salter (md) = (void *)(md) + (m)->desc_size) 1061e885cd80SMark Salter 106278ce248fSMatt Fleming /** 106378ce248fSMatt Fleming * for_each_efi_memory_desc - iterate over descriptors in efi.memmap 106478ce248fSMatt Fleming * @md: the efi_memory_desc_t * iterator 106578ce248fSMatt Fleming * 106678ce248fSMatt Fleming * Once the loop finishes @md must not be accessed. 106778ce248fSMatt Fleming */ 106878ce248fSMatt Fleming #define for_each_efi_memory_desc(md) \ 1069884f4f66SMatt Fleming for_each_efi_memory_desc_in_map(&efi.memmap, md) 107078ce248fSMatt Fleming 107198d2a6caSLaszlo Ersek /* 107298d2a6caSLaszlo Ersek * Format an EFI memory descriptor's type and attributes to a user-provided 107398d2a6caSLaszlo Ersek * character buffer, as per snprintf(), and return the buffer. 107498d2a6caSLaszlo Ersek */ 107598d2a6caSLaszlo Ersek char * __init efi_md_typeattr_format(char *buf, size_t size, 107698d2a6caSLaszlo Ersek const efi_memory_desc_t *md); 107798d2a6caSLaszlo Ersek 10780bc9ae39SDave Howells 10790bc9ae39SDave Howells typedef void (*efi_element_handler_t)(const char *source, 10800bc9ae39SDave Howells const void *element_data, 10810bc9ae39SDave Howells size_t element_size); 10820bc9ae39SDave Howells extern int __init parse_efi_signature_list( 10830bc9ae39SDave Howells const char *source, 10840bc9ae39SDave Howells const void *data, size_t size, 10850bc9ae39SDave Howells efi_element_handler_t (*get_handler_for_guid)(const efi_guid_t *)); 10860bc9ae39SDave Howells 10871da177e4SLinus Torvalds /** 10881da177e4SLinus Torvalds * efi_range_is_wc - check the WC bit on an address range 10891da177e4SLinus Torvalds * @start: starting kvirt address 10901da177e4SLinus Torvalds * @len: length of range 10911da177e4SLinus Torvalds * 10921da177e4SLinus Torvalds * Consult the EFI memory map and make sure it's ok to set this range WC. 10931da177e4SLinus Torvalds * Returns true or false. 10941da177e4SLinus Torvalds */ 10951da177e4SLinus Torvalds static inline int efi_range_is_wc(unsigned long start, unsigned long len) 10961da177e4SLinus Torvalds { 1097986a80d5SJesper Juhl unsigned long i; 10981da177e4SLinus Torvalds 10991da177e4SLinus Torvalds for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) { 11001da177e4SLinus Torvalds unsigned long paddr = __pa(start + i); 11011da177e4SLinus Torvalds if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC)) 11021da177e4SLinus Torvalds return 0; 11031da177e4SLinus Torvalds } 11041da177e4SLinus Torvalds /* The range checked out */ 11051da177e4SLinus Torvalds return 1; 11061da177e4SLinus Torvalds } 11071da177e4SLinus Torvalds 11081da177e4SLinus Torvalds #ifdef CONFIG_EFI_PCDP 11091da177e4SLinus Torvalds extern int __init efi_setup_pcdp_console(char *); 11101da177e4SLinus Torvalds #endif 11111da177e4SLinus Torvalds 11121da177e4SLinus Torvalds /* 111383e68189SMatt Fleming * We play games with efi_enabled so that the compiler will, if 111483e68189SMatt Fleming * possible, remove EFI-related code altogether. 11151da177e4SLinus Torvalds */ 111683e68189SMatt Fleming #define EFI_BOOT 0 /* Were we booted from EFI? */ 111783e68189SMatt Fleming #define EFI_CONFIG_TABLES 2 /* Can we use EFI config tables? */ 111883e68189SMatt Fleming #define EFI_RUNTIME_SERVICES 3 /* Can we use runtime services? */ 111983e68189SMatt Fleming #define EFI_MEMMAP 4 /* Can we use EFI memory map? */ 112083e68189SMatt Fleming #define EFI_64BIT 5 /* Is the firmware 64-bit? */ 11219f27bc54SDaniel Kiper #define EFI_PARAVIRT 6 /* Access is via a paravirt interface */ 11229f27bc54SDaniel Kiper #define EFI_ARCH_1 7 /* First arch-specific bit */ 1123fed6cefeSBorislav Petkov #define EFI_DBG 8 /* Print additional debug info at runtime */ 1124a1041713SArd Biesheuvel #define EFI_NX_PE_DATA 9 /* Can runtime data regions be mapped non-executable? */ 1125a19ebf59SSai Praneeth #define EFI_MEM_ATTR 10 /* Did firmware publish an EFI_MEMORY_ATTRIBUTES table? */ 1126b617c526SDan Williams #define EFI_MEM_NO_SOFT_RESERVE 11 /* Is the kernel configured to ignore soft reservations? */ 1127*0e72a6a3SHans de Goede #define EFI_PRESERVE_BS_REGIONS 12 /* Are EFI boot-services memory segments available? */ 112883e68189SMatt Fleming 11291da177e4SLinus Torvalds #ifdef CONFIG_EFI 11303e909599SMatt Fleming /* 11313e909599SMatt Fleming * Test whether the above EFI_* bits are enabled. 11323e909599SMatt Fleming */ 11333e909599SMatt Fleming static inline bool efi_enabled(int feature) 113483e68189SMatt Fleming { 11353e909599SMatt Fleming return test_bit(feature, &efi.flags) != 0; 11363e909599SMatt Fleming } 11378562c99cSMatt Fleming extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); 1138b617c526SDan Williams 1139b617c526SDan Williams bool __pure __efi_soft_reserve_enabled(void); 1140b617c526SDan Williams 1141b617c526SDan Williams static inline bool __pure efi_soft_reserve_enabled(void) 1142b617c526SDan Williams { 1143b617c526SDan Williams return IS_ENABLED(CONFIG_EFI_SOFT_RESERVE) 1144b617c526SDan Williams && __efi_soft_reserve_enabled(); 1145b617c526SDan Williams } 11463e909599SMatt Fleming #else 11473e909599SMatt Fleming static inline bool efi_enabled(int feature) 11483e909599SMatt Fleming { 11493e909599SMatt Fleming return false; 115083e68189SMatt Fleming } 11518562c99cSMatt Fleming static inline void 11528562c99cSMatt Fleming efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {} 115387615a34SMatt Fleming 115487615a34SMatt Fleming static inline bool 115587615a34SMatt Fleming efi_capsule_pending(int *reset_type) 115687615a34SMatt Fleming { 115787615a34SMatt Fleming return false; 115887615a34SMatt Fleming } 1159b617c526SDan Williams 1160b617c526SDan Williams static inline bool efi_soft_reserve_enabled(void) 1161b617c526SDan Williams { 1162b617c526SDan Williams return false; 1163b617c526SDan Williams } 11641da177e4SLinus Torvalds #endif 11651da177e4SLinus Torvalds 1166806b0351SMatt Fleming extern int efi_status_to_err(efi_status_t status); 1167806b0351SMatt Fleming 11681da177e4SLinus Torvalds /* 11691da177e4SLinus Torvalds * Variable Attributes 11701da177e4SLinus Torvalds */ 11711da177e4SLinus Torvalds #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001 11721da177e4SLinus Torvalds #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002 11731da177e4SLinus Torvalds #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004 117441b3254cSMatthew Garrett #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008 117541b3254cSMatthew Garrett #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010 117641b3254cSMatthew Garrett #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020 117741b3254cSMatthew Garrett #define EFI_VARIABLE_APPEND_WRITE 0x0000000000000040 11781da177e4SLinus Torvalds 117941b3254cSMatthew Garrett #define EFI_VARIABLE_MASK (EFI_VARIABLE_NON_VOLATILE | \ 118041b3254cSMatthew Garrett EFI_VARIABLE_BOOTSERVICE_ACCESS | \ 118141b3254cSMatthew Garrett EFI_VARIABLE_RUNTIME_ACCESS | \ 118241b3254cSMatthew Garrett EFI_VARIABLE_HARDWARE_ERROR_RECORD | \ 118341b3254cSMatthew Garrett EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \ 118441b3254cSMatthew Garrett EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \ 118541b3254cSMatthew Garrett EFI_VARIABLE_APPEND_WRITE) 11861da177e4SLinus Torvalds /* 1187e14ab23dSMatt Fleming * Length of a GUID string (strlen("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")) 1188e14ab23dSMatt Fleming * not including trailing NUL 1189e14ab23dSMatt Fleming */ 1190ba7e34b1SAndy Shevchenko #define EFI_VARIABLE_GUID_LEN UUID_STRING_LEN 1191e14ab23dSMatt Fleming 1192e14ab23dSMatt Fleming /* 1193e2527a7cSMatt Fleming * The type of search to perform when calling boottime->locate_handle 1194e2527a7cSMatt Fleming */ 1195e2527a7cSMatt Fleming #define EFI_LOCATE_ALL_HANDLES 0 1196e2527a7cSMatt Fleming #define EFI_LOCATE_BY_REGISTER_NOTIFY 1 1197e2527a7cSMatt Fleming #define EFI_LOCATE_BY_PROTOCOL 2 1198e2527a7cSMatt Fleming 1199e2527a7cSMatt Fleming /* 12001da177e4SLinus Torvalds * EFI Device Path information 12011da177e4SLinus Torvalds */ 12021da177e4SLinus Torvalds #define EFI_DEV_HW 0x01 12031da177e4SLinus Torvalds #define EFI_DEV_PCI 1 12041da177e4SLinus Torvalds #define EFI_DEV_PCCARD 2 12051da177e4SLinus Torvalds #define EFI_DEV_MEM_MAPPED 3 12061da177e4SLinus Torvalds #define EFI_DEV_VENDOR 4 12071da177e4SLinus Torvalds #define EFI_DEV_CONTROLLER 5 12081da177e4SLinus Torvalds #define EFI_DEV_ACPI 0x02 12091da177e4SLinus Torvalds #define EFI_DEV_BASIC_ACPI 1 12101da177e4SLinus Torvalds #define EFI_DEV_EXPANDED_ACPI 2 12111da177e4SLinus Torvalds #define EFI_DEV_MSG 0x03 12121da177e4SLinus Torvalds #define EFI_DEV_MSG_ATAPI 1 12131da177e4SLinus Torvalds #define EFI_DEV_MSG_SCSI 2 12141da177e4SLinus Torvalds #define EFI_DEV_MSG_FC 3 12151da177e4SLinus Torvalds #define EFI_DEV_MSG_1394 4 12161da177e4SLinus Torvalds #define EFI_DEV_MSG_USB 5 12171da177e4SLinus Torvalds #define EFI_DEV_MSG_USB_CLASS 15 12181da177e4SLinus Torvalds #define EFI_DEV_MSG_I20 6 12191da177e4SLinus Torvalds #define EFI_DEV_MSG_MAC 11 12201da177e4SLinus Torvalds #define EFI_DEV_MSG_IPV4 12 12211da177e4SLinus Torvalds #define EFI_DEV_MSG_IPV6 13 12221da177e4SLinus Torvalds #define EFI_DEV_MSG_INFINIBAND 9 12231da177e4SLinus Torvalds #define EFI_DEV_MSG_UART 14 12241da177e4SLinus Torvalds #define EFI_DEV_MSG_VENDOR 10 12251da177e4SLinus Torvalds #define EFI_DEV_MEDIA 0x04 12261da177e4SLinus Torvalds #define EFI_DEV_MEDIA_HARD_DRIVE 1 12271da177e4SLinus Torvalds #define EFI_DEV_MEDIA_CDROM 2 12281da177e4SLinus Torvalds #define EFI_DEV_MEDIA_VENDOR 3 12291da177e4SLinus Torvalds #define EFI_DEV_MEDIA_FILE 4 12301da177e4SLinus Torvalds #define EFI_DEV_MEDIA_PROTOCOL 5 12311da177e4SLinus Torvalds #define EFI_DEV_BIOS_BOOT 0x05 12321da177e4SLinus Torvalds #define EFI_DEV_END_PATH 0x7F 12331da177e4SLinus Torvalds #define EFI_DEV_END_PATH2 0xFF 12341da177e4SLinus Torvalds #define EFI_DEV_END_INSTANCE 0x01 12351da177e4SLinus Torvalds #define EFI_DEV_END_ENTIRE 0xFF 12361da177e4SLinus Torvalds 12371da177e4SLinus Torvalds struct efi_generic_dev_path { 12381da177e4SLinus Torvalds u8 type; 12391da177e4SLinus Torvalds u8 sub_type; 12401da177e4SLinus Torvalds u16 length; 12411da177e4SLinus Torvalds } __attribute ((packed)); 12421da177e4SLinus Torvalds 124346cd4b75SLukas Wunner struct efi_dev_path { 124446cd4b75SLukas Wunner u8 type; /* can be replaced with unnamed */ 124546cd4b75SLukas Wunner u8 sub_type; /* struct efi_generic_dev_path; */ 124646cd4b75SLukas Wunner u16 length; /* once we've moved to -std=c11 */ 124746cd4b75SLukas Wunner union { 124846cd4b75SLukas Wunner struct { 124946cd4b75SLukas Wunner u32 hid; 125046cd4b75SLukas Wunner u32 uid; 125146cd4b75SLukas Wunner } acpi; 125246cd4b75SLukas Wunner struct { 125346cd4b75SLukas Wunner u8 fn; 125446cd4b75SLukas Wunner u8 dev; 125546cd4b75SLukas Wunner } pci; 125646cd4b75SLukas Wunner }; 125746cd4b75SLukas Wunner } __attribute ((packed)); 125846cd4b75SLukas Wunner 125946cd4b75SLukas Wunner #if IS_ENABLED(CONFIG_EFI_DEV_PATH_PARSER) 126046cd4b75SLukas Wunner struct device *efi_get_device_by_path(struct efi_dev_path **node, size_t *len); 126146cd4b75SLukas Wunner #endif 126246cd4b75SLukas Wunner 12634a3575fdSHuang, Ying static inline void memrange_efi_to_native(u64 *addr, u64 *npages) 12644a3575fdSHuang, Ying { 12654a3575fdSHuang, Ying *npages = PFN_UP(*addr + (*npages<<EFI_PAGE_SHIFT)) - PFN_DOWN(*addr); 12664a3575fdSHuang, Ying *addr &= PAGE_MASK; 12674a3575fdSHuang, Ying } 12684a3575fdSHuang, Ying 126904851772SMatt Fleming /* 12704fc756bdSMike Waychison * EFI Variable support. 12714fc756bdSMike Waychison * 12724fc756bdSMike Waychison * Different firmware drivers can expose their EFI-like variables using 12734fc756bdSMike Waychison * the following. 12744fc756bdSMike Waychison */ 12754fc756bdSMike Waychison 12764fc756bdSMike Waychison struct efivar_operations { 12774fc756bdSMike Waychison efi_get_variable_t *get_variable; 12784fc756bdSMike Waychison efi_get_next_variable_t *get_next_variable; 12794fc756bdSMike Waychison efi_set_variable_t *set_variable; 128070d2a3cfSArd Biesheuvel efi_set_variable_t *set_variable_nonblocking; 1281a6e4d5a0SMatt Fleming efi_query_variable_store_t *query_variable_store; 12824fc756bdSMike Waychison }; 12834fc756bdSMike Waychison 12844fc756bdSMike Waychison struct efivars { 12854fc756bdSMike Waychison struct kset *kset; 1286605e70c7SLee, Chun-Yi struct kobject *kobject; 12874fc756bdSMike Waychison const struct efivar_operations *ops; 12884fc756bdSMike Waychison }; 12894fc756bdSMike Waychison 1290e14ab23dSMatt Fleming /* 1291e14ab23dSMatt Fleming * The maximum size of VariableName + Data = 1024 1292e14ab23dSMatt Fleming * Therefore, it's reasonable to save that much 1293e14ab23dSMatt Fleming * space in each part of the structure, 1294e14ab23dSMatt Fleming * and we use a page for reading/writing. 1295e14ab23dSMatt Fleming */ 1296e14ab23dSMatt Fleming 1297a5d92ad3SMatt Fleming #define EFI_VAR_NAME_LEN 1024 1298a5d92ad3SMatt Fleming 1299e14ab23dSMatt Fleming struct efi_variable { 1300a5d92ad3SMatt Fleming efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)]; 1301e14ab23dSMatt Fleming efi_guid_t VendorGuid; 1302e14ab23dSMatt Fleming unsigned long DataSize; 1303e14ab23dSMatt Fleming __u8 Data[1024]; 1304e14ab23dSMatt Fleming efi_status_t Status; 1305e14ab23dSMatt Fleming __u32 Attributes; 1306e14ab23dSMatt Fleming } __attribute__((packed)); 1307e14ab23dSMatt Fleming 1308e14ab23dSMatt Fleming struct efivar_entry { 1309e14ab23dSMatt Fleming struct efi_variable var; 1310e14ab23dSMatt Fleming struct list_head list; 1311e14ab23dSMatt Fleming struct kobject kobj; 1312e0d59733SSeiji Aguchi bool scanning; 1313e0d59733SSeiji Aguchi bool deleting; 1314e14ab23dSMatt Fleming }; 1315e14ab23dSMatt Fleming 13161786e830SArd Biesheuvel union efi_simple_text_output_protocol { 13171786e830SArd Biesheuvel struct { 1318ed37ddffSRoy Franz void *reset; 13198f24f8c2SArd Biesheuvel efi_status_t (__efiapi *output_string)(efi_simple_text_output_protocol_t *, 13201786e830SArd Biesheuvel efi_char16_t *); 1321ed37ddffSRoy Franz void *test_string; 1322ed37ddffSRoy Franz }; 13231786e830SArd Biesheuvel struct { 13241786e830SArd Biesheuvel u32 reset; 13251786e830SArd Biesheuvel u32 output_string; 13261786e830SArd Biesheuvel u32 test_string; 13271786e830SArd Biesheuvel } mixed_mode; 13281786e830SArd Biesheuvel }; 1329ed37ddffSRoy Franz 1330fc372064SArd Biesheuvel #define PIXEL_RGB_RESERVED_8BIT_PER_COLOR 0 1331fc372064SArd Biesheuvel #define PIXEL_BGR_RESERVED_8BIT_PER_COLOR 1 1332fc372064SArd Biesheuvel #define PIXEL_BIT_MASK 2 1333fc372064SArd Biesheuvel #define PIXEL_BLT_ONLY 3 1334fc372064SArd Biesheuvel #define PIXEL_FORMAT_MAX 4 1335fc372064SArd Biesheuvel 133644c84b4aSArvind Sankar typedef struct { 1337fc372064SArd Biesheuvel u32 red_mask; 1338fc372064SArd Biesheuvel u32 green_mask; 1339fc372064SArd Biesheuvel u32 blue_mask; 1340fc372064SArd Biesheuvel u32 reserved_mask; 134144c84b4aSArvind Sankar } efi_pixel_bitmask_t; 1342fc372064SArd Biesheuvel 134344c84b4aSArvind Sankar typedef struct { 1344fc372064SArd Biesheuvel u32 version; 1345fc372064SArd Biesheuvel u32 horizontal_resolution; 1346fc372064SArd Biesheuvel u32 vertical_resolution; 1347fc372064SArd Biesheuvel int pixel_format; 134844c84b4aSArvind Sankar efi_pixel_bitmask_t pixel_information; 1349fc372064SArd Biesheuvel u32 pixels_per_scan_line; 135044c84b4aSArvind Sankar } efi_graphics_output_mode_info_t; 1351fc372064SArd Biesheuvel 13521786e830SArd Biesheuvel typedef union efi_graphics_output_protocol_mode efi_graphics_output_protocol_mode_t; 13531786e830SArd Biesheuvel 13541786e830SArd Biesheuvel union efi_graphics_output_protocol_mode { 13551786e830SArd Biesheuvel struct { 1356fc372064SArd Biesheuvel u32 max_mode; 1357fc372064SArd Biesheuvel u32 mode; 135844c84b4aSArvind Sankar efi_graphics_output_mode_info_t *info; 1359fc372064SArd Biesheuvel unsigned long size_of_info; 136044c84b4aSArvind Sankar efi_physical_addr_t frame_buffer_base; 1361fc372064SArd Biesheuvel unsigned long frame_buffer_size; 13621786e830SArd Biesheuvel }; 13631786e830SArd Biesheuvel struct { 13641786e830SArd Biesheuvel u32 max_mode; 13651786e830SArd Biesheuvel u32 mode; 13661786e830SArd Biesheuvel u32 info; 13671786e830SArd Biesheuvel u32 size_of_info; 13681786e830SArd Biesheuvel u64 frame_buffer_base; 13691786e830SArd Biesheuvel u32 frame_buffer_size; 13701786e830SArd Biesheuvel } mixed_mode; 13711786e830SArd Biesheuvel }; 1372fc372064SArd Biesheuvel 13731786e830SArd Biesheuvel typedef union efi_graphics_output_protocol efi_graphics_output_protocol_t; 13741786e830SArd Biesheuvel 13751786e830SArd Biesheuvel union efi_graphics_output_protocol { 13761786e830SArd Biesheuvel struct { 137744c84b4aSArvind Sankar void *query_mode; 137844c84b4aSArvind Sankar void *set_mode; 137944c84b4aSArvind Sankar void *blt; 138044c84b4aSArvind Sankar efi_graphics_output_protocol_mode_t *mode; 13811786e830SArd Biesheuvel }; 13821786e830SArd Biesheuvel struct { 13831786e830SArd Biesheuvel u32 query_mode; 13841786e830SArd Biesheuvel u32 set_mode; 13851786e830SArd Biesheuvel u32 blt; 13861786e830SArd Biesheuvel u32 mode; 13871786e830SArd Biesheuvel } mixed_mode; 13881786e830SArd Biesheuvel }; 1389fc372064SArd Biesheuvel 139004851772SMatt Fleming extern struct list_head efivar_sysfs_list; 139104851772SMatt Fleming 139204851772SMatt Fleming static inline void 139304851772SMatt Fleming efivar_unregister(struct efivar_entry *var) 139404851772SMatt Fleming { 139504851772SMatt Fleming kobject_put(&var->kobj); 139604851772SMatt Fleming } 139704851772SMatt Fleming 1398e14ab23dSMatt Fleming int efivars_register(struct efivars *efivars, 13994fc756bdSMike Waychison const struct efivar_operations *ops, 1400e14ab23dSMatt Fleming struct kobject *kobject); 1401e14ab23dSMatt Fleming int efivars_unregister(struct efivars *efivars); 1402e14ab23dSMatt Fleming struct kobject *efivars_kobject(void); 1403e14ab23dSMatt Fleming 1404e14ab23dSMatt Fleming int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), 14051cfd6316SJulia Lawall void *data, bool duplicates, struct list_head *head); 1406e14ab23dSMatt Fleming 140721b3ddd3SSylvain Chouleur int efivar_entry_add(struct efivar_entry *entry, struct list_head *head); 140821b3ddd3SSylvain Chouleur int efivar_entry_remove(struct efivar_entry *entry); 1409e14ab23dSMatt Fleming 1410e14ab23dSMatt Fleming int __efivar_entry_delete(struct efivar_entry *entry); 1411e14ab23dSMatt Fleming int efivar_entry_delete(struct efivar_entry *entry); 1412e14ab23dSMatt Fleming 1413e14ab23dSMatt Fleming int efivar_entry_size(struct efivar_entry *entry, unsigned long *size); 14148a415b8cSMatt Fleming int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes, 14158a415b8cSMatt Fleming unsigned long *size, void *data); 1416e14ab23dSMatt Fleming int efivar_entry_get(struct efivar_entry *entry, u32 *attributes, 1417e14ab23dSMatt Fleming unsigned long *size, void *data); 1418e14ab23dSMatt Fleming int efivar_entry_set(struct efivar_entry *entry, u32 attributes, 1419e14ab23dSMatt Fleming unsigned long size, void *data, struct list_head *head); 1420e14ab23dSMatt Fleming int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes, 1421e14ab23dSMatt Fleming unsigned long *size, void *data, bool *set); 1422e14ab23dSMatt Fleming int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes, 1423e14ab23dSMatt Fleming bool block, unsigned long size, void *data); 1424e14ab23dSMatt Fleming 142521b3ddd3SSylvain Chouleur int efivar_entry_iter_begin(void); 1426e14ab23dSMatt Fleming void efivar_entry_iter_end(void); 1427e14ab23dSMatt Fleming 1428e14ab23dSMatt Fleming int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *), 1429e14ab23dSMatt Fleming struct list_head *head, void *data, 1430e14ab23dSMatt Fleming struct efivar_entry **prev); 1431e14ab23dSMatt Fleming int efivar_entry_iter(int (*func)(struct efivar_entry *, void *), 1432e14ab23dSMatt Fleming struct list_head *head, void *data); 1433e14ab23dSMatt Fleming 1434e14ab23dSMatt Fleming struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid, 1435e14ab23dSMatt Fleming struct list_head *head, bool remove); 1436e14ab23dSMatt Fleming 14378282f5d9SPeter Jones bool efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data, 14388282f5d9SPeter Jones unsigned long data_size); 1439ed8b0de5SPeter Jones bool efivar_variable_is_removable(efi_guid_t vendor, const char *name, 1440ed8b0de5SPeter Jones size_t len); 1441e14ab23dSMatt Fleming 1442a9499fa7STom Gundersen extern struct work_struct efivar_work; 144304851772SMatt Fleming void efivar_run_worker(void); 144404851772SMatt Fleming 1445a9499fa7STom Gundersen #if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE) 1446e14ab23dSMatt Fleming int efivars_sysfs_init(void); 14474fc756bdSMike Waychison 1448e0d59733SSeiji Aguchi #define EFIVARS_DATA_SIZE_MAX 1024 1449e0d59733SSeiji Aguchi 14504fc756bdSMike Waychison #endif /* CONFIG_EFI_VARS */ 1451f0133f3cSMatt Fleming extern bool efi_capsule_pending(int *reset_type); 1452f0133f3cSMatt Fleming 1453f0133f3cSMatt Fleming extern int efi_capsule_supported(efi_guid_t guid, u32 flags, 1454f0133f3cSMatt Fleming size_t size, int *reset); 1455f0133f3cSMatt Fleming 1456f0133f3cSMatt Fleming extern int efi_capsule_update(efi_capsule_header_t *capsule, 14572a457fb3SArd Biesheuvel phys_addr_t *pages); 14584fc756bdSMike Waychison 1459926172d4SDave Young #ifdef CONFIG_EFI_RUNTIME_MAP 1460926172d4SDave Young int efi_runtime_map_init(struct kobject *); 14616a2c20e7SVivek Goyal int efi_get_runtime_map_size(void); 14626a2c20e7SVivek Goyal int efi_get_runtime_map_desc_size(void); 14636a2c20e7SVivek Goyal int efi_runtime_map_copy(void *buf, size_t bufsz); 1464926172d4SDave Young #else 1465926172d4SDave Young static inline int efi_runtime_map_init(struct kobject *kobj) 1466926172d4SDave Young { 1467926172d4SDave Young return 0; 1468926172d4SDave Young } 1469926172d4SDave Young 14706a2c20e7SVivek Goyal static inline int efi_get_runtime_map_size(void) 14716a2c20e7SVivek Goyal { 14726a2c20e7SVivek Goyal return 0; 14736a2c20e7SVivek Goyal } 14746a2c20e7SVivek Goyal 14756a2c20e7SVivek Goyal static inline int efi_get_runtime_map_desc_size(void) 14766a2c20e7SVivek Goyal { 14776a2c20e7SVivek Goyal return 0; 14786a2c20e7SVivek Goyal } 14796a2c20e7SVivek Goyal 14806a2c20e7SVivek Goyal static inline int efi_runtime_map_copy(void *buf, size_t bufsz) 14816a2c20e7SVivek Goyal { 14826a2c20e7SVivek Goyal return 0; 14836a2c20e7SVivek Goyal } 14846a2c20e7SVivek Goyal 1485926172d4SDave Young #endif 1486926172d4SDave Young 1487bd669475SArd Biesheuvel /* prototypes shared between arch specific and generic stub code */ 1488bd669475SArd Biesheuvel 14898173ec79SArd Biesheuvel void efi_printk(char *str); 1490bd669475SArd Biesheuvel 1491cd33a5c1SArd Biesheuvel void efi_free(unsigned long size, unsigned long addr); 1492bd669475SArd Biesheuvel 1493cd33a5c1SArd Biesheuvel char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len); 1494bd669475SArd Biesheuvel 1495cd33a5c1SArd Biesheuvel efi_status_t efi_get_memory_map(struct efi_boot_memmap *map); 1496bd669475SArd Biesheuvel 1497cd33a5c1SArd Biesheuvel efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, 1498220dd769SKairui Song unsigned long *addr, unsigned long min); 1499220dd769SKairui Song 1500220dd769SKairui Song static inline 1501cd33a5c1SArd Biesheuvel efi_status_t efi_low_alloc(unsigned long size, unsigned long align, 1502220dd769SKairui Song unsigned long *addr) 1503220dd769SKairui Song { 1504220dd769SKairui Song /* 1505220dd769SKairui Song * Don't allocate at 0x0. It will confuse code that 1506220dd769SKairui Song * checks pointers against NULL. Skip the first 8 1507220dd769SKairui Song * bytes so we start at a nice even number. 1508220dd769SKairui Song */ 1509cd33a5c1SArd Biesheuvel return efi_low_alloc_above(size, align, addr, 0x8); 1510220dd769SKairui Song } 1511bd669475SArd Biesheuvel 1512cd33a5c1SArd Biesheuvel efi_status_t efi_high_alloc(unsigned long size, unsigned long align, 1513bd669475SArd Biesheuvel unsigned long *addr, unsigned long max); 1514bd669475SArd Biesheuvel 1515cd33a5c1SArd Biesheuvel efi_status_t efi_relocate_kernel(unsigned long *image_addr, 1516bd669475SArd Biesheuvel unsigned long image_size, 1517bd669475SArd Biesheuvel unsigned long alloc_size, 1518bd669475SArd Biesheuvel unsigned long preferred_addr, 1519220dd769SKairui Song unsigned long alignment, 1520220dd769SKairui Song unsigned long min_addr); 1521bd669475SArd Biesheuvel 1522cd33a5c1SArd Biesheuvel efi_status_t handle_cmdline_files(efi_loaded_image_t *image, 1523bd669475SArd Biesheuvel char *cmd_line, char *option_string, 1524bd669475SArd Biesheuvel unsigned long max_addr, 1525bd669475SArd Biesheuvel unsigned long *load_addr, 1526bd669475SArd Biesheuvel unsigned long *load_size); 1527bd669475SArd Biesheuvel 152860f38de7SArd Biesheuvel efi_status_t efi_parse_options(char const *cmdline); 15295a17dae4SMatt Fleming 1530cd33a5c1SArd Biesheuvel efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, 15312c23b73cSArd Biesheuvel unsigned long size); 15322c23b73cSArd Biesheuvel 15330082517fSJian-Hong Pan #ifdef CONFIG_EFI 15340082517fSJian-Hong Pan extern bool efi_runtime_disabled(void); 15350082517fSJian-Hong Pan #else 15360082517fSJian-Hong Pan static inline bool efi_runtime_disabled(void) { return true; } 15370082517fSJian-Hong Pan #endif 15380082517fSJian-Hong Pan 153980e75596SAlex Thorlton extern void efi_call_virt_check_flags(unsigned long flags, const char *call); 154013b210ddSJulien Thierry extern unsigned long efi_call_virt_save_flags(void); 154180e75596SAlex Thorlton 1542de8cb458SDavid Howells enum efi_secureboot_mode { 1543de8cb458SDavid Howells efi_secureboot_mode_unset, 1544de8cb458SDavid Howells efi_secureboot_mode_unknown, 1545de8cb458SDavid Howells efi_secureboot_mode_disabled, 1546de8cb458SDavid Howells efi_secureboot_mode_enabled, 1547de8cb458SDavid Howells }; 1548cd33a5c1SArd Biesheuvel enum efi_secureboot_mode efi_get_secureboot(void); 1549de8cb458SDavid Howells 1550ccc829baSMatthew Garrett #ifdef CONFIG_RESET_ATTACK_MITIGATION 1551cd33a5c1SArd Biesheuvel void efi_enable_reset_attack_mitigation(void); 1552ccc829baSMatthew Garrett #else 1553ccc829baSMatthew Garrett static inline void 1554cd33a5c1SArd Biesheuvel efi_enable_reset_attack_mitigation(void) { } 1555ccc829baSMatthew Garrett #endif 1556ccc829baSMatthew Garrett 1557cd33a5c1SArd Biesheuvel efi_status_t efi_random_get_seed(void); 15580d959814SDominik Brodowski 1559cd33a5c1SArd Biesheuvel void efi_retrieve_tpm2_eventlog(void); 156033b6d034SThiebaud Weksteen 156180e75596SAlex Thorlton /* 156280e75596SAlex Thorlton * Arch code can implement the following three template macros, avoiding 156380e75596SAlex Thorlton * reptition for the void/non-void return cases of {__,}efi_call_virt(): 156480e75596SAlex Thorlton * 156580e75596SAlex Thorlton * * arch_efi_call_virt_setup() 156680e75596SAlex Thorlton * 156780e75596SAlex Thorlton * Sets up the environment for the call (e.g. switching page tables, 156880e75596SAlex Thorlton * allowing kernel-mode use of floating point, if required). 156980e75596SAlex Thorlton * 157080e75596SAlex Thorlton * * arch_efi_call_virt() 157180e75596SAlex Thorlton * 157280e75596SAlex Thorlton * Performs the call. The last expression in the macro must be the call 157380e75596SAlex Thorlton * itself, allowing the logic to be shared by the void and non-void 157480e75596SAlex Thorlton * cases. 157580e75596SAlex Thorlton * 157680e75596SAlex Thorlton * * arch_efi_call_virt_teardown() 157780e75596SAlex Thorlton * 157880e75596SAlex Thorlton * Restores the usual kernel environment once the call has returned. 157980e75596SAlex Thorlton */ 158080e75596SAlex Thorlton 158180e75596SAlex Thorlton #define efi_call_virt_pointer(p, f, args...) \ 158280e75596SAlex Thorlton ({ \ 158380e75596SAlex Thorlton efi_status_t __s; \ 158480e75596SAlex Thorlton unsigned long __flags; \ 158580e75596SAlex Thorlton \ 158680e75596SAlex Thorlton arch_efi_call_virt_setup(); \ 158780e75596SAlex Thorlton \ 158813b210ddSJulien Thierry __flags = efi_call_virt_save_flags(); \ 158980e75596SAlex Thorlton __s = arch_efi_call_virt(p, f, args); \ 159080e75596SAlex Thorlton efi_call_virt_check_flags(__flags, __stringify(f)); \ 159180e75596SAlex Thorlton \ 159280e75596SAlex Thorlton arch_efi_call_virt_teardown(); \ 159380e75596SAlex Thorlton \ 159480e75596SAlex Thorlton __s; \ 159580e75596SAlex Thorlton }) 159680e75596SAlex Thorlton 159780e75596SAlex Thorlton #define __efi_call_virt_pointer(p, f, args...) \ 159880e75596SAlex Thorlton ({ \ 159980e75596SAlex Thorlton unsigned long __flags; \ 160080e75596SAlex Thorlton \ 160180e75596SAlex Thorlton arch_efi_call_virt_setup(); \ 160280e75596SAlex Thorlton \ 160313b210ddSJulien Thierry __flags = efi_call_virt_save_flags(); \ 160480e75596SAlex Thorlton arch_efi_call_virt(p, f, args); \ 160580e75596SAlex Thorlton efi_call_virt_check_flags(__flags, __stringify(f)); \ 160680e75596SAlex Thorlton \ 160780e75596SAlex Thorlton arch_efi_call_virt_teardown(); \ 160880e75596SAlex Thorlton }) 160980e75596SAlex Thorlton 1610fc07716bSJeffrey Hugo typedef efi_status_t (*efi_exit_boot_map_processing)( 1611fc07716bSJeffrey Hugo struct efi_boot_memmap *map, 1612fc07716bSJeffrey Hugo void *priv); 1613fc07716bSJeffrey Hugo 1614cd33a5c1SArd Biesheuvel efi_status_t efi_exit_boot_services(void *handle, 1615fc07716bSJeffrey Hugo struct efi_boot_memmap *map, 1616fc07716bSJeffrey Hugo void *priv, 1617fc07716bSJeffrey Hugo efi_exit_boot_map_processing priv_func); 161863625988SArd Biesheuvel 1619c2ceb5fdSArd Biesheuvel #define EFI_RANDOM_SEED_SIZE 64U 1620c2ceb5fdSArd Biesheuvel 162163625988SArd Biesheuvel struct linux_efi_random_seed { 162263625988SArd Biesheuvel u32 size; 162363625988SArd Biesheuvel u8 bits[]; 162463625988SArd Biesheuvel }; 162563625988SArd Biesheuvel 162633b6d034SThiebaud Weksteen struct linux_efi_tpm_eventlog { 162733b6d034SThiebaud Weksteen u32 size; 1628166a2809SMatthew Garrett u32 final_events_preboot_size; 162933b6d034SThiebaud Weksteen u8 version; 163033b6d034SThiebaud Weksteen u8 log[]; 163133b6d034SThiebaud Weksteen }; 163233b6d034SThiebaud Weksteen 163333b6d034SThiebaud Weksteen extern int efi_tpm_eventlog_init(void); 163433b6d034SThiebaud Weksteen 1635c46f3405SMatthew Garrett struct efi_tcg2_final_events_table { 1636c46f3405SMatthew Garrett u64 version; 1637c46f3405SMatthew Garrett u64 nr_events; 1638c46f3405SMatthew Garrett u8 events[]; 1639c46f3405SMatthew Garrett }; 1640c46f3405SMatthew Garrett extern int efi_tpm_final_log_size; 1641c46f3405SMatthew Garrett 16421c5fecb6SNarendra K extern unsigned long rci2_table_phys; 16431c5fecb6SNarendra K 16443425d934SSai Praneeth /* 16453425d934SSai Praneeth * efi_runtime_service() function identifiers. 16463425d934SSai Praneeth * "NONE" is used by efi_recover_from_page_fault() to check if the page 16473425d934SSai Praneeth * fault happened while executing an efi runtime service. 16483425d934SSai Praneeth */ 16499dbbedaaSSai Praneeth enum efi_rts_ids { 16505c418dc7SAnders Roxell EFI_NONE, 16515c418dc7SAnders Roxell EFI_GET_TIME, 16525c418dc7SAnders Roxell EFI_SET_TIME, 16535c418dc7SAnders Roxell EFI_GET_WAKEUP_TIME, 16545c418dc7SAnders Roxell EFI_SET_WAKEUP_TIME, 16555c418dc7SAnders Roxell EFI_GET_VARIABLE, 16565c418dc7SAnders Roxell EFI_GET_NEXT_VARIABLE, 16575c418dc7SAnders Roxell EFI_SET_VARIABLE, 16585c418dc7SAnders Roxell EFI_QUERY_VARIABLE_INFO, 16595c418dc7SAnders Roxell EFI_GET_NEXT_HIGH_MONO_COUNT, 16605c418dc7SAnders Roxell EFI_RESET_SYSTEM, 16615c418dc7SAnders Roxell EFI_UPDATE_CAPSULE, 16625c418dc7SAnders Roxell EFI_QUERY_CAPSULE_CAPS, 16639dbbedaaSSai Praneeth }; 16649dbbedaaSSai Praneeth 16659dbbedaaSSai Praneeth /* 16669dbbedaaSSai Praneeth * efi_runtime_work: Details of EFI Runtime Service work 16679dbbedaaSSai Praneeth * @arg<1-5>: EFI Runtime Service function arguments 16689dbbedaaSSai Praneeth * @status: Status of executing EFI Runtime Service 16699dbbedaaSSai Praneeth * @efi_rts_id: EFI Runtime Service function identifier 16709dbbedaaSSai Praneeth * @efi_rts_comp: Struct used for handling completions 16719dbbedaaSSai Praneeth */ 16729dbbedaaSSai Praneeth struct efi_runtime_work { 16739dbbedaaSSai Praneeth void *arg1; 16749dbbedaaSSai Praneeth void *arg2; 16759dbbedaaSSai Praneeth void *arg3; 16769dbbedaaSSai Praneeth void *arg4; 16779dbbedaaSSai Praneeth void *arg5; 16789dbbedaaSSai Praneeth efi_status_t status; 16799dbbedaaSSai Praneeth struct work_struct work; 16809dbbedaaSSai Praneeth enum efi_rts_ids efi_rts_id; 16819dbbedaaSSai Praneeth struct completion efi_rts_comp; 16829dbbedaaSSai Praneeth }; 16839dbbedaaSSai Praneeth 16849dbbedaaSSai Praneeth extern struct efi_runtime_work efi_rts_work; 16859dbbedaaSSai Praneeth 16863eb420e7SSai Praneeth /* Workqueue to queue EFI Runtime Services */ 16873eb420e7SSai Praneeth extern struct workqueue_struct *efi_rts_wq; 16883eb420e7SSai Praneeth 168971e0940dSArd Biesheuvel struct linux_efi_memreserve { 16905f0b0ecfSArd Biesheuvel int size; // allocated size of the array 16915f0b0ecfSArd Biesheuvel atomic_t count; // number of entries used 16925f0b0ecfSArd Biesheuvel phys_addr_t next; // pa of next struct instance 16935f0b0ecfSArd Biesheuvel struct { 169471e0940dSArd Biesheuvel phys_addr_t base; 169571e0940dSArd Biesheuvel phys_addr_t size; 16965f0b0ecfSArd Biesheuvel } entry[0]; 169771e0940dSArd Biesheuvel }; 169871e0940dSArd Biesheuvel 16995f0b0ecfSArd Biesheuvel #define EFI_MEMRESERVE_SIZE(count) (sizeof(struct linux_efi_memreserve) + \ 17005f0b0ecfSArd Biesheuvel (count) * sizeof(((struct linux_efi_memreserve *)0)->entry[0])) 17015f0b0ecfSArd Biesheuvel 170280424b02SArd Biesheuvel #define EFI_MEMRESERVE_COUNT(size) (((size) - sizeof(struct linux_efi_memreserve)) \ 170380424b02SArd Biesheuvel / sizeof(((struct linux_efi_memreserve *)0)->entry[0])) 170480424b02SArd Biesheuvel 17054444f854SMatthew Garrett void efi_pci_disable_bridge_busmaster(void); 17064444f854SMatthew Garrett 17071da177e4SLinus Torvalds #endif /* _LINUX_EFI_H */ 1708