xref: /openbmc/linux/include/linux/efi.h (revision 605e70c7aa1b7b0d554baf945630c1d606bbfbc3)
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 
204f30ca6baSMatt Fleming /*
2051da177e4SLinus Torvalds  * Types and defines for EFI ResetSystem
2061da177e4SLinus Torvalds  */
2071da177e4SLinus Torvalds #define EFI_RESET_COLD 0
2081da177e4SLinus Torvalds #define EFI_RESET_WARM 1
2091da177e4SLinus Torvalds #define EFI_RESET_SHUTDOWN 2
2101da177e4SLinus Torvalds 
2111da177e4SLinus Torvalds /*
2121da177e4SLinus Torvalds  * EFI Runtime Services table
2131da177e4SLinus Torvalds  */
2141da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL)
2151da177e4SLinus Torvalds #define EFI_RUNTIME_SERVICES_REVISION  0x00010000
2161da177e4SLinus Torvalds 
2171da177e4SLinus Torvalds typedef struct {
2181da177e4SLinus Torvalds 	efi_table_hdr_t hdr;
2191da177e4SLinus Torvalds 	unsigned long get_time;
2201da177e4SLinus Torvalds 	unsigned long set_time;
2211da177e4SLinus Torvalds 	unsigned long get_wakeup_time;
2221da177e4SLinus Torvalds 	unsigned long set_wakeup_time;
2231da177e4SLinus Torvalds 	unsigned long set_virtual_address_map;
2241da177e4SLinus Torvalds 	unsigned long convert_pointer;
2251da177e4SLinus Torvalds 	unsigned long get_variable;
2261da177e4SLinus Torvalds 	unsigned long get_next_variable;
2271da177e4SLinus Torvalds 	unsigned long set_variable;
2281da177e4SLinus Torvalds 	unsigned long get_next_high_mono_count;
2291da177e4SLinus Torvalds 	unsigned long reset_system;
2303b370237SMatthew Garrett 	unsigned long update_capsule;
2313b370237SMatthew Garrett 	unsigned long query_capsule_caps;
2323b370237SMatthew Garrett 	unsigned long query_variable_info;
2331da177e4SLinus Torvalds } efi_runtime_services_t;
2341da177e4SLinus Torvalds 
2351da177e4SLinus Torvalds typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc);
2361da177e4SLinus Torvalds typedef efi_status_t efi_set_time_t (efi_time_t *tm);
2371da177e4SLinus Torvalds typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending,
2381da177e4SLinus Torvalds 					    efi_time_t *tm);
2391da177e4SLinus Torvalds typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm);
2401da177e4SLinus Torvalds typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr,
2411da177e4SLinus Torvalds 					 unsigned long *data_size, void *data);
2421da177e4SLinus Torvalds typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name,
2431da177e4SLinus Torvalds 					      efi_guid_t *vendor);
2441da177e4SLinus Torvalds typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor,
245f7a2d73fSMatthew Garrett 					 u32 attr, unsigned long data_size,
2461da177e4SLinus Torvalds 					 void *data);
2471da177e4SLinus Torvalds typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count);
2481da177e4SLinus Torvalds typedef void efi_reset_system_t (int reset_type, efi_status_t status,
2491da177e4SLinus Torvalds 				 unsigned long data_size, efi_char16_t *data);
2501da177e4SLinus Torvalds typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size,
2511da177e4SLinus Torvalds 						unsigned long descriptor_size,
2521da177e4SLinus Torvalds 						u32 descriptor_version,
2531da177e4SLinus Torvalds 						efi_memory_desc_t *virtual_map);
2543b370237SMatthew Garrett typedef efi_status_t efi_query_variable_info_t(u32 attr,
2553b370237SMatthew Garrett 					       u64 *storage_space,
2563b370237SMatthew Garrett 					       u64 *remaining_space,
2573b370237SMatthew Garrett 					       u64 *max_variable_size);
2583b370237SMatthew Garrett typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **capsules,
2593b370237SMatthew Garrett 					  unsigned long count,
2603b370237SMatthew Garrett 					  unsigned long sg_list);
2613b370237SMatthew Garrett typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules,
2623b370237SMatthew Garrett 					      unsigned long count,
2633b370237SMatthew Garrett 					      u64 *max_size,
2643b370237SMatthew Garrett 					      int *reset_type);
2651da177e4SLinus Torvalds 
2661da177e4SLinus Torvalds /*
2671da177e4SLinus Torvalds  *  EFI Configuration Table and GUID definitions
2681da177e4SLinus Torvalds  */
2691da177e4SLinus Torvalds #define NULL_GUID \
2701da177e4SLinus Torvalds     EFI_GUID(  0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )
2711da177e4SLinus Torvalds 
2721da177e4SLinus Torvalds #define MPS_TABLE_GUID    \
2731da177e4SLinus Torvalds     EFI_GUID(  0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
2741da177e4SLinus Torvalds 
2751da177e4SLinus Torvalds #define ACPI_TABLE_GUID    \
2761da177e4SLinus Torvalds     EFI_GUID(  0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
2771da177e4SLinus Torvalds 
2781da177e4SLinus Torvalds #define ACPI_20_TABLE_GUID    \
2791da177e4SLinus Torvalds     EFI_GUID(  0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 )
2801da177e4SLinus Torvalds 
2811da177e4SLinus Torvalds #define SMBIOS_TABLE_GUID    \
2821da177e4SLinus Torvalds     EFI_GUID(  0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
2831da177e4SLinus Torvalds 
2841da177e4SLinus Torvalds #define SAL_SYSTEM_TABLE_GUID    \
2851da177e4SLinus Torvalds     EFI_GUID(  0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
2861da177e4SLinus Torvalds 
2871da177e4SLinus Torvalds #define HCDP_TABLE_GUID	\
2881da177e4SLinus Torvalds     EFI_GUID(  0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 )
2891da177e4SLinus Torvalds 
2901da177e4SLinus Torvalds #define UGA_IO_PROTOCOL_GUID \
2911da177e4SLinus Torvalds     EFI_GUID(  0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 )
2921da177e4SLinus Torvalds 
2931da177e4SLinus Torvalds #define EFI_GLOBAL_VARIABLE_GUID \
2941da177e4SLinus Torvalds     EFI_GUID(  0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c )
2951da177e4SLinus Torvalds 
296a50f70b1SRuss Anderson #define UV_SYSTEM_TABLE_GUID \
297a50f70b1SRuss Anderson     EFI_GUID(  0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 )
298a50f70b1SRuss Anderson 
2995ee9c198SMatthew Garrett #define LINUX_EFI_CRASH_GUID \
3005ee9c198SMatthew Garrett     EFI_GUID(  0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 )
3015ee9c198SMatthew Garrett 
3028e84f345SMatt Fleming #define LOADED_IMAGE_PROTOCOL_GUID \
3038e84f345SMatt Fleming     EFI_GUID(  0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
3048e84f345SMatt Fleming 
3050f7c5d47SMatt Fleming #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
3060f7c5d47SMatt Fleming     EFI_GUID(  0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a )
3070f7c5d47SMatt Fleming 
3080f7c5d47SMatt Fleming #define EFI_UGA_PROTOCOL_GUID \
3090f7c5d47SMatt Fleming     EFI_GUID(  0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 )
3100f7c5d47SMatt Fleming 
3110f7c5d47SMatt Fleming #define EFI_PCI_IO_PROTOCOL_GUID \
3120f7c5d47SMatt Fleming     EFI_GUID(  0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a )
3130f7c5d47SMatt Fleming 
31455839d51SMatt Fleming #define EFI_FILE_INFO_ID \
31555839d51SMatt Fleming     EFI_GUID(  0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
31655839d51SMatt Fleming 
31755839d51SMatt Fleming #define EFI_FILE_SYSTEM_GUID \
31855839d51SMatt Fleming     EFI_GUID(  0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
31955839d51SMatt Fleming 
3201da177e4SLinus Torvalds typedef struct {
3211da177e4SLinus Torvalds 	efi_guid_t guid;
3221adbfa35SOlof Johansson 	u64 table;
3231adbfa35SOlof Johansson } efi_config_table_64_t;
3241adbfa35SOlof Johansson 
3251adbfa35SOlof Johansson typedef struct {
3261adbfa35SOlof Johansson 	efi_guid_t guid;
3271adbfa35SOlof Johansson 	u32 table;
3281adbfa35SOlof Johansson } efi_config_table_32_t;
3291adbfa35SOlof Johansson 
3301adbfa35SOlof Johansson typedef struct {
3311adbfa35SOlof Johansson 	efi_guid_t guid;
3321da177e4SLinus Torvalds 	unsigned long table;
3331da177e4SLinus Torvalds } efi_config_table_t;
3341da177e4SLinus Torvalds 
3351da177e4SLinus Torvalds #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
3361da177e4SLinus Torvalds 
3373b370237SMatthew Garrett #define EFI_2_30_SYSTEM_TABLE_REVISION  ((2 << 16) | (30))
3383b370237SMatthew Garrett #define EFI_2_20_SYSTEM_TABLE_REVISION  ((2 << 16) | (20))
3393b370237SMatthew Garrett #define EFI_2_10_SYSTEM_TABLE_REVISION  ((2 << 16) | (10))
3403b370237SMatthew Garrett #define EFI_2_00_SYSTEM_TABLE_REVISION  ((2 << 16) | (00))
3413b370237SMatthew Garrett #define EFI_1_10_SYSTEM_TABLE_REVISION  ((1 << 16) | (10))
3423b370237SMatthew Garrett #define EFI_1_02_SYSTEM_TABLE_REVISION  ((1 << 16) | (02))
3433b370237SMatthew Garrett 
3441da177e4SLinus Torvalds typedef struct {
3451da177e4SLinus Torvalds 	efi_table_hdr_t hdr;
3461adbfa35SOlof Johansson 	u64 fw_vendor;	/* physical addr of CHAR16 vendor string */
3471adbfa35SOlof Johansson 	u32 fw_revision;
3481adbfa35SOlof Johansson 	u32 __pad1;
3491adbfa35SOlof Johansson 	u64 con_in_handle;
3501adbfa35SOlof Johansson 	u64 con_in;
3511adbfa35SOlof Johansson 	u64 con_out_handle;
3521adbfa35SOlof Johansson 	u64 con_out;
3531adbfa35SOlof Johansson 	u64 stderr_handle;
3541adbfa35SOlof Johansson 	u64 stderr;
3551adbfa35SOlof Johansson 	u64 runtime;
3561adbfa35SOlof Johansson 	u64 boottime;
3571adbfa35SOlof Johansson 	u32 nr_tables;
3581adbfa35SOlof Johansson 	u32 __pad2;
3591adbfa35SOlof Johansson 	u64 tables;
3601adbfa35SOlof Johansson } efi_system_table_64_t;
3611adbfa35SOlof Johansson 
3621adbfa35SOlof Johansson typedef struct {
3631adbfa35SOlof Johansson 	efi_table_hdr_t hdr;
3641adbfa35SOlof Johansson 	u32 fw_vendor;	/* physical addr of CHAR16 vendor string */
3651adbfa35SOlof Johansson 	u32 fw_revision;
3661adbfa35SOlof Johansson 	u32 con_in_handle;
3671adbfa35SOlof Johansson 	u32 con_in;
3681adbfa35SOlof Johansson 	u32 con_out_handle;
3691adbfa35SOlof Johansson 	u32 con_out;
3701adbfa35SOlof Johansson 	u32 stderr_handle;
3711adbfa35SOlof Johansson 	u32 stderr;
3721adbfa35SOlof Johansson 	u32 runtime;
3731adbfa35SOlof Johansson 	u32 boottime;
3741adbfa35SOlof Johansson 	u32 nr_tables;
3751adbfa35SOlof Johansson 	u32 tables;
3761adbfa35SOlof Johansson } efi_system_table_32_t;
3771adbfa35SOlof Johansson 
3781adbfa35SOlof Johansson typedef struct {
3791adbfa35SOlof Johansson 	efi_table_hdr_t hdr;
3801da177e4SLinus Torvalds 	unsigned long fw_vendor;	/* physical addr of CHAR16 vendor string */
3811da177e4SLinus Torvalds 	u32 fw_revision;
3821da177e4SLinus Torvalds 	unsigned long con_in_handle;
3831da177e4SLinus Torvalds 	unsigned long con_in;
3841da177e4SLinus Torvalds 	unsigned long con_out_handle;
3851da177e4SLinus Torvalds 	unsigned long con_out;
3861da177e4SLinus Torvalds 	unsigned long stderr_handle;
3871da177e4SLinus Torvalds 	unsigned long stderr;
3881da177e4SLinus Torvalds 	efi_runtime_services_t *runtime;
389f30ca6baSMatt Fleming 	efi_boot_services_t *boottime;
3901da177e4SLinus Torvalds 	unsigned long nr_tables;
3911da177e4SLinus Torvalds 	unsigned long tables;
3921da177e4SLinus Torvalds } efi_system_table_t;
3931da177e4SLinus Torvalds 
3941da177e4SLinus Torvalds struct efi_memory_map {
3957ae65fd3SMatt Tolentino 	void *phys_map;
3967ae65fd3SMatt Tolentino 	void *map;
3977ae65fd3SMatt Tolentino 	void *map_end;
3981da177e4SLinus Torvalds 	int nr_map;
3991da177e4SLinus Torvalds 	unsigned long desc_version;
4007ae65fd3SMatt Tolentino 	unsigned long desc_size;
4011da177e4SLinus Torvalds };
4021da177e4SLinus Torvalds 
4038e84f345SMatt Fleming typedef struct {
4048e84f345SMatt Fleming 	u32 revision;
4058e84f345SMatt Fleming 	void *parent_handle;
4068e84f345SMatt Fleming 	efi_system_table_t *system_table;
4078e84f345SMatt Fleming 	void *device_handle;
4088e84f345SMatt Fleming 	void *file_path;
4098e84f345SMatt Fleming 	void *reserved;
4108e84f345SMatt Fleming 	u32 load_options_size;
4118e84f345SMatt Fleming 	void *load_options;
4128e84f345SMatt Fleming 	void *image_base;
4138e84f345SMatt Fleming 	__aligned_u64 image_size;
4148e84f345SMatt Fleming 	unsigned int image_code_type;
4158e84f345SMatt Fleming 	unsigned int image_data_type;
4168e84f345SMatt Fleming 	unsigned long unload;
4178e84f345SMatt Fleming } efi_loaded_image_t;
4188e84f345SMatt Fleming 
41955839d51SMatt Fleming typedef struct {
42055839d51SMatt Fleming 	u64 revision;
42155839d51SMatt Fleming 	void *open_volume;
42255839d51SMatt Fleming } efi_file_io_interface_t;
42355839d51SMatt Fleming 
42455839d51SMatt Fleming typedef struct {
42555839d51SMatt Fleming 	u64 size;
42655839d51SMatt Fleming 	u64 file_size;
42755839d51SMatt Fleming 	u64 phys_size;
42855839d51SMatt Fleming 	efi_time_t create_time;
42955839d51SMatt Fleming 	efi_time_t last_access_time;
43055839d51SMatt Fleming 	efi_time_t modification_time;
43155839d51SMatt Fleming 	__aligned_u64 attribute;
43255839d51SMatt Fleming 	efi_char16_t filename[1];
43355839d51SMatt Fleming } efi_file_info_t;
43455839d51SMatt Fleming 
43555839d51SMatt Fleming typedef struct {
43655839d51SMatt Fleming 	u64 revision;
43755839d51SMatt Fleming 	void *open;
43855839d51SMatt Fleming 	void *close;
43955839d51SMatt Fleming 	void *delete;
44055839d51SMatt Fleming 	void *read;
44155839d51SMatt Fleming 	void *write;
44255839d51SMatt Fleming 	void *get_position;
44355839d51SMatt Fleming 	void *set_position;
44455839d51SMatt Fleming 	void *get_info;
44555839d51SMatt Fleming 	void *set_info;
44655839d51SMatt Fleming 	void *flush;
44755839d51SMatt Fleming } efi_file_handle_t;
44855839d51SMatt Fleming 
44955839d51SMatt Fleming #define EFI_FILE_MODE_READ	0x0000000000000001
45055839d51SMatt Fleming #define EFI_FILE_MODE_WRITE	0x0000000000000002
45155839d51SMatt Fleming #define EFI_FILE_MODE_CREATE	0x8000000000000000
45255839d51SMatt Fleming 
453b2c99e3cSBjorn Helgaas #define EFI_INVALID_TABLE_ADDR		(~0UL)
454b2c99e3cSBjorn Helgaas 
4551da177e4SLinus Torvalds /*
4561da177e4SLinus Torvalds  * All runtime access to EFI goes through this structure:
4571da177e4SLinus Torvalds  */
4581da177e4SLinus Torvalds extern struct efi {
4591da177e4SLinus Torvalds 	efi_system_table_t *systab;	/* EFI system table */
4603b370237SMatthew Garrett 	unsigned int runtime_version;	/* Runtime services version */
461b2c99e3cSBjorn Helgaas 	unsigned long mps;		/* MPS table */
462b2c99e3cSBjorn Helgaas 	unsigned long acpi;		/* ACPI table  (IA64 ext 0.71) */
463b2c99e3cSBjorn Helgaas 	unsigned long acpi20;		/* ACPI table  (ACPI 2.0) */
464b2c99e3cSBjorn Helgaas 	unsigned long smbios;		/* SM BIOS table */
465b2c99e3cSBjorn Helgaas 	unsigned long sal_systab;	/* SAL system table */
466b2c99e3cSBjorn Helgaas 	unsigned long boot_info;	/* boot info table */
467b2c99e3cSBjorn Helgaas 	unsigned long hcdp;		/* HCDP table */
468b2c99e3cSBjorn Helgaas 	unsigned long uga;		/* UGA table */
469a50f70b1SRuss Anderson 	unsigned long uv_systab;	/* UV system table */
4701da177e4SLinus Torvalds 	efi_get_time_t *get_time;
4711da177e4SLinus Torvalds 	efi_set_time_t *set_time;
4721da177e4SLinus Torvalds 	efi_get_wakeup_time_t *get_wakeup_time;
4731da177e4SLinus Torvalds 	efi_set_wakeup_time_t *set_wakeup_time;
4741da177e4SLinus Torvalds 	efi_get_variable_t *get_variable;
4751da177e4SLinus Torvalds 	efi_get_next_variable_t *get_next_variable;
4761da177e4SLinus Torvalds 	efi_set_variable_t *set_variable;
4773b370237SMatthew Garrett 	efi_query_variable_info_t *query_variable_info;
4783b370237SMatthew Garrett 	efi_update_capsule_t *update_capsule;
4793b370237SMatthew Garrett 	efi_query_capsule_caps_t *query_capsule_caps;
4801da177e4SLinus Torvalds 	efi_get_next_high_mono_count_t *get_next_high_mono_count;
4811da177e4SLinus Torvalds 	efi_reset_system_t *reset_system;
4821da177e4SLinus Torvalds 	efi_set_virtual_address_map_t *set_virtual_address_map;
4831da177e4SLinus Torvalds } efi;
4841da177e4SLinus Torvalds 
4851da177e4SLinus Torvalds static inline int
4861da177e4SLinus Torvalds efi_guidcmp (efi_guid_t left, efi_guid_t right)
4871da177e4SLinus Torvalds {
4881da177e4SLinus Torvalds 	return memcmp(&left, &right, sizeof (efi_guid_t));
4891da177e4SLinus Torvalds }
4901da177e4SLinus Torvalds 
4911da177e4SLinus Torvalds static inline char *
4921da177e4SLinus Torvalds efi_guid_unparse(efi_guid_t *guid, char *out)
4931da177e4SLinus Torvalds {
494925ede0bSJoe Perches 	sprintf(out, "%pUl", guid->b);
4951da177e4SLinus Torvalds         return out;
4961da177e4SLinus Torvalds }
4971da177e4SLinus Torvalds 
4981da177e4SLinus Torvalds extern void efi_init (void);
4991da177e4SLinus Torvalds extern void *efi_get_pal_addr (void);
5001da177e4SLinus Torvalds extern void efi_map_pal_code (void);
5011da177e4SLinus Torvalds extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
5021da177e4SLinus Torvalds extern void efi_gettimeofday (struct timespec *ts);
5031da177e4SLinus Torvalds extern void efi_enter_virtual_mode (void);	/* switch EFI to virtual mode, if possible */
50478510792SJosh Triplett #ifdef CONFIG_X86
5052223af38SJosh Triplett extern void efi_late_init(void);
50678510792SJosh Triplett extern void efi_free_boot_services(void);
50778510792SJosh Triplett #else
5082223af38SJosh Triplett static inline void efi_late_init(void) {}
50978510792SJosh Triplett static inline void efi_free_boot_services(void) {}
51078510792SJosh Triplett #endif
5117bc90e01SJosh Triplett extern void __iomem *efi_lookup_mapped_addr(u64 phys_addr);
5121da177e4SLinus Torvalds extern u64 efi_get_iobase (void);
5131da177e4SLinus Torvalds extern u32 efi_mem_type (unsigned long phys_addr);
5141da177e4SLinus Torvalds extern u64 efi_mem_attributes (unsigned long phys_addr);
51532e62c63SBjorn Helgaas extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
5161da177e4SLinus Torvalds extern int __init efi_uart_console_only (void);
5171da177e4SLinus Torvalds extern void efi_initialize_iomem_resources(struct resource *code_resource,
51800bf4098SBernhard Walle 		struct resource *data_resource, struct resource *bss_resource);
519f026cfa8SH. Peter Anvin extern unsigned long efi_get_time(void);
520f026cfa8SH. Peter Anvin extern int efi_set_rtc_mmss(unsigned long nowtime);
521916f676fSMatthew Garrett extern void efi_reserve_boot_services(void);
5221da177e4SLinus Torvalds extern struct efi_memory_map memmap;
5231da177e4SLinus Torvalds 
5241da177e4SLinus Torvalds /**
5251da177e4SLinus Torvalds  * efi_range_is_wc - check the WC bit on an address range
5261da177e4SLinus Torvalds  * @start: starting kvirt address
5271da177e4SLinus Torvalds  * @len: length of range
5281da177e4SLinus Torvalds  *
5291da177e4SLinus Torvalds  * Consult the EFI memory map and make sure it's ok to set this range WC.
5301da177e4SLinus Torvalds  * Returns true or false.
5311da177e4SLinus Torvalds  */
5321da177e4SLinus Torvalds static inline int efi_range_is_wc(unsigned long start, unsigned long len)
5331da177e4SLinus Torvalds {
534986a80d5SJesper Juhl 	unsigned long i;
5351da177e4SLinus Torvalds 
5361da177e4SLinus Torvalds 	for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) {
5371da177e4SLinus Torvalds 		unsigned long paddr = __pa(start + i);
5381da177e4SLinus Torvalds 		if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC))
5391da177e4SLinus Torvalds 			return 0;
5401da177e4SLinus Torvalds 	}
5411da177e4SLinus Torvalds 	/* The range checked out */
5421da177e4SLinus Torvalds 	return 1;
5431da177e4SLinus Torvalds }
5441da177e4SLinus Torvalds 
5451da177e4SLinus Torvalds #ifdef CONFIG_EFI_PCDP
5461da177e4SLinus Torvalds extern int __init efi_setup_pcdp_console(char *);
5471da177e4SLinus Torvalds #endif
5481da177e4SLinus Torvalds 
5491da177e4SLinus Torvalds /*
5501da177e4SLinus Torvalds  * We play games with efi_enabled so that the compiler will, if possible, remove
5511da177e4SLinus Torvalds  * EFI-related code altogether.
5521da177e4SLinus Torvalds  */
5531da177e4SLinus Torvalds #ifdef CONFIG_EFI
5541da177e4SLinus Torvalds # ifdef CONFIG_X86
5551da177e4SLinus Torvalds    extern int efi_enabled;
5561adbfa35SOlof Johansson    extern bool efi_64bit;
5571da177e4SLinus Torvalds # else
5581da177e4SLinus Torvalds #  define efi_enabled 1
5591da177e4SLinus Torvalds # endif
5601da177e4SLinus Torvalds #else
5611da177e4SLinus Torvalds # define efi_enabled 0
5621da177e4SLinus Torvalds #endif
5631da177e4SLinus Torvalds 
5641da177e4SLinus Torvalds /*
5651da177e4SLinus Torvalds  * Variable Attributes
5661da177e4SLinus Torvalds  */
5671da177e4SLinus Torvalds #define EFI_VARIABLE_NON_VOLATILE       0x0000000000000001
5681da177e4SLinus Torvalds #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
5691da177e4SLinus Torvalds #define EFI_VARIABLE_RUNTIME_ACCESS     0x0000000000000004
57041b3254cSMatthew Garrett #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008
57141b3254cSMatthew Garrett #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010
57241b3254cSMatthew Garrett #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020
57341b3254cSMatthew Garrett #define EFI_VARIABLE_APPEND_WRITE	0x0000000000000040
5741da177e4SLinus Torvalds 
57541b3254cSMatthew Garrett #define EFI_VARIABLE_MASK 	(EFI_VARIABLE_NON_VOLATILE | \
57641b3254cSMatthew Garrett 				EFI_VARIABLE_BOOTSERVICE_ACCESS | \
57741b3254cSMatthew Garrett 				EFI_VARIABLE_RUNTIME_ACCESS | \
57841b3254cSMatthew Garrett 				EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
57941b3254cSMatthew Garrett 				EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \
58041b3254cSMatthew Garrett 				EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
58141b3254cSMatthew Garrett 				EFI_VARIABLE_APPEND_WRITE)
5821da177e4SLinus Torvalds /*
583e2527a7cSMatt Fleming  * The type of search to perform when calling boottime->locate_handle
584e2527a7cSMatt Fleming  */
585e2527a7cSMatt Fleming #define EFI_LOCATE_ALL_HANDLES			0
586e2527a7cSMatt Fleming #define EFI_LOCATE_BY_REGISTER_NOTIFY		1
587e2527a7cSMatt Fleming #define EFI_LOCATE_BY_PROTOCOL			2
588e2527a7cSMatt Fleming 
589e2527a7cSMatt Fleming /*
5901da177e4SLinus Torvalds  * EFI Device Path information
5911da177e4SLinus Torvalds  */
5921da177e4SLinus Torvalds #define EFI_DEV_HW			0x01
5931da177e4SLinus Torvalds #define  EFI_DEV_PCI				 1
5941da177e4SLinus Torvalds #define  EFI_DEV_PCCARD				 2
5951da177e4SLinus Torvalds #define  EFI_DEV_MEM_MAPPED			 3
5961da177e4SLinus Torvalds #define  EFI_DEV_VENDOR				 4
5971da177e4SLinus Torvalds #define  EFI_DEV_CONTROLLER			 5
5981da177e4SLinus Torvalds #define EFI_DEV_ACPI			0x02
5991da177e4SLinus Torvalds #define   EFI_DEV_BASIC_ACPI			 1
6001da177e4SLinus Torvalds #define   EFI_DEV_EXPANDED_ACPI			 2
6011da177e4SLinus Torvalds #define EFI_DEV_MSG			0x03
6021da177e4SLinus Torvalds #define   EFI_DEV_MSG_ATAPI			 1
6031da177e4SLinus Torvalds #define   EFI_DEV_MSG_SCSI			 2
6041da177e4SLinus Torvalds #define   EFI_DEV_MSG_FC			 3
6051da177e4SLinus Torvalds #define   EFI_DEV_MSG_1394			 4
6061da177e4SLinus Torvalds #define   EFI_DEV_MSG_USB			 5
6071da177e4SLinus Torvalds #define   EFI_DEV_MSG_USB_CLASS			15
6081da177e4SLinus Torvalds #define   EFI_DEV_MSG_I20			 6
6091da177e4SLinus Torvalds #define   EFI_DEV_MSG_MAC			11
6101da177e4SLinus Torvalds #define   EFI_DEV_MSG_IPV4			12
6111da177e4SLinus Torvalds #define   EFI_DEV_MSG_IPV6			13
6121da177e4SLinus Torvalds #define   EFI_DEV_MSG_INFINIBAND		 9
6131da177e4SLinus Torvalds #define   EFI_DEV_MSG_UART			14
6141da177e4SLinus Torvalds #define   EFI_DEV_MSG_VENDOR			10
6151da177e4SLinus Torvalds #define EFI_DEV_MEDIA			0x04
6161da177e4SLinus Torvalds #define   EFI_DEV_MEDIA_HARD_DRIVE		 1
6171da177e4SLinus Torvalds #define   EFI_DEV_MEDIA_CDROM			 2
6181da177e4SLinus Torvalds #define   EFI_DEV_MEDIA_VENDOR			 3
6191da177e4SLinus Torvalds #define   EFI_DEV_MEDIA_FILE			 4
6201da177e4SLinus Torvalds #define   EFI_DEV_MEDIA_PROTOCOL		 5
6211da177e4SLinus Torvalds #define EFI_DEV_BIOS_BOOT		0x05
6221da177e4SLinus Torvalds #define EFI_DEV_END_PATH		0x7F
6231da177e4SLinus Torvalds #define EFI_DEV_END_PATH2		0xFF
6241da177e4SLinus Torvalds #define   EFI_DEV_END_INSTANCE			0x01
6251da177e4SLinus Torvalds #define   EFI_DEV_END_ENTIRE			0xFF
6261da177e4SLinus Torvalds 
6271da177e4SLinus Torvalds struct efi_generic_dev_path {
6281da177e4SLinus Torvalds 	u8 type;
6291da177e4SLinus Torvalds 	u8 sub_type;
6301da177e4SLinus Torvalds 	u16 length;
6311da177e4SLinus Torvalds } __attribute ((packed));
6321da177e4SLinus Torvalds 
6334a3575fdSHuang, Ying static inline void memrange_efi_to_native(u64 *addr, u64 *npages)
6344a3575fdSHuang, Ying {
6354a3575fdSHuang, Ying 	*npages = PFN_UP(*addr + (*npages<<EFI_PAGE_SHIFT)) - PFN_DOWN(*addr);
6364a3575fdSHuang, Ying 	*addr &= PAGE_MASK;
6374a3575fdSHuang, Ying }
6384a3575fdSHuang, Ying 
6394fc756bdSMike Waychison #if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE)
6404fc756bdSMike Waychison /*
6414fc756bdSMike Waychison  * EFI Variable support.
6424fc756bdSMike Waychison  *
6434fc756bdSMike Waychison  * Different firmware drivers can expose their EFI-like variables using
6444fc756bdSMike Waychison  * the following.
6454fc756bdSMike Waychison  */
6464fc756bdSMike Waychison 
6474fc756bdSMike Waychison struct efivar_operations {
6484fc756bdSMike Waychison 	efi_get_variable_t *get_variable;
6494fc756bdSMike Waychison 	efi_get_next_variable_t *get_next_variable;
6504fc756bdSMike Waychison 	efi_set_variable_t *set_variable;
6514fc756bdSMike Waychison };
6524fc756bdSMike Waychison 
6534fc756bdSMike Waychison struct efivars {
6544fc756bdSMike Waychison 	/*
6554fc756bdSMike Waychison 	 * ->lock protects two things:
6564fc756bdSMike Waychison 	 * 1) ->list - adds, removals, reads, writes
6574fc756bdSMike Waychison 	 * 2) ops.[gs]et_variable() calls.
6584fc756bdSMike Waychison 	 * It must not be held when creating sysfs entries or calling kmalloc.
6594fc756bdSMike Waychison 	 * ops.get_next_variable() is only called from register_efivars(),
6604fc756bdSMike Waychison 	 * which is protected by the BKL, so that path is safe.
6614fc756bdSMike Waychison 	 */
6624fc756bdSMike Waychison 	spinlock_t lock;
6634fc756bdSMike Waychison 	struct list_head list;
6644fc756bdSMike Waychison 	struct kset *kset;
665*605e70c7SLee, Chun-Yi 	struct kobject *kobject;
6664fc756bdSMike Waychison 	struct bin_attribute *new_var, *del_var;
6674fc756bdSMike Waychison 	const struct efivar_operations *ops;
6685ee9c198SMatthew Garrett 	struct efivar_entry *walk_entry;
6695ee9c198SMatthew Garrett 	struct pstore_info efi_pstore_info;
6704fc756bdSMike Waychison };
6714fc756bdSMike Waychison 
6724fc756bdSMike Waychison int register_efivars(struct efivars *efivars,
6734fc756bdSMike Waychison 		     const struct efivar_operations *ops,
6744fc756bdSMike Waychison 		     struct kobject *parent_kobj);
6754fc756bdSMike Waychison void unregister_efivars(struct efivars *efivars);
6764fc756bdSMike Waychison 
6774fc756bdSMike Waychison #endif /* CONFIG_EFI_VARS */
6784fc756bdSMike Waychison 
6791da177e4SLinus Torvalds #endif /* _LINUX_EFI_H */
680