blob: f04d9eb3419861926384006ed842638e7cf155fe [file] [log] [blame]
Alexander Grafc15d9212016-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 Grafc15d9212016-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 Graf393dd912016-10-14 13:45:30 +020040static struct efi_configuration_table __efi_runtime_data efi_conf_table[2];
Alexander Grafc15d9212016-03-04 01:09:59 +010041
Simon Glasscdfe6962016-09-25 15:27:35 -060042#ifdef CONFIG_ARM
Alexander Grafc15d9212016-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 Glasscdfe6962016-09-25 15:27:35 -060050#endif
Alexander Grafc15d9212016-03-04 01:09:59 +010051
52/* Called from do_bootefi_exec() */
53void efi_save_gd(void)
54{
Simon Glasscdfe6962016-09-25 15:27:35 -060055#ifdef CONFIG_ARM
Alexander Grafc15d9212016-03-04 01:09:59 +010056 efi_gd = gd;
Simon Glasscdfe6962016-09-25 15:27:35 -060057#endif
Alexander Grafc15d9212016-03-04 01:09:59 +010058}
59
60/* Called on every callback entry */
61void efi_restore_gd(void)
62{
Simon Glasscdfe6962016-09-25 15:27:35 -060063#ifdef CONFIG_ARM
Alexander Grafc15d9212016-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 Glasscdfe6962016-09-25 15:27:35 -060071#endif
Alexander Grafc15d9212016-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 Glasscdfe6962016-09-25 15:27:35 -060077#ifdef CONFIG_ARM
Alexander Grafc15d9212016-03-04 01:09:59 +010078 gd = app_gd;
Simon Glasscdfe6962016-09-25 15:27:35 -060079#endif
80
Alexander Grafc15d9212016-03-04 01:09:59 +010081 return ret;
82}
83
xypron.glpk@gmx.de30708232017-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 Grafc15d9212016-03-04 01:09:59 +010096static efi_status_t efi_unsupported(const char *funcname)
97{
Alexander Graf62a67482016-06-02 11:38:27 +020098 debug("EFI: App called into unimplemented function %s\n", funcname);
Alexander Grafc15d9212016-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.de48df2092017-07-18 20:17:19 +0200107static unsigned long EFIAPI efi_raise_tpl(UINTN new_tpl)
Alexander Grafc15d9212016-03-04 01:09:59 +0100108{
xypron.glpk@gmx.de48df2092017-07-18 20:17:19 +0200109 EFI_ENTRY("0x%zx", new_tpl);
Alexander Grafc15d9212016-03-04 01:09:59 +0100110 return EFI_EXIT(0);
111}
112
xypron.glpk@gmx.de48df2092017-07-18 20:17:19 +0200113static void EFIAPI efi_restore_tpl(UINTN old_tpl)
Alexander Grafc15d9212016-03-04 01:09:59 +0100114{
xypron.glpk@gmx.de48df2092017-07-18 20:17:19 +0200115 EFI_ENTRY("0x%zx", old_tpl);
Alexander Grafc15d9212016-03-04 01:09:59 +0100116 EFI_EXIT(efi_unsupported(__func__));
117}
118
Masahiro Yamadab2a05c12017-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 Grafc15d9212016-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 Yamadab2a05c12017-06-22 17:49:03 +0900130static efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory,
131 unsigned long pages)
Alexander Grafc15d9212016-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 Yamadab2a05c12017-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 Grafc15d9212016-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üns5a09aef2016-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 Grafc15d9212016-03-04 01:09:59 +0100159{
Alexander Graf1c34fa82016-03-24 01:37:37 +0100160 efi_status_t r;
161
162 EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer);
Stefan Brüns5a09aef2016-10-09 22:17:18 +0200163 r = efi_allocate_pool(pool_type, size, buffer);
Alexander Graf1c34fa82016-03-24 01:37:37 +0100164 return EFI_EXIT(r);
Alexander Grafc15d9212016-03-04 01:09:59 +0100165}
166
Stefan Brüns67b67d92016-10-09 22:17:26 +0200167static efi_status_t EFIAPI efi_free_pool_ext(void *buffer)
Alexander Grafc15d9212016-03-04 01:09:59 +0100168{
Alexander Graf1c34fa82016-03-24 01:37:37 +0100169 efi_status_t r;
170
171 EFI_ENTRY("%p", buffer);
Stefan Brüns67b67d92016-10-09 22:17:26 +0200172 r = efi_free_pool(buffer);
Alexander Graf1c34fa82016-03-24 01:37:37 +0100173 return EFI_EXIT(r);
Alexander Grafc15d9212016-03-04 01:09:59 +0100174}
175
176/*
xypron.glpk@gmx.de30708232017-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 Grafc15d9212016-03-04 01:09:59 +0100179 */
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200180static struct efi_event efi_events[16];
Alexander Grafc15d9212016-03-04 01:09:59 +0100181
182static efi_status_t EFIAPI efi_create_event(
xypron.glpk@gmx.de48df2092017-07-18 20:17:19 +0200183 enum efi_event_type type, UINTN notify_tpl,
xypron.glpk@gmx.decdbf3ac2017-07-18 20:17:17 +0200184 void (EFIAPI *notify_function) (
185 struct efi_event *event,
186 void *context),
187 void *notify_context, struct efi_event **event)
Alexander Grafc15d9212016-03-04 01:09:59 +0100188{
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200189 int i;
190
xypron.glpk@gmx.de48df2092017-07-18 20:17:19 +0200191 EFI_ENTRY("%d, 0x%zx, %p, %p", type, notify_tpl, notify_function,
Alexander Grafc15d9212016-03-04 01:09:59 +0100192 notify_context);
Jonathan Gray7758b212017-03-12 19:26:07 +1100193 if (event == NULL)
194 return EFI_EXIT(EFI_INVALID_PARAMETER);
195
196 if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT))
197 return EFI_EXIT(EFI_INVALID_PARAMETER);
198
199 if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) &&
200 notify_function == NULL)
201 return EFI_EXIT(EFI_INVALID_PARAMETER);
202
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200203 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
204 if (efi_events[i].type)
205 continue;
206 efi_events[i].type = type;
207 efi_events[i].notify_tpl = notify_tpl;
208 efi_events[i].notify_function = notify_function;
209 efi_events[i].notify_context = notify_context;
210 /* Disable timers on bootup */
211 efi_events[i].trigger_next = -1ULL;
212 efi_events[i].signaled = 0;
213 *event = &efi_events[i];
214 return EFI_EXIT(EFI_SUCCESS);
215 }
216 return EFI_EXIT(EFI_OUT_OF_RESOURCES);
Alexander Grafc15d9212016-03-04 01:09:59 +0100217}
218
219/*
220 * Our timers have to work without interrupts, so we check whenever keyboard
221 * input or disk accesses happen if enough time elapsed for it to fire.
222 */
223void efi_timer_check(void)
224{
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200225 int i;
Alexander Grafc15d9212016-03-04 01:09:59 +0100226 u64 now = timer_get_us();
227
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200228 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
229 if (!efi_events[i].type ||
230 !(efi_events[i].type & EVT_TIMER) ||
231 efi_events[i].trigger_type == EFI_TIMER_STOP ||
232 now < efi_events[i].trigger_next)
233 continue;
234 if (efi_events[i].trigger_type == EFI_TIMER_PERIODIC) {
235 efi_events[i].trigger_next +=
236 efi_events[i].trigger_time / 10;
237 efi_events[i].signaled = 0;
238 }
239 efi_signal_event(&efi_events[i]);
Alexander Grafc15d9212016-03-04 01:09:59 +0100240 }
Alexander Grafc15d9212016-03-04 01:09:59 +0100241 WATCHDOG_RESET();
242}
243
xypron.glpk@gmx.decdbf3ac2017-07-18 20:17:17 +0200244static efi_status_t EFIAPI efi_set_timer(struct efi_event *event, int type,
Alexander Grafc15d9212016-03-04 01:09:59 +0100245 uint64_t trigger_time)
246{
247 /* We don't have 64bit division available everywhere, so limit timer
248 * distances to 32bit bits. */
249 u32 trigger32 = trigger_time;
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200250 int i;
Alexander Grafc15d9212016-03-04 01:09:59 +0100251
252 EFI_ENTRY("%p, %d, %"PRIx64, event, type, trigger_time);
253
254 if (trigger32 < trigger_time) {
255 printf("WARNING: Truncating timer from %"PRIx64" to %x\n",
256 trigger_time, trigger32);
257 }
258
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200259 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
260 if (event != &efi_events[i])
261 continue;
Alexander Grafc15d9212016-03-04 01:09:59 +0100262
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200263 if (!(event->type & EVT_TIMER))
264 break;
265 switch (type) {
266 case EFI_TIMER_STOP:
267 event->trigger_next = -1ULL;
268 break;
269 case EFI_TIMER_PERIODIC:
270 case EFI_TIMER_RELATIVE:
271 event->trigger_next =
272 timer_get_us() + (trigger32 / 10);
273 break;
274 default:
275 return EFI_EXIT(EFI_INVALID_PARAMETER);
276 }
277 event->trigger_type = type;
278 event->trigger_time = trigger_time;
279 return EFI_EXIT(EFI_SUCCESS);
Alexander Grafc15d9212016-03-04 01:09:59 +0100280 }
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200281 return EFI_EXIT(EFI_INVALID_PARAMETER);
Alexander Grafc15d9212016-03-04 01:09:59 +0100282}
283
284static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,
xypron.glpk@gmx.decdbf3ac2017-07-18 20:17:17 +0200285 struct efi_event **event,
286 unsigned long *index)
Alexander Grafc15d9212016-03-04 01:09:59 +0100287{
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200288 int i, j;
Alexander Grafc15d9212016-03-04 01:09:59 +0100289
290 EFI_ENTRY("%ld, %p, %p", num_events, event, index);
291
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200292 /* Check parameters */
293 if (!num_events || !event)
294 return EFI_EXIT(EFI_INVALID_PARAMETER);
295 for (i = 0; i < num_events; ++i) {
296 for (j = 0; j < ARRAY_SIZE(efi_events); ++j) {
297 if (event[i] == &efi_events[j])
298 goto known_event;
299 }
300 return EFI_EXIT(EFI_INVALID_PARAMETER);
301known_event:
302 if (!event[i]->type || event[i]->type & EVT_NOTIFY_SIGNAL)
303 return EFI_EXIT(EFI_INVALID_PARAMETER);
304 }
305
306 /* Wait for signal */
307 for (;;) {
308 for (i = 0; i < num_events; ++i) {
309 if (event[i]->signaled)
310 goto out;
311 }
312 /* Allow events to occur. */
313 efi_timer_check();
314 }
315
316out:
317 /*
318 * Reset the signal which is passed to the caller to allow periodic
319 * events to occur.
320 */
321 event[i]->signaled = 0;
322 if (index)
323 *index = i;
Alexander Grafc15d9212016-03-04 01:09:59 +0100324
325 return EFI_EXIT(EFI_SUCCESS);
326}
327
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200328static efi_status_t EFIAPI efi_signal_event_ext(struct efi_event *event)
Alexander Grafc15d9212016-03-04 01:09:59 +0100329{
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200330 int i;
331
Alexander Grafc15d9212016-03-04 01:09:59 +0100332 EFI_ENTRY("%p", event);
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200333 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
334 if (event != &efi_events[i])
335 continue;
336 efi_signal_event(event);
337 break;
338 }
Alexander Grafc15d9212016-03-04 01:09:59 +0100339 return EFI_EXIT(EFI_SUCCESS);
340}
341
xypron.glpk@gmx.decdbf3ac2017-07-18 20:17:17 +0200342static efi_status_t EFIAPI efi_close_event(struct efi_event *event)
Alexander Grafc15d9212016-03-04 01:09:59 +0100343{
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200344 int i;
345
Alexander Grafc15d9212016-03-04 01:09:59 +0100346 EFI_ENTRY("%p", event);
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200347 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
348 if (event == &efi_events[i]) {
349 event->type = 0;
350 event->trigger_next = -1ULL;
351 event->signaled = 0;
352 return EFI_EXIT(EFI_SUCCESS);
353 }
354 }
355 return EFI_EXIT(EFI_INVALID_PARAMETER);
Alexander Grafc15d9212016-03-04 01:09:59 +0100356}
357
xypron.glpk@gmx.decdbf3ac2017-07-18 20:17:17 +0200358static efi_status_t EFIAPI efi_check_event(struct efi_event *event)
Alexander Grafc15d9212016-03-04 01:09:59 +0100359{
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200360 int i;
361
Alexander Grafc15d9212016-03-04 01:09:59 +0100362 EFI_ENTRY("%p", event);
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +0200363 efi_timer_check();
364 for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
365 if (event != &efi_events[i])
366 continue;
367 if (!event->type || event->type & EVT_NOTIFY_SIGNAL)
368 break;
369 if (event->signaled)
370 return EFI_EXIT(EFI_SUCCESS);
371 return EFI_EXIT(EFI_NOT_READY);
372 }
373 return EFI_EXIT(EFI_INVALID_PARAMETER);
Alexander Grafc15d9212016-03-04 01:09:59 +0100374}
375
376static efi_status_t EFIAPI efi_install_protocol_interface(void **handle,
377 efi_guid_t *protocol, int protocol_interface_type,
378 void *protocol_interface)
379{
xypron.glpk@gmx.de0581fa82017-07-11 22:06:16 +0200380 struct list_head *lhandle;
381 int i;
382 efi_status_t r;
383
xypron.glpk@gmx.de0581fa82017-07-11 22:06:16 +0200384 if (!handle || !protocol ||
385 protocol_interface_type != EFI_NATIVE_INTERFACE) {
386 r = EFI_INVALID_PARAMETER;
387 goto out;
388 }
389
390 /* Create new handle if requested. */
391 if (!*handle) {
392 r = EFI_OUT_OF_RESOURCES;
393 goto out;
394 }
395 /* Find object. */
396 list_for_each(lhandle, &efi_obj_list) {
397 struct efi_object *efiobj;
398 efiobj = list_entry(lhandle, struct efi_object, link);
399
400 if (efiobj->handle != *handle)
401 continue;
402 /* Check if protocol is already installed on the handle. */
403 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
404 struct efi_handler *handler = &efiobj->protocols[i];
405
406 if (!handler->guid)
407 continue;
408 if (!guidcmp(handler->guid, protocol)) {
409 r = EFI_INVALID_PARAMETER;
410 goto out;
411 }
412 }
413 /* Install protocol in first empty slot. */
414 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
415 struct efi_handler *handler = &efiobj->protocols[i];
416
417 if (handler->guid)
418 continue;
419
420 handler->guid = protocol;
421 handler->protocol_interface = protocol_interface;
422 r = EFI_SUCCESS;
423 goto out;
424 }
425 r = EFI_OUT_OF_RESOURCES;
426 goto out;
427 }
428 r = EFI_INVALID_PARAMETER;
429out:
xypron.glpk@gmx.de8b7b5df2017-07-11 22:06:18 +0200430 return r;
431}
432
433static efi_status_t EFIAPI efi_install_protocol_interface_ext(void **handle,
434 efi_guid_t *protocol, int protocol_interface_type,
435 void *protocol_interface)
436{
437 EFI_ENTRY("%p, %p, %d, %p", handle, protocol, protocol_interface_type,
438 protocol_interface);
439
440 return EFI_EXIT(efi_install_protocol_interface(handle, protocol,
441 protocol_interface_type,
442 protocol_interface));
Alexander Grafc15d9212016-03-04 01:09:59 +0100443}
xypron.glpk@gmx.de0581fa82017-07-11 22:06:16 +0200444
Alexander Grafc15d9212016-03-04 01:09:59 +0100445static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle,
446 efi_guid_t *protocol, void *old_interface,
447 void *new_interface)
448{
449 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, old_interface,
450 new_interface);
451 return EFI_EXIT(EFI_ACCESS_DENIED);
452}
453
454static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle,
455 efi_guid_t *protocol, void *protocol_interface)
456{
xypron.glpk@gmx.de2cfad482017-07-11 22:06:17 +0200457 struct list_head *lhandle;
458 int i;
459 efi_status_t r = EFI_NOT_FOUND;
460
xypron.glpk@gmx.de2cfad482017-07-11 22:06:17 +0200461 if (!handle || !protocol) {
462 r = EFI_INVALID_PARAMETER;
463 goto out;
464 }
465
466 list_for_each(lhandle, &efi_obj_list) {
467 struct efi_object *efiobj;
468 efiobj = list_entry(lhandle, struct efi_object, link);
469
470 if (efiobj->handle != handle)
471 continue;
472
473 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
474 struct efi_handler *handler = &efiobj->protocols[i];
475 const efi_guid_t *hprotocol = handler->guid;
476
477 if (!hprotocol)
478 continue;
479 if (!guidcmp(hprotocol, protocol)) {
480 if (handler->protocol_interface) {
481 r = EFI_ACCESS_DENIED;
482 } else {
483 handler->guid = 0;
484 r = EFI_SUCCESS;
485 }
486 goto out;
487 }
488 }
489 }
490
491out:
xypron.glpk@gmx.dea453e462017-07-11 22:06:19 +0200492 return r;
493}
494
495static efi_status_t EFIAPI efi_uninstall_protocol_interface_ext(void *handle,
496 efi_guid_t *protocol, void *protocol_interface)
497{
498 EFI_ENTRY("%p, %p, %p", handle, protocol, protocol_interface);
499
500 return EFI_EXIT(efi_uninstall_protocol_interface(handle, protocol,
501 protocol_interface));
Alexander Grafc15d9212016-03-04 01:09:59 +0100502}
503
504static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol,
xypron.glpk@gmx.decdbf3ac2017-07-18 20:17:17 +0200505 struct efi_event *event,
Alexander Grafc15d9212016-03-04 01:09:59 +0100506 void **registration)
507{
508 EFI_ENTRY("%p, %p, %p", protocol, event, registration);
509 return EFI_EXIT(EFI_OUT_OF_RESOURCES);
510}
511
512static int efi_search(enum efi_locate_search_type search_type,
513 efi_guid_t *protocol, void *search_key,
514 struct efi_object *efiobj)
515{
516 int i;
517
518 switch (search_type) {
519 case all_handles:
520 return 0;
521 case by_register_notify:
522 return -1;
523 case by_protocol:
524 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
525 const efi_guid_t *guid = efiobj->protocols[i].guid;
526 if (guid && !guidcmp(guid, protocol))
527 return 0;
528 }
529 return -1;
530 }
531
532 return -1;
533}
534
535static efi_status_t EFIAPI efi_locate_handle(
536 enum efi_locate_search_type search_type,
537 efi_guid_t *protocol, void *search_key,
538 unsigned long *buffer_size, efi_handle_t *buffer)
539{
540 struct list_head *lhandle;
541 unsigned long size = 0;
542
Alexander Grafc15d9212016-03-04 01:09:59 +0100543 /* Count how much space we need */
544 list_for_each(lhandle, &efi_obj_list) {
545 struct efi_object *efiobj;
546 efiobj = list_entry(lhandle, struct efi_object, link);
547 if (!efi_search(search_type, protocol, search_key, efiobj)) {
548 size += sizeof(void*);
549 }
550 }
551
552 if (*buffer_size < size) {
553 *buffer_size = size;
xypron.glpk@gmx.de69f94032017-07-11 22:06:21 +0200554 return EFI_BUFFER_TOO_SMALL;
Alexander Grafc15d9212016-03-04 01:09:59 +0100555 }
556
557 /* Then fill the array */
558 list_for_each(lhandle, &efi_obj_list) {
559 struct efi_object *efiobj;
560 efiobj = list_entry(lhandle, struct efi_object, link);
561 if (!efi_search(search_type, protocol, search_key, efiobj)) {
562 *(buffer++) = efiobj->handle;
563 }
564 }
565
566 *buffer_size = size;
xypron.glpk@gmx.de69f94032017-07-11 22:06:21 +0200567 return EFI_SUCCESS;
568}
569
570static efi_status_t EFIAPI efi_locate_handle_ext(
571 enum efi_locate_search_type search_type,
572 efi_guid_t *protocol, void *search_key,
573 unsigned long *buffer_size, efi_handle_t *buffer)
574{
575 EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
576 buffer_size, buffer);
577
578 return EFI_EXIT(efi_locate_handle(search_type, protocol, search_key,
579 buffer_size, buffer));
Alexander Grafc15d9212016-03-04 01:09:59 +0100580}
581
582static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol,
583 struct efi_device_path **device_path,
584 efi_handle_t *device)
585{
586 EFI_ENTRY("%p, %p, %p", protocol, device_path, device);
587 return EFI_EXIT(EFI_NOT_FOUND);
588}
589
Alexander Grafc5c11632016-08-19 01:23:24 +0200590efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table)
Alexander Grafc15d9212016-03-04 01:09:59 +0100591{
592 int i;
593
Alexander Grafc15d9212016-03-04 01:09:59 +0100594 /* Check for guid override */
595 for (i = 0; i < systab.nr_tables; i++) {
596 if (!guidcmp(guid, &efi_conf_table[i].guid)) {
597 efi_conf_table[i].table = table;
Alexander Grafc5c11632016-08-19 01:23:24 +0200598 return EFI_SUCCESS;
Alexander Grafc15d9212016-03-04 01:09:59 +0100599 }
600 }
601
602 /* No override, check for overflow */
603 if (i >= ARRAY_SIZE(efi_conf_table))
Alexander Grafc5c11632016-08-19 01:23:24 +0200604 return EFI_OUT_OF_RESOURCES;
Alexander Grafc15d9212016-03-04 01:09:59 +0100605
606 /* Add a new entry */
607 memcpy(&efi_conf_table[i].guid, guid, sizeof(*guid));
608 efi_conf_table[i].table = table;
Alexander Graf9982e672016-08-19 01:23:30 +0200609 systab.nr_tables = i + 1;
Alexander Grafc15d9212016-03-04 01:09:59 +0100610
Alexander Grafc5c11632016-08-19 01:23:24 +0200611 return EFI_SUCCESS;
Alexander Grafc15d9212016-03-04 01:09:59 +0100612}
613
Alexander Grafc5c11632016-08-19 01:23:24 +0200614static efi_status_t EFIAPI efi_install_configuration_table_ext(efi_guid_t *guid,
615 void *table)
616{
617 EFI_ENTRY("%p, %p", guid, table);
618 return EFI_EXIT(efi_install_configuration_table(guid, table));
619}
620
Alexander Grafc15d9212016-03-04 01:09:59 +0100621static efi_status_t EFIAPI efi_load_image(bool boot_policy,
622 efi_handle_t parent_image,
623 struct efi_device_path *file_path,
624 void *source_buffer,
625 unsigned long source_size,
626 efi_handle_t *image_handle)
627{
628 static struct efi_object loaded_image_info_obj = {
629 .protocols = {
630 {
631 .guid = &efi_guid_loaded_image,
Alexander Grafc15d9212016-03-04 01:09:59 +0100632 },
633 },
634 };
635 struct efi_loaded_image *info;
636 struct efi_object *obj;
637
638 EFI_ENTRY("%d, %p, %p, %p, %ld, %p", boot_policy, parent_image,
639 file_path, source_buffer, source_size, image_handle);
640 info = malloc(sizeof(*info));
xypron.glpk@gmx.dec35c9242017-07-11 22:06:14 +0200641 loaded_image_info_obj.protocols[0].protocol_interface = info;
Alexander Grafc15d9212016-03-04 01:09:59 +0100642 obj = malloc(sizeof(loaded_image_info_obj));
643 memset(info, 0, sizeof(*info));
644 memcpy(obj, &loaded_image_info_obj, sizeof(loaded_image_info_obj));
645 obj->handle = info;
646 info->file_path = file_path;
647 info->reserved = efi_load_pe(source_buffer, info);
648 if (!info->reserved) {
649 free(info);
650 free(obj);
651 return EFI_EXIT(EFI_UNSUPPORTED);
652 }
653
654 *image_handle = info;
655 list_add_tail(&obj->link, &efi_obj_list);
656
657 return EFI_EXIT(EFI_SUCCESS);
658}
659
660static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
661 unsigned long *exit_data_size,
662 s16 **exit_data)
663{
664 ulong (*entry)(void *image_handle, struct efi_system_table *st);
665 struct efi_loaded_image *info = image_handle;
666
667 EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
668 entry = info->reserved;
669
670 efi_is_direct_boot = false;
671
672 /* call the image! */
Alexander Graf988c0662016-05-20 23:28:23 +0200673 if (setjmp(&info->exit_jmp)) {
674 /* We returned from the child image */
675 return EFI_EXIT(info->exit_status);
676 }
677
Alexander Grafc15d9212016-03-04 01:09:59 +0100678 entry(image_handle, &systab);
679
680 /* Should usually never get here */
681 return EFI_EXIT(EFI_SUCCESS);
682}
683
Alexander Graf988c0662016-05-20 23:28:23 +0200684static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
685 efi_status_t exit_status, unsigned long exit_data_size,
686 int16_t *exit_data)
Alexander Grafc15d9212016-03-04 01:09:59 +0100687{
Alexander Graf988c0662016-05-20 23:28:23 +0200688 struct efi_loaded_image *loaded_image_info = (void*)image_handle;
689
Alexander Grafc15d9212016-03-04 01:09:59 +0100690 EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
691 exit_data_size, exit_data);
Alexander Graf988c0662016-05-20 23:28:23 +0200692
693 loaded_image_info->exit_status = exit_status;
Alexander Graf9d006b72016-09-27 09:30:32 +0200694 longjmp(&loaded_image_info->exit_jmp, 1);
Alexander Graf988c0662016-05-20 23:28:23 +0200695
696 panic("EFI application exited");
Alexander Grafc15d9212016-03-04 01:09:59 +0100697}
698
699static struct efi_object *efi_search_obj(void *handle)
700{
701 struct list_head *lhandle;
702
703 list_for_each(lhandle, &efi_obj_list) {
704 struct efi_object *efiobj;
705 efiobj = list_entry(lhandle, struct efi_object, link);
706 if (efiobj->handle == handle)
707 return efiobj;
708 }
709
710 return NULL;
711}
712
713static efi_status_t EFIAPI efi_unload_image(void *image_handle)
714{
715 struct efi_object *efiobj;
716
717 EFI_ENTRY("%p", image_handle);
718 efiobj = efi_search_obj(image_handle);
719 if (efiobj)
720 list_del(&efiobj->link);
721
722 return EFI_EXIT(EFI_SUCCESS);
723}
724
725static void efi_exit_caches(void)
726{
727#if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
728 /*
729 * Grub on 32bit ARM needs to have caches disabled before jumping into
730 * a zImage, but does not know of all cache layers. Give it a hand.
731 */
732 if (efi_is_direct_boot)
733 cleanup_before_linux();
734#endif
735}
736
737static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle,
738 unsigned long map_key)
739{
740 EFI_ENTRY("%p, %ld", image_handle, map_key);
741
Alexander Graf2ebeb442016-11-17 01:02:57 +0100742 board_quiesce_devices();
743
Alexander Grafc15d9212016-03-04 01:09:59 +0100744 /* Fix up caches for EFI payloads if necessary */
745 efi_exit_caches();
746
747 /* This stops all lingering devices */
748 bootm_disable_interrupts();
749
750 /* Give the payload some time to boot */
751 WATCHDOG_RESET();
752
753 return EFI_EXIT(EFI_SUCCESS);
754}
755
756static efi_status_t EFIAPI efi_get_next_monotonic_count(uint64_t *count)
757{
758 static uint64_t mono = 0;
759 EFI_ENTRY("%p", count);
760 *count = mono++;
761 return EFI_EXIT(EFI_SUCCESS);
762}
763
764static efi_status_t EFIAPI efi_stall(unsigned long microseconds)
765{
766 EFI_ENTRY("%ld", microseconds);
767 udelay(microseconds);
768 return EFI_EXIT(EFI_SUCCESS);
769}
770
771static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout,
772 uint64_t watchdog_code,
773 unsigned long data_size,
774 uint16_t *watchdog_data)
775{
776 EFI_ENTRY("%ld, 0x%"PRIx64", %ld, %p", timeout, watchdog_code,
777 data_size, watchdog_data);
778 return EFI_EXIT(efi_unsupported(__func__));
779}
780
781static efi_status_t EFIAPI efi_connect_controller(
782 efi_handle_t controller_handle,
783 efi_handle_t *driver_image_handle,
784 struct efi_device_path *remain_device_path,
785 bool recursive)
786{
787 EFI_ENTRY("%p, %p, %p, %d", controller_handle, driver_image_handle,
788 remain_device_path, recursive);
789 return EFI_EXIT(EFI_NOT_FOUND);
790}
791
792static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle,
793 void *driver_image_handle,
794 void *child_handle)
795{
796 EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle,
797 child_handle);
798 return EFI_EXIT(EFI_INVALID_PARAMETER);
799}
800
801static efi_status_t EFIAPI efi_close_protocol(void *handle,
802 efi_guid_t *protocol,
803 void *agent_handle,
804 void *controller_handle)
805{
806 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, agent_handle,
807 controller_handle);
808 return EFI_EXIT(EFI_NOT_FOUND);
809}
810
811static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,
812 efi_guid_t *protocol,
813 struct efi_open_protocol_info_entry **entry_buffer,
814 unsigned long *entry_count)
815{
816 EFI_ENTRY("%p, %p, %p, %p", handle, protocol, entry_buffer,
817 entry_count);
818 return EFI_EXIT(EFI_NOT_FOUND);
819}
820
821static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,
822 efi_guid_t ***protocol_buffer,
823 unsigned long *protocol_buffer_count)
824{
825 EFI_ENTRY("%p, %p, %p", handle, protocol_buffer,
826 protocol_buffer_count);
827 return EFI_EXIT(EFI_OUT_OF_RESOURCES);
828}
829
830static efi_status_t EFIAPI efi_locate_handle_buffer(
831 enum efi_locate_search_type search_type,
832 efi_guid_t *protocol, void *search_key,
833 unsigned long *no_handles, efi_handle_t **buffer)
834{
xypron.glpk@gmx.de550a68a2017-07-11 22:06:22 +0200835 efi_status_t r;
836 unsigned long buffer_size = 0;
837
Alexander Grafc15d9212016-03-04 01:09:59 +0100838 EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
839 no_handles, buffer);
xypron.glpk@gmx.de550a68a2017-07-11 22:06:22 +0200840
841 if (!no_handles || !buffer) {
842 r = EFI_INVALID_PARAMETER;
843 goto out;
844 }
845 *no_handles = 0;
846 *buffer = NULL;
847 r = efi_locate_handle(search_type, protocol, search_key, &buffer_size,
848 *buffer);
849 if (r != EFI_BUFFER_TOO_SMALL)
850 goto out;
851 r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
852 (void **)buffer);
853 if (r != EFI_SUCCESS)
854 goto out;
855 r = efi_locate_handle(search_type, protocol, search_key, &buffer_size,
856 *buffer);
857 if (r == EFI_SUCCESS)
858 *no_handles = buffer_size / sizeof(void *);
859out:
860 return EFI_EXIT(r);
Alexander Grafc15d9212016-03-04 01:09:59 +0100861}
862
Alexander Grafc15d9212016-03-04 01:09:59 +0100863static efi_status_t EFIAPI efi_locate_protocol(efi_guid_t *protocol,
864 void *registration,
865 void **protocol_interface)
866{
xypron.glpk@gmx.de4534ad62017-07-11 22:06:24 +0200867 struct list_head *lhandle;
Alexander Grafc15d9212016-03-04 01:09:59 +0100868 int i;
869
870 EFI_ENTRY("%p, %p, %p", protocol, registration, protocol_interface);
xypron.glpk@gmx.de4534ad62017-07-11 22:06:24 +0200871
872 if (!protocol || !protocol_interface)
873 return EFI_EXIT(EFI_INVALID_PARAMETER);
874
875 list_for_each(lhandle, &efi_obj_list) {
876 struct efi_object *efiobj;
877
878 efiobj = list_entry(lhandle, struct efi_object, link);
879 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
880 struct efi_handler *handler = &efiobj->protocols[i];
881
882 if (!handler->guid)
883 continue;
884 if (!guidcmp(handler->guid, protocol)) {
885 *protocol_interface =
886 handler->protocol_interface;
887 return EFI_EXIT(EFI_SUCCESS);
888 }
Alexander Grafc15d9212016-03-04 01:09:59 +0100889 }
890 }
xypron.glpk@gmx.de4534ad62017-07-11 22:06:24 +0200891 *protocol_interface = NULL;
Alexander Grafc15d9212016-03-04 01:09:59 +0100892
893 return EFI_EXIT(EFI_NOT_FOUND);
894}
895
896static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(
897 void **handle, ...)
898{
899 EFI_ENTRY("%p", handle);
xypron.glpk@gmx.de83eebc72017-07-11 22:06:20 +0200900
901 va_list argptr;
902 efi_guid_t *protocol;
903 void *protocol_interface;
904 efi_status_t r = EFI_SUCCESS;
905 int i = 0;
906
907 if (!handle)
908 return EFI_EXIT(EFI_INVALID_PARAMETER);
909
910 va_start(argptr, handle);
911 for (;;) {
912 protocol = va_arg(argptr, efi_guid_t*);
913 if (!protocol)
914 break;
915 protocol_interface = va_arg(argptr, void*);
916 r = efi_install_protocol_interface(handle, protocol,
917 EFI_NATIVE_INTERFACE,
918 protocol_interface);
919 if (r != EFI_SUCCESS)
920 break;
921 i++;
922 }
923 va_end(argptr);
924 if (r == EFI_SUCCESS)
925 return EFI_EXIT(r);
926
927 /* If an error occured undo all changes. */
928 va_start(argptr, handle);
929 for (; i; --i) {
930 protocol = va_arg(argptr, efi_guid_t*);
931 protocol_interface = va_arg(argptr, void*);
932 efi_uninstall_protocol_interface(handle, protocol,
933 protocol_interface);
934 }
935 va_end(argptr);
936
937 return EFI_EXIT(r);
Alexander Grafc15d9212016-03-04 01:09:59 +0100938}
939
940static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces(
941 void *handle, ...)
942{
943 EFI_ENTRY("%p", handle);
944 return EFI_EXIT(EFI_INVALID_PARAMETER);
945}
946
947static efi_status_t EFIAPI efi_calculate_crc32(void *data,
948 unsigned long data_size,
949 uint32_t *crc32_p)
950{
951 EFI_ENTRY("%p, %ld", data, data_size);
952 *crc32_p = crc32(0, data, data_size);
953 return EFI_EXIT(EFI_SUCCESS);
954}
955
956static void EFIAPI efi_copy_mem(void *destination, void *source,
957 unsigned long length)
958{
959 EFI_ENTRY("%p, %p, %ld", destination, source, length);
960 memcpy(destination, source, length);
961}
962
963static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value)
964{
965 EFI_ENTRY("%p, %ld, 0x%x", buffer, size, value);
966 memset(buffer, value, size);
967}
968
969static efi_status_t EFIAPI efi_open_protocol(
970 void *handle, efi_guid_t *protocol,
971 void **protocol_interface, void *agent_handle,
972 void *controller_handle, uint32_t attributes)
973{
974 struct list_head *lhandle;
975 int i;
xypron.glpk@gmx.def097c842017-07-11 22:06:15 +0200976 efi_status_t r = EFI_INVALID_PARAMETER;
Alexander Grafc15d9212016-03-04 01:09:59 +0100977
978 EFI_ENTRY("%p, %p, %p, %p, %p, 0x%x", handle, protocol,
979 protocol_interface, agent_handle, controller_handle,
980 attributes);
xypron.glpk@gmx.dec35c9242017-07-11 22:06:14 +0200981
xypron.glpk@gmx.def097c842017-07-11 22:06:15 +0200982 if (!handle || !protocol ||
983 (!protocol_interface && attributes !=
984 EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {
xypron.glpk@gmx.dec35c9242017-07-11 22:06:14 +0200985 goto out;
986 }
987
xypron.glpk@gmx.def097c842017-07-11 22:06:15 +0200988 switch (attributes) {
989 case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
990 case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
991 case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
992 break;
993 case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
994 if (controller_handle == handle)
995 goto out;
996 case EFI_OPEN_PROTOCOL_BY_DRIVER:
997 case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
998 if (controller_handle == NULL)
999 goto out;
1000 case EFI_OPEN_PROTOCOL_EXCLUSIVE:
1001 if (agent_handle == NULL)
1002 goto out;
1003 break;
1004 default:
1005 goto out;
1006 }
1007
Alexander Grafc15d9212016-03-04 01:09:59 +01001008 list_for_each(lhandle, &efi_obj_list) {
1009 struct efi_object *efiobj;
1010 efiobj = list_entry(lhandle, struct efi_object, link);
1011
1012 if (efiobj->handle != handle)
1013 continue;
1014
1015 for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
1016 struct efi_handler *handler = &efiobj->protocols[i];
1017 const efi_guid_t *hprotocol = handler->guid;
1018 if (!hprotocol)
xypron.glpk@gmx.de2cfad482017-07-11 22:06:17 +02001019 continue;
Alexander Grafc15d9212016-03-04 01:09:59 +01001020 if (!guidcmp(hprotocol, protocol)) {
xypron.glpk@gmx.dec35c9242017-07-11 22:06:14 +02001021 if (attributes !=
1022 EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
1023 *protocol_interface =
1024 handler->protocol_interface;
1025 }
1026 r = EFI_SUCCESS;
Alexander Grafc15d9212016-03-04 01:09:59 +01001027 goto out;
1028 }
1029 }
xypron.glpk@gmx.def097c842017-07-11 22:06:15 +02001030 goto unsupported;
Alexander Grafc15d9212016-03-04 01:09:59 +01001031 }
1032
xypron.glpk@gmx.def097c842017-07-11 22:06:15 +02001033unsupported:
1034 r = EFI_UNSUPPORTED;
Alexander Grafc15d9212016-03-04 01:09:59 +01001035out:
1036 return EFI_EXIT(r);
1037}
1038
1039static efi_status_t EFIAPI efi_handle_protocol(void *handle,
1040 efi_guid_t *protocol,
1041 void **protocol_interface)
1042{
xypron.glpk@gmx.de1bf5d872017-06-29 21:16:19 +02001043 return efi_open_protocol(handle, protocol, protocol_interface, NULL,
1044 NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
Alexander Grafc15d9212016-03-04 01:09:59 +01001045}
1046
1047static const struct efi_boot_services efi_boot_services = {
1048 .hdr = {
1049 .headersize = sizeof(struct efi_table_hdr),
1050 },
1051 .raise_tpl = efi_raise_tpl,
1052 .restore_tpl = efi_restore_tpl,
1053 .allocate_pages = efi_allocate_pages_ext,
1054 .free_pages = efi_free_pages_ext,
1055 .get_memory_map = efi_get_memory_map_ext,
Stefan Brüns5a09aef2016-10-09 22:17:18 +02001056 .allocate_pool = efi_allocate_pool_ext,
Stefan Brüns67b67d92016-10-09 22:17:26 +02001057 .free_pool = efi_free_pool_ext,
Alexander Grafc15d9212016-03-04 01:09:59 +01001058 .create_event = efi_create_event,
1059 .set_timer = efi_set_timer,
1060 .wait_for_event = efi_wait_for_event,
xypron.glpk@gmx.de30708232017-07-18 20:17:18 +02001061 .signal_event = efi_signal_event_ext,
Alexander Grafc15d9212016-03-04 01:09:59 +01001062 .close_event = efi_close_event,
1063 .check_event = efi_check_event,
xypron.glpk@gmx.de8b7b5df2017-07-11 22:06:18 +02001064 .install_protocol_interface = efi_install_protocol_interface_ext,
Alexander Grafc15d9212016-03-04 01:09:59 +01001065 .reinstall_protocol_interface = efi_reinstall_protocol_interface,
xypron.glpk@gmx.dea453e462017-07-11 22:06:19 +02001066 .uninstall_protocol_interface = efi_uninstall_protocol_interface_ext,
Alexander Grafc15d9212016-03-04 01:09:59 +01001067 .handle_protocol = efi_handle_protocol,
1068 .reserved = NULL,
1069 .register_protocol_notify = efi_register_protocol_notify,
xypron.glpk@gmx.de69f94032017-07-11 22:06:21 +02001070 .locate_handle = efi_locate_handle_ext,
Alexander Grafc15d9212016-03-04 01:09:59 +01001071 .locate_device_path = efi_locate_device_path,
Alexander Grafc5c11632016-08-19 01:23:24 +02001072 .install_configuration_table = efi_install_configuration_table_ext,
Alexander Grafc15d9212016-03-04 01:09:59 +01001073 .load_image = efi_load_image,
1074 .start_image = efi_start_image,
Alexander Graf988c0662016-05-20 23:28:23 +02001075 .exit = efi_exit,
Alexander Grafc15d9212016-03-04 01:09:59 +01001076 .unload_image = efi_unload_image,
1077 .exit_boot_services = efi_exit_boot_services,
1078 .get_next_monotonic_count = efi_get_next_monotonic_count,
1079 .stall = efi_stall,
1080 .set_watchdog_timer = efi_set_watchdog_timer,
1081 .connect_controller = efi_connect_controller,
1082 .disconnect_controller = efi_disconnect_controller,
1083 .open_protocol = efi_open_protocol,
1084 .close_protocol = efi_close_protocol,
1085 .open_protocol_information = efi_open_protocol_information,
1086 .protocols_per_handle = efi_protocols_per_handle,
1087 .locate_handle_buffer = efi_locate_handle_buffer,
1088 .locate_protocol = efi_locate_protocol,
1089 .install_multiple_protocol_interfaces = efi_install_multiple_protocol_interfaces,
1090 .uninstall_multiple_protocol_interfaces = efi_uninstall_multiple_protocol_interfaces,
1091 .calculate_crc32 = efi_calculate_crc32,
1092 .copy_mem = efi_copy_mem,
1093 .set_mem = efi_set_mem,
1094};
1095
1096
Alexander Graf393dd912016-10-14 13:45:30 +02001097static uint16_t __efi_runtime_data firmware_vendor[] =
Alexander Grafc15d9212016-03-04 01:09:59 +01001098 { 'D','a','s',' ','U','-','b','o','o','t',0 };
1099
Alexander Graf393dd912016-10-14 13:45:30 +02001100struct efi_system_table __efi_runtime_data systab = {
Alexander Grafc15d9212016-03-04 01:09:59 +01001101 .hdr = {
1102 .signature = EFI_SYSTEM_TABLE_SIGNATURE,
1103 .revision = 0x20005, /* 2.5 */
1104 .headersize = sizeof(struct efi_table_hdr),
1105 },
1106 .fw_vendor = (long)firmware_vendor,
1107 .con_in = (void*)&efi_con_in,
1108 .con_out = (void*)&efi_con_out,
1109 .std_err = (void*)&efi_con_out,
1110 .runtime = (void*)&efi_runtime_services,
1111 .boottime = (void*)&efi_boot_services,
1112 .nr_tables = 0,
1113 .tables = (void*)efi_conf_table,
1114};