Merge tag 'uniphier-v2020.04-3' of https://gitlab.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / include / efi_api.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Extensible Firmware Interface
4  * Based on 'Extensible Firmware Interface Specification' version 0.9,
5  * April 30, 1999
6  *
7  * Copyright (C) 1999 VA Linux Systems
8  * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
9  * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
10  *      David Mosberger-Tang <davidm@hpl.hp.com>
11  *      Stephane Eranian <eranian@hpl.hp.com>
12  *
13  * From include/linux/efi.h in kernel 4.1 with some additions/subtractions
14  */
15
16 #ifndef _EFI_API_H
17 #define _EFI_API_H
18
19 #include <efi.h>
20 #include <charset.h>
21
22 #ifdef CONFIG_EFI_LOADER
23 #include <asm/setjmp.h>
24 #endif
25
26 /* UEFI spec version 2.8 */
27 #define EFI_SPECIFICATION_VERSION (2 << 16 | 80)
28
29 /* Types and defines for EFI CreateEvent */
30 enum efi_timer_delay {
31         EFI_TIMER_STOP = 0,
32         EFI_TIMER_PERIODIC = 1,
33         EFI_TIMER_RELATIVE = 2
34 };
35
36 #define efi_intn_t ssize_t
37 #define efi_uintn_t size_t
38 typedef void *efi_hii_handle_t;
39 typedef u16 *efi_string_t;
40 typedef u16 efi_string_id_t;
41 typedef u32 efi_hii_font_style_t;
42 typedef u16 efi_question_id_t;
43 typedef u16 efi_image_id_t;
44 typedef u16 efi_form_id_t;
45
46 #define EVT_TIMER                               0x80000000
47 #define EVT_RUNTIME                             0x40000000
48 #define EVT_NOTIFY_WAIT                         0x00000100
49 #define EVT_NOTIFY_SIGNAL                       0x00000200
50 #define EVT_SIGNAL_EXIT_BOOT_SERVICES           0x00000201
51 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE       0x60000202
52
53 #define TPL_APPLICATION         0x04
54 #define TPL_CALLBACK            0x08
55 #define TPL_NOTIFY              0x10
56 #define TPL_HIGH_LEVEL          0x1F
57
58 struct efi_event;
59
60 /* EFI Boot Services table */
61 #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
62 struct efi_boot_services {
63         struct efi_table_hdr hdr;
64         efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl);
65         void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl);
66
67         efi_status_t (EFIAPI *allocate_pages)(int, int, efi_uintn_t,
68                                               efi_physical_addr_t *);
69         efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, efi_uintn_t);
70         efi_status_t (EFIAPI *get_memory_map)(efi_uintn_t *memory_map_size,
71                                               struct efi_mem_desc *desc,
72                                               efi_uintn_t *key,
73                                               efi_uintn_t *desc_size,
74                                               u32 *desc_version);
75         efi_status_t (EFIAPI *allocate_pool)(int, efi_uintn_t, void **);
76         efi_status_t (EFIAPI *free_pool)(void *);
77
78         efi_status_t (EFIAPI *create_event)(uint32_t type,
79                         efi_uintn_t notify_tpl,
80                         void (EFIAPI *notify_function) (
81                                         struct efi_event *event,
82                                         void *context),
83                         void *notify_context, struct efi_event **event);
84         efi_status_t (EFIAPI *set_timer)(struct efi_event *event,
85                                          enum efi_timer_delay type,
86                                          uint64_t trigger_time);
87         efi_status_t (EFIAPI *wait_for_event)(efi_uintn_t number_of_events,
88                                               struct efi_event **event,
89                                               efi_uintn_t *index);
90         efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
91         efi_status_t (EFIAPI *close_event)(struct efi_event *event);
92         efi_status_t (EFIAPI *check_event)(struct efi_event *event);
93 #define EFI_NATIVE_INTERFACE    0x00000000
94         efi_status_t (EFIAPI *install_protocol_interface)(
95                         efi_handle_t *handle, const efi_guid_t *protocol,
96                         int protocol_interface_type, void *protocol_interface);
97         efi_status_t (EFIAPI *reinstall_protocol_interface)(
98                         efi_handle_t handle, const efi_guid_t *protocol,
99                         void *old_interface, void *new_interface);
100         efi_status_t (EFIAPI *uninstall_protocol_interface)(
101                         efi_handle_t handle, const efi_guid_t *protocol,
102                         void *protocol_interface);
103         efi_status_t (EFIAPI *handle_protocol)(
104                         efi_handle_t handle, const efi_guid_t *protocol,
105                         void **protocol_interface);
106         void *reserved;
107         efi_status_t (EFIAPI *register_protocol_notify)(
108                         const efi_guid_t *protocol, struct efi_event *event,
109                         void **registration);
110         efi_status_t (EFIAPI *locate_handle)(
111                         enum efi_locate_search_type search_type,
112                         const efi_guid_t *protocol, void *search_key,
113                         efi_uintn_t *buffer_size, efi_handle_t *buffer);
114         efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol,
115                         struct efi_device_path **device_path,
116                         efi_handle_t *device);
117         efi_status_t (EFIAPI *install_configuration_table)(
118                         efi_guid_t *guid, void *table);
119
120         efi_status_t (EFIAPI *load_image)(bool boot_policiy,
121                         efi_handle_t parent_image,
122                         struct efi_device_path *file_path, void *source_buffer,
123                         efi_uintn_t source_size, efi_handle_t *image);
124         efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
125                                            efi_uintn_t *exitdata_size,
126                                            u16 **exitdata);
127         efi_status_t (EFIAPI *exit)(efi_handle_t handle,
128                                     efi_status_t exit_status,
129                                     efi_uintn_t exitdata_size, u16 *exitdata);
130         efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle);
131         efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t image_handle,
132                                                   efi_uintn_t map_key);
133
134         efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
135         efi_status_t (EFIAPI *stall)(unsigned long usecs);
136         efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
137                         uint64_t watchdog_code, unsigned long data_size,
138                         uint16_t *watchdog_data);
139         efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
140                         efi_handle_t *driver_image_handle,
141                         struct efi_device_path *remaining_device_path,
142                         bool recursive);
143         efi_status_t (EFIAPI *disconnect_controller)(
144                         efi_handle_t controller_handle,
145                         efi_handle_t driver_image_handle,
146                         efi_handle_t child_handle);
147 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
148 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
149 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
150 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
151 #define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
152 #define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
153         efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
154                         const efi_guid_t *protocol, void **interface,
155                         efi_handle_t agent_handle,
156                         efi_handle_t controller_handle, u32 attributes);
157         efi_status_t (EFIAPI *close_protocol)(
158                         efi_handle_t handle, const efi_guid_t *protocol,
159                         efi_handle_t agent_handle,
160                         efi_handle_t controller_handle);
161         efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
162                         const efi_guid_t *protocol,
163                         struct efi_open_protocol_info_entry **entry_buffer,
164                         efi_uintn_t *entry_count);
165         efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
166                         efi_guid_t ***protocol_buffer,
167                         efi_uintn_t *protocols_buffer_count);
168         efi_status_t (EFIAPI *locate_handle_buffer) (
169                         enum efi_locate_search_type search_type,
170                         const efi_guid_t *protocol, void *search_key,
171                         efi_uintn_t *no_handles, efi_handle_t **buffer);
172         efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
173                         void *registration, void **protocol_interface);
174         efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
175                         efi_handle_t *handle, ...);
176         efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
177                         efi_handle_t handle, ...);
178         efi_status_t (EFIAPI *calculate_crc32)(const void *data,
179                                                efi_uintn_t data_size,
180                                                u32 *crc32);
181         void (EFIAPI *copy_mem)(void *destination, const void *source,
182                         size_t length);
183         void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value);
184         efi_status_t (EFIAPI *create_event_ex)(
185                                 uint32_t type, efi_uintn_t notify_tpl,
186                                 void (EFIAPI *notify_function) (
187                                         struct efi_event *event,
188                                         void *context),
189                                 void *notify_context,
190                                 efi_guid_t *event_group,
191                                 struct efi_event **event);
192 };
193
194 /* Types and defines for EFI ResetSystem */
195 enum efi_reset_type {
196         EFI_RESET_COLD = 0,
197         EFI_RESET_WARM = 1,
198         EFI_RESET_SHUTDOWN = 2,
199         EFI_RESET_PLATFORM_SPECIFIC = 3,
200 };
201
202 /* EFI Runtime Services table */
203 #define EFI_RUNTIME_SERVICES_SIGNATURE  0x56524553544e5552ULL
204
205 #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET      0x00010000
206 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE     0x00020000
207 #define CAPSULE_FLAGS_INITIATE_RESET            0x00040000
208
209 struct efi_capsule_header {
210         efi_guid_t *capsule_guid;
211         u32 header_size;
212         u32 flags;
213         u32 capsule_image_size;
214 };
215
216 #define EFI_RT_SUPPORTED_GET_TIME                       0x0001
217 #define EFI_RT_SUPPORTED_SET_TIME                       0x0002
218 #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME                0x0004
219 #define EFI_RT_SUPPORTED_SET_WAKEUP_TIME                0x0008
220 #define EFI_RT_SUPPORTED_GET_VARIABLE                   0x0010
221 #define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME         0x0020
222 #define EFI_RT_SUPPORTED_SET_VARIABLE                   0x0040
223 #define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP        0x0080
224 #define EFI_RT_SUPPORTED_CONVERT_POINTER                0x0100
225 #define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT  0x0200
226 #define EFI_RT_SUPPORTED_RESET_SYSTEM                   0x0400
227 #define EFI_RT_SUPPORTED_UPDATE_CAPSULE                 0x0800
228 #define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES     0x1000
229 #define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO            0x2000
230
231 #define EFI_RT_PROPERTIES_TABLE_GUID \
232         EFI_GUID(0xeb66918a, 0x7eef, 0x402a, 0x84, 0x2e, \
233                  0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9)
234
235 #define EFI_RT_PROPERTIES_TABLE_VERSION 0x1
236
237 struct efi_rt_properties_table {
238         u16 version;
239         u16 length;
240         u32 runtime_services_supported;
241 };
242
243 struct efi_runtime_services {
244         struct efi_table_hdr hdr;
245         efi_status_t (EFIAPI *get_time)(struct efi_time *time,
246                         struct efi_time_cap *capabilities);
247         efi_status_t (EFIAPI *set_time)(struct efi_time *time);
248         efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
249                         struct efi_time *time);
250         efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
251                         struct efi_time *time);
252         efi_status_t (EFIAPI *set_virtual_address_map)(
253                         efi_uintn_t memory_map_size,
254                         efi_uintn_t descriptor_size,
255                         uint32_t descriptor_version,
256                         struct efi_mem_desc *virtmap);
257         efi_status_t (EFIAPI *convert_pointer)(
258                         efi_uintn_t debug_disposition, void **address);
259         efi_status_t (EFIAPI *get_variable)(u16 *variable_name,
260                                             const efi_guid_t *vendor,
261                                             u32 *attributes,
262                                             efi_uintn_t *data_size, void *data);
263         efi_status_t (EFIAPI *get_next_variable_name)(
264                         efi_uintn_t *variable_name_size,
265                         u16 *variable_name, const efi_guid_t *vendor);
266         efi_status_t (EFIAPI *set_variable)(u16 *variable_name,
267                                             const efi_guid_t *vendor,
268                                             u32 attributes,
269                                             efi_uintn_t data_size,
270                                             const void *data);
271         efi_status_t (EFIAPI *get_next_high_mono_count)(
272                         uint32_t *high_count);
273         void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
274                                     efi_status_t reset_status,
275                                     unsigned long data_size, void *reset_data);
276         efi_status_t (EFIAPI *update_capsule)(
277                         struct efi_capsule_header **capsule_header_array,
278                         efi_uintn_t capsule_count,
279                         u64 scatter_gather_list);
280         efi_status_t (EFIAPI *query_capsule_caps)(
281                         struct efi_capsule_header **capsule_header_array,
282                         efi_uintn_t capsule_count,
283                         u64 *maximum_capsule_size,
284                         u32 *reset_type);
285         efi_status_t (EFIAPI *query_variable_info)(
286                         u32 attributes,
287                         u64 *maximum_variable_storage_size,
288                         u64 *remaining_variable_storage_size,
289                         u64 *maximum_variable_size);
290 };
291
292 /* EFI event group GUID definitions */
293 #define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \
294         EFI_GUID(0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, \
295                  0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf)
296
297 #define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \
298         EFI_GUID(0x13fa7698, 0xc831, 0x49c7, 0x87, 0xea, \
299                  0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96)
300
301 #define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \
302         EFI_GUID(0x78bee926, 0x692f, 0x48fd, 0x9e, 0xdb, \
303                  0x01, 0x42, 0x2e, 0xf0, 0xd7, 0xab)
304
305 #define EFI_EVENT_GROUP_READY_TO_BOOT \
306         EFI_GUID(0x7ce88fb3, 0x4bd7, 0x4679, 0x87, 0xa8, \
307                  0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b)
308
309 #define EFI_EVENT_GROUP_RESET_SYSTEM \
310         EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \
311                  0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b)
312
313 /* EFI Configuration Table and GUID definitions */
314 #define NULL_GUID \
315         EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
316                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
317
318 #define EFI_GLOBAL_VARIABLE_GUID \
319         EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
320                  0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
321
322 #define EFI_FDT_GUID \
323         EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
324                  0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
325
326 #define EFI_ACPI_TABLE_GUID \
327         EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, \
328                  0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
329
330 #define SMBIOS_TABLE_GUID \
331         EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3,  \
332                  0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
333
334 struct efi_configuration_table {
335         efi_guid_t guid;
336         void *table;
337 } __packed;
338
339 #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
340
341 struct efi_system_table {
342         struct efi_table_hdr hdr;
343         u16 *fw_vendor;   /* physical addr of wchar_t vendor string */
344         u32 fw_revision;
345         efi_handle_t con_in_handle;
346         struct efi_simple_text_input_protocol *con_in;
347         efi_handle_t con_out_handle;
348         struct efi_simple_text_output_protocol *con_out;
349         efi_handle_t stderr_handle;
350         struct efi_simple_text_output_protocol *std_err;
351         struct efi_runtime_services *runtime;
352         struct efi_boot_services *boottime;
353         efi_uintn_t nr_tables;
354         struct efi_configuration_table *tables;
355 };
356
357 #define EFI_LOADED_IMAGE_PROTOCOL_GUID \
358         EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
359                  0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
360
361 #define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \
362         EFI_GUID(0xbc62157e, 0x3e33, 0x4fec, \
363                  0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf)
364
365 #define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000
366
367 struct efi_loaded_image {
368         u32 revision;
369         void *parent_handle;
370         struct efi_system_table *system_table;
371         efi_handle_t device_handle;
372         struct efi_device_path *file_path;
373         void *reserved;
374         u32 load_options_size;
375         void *load_options;
376         void *image_base;
377         aligned_u64 image_size;
378         unsigned int image_code_type;
379         unsigned int image_data_type;
380         efi_status_t (EFIAPI *unload)(efi_handle_t image_handle);
381 };
382
383 #define EFI_DEVICE_PATH_PROTOCOL_GUID \
384         EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
385                  0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
386
387 #define DEVICE_PATH_TYPE_END                    0x7f
388 #  define DEVICE_PATH_SUB_TYPE_INSTANCE_END     0x01
389 #  define DEVICE_PATH_SUB_TYPE_END              0xff
390
391 struct efi_device_path {
392         u8 type;
393         u8 sub_type;
394         u16 length;
395 } __packed;
396
397 struct efi_mac_addr {
398         u8 addr[32];
399 } __packed;
400
401 #define DEVICE_PATH_TYPE_HARDWARE_DEVICE        0x01
402 #  define DEVICE_PATH_SUB_TYPE_MEMORY           0x03
403 #  define DEVICE_PATH_SUB_TYPE_VENDOR           0x04
404
405 struct efi_device_path_memory {
406         struct efi_device_path dp;
407         u32 memory_type;
408         u64 start_address;
409         u64 end_address;
410 } __packed;
411
412 struct efi_device_path_vendor {
413         struct efi_device_path dp;
414         efi_guid_t guid;
415         u8 vendor_data[];
416 } __packed;
417
418 #define DEVICE_PATH_TYPE_ACPI_DEVICE            0x02
419 #  define DEVICE_PATH_SUB_TYPE_ACPI_DEVICE      0x01
420
421 #define EFI_PNP_ID(ID)                          (u32)(((ID) << 16) | 0x41D0)
422 #define EISA_PNP_ID(ID)                         EFI_PNP_ID(ID)
423 #define EISA_PNP_NUM(ID)                        ((ID) >> 16)
424
425 struct efi_device_path_acpi_path {
426         struct efi_device_path dp;
427         u32 hid;
428         u32 uid;
429 } __packed;
430
431 #define DEVICE_PATH_TYPE_MESSAGING_DEVICE       0x03
432 #  define DEVICE_PATH_SUB_TYPE_MSG_ATAPI        0x01
433 #  define DEVICE_PATH_SUB_TYPE_MSG_SCSI         0x02
434 #  define DEVICE_PATH_SUB_TYPE_MSG_USB          0x05
435 #  define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR     0x0b
436 #  define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS    0x0f
437 #  define DEVICE_PATH_SUB_TYPE_MSG_NVME         0x17
438 #  define DEVICE_PATH_SUB_TYPE_MSG_SD           0x1a
439 #  define DEVICE_PATH_SUB_TYPE_MSG_MMC          0x1d
440
441 struct efi_device_path_atapi {
442         struct efi_device_path dp;
443         u8 primary_secondary;
444         u8 slave_master;
445         u16 logical_unit_number;
446 } __packed;
447
448 struct efi_device_path_scsi {
449         struct efi_device_path dp;
450         u16 target_id;
451         u16 logical_unit_number;
452 } __packed;
453
454 struct efi_device_path_usb {
455         struct efi_device_path dp;
456         u8 parent_port_number;
457         u8 usb_interface;
458 } __packed;
459
460 struct efi_device_path_mac_addr {
461         struct efi_device_path dp;
462         struct efi_mac_addr mac;
463         u8 if_type;
464 } __packed;
465
466 struct efi_device_path_usb_class {
467         struct efi_device_path dp;
468         u16 vendor_id;
469         u16 product_id;
470         u8 device_class;
471         u8 device_subclass;
472         u8 device_protocol;
473 } __packed;
474
475 struct efi_device_path_sd_mmc_path {
476         struct efi_device_path dp;
477         u8 slot_number;
478 } __packed;
479
480 struct efi_device_path_nvme {
481         struct efi_device_path dp;
482         u32 ns_id;
483         u8 eui64[8];
484 } __packed;
485
486 #define DEVICE_PATH_TYPE_MEDIA_DEVICE           0x04
487 #  define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH  0x01
488 #  define DEVICE_PATH_SUB_TYPE_CDROM_PATH       0x02
489 #  define DEVICE_PATH_SUB_TYPE_FILE_PATH        0x04
490
491 struct efi_device_path_hard_drive_path {
492         struct efi_device_path dp;
493         u32 partition_number;
494         u64 partition_start;
495         u64 partition_end;
496         u8 partition_signature[16];
497         u8 partmap_type;
498         u8 signature_type;
499 } __packed;
500
501 struct efi_device_path_cdrom_path {
502         struct efi_device_path dp;
503         u32 boot_entry;
504         u64 partition_start;
505         u64 partition_size;
506 } __packed;
507
508 struct efi_device_path_file_path {
509         struct efi_device_path dp;
510         u16 str[];
511 } __packed;
512
513 #define EFI_BLOCK_IO_PROTOCOL_GUID \
514         EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
515                  0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
516
517 struct efi_block_io_media {
518         u32 media_id;
519         char removable_media;
520         char media_present;
521         char logical_partition;
522         char read_only;
523         char write_caching;
524         u8 pad[3];
525         u32 block_size;
526         u32 io_align;
527         u8 pad2[4];
528         u64 last_block;
529         /* Added in revision 2 of the protocol */
530         u64 lowest_aligned_lba;
531         u32 logical_blocks_per_physical_block;
532         /* Added in revision 3 of the protocol */
533         u32 optimal_transfer_length_granualarity;
534 };
535
536 #define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
537 #define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x0002001f
538
539 struct efi_block_io {
540         u64 revision;
541         struct efi_block_io_media *media;
542         efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
543                         char extended_verification);
544         efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
545                         u32 media_id, u64 lba, efi_uintn_t buffer_size,
546                         void *buffer);
547         efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
548                         u32 media_id, u64 lba, efi_uintn_t buffer_size,
549                         void *buffer);
550         efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
551 };
552
553 struct simple_text_output_mode {
554         s32 max_mode;
555         s32 mode;
556         s32 attribute;
557         s32 cursor_column;
558         s32 cursor_row;
559         bool cursor_visible;
560 };
561
562 #define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
563         EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
564                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
565
566 #define EFI_BLACK                0x00
567 #define EFI_BLUE                 0x01
568 #define EFI_GREEN                0x02
569 #define EFI_CYAN                 0x03
570 #define EFI_RED                  0x04
571 #define EFI_MAGENTA              0x05
572 #define EFI_BROWN                0x06
573 #define EFI_LIGHTGRAY            0x07
574 #define EFI_BRIGHT               0x08
575 #define EFI_DARKGRAY             0x08
576 #define EFI_LIGHTBLUE            0x09
577 #define EFI_LIGHTGREEN           0x0a
578 #define EFI_LIGHTCYAN            0x0b
579 #define EFI_LIGHTRED             0x0c
580 #define EFI_LIGHTMAGENTA         0x0d
581 #define EFI_YELLOW               0x0e
582 #define EFI_WHITE                0x0f
583 #define EFI_BACKGROUND_BLACK     0x00
584 #define EFI_BACKGROUND_BLUE      0x10
585 #define EFI_BACKGROUND_GREEN     0x20
586 #define EFI_BACKGROUND_CYAN      0x30
587 #define EFI_BACKGROUND_RED       0x40
588 #define EFI_BACKGROUND_MAGENTA   0x50
589 #define EFI_BACKGROUND_BROWN     0x60
590 #define EFI_BACKGROUND_LIGHTGRAY 0x70
591
592 /* extract foreground color from EFI attribute */
593 #define EFI_ATTR_FG(attr)        ((attr) & 0x07)
594 /* treat high bit of FG as bright/bold (similar to edk2) */
595 #define EFI_ATTR_BOLD(attr)      (((attr) >> 3) & 0x01)
596 /* extract background color from EFI attribute */
597 #define EFI_ATTR_BG(attr)        (((attr) >> 4) & 0x7)
598
599 struct efi_simple_text_output_protocol {
600         efi_status_t (EFIAPI *reset)(
601                         struct efi_simple_text_output_protocol *this,
602                         char extended_verification);
603         efi_status_t (EFIAPI *output_string)(
604                         struct efi_simple_text_output_protocol *this,
605                         const efi_string_t str);
606         efi_status_t (EFIAPI *test_string)(
607                         struct efi_simple_text_output_protocol *this,
608                         const efi_string_t str);
609         efi_status_t(EFIAPI *query_mode)(
610                         struct efi_simple_text_output_protocol *this,
611                         unsigned long mode_number, unsigned long *columns,
612                         unsigned long *rows);
613         efi_status_t(EFIAPI *set_mode)(
614                         struct efi_simple_text_output_protocol *this,
615                         unsigned long mode_number);
616         efi_status_t(EFIAPI *set_attribute)(
617                         struct efi_simple_text_output_protocol *this,
618                         unsigned long attribute);
619         efi_status_t(EFIAPI *clear_screen) (
620                         struct efi_simple_text_output_protocol *this);
621         efi_status_t(EFIAPI *set_cursor_position) (
622                         struct efi_simple_text_output_protocol *this,
623                         unsigned long column, unsigned long row);
624         efi_status_t(EFIAPI *enable_cursor)(
625                         struct efi_simple_text_output_protocol *this,
626                         bool enable);
627         struct simple_text_output_mode *mode;
628 };
629
630 #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
631         EFI_GUID(0xdd9e7534, 0x7762, 0x4698, \
632                  0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa)
633
634 struct efi_input_key {
635         u16 scan_code;
636         s16 unicode_char;
637 };
638
639 #define EFI_SHIFT_STATE_INVALID         0x00000000
640 #define EFI_RIGHT_SHIFT_PRESSED         0x00000001
641 #define EFI_LEFT_SHIFT_PRESSED          0x00000002
642 #define EFI_RIGHT_CONTROL_PRESSED       0x00000004
643 #define EFI_LEFT_CONTROL_PRESSED        0x00000008
644 #define EFI_RIGHT_ALT_PRESSED           0x00000010
645 #define EFI_LEFT_ALT_PRESSED            0x00000020
646 #define EFI_RIGHT_LOGO_PRESSED          0x00000040
647 #define EFI_LEFT_LOGO_PRESSED           0x00000080
648 #define EFI_MENU_KEY_PRESSED            0x00000100
649 #define EFI_SYS_REQ_PRESSED             0x00000200
650 #define EFI_SHIFT_STATE_VALID           0x80000000
651
652 #define EFI_TOGGLE_STATE_INVALID        0x00
653 #define EFI_SCROLL_LOCK_ACTIVE          0x01
654 #define EFI_NUM_LOCK_ACTIVE             0x02
655 #define EFI_CAPS_LOCK_ACTIVE            0x04
656 #define EFI_KEY_STATE_EXPOSED           0x40
657 #define EFI_TOGGLE_STATE_VALID          0x80
658
659 struct efi_key_state {
660         u32 key_shift_state;
661         u8 key_toggle_state;
662 };
663
664 struct efi_key_data {
665         struct efi_input_key key;
666         struct efi_key_state key_state;
667 };
668
669 struct efi_simple_text_input_ex_protocol {
670         efi_status_t (EFIAPI *reset) (
671                 struct efi_simple_text_input_ex_protocol *this,
672                 bool extended_verification);
673         efi_status_t (EFIAPI *read_key_stroke_ex) (
674                 struct efi_simple_text_input_ex_protocol *this,
675                 struct efi_key_data *key_data);
676         struct efi_event *wait_for_key_ex;
677         efi_status_t (EFIAPI *set_state) (
678                 struct efi_simple_text_input_ex_protocol *this,
679                 u8 *key_toggle_state);
680         efi_status_t (EFIAPI *register_key_notify) (
681                 struct efi_simple_text_input_ex_protocol *this,
682                 struct efi_key_data *key_data,
683                 efi_status_t (EFIAPI *key_notify_function)(
684                         struct efi_key_data *key_data),
685                 void **notify_handle);
686         efi_status_t (EFIAPI *unregister_key_notify) (
687                 struct efi_simple_text_input_ex_protocol *this,
688                 void *notification_handle);
689 };
690
691 #define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
692         EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \
693                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
694
695 struct efi_simple_text_input_protocol {
696         efi_status_t(EFIAPI *reset)(struct efi_simple_text_input_protocol *this,
697                                     bool extended_verification);
698         efi_status_t(EFIAPI *read_key_stroke)(
699                         struct efi_simple_text_input_protocol *this,
700                         struct efi_input_key *key);
701         struct efi_event *wait_for_key;
702 };
703
704 #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
705         EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
706                  0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
707
708 struct efi_device_path_to_text_protocol {
709         uint16_t *(EFIAPI *convert_device_node_to_text)(
710                         struct efi_device_path *device_node,
711                         bool display_only,
712                         bool allow_shortcuts);
713         uint16_t *(EFIAPI *convert_device_path_to_text)(
714                         struct efi_device_path *device_path,
715                         bool display_only,
716                         bool allow_shortcuts);
717 };
718
719 #define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
720         EFI_GUID(0x0379be4e, 0xd706, 0x437d, \
721                  0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4)
722
723 struct efi_device_path_utilities_protocol {
724         efi_uintn_t (EFIAPI *get_device_path_size)(
725                 const struct efi_device_path *device_path);
726         struct efi_device_path *(EFIAPI *duplicate_device_path)(
727                 const struct efi_device_path *device_path);
728         struct efi_device_path *(EFIAPI *append_device_path)(
729                 const struct efi_device_path *src1,
730                 const struct efi_device_path *src2);
731         struct efi_device_path *(EFIAPI *append_device_node)(
732                 const struct efi_device_path *device_path,
733                 const struct efi_device_path *device_node);
734         struct efi_device_path *(EFIAPI *append_device_path_instance)(
735                 const struct efi_device_path *device_path,
736                 const struct efi_device_path *device_path_instance);
737         struct efi_device_path *(EFIAPI *get_next_device_path_instance)(
738                 struct efi_device_path **device_path_instance,
739                 efi_uintn_t *device_path_instance_size);
740         bool (EFIAPI *is_device_path_multi_instance)(
741                 const struct efi_device_path *device_path);
742         struct efi_device_path *(EFIAPI *create_device_node)(
743                 uint8_t node_type,
744                 uint8_t node_sub_type,
745                 uint16_t node_length);
746 };
747
748 /*
749  * Human Interface Infrastructure (HII)
750  */
751 struct efi_hii_package_list_header {
752         efi_guid_t package_list_guid;
753         u32 package_length;
754 } __packed;
755
756 /**
757  * struct efi_hii_package_header - EFI HII package header
758  *
759  * @fields:     'fields' replaces the bit-fields defined in the EFI
760  *              specification to to avoid possible compiler incompatibilities::
761  *
762  *              u32 length:24;
763  *              u32 type:8;
764  */
765 struct efi_hii_package_header {
766         u32 fields;
767 } __packed;
768
769 #define __EFI_HII_PACKAGE_LEN_SHIFT     0
770 #define __EFI_HII_PACKAGE_TYPE_SHIFT    24
771 #define __EFI_HII_PACKAGE_LEN_MASK      0xffffff
772 #define __EFI_HII_PACKAGE_TYPE_MASK     0xff
773
774 #define EFI_HII_PACKAGE_TYPE_ALL          0x00
775 #define EFI_HII_PACKAGE_TYPE_GUID         0x01
776 #define EFI_HII_PACKAGE_FORMS             0x02
777 #define EFI_HII_PACKAGE_STRINGS           0x04
778 #define EFI_HII_PACKAGE_FONTS             0x05
779 #define EFI_HII_PACKAGE_IMAGES            0x06
780 #define EFI_HII_PACKAGE_SIMPLE_FONTS      0x07
781 #define EFI_HII_PACKAGE_DEVICE_PATH       0x08
782 #define EFI_HII_PACKAGE_KEYBOARD_LAYOUT   0x09
783 #define EFI_HII_PACKAGE_ANIMATIONS        0x0A
784 #define EFI_HII_PACKAGE_END               0xDF
785 #define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0
786 #define EFI_HII_PACKAGE_TYPE_SYSTEM_END   0xFF
787
788 /*
789  * HII GUID package
790  */
791 struct efi_hii_guid_package {
792         struct efi_hii_package_header header;
793         efi_guid_t guid;
794         char data[];
795 } __packed;
796
797 /*
798  * HII string package
799  */
800 struct efi_hii_strings_package {
801         struct efi_hii_package_header header;
802         u32 header_size;
803         u32 string_info_offset;
804         u16 language_window[16];
805         efi_string_id_t language_name;
806         u8  language[];
807 } __packed;
808
809 struct efi_hii_string_block {
810         u8 block_type;
811         /* u8 block_body[]; */
812 } __packed;
813
814 #define EFI_HII_SIBT_END               0x00
815 #define EFI_HII_SIBT_STRING_SCSU       0x10
816 #define EFI_HII_SIBT_STRING_SCSU_FONT  0x11
817 #define EFI_HII_SIBT_STRINGS_SCSU      0x12
818 #define EFI_HII_SIBT_STRINGS_SCSU_FONT 0x13
819 #define EFI_HII_SIBT_STRING_UCS2       0x14
820 #define EFI_HII_SIBT_STRING_UCS2_FONT  0x15
821 #define EFI_HII_SIBT_STRINGS_UCS2      0x16
822 #define EFI_HII_SIBT_STRINGS_UCS2_FONT 0x17
823 #define EFI_HII_SIBT_DUPLICATE         0x20
824 #define EFI_HII_SIBT_SKIP2             0x21
825 #define EFI_HII_SIBT_SKIP1             0x22
826 #define EFI_HII_SIBT_EXT1              0x30
827 #define EFI_HII_SIBT_EXT2              0x31
828 #define EFI_HII_SIBT_EXT4              0x32
829 #define EFI_HII_SIBT_FONT              0x40
830
831 struct efi_hii_sibt_string_ucs2_block {
832         struct efi_hii_string_block header;
833         u16 string_text[];
834 } __packed;
835
836 static inline struct efi_hii_string_block *
837 efi_hii_sibt_string_ucs2_block_next(struct efi_hii_sibt_string_ucs2_block *blk)
838 {
839         return ((void *)blk) + sizeof(*blk) +
840                 (u16_strlen(blk->string_text) + 1) * 2;
841 }
842
843 /*
844  * HII forms package
845  * TODO: full scope of definitions
846  */
847 struct efi_hii_time {
848         u8 hour;
849         u8 minute;
850         u8 second;
851 };
852
853 struct efi_hii_date {
854         u16 year;
855         u8 month;
856         u8 day;
857 };
858
859 struct efi_hii_ref {
860         efi_question_id_t question_id;
861         efi_form_id_t form_id;
862         efi_guid_t form_set_guid;
863         efi_string_id_t device_path;
864 };
865
866 union efi_ifr_type_value {
867         u8 u8;                          // EFI_IFR_TYPE_NUM_SIZE_8
868         u16 u16;                        // EFI_IFR_TYPE_NUM_SIZE_16
869         u32 u32;                        // EFI_IFR_TYPE_NUM_SIZE_32
870         u64 u64;                        // EFI_IFR_TYPE_NUM_SIZE_64
871         bool b;                         // EFI_IFR_TYPE_BOOLEAN
872         struct efi_hii_time time;       // EFI_IFR_TYPE_TIME
873         struct efi_hii_date date;       // EFI_IFR_TYPE_DATE
874         efi_string_id_t string; // EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION
875         struct efi_hii_ref ref;         // EFI_IFR_TYPE_REF
876         // u8 buffer[];                 // EFI_IFR_TYPE_BUFFER
877 };
878
879 #define EFI_IFR_TYPE_NUM_SIZE_8         0x00
880 #define EFI_IFR_TYPE_NUM_SIZE_16        0x01
881 #define EFI_IFR_TYPE_NUM_SIZE_32        0x02
882 #define EFI_IFR_TYPE_NUM_SIZE_64        0x03
883 #define EFI_IFR_TYPE_BOOLEAN            0x04
884 #define EFI_IFR_TYPE_TIME               0x05
885 #define EFI_IFR_TYPE_DATE               0x06
886 #define EFI_IFR_TYPE_STRING             0x07
887 #define EFI_IFR_TYPE_OTHER              0x08
888 #define EFI_IFR_TYPE_UNDEFINED          0x09
889 #define EFI_IFR_TYPE_ACTION             0x0A
890 #define EFI_IFR_TYPE_BUFFER             0x0B
891 #define EFI_IFR_TYPE_REF                0x0C
892 #define EFI_IFR_OPTION_DEFAULT          0x10
893 #define EFI_IFR_OPTION_DEFAULT_MFG      0x20
894
895 #define EFI_IFR_ONE_OF_OPTION_OP        0x09
896
897 struct efi_ifr_op_header {
898         u8 opCode;
899         u8 length:7;
900         u8 scope:1;
901 };
902
903 struct efi_ifr_one_of_option {
904         struct efi_ifr_op_header header;
905         efi_string_id_t option;
906         u8 flags;
907         u8 type;
908         union efi_ifr_type_value value;
909 };
910
911 typedef efi_uintn_t efi_browser_action_t;
912
913 #define EFI_BROWSER_ACTION_REQUEST_NONE                 0
914 #define EFI_BROWSER_ACTION_REQUEST_RESET                1
915 #define EFI_BROWSER_ACTION_REQUEST_SUBMIT               2
916 #define EFI_BROWSER_ACTION_REQUEST_EXIT                 3
917 #define EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT     4
918 #define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT    5
919 #define EFI_BROWSER_ACTION_REQUEST_FORM_APPLY           6
920 #define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD         7
921 #define EFI_BROWSER_ACTION_REQUEST_RECONNECT            8
922
923 typedef efi_uintn_t efi_browser_action_request_t;
924
925 #define EFI_BROWSER_ACTION_CHANGING                     0
926 #define EFI_BROWSER_ACTION_CHANGED                      1
927 #define EFI_BROWSER_ACTION_RETRIEVE                     2
928 #define EFI_BROWSER_ACTION_FORM_OPEN                    3
929 #define EFI_BROWSER_ACTION_FORM_CLOSE                   4
930 #define EFI_BROWSER_ACTION_SUBMITTED                    5
931 #define EFI_BROWSER_ACTION_DEFAULT_STANDARD             0x1000
932 #define EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING        0x1001
933 #define EFI_BROWSER_ACTION_DEFAULT_SAFE                 0x1002
934 #define EFI_BROWSER_ACTION_DEFAULT_PLATFORM             0x2000
935 #define EFI_BROWSER_ACTION_DEFAULT_HARDWARE             0x3000
936 #define EFI_BROWSER_ACTION_DEFAULT_FIRMWARE             0x4000
937
938 /*
939  * HII keyboard package
940  */
941 typedef enum {
942         EFI_KEY_LCTRL, EFI_KEY_A0, EFI_KEY_LALT, EFI_KEY_SPACE_BAR,
943         EFI_KEY_A2, EFI_KEY_A3, EFI_KEY_A4, EFI_KEY_RCTRL, EFI_KEY_LEFT_ARROW,
944         EFI_KEY_DOWN_ARROW, EFI_KEY_RIGHT_ARROW, EFI_KEY_ZERO,
945         EFI_KEY_PERIOD, EFI_KEY_ENTER, EFI_KEY_LSHIFT, EFI_KEY_B0,
946         EFI_KEY_B1, EFI_KEY_B2, EFI_KEY_B3, EFI_KEY_B4, EFI_KEY_B5, EFI_KEY_B6,
947         EFI_KEY_B7, EFI_KEY_B8, EFI_KEY_B9, EFI_KEY_B10, EFI_KEY_RSHIFT,
948         EFI_KEY_UP_ARROW, EFI_KEY_ONE, EFI_KEY_TWO, EFI_KEY_THREE,
949         EFI_KEY_CAPS_LOCK, EFI_KEY_C1, EFI_KEY_C2, EFI_KEY_C3, EFI_KEY_C4,
950         EFI_KEY_C5, EFI_KEY_C6, EFI_KEY_C7, EFI_KEY_C8, EFI_KEY_C9,
951         EFI_KEY_C10, EFI_KEY_C11, EFI_KEY_C12, EFI_KEY_FOUR, EFI_KEY_FIVE,
952         EFI_KEY_SIX, EFI_KEY_PLUS, EFI_KEY_TAB, EFI_KEY_D1, EFI_KEY_D2,
953         EFI_KEY_D3, EFI_KEY_D4, EFI_KEY_D5, EFI_KEY_D6, EFI_KEY_D7, EFI_KEY_D8,
954         EFI_KEY_D9, EFI_KEY_D10, EFI_KEY_D11, EFI_KEY_D12, EFI_KEY_D13,
955         EFI_KEY_DEL, EFI_KEY_END, EFI_KEY_PG_DN, EFI_KEY_SEVEN, EFI_KEY_EIGHT,
956         EFI_KEY_NINE, EFI_KEY_E0, EFI_KEY_E1, EFI_KEY_E2, EFI_KEY_E3,
957         EFI_KEY_E4, EFI_KEY_E5, EFI_KEY_E6, EFI_KEY_E7, EFI_KEY_E8, EFI_KEY_E9,
958         EFI_KEY_E10, EFI_KEY_E11, EFI_KEY_E12, EFI_KEY_BACK_SPACE,
959         EFI_KEY_INS, EFI_KEY_HOME, EFI_KEY_PG_UP, EFI_KEY_NLCK, EFI_KEY_SLASH,
960         EFI_KEY_ASTERISK, EFI_KEY_MINUS, EFI_KEY_ESC, EFI_KEY_F1, EFI_KEY_F2,
961         EFI_KEY_F3, EFI_KEY_F4, EFI_KEY_F5, EFI_KEY_F6, EFI_KEY_F7, EFI_KEY_F8,
962         EFI_KEY_F9, EFI_KEY_F10, EFI_KEY_F11, EFI_KEY_F12, EFI_KEY_PRINT,
963         EFI_KEY_SLCK, EFI_KEY_PAUSE,
964 } efi_key;
965
966 struct efi_key_descriptor {
967         u32 key;
968         u16 unicode;
969         u16 shifted_unicode;
970         u16 alt_gr_unicode;
971         u16 shifted_alt_gr_unicode;
972         u16 modifier;
973         u16 affected_attribute;
974 } __packed;
975
976 struct efi_hii_keyboard_layout {
977         u16 layout_length;
978         efi_guid_t guid;
979         u32 layout_descriptor_string_offset;
980         u8 descriptor_count;
981         struct efi_key_descriptor descriptors[];
982 } __packed;
983
984 struct efi_hii_keyboard_package {
985         struct efi_hii_package_header header;
986         u16 layout_count;
987         struct efi_hii_keyboard_layout layout[];
988 } __packed;
989
990 /*
991  * HII protocols
992  */
993 #define EFI_HII_STRING_PROTOCOL_GUID \
994         EFI_GUID(0x0fd96974, 0x23aa, 0x4cdc, \
995                  0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a)
996
997 struct efi_font_info {
998         efi_hii_font_style_t font_style;
999         u16 font_size;
1000         u16 font_name[1];
1001 };
1002
1003 struct efi_hii_string_protocol {
1004         efi_status_t(EFIAPI *new_string)(
1005                 const struct efi_hii_string_protocol *this,
1006                 efi_hii_handle_t package_list,
1007                 efi_string_id_t *string_id,
1008                 const u8 *language,
1009                 const u16 *language_name,
1010                 const efi_string_t string,
1011                 const struct efi_font_info *string_font_info);
1012         efi_status_t(EFIAPI *get_string)(
1013                 const struct efi_hii_string_protocol *this,
1014                 const u8 *language,
1015                 efi_hii_handle_t package_list,
1016                 efi_string_id_t string_id,
1017                 efi_string_t string,
1018                 efi_uintn_t *string_size,
1019                 struct efi_font_info **string_font_info);
1020         efi_status_t(EFIAPI *set_string)(
1021                 const struct efi_hii_string_protocol *this,
1022                 efi_hii_handle_t package_list,
1023                 efi_string_id_t string_id,
1024                 const u8 *language,
1025                 const efi_string_t string,
1026                 const struct efi_font_info *string_font_info);
1027         efi_status_t(EFIAPI *get_languages)(
1028                 const struct efi_hii_string_protocol *this,
1029                 efi_hii_handle_t package_list,
1030                 u8 *languages,
1031                 efi_uintn_t *languages_size);
1032         efi_status_t(EFIAPI *get_secondary_languages)(
1033                 const struct efi_hii_string_protocol *this,
1034                 efi_hii_handle_t package_list,
1035                 const u8 *primary_language,
1036                 u8 *secondary_languages,
1037                 efi_uintn_t *secondary_languages_size);
1038 };
1039
1040 #define EFI_HII_DATABASE_PROTOCOL_GUID       \
1041         EFI_GUID(0xef9fc172, 0xa1b2, 0x4693, \
1042                  0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42)
1043
1044 struct efi_hii_database_protocol {
1045         efi_status_t(EFIAPI *new_package_list)(
1046                 const struct efi_hii_database_protocol *this,
1047                 const struct efi_hii_package_list_header *package_list,
1048                 const efi_handle_t driver_handle,
1049                 efi_hii_handle_t *handle);
1050         efi_status_t(EFIAPI *remove_package_list)(
1051                 const struct efi_hii_database_protocol *this,
1052                 efi_hii_handle_t handle);
1053         efi_status_t(EFIAPI *update_package_list)(
1054                 const struct efi_hii_database_protocol *this,
1055                 efi_hii_handle_t handle,
1056                 const struct efi_hii_package_list_header *package_list);
1057         efi_status_t(EFIAPI *list_package_lists)(
1058                 const struct efi_hii_database_protocol *this,
1059                 u8 package_type,
1060                 const efi_guid_t *package_guid,
1061                 efi_uintn_t *handle_buffer_length,
1062                 efi_hii_handle_t *handle);
1063         efi_status_t(EFIAPI *export_package_lists)(
1064                 const struct efi_hii_database_protocol *this,
1065                 efi_hii_handle_t handle,
1066                 efi_uintn_t *buffer_size,
1067                 struct efi_hii_package_list_header *buffer);
1068         efi_status_t(EFIAPI *register_package_notify)(
1069                 const struct efi_hii_database_protocol *this,
1070                 u8 package_type,
1071                 const efi_guid_t *package_guid,
1072                 const void *package_notify_fn,
1073                 efi_uintn_t notify_type,
1074                 efi_handle_t *notify_handle);
1075         efi_status_t(EFIAPI *unregister_package_notify)(
1076                 const struct efi_hii_database_protocol *this,
1077                 efi_handle_t notification_handle
1078                 );
1079         efi_status_t(EFIAPI *find_keyboard_layouts)(
1080                 const struct efi_hii_database_protocol *this,
1081                 u16 *key_guid_buffer_length,
1082                 efi_guid_t *key_guid_buffer);
1083         efi_status_t(EFIAPI *get_keyboard_layout)(
1084                 const struct efi_hii_database_protocol *this,
1085                 efi_guid_t *key_guid,
1086                 u16 *keyboard_layout_length,
1087                 struct efi_hii_keyboard_layout *keyboard_layout);
1088         efi_status_t(EFIAPI *set_keyboard_layout)(
1089                 const struct efi_hii_database_protocol *this,
1090                 efi_guid_t *key_guid);
1091         efi_status_t(EFIAPI *get_package_list_handle)(
1092                 const struct efi_hii_database_protocol *this,
1093                 efi_hii_handle_t package_list_handle,
1094                 efi_handle_t *driver_handle);
1095 };
1096
1097 #define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
1098         EFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \
1099                  0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f)
1100
1101 struct efi_hii_config_routing_protocol {
1102         efi_status_t(EFIAPI *extract_config)(
1103                 const struct efi_hii_config_routing_protocol *this,
1104                 const efi_string_t request,
1105                 efi_string_t *progress,
1106                 efi_string_t *results);
1107         efi_status_t(EFIAPI *export_config)(
1108                 const struct efi_hii_config_routing_protocol *this,
1109                 efi_string_t *results);
1110         efi_status_t(EFIAPI *route_config)(
1111                 const struct efi_hii_config_routing_protocol *this,
1112                 const efi_string_t configuration,
1113                 efi_string_t *progress);
1114         efi_status_t(EFIAPI *block_to_config)(
1115                 const struct efi_hii_config_routing_protocol *this,
1116                 const efi_string_t config_request,
1117                 const uint8_t *block,
1118                 const efi_uintn_t block_size,
1119                 efi_string_t *config,
1120                 efi_string_t *progress);
1121         efi_status_t(EFIAPI *config_to_block)(
1122                 const struct efi_hii_config_routing_protocol *this,
1123                 const efi_string_t config_resp,
1124                 const uint8_t *block,
1125                 const efi_uintn_t *block_size,
1126                 efi_string_t *progress);
1127         efi_status_t(EFIAPI *get_alt_config)(
1128                 const struct efi_hii_config_routing_protocol *this,
1129                 const efi_string_t config_resp,
1130                 const efi_guid_t *guid,
1131                 const efi_string_t name,
1132                 const struct efi_device_path *device_path,
1133                 const efi_string_t alt_cfg_id,
1134                 efi_string_t *alt_cfg_resp);
1135 };
1136
1137 #define EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID \
1138         EFI_GUID(0x330d4706, 0xf2a0, 0x4e4f, \
1139                  0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85)
1140
1141 struct efi_hii_config_access_protocol {
1142         efi_status_t(EFIAPI *extract_config_access)(
1143                 const struct efi_hii_config_access_protocol *this,
1144                 const efi_string_t request,
1145                 efi_string_t *progress,
1146                 efi_string_t *results);
1147         efi_status_t(EFIAPI *route_config_access)(
1148                 const struct efi_hii_config_access_protocol *this,
1149                 const efi_string_t configuration,
1150                 efi_string_t *progress);
1151         efi_status_t(EFIAPI *form_callback)(
1152                 const struct efi_hii_config_access_protocol *this,
1153                 efi_browser_action_t action,
1154                 efi_question_id_t question_id,
1155                 u8 type,
1156                 union efi_ifr_type_value *value,
1157                 efi_browser_action_request_t *action_request);
1158 };
1159
1160 #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
1161         EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
1162                  0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
1163
1164 #define EFI_GOT_RGBA8           0
1165 #define EFI_GOT_BGRA8           1
1166 #define EFI_GOT_BITMASK         2
1167
1168 struct efi_gop_mode_info {
1169         u32 version;
1170         u32 width;
1171         u32 height;
1172         u32 pixel_format;
1173         u32 pixel_bitmask[4];
1174         u32 pixels_per_scanline;
1175 };
1176
1177 struct efi_gop_mode {
1178         u32 max_mode;
1179         u32 mode;
1180         struct efi_gop_mode_info *info;
1181         unsigned long info_size;
1182         efi_physical_addr_t fb_base;
1183         unsigned long fb_size;
1184 };
1185
1186 struct efi_gop_pixel {
1187         u8 blue;
1188         u8 green;
1189         u8 red;
1190         u8 reserved;
1191 };
1192
1193 #define EFI_BLT_VIDEO_FILL              0
1194 #define EFI_BLT_VIDEO_TO_BLT_BUFFER     1
1195 #define EFI_BLT_BUFFER_TO_VIDEO         2
1196 #define EFI_BLT_VIDEO_TO_VIDEO          3
1197
1198 struct efi_gop {
1199         efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
1200                                           efi_uintn_t *size_of_info,
1201                                           struct efi_gop_mode_info **info);
1202         efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
1203         efi_status_t (EFIAPI *blt)(struct efi_gop *this,
1204                                    struct efi_gop_pixel *buffer,
1205                                    u32 operation, efi_uintn_t sx,
1206                                    efi_uintn_t sy, efi_uintn_t dx,
1207                                    efi_uintn_t dy, efi_uintn_t width,
1208                                    efi_uintn_t height, efi_uintn_t delta);
1209         struct efi_gop_mode *mode;
1210 };
1211
1212 #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
1213         EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \
1214                  0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
1215
1216 struct efi_mac_address {
1217         char mac_addr[32];
1218 };
1219
1220 struct efi_ip_address {
1221         u8 ip_addr[16];
1222 } __attribute__((aligned(4)));
1223
1224 enum efi_simple_network_state {
1225         EFI_NETWORK_STOPPED,
1226         EFI_NETWORK_STARTED,
1227         EFI_NETWORK_INITIALIZED,
1228 };
1229
1230 struct efi_simple_network_mode {
1231         enum efi_simple_network_state state;
1232         u32 hwaddr_size;
1233         u32 media_header_size;
1234         u32 max_packet_size;
1235         u32 nvram_size;
1236         u32 nvram_access_size;
1237         u32 receive_filter_mask;
1238         u32 receive_filter_setting;
1239         u32 max_mcast_filter_count;
1240         u32 mcast_filter_count;
1241         struct efi_mac_address mcast_filter[16];
1242         struct efi_mac_address current_address;
1243         struct efi_mac_address broadcast_address;
1244         struct efi_mac_address permanent_address;
1245         u8 if_type;
1246         u8 mac_changeable;
1247         u8 multitx_supported;
1248         u8 media_present_supported;
1249         u8 media_present;
1250 };
1251
1252 /* receive_filters bit mask */
1253 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST               0x01
1254 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST             0x02
1255 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST             0x04
1256 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS           0x08
1257 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
1258
1259 /* interrupt status bit mask */
1260 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT    0x01
1261 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT   0x02
1262 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT    0x04
1263 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT   0x08
1264
1265 /* revision of the simple network protocol */
1266 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION    0x00010000
1267
1268 struct efi_simple_network {
1269         u64 revision;
1270         efi_status_t (EFIAPI *start)(struct efi_simple_network *this);
1271         efi_status_t (EFIAPI *stop)(struct efi_simple_network *this);
1272         efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this,
1273                         ulong extra_rx, ulong extra_tx);
1274         efi_status_t (EFIAPI *reset)(struct efi_simple_network *this,
1275                         int extended_verification);
1276         efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this);
1277         efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this,
1278                         u32 enable, u32 disable, int reset_mcast_filter,
1279                         ulong mcast_filter_count,
1280                         struct efi_mac_address *mcast_filter);
1281         efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this,
1282                         int reset, struct efi_mac_address *new_mac);
1283         efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this,
1284                         int reset, ulong *stat_size, void *stat_table);
1285         efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this,
1286                         int ipv6, struct efi_ip_address *ip,
1287                         struct efi_mac_address *mac);
1288         efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this,
1289                         int read_write, ulong offset, ulong buffer_size,
1290                         char *buffer);
1291         efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this,
1292                         u32 *int_status, void **txbuf);
1293         efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this,
1294                         size_t header_size, size_t buffer_size, void *buffer,
1295                         struct efi_mac_address *src_addr,
1296                         struct efi_mac_address *dest_addr, u16 *protocol);
1297         efi_status_t (EFIAPI *receive)(struct efi_simple_network *this,
1298                         size_t *header_size, size_t *buffer_size, void *buffer,
1299                         struct efi_mac_address *src_addr,
1300                         struct efi_mac_address *dest_addr, u16 *protocol);
1301         struct efi_event *wait_for_packet;
1302         struct efi_simple_network_mode *mode;
1303         /* private fields */
1304         u32 int_status;
1305 };
1306
1307 #define EFI_PXE_BASE_CODE_PROTOCOL_GUID \
1308         EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \
1309                  0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
1310
1311 #define EFI_PXE_BASE_CODE_PROTOCOL_REVISION 0x00010000
1312 #define EFI_PXE_BASE_CODE_MAX_IPCNT 8
1313
1314 struct efi_pxe_packet {
1315         u8 packet[1472];
1316 };
1317
1318 struct efi_pxe_mode {
1319         u8 started;
1320         u8 ipv6_available;
1321         u8 ipv6_supported;
1322         u8 using_ipv6;
1323         u8 bis_supported;
1324         u8 bis_detected;
1325         u8 auto_arp;
1326         u8 send_guid;
1327         u8 dhcp_discover_valid;
1328         u8 dhcp_ack_received;
1329         u8 proxy_offer_received;
1330         u8 pxe_discover_valid;
1331         u8 pxe_reply_received;
1332         u8 pxe_bis_reply_received;
1333         u8 icmp_error_received;
1334         u8 tftp_error_received;
1335         u8 make_callbacks;
1336         u8 ttl;
1337         u8 tos;
1338         u8 pad;
1339         struct efi_ip_address station_ip;
1340         struct efi_ip_address subnet_mask;
1341         struct efi_pxe_packet dhcp_discover;
1342         struct efi_pxe_packet dhcp_ack;
1343         struct efi_pxe_packet proxy_offer;
1344         struct efi_pxe_packet pxe_discover;
1345         struct efi_pxe_packet pxe_reply;
1346 };
1347
1348 struct efi_pxe_base_code_srvlist {
1349         u16 type;
1350         u8 accept_any_response;
1351         u8 reserved;
1352         struct efi_ip_address ip_addr;
1353 };
1354
1355 struct efi_pxe_base_code_discover_info {
1356         u8 use_m_cast;
1357         u8 use_b_cast;
1358         u8 use_u_cast;
1359         u8 must_use_list;
1360         struct efi_ip_address server_m_cast_ip;
1361         u16 ip_cnt;
1362         struct efi_pxe_base_code_srvlist srv_list[];
1363 };
1364
1365 struct efi_pxe_base_code_mtftp_info {
1366         struct efi_ip_address m_cast_ip;
1367         u16 cport;
1368         u16 sport;
1369         u16 listen_timeout;
1370         u16 transit_timeout;
1371 };
1372
1373 struct efi_pxe_base_code_filter {
1374         u8 filters;
1375         u8 ip_cnt;
1376         u16 reserved;
1377         struct efi_ip_address ip_list[EFI_PXE_BASE_CODE_MAX_IPCNT];
1378 };
1379
1380 struct efi_pxe_base_code_dhcpv4_packet {
1381         u8 bootp_op_code;
1382         u8 bootp_hw_type;
1383         u8 bootp_addr_len;
1384         u8 bootp_gate_hops;
1385         u32 bootp_ident;
1386         u16 bootp_seconds;
1387         u16 bootp_flags;
1388         u8 bootp_ci_addr[4];
1389         u8 bootp_yi_addr[4];
1390         u8 bootp_si_addr[4];
1391         u8 bootp_gi_addr[4];
1392         u8 bootp_hw_addr[16];
1393         u8 bootp_srv_name[64];
1394         u8 bootp_boot_file[128];
1395         u32 dhcp_magick;
1396         u8 dhcp_options[56];
1397 };
1398
1399 struct efi_pxe_base_code_dhcpv6_packet {
1400         u8 message_type;
1401         u8 transaction_id[3];
1402         u8 dhcp_options[1024];
1403 };
1404
1405 typedef union {
1406         u8 raw[1472];
1407         struct efi_pxe_base_code_dhcpv4_packet dhcpv4;
1408         struct efi_pxe_base_code_dhcpv6_packet dhcpv6;
1409 } EFI_PXE_BASE_CODE_PACKET;
1410
1411 struct efi_pxe_base_code_protocol {
1412         u64 revision;
1413         efi_status_t (EFIAPI *start)(struct efi_pxe_base_code_protocol *this,
1414                                      u8 use_ipv6);
1415         efi_status_t (EFIAPI *stop)(struct efi_pxe_base_code_protocol *this);
1416         efi_status_t (EFIAPI *dhcp)(struct efi_pxe_base_code_protocol *this,
1417                                     u8 sort_offers);
1418         efi_status_t (EFIAPI *discover)(
1419                                 struct efi_pxe_base_code_protocol *this,
1420                                 u16 type, u16 *layer, u8 bis,
1421                                 struct efi_pxe_base_code_discover_info *info);
1422         efi_status_t (EFIAPI *mtftp)(
1423                                 struct efi_pxe_base_code_protocol *this,
1424                                 u32 operation, void *buffer_ptr,
1425                                 u8 overwrite, efi_uintn_t *buffer_size,
1426                                 struct efi_ip_address server_ip, char *filename,
1427                                 struct efi_pxe_base_code_mtftp_info *info,
1428                                 u8 dont_use_buffer);
1429         efi_status_t (EFIAPI *udp_write)(
1430                                 struct efi_pxe_base_code_protocol *this,
1431                                 u16 op_flags, struct efi_ip_address *dest_ip,
1432                                 u16 *dest_port,
1433                                 struct efi_ip_address *gateway_ip,
1434                                 struct efi_ip_address *src_ip, u16 *src_port,
1435                                 efi_uintn_t *header_size, void *header_ptr,
1436                                 efi_uintn_t *buffer_size, void *buffer_ptr);
1437         efi_status_t (EFIAPI *udp_read)(
1438                                 struct efi_pxe_base_code_protocol *this,
1439                                 u16 op_flags, struct efi_ip_address *dest_ip,
1440                                 u16 *dest_port, struct efi_ip_address *src_ip,
1441                                 u16 *src_port, efi_uintn_t *header_size,
1442                                 void *header_ptr, efi_uintn_t *buffer_size,
1443                                 void *buffer_ptr);
1444         efi_status_t (EFIAPI *set_ip_filter)(
1445                                 struct efi_pxe_base_code_protocol *this,
1446                                 struct efi_pxe_base_code_filter *new_filter);
1447         efi_status_t (EFIAPI *arp)(struct efi_pxe_base_code_protocol *this,
1448                                    struct efi_ip_address *ip_addr,
1449                                    struct efi_mac_address *mac_addr);
1450         efi_status_t (EFIAPI *set_parameters)(
1451                                 struct efi_pxe_base_code_protocol *this,
1452                                 u8 *new_auto_arp, u8 *new_send_guid,
1453                                 u8 *new_ttl, u8 *new_tos,
1454                                 u8 *new_make_callback);
1455         efi_status_t (EFIAPI *set_station_ip)(
1456                                 struct efi_pxe_base_code_protocol *this,
1457                                 struct efi_ip_address *new_station_ip,
1458                                 struct efi_ip_address *new_subnet_mask);
1459         efi_status_t (EFIAPI *set_packets)(
1460                                 struct efi_pxe_base_code_protocol *this,
1461                                 u8 *new_dhcp_discover_valid,
1462                                 u8 *new_dhcp_ack_received,
1463                                 u8 *new_proxy_offer_received,
1464                                 u8 *new_pxe_discover_valid,
1465                                 u8 *new_pxe_reply_received,
1466                                 u8 *new_pxe_bis_reply_received,
1467                                 EFI_PXE_BASE_CODE_PACKET *new_dchp_discover,
1468                                 EFI_PXE_BASE_CODE_PACKET *new_dhcp_acc,
1469                                 EFI_PXE_BASE_CODE_PACKET *new_proxy_offer,
1470                                 EFI_PXE_BASE_CODE_PACKET *new_pxe_discover,
1471                                 EFI_PXE_BASE_CODE_PACKET *new_pxe_reply,
1472                                 EFI_PXE_BASE_CODE_PACKET *new_pxe_bis_reply);
1473         struct efi_pxe_mode *mode;
1474 };
1475
1476 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
1477         EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
1478                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
1479 #define EFI_FILE_PROTOCOL_REVISION      0x00010000
1480 #define EFI_FILE_PROTOCOL_REVISION2     0x00020000
1481 #define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2
1482
1483 struct efi_file_io_token {
1484         struct efi_event *event;
1485         efi_status_t status;
1486         efi_uintn_t buffer_size;
1487         void *buffer;};
1488
1489 struct efi_file_handle {
1490         u64 rev;
1491         efi_status_t (EFIAPI *open)(struct efi_file_handle *file,
1492                         struct efi_file_handle **new_handle,
1493                         u16 *file_name, u64 open_mode, u64 attributes);
1494         efi_status_t (EFIAPI *close)(struct efi_file_handle *file);
1495         efi_status_t (EFIAPI *delete)(struct efi_file_handle *file);
1496         efi_status_t (EFIAPI *read)(struct efi_file_handle *file,
1497                         efi_uintn_t *buffer_size, void *buffer);
1498         efi_status_t (EFIAPI *write)(struct efi_file_handle *file,
1499                         efi_uintn_t *buffer_size, void *buffer);
1500         efi_status_t (EFIAPI *getpos)(struct efi_file_handle *file,
1501                                       u64 *pos);
1502         efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file,
1503                                       u64 pos);
1504         efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file,
1505                         const efi_guid_t *info_type, efi_uintn_t *buffer_size,
1506                         void *buffer);
1507         efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *file,
1508                         const efi_guid_t *info_type, efi_uintn_t buffer_size,
1509                         void *buffer);
1510         efi_status_t (EFIAPI *flush)(struct efi_file_handle *file);
1511         efi_status_t (EFIAPI *open_ex)(struct efi_file_handle *file,
1512                         struct efi_file_handle **new_handle,
1513                         u16 *file_name, u64 open_mode, u64 attributes,
1514                         struct efi_file_io_token *token);
1515         efi_status_t (EFIAPI *read_ex)(struct efi_file_handle *file,
1516                         struct efi_file_io_token *token);
1517         efi_status_t (EFIAPI *write_ex)(struct efi_file_handle *file,
1518                         struct efi_file_io_token *token);
1519         efi_status_t (EFIAPI *flush_ex)(struct efi_file_handle *file,
1520                         struct efi_file_io_token *token);
1521 };
1522
1523 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
1524
1525 struct efi_simple_file_system_protocol {
1526         u64 rev;
1527         efi_status_t (EFIAPI *open_volume)(struct efi_simple_file_system_protocol *this,
1528                         struct efi_file_handle **root);
1529 };
1530
1531 #define EFI_FILE_INFO_GUID \
1532         EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
1533                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
1534
1535 #define EFI_FILE_SYSTEM_INFO_GUID \
1536         EFI_GUID(0x09576e93, 0x6d3f, 0x11d2, \
1537                  0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
1538
1539 #define EFI_FILE_SYSTEM_VOLUME_LABEL_ID \
1540         EFI_GUID(0xdb47d7d3, 0xfe81, 0x11d3, \
1541                  0x9a, 0x35, 0x00, 0x90, 0x27, 0x3f, 0xC1, 0x4d)
1542
1543 #define EFI_FILE_MODE_READ      0x0000000000000001
1544 #define EFI_FILE_MODE_WRITE     0x0000000000000002
1545 #define EFI_FILE_MODE_CREATE    0x8000000000000000
1546
1547 #define EFI_FILE_READ_ONLY      0x0000000000000001
1548 #define EFI_FILE_HIDDEN         0x0000000000000002
1549 #define EFI_FILE_SYSTEM         0x0000000000000004
1550 #define EFI_FILE_RESERVED       0x0000000000000008
1551 #define EFI_FILE_DIRECTORY      0x0000000000000010
1552 #define EFI_FILE_ARCHIVE        0x0000000000000020
1553 #define EFI_FILE_VALID_ATTR     0x0000000000000037
1554
1555 struct efi_file_info {
1556         u64 size;
1557         u64 file_size;
1558         u64 physical_size;
1559         struct efi_time create_time;
1560         struct efi_time last_access_time;
1561         struct efi_time modification_time;
1562         u64 attribute;
1563         u16 file_name[0];
1564 };
1565
1566 struct efi_file_system_info {
1567         u64 size;
1568         u8 read_only;
1569         u64 volume_size;
1570         u64 free_space;
1571         u32 block_size;
1572         u16 volume_label[0];
1573 };
1574
1575 #define EFI_DRIVER_BINDING_PROTOCOL_GUID \
1576         EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\
1577                  0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71)
1578 struct efi_driver_binding_protocol {
1579         efi_status_t (EFIAPI * supported)(
1580                         struct efi_driver_binding_protocol *this,
1581                         efi_handle_t controller_handle,
1582                         struct efi_device_path *remaining_device_path);
1583         efi_status_t (EFIAPI * start)(
1584                         struct efi_driver_binding_protocol *this,
1585                         efi_handle_t controller_handle,
1586                         struct efi_device_path *remaining_device_path);
1587         efi_status_t (EFIAPI * stop)(
1588                         struct efi_driver_binding_protocol *this,
1589                         efi_handle_t controller_handle,
1590                         efi_uintn_t number_of_children,
1591                         efi_handle_t *child_handle_buffer);
1592         u32 version;
1593         efi_handle_t image_handle;
1594         efi_handle_t driver_binding_handle;
1595 };
1596
1597 /* Deprecated version of the Unicode collation protocol */
1598 #define EFI_UNICODE_COLLATION_PROTOCOL_GUID \
1599         EFI_GUID(0x1d85cd7f, 0xf43d, 0x11d2, \
1600                  0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
1601 /* Current version of the Unicode collation protocol */
1602 #define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \
1603         EFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \
1604                  0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49)
1605 struct efi_unicode_collation_protocol {
1606         efi_intn_t (EFIAPI *stri_coll)(
1607                 struct efi_unicode_collation_protocol *this, u16 *s1, u16 *s2);
1608         bool (EFIAPI *metai_match)(struct efi_unicode_collation_protocol *this,
1609                                    const u16 *string, const u16 *patter);
1610         void (EFIAPI *str_lwr)(struct efi_unicode_collation_protocol
1611                                *this, u16 *string);
1612         void (EFIAPI *str_upr)(struct efi_unicode_collation_protocol *this,
1613                                u16 *string);
1614         void (EFIAPI *fat_to_str)(struct efi_unicode_collation_protocol *this,
1615                                   efi_uintn_t fat_size, char *fat, u16 *string);
1616         bool (EFIAPI *str_to_fat)(struct efi_unicode_collation_protocol *this,
1617                                   const u16 *string, efi_uintn_t fat_size,
1618                                   char *fat);
1619         char *supported_languages;
1620 };
1621
1622 /* Boot manager load options */
1623 #define LOAD_OPTION_ACTIVE              0x00000001
1624 #define LOAD_OPTION_FORCE_RECONNECT     0x00000002
1625 #define LOAD_OPTION_HIDDEN              0x00000008
1626 /* All values 0x00000200-0x00001F00 are reserved */
1627 #define LOAD_OPTION_CATEGORY            0x00001F00
1628 #define LOAD_OPTION_CATEGORY_BOOT       0x00000000
1629 #define LOAD_OPTION_CATEGORY_APP        0x00000100
1630
1631 #endif