efi_boottime.c 32 KB

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