blob: 4cd06b3c4c22b219cc698fad69ac9977e354e87b [file] [log] [blame]
Alexander Grafbee91162016-03-04 01:09:59 +01001/*
2 * EFI application boot time services
3 *
4 * Copyright (c) 2016 Alexander Graf
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
Alexander Grafbee91162016-03-04 01:09:59 +01009#include <common.h>
10#include <efi_loader.h>
11#include <malloc.h>
12#include <asm/global_data.h>
13#include <libfdt_env.h>
14#include <u-boot/crc.h>
15#include <bootm.h>
16#include <inttypes.h>
17#include <watchdog.h>
18
19DECLARE_GLOBAL_DATA_PTR;
20
21/* This list contains all the EFI objects our payload has access to */
22LIST_HEAD(efi_obj_list);
23
24/*
25 * If we're running on nasty systems (32bit ARM booting into non-EFI Linux)
26 * we need to do trickery with caches. Since we don't want to break the EFI
27 * aware boot path, only apply hacks when loading exiting directly (breaking
28 * direct Linux EFI booting along the way - oh well).
29 */
30static bool efi_is_direct_boot = true;
31
32/*
33 * EFI can pass arbitrary additional "tables" containing vendor specific
34 * information to the payload. One such table is the FDT table which contains
35 * a pointer to a flattened device tree blob.
36 *
37 * In most cases we want to pass an FDT to the payload, so reserve one slot of
38 * config table space for it. The pointer gets populated by do_bootefi_exec().
39 */
Alexander Graf3c63db92016-10-14 13:45:30 +020040static struct efi_configuration_table __efi_runtime_data efi_conf_table[2];
Alexander Grafbee91162016-03-04 01:09:59 +010041
Simon Glass65e4c0b2016-09-25 15:27:35 -060042#ifdef CONFIG_ARM
Alexander Grafbee91162016-03-04 01:09:59 +010043/*
44 * The "gd" pointer lives in a register on ARM and AArch64 that we declare
45 * fixed when compiling U-Boot. However, the payload does not know about that
46 * restriction so we need to manually swap its and our view of that register on
47 * EFI callback entry/exit.
48 */
49static volatile void *efi_gd, *app_gd;
Simon Glass65e4c0b2016-09-25 15:27:35 -060050#endif
Alexander Grafbee91162016-03-04 01:09:59 +010051
52/* Called from do_bootefi_exec() */
53void efi_save_gd(void)
54{
Simon Glass65e4c0b2016-09-25 15:27:35 -060055#ifdef CONFIG_ARM
Alexander Grafbee91162016-03-04 01:09:59 +010056 efi_gd = gd;
Simon Glass65e4c0b2016-09-25 15:27:35 -060057#endif
Alexander Grafbee91162016-03-04 01:09:59 +010058}
59
60/* Called on every callback entry */
61void efi_restore_gd(void)
62{
Simon Glass65e4c0b2016-09-25 15:27:35 -060063#ifdef CONFIG_ARM
Alexander Grafbee91162016-03-04 01:09:59 +010064 /* Only restore if we're already in EFI context */
65 if (!efi_gd)
66 return;
67
68 if (gd != efi_gd)
69 app_gd = gd;
70 gd = efi_gd;
Simon Glass65e4c0b2016-09-25 15:27:35 -060071#endif
Alexander Grafbee91162016-03-04 01:09:59 +010072}
73
74/* Called on every callback exit */
75efi_status_t efi_exit_func(efi_status_t ret)
76{
Simon Glass65e4c0b2016-09-25 15:27:35 -060077#ifdef CONFIG_ARM
Alexander Grafbee91162016-03-04 01:09:59 +010078 gd = app_gd;
Simon Glass65e4c0b2016-09-25 15:27:35 -060079#endif
80
Alexander Grafbee91162016-03-04 01:09:59 +010081 return ret;
82}
83
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +020084static void efi_signal_event(struct efi_event *event)
85{
86 if (event->signaled)
87 return;
88 event->signaled = 1;
89 if (event->type & EVT_NOTIFY_SIGNAL) {
90 EFI_EXIT(EFI_SUCCESS);
91 event->notify_function(event, event->notify_context);
92 EFI_ENTRY("returning from notification function");
93 }
94}
95
Alexander Grafbee91162016-03-04 01:09:59 +010096static efi_status_t efi_unsupported(const char *funcname)
97{
Alexander Grafedcef3b2016-06-02 11:38:27 +020098 debug("EFI: App called into unimplemented function %s\n", funcname);
Alexander Grafbee91162016-03-04 01:09:59 +010099 return EFI_EXIT(EFI_UNSUPPORTED);
100}
101
102static int guidcmp(const efi_guid_t *g1, const efi_guid_t *g2)
103{
104 return memcmp(g1, g2, sizeof(efi_guid_t));
105}
106
xypron.glpk@gmx.de503f2692017-07-18 20:17:19 +0200107static unsigned long EFIAPI efi_raise_tpl(UINTN new_tpl)
Alexander Grafbee91162016-03-04 01:09:59 +0100108{
xypron.glpk@gmx.de503f2692017-07-18 20:17:19 +0200109 EFI_ENTRY("0x%zx", new_tpl);
Alexander Grafbee91162016-03-04 01:09:59 +0100110 return EFI_EXIT(0);
111}
112
xypron.glpk@gmx.de503f2692017-07-18 20:17:19 +0200113static void EFIAPI efi_restore_tpl(UINTN old_tpl)
Alexander Grafbee91162016-03-04 01:09:59 +0100114{
xypron.glpk@gmx.de503f2692017-07-18 20:17:19 +0200115 EFI_ENTRY("0x%zx", old_tpl);
Alexander Grafbee91162016-03-04 01:09:59 +0100116 EFI_EXIT(efi_unsupported(__func__));
117}
118
Masahiro Yamada6e0bf8d2017-06-22 17:49:03 +0900119static efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type,
120 unsigned long pages,
121 uint64_t *memory)
Alexander Grafbee91162016-03-04 01:09:59 +0100122{
123 efi_status_t r;
124
125 EFI_ENTRY("%d, %d, 0x%lx, %p", type, memory_type, pages, memory);
126 r = efi_allocate_pages(type, memory_type, pages, memory);
127 return EFI_EXIT(r);
128}
129
Masahiro Yamada6e0bf8d2017-06-22 17:49:03 +0900130static efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory,
131 unsigned long pages)
Alexander Grafbee91162016-03-04 01:09:59 +0100132{
133 efi_status_t r;
134
135 EFI_ENTRY("%"PRIx64", 0x%lx", memory, pages);
136 r = efi_free_pages(memory, pages);
137 return EFI_EXIT(r);
138}
139
Masahiro Yamada6e0bf8d2017-06-22 17:49:03 +0900140static efi_status_t EFIAPI efi_get_memory_map_ext(
141 unsigned long *memory_map_size,
142 struct efi_mem_desc *memory_map,
143 unsigned long *map_key,
144 unsigned long *descriptor_size,
145 uint32_t *descriptor_version)
Alexander Grafbee91162016-03-04 01:09:59 +0100146{
147 efi_status_t r;
148
149 EFI_ENTRY("%p, %p, %p, %p, %p", memory_map_size, memory_map,
150 map_key, descriptor_size, descriptor_version);
151 r = efi_get_memory_map(memory_map_size, memory_map, map_key,
152 descriptor_size, descriptor_version);
153 return EFI_EXIT(r);
154}
155
Stefan Brünsead12742016-10-09 22:17:18 +0200156static efi_status_t EFIAPI efi_allocate_pool_ext(int pool_type,
157 unsigned long size,
158 void **buffer)
Alexander Grafbee91162016-03-04 01:09:59 +0100159{
Alexander Graf1cd29f02016-03-24 01:37:37 +0100160 efi_status_t r;
161
162 EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer);
Stefan Brünsead12742016-10-09 22:17:18 +0200163 r = efi_allocate_pool(pool_type, size, buffer);
Alexander Graf1cd29f02016-03-24 01:37:37 +0100164 return EFI_EXIT(r);
Alexander Grafbee91162016-03-04 01:09:59 +0100165}
166
Stefan Brüns42417bc2016-10-09 22:17:26 +0200167static efi_status_t EFIAPI efi_free_pool_ext(void *buffer)
Alexander Grafbee91162016-03-04 01:09:59 +0100168{
Alexander Graf1cd29f02016-03-24 01:37:37 +0100169 efi_status_t r;
170
171 EFI_ENTRY("%p", buffer);
Stefan Brüns42417bc2016-10-09 22:17:26 +0200172 r = efi_free_pool(buffer);
Alexander Graf1cd29f02016-03-24 01:37:37 +0100173 return EFI_EXIT(r);
Alexander Grafbee91162016-03-04 01:09:59 +0100174}
175
176/*
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200177 * Our event capabilities are very limited. Only a small limited
178 * number of events is allowed to coexist.
Alexander Grafbee91162016-03-04 01:09:59 +0100179 */
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200180static struct efi_event efi_events[16];
Alexander Grafbee91162016-03-04 01:09:59 +0100181
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +0200182efi_status_t efi_create_event(enum efi_event_type type, UINTN notify_tpl,
183 void (EFIAPI *notify_function) (
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +0200184 struct efi_event *event,
185 void *context),
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +0200186 void *notify_context, struct efi_event **event)
Alexander Grafbee91162016-03-04 01:09:59 +0100187{
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200188 int i;
189
Jonathan Graya95343b2017-03-12 19:26:07 +1100190 if (event == NULL)
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +0200191 return EFI_INVALID_PARAMETER;
Jonathan Graya95343b2017-03-12 19:26:07 +1100192
193 if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +0200194 return EFI_INVALID_PARAMETER;
Jonathan Graya95343b2017-03-12 19:26:07 +1100195
196 if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
197 notify_function == NULL)
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +0200198 return EFI_INVALID_PARAMETER;
Jonathan Graya95343b2017-03-12 19:26:07 +1100199
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200200 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
201 if (efi_events[i].type)
202 continue;
203 efi_events[i].type = type;
204 efi_events[i].notify_tpl = notify_tpl;
205 efi_events[i].notify_function = notify_function;
206 efi_events[i].notify_context = notify_context;
207 /* Disable timers on bootup */
208 efi_events[i].trigger_next = -1ULL;
209 efi_events[i].signaled = 0;
210 *event = &efi_events[i];
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +0200211 return EFI_SUCCESS;
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200212 }
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +0200213 return EFI_OUT_OF_RESOURCES;
Alexander Grafbee91162016-03-04 01:09:59 +0100214}
215
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +0200216static efi_status_t EFIAPI efi_create_event_ext(
217 enum efi_event_type type, UINTN notify_tpl,
218 void (EFIAPI *notify_function) (
219 struct efi_event *event,
220 void *context),
221 void *notify_context, struct efi_event **event)
222{
223 EFI_ENTRY("%d, 0x%zx, %p, %p", type, notify_tpl, notify_function,
224 notify_context);
225 return EFI_EXIT(efi_create_event(type, notify_tpl, notify_function,
226 notify_context, event));
227}
228
229
Alexander Grafbee91162016-03-04 01:09:59 +0100230/*
231 * Our timers have to work without interrupts, so we check whenever keyboard
232 * input or disk accesses happen if enough time elapsed for it to fire.
233 */
234void efi_timer_check(void)
235{
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200236 int i;
Alexander Grafbee91162016-03-04 01:09:59 +0100237 u64 now = timer_get_us();
238
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200239 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
240 if (!efi_events[i].type ||
241 !(efi_events[i].type & EVT_TIMER) ||
242 efi_events[i].trigger_type == EFI_TIMER_STOP ||
243 now < efi_events[i].trigger_next)
244 continue;
245 if (efi_events[i].trigger_type == EFI_TIMER_PERIODIC) {
246 efi_events[i].trigger_next +=
247 efi_events[i].trigger_time / 10;
248 efi_events[i].signaled = 0;
249 }
250 efi_signal_event(&efi_events[i]);
Alexander Grafbee91162016-03-04 01:09:59 +0100251 }
Alexander Grafbee91162016-03-04 01:09:59 +0100252 WATCHDOG_RESET();
253}
254
xypron.glpk@gmx.debfc72462017-07-18 20:17:21 +0200255efi_status_t efi_set_timer(struct efi_event *event, int type,
256 uint64_t trigger_time)
Alexander Grafbee91162016-03-04 01:09:59 +0100257{
258 /* We don't have 64bit division available everywhere, so limit timer
259 * distances to 32bit bits. */
260 u32 trigger32 = trigger_time;
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200261 int i;
Alexander Grafbee91162016-03-04 01:09:59 +0100262
Alexander Grafbee91162016-03-04 01:09:59 +0100263 if (trigger32 < trigger_time) {
264 printf("WARNING: Truncating timer from %"PRIx64" to %x\n",
265 trigger_time, trigger32);
266 }
267
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200268 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
269 if (event != &efi_events[i])
270 continue;
Alexander Grafbee91162016-03-04 01:09:59 +0100271
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200272 if (!(event->type & EVT_TIMER))
273 break;
274 switch (type) {
275 case EFI_TIMER_STOP:
276 event->trigger_next = -1ULL;
277 break;
278 case EFI_TIMER_PERIODIC:
279 case EFI_TIMER_RELATIVE:
280 event->trigger_next =
281 timer_get_us() + (trigger32 / 10);
282 break;
283 default:
xypron.glpk@gmx.debfc72462017-07-18 20:17:21 +0200284 return EFI_INVALID_PARAMETER;
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200285 }
286 event->trigger_type = type;
287 event->trigger_time = trigger_time;
xypron.glpk@gmx.debfc72462017-07-18 20:17:21 +0200288 return EFI_SUCCESS;
Alexander Grafbee91162016-03-04 01:09:59 +0100289 }
xypron.glpk@gmx.debfc72462017-07-18 20:17:21 +0200290 return EFI_INVALID_PARAMETER;
291}
292
293static efi_status_t EFIAPI efi_set_timer_ext(struct efi_event *event, int type,
294 uint64_t trigger_time)
295{
296 EFI_ENTRY("%p, %d, %"PRIx64, event, type, trigger_time);
297 return EFI_EXIT(efi_set_timer(event, type, trigger_time));
Alexander Grafbee91162016-03-04 01:09:59 +0100298}
299
300static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +0200301 struct efi_event **event,
302 unsigned long *index)
Alexander Grafbee91162016-03-04 01:09:59 +0100303{
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200304 int i, j;
Alexander Grafbee91162016-03-04 01:09:59 +0100305
306 EFI_ENTRY("%ld, %p, %p", num_events, event, index);
307
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200308 /* Check parameters */
309 if (!num_events || !event)
310 return EFI_EXIT(EFI_INVALID_PARAMETER);
311 for (i = 0; i < num_events; ++i) {
312 for (j = 0; j < ARRAY_SIZE(efi_events); ++j) {
313 if (event[i] == &efi_events[j])
314 goto known_event;
315 }
316 return EFI_EXIT(EFI_INVALID_PARAMETER);
317known_event:
318 if (!event[i]->type || event[i]->type & EVT_NOTIFY_SIGNAL)
319 return EFI_EXIT(EFI_INVALID_PARAMETER);
320 }
321
322 /* Wait for signal */
323 for (;;) {
324 for (i = 0; i < num_events; ++i) {
325 if (event[i]->signaled)
326 goto out;
327 }
328 /* Allow events to occur. */
329 efi_timer_check();
330 }
331
332out:
333 /*
334 * Reset the signal which is passed to the caller to allow periodic
335 * events to occur.
336 */
337 event[i]->signaled = 0;
338 if (index)
339 *index = i;
Alexander Grafbee91162016-03-04 01:09:59 +0100340
341 return EFI_EXIT(EFI_SUCCESS);
342}
343
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200344static efi_status_t EFIAPI efi_signal_event_ext(struct efi_event *event)
Alexander Grafbee91162016-03-04 01:09:59 +0100345{
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200346 int i;
347
Alexander Grafbee91162016-03-04 01:09:59 +0100348 EFI_ENTRY("%p", event);
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200349 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
350 if (event != &efi_events[i])
351 continue;
352 efi_signal_event(event);
353 break;
354 }
Alexander Grafbee91162016-03-04 01:09:59 +0100355 return EFI_EXIT(EFI_SUCCESS);
356}
357
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +0200358static efi_status_t EFIAPI efi_close_event(struct efi_event *event)
Alexander Grafbee91162016-03-04 01:09:59 +0100359{
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200360 int i;
361
Alexander Grafbee91162016-03-04 01:09:59 +0100362 EFI_ENTRY("%p", event);
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200363 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
364 if (event == &efi_events[i]) {
365 event->type = 0;
366 event->trigger_next = -1ULL;
367 event->signaled = 0;
368 return EFI_EXIT(EFI_SUCCESS);
369 }
370 }
371 return EFI_EXIT(EFI_INVALID_PARAMETER);
Alexander Grafbee91162016-03-04 01:09:59 +0100372}
373
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +0200374static efi_status_t EFIAPI efi_check_event(struct efi_event *event)
Alexander Grafbee91162016-03-04 01:09:59 +0100375{
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200376 int i;
377
Alexander Grafbee91162016-03-04 01:09:59 +0100378 EFI_ENTRY("%p", event);
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +0200379 efi_timer_check();
380 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
381 if (event != &efi_events[i])
382 continue;
383 if (!event->type || event->type & EVT_NOTIFY_SIGNAL)
384 break;
385 if (event->signaled)
386 return EFI_EXIT(EFI_SUCCESS);
387 return EFI_EXIT(EFI_NOT_READY);
388 }
389 return EFI_EXIT(EFI_INVALID_PARAMETER);
Alexander Grafbee91162016-03-04 01:09:59 +0100390}
391
392static efi_status_t EFIAPI efi_install_protocol_interface(void **handle,
393 efi_guid_t *protocol, int protocol_interface_type,
394 void *protocol_interface)
395{
xypron.glpk@gmx.dee0549f82017-07-11 22:06:16 +0200396 struct list_head *lhandle;
397 int i;
398 efi_status_t r;
399
xypron.glpk@gmx.dee0549f82017-07-11 22:06:16 +0200400 if (!handle || !protocol ||
401 protocol_interface_type != EFI_NATIVE_INTERFACE) {
402 r = EFI_INVALID_PARAMETER;
403 goto out;
404 }
405
406 /* Create new handle if requested. */
407 if (!*handle) {
408 r = EFI_OUT_OF_RESOURCES;
409 goto out;
410 }
411 /* Find object. */
412 list_for_each(lhandle, &efi_obj_list) {
413 struct efi_object *efiobj;
414 efiobj = list_entry(lhandle, struct efi_object, link);
415
416 if (efiobj->handle != *handle)
417 continue;
418 /* Check if protocol is already installed on the handle. */
419 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
420 struct efi_handler *handler = &efiobj->protocols[i];
421
422 if (!handler->guid)
423 continue;
424 if (!guidcmp(handler->guid, protocol)) {
425 r = EFI_INVALID_PARAMETER;
426 goto out;
427 }
428 }
429 /* Install protocol in first empty slot. */
430 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
431 struct efi_handler *handler = &efiobj->protocols[i];
432
433 if (handler->guid)
434 continue;
435
436 handler->guid = protocol;
437 handler->protocol_interface = protocol_interface;
438 r = EFI_SUCCESS;
439 goto out;
440 }
441 r = EFI_OUT_OF_RESOURCES;
442 goto out;
443 }
444 r = EFI_INVALID_PARAMETER;
445out:
xypron.glpk@gmx.de8bee5a32017-07-11 22:06:18 +0200446 return r;
447}
448
449static efi_status_t EFIAPI efi_install_protocol_interface_ext(void **handle,
450 efi_guid_t *protocol, int protocol_interface_type,
451 void *protocol_interface)
452{
453 EFI_ENTRY("%p, %p, %d, %p", handle, protocol, protocol_interface_type,
454 protocol_interface);
455
456 return EFI_EXIT(efi_install_protocol_interface(handle, protocol,
457 protocol_interface_type,
458 protocol_interface));
Alexander Grafbee91162016-03-04 01:09:59 +0100459}
xypron.glpk@gmx.dee0549f82017-07-11 22:06:16 +0200460
Alexander Grafbee91162016-03-04 01:09:59 +0100461static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle,
462 efi_guid_t *protocol, void *old_interface,
463 void *new_interface)
464{
465 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, old_interface,
466 new_interface);
467 return EFI_EXIT(EFI_ACCESS_DENIED);
468}
469
470static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle,
471 efi_guid_t *protocol, void *protocol_interface)
472{
xypron.glpk@gmx.de4b6ed0d2017-07-11 22:06:17 +0200473 struct list_head *lhandle;
474 int i;
475 efi_status_t r = EFI_NOT_FOUND;
476
xypron.glpk@gmx.de4b6ed0d2017-07-11 22:06:17 +0200477 if (!handle || !protocol) {
478 r = EFI_INVALID_PARAMETER;
479 goto out;
480 }
481
482 list_for_each(lhandle, &efi_obj_list) {
483 struct efi_object *efiobj;
484 efiobj = list_entry(lhandle, struct efi_object, link);
485
486 if (efiobj->handle != handle)
487 continue;
488
489 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
490 struct efi_handler *handler = &efiobj->protocols[i];
491 const efi_guid_t *hprotocol = handler->guid;
492
493 if (!hprotocol)
494 continue;
495 if (!guidcmp(hprotocol, protocol)) {
496 if (handler->protocol_interface) {
497 r = EFI_ACCESS_DENIED;
498 } else {
499 handler->guid = 0;
500 r = EFI_SUCCESS;
501 }
502 goto out;
503 }
504 }
505 }
506
507out:
xypron.glpk@gmx.de3d8e1452017-07-11 22:06:19 +0200508 return r;
509}
510
511static efi_status_t EFIAPI efi_uninstall_protocol_interface_ext(void *handle,
512 efi_guid_t *protocol, void *protocol_interface)
513{
514 EFI_ENTRY("%p, %p, %p", handle, protocol, protocol_interface);
515
516 return EFI_EXIT(efi_uninstall_protocol_interface(handle, protocol,
517 protocol_interface));
Alexander Grafbee91162016-03-04 01:09:59 +0100518}
519
520static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol,
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +0200521 struct efi_event *event,
Alexander Grafbee91162016-03-04 01:09:59 +0100522 void **registration)
523{
524 EFI_ENTRY("%p, %p, %p", protocol, event, registration);
525 return EFI_EXIT(EFI_OUT_OF_RESOURCES);
526}
527
528static int efi_search(enum efi_locate_search_type search_type,
529 efi_guid_t *protocol, void *search_key,
530 struct efi_object *efiobj)
531{
532 int i;
533
534 switch (search_type) {
535 case all_handles:
536 return 0;
537 case by_register_notify:
538 return -1;
539 case by_protocol:
540 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
541 const efi_guid_t *guid = efiobj->protocols[i].guid;
542 if (guid && !guidcmp(guid, protocol))
543 return 0;
544 }
545 return -1;
546 }
547
548 return -1;
549}
550
551static efi_status_t EFIAPI efi_locate_handle(
552 enum efi_locate_search_type search_type,
553 efi_guid_t *protocol, void *search_key,
554 unsigned long *buffer_size, efi_handle_t *buffer)
555{
556 struct list_head *lhandle;
557 unsigned long size = 0;
558
Alexander Grafbee91162016-03-04 01:09:59 +0100559 /* Count how much space we need */
560 list_for_each(lhandle, &efi_obj_list) {
561 struct efi_object *efiobj;
562 efiobj = list_entry(lhandle, struct efi_object, link);
563 if (!efi_search(search_type, protocol, search_key, efiobj)) {
564 size += sizeof(void*);
565 }
566 }
567
568 if (*buffer_size < size) {
569 *buffer_size = size;
xypron.glpk@gmx.de26329582017-07-11 22:06:21 +0200570 return EFI_BUFFER_TOO_SMALL;
Alexander Grafbee91162016-03-04 01:09:59 +0100571 }
572
573 /* Then fill the array */
574 list_for_each(lhandle, &efi_obj_list) {
575 struct efi_object *efiobj;
576 efiobj = list_entry(lhandle, struct efi_object, link);
577 if (!efi_search(search_type, protocol, search_key, efiobj)) {
578 *(buffer++) = efiobj->handle;
579 }
580 }
581
582 *buffer_size = size;
xypron.glpk@gmx.de26329582017-07-11 22:06:21 +0200583 return EFI_SUCCESS;
584}
585
586static efi_status_t EFIAPI efi_locate_handle_ext(
587 enum efi_locate_search_type search_type,
588 efi_guid_t *protocol, void *search_key,
589 unsigned long *buffer_size, efi_handle_t *buffer)
590{
591 EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
592 buffer_size, buffer);
593
594 return EFI_EXIT(efi_locate_handle(search_type, protocol, search_key,
595 buffer_size, buffer));
Alexander Grafbee91162016-03-04 01:09:59 +0100596}
597
598static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol,
599 struct efi_device_path **device_path,
600 efi_handle_t *device)
601{
602 EFI_ENTRY("%p, %p, %p", protocol, device_path, device);
603 return EFI_EXIT(EFI_NOT_FOUND);
604}
605
Alexander Graf488bf122016-08-19 01:23:24 +0200606efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table)
Alexander Grafbee91162016-03-04 01:09:59 +0100607{
608 int i;
609
Alexander Grafbee91162016-03-04 01:09:59 +0100610 /* Check for guid override */
611 for (i = 0; i < systab.nr_tables; i++) {
612 if (!guidcmp(guid, &efi_conf_table[i].guid)) {
613 efi_conf_table[i].table = table;
Alexander Graf488bf122016-08-19 01:23:24 +0200614 return EFI_SUCCESS;
Alexander Grafbee91162016-03-04 01:09:59 +0100615 }
616 }
617
618 /* No override, check for overflow */
619 if (i >= ARRAY_SIZE(efi_conf_table))
Alexander Graf488bf122016-08-19 01:23:24 +0200620 return EFI_OUT_OF_RESOURCES;
Alexander Grafbee91162016-03-04 01:09:59 +0100621
622 /* Add a new entry */
623 memcpy(&efi_conf_table[i].guid, guid, sizeof(*guid));
624 efi_conf_table[i].table = table;
Alexander Grafaba5e912016-08-19 01:23:30 +0200625 systab.nr_tables = i + 1;
Alexander Grafbee91162016-03-04 01:09:59 +0100626
Alexander Graf488bf122016-08-19 01:23:24 +0200627 return EFI_SUCCESS;
628}
629
630static efi_status_t EFIAPI efi_install_configuration_table_ext(efi_guid_t *guid,
631 void *table)
632{
633 EFI_ENTRY("%p, %p", guid, table);
634 return EFI_EXIT(efi_install_configuration_table(guid, table));
Alexander Grafbee91162016-03-04 01:09:59 +0100635}
636
637static efi_status_t EFIAPI efi_load_image(bool boot_policy,
638 efi_handle_t parent_image,
639 struct efi_device_path *file_path,
640 void *source_buffer,
641 unsigned long source_size,
642 efi_handle_t *image_handle)
643{
644 static struct efi_object loaded_image_info_obj = {
645 .protocols = {
646 {
647 .guid = &efi_guid_loaded_image,
Alexander Grafbee91162016-03-04 01:09:59 +0100648 },
649 },
650 };
651 struct efi_loaded_image *info;
652 struct efi_object *obj;
653
654 EFI_ENTRY("%d, %p, %p, %p, %ld, %p", boot_policy, parent_image,
655 file_path, source_buffer, source_size, image_handle);
656 info = malloc(sizeof(*info));
xypron.glpk@gmx.deb5349f72017-07-11 22:06:14 +0200657 loaded_image_info_obj.protocols[0].protocol_interface = info;
Alexander Grafbee91162016-03-04 01:09:59 +0100658 obj = malloc(sizeof(loaded_image_info_obj));
659 memset(info, 0, sizeof(*info));
660 memcpy(obj, &loaded_image_info_obj, sizeof(loaded_image_info_obj));
661 obj->handle = info;
662 info->file_path = file_path;
663 info->reserved = efi_load_pe(source_buffer, info);
664 if (!info->reserved) {
665 free(info);
666 free(obj);
667 return EFI_EXIT(EFI_UNSUPPORTED);
668 }
669
670 *image_handle = info;
671 list_add_tail(&obj->link, &efi_obj_list);
672
673 return EFI_EXIT(EFI_SUCCESS);
674}
675
676static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
677 unsigned long *exit_data_size,
678 s16 **exit_data)
679{
680 ulong (*entry)(void *image_handle, struct efi_system_table *st);
681 struct efi_loaded_image *info = image_handle;
682
683 EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
684 entry = info->reserved;
685
686 efi_is_direct_boot = false;
687
688 /* call the image! */
Alexander Grafa86aeaf2016-05-20 23:28:23 +0200689 if (setjmp(&info->exit_jmp)) {
690 /* We returned from the child image */
691 return EFI_EXIT(info->exit_status);
692 }
693
Alexander Grafbee91162016-03-04 01:09:59 +0100694 entry(image_handle, &systab);
695
696 /* Should usually never get here */
697 return EFI_EXIT(EFI_SUCCESS);
698}
699
Alexander Grafa86aeaf2016-05-20 23:28:23 +0200700static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
701 efi_status_t exit_status, unsigned long exit_data_size,
702 int16_t *exit_data)
Alexander Grafbee91162016-03-04 01:09:59 +0100703{
Alexander Grafa86aeaf2016-05-20 23:28:23 +0200704 struct efi_loaded_image *loaded_image_info = (void*)image_handle;
705
Alexander Grafbee91162016-03-04 01:09:59 +0100706 EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
707 exit_data_size, exit_data);
Alexander Grafa86aeaf2016-05-20 23:28:23 +0200708
709 loaded_image_info->exit_status = exit_status;
Alexander Graf692fcdd2016-09-27 09:30:32 +0200710 longjmp(&loaded_image_info->exit_jmp, 1);
Alexander Grafa86aeaf2016-05-20 23:28:23 +0200711
712 panic("EFI application exited");
Alexander Grafbee91162016-03-04 01:09:59 +0100713}
714
715static struct efi_object *efi_search_obj(void *handle)
716{
717 struct list_head *lhandle;
718
719 list_for_each(lhandle, &efi_obj_list) {
720 struct efi_object *efiobj;
721 efiobj = list_entry(lhandle, struct efi_object, link);
722 if (efiobj->handle == handle)
723 return efiobj;
724 }
725
726 return NULL;
727}
728
729static efi_status_t EFIAPI efi_unload_image(void *image_handle)
730{
731 struct efi_object *efiobj;
732
733 EFI_ENTRY("%p", image_handle);
734 efiobj = efi_search_obj(image_handle);
735 if (efiobj)
736 list_del(&efiobj->link);
737
738 return EFI_EXIT(EFI_SUCCESS);
739}
740
741static void efi_exit_caches(void)
742{
743#if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
744 /*
745 * Grub on 32bit ARM needs to have caches disabled before jumping into
746 * a zImage, but does not know of all cache layers. Give it a hand.
747 */
748 if (efi_is_direct_boot)
749 cleanup_before_linux();
750#endif
751}
752
753static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle,
754 unsigned long map_key)
755{
756 EFI_ENTRY("%p, %ld", image_handle, map_key);
757
Alexander Grafb7b84102016-11-17 01:02:57 +0100758 board_quiesce_devices();
759
Alexander Grafbee91162016-03-04 01:09:59 +0100760 /* Fix up caches for EFI payloads if necessary */
761 efi_exit_caches();
762
763 /* This stops all lingering devices */
764 bootm_disable_interrupts();
765
766 /* Give the payload some time to boot */
767 WATCHDOG_RESET();
768
769 return EFI_EXIT(EFI_SUCCESS);
770}
771
772static efi_status_t EFIAPI efi_get_next_monotonic_count(uint64_t *count)
773{
774 static uint64_t mono = 0;
775 EFI_ENTRY("%p", count);
776 *count = mono++;
777 return EFI_EXIT(EFI_SUCCESS);
778}
779
780static efi_status_t EFIAPI efi_stall(unsigned long microseconds)
781{
782 EFI_ENTRY("%ld", microseconds);
783 udelay(microseconds);
784 return EFI_EXIT(EFI_SUCCESS);
785}
786
787static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout,
788 uint64_t watchdog_code,
789 unsigned long data_size,
790 uint16_t *watchdog_data)
791{
792 EFI_ENTRY("%ld, 0x%"PRIx64", %ld, %p", timeout, watchdog_code,
793 data_size, watchdog_data);
794 return EFI_EXIT(efi_unsupported(__func__));
795}
796
797static efi_status_t EFIAPI efi_connect_controller(
798 efi_handle_t controller_handle,
799 efi_handle_t *driver_image_handle,
800 struct efi_device_path *remain_device_path,
801 bool recursive)
802{
803 EFI_ENTRY("%p, %p, %p, %d", controller_handle, driver_image_handle,
804 remain_device_path, recursive);
805 return EFI_EXIT(EFI_NOT_FOUND);
806}
807
808static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle,
809 void *driver_image_handle,
810 void *child_handle)
811{
812 EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle,
813 child_handle);
814 return EFI_EXIT(EFI_INVALID_PARAMETER);
815}
816
817static efi_status_t EFIAPI efi_close_protocol(void *handle,
818 efi_guid_t *protocol,
819 void *agent_handle,
820 void *controller_handle)
821{
822 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, agent_handle,
823 controller_handle);
824 return EFI_EXIT(EFI_NOT_FOUND);
825}
826
827static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,
828 efi_guid_t *protocol,
829 struct efi_open_protocol_info_entry **entry_buffer,
830 unsigned long *entry_count)
831{
832 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, entry_buffer,
833 entry_count);
834 return EFI_EXIT(EFI_NOT_FOUND);
835}
836
837static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,
838 efi_guid_t ***protocol_buffer,
839 unsigned long *protocol_buffer_count)
840{
841 EFI_ENTRY("%p, %p, %p", handle, protocol_buffer,
842 protocol_buffer_count);
843 return EFI_EXIT(EFI_OUT_OF_RESOURCES);
844}
845
846static efi_status_t EFIAPI efi_locate_handle_buffer(
847 enum efi_locate_search_type search_type,
848 efi_guid_t *protocol, void *search_key,
849 unsigned long *no_handles, efi_handle_t **buffer)
850{
xypron.glpk@gmx.dec2e703f2017-07-11 22:06:22 +0200851 efi_status_t r;
852 unsigned long buffer_size = 0;
853
Alexander Grafbee91162016-03-04 01:09:59 +0100854 EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
855 no_handles, buffer);
xypron.glpk@gmx.dec2e703f2017-07-11 22:06:22 +0200856
857 if (!no_handles || !buffer) {
858 r = EFI_INVALID_PARAMETER;
859 goto out;
860 }
861 *no_handles = 0;
862 *buffer = NULL;
863 r = efi_locate_handle(search_type, protocol, search_key, &buffer_size,
864 *buffer);
865 if (r != EFI_BUFFER_TOO_SMALL)
866 goto out;
867 r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
868 (void **)buffer);
869 if (r != EFI_SUCCESS)
870 goto out;
871 r = efi_locate_handle(search_type, protocol, search_key, &buffer_size,
872 *buffer);
873 if (r == EFI_SUCCESS)
874 *no_handles = buffer_size / sizeof(void *);
875out:
876 return EFI_EXIT(r);
Alexander Grafbee91162016-03-04 01:09:59 +0100877}
878
Alexander Grafbee91162016-03-04 01:09:59 +0100879static efi_status_t EFIAPI efi_locate_protocol(efi_guid_t *protocol,
880 void *registration,
881 void **protocol_interface)
882{
xypron.glpk@gmx.de88adae52017-07-11 22:06:24 +0200883 struct list_head *lhandle;
Alexander Grafbee91162016-03-04 01:09:59 +0100884 int i;
885
886 EFI_ENTRY("%p, %p, %p", protocol, registration, protocol_interface);
xypron.glpk@gmx.de88adae52017-07-11 22:06:24 +0200887
888 if (!protocol || !protocol_interface)
889 return EFI_EXIT(EFI_INVALID_PARAMETER);
890
891 list_for_each(lhandle, &efi_obj_list) {
892 struct efi_object *efiobj;
893
894 efiobj = list_entry(lhandle, struct efi_object, link);
895 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
896 struct efi_handler *handler = &efiobj->protocols[i];
897
898 if (!handler->guid)
899 continue;
900 if (!guidcmp(handler->guid, protocol)) {
901 *protocol_interface =
902 handler->protocol_interface;
903 return EFI_EXIT(EFI_SUCCESS);
904 }
Alexander Grafbee91162016-03-04 01:09:59 +0100905 }
906 }
xypron.glpk@gmx.de88adae52017-07-11 22:06:24 +0200907 *protocol_interface = NULL;
Alexander Grafbee91162016-03-04 01:09:59 +0100908
909 return EFI_EXIT(EFI_NOT_FOUND);
910}
911
912static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(
913 void **handle, ...)
914{
915 EFI_ENTRY("%p", handle);
xypron.glpk@gmx.de58b83582017-07-11 22:06:20 +0200916
917 va_list argptr;
918 efi_guid_t *protocol;
919 void *protocol_interface;
920 efi_status_t r = EFI_SUCCESS;
921 int i = 0;
922
923 if (!handle)
924 return EFI_EXIT(EFI_INVALID_PARAMETER);
925
926 va_start(argptr, handle);
927 for (;;) {
928 protocol = va_arg(argptr, efi_guid_t*);
929 if (!protocol)
930 break;
931 protocol_interface = va_arg(argptr, void*);
932 r = efi_install_protocol_interface(handle, protocol,
933 EFI_NATIVE_INTERFACE,
934 protocol_interface);
935 if (r != EFI_SUCCESS)
936 break;
937 i++;
938 }
939 va_end(argptr);
940 if (r == EFI_SUCCESS)
941 return EFI_EXIT(r);
942
943 /* If an error occured undo all changes. */
944 va_start(argptr, handle);
945 for (; i; --i) {
946 protocol = va_arg(argptr, efi_guid_t*);
947 protocol_interface = va_arg(argptr, void*);
948 efi_uninstall_protocol_interface(handle, protocol,
949 protocol_interface);
950 }
951 va_end(argptr);
952
953 return EFI_EXIT(r);
Alexander Grafbee91162016-03-04 01:09:59 +0100954}
955
956static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces(
957 void *handle, ...)
958{
959 EFI_ENTRY("%p", handle);
960 return EFI_EXIT(EFI_INVALID_PARAMETER);
961}
962
963static efi_status_t EFIAPI efi_calculate_crc32(void *data,
964 unsigned long data_size,
965 uint32_t *crc32_p)
966{
967 EFI_ENTRY("%p, %ld", data, data_size);
968 *crc32_p = crc32(0, data, data_size);
969 return EFI_EXIT(EFI_SUCCESS);
970}
971
972static void EFIAPI efi_copy_mem(void *destination, void *source,
973 unsigned long length)
974{
975 EFI_ENTRY("%p, %p, %ld", destination, source, length);
976 memcpy(destination, source, length);
977}
978
979static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value)
980{
981 EFI_ENTRY("%p, %ld, 0x%x", buffer, size, value);
982 memset(buffer, value, size);
983}
984
985static efi_status_t EFIAPI efi_open_protocol(
986 void *handle, efi_guid_t *protocol,
987 void **protocol_interface, void *agent_handle,
988 void *controller_handle, uint32_t attributes)
989{
990 struct list_head *lhandle;
991 int i;
xypron.glpk@gmx.de69baec62017-07-11 22:06:15 +0200992 efi_status_t r = EFI_INVALID_PARAMETER;
Alexander Grafbee91162016-03-04 01:09:59 +0100993
994 EFI_ENTRY("%p, %p, %p, %p, %p, 0x%x", handle, protocol,
995 protocol_interface, agent_handle, controller_handle,
996 attributes);
xypron.glpk@gmx.deb5349f72017-07-11 22:06:14 +0200997
xypron.glpk@gmx.de69baec62017-07-11 22:06:15 +0200998 if (!handle || !protocol ||
999 (!protocol_interface && attributes !=
1000 EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {
1001 goto out;
1002 }
1003
1004 switch (attributes) {
1005 case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
1006 case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
1007 case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
1008 break;
1009 case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
1010 if (controller_handle == handle)
1011 goto out;
1012 case EFI_OPEN_PROTOCOL_BY_DRIVER:
1013 case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
1014 if (controller_handle == NULL)
1015 goto out;
1016 case EFI_OPEN_PROTOCOL_EXCLUSIVE:
1017 if (agent_handle == NULL)
1018 goto out;
1019 break;
1020 default:
xypron.glpk@gmx.deb5349f72017-07-11 22:06:14 +02001021 goto out;
1022 }
1023
Alexander Grafbee91162016-03-04 01:09:59 +01001024 list_for_each(lhandle, &efi_obj_list) {
1025 struct efi_object *efiobj;
1026 efiobj = list_entry(lhandle, struct efi_object, link);
1027
1028 if (efiobj->handle != handle)
1029 continue;
1030
1031 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
1032 struct efi_handler *handler = &efiobj->protocols[i];
1033 const efi_guid_t *hprotocol = handler->guid;
1034 if (!hprotocol)
xypron.glpk@gmx.de4b6ed0d2017-07-11 22:06:17 +02001035 continue;
Alexander Grafbee91162016-03-04 01:09:59 +01001036 if (!guidcmp(hprotocol, protocol)) {
xypron.glpk@gmx.deb5349f72017-07-11 22:06:14 +02001037 if (attributes !=
1038 EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
1039 *protocol_interface =
1040 handler->protocol_interface;
1041 }
1042 r = EFI_SUCCESS;
Alexander Grafbee91162016-03-04 01:09:59 +01001043 goto out;
1044 }
1045 }
xypron.glpk@gmx.de69baec62017-07-11 22:06:15 +02001046 goto unsupported;
Alexander Grafbee91162016-03-04 01:09:59 +01001047 }
1048
xypron.glpk@gmx.de69baec62017-07-11 22:06:15 +02001049unsupported:
1050 r = EFI_UNSUPPORTED;
Alexander Grafbee91162016-03-04 01:09:59 +01001051out:
1052 return EFI_EXIT(r);
1053}
1054
1055static efi_status_t EFIAPI efi_handle_protocol(void *handle,
1056 efi_guid_t *protocol,
1057 void **protocol_interface)
1058{
xypron.glpk@gmx.de8e1d3292017-06-29 21:16:19 +02001059 return efi_open_protocol(handle, protocol, protocol_interface, NULL,
1060 NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
Alexander Grafbee91162016-03-04 01:09:59 +01001061}
1062
1063static const struct efi_boot_services efi_boot_services = {
1064 .hdr = {
1065 .headersize = sizeof(struct efi_table_hdr),
1066 },
1067 .raise_tpl = efi_raise_tpl,
1068 .restore_tpl = efi_restore_tpl,
1069 .allocate_pages = efi_allocate_pages_ext,
1070 .free_pages = efi_free_pages_ext,
1071 .get_memory_map = efi_get_memory_map_ext,
Stefan Brünsead12742016-10-09 22:17:18 +02001072 .allocate_pool = efi_allocate_pool_ext,
Stefan Brüns42417bc2016-10-09 22:17:26 +02001073 .free_pool = efi_free_pool_ext,
xypron.glpk@gmx.de49deb452017-07-18 20:17:20 +02001074 .create_event = efi_create_event_ext,
xypron.glpk@gmx.debfc72462017-07-18 20:17:21 +02001075 .set_timer = efi_set_timer_ext,
Alexander Grafbee91162016-03-04 01:09:59 +01001076 .wait_for_event = efi_wait_for_event,
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +02001077 .signal_event = efi_signal_event_ext,
Alexander Grafbee91162016-03-04 01:09:59 +01001078 .close_event = efi_close_event,
1079 .check_event = efi_check_event,
xypron.glpk@gmx.de8bee5a32017-07-11 22:06:18 +02001080 .install_protocol_interface = efi_install_protocol_interface_ext,
Alexander Grafbee91162016-03-04 01:09:59 +01001081 .reinstall_protocol_interface = efi_reinstall_protocol_interface,
xypron.glpk@gmx.de3d8e1452017-07-11 22:06:19 +02001082 .uninstall_protocol_interface = efi_uninstall_protocol_interface_ext,
Alexander Grafbee91162016-03-04 01:09:59 +01001083 .handle_protocol = efi_handle_protocol,
1084 .reserved = NULL,
1085 .register_protocol_notify = efi_register_protocol_notify,
xypron.glpk@gmx.de26329582017-07-11 22:06:21 +02001086 .locate_handle = efi_locate_handle_ext,
Alexander Grafbee91162016-03-04 01:09:59 +01001087 .locate_device_path = efi_locate_device_path,
Alexander Graf488bf122016-08-19 01:23:24 +02001088 .install_configuration_table = efi_install_configuration_table_ext,
Alexander Grafbee91162016-03-04 01:09:59 +01001089 .load_image = efi_load_image,
1090 .start_image = efi_start_image,
Alexander Grafa86aeaf2016-05-20 23:28:23 +02001091 .exit = efi_exit,
Alexander Grafbee91162016-03-04 01:09:59 +01001092 .unload_image = efi_unload_image,
1093 .exit_boot_services = efi_exit_boot_services,
1094 .get_next_monotonic_count = efi_get_next_monotonic_count,
1095 .stall = efi_stall,
1096 .set_watchdog_timer = efi_set_watchdog_timer,
1097 .connect_controller = efi_connect_controller,
1098 .disconnect_controller = efi_disconnect_controller,
1099 .open_protocol = efi_open_protocol,
1100 .close_protocol = efi_close_protocol,
1101 .open_protocol_information = efi_open_protocol_information,
1102 .protocols_per_handle = efi_protocols_per_handle,
1103 .locate_handle_buffer = efi_locate_handle_buffer,
1104 .locate_protocol = efi_locate_protocol,
1105 .install_multiple_protocol_interfaces = efi_install_multiple_protocol_interfaces,
1106 .uninstall_multiple_protocol_interfaces = efi_uninstall_multiple_protocol_interfaces,
1107 .calculate_crc32 = efi_calculate_crc32,
1108 .copy_mem = efi_copy_mem,
1109 .set_mem = efi_set_mem,
1110};
1111
1112
Alexander Graf3c63db92016-10-14 13:45:30 +02001113static uint16_t __efi_runtime_data firmware_vendor[] =
Alexander Grafbee91162016-03-04 01:09:59 +01001114 { 'D','a','s',' ','U','-','b','o','o','t',0 };
1115
Alexander Graf3c63db92016-10-14 13:45:30 +02001116struct efi_system_table __efi_runtime_data systab = {
Alexander Grafbee91162016-03-04 01:09:59 +01001117 .hdr = {
1118 .signature = EFI_SYSTEM_TABLE_SIGNATURE,
1119 .revision = 0x20005, /* 2.5 */
1120 .headersize = sizeof(struct efi_table_hdr),
1121 },
1122 .fw_vendor = (long)firmware_vendor,
1123 .con_in = (void*)&efi_con_in,
1124 .con_out = (void*)&efi_con_out,
1125 .std_err = (void*)&efi_con_out,
1126 .runtime = (void*)&efi_runtime_services,
1127 .boottime = (void*)&efi_boot_services,
1128 .nr_tables = 0,
1129 .tables = (void*)efi_conf_table,
1130};