11da177e4SLinus Torvalds #ifndef _LINUX_EFI_H 21da177e4SLinus Torvalds #define _LINUX_EFI_H 31da177e4SLinus Torvalds 41da177e4SLinus Torvalds /* 51da177e4SLinus Torvalds * Extensible Firmware Interface 61da177e4SLinus Torvalds * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * Copyright (C) 1999 VA Linux Systems 91da177e4SLinus Torvalds * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> 101da177e4SLinus Torvalds * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co. 111da177e4SLinus Torvalds * David Mosberger-Tang <davidm@hpl.hp.com> 121da177e4SLinus Torvalds * Stephane Eranian <eranian@hpl.hp.com> 131da177e4SLinus Torvalds */ 141da177e4SLinus Torvalds #include <linux/init.h> 151da177e4SLinus Torvalds #include <linux/string.h> 161da177e4SLinus Torvalds #include <linux/time.h> 171da177e4SLinus Torvalds #include <linux/types.h> 181da177e4SLinus Torvalds #include <linux/proc_fs.h> 191da177e4SLinus Torvalds #include <linux/rtc.h> 201da177e4SLinus Torvalds #include <linux/ioport.h> 214a3575fdSHuang, Ying #include <linux/pfn.h> 225ee9c198SMatthew Garrett #include <linux/pstore.h> 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds #include <asm/page.h> 251da177e4SLinus Torvalds 261da177e4SLinus Torvalds #define EFI_SUCCESS 0 271da177e4SLinus Torvalds #define EFI_LOAD_ERROR ( 1 | (1UL << (BITS_PER_LONG-1))) 281da177e4SLinus Torvalds #define EFI_INVALID_PARAMETER ( 2 | (1UL << (BITS_PER_LONG-1))) 291da177e4SLinus Torvalds #define EFI_UNSUPPORTED ( 3 | (1UL << (BITS_PER_LONG-1))) 301da177e4SLinus Torvalds #define EFI_BAD_BUFFER_SIZE ( 4 | (1UL << (BITS_PER_LONG-1))) 311da177e4SLinus Torvalds #define EFI_BUFFER_TOO_SMALL ( 5 | (1UL << (BITS_PER_LONG-1))) 325d9db883SMatthew Garrett #define EFI_NOT_READY ( 6 | (1UL << (BITS_PER_LONG-1))) 335d9db883SMatthew Garrett #define EFI_DEVICE_ERROR ( 7 | (1UL << (BITS_PER_LONG-1))) 345d9db883SMatthew Garrett #define EFI_WRITE_PROTECTED ( 8 | (1UL << (BITS_PER_LONG-1))) 355d9db883SMatthew Garrett #define EFI_OUT_OF_RESOURCES ( 9 | (1UL << (BITS_PER_LONG-1))) 361da177e4SLinus Torvalds #define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG-1))) 375d9db883SMatthew Garrett #define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG-1))) 381da177e4SLinus Torvalds 391da177e4SLinus Torvalds typedef unsigned long efi_status_t; 401da177e4SLinus Torvalds typedef u8 efi_bool_t; 411da177e4SLinus Torvalds typedef u16 efi_char16_t; /* UNICODE character */ 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds 441da177e4SLinus Torvalds typedef struct { 451da177e4SLinus Torvalds u8 b[16]; 461da177e4SLinus Torvalds } efi_guid_t; 471da177e4SLinus Torvalds 481da177e4SLinus Torvalds #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ 491da177e4SLinus Torvalds ((efi_guid_t) \ 501da177e4SLinus Torvalds {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 511da177e4SLinus Torvalds (b) & 0xff, ((b) >> 8) & 0xff, \ 521da177e4SLinus Torvalds (c) & 0xff, ((c) >> 8) & 0xff, \ 531da177e4SLinus Torvalds (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}) 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds /* 561da177e4SLinus Torvalds * Generic EFI table header 571da177e4SLinus Torvalds */ 581da177e4SLinus Torvalds typedef struct { 591da177e4SLinus Torvalds u64 signature; 601da177e4SLinus Torvalds u32 revision; 611da177e4SLinus Torvalds u32 headersize; 621da177e4SLinus Torvalds u32 crc32; 631da177e4SLinus Torvalds u32 reserved; 641da177e4SLinus Torvalds } efi_table_hdr_t; 651da177e4SLinus Torvalds 661da177e4SLinus Torvalds /* 671da177e4SLinus Torvalds * Memory map descriptor: 681da177e4SLinus Torvalds */ 691da177e4SLinus Torvalds 701da177e4SLinus Torvalds /* Memory types: */ 711da177e4SLinus Torvalds #define EFI_RESERVED_TYPE 0 721da177e4SLinus Torvalds #define EFI_LOADER_CODE 1 731da177e4SLinus Torvalds #define EFI_LOADER_DATA 2 741da177e4SLinus Torvalds #define EFI_BOOT_SERVICES_CODE 3 751da177e4SLinus Torvalds #define EFI_BOOT_SERVICES_DATA 4 761da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_CODE 5 771da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_DATA 6 781da177e4SLinus Torvalds #define EFI_CONVENTIONAL_MEMORY 7 791da177e4SLinus Torvalds #define EFI_UNUSABLE_MEMORY 8 801da177e4SLinus Torvalds #define EFI_ACPI_RECLAIM_MEMORY 9 811da177e4SLinus Torvalds #define EFI_ACPI_MEMORY_NVS 10 821da177e4SLinus Torvalds #define EFI_MEMORY_MAPPED_IO 11 831da177e4SLinus Torvalds #define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12 841da177e4SLinus Torvalds #define EFI_PAL_CODE 13 851da177e4SLinus Torvalds #define EFI_MAX_MEMORY_TYPE 14 861da177e4SLinus Torvalds 871da177e4SLinus Torvalds /* Attribute values: */ 881da177e4SLinus Torvalds #define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */ 891da177e4SLinus Torvalds #define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */ 901da177e4SLinus Torvalds #define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */ 911da177e4SLinus Torvalds #define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */ 921da177e4SLinus Torvalds #define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */ 931da177e4SLinus Torvalds #define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */ 941da177e4SLinus Torvalds #define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */ 951da177e4SLinus Torvalds #define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ 961da177e4SLinus Torvalds #define EFI_MEMORY_DESCRIPTOR_VERSION 1 971da177e4SLinus Torvalds 981da177e4SLinus Torvalds #define EFI_PAGE_SHIFT 12 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds typedef struct { 1011da177e4SLinus Torvalds u32 type; 1021da177e4SLinus Torvalds u32 pad; 1031da177e4SLinus Torvalds u64 phys_addr; 1041da177e4SLinus Torvalds u64 virt_addr; 1051da177e4SLinus Torvalds u64 num_pages; 1061da177e4SLinus Torvalds u64 attribute; 1071da177e4SLinus Torvalds } efi_memory_desc_t; 1081da177e4SLinus Torvalds 1093b370237SMatthew Garrett typedef struct { 1103b370237SMatthew Garrett efi_guid_t guid; 1113b370237SMatthew Garrett u32 headersize; 1123b370237SMatthew Garrett u32 flags; 1133b370237SMatthew Garrett u32 imagesize; 1143b370237SMatthew Garrett } efi_capsule_header_t; 1153b370237SMatthew Garrett 116bb05e4baSMatt Fleming /* 117bb05e4baSMatt Fleming * Allocation types for calls to boottime->allocate_pages. 118bb05e4baSMatt Fleming */ 119bb05e4baSMatt Fleming #define EFI_ALLOCATE_ANY_PAGES 0 120bb05e4baSMatt Fleming #define EFI_ALLOCATE_MAX_ADDRESS 1 121bb05e4baSMatt Fleming #define EFI_ALLOCATE_ADDRESS 2 122bb05e4baSMatt Fleming #define EFI_MAX_ALLOCATE_TYPE 3 123bb05e4baSMatt Fleming 124e088a4adSMatthew Wilcox typedef int (*efi_freemem_callback_t) (u64 start, u64 end, void *arg); 1251da177e4SLinus Torvalds 1261da177e4SLinus Torvalds /* 1271da177e4SLinus Torvalds * Types and defines for Time Services 1281da177e4SLinus Torvalds */ 1291da177e4SLinus Torvalds #define EFI_TIME_ADJUST_DAYLIGHT 0x1 1301da177e4SLinus Torvalds #define EFI_TIME_IN_DAYLIGHT 0x2 1311da177e4SLinus Torvalds #define EFI_UNSPECIFIED_TIMEZONE 0x07ff 1321da177e4SLinus Torvalds 1331da177e4SLinus Torvalds typedef struct { 1341da177e4SLinus Torvalds u16 year; 1351da177e4SLinus Torvalds u8 month; 1361da177e4SLinus Torvalds u8 day; 1371da177e4SLinus Torvalds u8 hour; 1381da177e4SLinus Torvalds u8 minute; 1391da177e4SLinus Torvalds u8 second; 1401da177e4SLinus Torvalds u8 pad1; 1411da177e4SLinus Torvalds u32 nanosecond; 1421da177e4SLinus Torvalds s16 timezone; 1431da177e4SLinus Torvalds u8 daylight; 1441da177e4SLinus Torvalds u8 pad2; 1451da177e4SLinus Torvalds } efi_time_t; 1461da177e4SLinus Torvalds 1471da177e4SLinus Torvalds typedef struct { 1481da177e4SLinus Torvalds u32 resolution; 1491da177e4SLinus Torvalds u32 accuracy; 1501da177e4SLinus Torvalds u8 sets_to_zero; 1511da177e4SLinus Torvalds } efi_time_cap_t; 1521da177e4SLinus Torvalds 1531da177e4SLinus Torvalds /* 154f30ca6baSMatt Fleming * EFI Boot Services table 155f30ca6baSMatt Fleming */ 156f30ca6baSMatt Fleming typedef struct { 157f30ca6baSMatt Fleming efi_table_hdr_t hdr; 158f30ca6baSMatt Fleming void *raise_tpl; 159f30ca6baSMatt Fleming void *restore_tpl; 160f30ca6baSMatt Fleming void *allocate_pages; 161f30ca6baSMatt Fleming void *free_pages; 162f30ca6baSMatt Fleming void *get_memory_map; 163f30ca6baSMatt Fleming void *allocate_pool; 164f30ca6baSMatt Fleming void *free_pool; 165f30ca6baSMatt Fleming void *create_event; 166f30ca6baSMatt Fleming void *set_timer; 167f30ca6baSMatt Fleming void *wait_for_event; 168f30ca6baSMatt Fleming void *signal_event; 169f30ca6baSMatt Fleming void *close_event; 170f30ca6baSMatt Fleming void *check_event; 171f30ca6baSMatt Fleming void *install_protocol_interface; 172f30ca6baSMatt Fleming void *reinstall_protocol_interface; 173f30ca6baSMatt Fleming void *uninstall_protocol_interface; 174f30ca6baSMatt Fleming void *handle_protocol; 175f30ca6baSMatt Fleming void *__reserved; 176f30ca6baSMatt Fleming void *register_protocol_notify; 177f30ca6baSMatt Fleming void *locate_handle; 178f30ca6baSMatt Fleming void *locate_device_path; 179f30ca6baSMatt Fleming void *install_configuration_table; 180f30ca6baSMatt Fleming void *load_image; 181f30ca6baSMatt Fleming void *start_image; 182f30ca6baSMatt Fleming void *exit; 183f30ca6baSMatt Fleming void *unload_image; 184f30ca6baSMatt Fleming void *exit_boot_services; 185f30ca6baSMatt Fleming void *get_next_monotonic_count; 186f30ca6baSMatt Fleming void *stall; 187f30ca6baSMatt Fleming void *set_watchdog_timer; 188f30ca6baSMatt Fleming void *connect_controller; 189f30ca6baSMatt Fleming void *disconnect_controller; 190f30ca6baSMatt Fleming void *open_protocol; 191f30ca6baSMatt Fleming void *close_protocol; 192f30ca6baSMatt Fleming void *open_protocol_information; 193f30ca6baSMatt Fleming void *protocols_per_handle; 194f30ca6baSMatt Fleming void *locate_handle_buffer; 195f30ca6baSMatt Fleming void *locate_protocol; 196f30ca6baSMatt Fleming void *install_multiple_protocol_interfaces; 197f30ca6baSMatt Fleming void *uninstall_multiple_protocol_interfaces; 198f30ca6baSMatt Fleming void *calculate_crc32; 199f30ca6baSMatt Fleming void *copy_mem; 200f30ca6baSMatt Fleming void *set_mem; 201f30ca6baSMatt Fleming void *create_event_ex; 202f30ca6baSMatt Fleming } efi_boot_services_t; 203f30ca6baSMatt Fleming 204dd5fc854SMatthew Garrett typedef enum { 205dd5fc854SMatthew Garrett EfiPciIoWidthUint8, 206dd5fc854SMatthew Garrett EfiPciIoWidthUint16, 207dd5fc854SMatthew Garrett EfiPciIoWidthUint32, 208dd5fc854SMatthew Garrett EfiPciIoWidthUint64, 209dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint8, 210dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint16, 211dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint32, 212dd5fc854SMatthew Garrett EfiPciIoWidthFifoUint64, 213dd5fc854SMatthew Garrett EfiPciIoWidthFillUint8, 214dd5fc854SMatthew Garrett EfiPciIoWidthFillUint16, 215dd5fc854SMatthew Garrett EfiPciIoWidthFillUint32, 216dd5fc854SMatthew Garrett EfiPciIoWidthFillUint64, 217dd5fc854SMatthew Garrett EfiPciIoWidthMaximum 218dd5fc854SMatthew Garrett } EFI_PCI_IO_PROTOCOL_WIDTH; 219dd5fc854SMatthew Garrett 220dd5fc854SMatthew Garrett typedef enum { 221dd5fc854SMatthew Garrett EfiPciIoAttributeOperationGet, 222dd5fc854SMatthew Garrett EfiPciIoAttributeOperationSet, 223dd5fc854SMatthew Garrett EfiPciIoAttributeOperationEnable, 224dd5fc854SMatthew Garrett EfiPciIoAttributeOperationDisable, 225dd5fc854SMatthew Garrett EfiPciIoAttributeOperationSupported, 226dd5fc854SMatthew Garrett EfiPciIoAttributeOperationMaximum 227dd5fc854SMatthew Garrett } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION; 228dd5fc854SMatthew Garrett 229dd5fc854SMatthew Garrett 230dd5fc854SMatthew Garrett typedef struct { 231dd5fc854SMatthew Garrett void *read; 232dd5fc854SMatthew Garrett void *write; 233dd5fc854SMatthew Garrett } efi_pci_io_protocol_access_t; 234dd5fc854SMatthew Garrett 235dd5fc854SMatthew Garrett typedef struct { 236dd5fc854SMatthew Garrett void *poll_mem; 237dd5fc854SMatthew Garrett void *poll_io; 238dd5fc854SMatthew Garrett efi_pci_io_protocol_access_t mem; 239dd5fc854SMatthew Garrett efi_pci_io_protocol_access_t io; 240dd5fc854SMatthew Garrett efi_pci_io_protocol_access_t pci; 241dd5fc854SMatthew Garrett void *copy_mem; 242dd5fc854SMatthew Garrett void *map; 243dd5fc854SMatthew Garrett void *unmap; 244dd5fc854SMatthew Garrett void *allocate_buffer; 245dd5fc854SMatthew Garrett void *free_buffer; 246dd5fc854SMatthew Garrett void *flush; 247dd5fc854SMatthew Garrett void *get_location; 248dd5fc854SMatthew Garrett void *attributes; 249dd5fc854SMatthew Garrett void *get_bar_attributes; 250dd5fc854SMatthew Garrett void *set_bar_attributes; 251dd5fc854SMatthew Garrett uint64_t romsize; 252dd5fc854SMatthew Garrett void *romimage; 253dd5fc854SMatthew Garrett } efi_pci_io_protocol; 254dd5fc854SMatthew Garrett 255dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 256dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 257dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 258dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 259dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 260dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 261dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 262dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 263dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 264dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 265dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 266dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 267dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 268dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 269dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 270dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 271dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 272dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 273dd5fc854SMatthew Garrett #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 274dd5fc854SMatthew Garrett 275f30ca6baSMatt Fleming /* 2761da177e4SLinus Torvalds * Types and defines for EFI ResetSystem 2771da177e4SLinus Torvalds */ 2781da177e4SLinus Torvalds #define EFI_RESET_COLD 0 2791da177e4SLinus Torvalds #define EFI_RESET_WARM 1 2801da177e4SLinus Torvalds #define EFI_RESET_SHUTDOWN 2 2811da177e4SLinus Torvalds 2821da177e4SLinus Torvalds /* 2831da177e4SLinus Torvalds * EFI Runtime Services table 2841da177e4SLinus Torvalds */ 2851da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL) 2861da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_REVISION 0x00010000 2871da177e4SLinus Torvalds 2881da177e4SLinus Torvalds typedef struct { 2891da177e4SLinus Torvalds efi_table_hdr_t hdr; 2901da177e4SLinus Torvalds unsigned long get_time; 2911da177e4SLinus Torvalds unsigned long set_time; 2921da177e4SLinus Torvalds unsigned long get_wakeup_time; 2931da177e4SLinus Torvalds unsigned long set_wakeup_time; 2941da177e4SLinus Torvalds unsigned long set_virtual_address_map; 2951da177e4SLinus Torvalds unsigned long convert_pointer; 2961da177e4SLinus Torvalds unsigned long get_variable; 2971da177e4SLinus Torvalds unsigned long get_next_variable; 2981da177e4SLinus Torvalds unsigned long set_variable; 2991da177e4SLinus Torvalds unsigned long get_next_high_mono_count; 3001da177e4SLinus Torvalds unsigned long reset_system; 3013b370237SMatthew Garrett unsigned long update_capsule; 3023b370237SMatthew Garrett unsigned long query_capsule_caps; 3033b370237SMatthew Garrett unsigned long query_variable_info; 3041da177e4SLinus Torvalds } efi_runtime_services_t; 3051da177e4SLinus Torvalds 3061da177e4SLinus Torvalds typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc); 3071da177e4SLinus Torvalds typedef efi_status_t efi_set_time_t (efi_time_t *tm); 3081da177e4SLinus Torvalds typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending, 3091da177e4SLinus Torvalds efi_time_t *tm); 3101da177e4SLinus Torvalds typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm); 3111da177e4SLinus Torvalds typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr, 3121da177e4SLinus Torvalds unsigned long *data_size, void *data); 3131da177e4SLinus Torvalds typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name, 3141da177e4SLinus Torvalds efi_guid_t *vendor); 3151da177e4SLinus Torvalds typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor, 316f7a2d73fSMatthew Garrett u32 attr, unsigned long data_size, 3171da177e4SLinus Torvalds void *data); 3181da177e4SLinus Torvalds typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count); 3191da177e4SLinus Torvalds typedef void efi_reset_system_t (int reset_type, efi_status_t status, 3201da177e4SLinus Torvalds unsigned long data_size, efi_char16_t *data); 3211da177e4SLinus Torvalds typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size, 3221da177e4SLinus Torvalds unsigned long descriptor_size, 3231da177e4SLinus Torvalds u32 descriptor_version, 3241da177e4SLinus Torvalds efi_memory_desc_t *virtual_map); 3253b370237SMatthew Garrett typedef efi_status_t efi_query_variable_info_t(u32 attr, 3263b370237SMatthew Garrett u64 *storage_space, 3273b370237SMatthew Garrett u64 *remaining_space, 3283b370237SMatthew Garrett u64 *max_variable_size); 3293b370237SMatthew Garrett typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **capsules, 3303b370237SMatthew Garrett unsigned long count, 3313b370237SMatthew Garrett unsigned long sg_list); 3323b370237SMatthew Garrett typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules, 3333b370237SMatthew Garrett unsigned long count, 3343b370237SMatthew Garrett u64 *max_size, 3353b370237SMatthew Garrett int *reset_type); 3361da177e4SLinus Torvalds 3371da177e4SLinus Torvalds /* 3381da177e4SLinus Torvalds * EFI Configuration Table and GUID definitions 3391da177e4SLinus Torvalds */ 3401da177e4SLinus Torvalds #define NULL_GUID \ 3411da177e4SLinus Torvalds EFI_GUID( 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ) 3421da177e4SLinus Torvalds 3431da177e4SLinus Torvalds #define MPS_TABLE_GUID \ 3441da177e4SLinus Torvalds EFI_GUID( 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) 3451da177e4SLinus Torvalds 3461da177e4SLinus Torvalds #define ACPI_TABLE_GUID \ 3471da177e4SLinus Torvalds EFI_GUID( 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) 3481da177e4SLinus Torvalds 3491da177e4SLinus Torvalds #define ACPI_20_TABLE_GUID \ 3501da177e4SLinus Torvalds EFI_GUID( 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 ) 3511da177e4SLinus Torvalds 3521da177e4SLinus Torvalds #define SMBIOS_TABLE_GUID \ 3531da177e4SLinus Torvalds EFI_GUID( 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) 3541da177e4SLinus Torvalds 3551da177e4SLinus Torvalds #define SAL_SYSTEM_TABLE_GUID \ 3561da177e4SLinus Torvalds EFI_GUID( 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) 3571da177e4SLinus Torvalds 3581da177e4SLinus Torvalds #define HCDP_TABLE_GUID \ 3591da177e4SLinus Torvalds EFI_GUID( 0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 ) 3601da177e4SLinus Torvalds 3611da177e4SLinus Torvalds #define UGA_IO_PROTOCOL_GUID \ 3621da177e4SLinus Torvalds EFI_GUID( 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 ) 3631da177e4SLinus Torvalds 3641da177e4SLinus Torvalds #define EFI_GLOBAL_VARIABLE_GUID \ 3651da177e4SLinus Torvalds EFI_GUID( 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c ) 3661da177e4SLinus Torvalds 367a50f70b1SRuss Anderson #define UV_SYSTEM_TABLE_GUID \ 368a50f70b1SRuss Anderson EFI_GUID( 0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 ) 369a50f70b1SRuss Anderson 3705ee9c198SMatthew Garrett #define LINUX_EFI_CRASH_GUID \ 3715ee9c198SMatthew Garrett EFI_GUID( 0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 ) 3725ee9c198SMatthew Garrett 3738e84f345SMatt Fleming #define LOADED_IMAGE_PROTOCOL_GUID \ 3748e84f345SMatt Fleming EFI_GUID( 0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) 3758e84f345SMatt Fleming 3760f7c5d47SMatt Fleming #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ 3770f7c5d47SMatt Fleming EFI_GUID( 0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a ) 3780f7c5d47SMatt Fleming 3790f7c5d47SMatt Fleming #define EFI_UGA_PROTOCOL_GUID \ 3800f7c5d47SMatt Fleming EFI_GUID( 0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 ) 3810f7c5d47SMatt Fleming 3820f7c5d47SMatt Fleming #define EFI_PCI_IO_PROTOCOL_GUID \ 3830f7c5d47SMatt Fleming EFI_GUID( 0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a ) 3840f7c5d47SMatt Fleming 38555839d51SMatt Fleming #define EFI_FILE_INFO_ID \ 38655839d51SMatt Fleming EFI_GUID( 0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) 38755839d51SMatt Fleming 38855839d51SMatt Fleming #define EFI_FILE_SYSTEM_GUID \ 38955839d51SMatt Fleming EFI_GUID( 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) 39055839d51SMatt Fleming 3911da177e4SLinus Torvalds typedef struct { 3921da177e4SLinus Torvalds efi_guid_t guid; 3931adbfa35SOlof Johansson u64 table; 3941adbfa35SOlof Johansson } efi_config_table_64_t; 3951adbfa35SOlof Johansson 3961adbfa35SOlof Johansson typedef struct { 3971adbfa35SOlof Johansson efi_guid_t guid; 3981adbfa35SOlof Johansson u32 table; 3991adbfa35SOlof Johansson } efi_config_table_32_t; 4001adbfa35SOlof Johansson 4011adbfa35SOlof Johansson typedef struct { 4021adbfa35SOlof Johansson efi_guid_t guid; 4031da177e4SLinus Torvalds unsigned long table; 4041da177e4SLinus Torvalds } efi_config_table_t; 4051da177e4SLinus Torvalds 4061da177e4SLinus Torvalds #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) 4071da177e4SLinus Torvalds 4083b370237SMatthew Garrett #define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30)) 4093b370237SMatthew Garrett #define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20)) 4103b370237SMatthew Garrett #define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10)) 4113b370237SMatthew Garrett #define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00)) 4123b370237SMatthew Garrett #define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10)) 4133b370237SMatthew Garrett #define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02)) 4143b370237SMatthew Garrett 4151da177e4SLinus Torvalds typedef struct { 4161da177e4SLinus Torvalds efi_table_hdr_t hdr; 4171adbfa35SOlof Johansson u64 fw_vendor; /* physical addr of CHAR16 vendor string */ 4181adbfa35SOlof Johansson u32 fw_revision; 4191adbfa35SOlof Johansson u32 __pad1; 4201adbfa35SOlof Johansson u64 con_in_handle; 4211adbfa35SOlof Johansson u64 con_in; 4221adbfa35SOlof Johansson u64 con_out_handle; 4231adbfa35SOlof Johansson u64 con_out; 4241adbfa35SOlof Johansson u64 stderr_handle; 4251adbfa35SOlof Johansson u64 stderr; 4261adbfa35SOlof Johansson u64 runtime; 4271adbfa35SOlof Johansson u64 boottime; 4281adbfa35SOlof Johansson u32 nr_tables; 4291adbfa35SOlof Johansson u32 __pad2; 4301adbfa35SOlof Johansson u64 tables; 4311adbfa35SOlof Johansson } efi_system_table_64_t; 4321adbfa35SOlof Johansson 4331adbfa35SOlof Johansson typedef struct { 4341adbfa35SOlof Johansson efi_table_hdr_t hdr; 4351adbfa35SOlof Johansson u32 fw_vendor; /* physical addr of CHAR16 vendor string */ 4361adbfa35SOlof Johansson u32 fw_revision; 4371adbfa35SOlof Johansson u32 con_in_handle; 4381adbfa35SOlof Johansson u32 con_in; 4391adbfa35SOlof Johansson u32 con_out_handle; 4401adbfa35SOlof Johansson u32 con_out; 4411adbfa35SOlof Johansson u32 stderr_handle; 4421adbfa35SOlof Johansson u32 stderr; 4431adbfa35SOlof Johansson u32 runtime; 4441adbfa35SOlof Johansson u32 boottime; 4451adbfa35SOlof Johansson u32 nr_tables; 4461adbfa35SOlof Johansson u32 tables; 4471adbfa35SOlof Johansson } efi_system_table_32_t; 4481adbfa35SOlof Johansson 4491adbfa35SOlof Johansson typedef struct { 4501adbfa35SOlof Johansson efi_table_hdr_t hdr; 4511da177e4SLinus Torvalds unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */ 4521da177e4SLinus Torvalds u32 fw_revision; 4531da177e4SLinus Torvalds unsigned long con_in_handle; 4541da177e4SLinus Torvalds unsigned long con_in; 4551da177e4SLinus Torvalds unsigned long con_out_handle; 4561da177e4SLinus Torvalds unsigned long con_out; 4571da177e4SLinus Torvalds unsigned long stderr_handle; 4581da177e4SLinus Torvalds unsigned long stderr; 4591da177e4SLinus Torvalds efi_runtime_services_t *runtime; 460f30ca6baSMatt Fleming efi_boot_services_t *boottime; 4611da177e4SLinus Torvalds unsigned long nr_tables; 4621da177e4SLinus Torvalds unsigned long tables; 4631da177e4SLinus Torvalds } efi_system_table_t; 4641da177e4SLinus Torvalds 4651da177e4SLinus Torvalds struct efi_memory_map { 4667ae65fd3SMatt Tolentino void *phys_map; 4677ae65fd3SMatt Tolentino void *map; 4687ae65fd3SMatt Tolentino void *map_end; 4691da177e4SLinus Torvalds int nr_map; 4701da177e4SLinus Torvalds unsigned long desc_version; 4717ae65fd3SMatt Tolentino unsigned long desc_size; 4721da177e4SLinus Torvalds }; 4731da177e4SLinus Torvalds 4748e84f345SMatt Fleming typedef struct { 4758e84f345SMatt Fleming u32 revision; 4768e84f345SMatt Fleming void *parent_handle; 4778e84f345SMatt Fleming efi_system_table_t *system_table; 4788e84f345SMatt Fleming void *device_handle; 4798e84f345SMatt Fleming void *file_path; 4808e84f345SMatt Fleming void *reserved; 4818e84f345SMatt Fleming u32 load_options_size; 4828e84f345SMatt Fleming void *load_options; 4838e84f345SMatt Fleming void *image_base; 4848e84f345SMatt Fleming __aligned_u64 image_size; 4858e84f345SMatt Fleming unsigned int image_code_type; 4868e84f345SMatt Fleming unsigned int image_data_type; 4878e84f345SMatt Fleming unsigned long unload; 4888e84f345SMatt Fleming } efi_loaded_image_t; 4898e84f345SMatt Fleming 49055839d51SMatt Fleming typedef struct { 49155839d51SMatt Fleming u64 revision; 49255839d51SMatt Fleming void *open_volume; 49355839d51SMatt Fleming } efi_file_io_interface_t; 49455839d51SMatt Fleming 49555839d51SMatt Fleming typedef struct { 49655839d51SMatt Fleming u64 size; 49755839d51SMatt Fleming u64 file_size; 49855839d51SMatt Fleming u64 phys_size; 49955839d51SMatt Fleming efi_time_t create_time; 50055839d51SMatt Fleming efi_time_t last_access_time; 50155839d51SMatt Fleming efi_time_t modification_time; 50255839d51SMatt Fleming __aligned_u64 attribute; 50355839d51SMatt Fleming efi_char16_t filename[1]; 50455839d51SMatt Fleming } efi_file_info_t; 50555839d51SMatt Fleming 50655839d51SMatt Fleming typedef struct { 50755839d51SMatt Fleming u64 revision; 50855839d51SMatt Fleming void *open; 50955839d51SMatt Fleming void *close; 51055839d51SMatt Fleming void *delete; 51155839d51SMatt Fleming void *read; 51255839d51SMatt Fleming void *write; 51355839d51SMatt Fleming void *get_position; 51455839d51SMatt Fleming void *set_position; 51555839d51SMatt Fleming void *get_info; 51655839d51SMatt Fleming void *set_info; 51755839d51SMatt Fleming void *flush; 51855839d51SMatt Fleming } efi_file_handle_t; 51955839d51SMatt Fleming 52055839d51SMatt Fleming #define EFI_FILE_MODE_READ 0x0000000000000001 52155839d51SMatt Fleming #define EFI_FILE_MODE_WRITE 0x0000000000000002 52255839d51SMatt Fleming #define EFI_FILE_MODE_CREATE 0x8000000000000000 52355839d51SMatt Fleming 524b2c99e3cSBjorn Helgaas #define EFI_INVALID_TABLE_ADDR (~0UL) 525b2c99e3cSBjorn Helgaas 5261da177e4SLinus Torvalds /* 5271da177e4SLinus Torvalds * All runtime access to EFI goes through this structure: 5281da177e4SLinus Torvalds */ 5291da177e4SLinus Torvalds extern struct efi { 5301da177e4SLinus Torvalds efi_system_table_t *systab; /* EFI system table */ 5313b370237SMatthew Garrett unsigned int runtime_version; /* Runtime services version */ 532b2c99e3cSBjorn Helgaas unsigned long mps; /* MPS table */ 533b2c99e3cSBjorn Helgaas unsigned long acpi; /* ACPI table (IA64 ext 0.71) */ 534b2c99e3cSBjorn Helgaas unsigned long acpi20; /* ACPI table (ACPI 2.0) */ 535b2c99e3cSBjorn Helgaas unsigned long smbios; /* SM BIOS table */ 536b2c99e3cSBjorn Helgaas unsigned long sal_systab; /* SAL system table */ 537b2c99e3cSBjorn Helgaas unsigned long boot_info; /* boot info table */ 538b2c99e3cSBjorn Helgaas unsigned long hcdp; /* HCDP table */ 539b2c99e3cSBjorn Helgaas unsigned long uga; /* UGA table */ 540a50f70b1SRuss Anderson unsigned long uv_systab; /* UV system table */ 5411da177e4SLinus Torvalds efi_get_time_t *get_time; 5421da177e4SLinus Torvalds efi_set_time_t *set_time; 5431da177e4SLinus Torvalds efi_get_wakeup_time_t *get_wakeup_time; 5441da177e4SLinus Torvalds efi_set_wakeup_time_t *set_wakeup_time; 5451da177e4SLinus Torvalds efi_get_variable_t *get_variable; 5461da177e4SLinus Torvalds efi_get_next_variable_t *get_next_variable; 5471da177e4SLinus Torvalds efi_set_variable_t *set_variable; 5483b370237SMatthew Garrett efi_query_variable_info_t *query_variable_info; 5493b370237SMatthew Garrett efi_update_capsule_t *update_capsule; 5503b370237SMatthew Garrett efi_query_capsule_caps_t *query_capsule_caps; 5511da177e4SLinus Torvalds efi_get_next_high_mono_count_t *get_next_high_mono_count; 5521da177e4SLinus Torvalds efi_reset_system_t *reset_system; 5531da177e4SLinus Torvalds efi_set_virtual_address_map_t *set_virtual_address_map; 5541da177e4SLinus Torvalds } efi; 5551da177e4SLinus Torvalds 5561da177e4SLinus Torvalds static inline int 5571da177e4SLinus Torvalds efi_guidcmp (efi_guid_t left, efi_guid_t right) 5581da177e4SLinus Torvalds { 5591da177e4SLinus Torvalds return memcmp(&left, &right, sizeof (efi_guid_t)); 5601da177e4SLinus Torvalds } 5611da177e4SLinus Torvalds 5621da177e4SLinus Torvalds static inline char * 5631da177e4SLinus Torvalds efi_guid_unparse(efi_guid_t *guid, char *out) 5641da177e4SLinus Torvalds { 565925ede0bSJoe Perches sprintf(out, "%pUl", guid->b); 5661da177e4SLinus Torvalds return out; 5671da177e4SLinus Torvalds } 5681da177e4SLinus Torvalds 5691da177e4SLinus Torvalds extern void efi_init (void); 5701da177e4SLinus Torvalds extern void *efi_get_pal_addr (void); 5711da177e4SLinus Torvalds extern void efi_map_pal_code (void); 5721da177e4SLinus Torvalds extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg); 5731da177e4SLinus Torvalds extern void efi_gettimeofday (struct timespec *ts); 5741da177e4SLinus Torvalds extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */ 57578510792SJosh Triplett #ifdef CONFIG_X86 5762223af38SJosh Triplett extern void efi_late_init(void); 57778510792SJosh Triplett extern void efi_free_boot_services(void); 57878510792SJosh Triplett #else 5792223af38SJosh Triplett static inline void efi_late_init(void) {} 58078510792SJosh Triplett static inline void efi_free_boot_services(void) {} 58178510792SJosh Triplett #endif 5827bc90e01SJosh Triplett extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr); 5831da177e4SLinus Torvalds extern u64 efi_get_iobase (void); 5841da177e4SLinus Torvalds extern u32 efi_mem_type (unsigned long phys_addr); 5851da177e4SLinus Torvalds extern u64 efi_mem_attributes (unsigned long phys_addr); 58632e62c63SBjorn Helgaas extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size); 5871da177e4SLinus Torvalds extern int __init efi_uart_console_only (void); 5881da177e4SLinus Torvalds extern void efi_initialize_iomem_resources(struct resource *code_resource, 58900bf4098SBernhard Walle struct resource *data_resource, struct resource *bss_resource); 59011520e5eSLinus Torvalds extern unsigned long efi_get_time(void); 59111520e5eSLinus Torvalds extern int efi_set_rtc_mmss(unsigned long nowtime); 592916f676fSMatthew Garrett extern void efi_reserve_boot_services(void); 5931da177e4SLinus Torvalds extern struct efi_memory_map memmap; 5941da177e4SLinus Torvalds 5951da177e4SLinus Torvalds /** 5961da177e4SLinus Torvalds * efi_range_is_wc - check the WC bit on an address range 5971da177e4SLinus Torvalds * @start: starting kvirt address 5981da177e4SLinus Torvalds * @len: length of range 5991da177e4SLinus Torvalds * 6001da177e4SLinus Torvalds * Consult the EFI memory map and make sure it's ok to set this range WC. 6011da177e4SLinus Torvalds * Returns true or false. 6021da177e4SLinus Torvalds */ 6031da177e4SLinus Torvalds static inline int efi_range_is_wc(unsigned long start, unsigned long len) 6041da177e4SLinus Torvalds { 605986a80d5SJesper Juhl unsigned long i; 6061da177e4SLinus Torvalds 6071da177e4SLinus Torvalds for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) { 6081da177e4SLinus Torvalds unsigned long paddr = __pa(start + i); 6091da177e4SLinus Torvalds if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC)) 6101da177e4SLinus Torvalds return 0; 6111da177e4SLinus Torvalds } 6121da177e4SLinus Torvalds /* The range checked out */ 6131da177e4SLinus Torvalds return 1; 6141da177e4SLinus Torvalds } 6151da177e4SLinus Torvalds 6161da177e4SLinus Torvalds #ifdef CONFIG_EFI_PCDP 6171da177e4SLinus Torvalds extern int __init efi_setup_pcdp_console(char *); 6181da177e4SLinus Torvalds #endif 6191da177e4SLinus Torvalds 6201da177e4SLinus Torvalds /* 621*83e68189SMatt Fleming * We play games with efi_enabled so that the compiler will, if 622*83e68189SMatt Fleming * possible, remove EFI-related code altogether. 6231da177e4SLinus Torvalds */ 624*83e68189SMatt Fleming #define EFI_BOOT 0 /* Were we booted from EFI? */ 625*83e68189SMatt Fleming #define EFI_SYSTEM_TABLES 1 /* Can we use EFI system tables? */ 626*83e68189SMatt Fleming #define EFI_CONFIG_TABLES 2 /* Can we use EFI config tables? */ 627*83e68189SMatt Fleming #define EFI_RUNTIME_SERVICES 3 /* Can we use runtime services? */ 628*83e68189SMatt Fleming #define EFI_MEMMAP 4 /* Can we use EFI memory map? */ 629*83e68189SMatt Fleming #define EFI_64BIT 5 /* Is the firmware 64-bit? */ 630*83e68189SMatt Fleming 6311da177e4SLinus Torvalds #ifdef CONFIG_EFI 6321da177e4SLinus Torvalds # ifdef CONFIG_X86 633*83e68189SMatt Fleming extern int efi_enabled(int facility); 6341da177e4SLinus Torvalds # else 635*83e68189SMatt Fleming static inline int efi_enabled(int facility) 636*83e68189SMatt Fleming { 637*83e68189SMatt Fleming return 1; 638*83e68189SMatt Fleming } 6391da177e4SLinus Torvalds # endif 6401da177e4SLinus Torvalds #else 641*83e68189SMatt Fleming static inline int efi_enabled(int facility) 642*83e68189SMatt Fleming { 643*83e68189SMatt Fleming return 0; 644*83e68189SMatt Fleming } 6451da177e4SLinus Torvalds #endif 6461da177e4SLinus Torvalds 6471da177e4SLinus Torvalds /* 6481da177e4SLinus Torvalds * Variable Attributes 6491da177e4SLinus Torvalds */ 6501da177e4SLinus Torvalds #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001 6511da177e4SLinus Torvalds #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002 6521da177e4SLinus Torvalds #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004 65341b3254cSMatthew Garrett #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008 65441b3254cSMatthew Garrett #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010 65541b3254cSMatthew Garrett #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020 65641b3254cSMatthew Garrett #define EFI_VARIABLE_APPEND_WRITE 0x0000000000000040 6571da177e4SLinus Torvalds 65841b3254cSMatthew Garrett #define EFI_VARIABLE_MASK (EFI_VARIABLE_NON_VOLATILE | \ 65941b3254cSMatthew Garrett EFI_VARIABLE_BOOTSERVICE_ACCESS | \ 66041b3254cSMatthew Garrett EFI_VARIABLE_RUNTIME_ACCESS | \ 66141b3254cSMatthew Garrett EFI_VARIABLE_HARDWARE_ERROR_RECORD | \ 66241b3254cSMatthew Garrett EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \ 66341b3254cSMatthew Garrett EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \ 66441b3254cSMatthew Garrett EFI_VARIABLE_APPEND_WRITE) 6651da177e4SLinus Torvalds /* 666e2527a7cSMatt Fleming * The type of search to perform when calling boottime->locate_handle 667e2527a7cSMatt Fleming */ 668e2527a7cSMatt Fleming #define EFI_LOCATE_ALL_HANDLES 0 669e2527a7cSMatt Fleming #define EFI_LOCATE_BY_REGISTER_NOTIFY 1 670e2527a7cSMatt Fleming #define EFI_LOCATE_BY_PROTOCOL 2 671e2527a7cSMatt Fleming 672e2527a7cSMatt Fleming /* 6731da177e4SLinus Torvalds * EFI Device Path information 6741da177e4SLinus Torvalds */ 6751da177e4SLinus Torvalds #define EFI_DEV_HW 0x01 6761da177e4SLinus Torvalds #define EFI_DEV_PCI 1 6771da177e4SLinus Torvalds #define EFI_DEV_PCCARD 2 6781da177e4SLinus Torvalds #define EFI_DEV_MEM_MAPPED 3 6791da177e4SLinus Torvalds #define EFI_DEV_VENDOR 4 6801da177e4SLinus Torvalds #define EFI_DEV_CONTROLLER 5 6811da177e4SLinus Torvalds #define EFI_DEV_ACPI 0x02 6821da177e4SLinus Torvalds #define EFI_DEV_BASIC_ACPI 1 6831da177e4SLinus Torvalds #define EFI_DEV_EXPANDED_ACPI 2 6841da177e4SLinus Torvalds #define EFI_DEV_MSG 0x03 6851da177e4SLinus Torvalds #define EFI_DEV_MSG_ATAPI 1 6861da177e4SLinus Torvalds #define EFI_DEV_MSG_SCSI 2 6871da177e4SLinus Torvalds #define EFI_DEV_MSG_FC 3 6881da177e4SLinus Torvalds #define EFI_DEV_MSG_1394 4 6891da177e4SLinus Torvalds #define EFI_DEV_MSG_USB 5 6901da177e4SLinus Torvalds #define EFI_DEV_MSG_USB_CLASS 15 6911da177e4SLinus Torvalds #define EFI_DEV_MSG_I20 6 6921da177e4SLinus Torvalds #define EFI_DEV_MSG_MAC 11 6931da177e4SLinus Torvalds #define EFI_DEV_MSG_IPV4 12 6941da177e4SLinus Torvalds #define EFI_DEV_MSG_IPV6 13 6951da177e4SLinus Torvalds #define EFI_DEV_MSG_INFINIBAND 9 6961da177e4SLinus Torvalds #define EFI_DEV_MSG_UART 14 6971da177e4SLinus Torvalds #define EFI_DEV_MSG_VENDOR 10 6981da177e4SLinus Torvalds #define EFI_DEV_MEDIA 0x04 6991da177e4SLinus Torvalds #define EFI_DEV_MEDIA_HARD_DRIVE 1 7001da177e4SLinus Torvalds #define EFI_DEV_MEDIA_CDROM 2 7011da177e4SLinus Torvalds #define EFI_DEV_MEDIA_VENDOR 3 7021da177e4SLinus Torvalds #define EFI_DEV_MEDIA_FILE 4 7031da177e4SLinus Torvalds #define EFI_DEV_MEDIA_PROTOCOL 5 7041da177e4SLinus Torvalds #define EFI_DEV_BIOS_BOOT 0x05 7051da177e4SLinus Torvalds #define EFI_DEV_END_PATH 0x7F 7061da177e4SLinus Torvalds #define EFI_DEV_END_PATH2 0xFF 7071da177e4SLinus Torvalds #define EFI_DEV_END_INSTANCE 0x01 7081da177e4SLinus Torvalds #define EFI_DEV_END_ENTIRE 0xFF 7091da177e4SLinus Torvalds 7101da177e4SLinus Torvalds struct efi_generic_dev_path { 7111da177e4SLinus Torvalds u8 type; 7121da177e4SLinus Torvalds u8 sub_type; 7131da177e4SLinus Torvalds u16 length; 7141da177e4SLinus Torvalds } __attribute ((packed)); 7151da177e4SLinus Torvalds 7164a3575fdSHuang, Ying static inline void memrange_efi_to_native(u64 *addr, u64 *npages) 7174a3575fdSHuang, Ying { 7184a3575fdSHuang, Ying *npages = PFN_UP(*addr + (*npages<<EFI_PAGE_SHIFT)) - PFN_DOWN(*addr); 7194a3575fdSHuang, Ying *addr &= PAGE_MASK; 7204a3575fdSHuang, Ying } 7214a3575fdSHuang, Ying 7224fc756bdSMike Waychison #if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE) 7234fc756bdSMike Waychison /* 7244fc756bdSMike Waychison * EFI Variable support. 7254fc756bdSMike Waychison * 7264fc756bdSMike Waychison * Different firmware drivers can expose their EFI-like variables using 7274fc756bdSMike Waychison * the following. 7284fc756bdSMike Waychison */ 7294fc756bdSMike Waychison 7304fc756bdSMike Waychison struct efivar_operations { 7314fc756bdSMike Waychison efi_get_variable_t *get_variable; 7324fc756bdSMike Waychison efi_get_next_variable_t *get_next_variable; 7334fc756bdSMike Waychison efi_set_variable_t *set_variable; 734d80a361dSSeiji Aguchi efi_query_variable_info_t *query_variable_info; 7354fc756bdSMike Waychison }; 7364fc756bdSMike Waychison 7374fc756bdSMike Waychison struct efivars { 7384fc756bdSMike Waychison /* 7394fc756bdSMike Waychison * ->lock protects two things: 7404fc756bdSMike Waychison * 1) ->list - adds, removals, reads, writes 7414fc756bdSMike Waychison * 2) ops.[gs]et_variable() calls. 7424fc756bdSMike Waychison * It must not be held when creating sysfs entries or calling kmalloc. 7434fc756bdSMike Waychison * ops.get_next_variable() is only called from register_efivars(), 7444fc756bdSMike Waychison * which is protected by the BKL, so that path is safe. 7454fc756bdSMike Waychison */ 7464fc756bdSMike Waychison spinlock_t lock; 7474fc756bdSMike Waychison struct list_head list; 7484fc756bdSMike Waychison struct kset *kset; 749605e70c7SLee, Chun-Yi struct kobject *kobject; 7504fc756bdSMike Waychison struct bin_attribute *new_var, *del_var; 7514fc756bdSMike Waychison const struct efivar_operations *ops; 7525ee9c198SMatthew Garrett struct efivar_entry *walk_entry; 7535ee9c198SMatthew Garrett struct pstore_info efi_pstore_info; 7544fc756bdSMike Waychison }; 7554fc756bdSMike Waychison 7564fc756bdSMike Waychison int register_efivars(struct efivars *efivars, 7574fc756bdSMike Waychison const struct efivar_operations *ops, 7584fc756bdSMike Waychison struct kobject *parent_kobj); 7594fc756bdSMike Waychison void unregister_efivars(struct efivars *efivars); 7604fc756bdSMike Waychison 7614fc756bdSMike Waychison #endif /* CONFIG_EFI_VARS */ 7624fc756bdSMike Waychison 7631da177e4SLinus Torvalds #endif /* _LINUX_EFI_H */ 764