]> git.ipfire.org Git - thirdparty/u-boot.git/blame - lib/efi_loader/efi_boottime.c
efi_selftest: test task priority levels
[thirdparty/u-boot.git] / lib / efi_loader / efi_boottime.c
CommitLineData
bee91169
AG
1/*
2 * EFI application boot time services
3 *
4 * Copyright (c) 2016 Alexander Graf
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
bee91169
AG
9#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
32f4b2f8
HS
21/* Task priority level */
22static UINTN efi_tpl = TPL_APPLICATION;
23
bee91169
AG
24/* This list contains all the EFI objects our payload has access to */
25LIST_HEAD(efi_obj_list);
26
27/*
28 * If we're running on nasty systems (32bit ARM booting into non-EFI Linux)
29 * we need to do trickery with caches. Since we don't want to break the EFI
30 * aware boot path, only apply hacks when loading exiting directly (breaking
31 * direct Linux EFI booting along the way - oh well).
32 */
33static bool efi_is_direct_boot = true;
34
35/*
36 * EFI can pass arbitrary additional "tables" containing vendor specific
37 * information to the payload. One such table is the FDT table which contains
38 * a pointer to a flattened device tree blob.
39 *
40 * In most cases we want to pass an FDT to the payload, so reserve one slot of
41 * config table space for it. The pointer gets populated by do_bootefi_exec().
42 */
3c63db9c 43static struct efi_configuration_table __efi_runtime_data efi_conf_table[2];
bee91169 44
65e4c0b1 45#ifdef CONFIG_ARM
bee91169
AG
46/*
47 * The "gd" pointer lives in a register on ARM and AArch64 that we declare
48 * fixed when compiling U-Boot. However, the payload does not know about that
49 * restriction so we need to manually swap its and our view of that register on
50 * EFI callback entry/exit.
51 */
52static volatile void *efi_gd, *app_gd;
65e4c0b1 53#endif
bee91169 54
c160d2f5 55static int entry_count;
af65db85 56static int nesting_level;
c160d2f5
RC
57
58/* Called on every callback entry */
59int __efi_entry_check(void)
60{
61 int ret = entry_count++ == 0;
62#ifdef CONFIG_ARM
63 assert(efi_gd);
64 app_gd = gd;
65 gd = efi_gd;
66#endif
67 return ret;
68}
69
70/* Called on every callback exit */
71int __efi_exit_check(void)
72{
73 int ret = --entry_count == 0;
74#ifdef CONFIG_ARM
75 gd = app_gd;
76#endif
77 return ret;
78}
79
bee91169
AG
80/* Called from do_bootefi_exec() */
81void efi_save_gd(void)
82{
65e4c0b1 83#ifdef CONFIG_ARM
bee91169 84 efi_gd = gd;
65e4c0b1 85#endif
bee91169
AG
86}
87
c160d2f5
RC
88/*
89 * Special case handler for error/abort that just forces things back
90 * to u-boot world so we can dump out an abort msg, without any care
91 * about returning back to UEFI world.
92 */
bee91169
AG
93void efi_restore_gd(void)
94{
65e4c0b1 95#ifdef CONFIG_ARM
bee91169
AG
96 /* Only restore if we're already in EFI context */
97 if (!efi_gd)
98 return;
bee91169 99 gd = efi_gd;
65e4c0b1 100#endif
bee91169
AG
101}
102
af65db85
RC
103/*
104 * Two spaces per indent level, maxing out at 10.. which ought to be
105 * enough for anyone ;-)
106 */
107static const char *indent_string(int level)
108{
109 const char *indent = " ";
110 const int max = strlen(indent);
111 level = min(max, level * 2);
112 return &indent[max - level];
113}
114
ae0bd3a9
HS
115const char *__efi_nesting(void)
116{
117 return indent_string(nesting_level);
118}
119
af65db85
RC
120const char *__efi_nesting_inc(void)
121{
122 return indent_string(nesting_level++);
123}
124
125const char *__efi_nesting_dec(void)
126{
127 return indent_string(--nesting_level);
128}
129
8787b02e
HS
130/* Low 32 bit */
131#define EFI_LOW32(a) (a & 0xFFFFFFFFULL)
132/* High 32 bit */
133#define EFI_HIGH32(a) (a >> 32)
134
135/*
136 * 64bit division by 10 implemented as multiplication by 1 / 10
137 *
138 * Decimals of one tenth: 0x1 / 0xA = 0x0.19999...
139 */
140#define EFI_TENTH 0x199999999999999A
141static u64 efi_div10(u64 a)
142{
143 u64 prod;
144 u64 rem;
145 u64 ret;
146
147 ret = EFI_HIGH32(a) * EFI_HIGH32(EFI_TENTH);
148 prod = EFI_HIGH32(a) * EFI_LOW32(EFI_TENTH);
149 rem = EFI_LOW32(prod);
150 ret += EFI_HIGH32(prod);
151 prod = EFI_LOW32(a) * EFI_HIGH32(EFI_TENTH);
152 rem += EFI_LOW32(prod);
153 ret += EFI_HIGH32(prod);
154 prod = EFI_LOW32(a) * EFI_LOW32(EFI_TENTH);
155 rem += EFI_HIGH32(prod);
156 ret += EFI_HIGH32(rem);
157 /* Round to nearest integer */
158 if (rem >= (1 << 31))
159 ++ret;
160 return ret;
161}
162
91be9a77 163void efi_signal_event(struct efi_event *event)
c6841592 164{
ca62a4f5
HS
165 if (event->notify_function) {
166 event->queued = 1;
32f4b2f8
HS
167 /* Check TPL */
168 if (efi_tpl >= event->notify_tpl)
169 return;
ea630ce9
HS
170 EFI_CALL_VOID(event->notify_function(event,
171 event->notify_context));
c6841592 172 }
ca62a4f5 173 event->queued = 0;
c6841592
HS
174}
175
bee91169
AG
176static efi_status_t efi_unsupported(const char *funcname)
177{
edcef3ba 178 debug("EFI: App called into unimplemented function %s\n", funcname);
bee91169
AG
179 return EFI_EXIT(EFI_UNSUPPORTED);
180}
181
503f2695 182static unsigned long EFIAPI efi_raise_tpl(UINTN new_tpl)
bee91169 183{
32f4b2f8
HS
184 UINTN old_tpl = efi_tpl;
185
503f2695 186 EFI_ENTRY("0x%zx", new_tpl);
32f4b2f8
HS
187
188 if (new_tpl < efi_tpl)
189 debug("WARNING: new_tpl < current_tpl in %s\n", __func__);
190 efi_tpl = new_tpl;
191 if (efi_tpl > TPL_HIGH_LEVEL)
192 efi_tpl = TPL_HIGH_LEVEL;
193
194 EFI_EXIT(EFI_SUCCESS);
195 return old_tpl;
bee91169
AG
196}
197
503f2695 198static void EFIAPI efi_restore_tpl(UINTN old_tpl)
bee91169 199{
503f2695 200 EFI_ENTRY("0x%zx", old_tpl);
32f4b2f8
HS
201
202 if (old_tpl > efi_tpl)
203 debug("WARNING: old_tpl > current_tpl in %s\n", __func__);
204 efi_tpl = old_tpl;
205 if (efi_tpl > TPL_HIGH_LEVEL)
206 efi_tpl = TPL_HIGH_LEVEL;
207
208 EFI_EXIT(EFI_SUCCESS);
bee91169
AG
209}
210
6e0bf8d8
MY
211static efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type,
212 unsigned long pages,
213 uint64_t *memory)
bee91169
AG
214{
215 efi_status_t r;
216
217 EFI_ENTRY("%d, %d, 0x%lx, %p", type, memory_type, pages, memory);
218 r = efi_allocate_pages(type, memory_type, pages, memory);
219 return EFI_EXIT(r);
220}
221
6e0bf8d8
MY
222static efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory,
223 unsigned long pages)
bee91169
AG
224{
225 efi_status_t r;
226
227 EFI_ENTRY("%"PRIx64", 0x%lx", memory, pages);
228 r = efi_free_pages(memory, pages);
229 return EFI_EXIT(r);
230}
231
6e0bf8d8
MY
232static efi_status_t EFIAPI efi_get_memory_map_ext(
233 unsigned long *memory_map_size,
234 struct efi_mem_desc *memory_map,
235 unsigned long *map_key,
236 unsigned long *descriptor_size,
237 uint32_t *descriptor_version)
bee91169
AG
238{
239 efi_status_t r;
240
241 EFI_ENTRY("%p, %p, %p, %p, %p", memory_map_size, memory_map,
242 map_key, descriptor_size, descriptor_version);
243 r = efi_get_memory_map(memory_map_size, memory_map, map_key,
244 descriptor_size, descriptor_version);
245 return EFI_EXIT(r);
246}
247
ead1274b
SB
248static efi_status_t EFIAPI efi_allocate_pool_ext(int pool_type,
249 unsigned long size,
250 void **buffer)
bee91169 251{
1cd29f0a
AG
252 efi_status_t r;
253
254 EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer);
ead1274b 255 r = efi_allocate_pool(pool_type, size, buffer);
1cd29f0a 256 return EFI_EXIT(r);
bee91169
AG
257}
258
42417bc8 259static efi_status_t EFIAPI efi_free_pool_ext(void *buffer)
bee91169 260{
1cd29f0a
AG
261 efi_status_t r;
262
263 EFI_ENTRY("%p", buffer);
42417bc8 264 r = efi_free_pool(buffer);
1cd29f0a 265 return EFI_EXIT(r);
bee91169
AG
266}
267
268/*
c6841592
HS
269 * Our event capabilities are very limited. Only a small limited
270 * number of events is allowed to coexist.
bee91169 271 */
c6841592 272static struct efi_event efi_events[16];
bee91169 273
b521d29e 274efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,
49deb455 275 void (EFIAPI *notify_function) (
2fd945fe
HS
276 struct efi_event *event,
277 void *context),
49deb455 278 void *notify_context, struct efi_event **event)
bee91169 279{
c6841592
HS
280 int i;
281
a95343b8 282 if (event == NULL)
49deb455 283 return EFI_INVALID_PARAMETER;
a95343b8
JG
284
285 if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
49deb455 286 return EFI_INVALID_PARAMETER;
a95343b8
JG
287
288 if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
289 notify_function == NULL)
49deb455 290 return EFI_INVALID_PARAMETER;
a95343b8 291
c6841592
HS
292 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
293 if (efi_events[i].type)
294 continue;
295 efi_events[i].type = type;
296 efi_events[i].notify_tpl = notify_tpl;
297 efi_events[i].notify_function = notify_function;
298 efi_events[i].notify_context = notify_context;
299 /* Disable timers on bootup */
300 efi_events[i].trigger_next = -1ULL;
ca62a4f5 301 efi_events[i].queued = 0;
c6841592
HS
302 efi_events[i].signaled = 0;
303 *event = &efi_events[i];
49deb455 304 return EFI_SUCCESS;
c6841592 305 }
49deb455 306 return EFI_OUT_OF_RESOURCES;
bee91169
AG
307}
308
49deb455 309static efi_status_t EFIAPI efi_create_event_ext(
b521d29e 310 uint32_t type, UINTN notify_tpl,
49deb455
HS
311 void (EFIAPI *notify_function) (
312 struct efi_event *event,
313 void *context),
314 void *notify_context, struct efi_event **event)
315{
316 EFI_ENTRY("%d, 0x%zx, %p, %p", type, notify_tpl, notify_function,
317 notify_context);
318 return EFI_EXIT(efi_create_event(type, notify_tpl, notify_function,
319 notify_context, event));
320}
321
322
bee91169
AG
323/*
324 * Our timers have to work without interrupts, so we check whenever keyboard
325 * input or disk accesses happen if enough time elapsed for it to fire.
326 */
327void efi_timer_check(void)
328{
c6841592 329 int i;
bee91169
AG
330 u64 now = timer_get_us();
331
c6841592 332 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
ca62a4f5
HS
333 if (!efi_events[i].type)
334 continue;
335 if (efi_events[i].queued)
336 efi_signal_event(&efi_events[i]);
337 if (!(efi_events[i].type & EVT_TIMER) ||
c6841592
HS
338 now < efi_events[i].trigger_next)
339 continue;
ca62a4f5
HS
340 switch (efi_events[i].trigger_type) {
341 case EFI_TIMER_RELATIVE:
342 efi_events[i].trigger_type = EFI_TIMER_STOP;
343 break;
344 case EFI_TIMER_PERIODIC:
c6841592 345 efi_events[i].trigger_next +=
8787b02e 346 efi_events[i].trigger_time;
ca62a4f5
HS
347 break;
348 default:
349 continue;
c6841592 350 }
ca62a4f5 351 efi_events[i].signaled = 1;
c6841592 352 efi_signal_event(&efi_events[i]);
bee91169 353 }
bee91169
AG
354 WATCHDOG_RESET();
355}
356
b521d29e 357efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type,
bfc72462 358 uint64_t trigger_time)
bee91169 359{
c6841592 360 int i;
bee91169 361
8787b02e
HS
362 /*
363 * The parameter defines a multiple of 100ns.
364 * We use multiples of 1000ns. So divide by 10.
365 */
366 trigger_time = efi_div10(trigger_time);
bee91169 367
c6841592
HS
368 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
369 if (event != &efi_events[i])
370 continue;
bee91169 371
c6841592
HS
372 if (!(event->type & EVT_TIMER))
373 break;
374 switch (type) {
375 case EFI_TIMER_STOP:
376 event->trigger_next = -1ULL;
377 break;
378 case EFI_TIMER_PERIODIC:
379 case EFI_TIMER_RELATIVE:
380 event->trigger_next =
8787b02e 381 timer_get_us() + trigger_time;
c6841592
HS
382 break;
383 default:
bfc72462 384 return EFI_INVALID_PARAMETER;
c6841592
HS
385 }
386 event->trigger_type = type;
387 event->trigger_time = trigger_time;
2eca8452 388 event->signaled = 0;
bfc72462 389 return EFI_SUCCESS;
bee91169 390 }
bfc72462
HS
391 return EFI_INVALID_PARAMETER;
392}
393
b521d29e
HS
394static efi_status_t EFIAPI efi_set_timer_ext(struct efi_event *event,
395 enum efi_timer_delay type,
396 uint64_t trigger_time)
bfc72462
HS
397{
398 EFI_ENTRY("%p, %d, %"PRIx64, event, type, trigger_time);
399 return EFI_EXIT(efi_set_timer(event, type, trigger_time));
bee91169
AG
400}
401
402static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,
2fd945fe
HS
403 struct efi_event **event,
404 unsigned long *index)
bee91169 405{
c6841592 406 int i, j;
bee91169
AG
407
408 EFI_ENTRY("%ld, %p, %p", num_events, event, index);
409
c6841592
HS
410 /* Check parameters */
411 if (!num_events || !event)
412 return EFI_EXIT(EFI_INVALID_PARAMETER);
32f4b2f8
HS
413 /* Check TPL */
414 if (efi_tpl != TPL_APPLICATION)
415 return EFI_EXIT(EFI_UNSUPPORTED);
c6841592
HS
416 for (i = 0; i < num_events; ++i) {
417 for (j = 0; j < ARRAY_SIZE(efi_events); ++j) {
418 if (event[i] == &efi_events[j])
419 goto known_event;
420 }
421 return EFI_EXIT(EFI_INVALID_PARAMETER);
422known_event:
423 if (!event[i]->type || event[i]->type & EVT_NOTIFY_SIGNAL)
424 return EFI_EXIT(EFI_INVALID_PARAMETER);
ca62a4f5
HS
425 if (!event[i]->signaled)
426 efi_signal_event(event[i]);
c6841592
HS
427 }
428
429 /* Wait for signal */
430 for (;;) {
431 for (i = 0; i < num_events; ++i) {
432 if (event[i]->signaled)
433 goto out;
434 }
435 /* Allow events to occur. */
436 efi_timer_check();
437 }
438
439out:
440 /*
441 * Reset the signal which is passed to the caller to allow periodic
442 * events to occur.
443 */
444 event[i]->signaled = 0;
445 if (index)
446 *index = i;
bee91169
AG
447
448 return EFI_EXIT(EFI_SUCCESS);
449}
450
c6841592 451static efi_status_t EFIAPI efi_signal_event_ext(struct efi_event *event)
bee91169 452{
c6841592
HS
453 int i;
454
bee91169 455 EFI_ENTRY("%p", event);
c6841592
HS
456 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
457 if (event != &efi_events[i])
458 continue;
ca62a4f5
HS
459 if (event->signaled)
460 break;
461 event->signaled = 1;
462 if (event->type & EVT_NOTIFY_SIGNAL)
463 efi_signal_event(event);
c6841592
HS
464 break;
465 }
bee91169
AG
466 return EFI_EXIT(EFI_SUCCESS);
467}
468
2fd945fe 469static efi_status_t EFIAPI efi_close_event(struct efi_event *event)
bee91169 470{
c6841592
HS
471 int i;
472
bee91169 473 EFI_ENTRY("%p", event);
c6841592
HS
474 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
475 if (event == &efi_events[i]) {
476 event->type = 0;
477 event->trigger_next = -1ULL;
ca62a4f5 478 event->queued = 0;
c6841592
HS
479 event->signaled = 0;
480 return EFI_EXIT(EFI_SUCCESS);
481 }
482 }
483 return EFI_EXIT(EFI_INVALID_PARAMETER);
bee91169
AG
484}
485
2fd945fe 486static efi_status_t EFIAPI efi_check_event(struct efi_event *event)
bee91169 487{
c6841592
HS
488 int i;
489
bee91169 490 EFI_ENTRY("%p", event);
c6841592
HS
491 efi_timer_check();
492 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
493 if (event != &efi_events[i])
494 continue;
495 if (!event->type || event->type & EVT_NOTIFY_SIGNAL)
496 break;
ca62a4f5
HS
497 if (!event->signaled)
498 efi_signal_event(event);
c6841592
HS
499 if (event->signaled)
500 return EFI_EXIT(EFI_SUCCESS);
501 return EFI_EXIT(EFI_NOT_READY);
502 }
503 return EFI_EXIT(EFI_INVALID_PARAMETER);
bee91169
AG
504}
505
506static efi_status_t EFIAPI efi_install_protocol_interface(void **handle,
507 efi_guid_t *protocol, int protocol_interface_type,
508 void *protocol_interface)
509{
e0549f8a
HS
510 struct list_head *lhandle;
511 int i;
512 efi_status_t r;
513
e0549f8a
HS
514 if (!handle || !protocol ||
515 protocol_interface_type != EFI_NATIVE_INTERFACE) {
516 r = EFI_INVALID_PARAMETER;
517 goto out;
518 }
519
520 /* Create new handle if requested. */
521 if (!*handle) {
522 r = EFI_OUT_OF_RESOURCES;
523 goto out;
524 }
525 /* Find object. */
526 list_for_each(lhandle, &efi_obj_list) {
527 struct efi_object *efiobj;
528 efiobj = list_entry(lhandle, struct efi_object, link);
529
530 if (efiobj->handle != *handle)
531 continue;
532 /* Check if protocol is already installed on the handle. */
533 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
534 struct efi_handler *handler = &efiobj->protocols[i];
535
536 if (!handler->guid)
537 continue;
538 if (!guidcmp(handler->guid, protocol)) {
539 r = EFI_INVALID_PARAMETER;
540 goto out;
541 }
542 }
543 /* Install protocol in first empty slot. */
544 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
545 struct efi_handler *handler = &efiobj->protocols[i];
546
547 if (handler->guid)
548 continue;
549
550 handler->guid = protocol;
551 handler->protocol_interface = protocol_interface;
552 r = EFI_SUCCESS;
553 goto out;
554 }
555 r = EFI_OUT_OF_RESOURCES;
556 goto out;
557 }
558 r = EFI_INVALID_PARAMETER;
559out:
8bee5a3c
HS
560 return r;
561}
562
563static efi_status_t EFIAPI efi_install_protocol_interface_ext(void **handle,
564 efi_guid_t *protocol, int protocol_interface_type,
565 void *protocol_interface)
566{
567 EFI_ENTRY("%p, %p, %d, %p", handle, protocol, protocol_interface_type,
568 protocol_interface);
569
570 return EFI_EXIT(efi_install_protocol_interface(handle, protocol,
571 protocol_interface_type,
572 protocol_interface));
bee91169 573}
e0549f8a 574
bee91169
AG
575static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle,
576 efi_guid_t *protocol, void *old_interface,
577 void *new_interface)
578{
579 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, old_interface,
580 new_interface);
581 return EFI_EXIT(EFI_ACCESS_DENIED);
582}
583
584static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle,
585 efi_guid_t *protocol, void *protocol_interface)
586{
4b6ed0d7
HS
587 struct list_head *lhandle;
588 int i;
589 efi_status_t r = EFI_NOT_FOUND;
590
4b6ed0d7
HS
591 if (!handle || !protocol) {
592 r = EFI_INVALID_PARAMETER;
593 goto out;
594 }
595
596 list_for_each(lhandle, &efi_obj_list) {
597 struct efi_object *efiobj;
598 efiobj = list_entry(lhandle, struct efi_object, link);
599
600 if (efiobj->handle != handle)
601 continue;
602
603 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
604 struct efi_handler *handler = &efiobj->protocols[i];
605 const efi_guid_t *hprotocol = handler->guid;
606
607 if (!hprotocol)
608 continue;
609 if (!guidcmp(hprotocol, protocol)) {
610 if (handler->protocol_interface) {
611 r = EFI_ACCESS_DENIED;
612 } else {
613 handler->guid = 0;
614 r = EFI_SUCCESS;
615 }
616 goto out;
617 }
618 }
619 }
620
621out:
3d8e1456
HS
622 return r;
623}
624
625static efi_status_t EFIAPI efi_uninstall_protocol_interface_ext(void *handle,
626 efi_guid_t *protocol, void *protocol_interface)
627{
628 EFI_ENTRY("%p, %p, %p", handle, protocol, protocol_interface);
629
630 return EFI_EXIT(efi_uninstall_protocol_interface(handle, protocol,
631 protocol_interface));
bee91169
AG
632}
633
634static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol,
2fd945fe 635 struct efi_event *event,
bee91169
AG
636 void **registration)
637{
638 EFI_ENTRY("%p, %p, %p", protocol, event, registration);
639 return EFI_EXIT(EFI_OUT_OF_RESOURCES);
640}
641
642static int efi_search(enum efi_locate_search_type search_type,
643 efi_guid_t *protocol, void *search_key,
644 struct efi_object *efiobj)
645{
646 int i;
647
648 switch (search_type) {
649 case all_handles:
650 return 0;
651 case by_register_notify:
652 return -1;
653 case by_protocol:
654 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
655 const efi_guid_t *guid = efiobj->protocols[i].guid;
656 if (guid && !guidcmp(guid, protocol))
657 return 0;
658 }
659 return -1;
660 }
661
662 return -1;
663}
664
ebf199b9 665static efi_status_t efi_locate_handle(
bee91169
AG
666 enum efi_locate_search_type search_type,
667 efi_guid_t *protocol, void *search_key,
668 unsigned long *buffer_size, efi_handle_t *buffer)
669{
670 struct list_head *lhandle;
671 unsigned long size = 0;
672
bee91169
AG
673 /* Count how much space we need */
674 list_for_each(lhandle, &efi_obj_list) {
675 struct efi_object *efiobj;
676 efiobj = list_entry(lhandle, struct efi_object, link);
677 if (!efi_search(search_type, protocol, search_key, efiobj)) {
678 size += sizeof(void*);
679 }
680 }
681
682 if (*buffer_size < size) {
683 *buffer_size = size;
26329584 684 return EFI_BUFFER_TOO_SMALL;
bee91169
AG
685 }
686
796a78cb
RC
687 *buffer_size = size;
688 if (size == 0)
689 return EFI_NOT_FOUND;
690
bee91169
AG
691 /* Then fill the array */
692 list_for_each(lhandle, &efi_obj_list) {
693 struct efi_object *efiobj;
694 efiobj = list_entry(lhandle, struct efi_object, link);
695 if (!efi_search(search_type, protocol, search_key, efiobj)) {
696 *(buffer++) = efiobj->handle;
697 }
698 }
699
26329584
HS
700 return EFI_SUCCESS;
701}
702
703static efi_status_t EFIAPI efi_locate_handle_ext(
704 enum efi_locate_search_type search_type,
705 efi_guid_t *protocol, void *search_key,
706 unsigned long *buffer_size, efi_handle_t *buffer)
707{
708 EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
709 buffer_size, buffer);
710
711 return EFI_EXIT(efi_locate_handle(search_type, protocol, search_key,
712 buffer_size, buffer));
bee91169
AG
713}
714
715static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol,
716 struct efi_device_path **device_path,
717 efi_handle_t *device)
718{
719 EFI_ENTRY("%p, %p, %p", protocol, device_path, device);
720 return EFI_EXIT(EFI_NOT_FOUND);
721}
722
d98cdf6a
AG
723/* Collapses configuration table entries, removing index i */
724static void efi_remove_configuration_table(int i)
725{
726 struct efi_configuration_table *this = &efi_conf_table[i];
727 struct efi_configuration_table *next = &efi_conf_table[i+1];
728 struct efi_configuration_table *end = &efi_conf_table[systab.nr_tables];
729
730 memmove(this, next, (ulong)end - (ulong)next);
731 systab.nr_tables--;
732}
733
488bf12d 734efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table)
bee91169
AG
735{
736 int i;
737
bee91169
AG
738 /* Check for guid override */
739 for (i = 0; i < systab.nr_tables; i++) {
740 if (!guidcmp(guid, &efi_conf_table[i].guid)) {
d98cdf6a
AG
741 if (table)
742 efi_conf_table[i].table = table;
743 else
744 efi_remove_configuration_table(i);
488bf12d 745 return EFI_SUCCESS;
bee91169
AG
746 }
747 }
748
d98cdf6a
AG
749 if (!table)
750 return EFI_NOT_FOUND;
751
bee91169
AG
752 /* No override, check for overflow */
753 if (i >= ARRAY_SIZE(efi_conf_table))
488bf12d 754 return EFI_OUT_OF_RESOURCES;
bee91169
AG
755
756 /* Add a new entry */
757 memcpy(&efi_conf_table[i].guid, guid, sizeof(*guid));
758 efi_conf_table[i].table = table;
aba5e919 759 systab.nr_tables = i + 1;
bee91169 760
488bf12d
AG
761 return EFI_SUCCESS;
762}
763
764static efi_status_t EFIAPI efi_install_configuration_table_ext(efi_guid_t *guid,
765 void *table)
766{
767 EFI_ENTRY("%p, %p", guid, table);
768 return EFI_EXIT(efi_install_configuration_table(guid, table));
bee91169
AG
769}
770
771static efi_status_t EFIAPI efi_load_image(bool boot_policy,
772 efi_handle_t parent_image,
773 struct efi_device_path *file_path,
774 void *source_buffer,
775 unsigned long source_size,
776 efi_handle_t *image_handle)
777{
778 static struct efi_object loaded_image_info_obj = {
779 .protocols = {
780 {
781 .guid = &efi_guid_loaded_image,
bee91169
AG
782 },
783 },
784 };
785 struct efi_loaded_image *info;
786 struct efi_object *obj;
787
788 EFI_ENTRY("%d, %p, %p, %p, %ld, %p", boot_policy, parent_image,
789 file_path, source_buffer, source_size, image_handle);
790 info = malloc(sizeof(*info));
b5349f74 791 loaded_image_info_obj.protocols[0].protocol_interface = info;
bee91169
AG
792 obj = malloc(sizeof(loaded_image_info_obj));
793 memset(info, 0, sizeof(*info));
794 memcpy(obj, &loaded_image_info_obj, sizeof(loaded_image_info_obj));
795 obj->handle = info;
796 info->file_path = file_path;
797 info->reserved = efi_load_pe(source_buffer, info);
798 if (!info->reserved) {
799 free(info);
800 free(obj);
801 return EFI_EXIT(EFI_UNSUPPORTED);
802 }
803
804 *image_handle = info;
805 list_add_tail(&obj->link, &efi_obj_list);
806
807 return EFI_EXIT(EFI_SUCCESS);
808}
809
810static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
811 unsigned long *exit_data_size,
812 s16 **exit_data)
813{
814 ulong (*entry)(void *image_handle, struct efi_system_table *st);
815 struct efi_loaded_image *info = image_handle;
816
817 EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
818 entry = info->reserved;
819
820 efi_is_direct_boot = false;
821
822 /* call the image! */
a86aeaf2
AG
823 if (setjmp(&info->exit_jmp)) {
824 /* We returned from the child image */
825 return EFI_EXIT(info->exit_status);
826 }
827
af65db85 828 __efi_nesting_dec();
c160d2f5 829 __efi_exit_check();
bee91169 830 entry(image_handle, &systab);
c160d2f5 831 __efi_entry_check();
af65db85 832 __efi_nesting_inc();
bee91169
AG
833
834 /* Should usually never get here */
835 return EFI_EXIT(EFI_SUCCESS);
836}
837
a86aeaf2
AG
838static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
839 efi_status_t exit_status, unsigned long exit_data_size,
840 int16_t *exit_data)
bee91169 841{
a86aeaf2
AG
842 struct efi_loaded_image *loaded_image_info = (void*)image_handle;
843
bee91169
AG
844 EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
845 exit_data_size, exit_data);
a86aeaf2 846
a148920e 847 /* Make sure entry/exit counts for EFI world cross-overs match */
da94073b
HS
848 __efi_exit_check();
849
a148920e
AG
850 /*
851 * But longjmp out with the U-Boot gd, not the application's, as
852 * the other end is a setjmp call inside EFI context.
853 */
854 efi_restore_gd();
855
a86aeaf2 856 loaded_image_info->exit_status = exit_status;
692fcdd8 857 longjmp(&loaded_image_info->exit_jmp, 1);
a86aeaf2
AG
858
859 panic("EFI application exited");
bee91169
AG
860}
861
862static struct efi_object *efi_search_obj(void *handle)
863{
864 struct list_head *lhandle;
865
866 list_for_each(lhandle, &efi_obj_list) {
867 struct efi_object *efiobj;
868 efiobj = list_entry(lhandle, struct efi_object, link);
869 if (efiobj->handle == handle)
870 return efiobj;
871 }
872
873 return NULL;
874}
875
876static efi_status_t EFIAPI efi_unload_image(void *image_handle)
877{
878 struct efi_object *efiobj;
879
880 EFI_ENTRY("%p", image_handle);
881 efiobj = efi_search_obj(image_handle);
882 if (efiobj)
883 list_del(&efiobj->link);
884
885 return EFI_EXIT(EFI_SUCCESS);
886}
887
888static void efi_exit_caches(void)
889{
890#if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
891 /*
892 * Grub on 32bit ARM needs to have caches disabled before jumping into
893 * a zImage, but does not know of all cache layers. Give it a hand.
894 */
895 if (efi_is_direct_boot)
896 cleanup_before_linux();
897#endif
898}
899
900static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle,
901 unsigned long map_key)
902{
903 EFI_ENTRY("%p, %ld", image_handle, map_key);
904
b7b8410a
AG
905 board_quiesce_devices();
906
bee91169
AG
907 /* Fix up caches for EFI payloads if necessary */
908 efi_exit_caches();
909
910 /* This stops all lingering devices */
911 bootm_disable_interrupts();
912
913 /* Give the payload some time to boot */
914 WATCHDOG_RESET();
915
916 return EFI_EXIT(EFI_SUCCESS);
917}
918
919static efi_status_t EFIAPI efi_get_next_monotonic_count(uint64_t *count)
920{
921 static uint64_t mono = 0;
922 EFI_ENTRY("%p", count);
923 *count = mono++;
924 return EFI_EXIT(EFI_SUCCESS);
925}
926
927static efi_status_t EFIAPI efi_stall(unsigned long microseconds)
928{
929 EFI_ENTRY("%ld", microseconds);
930 udelay(microseconds);
931 return EFI_EXIT(EFI_SUCCESS);
932}
933
934static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout,
935 uint64_t watchdog_code,
936 unsigned long data_size,
937 uint16_t *watchdog_data)
938{
939 EFI_ENTRY("%ld, 0x%"PRIx64", %ld, %p", timeout, watchdog_code,
940 data_size, watchdog_data);
b5104821 941 return efi_unsupported(__func__);
bee91169
AG
942}
943
944static efi_status_t EFIAPI efi_connect_controller(
945 efi_handle_t controller_handle,
946 efi_handle_t *driver_image_handle,
947 struct efi_device_path *remain_device_path,
948 bool recursive)
949{
950 EFI_ENTRY("%p, %p, %p, %d", controller_handle, driver_image_handle,
951 remain_device_path, recursive);
952 return EFI_EXIT(EFI_NOT_FOUND);
953}
954
955static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle,
956 void *driver_image_handle,
957 void *child_handle)
958{
959 EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle,
960 child_handle);
961 return EFI_EXIT(EFI_INVALID_PARAMETER);
962}
963
964static efi_status_t EFIAPI efi_close_protocol(void *handle,
965 efi_guid_t *protocol,
966 void *agent_handle,
967 void *controller_handle)
968{
969 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, agent_handle,
970 controller_handle);
971 return EFI_EXIT(EFI_NOT_FOUND);
972}
973
974static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,
975 efi_guid_t *protocol,
976 struct efi_open_protocol_info_entry **entry_buffer,
977 unsigned long *entry_count)
978{
979 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, entry_buffer,
980 entry_count);
981 return EFI_EXIT(EFI_NOT_FOUND);
982}
983
984static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,
985 efi_guid_t ***protocol_buffer,
986 unsigned long *protocol_buffer_count)
987{
c0ebfc86
HS
988 unsigned long buffer_size;
989 struct efi_object *efiobj;
990 unsigned long i, j;
991 struct list_head *lhandle;
992 efi_status_t r;
993
bee91169
AG
994 EFI_ENTRY("%p, %p, %p", handle, protocol_buffer,
995 protocol_buffer_count);
c0ebfc86
HS
996
997 if (!handle || !protocol_buffer || !protocol_buffer_count)
998 return EFI_EXIT(EFI_INVALID_PARAMETER);
999
1000 *protocol_buffer = NULL;
661c8327 1001 *protocol_buffer_count = 0;
c0ebfc86
HS
1002 list_for_each(lhandle, &efi_obj_list) {
1003 efiobj = list_entry(lhandle, struct efi_object, link);
1004
1005 if (efiobj->handle != handle)
1006 continue;
1007
1008 /* Count protocols */
1009 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
1010 if (efiobj->protocols[i].guid)
1011 ++*protocol_buffer_count;
1012 }
1013 /* Copy guids */
1014 if (*protocol_buffer_count) {
1015 buffer_size = sizeof(efi_guid_t *) *
1016 *protocol_buffer_count;
1017 r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
1018 buffer_size,
1019 (void **)protocol_buffer);
1020 if (r != EFI_SUCCESS)
1021 return EFI_EXIT(r);
1022 j = 0;
1023 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); ++i) {
1024 if (efiobj->protocols[i].guid) {
1025 (*protocol_buffer)[j] = (void *)
1026 efiobj->protocols[i].guid;
1027 ++j;
1028 }
1029 }
1030 }
1031 break;
1032 }
1033
1034 return EFI_EXIT(EFI_SUCCESS);
bee91169
AG
1035}
1036
1037static efi_status_t EFIAPI efi_locate_handle_buffer(
1038 enum efi_locate_search_type search_type,
1039 efi_guid_t *protocol, void *search_key,
1040 unsigned long *no_handles, efi_handle_t **buffer)
1041{
c2e703f9
HS
1042 efi_status_t r;
1043 unsigned long buffer_size = 0;
1044
bee91169
AG
1045 EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
1046 no_handles, buffer);
c2e703f9
HS
1047
1048 if (!no_handles || !buffer) {
1049 r = EFI_INVALID_PARAMETER;
1050 goto out;
1051 }
1052 *no_handles = 0;
1053 *buffer = NULL;
1054 r = efi_locate_handle(search_type, protocol, search_key, &buffer_size,
1055 *buffer);
1056 if (r != EFI_BUFFER_TOO_SMALL)
1057 goto out;
1058 r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
1059 (void **)buffer);
1060 if (r != EFI_SUCCESS)
1061 goto out;
1062 r = efi_locate_handle(search_type, protocol, search_key, &buffer_size,
1063 *buffer);
1064 if (r == EFI_SUCCESS)
1065 *no_handles = buffer_size / sizeof(void *);
1066out:
1067 return EFI_EXIT(r);
bee91169
AG
1068}
1069
bee91169
AG
1070static efi_status_t EFIAPI efi_locate_protocol(efi_guid_t *protocol,
1071 void *registration,
1072 void **protocol_interface)
1073{
88adae5e 1074 struct list_head *lhandle;
bee91169
AG
1075 int i;
1076
1077 EFI_ENTRY("%p, %p, %p", protocol, registration, protocol_interface);
88adae5e
HS
1078
1079 if (!protocol || !protocol_interface)
1080 return EFI_EXIT(EFI_INVALID_PARAMETER);
1081
ae0bd3a9
HS
1082 EFI_PRINT_GUID("protocol", protocol);
1083
88adae5e
HS
1084 list_for_each(lhandle, &efi_obj_list) {
1085 struct efi_object *efiobj;
1086
1087 efiobj = list_entry(lhandle, struct efi_object, link);
1088 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
1089 struct efi_handler *handler = &efiobj->protocols[i];
1090
1091 if (!handler->guid)
1092 continue;
1093 if (!guidcmp(handler->guid, protocol)) {
1094 *protocol_interface =
1095 handler->protocol_interface;
1096 return EFI_EXIT(EFI_SUCCESS);
1097 }
bee91169
AG
1098 }
1099 }
88adae5e 1100 *protocol_interface = NULL;
bee91169
AG
1101
1102 return EFI_EXIT(EFI_NOT_FOUND);
1103}
1104
1105static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(
1106 void **handle, ...)
1107{
1108 EFI_ENTRY("%p", handle);
58b83586
HS
1109
1110 va_list argptr;
1111 efi_guid_t *protocol;
1112 void *protocol_interface;
1113 efi_status_t r = EFI_SUCCESS;
1114 int i = 0;
1115
1116 if (!handle)
1117 return EFI_EXIT(EFI_INVALID_PARAMETER);
1118
1119 va_start(argptr, handle);
1120 for (;;) {
1121 protocol = va_arg(argptr, efi_guid_t*);
1122 if (!protocol)
1123 break;
1124 protocol_interface = va_arg(argptr, void*);
1125 r = efi_install_protocol_interface(handle, protocol,
1126 EFI_NATIVE_INTERFACE,
1127 protocol_interface);
1128 if (r != EFI_SUCCESS)
1129 break;
1130 i++;
1131 }
1132 va_end(argptr);
1133 if (r == EFI_SUCCESS)
1134 return EFI_EXIT(r);
1135
1136 /* If an error occured undo all changes. */
1137 va_start(argptr, handle);
1138 for (; i; --i) {
1139 protocol = va_arg(argptr, efi_guid_t*);
1140 protocol_interface = va_arg(argptr, void*);
1141 efi_uninstall_protocol_interface(handle, protocol,
1142 protocol_interface);
1143 }
1144 va_end(argptr);
1145
1146 return EFI_EXIT(r);
bee91169
AG
1147}
1148
1149static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces(
1150 void *handle, ...)
1151{
1152 EFI_ENTRY("%p", handle);
1153 return EFI_EXIT(EFI_INVALID_PARAMETER);
1154}
1155
1156static efi_status_t EFIAPI efi_calculate_crc32(void *data,
1157 unsigned long data_size,
1158 uint32_t *crc32_p)
1159{
1160 EFI_ENTRY("%p, %ld", data, data_size);
1161 *crc32_p = crc32(0, data, data_size);
1162 return EFI_EXIT(EFI_SUCCESS);
1163}
1164
1165static void EFIAPI efi_copy_mem(void *destination, void *source,
1166 unsigned long length)
1167{
1168 EFI_ENTRY("%p, %p, %ld", destination, source, length);
1169 memcpy(destination, source, length);
1170}
1171
1172static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value)
1173{
1174 EFI_ENTRY("%p, %ld, 0x%x", buffer, size, value);
1175 memset(buffer, value, size);
1176}
1177
1178static efi_status_t EFIAPI efi_open_protocol(
1179 void *handle, efi_guid_t *protocol,
1180 void **protocol_interface, void *agent_handle,
1181 void *controller_handle, uint32_t attributes)
1182{
1183 struct list_head *lhandle;
1184 int i;
69baec67 1185 efi_status_t r = EFI_INVALID_PARAMETER;
bee91169
AG
1186
1187 EFI_ENTRY("%p, %p, %p, %p, %p, 0x%x", handle, protocol,
1188 protocol_interface, agent_handle, controller_handle,
1189 attributes);
b5349f74 1190
69baec67
HS
1191 if (!handle || !protocol ||
1192 (!protocol_interface && attributes !=
1193 EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {
1194 goto out;
1195 }
1196
ae0bd3a9
HS
1197 EFI_PRINT_GUID("protocol", protocol);
1198
69baec67
HS
1199 switch (attributes) {
1200 case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
1201 case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
1202 case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
1203 break;
1204 case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
1205 if (controller_handle == handle)
1206 goto out;
1207 case EFI_OPEN_PROTOCOL_BY_DRIVER:
1208 case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
1209 if (controller_handle == NULL)
1210 goto out;
1211 case EFI_OPEN_PROTOCOL_EXCLUSIVE:
1212 if (agent_handle == NULL)
1213 goto out;
1214 break;
1215 default:
b5349f74
HS
1216 goto out;
1217 }
1218
bee91169
AG
1219 list_for_each(lhandle, &efi_obj_list) {
1220 struct efi_object *efiobj;
1221 efiobj = list_entry(lhandle, struct efi_object, link);
1222
1223 if (efiobj->handle != handle)
1224 continue;
1225
1226 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
1227 struct efi_handler *handler = &efiobj->protocols[i];
1228 const efi_guid_t *hprotocol = handler->guid;
1229 if (!hprotocol)
4b6ed0d7 1230 continue;
bee91169 1231 if (!guidcmp(hprotocol, protocol)) {
b5349f74
HS
1232 if (attributes !=
1233 EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
1234 *protocol_interface =
1235 handler->protocol_interface;
1236 }
1237 r = EFI_SUCCESS;
bee91169
AG
1238 goto out;
1239 }
1240 }
69baec67 1241 goto unsupported;
bee91169
AG
1242 }
1243
69baec67
HS
1244unsupported:
1245 r = EFI_UNSUPPORTED;
bee91169
AG
1246out:
1247 return EFI_EXIT(r);
1248}
1249
1250static efi_status_t EFIAPI efi_handle_protocol(void *handle,
1251 efi_guid_t *protocol,
1252 void **protocol_interface)
1253{
8e1d329f
HS
1254 return efi_open_protocol(handle, protocol, protocol_interface, NULL,
1255 NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
bee91169
AG
1256}
1257
1258static const struct efi_boot_services efi_boot_services = {
1259 .hdr = {
1260 .headersize = sizeof(struct efi_table_hdr),
1261 },
1262 .raise_tpl = efi_raise_tpl,
1263 .restore_tpl = efi_restore_tpl,
1264 .allocate_pages = efi_allocate_pages_ext,
1265 .free_pages = efi_free_pages_ext,
1266 .get_memory_map = efi_get_memory_map_ext,
ead1274b 1267 .allocate_pool = efi_allocate_pool_ext,
42417bc8 1268 .free_pool = efi_free_pool_ext,
49deb455 1269 .create_event = efi_create_event_ext,
bfc72462 1270 .set_timer = efi_set_timer_ext,
bee91169 1271 .wait_for_event = efi_wait_for_event,
c6841592 1272 .signal_event = efi_signal_event_ext,
bee91169
AG
1273 .close_event = efi_close_event,
1274 .check_event = efi_check_event,
8bee5a3c 1275 .install_protocol_interface = efi_install_protocol_interface_ext,
bee91169 1276 .reinstall_protocol_interface = efi_reinstall_protocol_interface,
3d8e1456 1277 .uninstall_protocol_interface = efi_uninstall_protocol_interface_ext,
bee91169
AG
1278 .handle_protocol = efi_handle_protocol,
1279 .reserved = NULL,
1280 .register_protocol_notify = efi_register_protocol_notify,
26329584 1281 .locate_handle = efi_locate_handle_ext,
bee91169 1282 .locate_device_path = efi_locate_device_path,
488bf12d 1283 .install_configuration_table = efi_install_configuration_table_ext,
bee91169
AG
1284 .load_image = efi_load_image,
1285 .start_image = efi_start_image,
a86aeaf2 1286 .exit = efi_exit,
bee91169
AG
1287 .unload_image = efi_unload_image,
1288 .exit_boot_services = efi_exit_boot_services,
1289 .get_next_monotonic_count = efi_get_next_monotonic_count,
1290 .stall = efi_stall,
1291 .set_watchdog_timer = efi_set_watchdog_timer,
1292 .connect_controller = efi_connect_controller,
1293 .disconnect_controller = efi_disconnect_controller,
1294 .open_protocol = efi_open_protocol,
1295 .close_protocol = efi_close_protocol,
1296 .open_protocol_information = efi_open_protocol_information,
1297 .protocols_per_handle = efi_protocols_per_handle,
1298 .locate_handle_buffer = efi_locate_handle_buffer,
1299 .locate_protocol = efi_locate_protocol,
1300 .install_multiple_protocol_interfaces = efi_install_multiple_protocol_interfaces,
1301 .uninstall_multiple_protocol_interfaces = efi_uninstall_multiple_protocol_interfaces,
1302 .calculate_crc32 = efi_calculate_crc32,
1303 .copy_mem = efi_copy_mem,
1304 .set_mem = efi_set_mem,
1305};
1306
1307
3c63db9c 1308static uint16_t __efi_runtime_data firmware_vendor[] =
bee91169
AG
1309 { 'D','a','s',' ','U','-','b','o','o','t',0 };
1310
3c63db9c 1311struct efi_system_table __efi_runtime_data systab = {
bee91169
AG
1312 .hdr = {
1313 .signature = EFI_SYSTEM_TABLE_SIGNATURE,
1314 .revision = 0x20005, /* 2.5 */
1315 .headersize = sizeof(struct efi_table_hdr),
1316 },
1317 .fw_vendor = (long)firmware_vendor,
1318 .con_in = (void*)&efi_con_in,
1319 .con_out = (void*)&efi_con_out,
1320 .std_err = (void*)&efi_con_out,
1321 .runtime = (void*)&efi_runtime_services,
1322 .boottime = (void*)&efi_boot_services,
1323 .nr_tables = 0,
1324 .tables = (void*)efi_conf_table,
1325};