]> git.sur5r.net Git - u-boot/blob - include/efi_api.h
efi_loader: replace UINTN by efi_uintn_t
[u-boot] / include / efi_api.h
1 /*
2  * Extensible Firmware Interface
3  * Based on 'Extensible Firmware Interface Specification' version 0.9,
4  * April 30, 1999
5  *
6  * Copyright (C) 1999 VA Linux Systems
7  * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
8  * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
9  *      David Mosberger-Tang <davidm@hpl.hp.com>
10  *      Stephane Eranian <eranian@hpl.hp.com>
11  *
12  * From include/linux/efi.h in kernel 4.1 with some additions/subtractions
13  */
14
15 #ifndef _EFI_API_H
16 #define _EFI_API_H
17
18 #include <efi.h>
19
20 #ifdef CONFIG_EFI_LOADER
21 #include <asm/setjmp.h>
22 #endif
23
24 /* Types and defines for EFI CreateEvent */
25 enum efi_timer_delay {
26         EFI_TIMER_STOP = 0,
27         EFI_TIMER_PERIODIC = 1,
28         EFI_TIMER_RELATIVE = 2
29 };
30
31 #define efi_uintn_t size_t
32 typedef uint16_t *efi_string_t;
33
34 #define EVT_TIMER                               0x80000000
35 #define EVT_RUNTIME                             0x40000000
36 #define EVT_NOTIFY_WAIT                         0x00000100
37 #define EVT_NOTIFY_SIGNAL                       0x00000200
38 #define EVT_SIGNAL_EXIT_BOOT_SERVICES           0x00000201
39 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE       0x60000202
40
41 #define TPL_APPLICATION         0x04
42 #define TPL_CALLBACK            0x08
43 #define TPL_NOTIFY              0x10
44 #define TPL_HIGH_LEVEL          0x1F
45
46 struct efi_event;
47
48 /* EFI Boot Services table */
49 struct efi_boot_services {
50         struct efi_table_hdr hdr;
51         efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl);
52         void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl);
53
54         efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
55                                               efi_physical_addr_t *);
56         efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, unsigned long);
57         efi_status_t (EFIAPI *get_memory_map)(unsigned long *memory_map_size,
58                         struct efi_mem_desc *desc, unsigned long *key,
59                         unsigned long *desc_size, u32 *desc_version);
60         efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
61         efi_status_t (EFIAPI *free_pool)(void *);
62
63         efi_status_t (EFIAPI *create_event)(uint32_t type,
64                         efi_uintn_t notify_tpl,
65                         void (EFIAPI *notify_function) (
66                                         struct efi_event *event,
67                                         void *context),
68                         void *notify_context, struct efi_event **event);
69         efi_status_t (EFIAPI *set_timer)(struct efi_event *event,
70                                          enum efi_timer_delay type,
71                                          uint64_t trigger_time);
72         efi_status_t (EFIAPI *wait_for_event)(unsigned long number_of_events,
73                         struct efi_event **event, size_t *index);
74         efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
75         efi_status_t (EFIAPI *close_event)(struct efi_event *event);
76         efi_status_t (EFIAPI *check_event)(struct efi_event *event);
77 #define EFI_NATIVE_INTERFACE    0x00000000
78         efi_status_t (EFIAPI *install_protocol_interface)(
79                         void **handle, const efi_guid_t *protocol,
80                         int protocol_interface_type, void *protocol_interface);
81         efi_status_t (EFIAPI *reinstall_protocol_interface)(
82                         void *handle, const efi_guid_t *protocol,
83                         void *old_interface, void *new_interface);
84         efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle,
85                         const efi_guid_t *protocol, void *protocol_interface);
86         efi_status_t (EFIAPI *handle_protocol)(efi_handle_t,
87                                                const efi_guid_t *protocol,
88                                                void **protocol_interface);
89         void *reserved;
90         efi_status_t (EFIAPI *register_protocol_notify)(
91                         const efi_guid_t *protocol, struct efi_event *event,
92                         void **registration);
93         efi_status_t (EFIAPI *locate_handle)(
94                         enum efi_locate_search_type search_type,
95                         const efi_guid_t *protocol, void *search_key,
96                         unsigned long *buffer_size, efi_handle_t *buffer);
97         efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol,
98                         struct efi_device_path **device_path,
99                         efi_handle_t *device);
100         efi_status_t (EFIAPI *install_configuration_table)(
101                         efi_guid_t *guid, void *table);
102
103         efi_status_t (EFIAPI *load_image)(bool boot_policiy,
104                         efi_handle_t parent_image,
105                         struct efi_device_path *file_path, void *source_buffer,
106                         unsigned long source_size, efi_handle_t *image);
107         efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
108                                            unsigned long *exitdata_size,
109                                            s16 **exitdata);
110         efi_status_t (EFIAPI *exit)(efi_handle_t handle,
111                                     efi_status_t exit_status,
112                                     unsigned long exitdata_size, s16 *exitdata);
113         efi_status_t (EFIAPI *unload_image)(void *image_handle);
114         efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
115
116         efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
117         efi_status_t (EFIAPI *stall)(unsigned long usecs);
118         efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
119                         uint64_t watchdog_code, unsigned long data_size,
120                         uint16_t *watchdog_data);
121         efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
122                         efi_handle_t *driver_image_handle,
123                         struct efi_device_path *remaining_device_path,
124                         bool recursive);
125         efi_status_t (EFIAPI *disconnect_controller)(void *controller_handle,
126                         void *driver_image_handle, void *child_handle);
127 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
128 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
129 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
130 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
131 #define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
132 #define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
133         efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
134                         const efi_guid_t *protocol, void **interface,
135                         efi_handle_t agent_handle,
136                         efi_handle_t controller_handle, u32 attributes);
137         efi_status_t (EFIAPI *close_protocol)(void *handle,
138                         const efi_guid_t *protocol, void *agent_handle,
139                         void *controller_handle);
140         efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
141                         const efi_guid_t *protocol,
142                         struct efi_open_protocol_info_entry **entry_buffer,
143                         unsigned long *entry_count);
144         efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
145                         efi_guid_t ***protocol_buffer,
146                         unsigned long *protocols_buffer_count);
147         efi_status_t (EFIAPI *locate_handle_buffer) (
148                         enum efi_locate_search_type search_type,
149                         const efi_guid_t *protocol, void *search_key,
150                         unsigned long *no_handles, efi_handle_t **buffer);
151         efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
152                         void *registration, void **protocol_interface);
153         efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
154                         void **handle, ...);
155         efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
156                         void *handle, ...);
157         efi_status_t (EFIAPI *calculate_crc32)(void *data,
158                         unsigned long data_size, uint32_t *crc32);
159         void (EFIAPI *copy_mem)(void *destination, const void *source,
160                         size_t length);
161         void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value);
162         void *create_event_ex;
163 };
164
165 /* Types and defines for EFI ResetSystem */
166 enum efi_reset_type {
167         EFI_RESET_COLD = 0,
168         EFI_RESET_WARM = 1,
169         EFI_RESET_SHUTDOWN = 2
170 };
171
172 /* EFI Runtime Services table */
173 #define EFI_RUNTIME_SERVICES_SIGNATURE  0x5652453544e5552ULL
174 #define EFI_RUNTIME_SERVICES_REVISION   0x00010000
175
176 struct efi_runtime_services {
177         struct efi_table_hdr hdr;
178         efi_status_t (EFIAPI *get_time)(struct efi_time *time,
179                         struct efi_time_cap *capabilities);
180         efi_status_t (EFIAPI *set_time)(struct efi_time *time);
181         efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
182                         struct efi_time *time);
183         efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
184                         struct efi_time *time);
185         efi_status_t (EFIAPI *set_virtual_address_map)(
186                         unsigned long memory_map_size,
187                         unsigned long descriptor_size,
188                         uint32_t descriptor_version,
189                         struct efi_mem_desc *virtmap);
190         efi_status_t (*convert_pointer)(unsigned long dbg, void **address);
191         efi_status_t (EFIAPI *get_variable)(s16 *variable_name,
192                         efi_guid_t *vendor, u32 *attributes,
193                         unsigned long *data_size, void *data);
194         efi_status_t (EFIAPI *get_next_variable)(
195                         unsigned long *variable_name_size,
196                         s16 *variable_name, efi_guid_t *vendor);
197         efi_status_t (EFIAPI *set_variable)(s16 *variable_name,
198                         efi_guid_t *vendor, u32 attributes,
199                         unsigned long data_size, void *data);
200         efi_status_t (EFIAPI *get_next_high_mono_count)(
201                         uint32_t *high_count);
202         void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
203                                     efi_status_t reset_status,
204                                     unsigned long data_size, void *reset_data);
205         void *update_capsule;
206         void *query_capsule_caps;
207         void *query_variable_info;
208 };
209
210 /* EFI Configuration Table and GUID definitions */
211 #define NULL_GUID \
212         EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
213                  0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
214
215 #define EFI_GLOBAL_VARIABLE_GUID \
216         EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
217                  0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
218
219 #define LOADED_IMAGE_PROTOCOL_GUID \
220         EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \
221                  0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
222
223 #define EFI_FDT_GUID \
224         EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
225                  0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
226
227 #define SMBIOS_TABLE_GUID \
228         EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3,  \
229                  0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
230
231 struct efi_configuration_table
232 {
233         efi_guid_t guid;
234         void *table;
235 };
236
237 #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
238
239 struct efi_system_table {
240         struct efi_table_hdr hdr;
241         unsigned long fw_vendor;   /* physical addr of wchar_t vendor string */
242         u32 fw_revision;
243         unsigned long con_in_handle;
244         struct efi_simple_input_interface *con_in;
245         unsigned long con_out_handle;
246         struct efi_simple_text_output_protocol *con_out;
247         unsigned long stderr_handle;
248         struct efi_simple_text_output_protocol *std_err;
249         struct efi_runtime_services *runtime;
250         struct efi_boot_services *boottime;
251         unsigned long nr_tables;
252         struct efi_configuration_table *tables;
253 };
254
255 #define LOADED_IMAGE_GUID \
256         EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
257                  0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
258
259 struct efi_loaded_image {
260         u32 revision;
261         void *parent_handle;
262         struct efi_system_table *system_table;
263         void *device_handle;
264         void *file_path;
265         void *reserved;
266         u32 load_options_size;
267         void *load_options;
268         void *image_base;
269         aligned_u64 image_size;
270         unsigned int image_code_type;
271         unsigned int image_data_type;
272         unsigned long unload;
273
274         /* Below are efi loader private fields */
275 #ifdef CONFIG_EFI_LOADER
276         efi_status_t exit_status;
277         struct jmp_buf_data exit_jmp;
278 #endif
279 };
280
281 #define DEVICE_PATH_GUID \
282         EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
283                  0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
284
285 #define DEVICE_PATH_TYPE_END                    0x7f
286 #  define DEVICE_PATH_SUB_TYPE_END              0xff
287
288 struct efi_device_path {
289         u8 type;
290         u8 sub_type;
291         u16 length;
292 } __packed;
293
294 struct efi_mac_addr {
295         u8 addr[32];
296 } __packed;
297
298 #define DEVICE_PATH_TYPE_HARDWARE_DEVICE        0x01
299 #  define DEVICE_PATH_SUB_TYPE_MEMORY           0x03
300 #  define DEVICE_PATH_SUB_TYPE_VENDOR           0x04
301
302 struct efi_device_path_memory {
303         struct efi_device_path dp;
304         u32 memory_type;
305         u64 start_address;
306         u64 end_address;
307 } __packed;
308
309 struct efi_device_path_vendor {
310         struct efi_device_path dp;
311         efi_guid_t guid;
312         u8 vendor_data[];
313 } __packed;
314
315 #define DEVICE_PATH_TYPE_ACPI_DEVICE            0x02
316 #  define DEVICE_PATH_SUB_TYPE_ACPI_DEVICE      0x01
317
318 #define EFI_PNP_ID(ID)                          (u32)(((ID) << 16) | 0x41D0)
319 #define EISA_PNP_ID(ID)                         EFI_PNP_ID(ID)
320 #define EISA_PNP_NUM(ID)                        ((ID) >> 16)
321
322 struct efi_device_path_acpi_path {
323         struct efi_device_path dp;
324         u32 hid;
325         u32 uid;
326 } __packed;
327
328 #define DEVICE_PATH_TYPE_MESSAGING_DEVICE       0x03
329 #  define DEVICE_PATH_SUB_TYPE_MSG_USB          0x05
330 #  define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR     0x0b
331 #  define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS    0x0f
332 #  define DEVICE_PATH_SUB_TYPE_MSG_SD           0x1a
333 #  define DEVICE_PATH_SUB_TYPE_MSG_MMC          0x1d
334
335 struct efi_device_path_usb {
336         struct efi_device_path dp;
337         u8 parent_port_number;
338         u8 usb_interface;
339 } __packed;
340
341 struct efi_device_path_mac_addr {
342         struct efi_device_path dp;
343         struct efi_mac_addr mac;
344         u8 if_type;
345 } __packed;
346
347 struct efi_device_path_usb_class {
348         struct efi_device_path dp;
349         u16 vendor_id;
350         u16 product_id;
351         u8 device_class;
352         u8 device_subclass;
353         u8 device_protocol;
354 } __packed;
355
356 struct efi_device_path_sd_mmc_path {
357         struct efi_device_path dp;
358         u8 slot_number;
359 } __packed;
360
361 #define DEVICE_PATH_TYPE_MEDIA_DEVICE           0x04
362 #  define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH  0x01
363 #  define DEVICE_PATH_SUB_TYPE_CDROM_PATH       0x02
364 #  define DEVICE_PATH_SUB_TYPE_FILE_PATH        0x04
365
366 struct efi_device_path_hard_drive_path {
367         struct efi_device_path dp;
368         u32 partition_number;
369         u64 partition_start;
370         u64 partition_end;
371         u8 partition_signature[16];
372         u8 partmap_type;
373         u8 signature_type;
374 } __packed;
375
376 struct efi_device_path_cdrom_path {
377         struct efi_device_path dp;
378         u32 boot_entry;
379         u64 partition_start;
380         u64 partition_end;
381 } __packed;
382
383 struct efi_device_path_file_path {
384         struct efi_device_path dp;
385         u16 str[];
386 } __packed;
387
388 #define BLOCK_IO_GUID \
389         EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
390                  0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
391
392 struct efi_block_io_media
393 {
394         u32 media_id;
395         char removable_media;
396         char media_present;
397         char logical_partition;
398         char read_only;
399         char write_caching;
400         u8 pad[3];
401         u32 block_size;
402         u32 io_align;
403         u8 pad2[4];
404         u64 last_block;
405 };
406
407 struct efi_block_io {
408         u64 revision;
409         struct efi_block_io_media *media;
410         efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
411                         char extended_verification);
412         efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
413                         u32 media_id, u64 lba, unsigned long buffer_size,
414                         void *buffer);
415         efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
416                         u32 media_id, u64 lba, unsigned long buffer_size,
417                         void *buffer);
418         efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
419 };
420
421 struct simple_text_output_mode {
422         s32 max_mode;
423         s32 mode;
424         s32 attribute;
425         s32 cursor_column;
426         s32 cursor_row;
427         bool cursor_visible;
428 };
429
430
431 #define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
432         EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
433                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
434
435 #define EFI_BLACK                0x00
436 #define EFI_BLUE                 0x01
437 #define EFI_GREEN                0x02
438 #define EFI_CYAN                 0x03
439 #define EFI_RED                  0x04
440 #define EFI_MAGENTA              0x05
441 #define EFI_BROWN                0x06
442 #define EFI_LIGHTGRAY            0x07
443 #define EFI_BRIGHT               0x08
444 #define EFI_DARKGRAY             0x08
445 #define EFI_LIGHTBLUE            0x09
446 #define EFI_LIGHTGREEN           0x0a
447 #define EFI_LIGHTCYAN            0x0b
448 #define EFI_LIGHTRED             0x0c
449 #define EFI_LIGHTMAGENTA         0x0d
450 #define EFI_YELLOW               0x0e
451 #define EFI_WHITE                0x0f
452 #define EFI_BACKGROUND_BLACK     0x00
453 #define EFI_BACKGROUND_BLUE      0x10
454 #define EFI_BACKGROUND_GREEN     0x20
455 #define EFI_BACKGROUND_CYAN      0x30
456 #define EFI_BACKGROUND_RED       0x40
457 #define EFI_BACKGROUND_MAGENTA   0x50
458 #define EFI_BACKGROUND_BROWN     0x60
459 #define EFI_BACKGROUND_LIGHTGRAY 0x70
460
461 /* extract foreground color from EFI attribute */
462 #define EFI_ATTR_FG(attr)        ((attr) & 0x07)
463 /* treat high bit of FG as bright/bold (similar to edk2) */
464 #define EFI_ATTR_BOLD(attr)      (((attr) >> 3) & 0x01)
465 /* extract background color from EFI attribute */
466 #define EFI_ATTR_BG(attr)        (((attr) >> 4) & 0x7)
467
468 struct efi_simple_text_output_protocol {
469         void *reset;
470         efi_status_t (EFIAPI *output_string)(
471                         struct efi_simple_text_output_protocol *this,
472                         const efi_string_t str);
473         efi_status_t (EFIAPI *test_string)(
474                         struct efi_simple_text_output_protocol *this,
475                         const efi_string_t str);
476         efi_status_t(EFIAPI *query_mode)(
477                         struct efi_simple_text_output_protocol *this,
478                         unsigned long mode_number, unsigned long *columns,
479                         unsigned long *rows);
480         efi_status_t(EFIAPI *set_mode)(
481                         struct efi_simple_text_output_protocol *this,
482                         unsigned long mode_number);
483         efi_status_t(EFIAPI *set_attribute)(
484                         struct efi_simple_text_output_protocol *this,
485                         unsigned long attribute);
486         efi_status_t(EFIAPI *clear_screen) (
487                         struct efi_simple_text_output_protocol *this);
488         efi_status_t(EFIAPI *set_cursor_position) (
489                         struct efi_simple_text_output_protocol *this,
490                         unsigned long column, unsigned long row);
491         efi_status_t(EFIAPI *enable_cursor)(
492                         struct efi_simple_text_output_protocol *this,
493                         bool enable);
494         struct simple_text_output_mode *mode;
495 };
496
497 struct efi_input_key {
498         u16 scan_code;
499         s16 unicode_char;
500 };
501
502 #define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
503         EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \
504                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
505
506 struct efi_simple_input_interface {
507         efi_status_t(EFIAPI *reset)(struct efi_simple_input_interface *this,
508                         bool ExtendedVerification);
509         efi_status_t(EFIAPI *read_key_stroke)(
510                         struct efi_simple_input_interface *this,
511                         struct efi_input_key *key);
512         struct efi_event *wait_for_key;
513 };
514
515 #define CONSOLE_CONTROL_GUID \
516         EFI_GUID(0xf42f7782, 0x12e, 0x4c12, \
517                  0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21)
518 #define EFI_CONSOLE_MODE_TEXT   0
519 #define EFI_CONSOLE_MODE_GFX    1
520
521 struct efi_console_control_protocol
522 {
523         efi_status_t (EFIAPI *get_mode)(
524                         struct efi_console_control_protocol *this, int *mode,
525                         char *uga_exists, char *std_in_locked);
526         efi_status_t (EFIAPI *set_mode)(
527                         struct efi_console_control_protocol *this, int mode);
528         efi_status_t (EFIAPI *lock_std_in)(
529                         struct efi_console_control_protocol *this,
530                         uint16_t *password);
531 };
532
533 #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
534         EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
535                  0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
536
537 struct efi_device_path_to_text_protocol
538 {
539         uint16_t *(EFIAPI *convert_device_node_to_text)(
540                         struct efi_device_path *device_node,
541                         bool display_only,
542                         bool allow_shortcuts);
543         uint16_t *(EFIAPI *convert_device_path_to_text)(
544                         struct efi_device_path *device_path,
545                         bool display_only,
546                         bool allow_shortcuts);
547 };
548
549 #define EFI_GOP_GUID \
550         EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
551                  0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
552
553 #define EFI_GOT_RGBA8           0
554 #define EFI_GOT_BGRA8           1
555 #define EFI_GOT_BITMASK         2
556
557 struct efi_gop_mode_info
558 {
559         u32 version;
560         u32 width;
561         u32 height;
562         u32 pixel_format;
563         u32 pixel_bitmask[4];
564         u32 pixels_per_scanline;
565 };
566
567 struct efi_gop_mode
568 {
569         u32 max_mode;
570         u32 mode;
571         struct efi_gop_mode_info *info;
572         unsigned long info_size;
573         efi_physical_addr_t fb_base;
574         unsigned long fb_size;
575 };
576
577 #define EFI_BLT_VIDEO_FILL              0
578 #define EFI_BLT_VIDEO_TO_BLT_BUFFER     1
579 #define EFI_BLT_BUFFER_TO_VIDEO         2
580 #define EFI_BLT_VIDEO_TO_VIDEO          3
581
582 struct efi_gop
583 {
584         efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
585                                           unsigned long *size_of_info,
586                                           struct efi_gop_mode_info **info);
587         efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
588         efi_status_t (EFIAPI *blt)(struct efi_gop *this, void *buffer,
589                                    unsigned long operation, unsigned long sx,
590                                    unsigned long sy, unsigned long dx,
591                                    unsigned long dy, unsigned long width,
592                                    unsigned long height, unsigned long delta);
593         struct efi_gop_mode *mode;
594 };
595
596 #define EFI_SIMPLE_NETWORK_GUID \
597         EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \
598                  0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
599
600 struct efi_mac_address {
601         char mac_addr[32];
602 };
603
604 struct efi_ip_address {
605         u8 ip_addr[16];
606 };
607
608 enum efi_simple_network_state {
609         EFI_NETWORK_STOPPED,
610         EFI_NETWORK_STARTED,
611         EFI_NETWORK_INITIALIZED,
612 };
613
614 struct efi_simple_network_mode {
615         enum efi_simple_network_state state;
616         u32 hwaddr_size;
617         u32 media_header_size;
618         u32 max_packet_size;
619         u32 nvram_size;
620         u32 nvram_access_size;
621         u32 receive_filter_mask;
622         u32 receive_filter_setting;
623         u32 max_mcast_filter_count;
624         u32 mcast_filter_count;
625         struct efi_mac_address mcast_filter[16];
626         struct efi_mac_address current_address;
627         struct efi_mac_address broadcast_address;
628         struct efi_mac_address permanent_address;
629         u8 if_type;
630         u8 mac_changeable;
631         u8 multitx_supported;
632         u8 media_present_supported;
633         u8 media_present;
634 };
635
636 /* receive_filters bit mask */
637 #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST               0x01
638 #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST             0x02
639 #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST             0x04
640 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS           0x08
641 #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
642
643 /* interrupt status bit mask */
644 #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT    0x01
645 #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT   0x02
646 #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT    0x04
647 #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT   0x08
648
649 /* revision of the simple network protocol */
650 #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION    0x00010000
651
652 struct efi_simple_network
653 {
654         u64 revision;
655         efi_status_t (EFIAPI *start)(struct efi_simple_network *this);
656         efi_status_t (EFIAPI *stop)(struct efi_simple_network *this);
657         efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this,
658                         ulong extra_rx, ulong extra_tx);
659         efi_status_t (EFIAPI *reset)(struct efi_simple_network *this,
660                         int extended_verification);
661         efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this);
662         efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this,
663                         u32 enable, u32 disable, int reset_mcast_filter,
664                         ulong mcast_filter_count,
665                         struct efi_mac_address *mcast_filter);
666         efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this,
667                         int reset, struct efi_mac_address *new_mac);
668         efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this,
669                         int reset, ulong *stat_size, void *stat_table);
670         efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this,
671                         int ipv6, struct efi_ip_address *ip,
672                         struct efi_mac_address *mac);
673         efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this,
674                         int read_write, ulong offset, ulong buffer_size,
675                         char *buffer);
676         efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this,
677                         u32 *int_status, void **txbuf);
678         efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this,
679                         size_t header_size, size_t buffer_size, void *buffer,
680                         struct efi_mac_address *src_addr,
681                         struct efi_mac_address *dest_addr, u16 *protocol);
682         efi_status_t (EFIAPI *receive)(struct efi_simple_network *this,
683                         size_t *header_size, size_t *buffer_size, void *buffer,
684                         struct efi_mac_address *src_addr,
685                         struct efi_mac_address *dest_addr, u16 *protocol);
686         struct efi_event *wait_for_packet;
687         struct efi_simple_network_mode *mode;
688 };
689
690 #define EFI_PXE_GUID \
691         EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \
692                  0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
693
694 struct efi_pxe_packet {
695         u8 packet[1472];
696 };
697
698 struct efi_pxe_mode
699 {
700         u8 unused[52];
701         struct efi_pxe_packet dhcp_discover;
702         struct efi_pxe_packet dhcp_ack;
703         struct efi_pxe_packet proxy_offer;
704         struct efi_pxe_packet pxe_discover;
705         struct efi_pxe_packet pxe_reply;
706 };
707
708 struct efi_pxe {
709         u64 rev;
710         void (EFIAPI *start)(void);
711         void (EFIAPI *stop)(void);
712         void (EFIAPI *dhcp)(void);
713         void (EFIAPI *discover)(void);
714         void (EFIAPI *mftp)(void);
715         void (EFIAPI *udpwrite)(void);
716         void (EFIAPI *udpread)(void);
717         void (EFIAPI *setipfilter)(void);
718         void (EFIAPI *arp)(void);
719         void (EFIAPI *setparams)(void);
720         void (EFIAPI *setstationip)(void);
721         void (EFIAPI *setpackets)(void);
722         struct efi_pxe_mode *mode;
723 };
724
725 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
726         EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
727                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
728 #define EFI_FILE_PROTOCOL_REVISION 0x00010000
729
730 struct efi_file_handle {
731         u64 rev;
732         efi_status_t (EFIAPI *open)(struct efi_file_handle *file,
733                         struct efi_file_handle **new_handle,
734                         s16 *file_name, u64 open_mode, u64 attributes);
735         efi_status_t (EFIAPI *close)(struct efi_file_handle *file);
736         efi_status_t (EFIAPI *delete)(struct efi_file_handle *file);
737         efi_status_t (EFIAPI *read)(struct efi_file_handle *file,
738                         u64 *buffer_size, void *buffer);
739         efi_status_t (EFIAPI *write)(struct efi_file_handle *file,
740                         u64 *buffer_size, void *buffer);
741         efi_status_t (EFIAPI *getpos)(struct efi_file_handle *file,
742                         u64 *pos);
743         efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file,
744                         u64 pos);
745         efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file,
746                         efi_guid_t *info_type, u64 *buffer_size, void *buffer);
747         efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *file,
748                         efi_guid_t *info_type, u64 buffer_size, void *buffer);
749         efi_status_t (EFIAPI *flush)(struct efi_file_handle *file);
750 };
751
752 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
753         EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
754                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
755 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
756
757 struct efi_simple_file_system_protocol {
758         u64 rev;
759         efi_status_t (EFIAPI *open_volume)(struct efi_simple_file_system_protocol *this,
760                         struct efi_file_handle **root);
761 };
762
763 #define EFI_FILE_INFO_GUID \
764         EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
765                  0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
766
767 #define EFI_FILE_MODE_READ      0x0000000000000001
768 #define EFI_FILE_MODE_WRITE     0x0000000000000002
769 #define EFI_FILE_MODE_CREATE    0x8000000000000000
770
771 #define EFI_FILE_READ_ONLY      0x0000000000000001
772 #define EFI_FILE_HIDDEN         0x0000000000000002
773 #define EFI_FILE_SYSTEM         0x0000000000000004
774 #define EFI_FILE_RESERVED       0x0000000000000008
775 #define EFI_FILE_DIRECTORY      0x0000000000000010
776 #define EFI_FILE_ARCHIVE        0x0000000000000020
777 #define EFI_FILE_VALID_ATTR     0x0000000000000037
778
779 struct efi_file_info {
780         u64 size;
781         u64 file_size;
782         u64 physical_size;
783         struct efi_time create_time;
784         struct efi_time last_access_time;
785         struct efi_time modification_time;
786         u64 attribute;
787         s16 file_name[0];
788 };
789
790 #endif