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