]> git.ipfire.org Git - people/ms/u-boot.git/blob - include/efi_api.h
efi_loader: Add GOP support
[people/ms/u-boot.git] / 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 /* Types and defines for EFI CreateEvent */
21 enum efi_event_type {
22 EFI_TIMER_STOP = 0,
23 EFI_TIMER_PERIODIC = 1,
24 EFI_TIMER_RELATIVE = 2
25 };
26
27 /* EFI Boot Services table */
28 struct efi_boot_services {
29 struct efi_table_hdr hdr;
30 efi_status_t (EFIAPI *raise_tpl)(unsigned long new_tpl);
31 void (EFIAPI *restore_tpl)(unsigned long old_tpl);
32
33 efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
34 efi_physical_addr_t *);
35 efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, unsigned long);
36 efi_status_t (EFIAPI *get_memory_map)(unsigned long *memory_map_size,
37 struct efi_mem_desc *desc, unsigned long *key,
38 unsigned long *desc_size, u32 *desc_version);
39 efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
40 efi_status_t (EFIAPI *free_pool)(void *);
41
42 efi_status_t (EFIAPI *create_event)(enum efi_event_type type,
43 unsigned long notify_tpl,
44 void (EFIAPI *notify_function) (void *event,
45 void *context),
46 void *notify_context, void **event);
47 efi_status_t (EFIAPI *set_timer)(void *event, int type,
48 uint64_t trigger_time);
49 efi_status_t (EFIAPI *wait_for_event)(unsigned long number_of_events,
50 void *event, unsigned long *index);
51 efi_status_t (EFIAPI *signal_event)(void *event);
52 efi_status_t (EFIAPI *close_event)(void *event);
53 efi_status_t (EFIAPI *check_event)(void *event);
54
55 efi_status_t (EFIAPI *install_protocol_interface)(
56 void **handle, efi_guid_t *protocol,
57 int protocol_interface_type, void *protocol_interface);
58 efi_status_t (EFIAPI *reinstall_protocol_interface)(
59 void *handle, efi_guid_t *protocol,
60 void *old_interface, void *new_interface);
61 efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle,
62 efi_guid_t *protocol, void *protocol_interface);
63 efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *,
64 void **);
65 void *reserved;
66 efi_status_t (EFIAPI *register_protocol_notify)(
67 efi_guid_t *protocol, void *event,
68 void **registration);
69 efi_status_t (EFIAPI *locate_handle)(
70 enum efi_locate_search_type search_type,
71 efi_guid_t *protocol, void *search_key,
72 unsigned long *buffer_size, efi_handle_t *buffer);
73 efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol,
74 struct efi_device_path **device_path,
75 efi_handle_t *device);
76 efi_status_t (EFIAPI *install_configuration_table)(
77 efi_guid_t *guid, void *table);
78
79 efi_status_t (EFIAPI *load_image)(bool boot_policiy,
80 efi_handle_t parent_image,
81 struct efi_device_path *file_path, void *source_buffer,
82 unsigned long source_size, efi_handle_t *image);
83 efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
84 unsigned long *exitdata_size,
85 s16 **exitdata);
86 efi_status_t (EFIAPI *exit)(efi_handle_t handle,
87 efi_status_t exit_status,
88 unsigned long exitdata_size, s16 *exitdata);
89 efi_status_t (EFIAPI *unload_image)(void *image_handle);
90 efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
91
92 efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
93 efi_status_t (EFIAPI *stall)(unsigned long usecs);
94 efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
95 uint64_t watchdog_code, unsigned long data_size,
96 uint16_t *watchdog_data);
97 efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
98 efi_handle_t *driver_image_handle,
99 struct efi_device_path *remaining_device_path,
100 bool recursive);
101 efi_status_t (EFIAPI *disconnect_controller)(void *controller_handle,
102 void *driver_image_handle, void *child_handle);
103 #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
104 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
105 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
106 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
107 #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
108 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
109 efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
110 efi_guid_t *protocol, void **interface,
111 efi_handle_t agent_handle,
112 efi_handle_t controller_handle, u32 attributes);
113 efi_status_t (EFIAPI *close_protocol)(void *handle,
114 efi_guid_t *protocol, void *agent_handle,
115 void *controller_handle);
116 efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
117 efi_guid_t *protocol,
118 struct efi_open_protocol_info_entry **entry_buffer,
119 unsigned long *entry_count);
120 efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
121 efi_guid_t ***protocol_buffer,
122 unsigned long *protocols_buffer_count);
123 efi_status_t (EFIAPI *locate_handle_buffer) (
124 enum efi_locate_search_type search_type,
125 efi_guid_t *protocol, void *search_key,
126 unsigned long *no_handles, efi_handle_t **buffer);
127 efi_status_t (EFIAPI *locate_protocol)(efi_guid_t *protocol,
128 void *registration, void **protocol_interface);
129 efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
130 void **handle, ...);
131 efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
132 void *handle, ...);
133 efi_status_t (EFIAPI *calculate_crc32)(void *data,
134 unsigned long data_size, uint32_t *crc32);
135 void (EFIAPI *copy_mem)(void *destination, void *source,
136 unsigned long length);
137 void (EFIAPI *set_mem)(void *buffer, unsigned long size,
138 uint8_t value);
139 void *create_event_ex;
140 };
141
142 /* Types and defines for EFI ResetSystem */
143 enum efi_reset_type {
144 EFI_RESET_COLD = 0,
145 EFI_RESET_WARM = 1,
146 EFI_RESET_SHUTDOWN = 2
147 };
148
149 /* EFI Runtime Services table */
150 #define EFI_RUNTIME_SERVICES_SIGNATURE 0x5652453544e5552ULL
151 #define EFI_RUNTIME_SERVICES_REVISION 0x00010000
152
153 struct efi_runtime_services {
154 struct efi_table_hdr hdr;
155 efi_status_t (EFIAPI *get_time)(struct efi_time *time,
156 struct efi_time_cap *capabilities);
157 efi_status_t (EFIAPI *set_time)(struct efi_time *time);
158 efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
159 struct efi_time *time);
160 efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
161 struct efi_time *time);
162 efi_status_t (EFIAPI *set_virtual_address_map)(
163 unsigned long memory_map_size,
164 unsigned long descriptor_size,
165 uint32_t descriptor_version,
166 struct efi_mem_desc *virtmap);
167 efi_status_t (*convert_pointer)(unsigned long dbg, void **address);
168 efi_status_t (EFIAPI *get_variable)(s16 *variable_name,
169 efi_guid_t *vendor, u32 *attributes,
170 unsigned long *data_size, void *data);
171 efi_status_t (EFIAPI *get_next_variable)(
172 unsigned long *variable_name_size,
173 s16 *variable_name, efi_guid_t *vendor);
174 efi_status_t (EFIAPI *set_variable)(s16 *variable_name,
175 efi_guid_t *vendor, u32 attributes,
176 unsigned long data_size, void *data);
177 efi_status_t (EFIAPI *get_next_high_mono_count)(
178 uint32_t *high_count);
179 void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
180 efi_status_t reset_status,
181 unsigned long data_size, void *reset_data);
182 void *update_capsule;
183 void *query_capsule_caps;
184 void *query_variable_info;
185 };
186
187 /* EFI Configuration Table and GUID definitions */
188 #define NULL_GUID \
189 EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
191
192 #define LOADED_IMAGE_PROTOCOL_GUID \
193 EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \
194 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
195
196 #define EFI_FDT_GUID \
197 EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
198 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
199
200 struct efi_configuration_table
201 {
202 efi_guid_t guid;
203 void *table;
204 };
205
206 #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
207
208 struct efi_system_table {
209 struct efi_table_hdr hdr;
210 unsigned long fw_vendor; /* physical addr of wchar_t vendor string */
211 u32 fw_revision;
212 unsigned long con_in_handle;
213 struct efi_simple_input_interface *con_in;
214 unsigned long con_out_handle;
215 struct efi_simple_text_output_protocol *con_out;
216 unsigned long stderr_handle;
217 struct efi_simple_text_output_protocol *std_err;
218 struct efi_runtime_services *runtime;
219 struct efi_boot_services *boottime;
220 unsigned long nr_tables;
221 struct efi_configuration_table *tables;
222 };
223
224 #define LOADED_IMAGE_GUID \
225 EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
226 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
227
228 struct efi_loaded_image {
229 u32 revision;
230 void *parent_handle;
231 struct efi_system_table *system_table;
232 void *device_handle;
233 void *file_path;
234 void *reserved;
235 u32 load_options_size;
236 void *load_options;
237 void *image_base;
238 aligned_u64 image_size;
239 unsigned int image_code_type;
240 unsigned int image_data_type;
241 unsigned long unload;
242 };
243
244 #define DEVICE_PATH_GUID \
245 EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
246 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
247
248 #define DEVICE_PATH_TYPE_END 0x7f
249 # define DEVICE_PATH_SUB_TYPE_END 0xff
250
251 struct efi_device_path {
252 u8 type;
253 u8 sub_type;
254 u16 length;
255 };
256
257 #define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04
258 # define DEVICE_PATH_SUB_TYPE_FILE_PATH 0x04
259
260 struct efi_device_path_file_path {
261 struct efi_device_path dp;
262 u16 str[16];
263 };
264
265 #define BLOCK_IO_GUID \
266 EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
267 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
268
269 struct efi_block_io_media
270 {
271 u32 media_id;
272 char removable_media;
273 char media_present;
274 char logical_partition;
275 char read_only;
276 char write_caching;
277 u8 pad[3];
278 u32 block_size;
279 u32 io_align;
280 u8 pad2[4];
281 u64 last_block;
282 };
283
284 struct efi_block_io {
285 u64 revision;
286 struct efi_block_io_media *media;
287 efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
288 char extended_verification);
289 efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
290 u32 media_id, u64 lba, unsigned long buffer_size,
291 void *buffer);
292 efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
293 u32 media_id, u64 lba, unsigned long buffer_size,
294 void *buffer);
295 efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
296 };
297
298 struct simple_text_output_mode {
299 s32 max_mode;
300 s32 mode;
301 s32 attribute;
302 s32 cursor_column;
303 s32 cursor_row;
304 bool cursor_visible;
305 };
306
307 struct efi_simple_text_output_protocol {
308 void *reset;
309 efi_status_t (EFIAPI *output_string)(
310 struct efi_simple_text_output_protocol *this,
311 const unsigned short *str);
312 efi_status_t (EFIAPI *test_string)(
313 struct efi_simple_text_output_protocol *this,
314 const unsigned short *str);
315 efi_status_t(EFIAPI *query_mode)(
316 struct efi_simple_text_output_protocol *this,
317 unsigned long mode_number, unsigned long *columns,
318 unsigned long *rows);
319 efi_status_t(EFIAPI *set_mode)(
320 struct efi_simple_text_output_protocol *this,
321 unsigned long mode_number);
322 efi_status_t(EFIAPI *set_attribute)(
323 struct efi_simple_text_output_protocol *this,
324 unsigned long attribute);
325 efi_status_t(EFIAPI *clear_screen) (
326 struct efi_simple_text_output_protocol *this);
327 efi_status_t(EFIAPI *set_cursor_position) (
328 struct efi_simple_text_output_protocol *this,
329 unsigned long column, unsigned long row);
330 efi_status_t(EFIAPI *enable_cursor)(
331 struct efi_simple_text_output_protocol *this,
332 bool enable);
333 struct simple_text_output_mode *mode;
334 };
335
336 struct efi_input_key {
337 u16 scan_code;
338 s16 unicode_char;
339 };
340
341 struct efi_simple_input_interface {
342 efi_status_t(EFIAPI *reset)(struct efi_simple_input_interface *this,
343 bool ExtendedVerification);
344 efi_status_t(EFIAPI *read_key_stroke)(
345 struct efi_simple_input_interface *this,
346 struct efi_input_key *key);
347 void *wait_for_key;
348 };
349
350 #define CONSOLE_CONTROL_GUID \
351 EFI_GUID(0xf42f7782, 0x12e, 0x4c12, \
352 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21)
353 #define EFI_CONSOLE_MODE_TEXT 0
354 #define EFI_CONSOLE_MODE_GFX 1
355
356 struct efi_console_control_protocol
357 {
358 efi_status_t (EFIAPI *get_mode)(
359 struct efi_console_control_protocol *this, int *mode,
360 char *uga_exists, char *std_in_locked);
361 efi_status_t (EFIAPI *set_mode)(
362 struct efi_console_control_protocol *this, int mode);
363 efi_status_t (EFIAPI *lock_std_in)(
364 struct efi_console_control_protocol *this,
365 uint16_t *password);
366 };
367
368 #define EFI_GOP_GUID \
369 EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
370 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
371
372 #define EFI_GOT_RGBA8 0
373 #define EFI_GOT_BGRA8 1
374 #define EFI_GOT_BITMASK 2
375
376 struct efi_gop_mode_info
377 {
378 u32 version;
379 u32 width;
380 u32 height;
381 u32 pixel_format;
382 u32 pixel_bitmask[4];
383 u32 pixels_per_scanline;
384 };
385
386 struct efi_gop_mode
387 {
388 u32 max_mode;
389 u32 mode;
390 struct efi_gop_mode_info *info;
391 unsigned long info_size;
392 efi_physical_addr_t fb_base;
393 unsigned long fb_size;
394 };
395
396 #define EFI_BLT_VIDEO_FILL 0
397 #define EFI_BLT_VIDEO_TO_BLT_BUFFER 1
398 #define EFI_BLT_BUFFER_TO_VIDEO 2
399 #define EFI_BLT_VIDEO_TO_VIDEO 3
400
401 struct efi_gop
402 {
403 efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
404 unsigned long *size_of_info,
405 struct efi_gop_mode_info **info);
406 efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
407 efi_status_t (EFIAPI *blt)(struct efi_gop *this, void *buffer,
408 unsigned long operation, unsigned long sx,
409 unsigned long sy, unsigned long dx,
410 unsigned long dy, unsigned long width,
411 unsigned long height, unsigned long delta);
412 struct efi_gop_mode *mode;
413 };
414
415 #endif