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