blob: 4fd17d6b687db176978e239ec0ab272a1f0483a3 [file] [log] [blame]
Simon Glass867a6ac2015-07-31 09:31:36 -06001/*
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/* EFI Boot Services table */
21struct efi_boot_services {
22 struct efi_table_hdr hdr;
23 void *raise_tpl;
24 void *restore_tpl;
25
26 efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
27 efi_physical_addr_t *);
28 efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, unsigned long);
29 efi_status_t (EFIAPI *get_memory_map)(unsigned long *memory_map_size,
30 struct efi_mem_desc *desc, unsigned long *key,
31 unsigned long *desc_size, u32 *desc_version);
32 efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
33 efi_status_t (EFIAPI *free_pool)(void *);
34
35 void *create_event;
36 void *set_timer;
37 efi_status_t(EFIAPI *wait_for_event)(unsigned long number_of_events,
38 void *event, unsigned long *index);
39 void *signal_event;
40 void *close_event;
41 void *check_event;
42
43 void *install_protocol_interface;
44 void *reinstall_protocol_interface;
45 void *uninstall_protocol_interface;
46 efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *,
47 void **);
48 void *reserved;
49 void *register_protocol_notify;
50 efi_status_t (EFIAPI *locate_handle)(
51 enum efi_locate_search_type search_type,
52 efi_guid_t *protocol, void *search_key,
53 unsigned long *buffer_size, efi_handle_t *buffer);
54 efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol,
55 struct efi_device_path **device_path,
56 efi_handle_t *device);
57 void *install_configuration_table;
58
59 efi_status_t (EFIAPI *load_image)(bool boot_policiy,
60 efi_handle_t parent_image,
61 struct efi_device_path *file_path, void *source_buffer,
62 unsigned long source_size, efi_handle_t *image);
63 efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
64 unsigned long *exitdata_size,
65 s16 **exitdata);
66 efi_status_t (EFIAPI *exit)(efi_handle_t handle,
67 efi_status_t exit_status,
68 unsigned long exitdata_size, s16 *exitdata);
69 void *unload_image;
70 efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
71
72 efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
73 efi_status_t (EFIAPI *stall)(unsigned long usecs);
74 void *set_watchdog_timer;
75 efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
76 efi_handle_t *driver_image_handle,
77 struct efi_device_path *remaining_device_path,
78 bool recursive);
79 void *disconnect_controller;
80#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
81#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
82#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
83#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
84#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
85#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
86 efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
87 efi_guid_t *protocol, void **interface,
88 efi_handle_t agent_handle,
89 efi_handle_t controller_handle, u32 attributes);
90 void *close_protocol;
91 efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
92 efi_guid_t *protocol,
93 struct efi_open_protocol_info_entry **entry_buffer,
94 unsigned long *entry_count);
95 efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
96 efi_guid_t ***protocol_buffer,
97 unsigned long *protocols_buffer_count);
98 efi_status_t (EFIAPI *locate_handle_buffer) (
99 enum efi_locate_search_type search_type,
100 efi_guid_t *protocol, void *search_key,
101 unsigned long *no_handles, efi_handle_t **buffer);
102 void *locate_protocol;
103 void *install_multiple_protocol_interfaces;
104 void *uninstall_multiple_protocol_interfaces;
105 void *calculate_crc32;
106 void *copy_mem;
107 void *set_mem;
108 void *create_event_ex;
109};
110
111/* Types and defines for EFI ResetSystem */
112enum efi_reset_type {
113 EFI_RESET_COLD = 0,
114 EFI_RESET_WARM = 1,
115 EFI_RESET_SHUTDOWN = 2
116};
117
118/* EFI Runtime Services table */
119#define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552ULL
120#define EFI_RUNTIME_SERVICES_REVISION 0x00010000
121
122struct efi_runtime_services {
123 struct efi_table_hdr hdr;
124 void *get_time;
125 void *set_time;
126 void *get_wakeup_time;
127 void *set_wakeup_time;
128 void *set_virtual_address_map;
129 void *convert_pointer;
130 efi_status_t (EFIAPI *get_variable)(s16 *variable_name,
131 efi_guid_t *vendor, u32 *attributes,
132 unsigned long *data_size, void *data);
133 efi_status_t (EFIAPI *get_next_variable)(
134 unsigned long *variable_name_size,
135 s16 *variable_name, efi_guid_t *vendor);
136 efi_status_t (EFIAPI *set_variable)(s16 *variable_name,
137 efi_guid_t *vendor, u32 attributes,
138 unsigned long data_size, void *data);
139 void *get_next_high_mono_count;
140 void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
141 efi_status_t reset_status,
142 unsigned long data_size, void *reset_data);
143 void *update_capsule;
144 void *query_capsule_caps;
145 void *query_variable_info;
146};
147
148/* EFI Configuration Table and GUID definitions */
149#define NULL_GUID \
150 EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
152
153#define LOADED_IMAGE_PROTOCOL_GUID \
154 EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \
155 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
156
157struct efi_system_table {
158 struct efi_table_hdr hdr;
159 unsigned long fw_vendor; /* physical addr of wchar_t vendor string */
160 u32 fw_revision;
161 unsigned long con_in_handle;
162 struct efi_simple_input_interface *con_in;
163 unsigned long con_out_handle;
164 struct efi_simple_text_output_protocol *con_out;
165 unsigned long stderr_handle;
166 unsigned long std_err;
167 struct efi_runtime_services *runtime;
168 struct efi_boot_services *boottime;
169 unsigned long nr_tables;
170 unsigned long tables;
171};
172
173struct efi_loaded_image {
174 u32 revision;
175 void *parent_handle;
176 struct efi_system_table *system_table;
177 void *device_handle;
178 void *file_path;
179 void *reserved;
180 u32 load_options_size;
181 void *load_options;
182 void *image_base;
183 aligned_u64 image_size;
184 unsigned int image_code_type;
185 unsigned int image_data_type;
186 unsigned long unload;
187};
188
189struct efi_device_path {
190 u8 type;
191 u8 sub_type;
192 u16 length;
193};
194
195struct simple_text_output_mode {
196 s32 max_mode;
197 s32 mode;
198 s32 attribute;
199 s32 cursor_column;
200 s32 cursor_row;
201 bool cursor_visible;
202};
203
204struct efi_simple_text_output_protocol {
205 void *reset;
206 efi_status_t (EFIAPI *output_string)(
207 struct efi_simple_text_output_protocol *this,
208 const unsigned short *str);
209 void *test_string;
210
211 efi_status_t(EFIAPI *query_mode)(
212 struct efi_simple_text_output_protocol *this,
213 unsigned long mode_number, unsigned long *columns,
214 unsigned long *rows);
215 efi_status_t(EFIAPI *set_mode)(
216 struct efi_simple_text_output_protocol *this,
217 unsigned long mode_number);
218 efi_status_t(EFIAPI *set_attribute)(
219 struct efi_simple_text_output_protocol *this,
220 unsigned long attribute);
221 efi_status_t(EFIAPI *clear_screen) (
222 struct efi_simple_text_output_protocol *this);
223 efi_status_t(EFIAPI *set_cursor_position) (
224 struct efi_simple_text_output_protocol *this,
225 unsigned long column, unsigned long row);
226 efi_status_t(EFIAPI *enable_cursor)(void *, bool enable);
227 struct simple_text_output_mode *mode;
228};
229
230struct efi_input_key {
231 u16 scan_code;
232 s16 unicode_char;
233};
234
235struct efi_simple_input_interface {
236 efi_status_t(EFIAPI *reset)(struct efi_simple_input_interface *this,
237 bool ExtendedVerification);
238 efi_status_t(EFIAPI *read_key_stroke)(
239 struct efi_simple_input_interface *this,
240 struct efi_input_key *key);
241 void *wait_for_key;
242};
243
244#endif