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 51*89ed4865SArd Biesheuvel #if defined(CONFIG_X86_64) 528f24f8c2SArd Biesheuvel #define __efiapi __attribute__((ms_abi)) 53*89ed4865SArd Biesheuvel #elif defined(CONFIG_X86_32) 54*89ed4865SArd 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; 322f30ca6baSMatt Fleming void *disconnect_controller; 323f30ca6baSMatt Fleming void *open_protocol; 324f30ca6baSMatt Fleming void *close_protocol; 325f30ca6baSMatt Fleming void *open_protocol_information; 326f30ca6baSMatt Fleming void *protocols_per_handle; 327f30ca6baSMatt Fleming void *locate_handle_buffer; 3288f24f8c2SArd Biesheuvel efi_status_t (__efiapi *locate_protocol)(efi_guid_t *, void *, 3298f24f8c2SArd Biesheuvel void **); 330f30ca6baSMatt Fleming void *install_multiple_protocol_interfaces; 331f30ca6baSMatt Fleming void *uninstall_multiple_protocol_interfaces; 332f30ca6baSMatt Fleming void *calculate_crc32; 333f30ca6baSMatt Fleming void *copy_mem; 334f30ca6baSMatt Fleming void *set_mem; 335f30ca6baSMatt Fleming void *create_event_ex; 3361786e830SArd Biesheuvel }; 3371786e830SArd Biesheuvel efi_boot_services_32_t mixed_mode; 338f30ca6baSMatt Fleming } efi_boot_services_t; 339f30ca6baSMatt Fleming 340dd5fc854SMatthew Garrett typedef enum { 341dd5fc854SMatthew Garrett EfiPciIoWidthUint8, 342dd5fc854SMatthew Garrett EfiPciIoWidthUint16, 343dd5fc854SMatthew Garrett EfiPciIoWidthUint32, 344dd5fc854SMatthew Garrett EfiPciIoWidthUint64, 345dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint8, 346dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint16, 347dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint32, 348dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint64, 349dd5fc854SMatthew Garrett EfiPciIoWidthFillUint8, 350dd5fc854SMatthew Garrett EfiPciIoWidthFillUint16, 351dd5fc854SMatthew Garrett EfiPciIoWidthFillUint32, 352dd5fc854SMatthew Garrett EfiPciIoWidthFillUint64, 353dd5fc854SMatthew Garrett EfiPciIoWidthMaximum 354dd5fc854SMatthew Garrett } EFI_PCI_IO_PROTOCOL_WIDTH; 355dd5fc854SMatthew Garrett 356dd5fc854SMatthew Garrett typedef enum { 357dd5fc854SMatthew Garrett EfiPciIoAttributeOperationGet, 358dd5fc854SMatthew Garrett EfiPciIoAttributeOperationSet, 359dd5fc854SMatthew Garrett EfiPciIoAttributeOperationEnable, 360dd5fc854SMatthew Garrett EfiPciIoAttributeOperationDisable, 361dd5fc854SMatthew Garrett EfiPciIoAttributeOperationSupported, 362dd5fc854SMatthew Garrett EfiPciIoAttributeOperationMaximum 363dd5fc854SMatthew Garrett } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; 364dd5fc854SMatthew Garrett 365677703ceSMatt Fleming typedef struct { 366677703ceSMatt Fleming u32 read; 367677703ceSMatt Fleming u32 write; 368677703ceSMatt Fleming } efi_pci_io_protocol_access_32_t; 369677703ceSMatt Fleming 3701786e830SArd Biesheuvel typedef union efi_pci_io_protocol efi_pci_io_protocol_t; 3711786e830SArd Biesheuvel 3721786e830SArd Biesheuvel typedef 3738f24f8c2SArd Biesheuvel efi_status_t (__efiapi *efi_pci_io_protocol_cfg_t)(efi_pci_io_protocol_t *, 3741786e830SArd Biesheuvel EFI_PCI_IO_PROTOCOL_WIDTH, 3758f24f8c2SArd Biesheuvel u32 offset, 3768f24f8c2SArd Biesheuvel unsigned long count, 3771786e830SArd Biesheuvel void *buffer); 3781786e830SArd Biesheuvel 379dd5fc854SMatthew Garrett typedef struct { 380dd5fc854SMatthew Garrett void *read; 381dd5fc854SMatthew Garrett void *write; 382dd5fc854SMatthew Garrett } efi_pci_io_protocol_access_t; 383dd5fc854SMatthew Garrett 384dd5fc854SMatthew Garrett typedef struct { 3851786e830SArd Biesheuvel efi_pci_io_protocol_cfg_t read; 3861786e830SArd Biesheuvel efi_pci_io_protocol_cfg_t write; 3871786e830SArd Biesheuvel } efi_pci_io_protocol_config_access_t; 3881786e830SArd Biesheuvel 3891786e830SArd Biesheuvel union efi_pci_io_protocol { 3901786e830SArd Biesheuvel struct { 391dd5fc854SMatthew Garrett void *poll_mem; 392dd5fc854SMatthew Garrett void *poll_io; 393dd5fc854SMatthew Garrett efi_pci_io_protocol_access_t mem; 394dd5fc854SMatthew Garrett efi_pci_io_protocol_access_t io; 3951786e830SArd Biesheuvel efi_pci_io_protocol_config_access_t pci; 396dd5fc854SMatthew Garrett void *copy_mem; 397dd5fc854SMatthew Garrett void *map; 398dd5fc854SMatthew Garrett void *unmap; 399dd5fc854SMatthew Garrett void *allocate_buffer; 400dd5fc854SMatthew Garrett void *free_buffer; 401dd5fc854SMatthew Garrett void *flush; 4028f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_location)(efi_pci_io_protocol_t *, 403960a8d01SArd Biesheuvel unsigned long *segment_nr, 404960a8d01SArd Biesheuvel unsigned long *bus_nr, 405960a8d01SArd Biesheuvel unsigned long *device_nr, 4068f24f8c2SArd Biesheuvel unsigned long *func_nr); 407dd5fc854SMatthew Garrett void *attributes; 408dd5fc854SMatthew Garrett void *get_bar_attributes; 409dd5fc854SMatthew Garrett void *set_bar_attributes; 410dd5fc854SMatthew Garrett uint64_t romsize; 411dd5fc854SMatthew Garrett void *romimage; 4121786e830SArd Biesheuvel }; 4131786e830SArd Biesheuvel struct { 4141786e830SArd Biesheuvel u32 poll_mem; 4151786e830SArd Biesheuvel u32 poll_io; 4161786e830SArd Biesheuvel efi_pci_io_protocol_access_32_t mem; 4171786e830SArd Biesheuvel efi_pci_io_protocol_access_32_t io; 4181786e830SArd Biesheuvel efi_pci_io_protocol_access_32_t pci; 4191786e830SArd Biesheuvel u32 copy_mem; 4201786e830SArd Biesheuvel u32 map; 4211786e830SArd Biesheuvel u32 unmap; 4221786e830SArd Biesheuvel u32 allocate_buffer; 4231786e830SArd Biesheuvel u32 free_buffer; 4241786e830SArd Biesheuvel u32 flush; 4251786e830SArd Biesheuvel u32 get_location; 4261786e830SArd Biesheuvel u32 attributes; 4271786e830SArd Biesheuvel u32 get_bar_attributes; 4281786e830SArd Biesheuvel u32 set_bar_attributes; 4291786e830SArd Biesheuvel u64 romsize; 4301786e830SArd Biesheuvel u32 romimage; 4311786e830SArd Biesheuvel } mixed_mode; 4321786e830SArd Biesheuvel }; 433dd5fc854SMatthew Garrett 434dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 435dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 436dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 437dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 438dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 439dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 440dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 441dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 442dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 443dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 444dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 445dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 446dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 447dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 448dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 449dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 450dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 451dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 452dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 453dd5fc854SMatthew Garrett 4541786e830SArd Biesheuvel struct efi_dev_path; 4551786e830SArd Biesheuvel 4561786e830SArd Biesheuvel typedef union apple_properties_protocol apple_properties_protocol_t; 4571786e830SArd Biesheuvel 4581786e830SArd Biesheuvel union apple_properties_protocol { 4591786e830SArd Biesheuvel struct { 4601786e830SArd Biesheuvel unsigned long version; 4618f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get)(apple_properties_protocol_t *, 4628f24f8c2SArd Biesheuvel struct efi_dev_path *, 4638f24f8c2SArd Biesheuvel efi_char16_t *, void *, u32 *); 4648f24f8c2SArd Biesheuvel efi_status_t (__efiapi *set)(apple_properties_protocol_t *, 4658f24f8c2SArd Biesheuvel struct efi_dev_path *, 4668f24f8c2SArd Biesheuvel efi_char16_t *, void *, u32); 4678f24f8c2SArd Biesheuvel efi_status_t (__efiapi *del)(apple_properties_protocol_t *, 4688f24f8c2SArd Biesheuvel struct efi_dev_path *, 4698f24f8c2SArd Biesheuvel efi_char16_t *); 4708f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_all)(apple_properties_protocol_t *, 4711786e830SArd Biesheuvel void *buffer, u32 *); 4721786e830SArd Biesheuvel }; 4731786e830SArd Biesheuvel struct { 4741786e830SArd Biesheuvel u32 version; 4751786e830SArd Biesheuvel u32 get; 4761786e830SArd Biesheuvel u32 set; 4771786e830SArd Biesheuvel u32 del; 4781786e830SArd Biesheuvel u32 get_all; 4791786e830SArd Biesheuvel } mixed_mode; 4801786e830SArd Biesheuvel }; 4811786e830SArd Biesheuvel 48233b6d034SThiebaud Weksteen typedef u32 efi_tcg2_event_log_format; 48333b6d034SThiebaud Weksteen 4841786e830SArd Biesheuvel typedef union efi_tcg2_protocol efi_tcg2_protocol_t; 4851786e830SArd Biesheuvel 4861786e830SArd Biesheuvel union efi_tcg2_protocol { 4871786e830SArd Biesheuvel struct { 48833b6d034SThiebaud Weksteen void *get_capability; 4898f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_event_log)(efi_handle_t, 4901786e830SArd Biesheuvel efi_tcg2_event_log_format, 4911786e830SArd Biesheuvel efi_physical_addr_t *, 4921786e830SArd Biesheuvel efi_physical_addr_t *, 4931786e830SArd Biesheuvel efi_bool_t *); 49433b6d034SThiebaud Weksteen void *hash_log_extend_event; 49533b6d034SThiebaud Weksteen void *submit_command; 49633b6d034SThiebaud Weksteen void *get_active_pcr_banks; 49733b6d034SThiebaud Weksteen void *set_active_pcr_banks; 49833b6d034SThiebaud Weksteen void *get_result_of_set_active_pcr_banks; 4991786e830SArd Biesheuvel }; 5001786e830SArd Biesheuvel struct { 5011786e830SArd Biesheuvel u32 get_capability; 5021786e830SArd Biesheuvel u32 get_event_log; 5031786e830SArd Biesheuvel u32 hash_log_extend_event; 5041786e830SArd Biesheuvel u32 submit_command; 5051786e830SArd Biesheuvel u32 get_active_pcr_banks; 5061786e830SArd Biesheuvel u32 set_active_pcr_banks; 5071786e830SArd Biesheuvel u32 get_result_of_set_active_pcr_banks; 5081786e830SArd Biesheuvel } mixed_mode; 5091786e830SArd Biesheuvel }; 51033b6d034SThiebaud Weksteen 511f30ca6baSMatt Fleming /* 5121da177e4SLinus Torvalds * Types and defines for EFI ResetSystem 5131da177e4SLinus Torvalds */ 5141da177e4SLinus Torvalds #define EFI_RESET_COLD 0 5151da177e4SLinus Torvalds #define EFI_RESET_WARM 1 5161da177e4SLinus Torvalds #define EFI_RESET_SHUTDOWN 2 5171da177e4SLinus Torvalds 5181da177e4SLinus Torvalds /* 5191da177e4SLinus Torvalds * EFI Runtime Services table 5201da177e4SLinus Torvalds */ 5211da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL) 5221da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_REVISION 0x00010000 5231da177e4SLinus Torvalds 5241da177e4SLinus Torvalds typedef struct { 5251da177e4SLinus Torvalds efi_table_hdr_t hdr; 526677703ceSMatt Fleming u32 get_time; 527677703ceSMatt Fleming u32 set_time; 528677703ceSMatt Fleming u32 get_wakeup_time; 529677703ceSMatt Fleming u32 set_wakeup_time; 530677703ceSMatt Fleming u32 set_virtual_address_map; 531677703ceSMatt Fleming u32 convert_pointer; 532677703ceSMatt Fleming u32 get_variable; 533677703ceSMatt Fleming u32 get_next_variable; 534677703ceSMatt Fleming u32 set_variable; 535677703ceSMatt Fleming u32 get_next_high_mono_count; 536677703ceSMatt Fleming u32 reset_system; 537677703ceSMatt Fleming u32 update_capsule; 538677703ceSMatt Fleming u32 query_capsule_caps; 539677703ceSMatt Fleming u32 query_variable_info; 540677703ceSMatt Fleming } efi_runtime_services_32_t; 541677703ceSMatt Fleming 542677703ceSMatt Fleming typedef struct { 543677703ceSMatt Fleming efi_table_hdr_t hdr; 544677703ceSMatt Fleming u64 get_time; 545677703ceSMatt Fleming u64 set_time; 546677703ceSMatt Fleming u64 get_wakeup_time; 547677703ceSMatt Fleming u64 set_wakeup_time; 548677703ceSMatt Fleming u64 set_virtual_address_map; 549677703ceSMatt Fleming u64 convert_pointer; 550677703ceSMatt Fleming u64 get_variable; 551677703ceSMatt Fleming u64 get_next_variable; 552677703ceSMatt Fleming u64 set_variable; 553677703ceSMatt Fleming u64 get_next_high_mono_count; 554677703ceSMatt Fleming u64 reset_system; 555677703ceSMatt Fleming u64 update_capsule; 556677703ceSMatt Fleming u64 query_capsule_caps; 557677703ceSMatt Fleming u64 query_variable_info; 558677703ceSMatt Fleming } efi_runtime_services_64_t; 559677703ceSMatt Fleming 5601da177e4SLinus Torvalds typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc); 5611da177e4SLinus Torvalds typedef efi_status_t efi_set_time_t (efi_time_t *tm); 5621da177e4SLinus Torvalds typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending, 5631da177e4SLinus Torvalds efi_time_t *tm); 5641da177e4SLinus Torvalds typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm); 5651da177e4SLinus Torvalds typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr, 5661da177e4SLinus Torvalds unsigned long *data_size, void *data); 5671da177e4SLinus Torvalds typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name, 5681da177e4SLinus Torvalds efi_guid_t *vendor); 5691da177e4SLinus Torvalds typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor, 570f7a2d73fSMatthew Garrett u32 attr, unsigned long data_size, 5711da177e4SLinus Torvalds void *data); 5721da177e4SLinus Torvalds typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count); 5731da177e4SLinus Torvalds typedef void efi_reset_system_t (int reset_type, efi_status_t status, 5741da177e4SLinus Torvalds unsigned long data_size, efi_char16_t *data); 5751da177e4SLinus Torvalds typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size, 5761da177e4SLinus Torvalds unsigned long descriptor_size, 5771da177e4SLinus Torvalds u32 descriptor_version, 5781da177e4SLinus Torvalds efi_memory_desc_t *virtual_map); 5793b370237SMatthew Garrett typedef efi_status_t efi_query_variable_info_t(u32 attr, 5803b370237SMatthew Garrett u64 *storage_space, 5813b370237SMatthew Garrett u64 *remaining_space, 5823b370237SMatthew Garrett u64 *max_variable_size); 5833b370237SMatthew Garrett typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **capsules, 5843b370237SMatthew Garrett unsigned long count, 5853b370237SMatthew Garrett unsigned long sg_list); 5863b370237SMatthew Garrett typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules, 5873b370237SMatthew Garrett unsigned long count, 5883b370237SMatthew Garrett u64 *max_size, 5893b370237SMatthew Garrett int *reset_type); 590ca0e30dcSArd Biesheuvel typedef efi_status_t efi_query_variable_store_t(u32 attributes, 591ca0e30dcSArd Biesheuvel unsigned long size, 592ca0e30dcSArd Biesheuvel bool nonblocking); 5931da177e4SLinus Torvalds 5941786e830SArd Biesheuvel typedef union { 5951786e830SArd Biesheuvel struct { 596c4c39c70SArd Biesheuvel efi_table_hdr_t hdr; 5978f24f8c2SArd Biesheuvel efi_get_time_t __efiapi *get_time; 5988f24f8c2SArd Biesheuvel efi_set_time_t __efiapi *set_time; 5998f24f8c2SArd Biesheuvel efi_get_wakeup_time_t __efiapi *get_wakeup_time; 6008f24f8c2SArd Biesheuvel efi_set_wakeup_time_t __efiapi *set_wakeup_time; 6018f24f8c2SArd Biesheuvel efi_set_virtual_address_map_t __efiapi *set_virtual_address_map; 602c4c39c70SArd Biesheuvel void *convert_pointer; 6038f24f8c2SArd Biesheuvel efi_get_variable_t __efiapi *get_variable; 6048f24f8c2SArd Biesheuvel efi_get_next_variable_t __efiapi *get_next_variable; 6058f24f8c2SArd Biesheuvel efi_set_variable_t __efiapi *set_variable; 6068f24f8c2SArd Biesheuvel efi_get_next_high_mono_count_t __efiapi *get_next_high_mono_count; 6078f24f8c2SArd Biesheuvel efi_reset_system_t __efiapi *reset_system; 6088f24f8c2SArd Biesheuvel efi_update_capsule_t __efiapi *update_capsule; 6098f24f8c2SArd Biesheuvel efi_query_capsule_caps_t __efiapi *query_capsule_caps; 6108f24f8c2SArd Biesheuvel efi_query_variable_info_t __efiapi *query_variable_info; 6111786e830SArd Biesheuvel }; 6121786e830SArd Biesheuvel efi_runtime_services_32_t mixed_mode; 613c4c39c70SArd Biesheuvel } efi_runtime_services_t; 614c4c39c70SArd Biesheuvel 615022ee6c5SArd Biesheuvel void efi_native_runtime_setup(void); 616022ee6c5SArd Biesheuvel 6171da177e4SLinus Torvalds /* 6181da177e4SLinus Torvalds * EFI Configuration Table and GUID definitions 61954fd11feSPeter Jones * 6207fb2b43cSIngo Molnar * These are all defined in a single line to make them easier to 6217fb2b43cSIngo Molnar * grep for and to see them at a glance - while still having a 6227fb2b43cSIngo Molnar * similar structure to the definitions in the spec. 6237fb2b43cSIngo Molnar * 6247fb2b43cSIngo Molnar * Here's how they are structured: 62554fd11feSPeter Jones * 62654fd11feSPeter Jones * GUID: 12345678-1234-1234-1234-123456789012 62754fd11feSPeter Jones * Spec: 62854fd11feSPeter Jones * #define EFI_SOME_PROTOCOL_GUID \ 62954fd11feSPeter Jones * {0x12345678,0x1234,0x1234,\ 63054fd11feSPeter Jones * {0x12,0x34,0x12,0x34,0x56,0x78,0x90,0x12}} 63154fd11feSPeter Jones * Here: 6327fb2b43cSIngo Molnar * #define SOME_PROTOCOL_GUID EFI_GUID(0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12) 6337fb2b43cSIngo Molnar * ^ tabs ^extra space 6347fb2b43cSIngo Molnar * 6357fb2b43cSIngo Molnar * Note that the 'extra space' separates the values at the same place 6367fb2b43cSIngo Molnar * where the UEFI SPEC breaks the line. 6371da177e4SLinus Torvalds */ 6387fb2b43cSIngo Molnar #define NULL_GUID EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) 6397fb2b43cSIngo Molnar #define MPS_TABLE_GUID EFI_GUID(0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 6407fb2b43cSIngo Molnar #define ACPI_TABLE_GUID EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 6417fb2b43cSIngo Molnar #define ACPI_20_TABLE_GUID EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81) 6427fb2b43cSIngo Molnar #define SMBIOS_TABLE_GUID EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 6437fb2b43cSIngo Molnar #define SMBIOS3_TABLE_GUID EFI_GUID(0xf2fd1544, 0x9794, 0x4a2c, 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94) 6447fb2b43cSIngo Molnar #define SAL_SYSTEM_TABLE_GUID EFI_GUID(0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 6457fb2b43cSIngo Molnar #define HCDP_TABLE_GUID EFI_GUID(0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98) 6467fb2b43cSIngo Molnar #define UGA_IO_PROTOCOL_GUID EFI_GUID(0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0x0b, 0x07, 0xa2) 6477fb2b43cSIngo Molnar #define EFI_GLOBAL_VARIABLE_GUID EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c) 6487fb2b43cSIngo Molnar #define UV_SYSTEM_TABLE_GUID EFI_GUID(0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93) 6497fb2b43cSIngo Molnar #define LINUX_EFI_CRASH_GUID EFI_GUID(0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0) 6507fb2b43cSIngo Molnar #define LOADED_IMAGE_PROTOCOL_GUID EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 6517fb2b43cSIngo Molnar #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a) 6527fb2b43cSIngo Molnar #define EFI_UGA_PROTOCOL_GUID EFI_GUID(0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39) 6537fb2b43cSIngo Molnar #define EFI_PCI_IO_PROTOCOL_GUID EFI_GUID(0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a) 6547fb2b43cSIngo Molnar #define EFI_FILE_INFO_ID EFI_GUID(0x09576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 6557fb2b43cSIngo Molnar #define EFI_SYSTEM_RESOURCE_TABLE_GUID EFI_GUID(0xb122a263, 0x3661, 0x4f68, 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80) 6567fb2b43cSIngo Molnar #define EFI_FILE_SYSTEM_GUID EFI_GUID(0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 6577fb2b43cSIngo Molnar #define DEVICE_TREE_GUID EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0) 6587fb2b43cSIngo Molnar #define EFI_PROPERTIES_TABLE_GUID EFI_GUID(0x880aaca3, 0x4adc, 0x4a04, 0x90, 0x79, 0xb7, 0x47, 0x34, 0x08, 0x25, 0xe5) 6597fb2b43cSIngo Molnar #define EFI_RNG_PROTOCOL_GUID EFI_GUID(0x3152bca5, 0xeade, 0x433d, 0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44) 660568bc4e8SArd Biesheuvel #define EFI_RNG_ALGORITHM_RAW EFI_GUID(0xe43176d7, 0xb6e8, 0x4827, 0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61) 6617fb2b43cSIngo Molnar #define EFI_MEMORY_ATTRIBUTES_TABLE_GUID EFI_GUID(0xdcfa911d, 0x26eb, 0x469f, 0xa2, 0x20, 0x38, 0xb7, 0xdc, 0x46, 0x12, 0x20) 6627fb2b43cSIngo Molnar #define EFI_CONSOLE_OUT_DEVICE_GUID EFI_GUID(0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 66358c5475aSLukas Wunner #define APPLE_PROPERTIES_PROTOCOL_GUID EFI_GUID(0x91bd12fe, 0xf6c3, 0x44fb, 0xa5, 0xb7, 0x51, 0x22, 0xab, 0x30, 0x3a, 0xe0) 66433b6d034SThiebaud Weksteen #define EFI_TCG2_PROTOCOL_GUID EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f) 665fc372064SArd Biesheuvel 666e58910cdSJosh Boyer #define EFI_IMAGE_SECURITY_DATABASE_GUID EFI_GUID(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f) 667e58910cdSJosh Boyer #define EFI_SHIM_LOCK_GUID EFI_GUID(0x605dab50, 0xe046, 0x4300, 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23) 668e58910cdSJosh Boyer 6695c126ba2SDave Howells #define EFI_CERT_SHA256_GUID EFI_GUID(0xc1c41626, 0x504c, 0x4092, 0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28) 6705c126ba2SDave Howells #define EFI_CERT_X509_GUID EFI_GUID(0xa5c059a1, 0x94e4, 0x4aa7, 0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72) 6715c126ba2SDave Howells #define EFI_CERT_X509_SHA256_GUID EFI_GUID(0x3bd2a492, 0x96c0, 0x4079, 0xb4, 0x20, 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed) 6725c126ba2SDave Howells 673801820beSArd Biesheuvel /* 674801820beSArd Biesheuvel * This GUID is used to pass to the kernel proper the struct screen_info 675801820beSArd Biesheuvel * structure that was populated by the stub based on the GOP protocol instance 676801820beSArd Biesheuvel * associated with ConOut 677801820beSArd Biesheuvel */ 6787fb2b43cSIngo Molnar #define LINUX_EFI_ARM_SCREEN_INFO_TABLE_GUID EFI_GUID(0xe03fc20a, 0x85dc, 0x406e, 0xb9, 0x0e, 0x4a, 0xb5, 0x02, 0x37, 0x1d, 0x95) 6797fb2b43cSIngo Molnar #define LINUX_EFI_LOADER_ENTRY_GUID EFI_GUID(0x4a67b082, 0x0a4c, 0x41cf, 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f) 68063625988SArd Biesheuvel #define LINUX_EFI_RANDOM_SEED_TABLE_GUID EFI_GUID(0x1ce1e5bc, 0x7ceb, 0x42f2, 0x81, 0xe5, 0x8a, 0xad, 0xf1, 0x80, 0xf5, 0x7b) 68133b6d034SThiebaud Weksteen #define LINUX_EFI_TPM_EVENT_LOG_GUID EFI_GUID(0xb7799cb0, 0xeca2, 0x4943, 0x96, 0x67, 0x1f, 0xae, 0x07, 0xb7, 0x47, 0xfa) 682c46f3405SMatthew Garrett #define LINUX_EFI_TPM_FINAL_LOG_GUID EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25) 68371e0940dSArd Biesheuvel #define LINUX_EFI_MEMRESERVE_TABLE_GUID EFI_GUID(0x888eb0c6, 0x8ede, 0x4ff5, 0xa8, 0xf0, 0x9a, 0xee, 0x5c, 0xb9, 0x77, 0xc2) 68406f7d4a1SCompostella, Jeremy 6851c5fecb6SNarendra K /* OEM GUIDs */ 6861c5fecb6SNarendra K #define DELLEMC_EFI_RCI2_TABLE_GUID EFI_GUID(0x2d9f28a2, 0xa886, 0x456a, 0x97, 0xa8, 0xf1, 0x1e, 0xf2, 0x4f, 0xf4, 0x55) 6871c5fecb6SNarendra K 6881da177e4SLinus Torvalds typedef struct { 6891da177e4SLinus Torvalds efi_guid_t guid; 6901adbfa35SOlof Johansson u64 table; 6911adbfa35SOlof Johansson } efi_config_table_64_t; 6921adbfa35SOlof Johansson 6931adbfa35SOlof Johansson typedef struct { 6941adbfa35SOlof Johansson efi_guid_t guid; 6951adbfa35SOlof Johansson u32 table; 6961adbfa35SOlof Johansson } efi_config_table_32_t; 6971adbfa35SOlof Johansson 6981786e830SArd Biesheuvel typedef union { 6991786e830SArd Biesheuvel struct { 7001adbfa35SOlof Johansson efi_guid_t guid; 701f958efe9SArd Biesheuvel void *table; 7021786e830SArd Biesheuvel }; 7031786e830SArd Biesheuvel efi_config_table_32_t mixed_mode; 7041da177e4SLinus Torvalds } efi_config_table_t; 7051da177e4SLinus Torvalds 706272686bfSLeif Lindholm typedef struct { 707272686bfSLeif Lindholm efi_guid_t guid; 708272686bfSLeif Lindholm const char *name; 709272686bfSLeif Lindholm unsigned long *ptr; 710272686bfSLeif Lindholm } efi_config_table_type_t; 711272686bfSLeif Lindholm 7121da177e4SLinus Torvalds #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) 7131da177e4SLinus Torvalds 7143b370237SMatthew Garrett #define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30)) 7153b370237SMatthew Garrett #define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20)) 7163b370237SMatthew Garrett #define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10)) 7173b370237SMatthew Garrett #define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00)) 7183b370237SMatthew Garrett #define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10)) 7193b370237SMatthew Garrett #define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02)) 7203b370237SMatthew Garrett 7211da177e4SLinus Torvalds typedef struct { 7221da177e4SLinus Torvalds efi_table_hdr_t hdr; 7231adbfa35SOlof Johansson u64 fw_vendor; /* physical addr of CHAR16 vendor string */ 7241adbfa35SOlof Johansson u32 fw_revision; 7251adbfa35SOlof Johansson u32 __pad1; 7261adbfa35SOlof Johansson u64 con_in_handle; 7271adbfa35SOlof Johansson u64 con_in; 7281adbfa35SOlof Johansson u64 con_out_handle; 7291adbfa35SOlof Johansson u64 con_out; 7301adbfa35SOlof Johansson u64 stderr_handle; 7311adbfa35SOlof Johansson u64 stderr; 7321adbfa35SOlof Johansson u64 runtime; 7331adbfa35SOlof Johansson u64 boottime; 7341adbfa35SOlof Johansson u32 nr_tables; 7351adbfa35SOlof Johansson u32 __pad2; 7361adbfa35SOlof Johansson u64 tables; 7371adbfa35SOlof Johansson } efi_system_table_64_t; 7381adbfa35SOlof Johansson 7391adbfa35SOlof Johansson typedef struct { 7401adbfa35SOlof Johansson efi_table_hdr_t hdr; 7411adbfa35SOlof Johansson u32 fw_vendor; /* physical addr of CHAR16 vendor string */ 7421adbfa35SOlof Johansson u32 fw_revision; 7431adbfa35SOlof Johansson u32 con_in_handle; 7441adbfa35SOlof Johansson u32 con_in; 7451adbfa35SOlof Johansson u32 con_out_handle; 7461adbfa35SOlof Johansson u32 con_out; 7471adbfa35SOlof Johansson u32 stderr_handle; 7481adbfa35SOlof Johansson u32 stderr; 7491adbfa35SOlof Johansson u32 runtime; 7501adbfa35SOlof Johansson u32 boottime; 7511adbfa35SOlof Johansson u32 nr_tables; 7521adbfa35SOlof Johansson u32 tables; 7531adbfa35SOlof Johansson } efi_system_table_32_t; 7541adbfa35SOlof Johansson 755960a8d01SArd Biesheuvel typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t; 756960a8d01SArd Biesheuvel 7571786e830SArd Biesheuvel typedef union { 7581786e830SArd Biesheuvel struct { 7591adbfa35SOlof Johansson efi_table_hdr_t hdr; 7601da177e4SLinus Torvalds unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */ 7611da177e4SLinus Torvalds u32 fw_revision; 7621da177e4SLinus Torvalds unsigned long con_in_handle; 7631da177e4SLinus Torvalds unsigned long con_in; 7641da177e4SLinus Torvalds unsigned long con_out_handle; 765960a8d01SArd Biesheuvel efi_simple_text_output_protocol_t *con_out; 7661da177e4SLinus Torvalds unsigned long stderr_handle; 7671da177e4SLinus Torvalds unsigned long stderr; 7681da177e4SLinus Torvalds efi_runtime_services_t *runtime; 769f30ca6baSMatt Fleming efi_boot_services_t *boottime; 7701da177e4SLinus Torvalds unsigned long nr_tables; 7711da177e4SLinus Torvalds unsigned long tables; 7721786e830SArd Biesheuvel }; 7731786e830SArd Biesheuvel efi_system_table_32_t mixed_mode; 7741da177e4SLinus Torvalds } efi_system_table_t; 7751da177e4SLinus Torvalds 7769479c7ceSMatt Fleming /* 7779479c7ceSMatt Fleming * Architecture independent structure for describing a memory map for the 7789479c7ceSMatt Fleming * benefit of efi_memmap_init_early(), saving us the need to pass four 7799479c7ceSMatt Fleming * parameters. 7809479c7ceSMatt Fleming */ 7819479c7ceSMatt Fleming struct efi_memory_map_data { 7829479c7ceSMatt Fleming phys_addr_t phys_map; 7839479c7ceSMatt Fleming unsigned long size; 7849479c7ceSMatt Fleming unsigned long desc_version; 7859479c7ceSMatt Fleming unsigned long desc_size; 7869479c7ceSMatt Fleming }; 7879479c7ceSMatt Fleming 7881da177e4SLinus Torvalds struct efi_memory_map { 78944511fb9SArd Biesheuvel phys_addr_t phys_map; 7907ae65fd3SMatt Tolentino void *map; 7917ae65fd3SMatt Tolentino void *map_end; 7921da177e4SLinus Torvalds int nr_map; 7931da177e4SLinus Torvalds unsigned long desc_version; 7947ae65fd3SMatt Tolentino unsigned long desc_size; 795dca0f971SMatt Fleming bool late; 7961da177e4SLinus Torvalds }; 7971da177e4SLinus Torvalds 79860863c0dSMatt Fleming struct efi_mem_range { 79960863c0dSMatt Fleming struct range range; 80060863c0dSMatt Fleming u64 attribute; 8011da177e4SLinus Torvalds }; 8021da177e4SLinus Torvalds 8030302f71cSMark Salter struct efi_fdt_params { 8040302f71cSMark Salter u64 system_table; 8050302f71cSMark Salter u64 mmap; 8060302f71cSMark Salter u32 mmap_size; 8070302f71cSMark Salter u32 desc_size; 8080302f71cSMark Salter u32 desc_ver; 8090302f71cSMark Salter }; 8100302f71cSMark Salter 81114e900c7SArd Biesheuvel typedef struct { 812677703ceSMatt Fleming u32 revision; 8139fa76ca7SArvind Sankar efi_handle_t parent_handle; 8148e84f345SMatt Fleming efi_system_table_t *system_table; 8159fa76ca7SArvind Sankar efi_handle_t device_handle; 8168e84f345SMatt Fleming void *file_path; 8178e84f345SMatt Fleming void *reserved; 8188e84f345SMatt Fleming u32 load_options_size; 8198e84f345SMatt Fleming void *load_options; 8208e84f345SMatt Fleming void *image_base; 8218e84f345SMatt Fleming __aligned_u64 image_size; 8228e84f345SMatt Fleming unsigned int image_code_type; 8238e84f345SMatt Fleming unsigned int image_data_type; 8248f24f8c2SArd Biesheuvel efi_status_t ( __efiapi *unload)(efi_handle_t image_handle); 82514e900c7SArd Biesheuvel } efi_loaded_image_t; 82655839d51SMatt Fleming 82755839d51SMatt Fleming typedef struct { 82855839d51SMatt Fleming u64 size; 82955839d51SMatt Fleming u64 file_size; 83055839d51SMatt Fleming u64 phys_size; 83155839d51SMatt Fleming efi_time_t create_time; 83255839d51SMatt Fleming efi_time_t last_access_time; 83355839d51SMatt Fleming efi_time_t modification_time; 83455839d51SMatt Fleming __aligned_u64 attribute; 83555839d51SMatt Fleming efi_char16_t filename[1]; 83655839d51SMatt Fleming } efi_file_info_t; 83755839d51SMatt Fleming 83814e900c7SArd Biesheuvel typedef struct efi_file_handle efi_file_handle_t; 8391786e830SArd Biesheuvel 84014e900c7SArd Biesheuvel struct efi_file_handle { 84155839d51SMatt Fleming u64 revision; 8428f24f8c2SArd Biesheuvel efi_status_t (__efiapi *open)(efi_file_handle_t *, 8431786e830SArd Biesheuvel efi_file_handle_t **, 844ed37ddffSRoy Franz efi_char16_t *, u64, u64); 8458f24f8c2SArd Biesheuvel efi_status_t (__efiapi *close)(efi_file_handle_t *); 84655839d51SMatt Fleming void *delete; 8478f24f8c2SArd Biesheuvel efi_status_t (__efiapi *read)(efi_file_handle_t *, 8488f24f8c2SArd Biesheuvel unsigned long *, void *); 84955839d51SMatt Fleming void *write; 85055839d51SMatt Fleming void *get_position; 85155839d51SMatt Fleming void *set_position; 8528f24f8c2SArd Biesheuvel efi_status_t (__efiapi *get_info)(efi_file_handle_t *, 8538f24f8c2SArd Biesheuvel efi_guid_t *, unsigned long *, 8548f24f8c2SArd Biesheuvel void *); 85555839d51SMatt Fleming void *set_info; 85655839d51SMatt Fleming void *flush; 8571786e830SArd Biesheuvel }; 85855839d51SMatt Fleming 85914e900c7SArd Biesheuvel typedef struct efi_file_io_interface efi_file_io_interface_t; 8601786e830SArd Biesheuvel 86114e900c7SArd Biesheuvel struct efi_file_io_interface { 862ed37ddffSRoy Franz u64 revision; 8638f24f8c2SArd Biesheuvel int (__efiapi *open_volume)(efi_file_io_interface_t *, 864ed37ddffSRoy Franz efi_file_handle_t **); 8651786e830SArd Biesheuvel }; 866ed37ddffSRoy Franz 86755839d51SMatt Fleming #define EFI_FILE_MODE_READ 0x0000000000000001 86855839d51SMatt Fleming #define EFI_FILE_MODE_WRITE 0x0000000000000002 86955839d51SMatt Fleming #define EFI_FILE_MODE_CREATE 0x8000000000000000 87055839d51SMatt Fleming 871bf924863SArd Biesheuvel typedef struct { 872bf924863SArd Biesheuvel u32 version; 873bf924863SArd Biesheuvel u32 length; 874bf924863SArd Biesheuvel u64 memory_protection_attribute; 875bf924863SArd Biesheuvel } efi_properties_table_t; 876bf924863SArd Biesheuvel 877bf924863SArd Biesheuvel #define EFI_PROPERTIES_TABLE_VERSION 0x00010000 878bf924863SArd Biesheuvel #define EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA 0x1 879bf924863SArd Biesheuvel 880b2c99e3cSBjorn Helgaas #define EFI_INVALID_TABLE_ADDR (~0UL) 881b2c99e3cSBjorn Helgaas 882a604af07SArd Biesheuvel typedef struct { 883a604af07SArd Biesheuvel u32 version; 884a604af07SArd Biesheuvel u32 num_entries; 885a604af07SArd Biesheuvel u32 desc_size; 886a604af07SArd Biesheuvel u32 reserved; 887a604af07SArd Biesheuvel efi_memory_desc_t entry[0]; 888a604af07SArd Biesheuvel } efi_memory_attributes_table_t; 889a604af07SArd Biesheuvel 8905c126ba2SDave Howells typedef struct { 8915c126ba2SDave Howells efi_guid_t signature_owner; 8925c126ba2SDave Howells u8 signature_data[]; 8935c126ba2SDave Howells } efi_signature_data_t; 8945c126ba2SDave Howells 8955c126ba2SDave Howells typedef struct { 8965c126ba2SDave Howells efi_guid_t signature_type; 8975c126ba2SDave Howells u32 signature_list_size; 8985c126ba2SDave Howells u32 signature_header_size; 8995c126ba2SDave Howells u32 signature_size; 9005c126ba2SDave Howells u8 signature_header[]; 9015c126ba2SDave Howells /* efi_signature_data_t signatures[][] */ 9025c126ba2SDave Howells } efi_signature_list_t; 9035c126ba2SDave Howells 9045c126ba2SDave Howells typedef u8 efi_sha256_hash_t[32]; 9055c126ba2SDave Howells 9065c126ba2SDave Howells typedef struct { 9075c126ba2SDave Howells efi_sha256_hash_t to_be_signed_hash; 9085c126ba2SDave Howells efi_time_t time_of_revocation; 9095c126ba2SDave Howells } efi_cert_x509_sha256_t; 9105c126ba2SDave Howells 9111da177e4SLinus Torvalds /* 9121da177e4SLinus Torvalds * All runtime access to EFI goes through this structure: 9131da177e4SLinus Torvalds */ 9141da177e4SLinus Torvalds extern struct efi { 9151da177e4SLinus Torvalds efi_system_table_t *systab; /* EFI system table */ 9163b370237SMatthew Garrett unsigned int runtime_version; /* Runtime services version */ 917b2c99e3cSBjorn Helgaas unsigned long mps; /* MPS table */ 918b2c99e3cSBjorn Helgaas unsigned long acpi; /* ACPI table (IA64 ext 0.71) */ 919b2c99e3cSBjorn Helgaas unsigned long acpi20; /* ACPI table (ACPI 2.0) */ 920e1ccbbc9SArd Biesheuvel unsigned long smbios; /* SMBIOS table (32 bit entry point) */ 921e1ccbbc9SArd Biesheuvel unsigned long smbios3; /* SMBIOS table (64 bit entry point) */ 922b2c99e3cSBjorn Helgaas unsigned long boot_info; /* boot info table */ 923b2c99e3cSBjorn Helgaas unsigned long hcdp; /* HCDP table */ 924b2c99e3cSBjorn Helgaas unsigned long uga; /* UGA table */ 925a0998eb1SDave Young unsigned long fw_vendor; /* fw_vendor */ 926a0998eb1SDave Young unsigned long runtime; /* runtime table */ 927a0998eb1SDave Young unsigned long config_table; /* config tables */ 9280bb54905SPeter Jones unsigned long esrt; /* ESRT table */ 929bf924863SArd Biesheuvel unsigned long properties_table; /* properties table */ 930a604af07SArd Biesheuvel unsigned long mem_attr_table; /* memory attributes table */ 93163625988SArd Biesheuvel unsigned long rng_seed; /* UEFI firmware random seed */ 93233b6d034SThiebaud Weksteen unsigned long tpm_log; /* TPM2 Event Log table */ 933c46f3405SMatthew Garrett unsigned long tpm_final_log; /* TPM2 Final Events Log table */ 93471e0940dSArd Biesheuvel unsigned long mem_reserve; /* Linux EFI memreserve table */ 9351da177e4SLinus Torvalds efi_get_time_t *get_time; 9361da177e4SLinus Torvalds efi_set_time_t *set_time; 9371da177e4SLinus Torvalds efi_get_wakeup_time_t *get_wakeup_time; 9381da177e4SLinus Torvalds efi_set_wakeup_time_t *set_wakeup_time; 9391da177e4SLinus Torvalds efi_get_variable_t *get_variable; 9401da177e4SLinus Torvalds efi_get_next_variable_t *get_next_variable; 9411da177e4SLinus Torvalds efi_set_variable_t *set_variable; 94270d2a3cfSArd Biesheuvel efi_set_variable_t *set_variable_nonblocking; 9433b370237SMatthew Garrett efi_query_variable_info_t *query_variable_info; 944d3cac1f8SArd Biesheuvel efi_query_variable_info_t *query_variable_info_nonblocking; 9453b370237SMatthew Garrett efi_update_capsule_t *update_capsule; 9463b370237SMatthew Garrett efi_query_capsule_caps_t *query_capsule_caps; 9471da177e4SLinus Torvalds efi_get_next_high_mono_count_t *get_next_high_mono_count; 9481da177e4SLinus Torvalds efi_reset_system_t *reset_system; 9491da177e4SLinus Torvalds efi_set_virtual_address_map_t *set_virtual_address_map; 950884f4f66SMatt Fleming struct efi_memory_map memmap; 9513e909599SMatt Fleming unsigned long flags; 9521da177e4SLinus Torvalds } efi; 9531da177e4SLinus Torvalds 9547e904a91SSai Praneeth extern struct mm_struct efi_mm; 9557e904a91SSai Praneeth 9561da177e4SLinus Torvalds static inline int 9571da177e4SLinus Torvalds efi_guidcmp (efi_guid_t left, efi_guid_t right) 9581da177e4SLinus Torvalds { 9591da177e4SLinus Torvalds return memcmp(&left, &right, sizeof (efi_guid_t)); 9601da177e4SLinus Torvalds } 9611da177e4SLinus Torvalds 9621da177e4SLinus Torvalds static inline char * 96326e02272SBorislav Petkov efi_guid_to_str(efi_guid_t *guid, char *out) 9641da177e4SLinus Torvalds { 965925ede0bSJoe Perches sprintf(out, "%pUl", guid->b); 9661da177e4SLinus Torvalds return out; 9671da177e4SLinus Torvalds } 9681da177e4SLinus Torvalds 9691da177e4SLinus Torvalds extern void efi_init (void); 9701da177e4SLinus Torvalds extern void *efi_get_pal_addr (void); 9711da177e4SLinus Torvalds extern void efi_map_pal_code (void); 9721da177e4SLinus Torvalds extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg); 97370f4f935SArnd Bergmann extern void efi_gettimeofday (struct timespec64 *ts); 9741da177e4SLinus Torvalds extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */ 97578510792SJosh Triplett #ifdef CONFIG_X86 976ca0e30dcSArd Biesheuvel extern efi_status_t efi_query_variable_store(u32 attributes, 977ca0e30dcSArd Biesheuvel unsigned long size, 978ca0e30dcSArd Biesheuvel bool nonblocking); 97978510792SJosh Triplett #else 980a6e4d5a0SMatt Fleming 981ca0e30dcSArd Biesheuvel static inline efi_status_t efi_query_variable_store(u32 attributes, 982ca0e30dcSArd Biesheuvel unsigned long size, 983ca0e30dcSArd Biesheuvel bool nonblocking) 984a6e4d5a0SMatt Fleming { 985a6e4d5a0SMatt Fleming return EFI_SUCCESS; 986a6e4d5a0SMatt Fleming } 98778510792SJosh Triplett #endif 9887bc90e01SJosh Triplett extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); 9899479c7ceSMatt Fleming 99020b1e22dSNicolai Stange extern phys_addr_t __init efi_memmap_alloc(unsigned int num_entries); 9919479c7ceSMatt Fleming extern int __init efi_memmap_init_early(struct efi_memory_map_data *data); 992dca0f971SMatt Fleming extern int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size); 9939479c7ceSMatt Fleming extern void __init efi_memmap_unmap(void); 994c45f4da3SMatt Fleming extern int __init efi_memmap_install(phys_addr_t addr, unsigned int nr_map); 99560863c0dSMatt Fleming extern int __init efi_memmap_split_count(efi_memory_desc_t *md, 99660863c0dSMatt Fleming struct range *range); 99760863c0dSMatt Fleming extern void __init efi_memmap_insert(struct efi_memory_map *old_memmap, 99860863c0dSMatt Fleming void *buf, struct efi_mem_range *mem); 9999479c7ceSMatt Fleming 1000272686bfSLeif Lindholm extern int efi_config_init(efi_config_table_type_t *arch_tables); 10013846c158SPeter Jones #ifdef CONFIG_EFI_ESRT 10020bb54905SPeter Jones extern void __init efi_esrt_init(void); 10033846c158SPeter Jones #else 10043846c158SPeter Jones static inline void efi_esrt_init(void) { } 10053846c158SPeter Jones #endif 10067bb68410SArd Biesheuvel extern int efi_config_parse_tables(void *config_tables, int count, int sz, 10077bb68410SArd Biesheuvel efi_config_table_type_t *arch_tables); 10081da177e4SLinus Torvalds extern u64 efi_get_iobase (void); 1009f99afd08STom Lendacky extern int efi_mem_type(unsigned long phys_addr); 10101da177e4SLinus Torvalds extern u64 efi_mem_attributes (unsigned long phys_addr); 101132e62c63SBjorn Helgaas extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size); 10121da177e4SLinus Torvalds extern int __init efi_uart_console_only (void); 10130bb54905SPeter Jones extern u64 efi_mem_desc_end(efi_memory_desc_t *md); 10140bb54905SPeter Jones extern int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md); 1015816e7612SMatt Fleming extern void efi_mem_reserve(phys_addr_t addr, u64 size); 1016a23d3bb0SArd Biesheuvel extern int efi_mem_reserve_persistent(phys_addr_t addr, u64 size); 10171da177e4SLinus Torvalds extern void efi_initialize_iomem_resources(struct resource *code_resource, 101800bf4098SBernhard Walle struct resource *data_resource, struct resource *bss_resource); 10197968c0e3SLeif Lindholm extern int efi_get_fdt_params(struct efi_fdt_params *params); 10200bb54905SPeter Jones extern struct kobject *efi_kobj; 10211da177e4SLinus Torvalds 102244be28e9SMatt Fleming extern int efi_reboot_quirk_mode; 10230c5ed61aSMatt Fleming extern bool efi_poweroff_required(void); 10240c5ed61aSMatt Fleming 10250f96a99dSTaku Izumi #ifdef CONFIG_EFI_FAKE_MEMMAP 10260f96a99dSTaku Izumi extern void __init efi_fake_memmap(void); 10270f96a99dSTaku Izumi #else 10280f96a99dSTaku Izumi static inline void efi_fake_memmap(void) { } 10290f96a99dSTaku Izumi #endif 10300f96a99dSTaku Izumi 103110f0d2f5SArd Biesheuvel /* 103210f0d2f5SArd Biesheuvel * efi_memattr_perm_setter - arch specific callback function passed into 103310f0d2f5SArd Biesheuvel * efi_memattr_apply_permissions() that updates the 103410f0d2f5SArd Biesheuvel * mapping permissions described by the second 103510f0d2f5SArd Biesheuvel * argument in the page tables referred to by the 103610f0d2f5SArd Biesheuvel * first argument. 103710f0d2f5SArd Biesheuvel */ 103810f0d2f5SArd Biesheuvel typedef int (*efi_memattr_perm_setter)(struct mm_struct *, efi_memory_desc_t *); 103910f0d2f5SArd Biesheuvel 104010f0d2f5SArd Biesheuvel extern int efi_memattr_init(void); 104110f0d2f5SArd Biesheuvel extern int efi_memattr_apply_permissions(struct mm_struct *mm, 104210f0d2f5SArd Biesheuvel efi_memattr_perm_setter fn); 104310f0d2f5SArd Biesheuvel 104402e43c2dSBaoquan He /* 104502e43c2dSBaoquan He * efi_early_memdesc_ptr - get the n-th EFI memmap descriptor 104602e43c2dSBaoquan He * @map: the start of efi memmap 104702e43c2dSBaoquan He * @desc_size: the size of space for each EFI memmap descriptor 104802e43c2dSBaoquan He * @n: the index of efi memmap descriptor 104902e43c2dSBaoquan He * 105002e43c2dSBaoquan He * EFI boot service provides the GetMemoryMap() function to get a copy of the 105102e43c2dSBaoquan He * current memory map which is an array of memory descriptors, each of 105202e43c2dSBaoquan He * which describes a contiguous block of memory. It also gets the size of the 105302e43c2dSBaoquan He * map, and the size of each descriptor, etc. 105402e43c2dSBaoquan He * 105502e43c2dSBaoquan He * Note that per section 6.2 of UEFI Spec 2.6 Errata A, the returned size of 105602e43c2dSBaoquan He * each descriptor might not be equal to sizeof(efi_memory_memdesc_t), 105702e43c2dSBaoquan He * since efi_memory_memdesc_t may be extended in the future. Thus the OS 105802e43c2dSBaoquan He * MUST use the returned size of the descriptor to find the start of each 105902e43c2dSBaoquan He * efi_memory_memdesc_t in the memory map array. This should only be used 106002e43c2dSBaoquan He * during bootup since for_each_efi_memory_desc_xxx() is available after the 106102e43c2dSBaoquan He * kernel initializes the EFI subsystem to set up struct efi_memory_map. 106202e43c2dSBaoquan He */ 106302e43c2dSBaoquan He #define efi_early_memdesc_ptr(map, desc_size, n) \ 106402e43c2dSBaoquan He (efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size))) 106502e43c2dSBaoquan He 1066e885cd80SMark Salter /* Iterate through an efi_memory_map */ 106778ce248fSMatt Fleming #define for_each_efi_memory_desc_in_map(m, md) \ 1068e885cd80SMark Salter for ((md) = (m)->map; \ 1069d4c4fed0SJan Beulich (md) && ((void *)(md) + (m)->desc_size) <= (m)->map_end; \ 1070e885cd80SMark Salter (md) = (void *)(md) + (m)->desc_size) 1071e885cd80SMark Salter 107278ce248fSMatt Fleming /** 107378ce248fSMatt Fleming * for_each_efi_memory_desc - iterate over descriptors in efi.memmap 107478ce248fSMatt Fleming * @md: the efi_memory_desc_t * iterator 107578ce248fSMatt Fleming * 107678ce248fSMatt Fleming * Once the loop finishes @md must not be accessed. 107778ce248fSMatt Fleming */ 107878ce248fSMatt Fleming #define for_each_efi_memory_desc(md) \ 1079884f4f66SMatt Fleming for_each_efi_memory_desc_in_map(&efi.memmap, md) 108078ce248fSMatt Fleming 108198d2a6caSLaszlo Ersek /* 108298d2a6caSLaszlo Ersek * Format an EFI memory descriptor's type and attributes to a user-provided 108398d2a6caSLaszlo Ersek * character buffer, as per snprintf(), and return the buffer. 108498d2a6caSLaszlo Ersek */ 108598d2a6caSLaszlo Ersek char * __init efi_md_typeattr_format(char *buf, size_t size, 108698d2a6caSLaszlo Ersek const efi_memory_desc_t *md); 108798d2a6caSLaszlo Ersek 10880bc9ae39SDave Howells 10890bc9ae39SDave Howells typedef void (*efi_element_handler_t)(const char *source, 10900bc9ae39SDave Howells const void *element_data, 10910bc9ae39SDave Howells size_t element_size); 10920bc9ae39SDave Howells extern int __init parse_efi_signature_list( 10930bc9ae39SDave Howells const char *source, 10940bc9ae39SDave Howells const void *data, size_t size, 10950bc9ae39SDave Howells efi_element_handler_t (*get_handler_for_guid)(const efi_guid_t *)); 10960bc9ae39SDave Howells 10971da177e4SLinus Torvalds /** 10981da177e4SLinus Torvalds * efi_range_is_wc - check the WC bit on an address range 10991da177e4SLinus Torvalds * @start: starting kvirt address 11001da177e4SLinus Torvalds * @len: length of range 11011da177e4SLinus Torvalds * 11021da177e4SLinus Torvalds * Consult the EFI memory map and make sure it's ok to set this range WC. 11031da177e4SLinus Torvalds * Returns true or false. 11041da177e4SLinus Torvalds */ 11051da177e4SLinus Torvalds static inline int efi_range_is_wc(unsigned long start, unsigned long len) 11061da177e4SLinus Torvalds { 1107986a80d5SJesper Juhl unsigned long i; 11081da177e4SLinus Torvalds 11091da177e4SLinus Torvalds for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) { 11101da177e4SLinus Torvalds unsigned long paddr = __pa(start + i); 11111da177e4SLinus Torvalds if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC)) 11121da177e4SLinus Torvalds return 0; 11131da177e4SLinus Torvalds } 11141da177e4SLinus Torvalds /* The range checked out */ 11151da177e4SLinus Torvalds return 1; 11161da177e4SLinus Torvalds } 11171da177e4SLinus Torvalds 11181da177e4SLinus Torvalds #ifdef CONFIG_EFI_PCDP 11191da177e4SLinus Torvalds extern int __init efi_setup_pcdp_console(char *); 11201da177e4SLinus Torvalds #endif 11211da177e4SLinus Torvalds 11221da177e4SLinus Torvalds /* 112383e68189SMatt Fleming * We play games with efi_enabled so that the compiler will, if 112483e68189SMatt Fleming * possible, remove EFI-related code altogether. 11251da177e4SLinus Torvalds */ 112683e68189SMatt Fleming #define EFI_BOOT 0 /* Were we booted from EFI? */ 112783e68189SMatt Fleming #define EFI_CONFIG_TABLES 2 /* Can we use EFI config tables? */ 112883e68189SMatt Fleming #define EFI_RUNTIME_SERVICES 3 /* Can we use runtime services? */ 112983e68189SMatt Fleming #define EFI_MEMMAP 4 /* Can we use EFI memory map? */ 113083e68189SMatt Fleming #define EFI_64BIT 5 /* Is the firmware 64-bit? */ 11319f27bc54SDaniel Kiper #define EFI_PARAVIRT 6 /* Access is via a paravirt interface */ 11329f27bc54SDaniel Kiper #define EFI_ARCH_1 7 /* First arch-specific bit */ 1133fed6cefeSBorislav Petkov #define EFI_DBG 8 /* Print additional debug info at runtime */ 1134a1041713SArd Biesheuvel #define EFI_NX_PE_DATA 9 /* Can runtime data regions be mapped non-executable? */ 1135a19ebf59SSai Praneeth #define EFI_MEM_ATTR 10 /* Did firmware publish an EFI_MEMORY_ATTRIBUTES table? */ 1136b617c526SDan Williams #define EFI_MEM_NO_SOFT_RESERVE 11 /* Is the kernel configured to ignore soft reservations? */ 113783e68189SMatt Fleming 11381da177e4SLinus Torvalds #ifdef CONFIG_EFI 11393e909599SMatt Fleming /* 11403e909599SMatt Fleming * Test whether the above EFI_* bits are enabled. 11413e909599SMatt Fleming */ 11423e909599SMatt Fleming static inline bool efi_enabled(int feature) 114383e68189SMatt Fleming { 11443e909599SMatt Fleming return test_bit(feature, &efi.flags) != 0; 11453e909599SMatt Fleming } 11468562c99cSMatt Fleming extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); 1147b617c526SDan Williams 1148b617c526SDan Williams bool __pure __efi_soft_reserve_enabled(void); 1149b617c526SDan Williams 1150b617c526SDan Williams static inline bool __pure efi_soft_reserve_enabled(void) 1151b617c526SDan Williams { 1152b617c526SDan Williams return IS_ENABLED(CONFIG_EFI_SOFT_RESERVE) 1153b617c526SDan Williams && __efi_soft_reserve_enabled(); 1154b617c526SDan Williams } 11553e909599SMatt Fleming #else 11563e909599SMatt Fleming static inline bool efi_enabled(int feature) 11573e909599SMatt Fleming { 11583e909599SMatt Fleming return false; 115983e68189SMatt Fleming } 11608562c99cSMatt Fleming static inline void 11618562c99cSMatt Fleming efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {} 116287615a34SMatt Fleming 116387615a34SMatt Fleming static inline bool 116487615a34SMatt Fleming efi_capsule_pending(int *reset_type) 116587615a34SMatt Fleming { 116687615a34SMatt Fleming return false; 116787615a34SMatt Fleming } 1168b617c526SDan Williams 1169b617c526SDan Williams static inline bool efi_soft_reserve_enabled(void) 1170b617c526SDan Williams { 1171b617c526SDan Williams return false; 1172b617c526SDan Williams } 11731da177e4SLinus Torvalds #endif 11741da177e4SLinus Torvalds 1175806b0351SMatt Fleming extern int efi_status_to_err(efi_status_t status); 1176806b0351SMatt Fleming 11771da177e4SLinus Torvalds /* 11781da177e4SLinus Torvalds * Variable Attributes 11791da177e4SLinus Torvalds */ 11801da177e4SLinus Torvalds #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001 11811da177e4SLinus Torvalds #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002 11821da177e4SLinus Torvalds #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004 118341b3254cSMatthew Garrett #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008 118441b3254cSMatthew Garrett #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010 118541b3254cSMatthew Garrett #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020 118641b3254cSMatthew Garrett #define EFI_VARIABLE_APPEND_WRITE 0x0000000000000040 11871da177e4SLinus Torvalds 118841b3254cSMatthew Garrett #define EFI_VARIABLE_MASK (EFI_VARIABLE_NON_VOLATILE | \ 118941b3254cSMatthew Garrett EFI_VARIABLE_BOOTSERVICE_ACCESS | \ 119041b3254cSMatthew Garrett EFI_VARIABLE_RUNTIME_ACCESS | \ 119141b3254cSMatthew Garrett EFI_VARIABLE_HARDWARE_ERROR_RECORD | \ 119241b3254cSMatthew Garrett EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \ 119341b3254cSMatthew Garrett EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \ 119441b3254cSMatthew Garrett EFI_VARIABLE_APPEND_WRITE) 11951da177e4SLinus Torvalds /* 1196e14ab23dSMatt Fleming * Length of a GUID string (strlen("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")) 1197e14ab23dSMatt Fleming * not including trailing NUL 1198e14ab23dSMatt Fleming */ 1199ba7e34b1SAndy Shevchenko #define EFI_VARIABLE_GUID_LEN UUID_STRING_LEN 1200e14ab23dSMatt Fleming 1201e14ab23dSMatt Fleming /* 1202e2527a7cSMatt Fleming * The type of search to perform when calling boottime->locate_handle 1203e2527a7cSMatt Fleming */ 1204e2527a7cSMatt Fleming #define EFI_LOCATE_ALL_HANDLES 0 1205e2527a7cSMatt Fleming #define EFI_LOCATE_BY_REGISTER_NOTIFY 1 1206e2527a7cSMatt Fleming #define EFI_LOCATE_BY_PROTOCOL 2 1207e2527a7cSMatt Fleming 1208e2527a7cSMatt Fleming /* 12091da177e4SLinus Torvalds * EFI Device Path information 12101da177e4SLinus Torvalds */ 12111da177e4SLinus Torvalds #define EFI_DEV_HW 0x01 12121da177e4SLinus Torvalds #define EFI_DEV_PCI 1 12131da177e4SLinus Torvalds #define EFI_DEV_PCCARD 2 12141da177e4SLinus Torvalds #define EFI_DEV_MEM_MAPPED 3 12151da177e4SLinus Torvalds #define EFI_DEV_VENDOR 4 12161da177e4SLinus Torvalds #define EFI_DEV_CONTROLLER 5 12171da177e4SLinus Torvalds #define EFI_DEV_ACPI 0x02 12181da177e4SLinus Torvalds #define EFI_DEV_BASIC_ACPI 1 12191da177e4SLinus Torvalds #define EFI_DEV_EXPANDED_ACPI 2 12201da177e4SLinus Torvalds #define EFI_DEV_MSG 0x03 12211da177e4SLinus Torvalds #define EFI_DEV_MSG_ATAPI 1 12221da177e4SLinus Torvalds #define EFI_DEV_MSG_SCSI 2 12231da177e4SLinus Torvalds #define EFI_DEV_MSG_FC 3 12241da177e4SLinus Torvalds #define EFI_DEV_MSG_1394 4 12251da177e4SLinus Torvalds #define EFI_DEV_MSG_USB 5 12261da177e4SLinus Torvalds #define EFI_DEV_MSG_USB_CLASS 15 12271da177e4SLinus Torvalds #define EFI_DEV_MSG_I20 6 12281da177e4SLinus Torvalds #define EFI_DEV_MSG_MAC 11 12291da177e4SLinus Torvalds #define EFI_DEV_MSG_IPV4 12 12301da177e4SLinus Torvalds #define EFI_DEV_MSG_IPV6 13 12311da177e4SLinus Torvalds #define EFI_DEV_MSG_INFINIBAND 9 12321da177e4SLinus Torvalds #define EFI_DEV_MSG_UART 14 12331da177e4SLinus Torvalds #define EFI_DEV_MSG_VENDOR 10 12341da177e4SLinus Torvalds #define EFI_DEV_MEDIA 0x04 12351da177e4SLinus Torvalds #define EFI_DEV_MEDIA_HARD_DRIVE 1 12361da177e4SLinus Torvalds #define EFI_DEV_MEDIA_CDROM 2 12371da177e4SLinus Torvalds #define EFI_DEV_MEDIA_VENDOR 3 12381da177e4SLinus Torvalds #define EFI_DEV_MEDIA_FILE 4 12391da177e4SLinus Torvalds #define EFI_DEV_MEDIA_PROTOCOL 5 12401da177e4SLinus Torvalds #define EFI_DEV_BIOS_BOOT 0x05 12411da177e4SLinus Torvalds #define EFI_DEV_END_PATH 0x7F 12421da177e4SLinus Torvalds #define EFI_DEV_END_PATH2 0xFF 12431da177e4SLinus Torvalds #define EFI_DEV_END_INSTANCE 0x01 12441da177e4SLinus Torvalds #define EFI_DEV_END_ENTIRE 0xFF 12451da177e4SLinus Torvalds 12461da177e4SLinus Torvalds struct efi_generic_dev_path { 12471da177e4SLinus Torvalds u8 type; 12481da177e4SLinus Torvalds u8 sub_type; 12491da177e4SLinus Torvalds u16 length; 12501da177e4SLinus Torvalds } __attribute ((packed)); 12511da177e4SLinus Torvalds 125246cd4b75SLukas Wunner struct efi_dev_path { 125346cd4b75SLukas Wunner u8 type; /* can be replaced with unnamed */ 125446cd4b75SLukas Wunner u8 sub_type; /* struct efi_generic_dev_path; */ 125546cd4b75SLukas Wunner u16 length; /* once we've moved to -std=c11 */ 125646cd4b75SLukas Wunner union { 125746cd4b75SLukas Wunner struct { 125846cd4b75SLukas Wunner u32 hid; 125946cd4b75SLukas Wunner u32 uid; 126046cd4b75SLukas Wunner } acpi; 126146cd4b75SLukas Wunner struct { 126246cd4b75SLukas Wunner u8 fn; 126346cd4b75SLukas Wunner u8 dev; 126446cd4b75SLukas Wunner } pci; 126546cd4b75SLukas Wunner }; 126646cd4b75SLukas Wunner } __attribute ((packed)); 126746cd4b75SLukas Wunner 126846cd4b75SLukas Wunner #if IS_ENABLED(CONFIG_EFI_DEV_PATH_PARSER) 126946cd4b75SLukas Wunner struct device *efi_get_device_by_path(struct efi_dev_path **node, size_t *len); 127046cd4b75SLukas Wunner #endif 127146cd4b75SLukas Wunner 12724a3575fdSHuang, Ying static inline void memrange_efi_to_native(u64 *addr, u64 *npages) 12734a3575fdSHuang, Ying { 12744a3575fdSHuang, Ying *npages = PFN_UP(*addr + (*npages<<EFI_PAGE_SHIFT)) - PFN_DOWN(*addr); 12754a3575fdSHuang, Ying *addr &= PAGE_MASK; 12764a3575fdSHuang, Ying } 12774a3575fdSHuang, Ying 127804851772SMatt Fleming /* 12794fc756bdSMike Waychison * EFI Variable support. 12804fc756bdSMike Waychison * 12814fc756bdSMike Waychison * Different firmware drivers can expose their EFI-like variables using 12824fc756bdSMike Waychison * the following. 12834fc756bdSMike Waychison */ 12844fc756bdSMike Waychison 12854fc756bdSMike Waychison struct efivar_operations { 12864fc756bdSMike Waychison efi_get_variable_t *get_variable; 12874fc756bdSMike Waychison efi_get_next_variable_t *get_next_variable; 12884fc756bdSMike Waychison efi_set_variable_t *set_variable; 128970d2a3cfSArd Biesheuvel efi_set_variable_t *set_variable_nonblocking; 1290a6e4d5a0SMatt Fleming efi_query_variable_store_t *query_variable_store; 12914fc756bdSMike Waychison }; 12924fc756bdSMike Waychison 12934fc756bdSMike Waychison struct efivars { 12944fc756bdSMike Waychison struct kset *kset; 1295605e70c7SLee, Chun-Yi struct kobject *kobject; 12964fc756bdSMike Waychison const struct efivar_operations *ops; 12974fc756bdSMike Waychison }; 12984fc756bdSMike Waychison 1299e14ab23dSMatt Fleming /* 1300e14ab23dSMatt Fleming * The maximum size of VariableName + Data = 1024 1301e14ab23dSMatt Fleming * Therefore, it's reasonable to save that much 1302e14ab23dSMatt Fleming * space in each part of the structure, 1303e14ab23dSMatt Fleming * and we use a page for reading/writing. 1304e14ab23dSMatt Fleming */ 1305e14ab23dSMatt Fleming 1306a5d92ad3SMatt Fleming #define EFI_VAR_NAME_LEN 1024 1307a5d92ad3SMatt Fleming 1308e14ab23dSMatt Fleming struct efi_variable { 1309a5d92ad3SMatt Fleming efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)]; 1310e14ab23dSMatt Fleming efi_guid_t VendorGuid; 1311e14ab23dSMatt Fleming unsigned long DataSize; 1312e14ab23dSMatt Fleming __u8 Data[1024]; 1313e14ab23dSMatt Fleming efi_status_t Status; 1314e14ab23dSMatt Fleming __u32 Attributes; 1315e14ab23dSMatt Fleming } __attribute__((packed)); 1316e14ab23dSMatt Fleming 1317e14ab23dSMatt Fleming struct efivar_entry { 1318e14ab23dSMatt Fleming struct efi_variable var; 1319e14ab23dSMatt Fleming struct list_head list; 1320e14ab23dSMatt Fleming struct kobject kobj; 1321e0d59733SSeiji Aguchi bool scanning; 1322e0d59733SSeiji Aguchi bool deleting; 1323e14ab23dSMatt Fleming }; 1324e14ab23dSMatt Fleming 13251786e830SArd Biesheuvel union efi_simple_text_output_protocol { 13261786e830SArd Biesheuvel struct { 1327ed37ddffSRoy Franz void *reset; 13288f24f8c2SArd Biesheuvel efi_status_t (__efiapi *output_string)(efi_simple_text_output_protocol_t *, 13291786e830SArd Biesheuvel efi_char16_t *); 1330ed37ddffSRoy Franz void *test_string; 1331ed37ddffSRoy Franz }; 13321786e830SArd Biesheuvel struct { 13331786e830SArd Biesheuvel u32 reset; 13341786e830SArd Biesheuvel u32 output_string; 13351786e830SArd Biesheuvel u32 test_string; 13361786e830SArd Biesheuvel } mixed_mode; 13371786e830SArd Biesheuvel }; 1338ed37ddffSRoy Franz 1339fc372064SArd Biesheuvel #define PIXEL_RGB_RESERVED_8BIT_PER_COLOR 0 1340fc372064SArd Biesheuvel #define PIXEL_BGR_RESERVED_8BIT_PER_COLOR 1 1341fc372064SArd Biesheuvel #define PIXEL_BIT_MASK 2 1342fc372064SArd Biesheuvel #define PIXEL_BLT_ONLY 3 1343fc372064SArd Biesheuvel #define PIXEL_FORMAT_MAX 4 1344fc372064SArd Biesheuvel 134544c84b4aSArvind Sankar typedef struct { 1346fc372064SArd Biesheuvel u32 red_mask; 1347fc372064SArd Biesheuvel u32 green_mask; 1348fc372064SArd Biesheuvel u32 blue_mask; 1349fc372064SArd Biesheuvel u32 reserved_mask; 135044c84b4aSArvind Sankar } efi_pixel_bitmask_t; 1351fc372064SArd Biesheuvel 135244c84b4aSArvind Sankar typedef struct { 1353fc372064SArd Biesheuvel u32 version; 1354fc372064SArd Biesheuvel u32 horizontal_resolution; 1355fc372064SArd Biesheuvel u32 vertical_resolution; 1356fc372064SArd Biesheuvel int pixel_format; 135744c84b4aSArvind Sankar efi_pixel_bitmask_t pixel_information; 1358fc372064SArd Biesheuvel u32 pixels_per_scan_line; 135944c84b4aSArvind Sankar } efi_graphics_output_mode_info_t; 1360fc372064SArd Biesheuvel 13611786e830SArd Biesheuvel typedef union efi_graphics_output_protocol_mode efi_graphics_output_protocol_mode_t; 13621786e830SArd Biesheuvel 13631786e830SArd Biesheuvel union efi_graphics_output_protocol_mode { 13641786e830SArd Biesheuvel struct { 1365fc372064SArd Biesheuvel u32 max_mode; 1366fc372064SArd Biesheuvel u32 mode; 136744c84b4aSArvind Sankar efi_graphics_output_mode_info_t *info; 1368fc372064SArd Biesheuvel unsigned long size_of_info; 136944c84b4aSArvind Sankar efi_physical_addr_t frame_buffer_base; 1370fc372064SArd Biesheuvel unsigned long frame_buffer_size; 13711786e830SArd Biesheuvel }; 13721786e830SArd Biesheuvel struct { 13731786e830SArd Biesheuvel u32 max_mode; 13741786e830SArd Biesheuvel u32 mode; 13751786e830SArd Biesheuvel u32 info; 13761786e830SArd Biesheuvel u32 size_of_info; 13771786e830SArd Biesheuvel u64 frame_buffer_base; 13781786e830SArd Biesheuvel u32 frame_buffer_size; 13791786e830SArd Biesheuvel } mixed_mode; 13801786e830SArd Biesheuvel }; 1381fc372064SArd Biesheuvel 13821786e830SArd Biesheuvel typedef union efi_graphics_output_protocol efi_graphics_output_protocol_t; 13831786e830SArd Biesheuvel 13841786e830SArd Biesheuvel union efi_graphics_output_protocol { 13851786e830SArd Biesheuvel struct { 138644c84b4aSArvind Sankar void *query_mode; 138744c84b4aSArvind Sankar void *set_mode; 138844c84b4aSArvind Sankar void *blt; 138944c84b4aSArvind Sankar efi_graphics_output_protocol_mode_t *mode; 13901786e830SArd Biesheuvel }; 13911786e830SArd Biesheuvel struct { 13921786e830SArd Biesheuvel u32 query_mode; 13931786e830SArd Biesheuvel u32 set_mode; 13941786e830SArd Biesheuvel u32 blt; 13951786e830SArd Biesheuvel u32 mode; 13961786e830SArd Biesheuvel } mixed_mode; 13971786e830SArd Biesheuvel }; 1398fc372064SArd Biesheuvel 139904851772SMatt Fleming extern struct list_head efivar_sysfs_list; 140004851772SMatt Fleming 140104851772SMatt Fleming static inline void 140204851772SMatt Fleming efivar_unregister(struct efivar_entry *var) 140304851772SMatt Fleming { 140404851772SMatt Fleming kobject_put(&var->kobj); 140504851772SMatt Fleming } 140604851772SMatt Fleming 1407e14ab23dSMatt Fleming int efivars_register(struct efivars *efivars, 14084fc756bdSMike Waychison const struct efivar_operations *ops, 1409e14ab23dSMatt Fleming struct kobject *kobject); 1410e14ab23dSMatt Fleming int efivars_unregister(struct efivars *efivars); 1411e14ab23dSMatt Fleming struct kobject *efivars_kobject(void); 1412e14ab23dSMatt Fleming 1413e14ab23dSMatt Fleming int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), 14141cfd6316SJulia Lawall void *data, bool duplicates, struct list_head *head); 1415e14ab23dSMatt Fleming 141621b3ddd3SSylvain Chouleur int efivar_entry_add(struct efivar_entry *entry, struct list_head *head); 141721b3ddd3SSylvain Chouleur int efivar_entry_remove(struct efivar_entry *entry); 1418e14ab23dSMatt Fleming 1419e14ab23dSMatt Fleming int __efivar_entry_delete(struct efivar_entry *entry); 1420e14ab23dSMatt Fleming int efivar_entry_delete(struct efivar_entry *entry); 1421e14ab23dSMatt Fleming 1422e14ab23dSMatt Fleming int efivar_entry_size(struct efivar_entry *entry, unsigned long *size); 14238a415b8cSMatt Fleming int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes, 14248a415b8cSMatt Fleming unsigned long *size, void *data); 1425e14ab23dSMatt Fleming int efivar_entry_get(struct efivar_entry *entry, u32 *attributes, 1426e14ab23dSMatt Fleming unsigned long *size, void *data); 1427e14ab23dSMatt Fleming int efivar_entry_set(struct efivar_entry *entry, u32 attributes, 1428e14ab23dSMatt Fleming unsigned long size, void *data, struct list_head *head); 1429e14ab23dSMatt Fleming int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes, 1430e14ab23dSMatt Fleming unsigned long *size, void *data, bool *set); 1431e14ab23dSMatt Fleming int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes, 1432e14ab23dSMatt Fleming bool block, unsigned long size, void *data); 1433e14ab23dSMatt Fleming 143421b3ddd3SSylvain Chouleur int efivar_entry_iter_begin(void); 1435e14ab23dSMatt Fleming void efivar_entry_iter_end(void); 1436e14ab23dSMatt Fleming 1437e14ab23dSMatt Fleming int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *), 1438e14ab23dSMatt Fleming struct list_head *head, void *data, 1439e14ab23dSMatt Fleming struct efivar_entry **prev); 1440e14ab23dSMatt Fleming int efivar_entry_iter(int (*func)(struct efivar_entry *, void *), 1441e14ab23dSMatt Fleming struct list_head *head, void *data); 1442e14ab23dSMatt Fleming 1443e14ab23dSMatt Fleming struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid, 1444e14ab23dSMatt Fleming struct list_head *head, bool remove); 1445e14ab23dSMatt Fleming 14468282f5d9SPeter Jones bool efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data, 14478282f5d9SPeter Jones unsigned long data_size); 1448ed8b0de5SPeter Jones bool efivar_variable_is_removable(efi_guid_t vendor, const char *name, 1449ed8b0de5SPeter Jones size_t len); 1450e14ab23dSMatt Fleming 1451a9499fa7STom Gundersen extern struct work_struct efivar_work; 145204851772SMatt Fleming void efivar_run_worker(void); 145304851772SMatt Fleming 1454a9499fa7STom Gundersen #if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE) 1455e14ab23dSMatt Fleming int efivars_sysfs_init(void); 14564fc756bdSMike Waychison 1457e0d59733SSeiji Aguchi #define EFIVARS_DATA_SIZE_MAX 1024 1458e0d59733SSeiji Aguchi 14594fc756bdSMike Waychison #endif /* CONFIG_EFI_VARS */ 1460f0133f3cSMatt Fleming extern bool efi_capsule_pending(int *reset_type); 1461f0133f3cSMatt Fleming 1462f0133f3cSMatt Fleming extern int efi_capsule_supported(efi_guid_t guid, u32 flags, 1463f0133f3cSMatt Fleming size_t size, int *reset); 1464f0133f3cSMatt Fleming 1465f0133f3cSMatt Fleming extern int efi_capsule_update(efi_capsule_header_t *capsule, 14662a457fb3SArd Biesheuvel phys_addr_t *pages); 14674fc756bdSMike Waychison 1468926172d4SDave Young #ifdef CONFIG_EFI_RUNTIME_MAP 1469926172d4SDave Young int efi_runtime_map_init(struct kobject *); 14706a2c20e7SVivek Goyal int efi_get_runtime_map_size(void); 14716a2c20e7SVivek Goyal int efi_get_runtime_map_desc_size(void); 14726a2c20e7SVivek Goyal int efi_runtime_map_copy(void *buf, size_t bufsz); 1473926172d4SDave Young #else 1474926172d4SDave Young static inline int efi_runtime_map_init(struct kobject *kobj) 1475926172d4SDave Young { 1476926172d4SDave Young return 0; 1477926172d4SDave Young } 1478926172d4SDave Young 14796a2c20e7SVivek Goyal static inline int efi_get_runtime_map_size(void) 14806a2c20e7SVivek Goyal { 14816a2c20e7SVivek Goyal return 0; 14826a2c20e7SVivek Goyal } 14836a2c20e7SVivek Goyal 14846a2c20e7SVivek Goyal static inline int efi_get_runtime_map_desc_size(void) 14856a2c20e7SVivek Goyal { 14866a2c20e7SVivek Goyal return 0; 14876a2c20e7SVivek Goyal } 14886a2c20e7SVivek Goyal 14896a2c20e7SVivek Goyal static inline int efi_runtime_map_copy(void *buf, size_t bufsz) 14906a2c20e7SVivek Goyal { 14916a2c20e7SVivek Goyal return 0; 14926a2c20e7SVivek Goyal } 14936a2c20e7SVivek Goyal 1494926172d4SDave Young #endif 1495926172d4SDave Young 1496bd669475SArd Biesheuvel /* prototypes shared between arch specific and generic stub code */ 1497bd669475SArd Biesheuvel 14988173ec79SArd Biesheuvel void efi_printk(char *str); 1499bd669475SArd Biesheuvel 1500cd33a5c1SArd Biesheuvel void efi_free(unsigned long size, unsigned long addr); 1501bd669475SArd Biesheuvel 1502cd33a5c1SArd Biesheuvel char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len); 1503bd669475SArd Biesheuvel 1504cd33a5c1SArd Biesheuvel efi_status_t efi_get_memory_map(struct efi_boot_memmap *map); 1505bd669475SArd Biesheuvel 1506cd33a5c1SArd Biesheuvel efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, 1507220dd769SKairui Song unsigned long *addr, unsigned long min); 1508220dd769SKairui Song 1509220dd769SKairui Song static inline 1510cd33a5c1SArd Biesheuvel efi_status_t efi_low_alloc(unsigned long size, unsigned long align, 1511220dd769SKairui Song unsigned long *addr) 1512220dd769SKairui Song { 1513220dd769SKairui Song /* 1514220dd769SKairui Song * Don't allocate at 0x0. It will confuse code that 1515220dd769SKairui Song * checks pointers against NULL. Skip the first 8 1516220dd769SKairui Song * bytes so we start at a nice even number. 1517220dd769SKairui Song */ 1518cd33a5c1SArd Biesheuvel return efi_low_alloc_above(size, align, addr, 0x8); 1519220dd769SKairui Song } 1520bd669475SArd Biesheuvel 1521cd33a5c1SArd Biesheuvel efi_status_t efi_high_alloc(unsigned long size, unsigned long align, 1522bd669475SArd Biesheuvel unsigned long *addr, unsigned long max); 1523bd669475SArd Biesheuvel 1524cd33a5c1SArd Biesheuvel efi_status_t efi_relocate_kernel(unsigned long *image_addr, 1525bd669475SArd Biesheuvel unsigned long image_size, 1526bd669475SArd Biesheuvel unsigned long alloc_size, 1527bd669475SArd Biesheuvel unsigned long preferred_addr, 1528220dd769SKairui Song unsigned long alignment, 1529220dd769SKairui Song unsigned long min_addr); 1530bd669475SArd Biesheuvel 1531cd33a5c1SArd Biesheuvel efi_status_t handle_cmdline_files(efi_loaded_image_t *image, 1532bd669475SArd Biesheuvel char *cmd_line, char *option_string, 1533bd669475SArd Biesheuvel unsigned long max_addr, 1534bd669475SArd Biesheuvel unsigned long *load_addr, 1535bd669475SArd Biesheuvel unsigned long *load_size); 1536bd669475SArd Biesheuvel 153760f38de7SArd Biesheuvel efi_status_t efi_parse_options(char const *cmdline); 15385a17dae4SMatt Fleming 1539cd33a5c1SArd Biesheuvel efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, 15402c23b73cSArd Biesheuvel unsigned long size); 15412c23b73cSArd Biesheuvel 15420082517fSJian-Hong Pan #ifdef CONFIG_EFI 15430082517fSJian-Hong Pan extern bool efi_runtime_disabled(void); 15440082517fSJian-Hong Pan #else 15450082517fSJian-Hong Pan static inline bool efi_runtime_disabled(void) { return true; } 15460082517fSJian-Hong Pan #endif 15470082517fSJian-Hong Pan 154880e75596SAlex Thorlton extern void efi_call_virt_check_flags(unsigned long flags, const char *call); 154913b210ddSJulien Thierry extern unsigned long efi_call_virt_save_flags(void); 155080e75596SAlex Thorlton 1551de8cb458SDavid Howells enum efi_secureboot_mode { 1552de8cb458SDavid Howells efi_secureboot_mode_unset, 1553de8cb458SDavid Howells efi_secureboot_mode_unknown, 1554de8cb458SDavid Howells efi_secureboot_mode_disabled, 1555de8cb458SDavid Howells efi_secureboot_mode_enabled, 1556de8cb458SDavid Howells }; 1557cd33a5c1SArd Biesheuvel enum efi_secureboot_mode efi_get_secureboot(void); 1558de8cb458SDavid Howells 1559ccc829baSMatthew Garrett #ifdef CONFIG_RESET_ATTACK_MITIGATION 1560cd33a5c1SArd Biesheuvel void efi_enable_reset_attack_mitigation(void); 1561ccc829baSMatthew Garrett #else 1562ccc829baSMatthew Garrett static inline void 1563cd33a5c1SArd Biesheuvel efi_enable_reset_attack_mitigation(void) { } 1564ccc829baSMatthew Garrett #endif 1565ccc829baSMatthew Garrett 1566cd33a5c1SArd Biesheuvel efi_status_t efi_random_get_seed(void); 15670d959814SDominik Brodowski 1568cd33a5c1SArd Biesheuvel void efi_retrieve_tpm2_eventlog(void); 156933b6d034SThiebaud Weksteen 157080e75596SAlex Thorlton /* 157180e75596SAlex Thorlton * Arch code can implement the following three template macros, avoiding 157280e75596SAlex Thorlton * reptition for the void/non-void return cases of {__,}efi_call_virt(): 157380e75596SAlex Thorlton * 157480e75596SAlex Thorlton * * arch_efi_call_virt_setup() 157580e75596SAlex Thorlton * 157680e75596SAlex Thorlton * Sets up the environment for the call (e.g. switching page tables, 157780e75596SAlex Thorlton * allowing kernel-mode use of floating point, if required). 157880e75596SAlex Thorlton * 157980e75596SAlex Thorlton * * arch_efi_call_virt() 158080e75596SAlex Thorlton * 158180e75596SAlex Thorlton * Performs the call. The last expression in the macro must be the call 158280e75596SAlex Thorlton * itself, allowing the logic to be shared by the void and non-void 158380e75596SAlex Thorlton * cases. 158480e75596SAlex Thorlton * 158580e75596SAlex Thorlton * * arch_efi_call_virt_teardown() 158680e75596SAlex Thorlton * 158780e75596SAlex Thorlton * Restores the usual kernel environment once the call has returned. 158880e75596SAlex Thorlton */ 158980e75596SAlex Thorlton 159080e75596SAlex Thorlton #define efi_call_virt_pointer(p, f, args...) \ 159180e75596SAlex Thorlton ({ \ 159280e75596SAlex Thorlton efi_status_t __s; \ 159380e75596SAlex Thorlton unsigned long __flags; \ 159480e75596SAlex Thorlton \ 159580e75596SAlex Thorlton arch_efi_call_virt_setup(); \ 159680e75596SAlex Thorlton \ 159713b210ddSJulien Thierry __flags = efi_call_virt_save_flags(); \ 159880e75596SAlex Thorlton __s = arch_efi_call_virt(p, f, args); \ 159980e75596SAlex Thorlton efi_call_virt_check_flags(__flags, __stringify(f)); \ 160080e75596SAlex Thorlton \ 160180e75596SAlex Thorlton arch_efi_call_virt_teardown(); \ 160280e75596SAlex Thorlton \ 160380e75596SAlex Thorlton __s; \ 160480e75596SAlex Thorlton }) 160580e75596SAlex Thorlton 160680e75596SAlex Thorlton #define __efi_call_virt_pointer(p, f, args...) \ 160780e75596SAlex Thorlton ({ \ 160880e75596SAlex Thorlton unsigned long __flags; \ 160980e75596SAlex Thorlton \ 161080e75596SAlex Thorlton arch_efi_call_virt_setup(); \ 161180e75596SAlex Thorlton \ 161213b210ddSJulien Thierry __flags = efi_call_virt_save_flags(); \ 161380e75596SAlex Thorlton arch_efi_call_virt(p, f, args); \ 161480e75596SAlex Thorlton efi_call_virt_check_flags(__flags, __stringify(f)); \ 161580e75596SAlex Thorlton \ 161680e75596SAlex Thorlton arch_efi_call_virt_teardown(); \ 161780e75596SAlex Thorlton }) 161880e75596SAlex Thorlton 1619fc07716bSJeffrey Hugo typedef efi_status_t (*efi_exit_boot_map_processing)( 1620fc07716bSJeffrey Hugo struct efi_boot_memmap *map, 1621fc07716bSJeffrey Hugo void *priv); 1622fc07716bSJeffrey Hugo 1623cd33a5c1SArd Biesheuvel efi_status_t efi_exit_boot_services(void *handle, 1624fc07716bSJeffrey Hugo struct efi_boot_memmap *map, 1625fc07716bSJeffrey Hugo void *priv, 1626fc07716bSJeffrey Hugo efi_exit_boot_map_processing priv_func); 162763625988SArd Biesheuvel 1628c2ceb5fdSArd Biesheuvel #define EFI_RANDOM_SEED_SIZE 64U 1629c2ceb5fdSArd Biesheuvel 163063625988SArd Biesheuvel struct linux_efi_random_seed { 163163625988SArd Biesheuvel u32 size; 163263625988SArd Biesheuvel u8 bits[]; 163363625988SArd Biesheuvel }; 163463625988SArd Biesheuvel 163533b6d034SThiebaud Weksteen struct linux_efi_tpm_eventlog { 163633b6d034SThiebaud Weksteen u32 size; 1637166a2809SMatthew Garrett u32 final_events_preboot_size; 163833b6d034SThiebaud Weksteen u8 version; 163933b6d034SThiebaud Weksteen u8 log[]; 164033b6d034SThiebaud Weksteen }; 164133b6d034SThiebaud Weksteen 164233b6d034SThiebaud Weksteen extern int efi_tpm_eventlog_init(void); 164333b6d034SThiebaud Weksteen 1644c46f3405SMatthew Garrett struct efi_tcg2_final_events_table { 1645c46f3405SMatthew Garrett u64 version; 1646c46f3405SMatthew Garrett u64 nr_events; 1647c46f3405SMatthew Garrett u8 events[]; 1648c46f3405SMatthew Garrett }; 1649c46f3405SMatthew Garrett extern int efi_tpm_final_log_size; 1650c46f3405SMatthew Garrett 16511c5fecb6SNarendra K extern unsigned long rci2_table_phys; 16521c5fecb6SNarendra K 16533425d934SSai Praneeth /* 16543425d934SSai Praneeth * efi_runtime_service() function identifiers. 16553425d934SSai Praneeth * "NONE" is used by efi_recover_from_page_fault() to check if the page 16563425d934SSai Praneeth * fault happened while executing an efi runtime service. 16573425d934SSai Praneeth */ 16589dbbedaaSSai Praneeth enum efi_rts_ids { 16595c418dc7SAnders Roxell EFI_NONE, 16605c418dc7SAnders Roxell EFI_GET_TIME, 16615c418dc7SAnders Roxell EFI_SET_TIME, 16625c418dc7SAnders Roxell EFI_GET_WAKEUP_TIME, 16635c418dc7SAnders Roxell EFI_SET_WAKEUP_TIME, 16645c418dc7SAnders Roxell EFI_GET_VARIABLE, 16655c418dc7SAnders Roxell EFI_GET_NEXT_VARIABLE, 16665c418dc7SAnders Roxell EFI_SET_VARIABLE, 16675c418dc7SAnders Roxell EFI_QUERY_VARIABLE_INFO, 16685c418dc7SAnders Roxell EFI_GET_NEXT_HIGH_MONO_COUNT, 16695c418dc7SAnders Roxell EFI_RESET_SYSTEM, 16705c418dc7SAnders Roxell EFI_UPDATE_CAPSULE, 16715c418dc7SAnders Roxell EFI_QUERY_CAPSULE_CAPS, 16729dbbedaaSSai Praneeth }; 16739dbbedaaSSai Praneeth 16749dbbedaaSSai Praneeth /* 16759dbbedaaSSai Praneeth * efi_runtime_work: Details of EFI Runtime Service work 16769dbbedaaSSai Praneeth * @arg<1-5>: EFI Runtime Service function arguments 16779dbbedaaSSai Praneeth * @status: Status of executing EFI Runtime Service 16789dbbedaaSSai Praneeth * @efi_rts_id: EFI Runtime Service function identifier 16799dbbedaaSSai Praneeth * @efi_rts_comp: Struct used for handling completions 16809dbbedaaSSai Praneeth */ 16819dbbedaaSSai Praneeth struct efi_runtime_work { 16829dbbedaaSSai Praneeth void *arg1; 16839dbbedaaSSai Praneeth void *arg2; 16849dbbedaaSSai Praneeth void *arg3; 16859dbbedaaSSai Praneeth void *arg4; 16869dbbedaaSSai Praneeth void *arg5; 16879dbbedaaSSai Praneeth efi_status_t status; 16889dbbedaaSSai Praneeth struct work_struct work; 16899dbbedaaSSai Praneeth enum efi_rts_ids efi_rts_id; 16909dbbedaaSSai Praneeth struct completion efi_rts_comp; 16919dbbedaaSSai Praneeth }; 16929dbbedaaSSai Praneeth 16939dbbedaaSSai Praneeth extern struct efi_runtime_work efi_rts_work; 16949dbbedaaSSai Praneeth 16953eb420e7SSai Praneeth /* Workqueue to queue EFI Runtime Services */ 16963eb420e7SSai Praneeth extern struct workqueue_struct *efi_rts_wq; 16973eb420e7SSai Praneeth 169871e0940dSArd Biesheuvel struct linux_efi_memreserve { 16995f0b0ecfSArd Biesheuvel int size; // allocated size of the array 17005f0b0ecfSArd Biesheuvel atomic_t count; // number of entries used 17015f0b0ecfSArd Biesheuvel phys_addr_t next; // pa of next struct instance 17025f0b0ecfSArd Biesheuvel struct { 170371e0940dSArd Biesheuvel phys_addr_t base; 170471e0940dSArd Biesheuvel phys_addr_t size; 17055f0b0ecfSArd Biesheuvel } entry[0]; 170671e0940dSArd Biesheuvel }; 170771e0940dSArd Biesheuvel 17085f0b0ecfSArd Biesheuvel #define EFI_MEMRESERVE_SIZE(count) (sizeof(struct linux_efi_memreserve) + \ 17095f0b0ecfSArd Biesheuvel (count) * sizeof(((struct linux_efi_memreserve *)0)->entry[0])) 17105f0b0ecfSArd Biesheuvel 171180424b02SArd Biesheuvel #define EFI_MEMRESERVE_COUNT(size) (((size) - sizeof(struct linux_efi_memreserve)) \ 171280424b02SArd Biesheuvel / sizeof(((struct linux_efi_memreserve *)0)->entry[0])) 171380424b02SArd Biesheuvel 17141da177e4SLinus Torvalds #endif /* _LINUX_EFI_H */ 1715