xref: /kvm-unit-tests/lib/linux/efi.h (revision 9632ce446b8f2e8362c3877359663bb99dba70c1)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Relevant definitions from linux/efi.h. */
3 
4 #ifndef __LINUX_UEFI_H
5 #define __LINUX_UEFI_H
6 
7 #include "libcflat.h"
8 
9 #ifndef __packed
10 # define __packed		__attribute__((__packed__))
11 #endif
12 
13 #define BITS_PER_LONG 64
14 
15 #define EFI_ERROR(a)		(((int64_t) a) < 0)
16 #define EFI_SUCCESS		0
17 #define EFI_LOAD_ERROR		( 1 | (1UL << (BITS_PER_LONG-1)))
18 #define EFI_INVALID_PARAMETER	( 2 | (1UL << (BITS_PER_LONG-1)))
19 #define EFI_UNSUPPORTED		( 3 | (1UL << (BITS_PER_LONG-1)))
20 #define EFI_BAD_BUFFER_SIZE	( 4 | (1UL << (BITS_PER_LONG-1)))
21 #define EFI_BUFFER_TOO_SMALL	( 5 | (1UL << (BITS_PER_LONG-1)))
22 #define EFI_NOT_READY		( 6 | (1UL << (BITS_PER_LONG-1)))
23 #define EFI_DEVICE_ERROR	( 7 | (1UL << (BITS_PER_LONG-1)))
24 #define EFI_WRITE_PROTECTED	( 8 | (1UL << (BITS_PER_LONG-1)))
25 #define EFI_OUT_OF_RESOURCES	( 9 | (1UL << (BITS_PER_LONG-1)))
26 #define EFI_NOT_FOUND		(14 | (1UL << (BITS_PER_LONG-1)))
27 #define EFI_TIMEOUT		(18 | (1UL << (BITS_PER_LONG-1)))
28 #define EFI_ABORTED		(21 | (1UL << (BITS_PER_LONG-1)))
29 #define EFI_SECURITY_VIOLATION	(26 | (1UL << (BITS_PER_LONG-1)))
30 
31 typedef unsigned long efi_status_t;
32 typedef u8 efi_bool_t;
33 typedef u16 efi_char16_t;		/* UNICODE character */
34 typedef u64 efi_physical_addr_t;
35 typedef void *efi_handle_t;
36 
37 #ifdef __x86_64__
38 #define __efiapi __attribute__((ms_abi))
39 #else
40 #define __efiapi
41 #endif
42 
43 /*
44  * The UEFI spec and EDK2 reference implementation both define EFI_GUID as
45  * struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment
46  * is 32 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM),
47  * this means that firmware services invoked by the kernel may assume that
48  * efi_guid_t* arguments are 32-bit aligned, and use memory accessors that
49  * do not tolerate misalignment. So let's set the minimum alignment to 32 bits.
50  *
51  * Note that the UEFI spec as well as some comments in the EDK2 code base
52  * suggest that EFI_GUID should be 64-bit aligned, but this appears to be
53  * a mistake, given that no code seems to exist that actually enforces that
54  * or relies on it.
55  */
56 typedef struct {
57 	u8 b[16];
58 } guid_t __attribute__((aligned(__alignof__(u32))));
59 typedef guid_t efi_guid_t;
60 
61 #define EFI_GUID(a, b, c, d...) (efi_guid_t){ {					\
62 	(a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff,	\
63 	(b) & 0xff, ((b) >> 8) & 0xff,						\
64 	(c) & 0xff, ((c) >> 8) & 0xff, d } }
65 
66 #define ACPI_TABLE_GUID EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
67 #define ACPI_20_TABLE_GUID EFI_GUID(0x8868e871, 0xe4f1, 0x11d3,  0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
68 
69 #define DEVICE_TREE_GUID EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5,  0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
70 
71 #define LOADED_IMAGE_PROTOCOL_GUID EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2,  0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
72 
73 typedef struct {
74 	efi_guid_t guid;
75 	void *table;
76 } efi_config_table_t;
77 
78 /*
79  * Generic EFI table header
80  */
81 typedef	struct {
82 	u64 signature;
83 	u32 revision;
84 	u32 headersize;
85 	u32 crc32;
86 	u32 reserved;
87 } efi_table_hdr_t;
88 
89 /*
90  * Memory map descriptor:
91  */
92 
93 /* Memory types: */
94 #define EFI_RESERVED_TYPE		 0
95 #define EFI_LOADER_CODE			 1
96 #define EFI_LOADER_DATA			 2
97 #define EFI_BOOT_SERVICES_CODE		 3
98 #define EFI_BOOT_SERVICES_DATA		 4
99 #define EFI_RUNTIME_SERVICES_CODE	 5
100 #define EFI_RUNTIME_SERVICES_DATA	 6
101 #define EFI_CONVENTIONAL_MEMORY		 7
102 #define EFI_UNUSABLE_MEMORY		 8
103 #define EFI_ACPI_RECLAIM_MEMORY		 9
104 #define EFI_ACPI_MEMORY_NVS		10
105 #define EFI_MEMORY_MAPPED_IO		11
106 #define EFI_MEMORY_MAPPED_IO_PORT_SPACE	12
107 #define EFI_PAL_CODE			13
108 #define EFI_PERSISTENT_MEMORY		14
109 #define EFI_MAX_MEMORY_TYPE		15
110 
111 /* Attribute values: */
112 #define EFI_MEMORY_UC		((u64)0x0000000000000001ULL)	/* uncached */
113 #define EFI_MEMORY_WC		((u64)0x0000000000000002ULL)	/* write-coalescing */
114 #define EFI_MEMORY_WT		((u64)0x0000000000000004ULL)	/* write-through */
115 #define EFI_MEMORY_WB		((u64)0x0000000000000008ULL)	/* write-back */
116 #define EFI_MEMORY_UCE		((u64)0x0000000000000010ULL)	/* uncached, exported */
117 #define EFI_MEMORY_WP		((u64)0x0000000000001000ULL)	/* write-protect */
118 #define EFI_MEMORY_RP		((u64)0x0000000000002000ULL)	/* read-protect */
119 #define EFI_MEMORY_XP		((u64)0x0000000000004000ULL)	/* execute-protect */
120 #define EFI_MEMORY_NV		((u64)0x0000000000008000ULL)	/* non-volatile */
121 #define EFI_MEMORY_MORE_RELIABLE \
122 				((u64)0x0000000000010000ULL)	/* higher reliability */
123 #define EFI_MEMORY_RO		((u64)0x0000000000020000ULL)	/* read-only */
124 #define EFI_MEMORY_SP		((u64)0x0000000000040000ULL)	/* soft reserved */
125 #define EFI_MEMORY_CPU_CRYPTO	((u64)0x0000000000080000ULL)	/* supports encryption */
126 #define EFI_MEMORY_RUNTIME	((u64)0x8000000000000000ULL)	/* range requires runtime mapping */
127 #define EFI_MEMORY_DESCRIPTOR_VERSION	1
128 
129 #define EFI_PAGE_SHIFT		12
130 #define EFI_PAGE_SIZE		(1UL << EFI_PAGE_SHIFT)
131 #define EFI_PAGES_MAX		(U64_MAX >> EFI_PAGE_SHIFT)
132 
133 typedef struct {
134 	u32 type;
135 	u32 pad;
136 	u64 phys_addr;
137 	u64 virt_addr;
138 	u64 num_pages;
139 	u64 attribute;
140 } efi_memory_desc_t;
141 
142 typedef struct {
143 	efi_guid_t guid;
144 	u32 headersize;
145 	u32 flags;
146 	u32 imagesize;
147 } efi_capsule_header_t;
148 
149 /*
150  * EFI capsule flags
151  */
152 #define EFI_CAPSULE_PERSIST_ACROSS_RESET	0x00010000
153 #define EFI_CAPSULE_POPULATE_SYSTEM_TABLE	0x00020000
154 #define EFI_CAPSULE_INITIATE_RESET		0x00040000
155 
156 struct capsule_info {
157 	efi_capsule_header_t	header;
158 	efi_capsule_header_t	*capsule;
159 	int			reset_type;
160 	long			index;
161 	size_t			count;
162 	size_t			total_size;
163 	struct page		**pages;
164 	phys_addr_t		*phys;
165 	size_t			page_bytes_remain;
166 };
167 
168 int __efi_capsule_setup_info(struct capsule_info *cap_info);
169 
170 /*
171  * Types and defines for Time Services
172  */
173 #define EFI_TIME_ADJUST_DAYLIGHT 0x1
174 #define EFI_TIME_IN_DAYLIGHT     0x2
175 #define EFI_UNSPECIFIED_TIMEZONE 0x07ff
176 
177 typedef struct {
178 	u16 year;
179 	u8 month;
180 	u8 day;
181 	u8 hour;
182 	u8 minute;
183 	u8 second;
184 	u8 pad1;
185 	u32 nanosecond;
186 	s16 timezone;
187 	u8 daylight;
188 	u8 pad2;
189 } efi_time_t;
190 
191 typedef struct {
192 	u32 resolution;
193 	u32 accuracy;
194 	u8 sets_to_zero;
195 } efi_time_cap_t;
196 
197 typedef void *efi_event_t;
198 /* Note that notifications won't work in mixed mode */
199 typedef void (__efiapi *efi_event_notify_t)(efi_event_t, void *);
200 
201 typedef enum {
202 	EfiTimerCancel,
203 	EfiTimerPeriodic,
204 	EfiTimerRelative
205 } EFI_TIMER_DELAY;
206 
207 /*
208  * EFI Device Path information
209  */
210 #define EFI_DEV_HW			0x01
211 #define  EFI_DEV_PCI				 1
212 #define  EFI_DEV_PCCARD				 2
213 #define  EFI_DEV_MEM_MAPPED			 3
214 #define  EFI_DEV_VENDOR				 4
215 #define  EFI_DEV_CONTROLLER			 5
216 #define EFI_DEV_ACPI			0x02
217 #define   EFI_DEV_BASIC_ACPI			 1
218 #define   EFI_DEV_EXPANDED_ACPI			 2
219 #define EFI_DEV_MSG			0x03
220 #define   EFI_DEV_MSG_ATAPI			 1
221 #define   EFI_DEV_MSG_SCSI			 2
222 #define   EFI_DEV_MSG_FC			 3
223 #define   EFI_DEV_MSG_1394			 4
224 #define   EFI_DEV_MSG_USB			 5
225 #define   EFI_DEV_MSG_USB_CLASS			15
226 #define   EFI_DEV_MSG_I20			 6
227 #define   EFI_DEV_MSG_MAC			11
228 #define   EFI_DEV_MSG_IPV4			12
229 #define   EFI_DEV_MSG_IPV6			13
230 #define   EFI_DEV_MSG_INFINIBAND		 9
231 #define   EFI_DEV_MSG_UART			14
232 #define   EFI_DEV_MSG_VENDOR			10
233 #define EFI_DEV_MEDIA			0x04
234 #define   EFI_DEV_MEDIA_HARD_DRIVE		 1
235 #define   EFI_DEV_MEDIA_CDROM			 2
236 #define   EFI_DEV_MEDIA_VENDOR			 3
237 #define   EFI_DEV_MEDIA_FILE			 4
238 #define   EFI_DEV_MEDIA_PROTOCOL		 5
239 #define EFI_DEV_BIOS_BOOT		0x05
240 #define EFI_DEV_END_PATH		0x7F
241 #define EFI_DEV_END_PATH2		0xFF
242 #define   EFI_DEV_END_INSTANCE			0x01
243 #define   EFI_DEV_END_ENTIRE			0xFF
244 
245 struct efi_generic_dev_path {
246 	u8				type;
247 	u8				sub_type;
248 	u16				length;
249 } __packed;
250 
251 typedef struct efi_generic_dev_path efi_device_path_protocol_t;
252 
253 /*
254  * EFI Boot Services table
255  */
256 typedef struct {
257 	efi_table_hdr_t hdr;
258 	void *raise_tpl;
259 	void *restore_tpl;
260 	efi_status_t(__efiapi *allocate_pages)(int, int, unsigned long,
261 					       efi_physical_addr_t *);
262 	efi_status_t(__efiapi *free_pages)(efi_physical_addr_t,
263 					   unsigned long);
264 	efi_status_t(__efiapi *get_memory_map)(unsigned long *, void *,
265 					       unsigned long *,
266 					       unsigned long *, u32 *);
267 	efi_status_t(__efiapi *allocate_pool)(int, unsigned long,
268 					      void **);
269 	efi_status_t(__efiapi *free_pool)(void *);
270 	efi_status_t(__efiapi *create_event)(u32, unsigned long,
271 					     efi_event_notify_t, void *,
272 					     efi_event_t *);
273 	efi_status_t(__efiapi *set_timer)(efi_event_t,
274 					  EFI_TIMER_DELAY, u64);
275 	efi_status_t(__efiapi *wait_for_event)(unsigned long,
276 					       efi_event_t *,
277 					       unsigned long *);
278 	void *signal_event;
279 	efi_status_t(__efiapi *close_event)(efi_event_t);
280 	void *check_event;
281 	void *install_protocol_interface;
282 	void *reinstall_protocol_interface;
283 	void *uninstall_protocol_interface;
284 	efi_status_t(__efiapi *handle_protocol)(efi_handle_t,
285 						efi_guid_t *, void **);
286 	void *__reserved;
287 	void *register_protocol_notify;
288 	efi_status_t(__efiapi *locate_handle)(int, efi_guid_t *,
289 					      void *, unsigned long *,
290 					      efi_handle_t *);
291 	efi_status_t(__efiapi *locate_device_path)(efi_guid_t *,
292 						   efi_device_path_protocol_t **,
293 						   efi_handle_t *);
294 	efi_status_t(__efiapi *install_configuration_table)(efi_guid_t *,
295 							    void *);
296 	void *load_image;
297 	void *start_image;
298 	efi_status_t(__efiapi *exit)(efi_handle_t,
299 				     efi_status_t,
300 				     unsigned long,
301 				     efi_char16_t *);
302 	void *unload_image;
303 	efi_status_t(__efiapi *exit_boot_services)(efi_handle_t,
304 						   unsigned long);
305 	void *get_next_monotonic_count;
306 	efi_status_t(__efiapi *stall)(unsigned long);
307 	void *set_watchdog_timer;
308 	void *connect_controller;
309 	efi_status_t(__efiapi *disconnect_controller)(efi_handle_t,
310 						      efi_handle_t,
311 						      efi_handle_t);
312 	void *open_protocol;
313 	void *close_protocol;
314 	void *open_protocol_information;
315 	void *protocols_per_handle;
316 	void *locate_handle_buffer;
317 	efi_status_t(__efiapi *locate_protocol)(efi_guid_t *, void *,
318 						void **);
319 	void *install_multiple_protocol_interfaces;
320 	void *uninstall_multiple_protocol_interfaces;
321 	void *calculate_crc32;
322 	void *copy_mem;
323 	void *set_mem;
324 	void *create_event_ex;
325 } efi_boot_services_t;
326 
327 /*
328  * Types and defines for EFI ResetSystem
329  */
330 #define EFI_RESET_COLD 0
331 #define EFI_RESET_WARM 1
332 #define EFI_RESET_SHUTDOWN 2
333 
334 /*
335  * EFI Runtime Services table
336  */
337 #define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL)
338 #define EFI_RUNTIME_SERVICES_REVISION  0x00010000
339 
340 typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc);
341 typedef efi_status_t efi_set_time_t (efi_time_t *tm);
342 typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending,
343 					    efi_time_t *tm);
344 typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm);
345 typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr,
346 					 unsigned long *data_size, void *data);
347 typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name,
348 					      efi_guid_t *vendor);
349 typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor,
350 					 u32 attr, unsigned long data_size,
351 					 void *data);
352 typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count);
353 typedef void efi_reset_system_t (int reset_type, efi_status_t status,
354 				 unsigned long data_size, efi_char16_t *data);
355 typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size,
356 						unsigned long descriptor_size,
357 						u32 descriptor_version,
358 						efi_memory_desc_t *virtual_map);
359 typedef efi_status_t efi_query_variable_info_t(u32 attr,
360 					       u64 *storage_space,
361 					       u64 *remaining_space,
362 					       u64 *max_variable_size);
363 typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **capsules,
364 					  unsigned long count,
365 					  unsigned long sg_list);
366 typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules,
367 					      unsigned long count,
368 					      u64 *max_size,
369 					      int *reset_type);
370 typedef efi_status_t efi_query_variable_store_t(u32 attributes,
371 						unsigned long size,
372 						bool nonblocking);
373 
374 typedef struct {
375 	efi_table_hdr_t				hdr;
376 	efi_get_time_t __efiapi			*get_time;
377 	efi_set_time_t __efiapi			*set_time;
378 	efi_get_wakeup_time_t __efiapi		*get_wakeup_time;
379 	efi_set_wakeup_time_t __efiapi		*set_wakeup_time;
380 	efi_set_virtual_address_map_t __efiapi	*set_virtual_address_map;
381 	void					*convert_pointer;
382 	efi_get_variable_t __efiapi		*get_variable;
383 	efi_get_next_variable_t __efiapi	*get_next_variable;
384 	efi_set_variable_t __efiapi		*set_variable;
385 	efi_get_next_high_mono_count_t __efiapi	*get_next_high_mono_count;
386 	efi_reset_system_t __efiapi		*reset_system;
387 	efi_update_capsule_t __efiapi		*update_capsule;
388 	efi_query_capsule_caps_t __efiapi	*query_capsule_caps;
389 	efi_query_variable_info_t __efiapi	*query_variable_info;
390 } efi_runtime_services_t;
391 
392 #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
393 
394 #define EFI_2_30_SYSTEM_TABLE_REVISION  ((2 << 16) | (30))
395 #define EFI_2_20_SYSTEM_TABLE_REVISION  ((2 << 16) | (20))
396 #define EFI_2_10_SYSTEM_TABLE_REVISION  ((2 << 16) | (10))
397 #define EFI_2_00_SYSTEM_TABLE_REVISION  ((2 << 16) | (00))
398 #define EFI_1_10_SYSTEM_TABLE_REVISION  ((1 << 16) | (10))
399 #define EFI_1_02_SYSTEM_TABLE_REVISION  ((1 << 16) | (02))
400 
401 typedef union efi_simple_text_input_protocol efi_simple_text_input_protocol_t;
402 typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t;
403 
404 typedef struct {
405 	efi_table_hdr_t hdr;
406 	unsigned long fw_vendor;	/* physical addr of CHAR16 vendor string */
407 	u32 fw_revision;
408 	unsigned long con_in_handle;
409 	efi_simple_text_input_protocol_t *con_in;
410 	unsigned long con_out_handle;
411 	efi_simple_text_output_protocol_t *con_out;
412 	unsigned long stderr_handle;
413 	unsigned long stderr;
414 	efi_runtime_services_t *runtime;
415 	efi_boot_services_t *boottime;
416 	unsigned long nr_tables;
417 	unsigned long tables;
418 } efi_system_table_t;
419 
420 struct efi_boot_memmap {
421 	efi_memory_desc_t       **map;
422 	unsigned long           *map_size;
423 	unsigned long           *desc_size;
424 	u32                     *desc_ver;
425 	unsigned long           *key_ptr;
426 	unsigned long           *buff_size;
427 };
428 
429 #define __aligned_u64 u64 __attribute__((aligned(8)))
430 
431 struct efi_loaded_image_64 {
432 	u32			revision;
433 	efi_handle_t		parent_handle;
434 	efi_system_table_t	*system_table;
435 	efi_handle_t		device_handle;
436 	void			*file_path;
437 	void			*reserved;
438 	u32			load_options_size;
439 	void			*load_options;
440 	void			*image_base;
441 	__aligned_u64		image_size;
442 	unsigned int		image_code_type;
443 	unsigned int		image_data_type;
444 	efi_status_t		(__efiapi * unload)(efi_handle_t image_handle);
445 };
446 
447 
448 typedef struct _efi_simple_file_system_protocol efi_simple_file_system_protocol_t;
449 typedef struct _efi_file_protocol efi_file_protocol_t;
450 typedef efi_simple_file_system_protocol_t efi_file_io_interface_t;
451 typedef efi_file_protocol_t efi_file_t;
452 
453 typedef efi_status_t efi_simple_file_system_protocol_open_volume(
454 	efi_simple_file_system_protocol_t *this,
455 	efi_file_protocol_t **root);
456 
457 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID EFI_GUID(0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
458 
459 struct _efi_simple_file_system_protocol {
460 	uint64_t						revision;
461 	efi_simple_file_system_protocol_open_volume __efiapi	*open_volume;
462 };
463 
464 /* Open modes */
465 #define EFI_FILE_MODE_READ    0x0000000000000001ULL
466 #define EFI_FILE_MODE_WRITE   0x0000000000000002ULL
467 #define EFI_FILE_MODE_CREATE  0x8000000000000000ULL
468 
469 typedef efi_status_t efi_file_open(efi_file_protocol_t *this,
470 				   efi_file_protocol_t **new_handle,
471 				   efi_char16_t *file_name,
472 				   uint64_t open_mode,
473 				   uint64_t attributes);
474 typedef efi_status_t efi_file_close(efi_file_protocol_t *this);
475 typedef efi_status_t efi_file_delete(efi_file_protocol_t *this);
476 typedef efi_status_t efi_file_read(efi_file_protocol_t *this,
477 				   uint64_t *buffer_size,
478 				   void *buffer);
479 typedef efi_status_t efi_file_write(efi_file_protocol_t *this,
480 				    uint64_t *buffer_size,
481 				    void *buffer);
482 typedef efi_status_t efi_file_set_position(efi_file_protocol_t *this,
483 					   uint64_t position);
484 typedef efi_status_t efi_file_get_position(efi_file_protocol_t *this,
485 					   uint64_t *position);
486 typedef efi_status_t efi_file_get_info(efi_file_protocol_t *this,
487 				       efi_guid_t *information_type,
488 				       uint64_t *buffer_size,
489 				       void *buffer);
490 typedef efi_status_t efi_file_set_info(efi_file_protocol_t *this,
491 				       efi_guid_t *information_type,
492 				       uint64_t *buffer_size,
493 				       void *buffer);
494 typedef efi_status_t efi_file_flush(efi_file_protocol_t *this);
495 
496 typedef struct {
497 	efi_event_t event;
498 	efi_status_t status;
499 	uint64_t buffer_size;
500 	void *buffer;
501 } efi_file_io_open_t;
502 
503 typedef efi_status_t efi_file_open_ex(efi_file_protocol_t *this,
504 				      efi_file_protocol_t **new_handle,
505 				      efi_char16_t *file_name,
506 				      uint64_t open_mode,
507 				      uint64_t attributes,
508 				      efi_file_io_open_t *token);
509 typedef efi_status_t efi_file_read_ex(efi_file_protocol_t *this,
510 				      efi_file_io_open_t *token);
511 typedef efi_status_t efi_file_write_ex(efi_file_protocol_t *this,
512 				       efi_file_io_open_t *token);
513 typedef efi_status_t efi_file_flush_ex(efi_file_protocol_t *this,
514 				       efi_file_io_open_t *token);
515 
516 struct _efi_file_protocol {
517 	uint64_t			revision;
518 	efi_file_open __efiapi		*open;
519 	efi_file_close __efiapi		*close;
520 	efi_file_delete __efiapi	*delete;
521 	efi_file_read __efiapi		*read;
522 	efi_file_write __efiapi		*write;
523 	efi_file_get_position __efiapi	*get_position;
524 	efi_file_set_position __efiapi	*set_position;
525 	efi_file_get_info __efiapi	*get_info;
526 	efi_file_set_info __efiapi	*set_info;
527 	efi_file_flush __efiapi		*flush;
528 	efi_file_open_ex __efiapi	*open_ex;
529 	efi_file_read_ex __efiapi	*read_ex;
530 	efi_file_write_ex __efiapi	*write_ex;
531 	efi_file_flush_ex __efiapi	*flush_ex;
532 };
533 
534 #define EFI_FILE_INFO_ID EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
535 
536 typedef struct {
537 	uint64_t	size;
538 	uint64_t	file_size;
539 	uint64_t	physical_size;
540 	efi_time_t	create_time;
541 	efi_time_t	last_access_time;
542 	efi_time_t	modification_time;
543 	uint64_t	attributes;
544 	efi_char16_t	file_name[1];
545 } efi_file_info_t;
546 
547 #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__)
548 #define efi_rs_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__)
549 
550 #endif /* __LINUX_UEFI_H */
551