efi_boottime.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  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. event->signaled = 0;
  321. return EFI_SUCCESS;
  322. }
  323. return EFI_INVALID_PARAMETER;
  324. }
  325. static efi_status_t EFIAPI efi_set_timer_ext(struct efi_event *event,
  326. enum efi_timer_delay type,
  327. uint64_t trigger_time)
  328. {
  329. EFI_ENTRY("%p, %d, %"PRIx64, event, type, trigger_time);
  330. return EFI_EXIT(efi_set_timer(event, type, trigger_time));
  331. }
  332. static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,
  333. struct efi_event **event,
  334. unsigned long *index)
  335. {
  336. int i, j;
  337. EFI_ENTRY("%ld, %p, %p", num_events, event, index);
  338. /* Check parameters */
  339. if (!num_events || !event)
  340. return EFI_EXIT(EFI_INVALID_PARAMETER);
  341. /* Put missing TPL check here */
  342. for (i = 0; i < num_events; ++i) {
  343. for (j = 0; j < ARRAY_SIZE(efi_events); ++j) {
  344. if (event[i] == &efi_events[j])
  345. goto known_event;
  346. }
  347. return EFI_EXIT(EFI_INVALID_PARAMETER);
  348. known_event:
  349. if (!event[i]->type || event[i]->type & EVT_NOTIFY_SIGNAL)
  350. return EFI_EXIT(EFI_INVALID_PARAMETER);
  351. if (!event[i]->signaled)
  352. efi_signal_event(event[i]);
  353. }
  354. /* Wait for signal */
  355. for (;;) {
  356. for (i = 0; i < num_events; ++i) {
  357. if (event[i]->signaled)
  358. goto out;
  359. }
  360. /* Allow events to occur. */
  361. efi_timer_check();
  362. }
  363. out:
  364. /*
  365. * Reset the signal which is passed to the caller to allow periodic
  366. * events to occur.
  367. */
  368. event[i]->signaled = 0;
  369. if (index)
  370. *index = i;
  371. return EFI_EXIT(EFI_SUCCESS);
  372. }
  373. static efi_status_t EFIAPI efi_signal_event_ext(struct efi_event *event)
  374. {
  375. int i;
  376. EFI_ENTRY("%p", event);
  377. for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
  378. if (event != &efi_events[i])
  379. continue;
  380. if (event->signaled)
  381. break;
  382. event->signaled = 1;
  383. if (event->type & EVT_NOTIFY_SIGNAL)
  384. efi_signal_event(event);
  385. break;
  386. }
  387. return EFI_EXIT(EFI_SUCCESS);
  388. }
  389. static efi_status_t EFIAPI efi_close_event(struct efi_event *event)
  390. {
  391. int i;
  392. EFI_ENTRY("%p", event);
  393. for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
  394. if (event == &efi_events[i]) {
  395. event->type = 0;
  396. event->trigger_next = -1ULL;
  397. event->queued = 0;
  398. event->signaled = 0;
  399. return EFI_EXIT(EFI_SUCCESS);
  400. }
  401. }
  402. return EFI_EXIT(EFI_INVALID_PARAMETER);
  403. }
  404. static efi_status_t EFIAPI efi_check_event(struct efi_event *event)
  405. {
  406. int i;
  407. EFI_ENTRY("%p", event);
  408. efi_timer_check();
  409. for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
  410. if (event != &efi_events[i])
  411. continue;
  412. if (!event->type || event->type & EVT_NOTIFY_SIGNAL)
  413. break;
  414. if (!event->signaled)
  415. efi_signal_event(event);
  416. if (event->signaled)
  417. return EFI_EXIT(EFI_SUCCESS);
  418. return EFI_EXIT(EFI_NOT_READY);
  419. }
  420. return EFI_EXIT(EFI_INVALID_PARAMETER);
  421. }
  422. static efi_status_t EFIAPI efi_install_protocol_interface(void **handle,
  423. efi_guid_t *protocol, int protocol_interface_type,
  424. void *protocol_interface)
  425. {
  426. struct list_head *lhandle;
  427. int i;
  428. efi_status_t r;
  429. if (!handle || !protocol ||
  430. protocol_interface_type != EFI_NATIVE_INTERFACE) {
  431. r = EFI_INVALID_PARAMETER;
  432. goto out;
  433. }
  434. /* Create new handle if requested. */
  435. if (!*handle) {
  436. r = EFI_OUT_OF_RESOURCES;
  437. goto out;
  438. }
  439. /* Find object. */
  440. list_for_each(lhandle, &efi_obj_list) {
  441. struct efi_object *efiobj;
  442. efiobj = list_entry(lhandle, struct efi_object, link);
  443. if (efiobj->handle != *handle)
  444. continue;
  445. /* Check if protocol is already installed on the handle. */
  446. for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
  447. struct efi_handler *handler = &efiobj->protocols[i];
  448. if (!handler->guid)
  449. continue;
  450. if (!guidcmp(handler->guid, protocol)) {
  451. r = EFI_INVALID_PARAMETER;
  452. goto out;
  453. }
  454. }
  455. /* Install protocol in first empty slot. */
  456. for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
  457. struct efi_handler *handler = &efiobj->protocols[i];
  458. if (handler->guid)
  459. continue;
  460. handler->guid = protocol;
  461. handler->protocol_interface = protocol_interface;
  462. r = EFI_SUCCESS;
  463. goto out;
  464. }
  465. r = EFI_OUT_OF_RESOURCES;
  466. goto out;
  467. }
  468. r = EFI_INVALID_PARAMETER;
  469. out:
  470. return r;
  471. }
  472. static efi_status_t EFIAPI efi_install_protocol_interface_ext(void **handle,
  473. efi_guid_t *protocol, int protocol_interface_type,
  474. void *protocol_interface)
  475. {
  476. EFI_ENTRY("%p, %p, %d, %p", handle, protocol, protocol_interface_type,
  477. protocol_interface);
  478. return EFI_EXIT(efi_install_protocol_interface(handle, protocol,
  479. protocol_interface_type,
  480. protocol_interface));
  481. }
  482. static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle,
  483. efi_guid_t *protocol, void *old_interface,
  484. void *new_interface)
  485. {
  486. EFI_ENTRY("%p, %p, %p, %p", handle, protocol, old_interface,
  487. new_interface);
  488. return EFI_EXIT(EFI_ACCESS_DENIED);
  489. }
  490. static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle,
  491. efi_guid_t *protocol, void *protocol_interface)
  492. {
  493. struct list_head *lhandle;
  494. int i;
  495. efi_status_t r = EFI_NOT_FOUND;
  496. if (!handle || !protocol) {
  497. r = EFI_INVALID_PARAMETER;
  498. goto out;
  499. }
  500. list_for_each(lhandle, &efi_obj_list) {
  501. struct efi_object *efiobj;
  502. efiobj = list_entry(lhandle, struct efi_object, link);
  503. if (efiobj->handle != handle)
  504. continue;
  505. for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
  506. struct efi_handler *handler = &efiobj->protocols[i];
  507. const efi_guid_t *hprotocol = handler->guid;
  508. if (!hprotocol)
  509. continue;
  510. if (!guidcmp(hprotocol, protocol)) {
  511. if (handler->protocol_interface) {
  512. r = EFI_ACCESS_DENIED;
  513. } else {
  514. handler->guid = 0;
  515. r = EFI_SUCCESS;
  516. }
  517. goto out;
  518. }
  519. }
  520. }
  521. out:
  522. return r;
  523. }
  524. static efi_status_t EFIAPI efi_uninstall_protocol_interface_ext(void *handle,
  525. efi_guid_t *protocol, void *protocol_interface)
  526. {
  527. EFI_ENTRY("%p, %p, %p", handle, protocol, protocol_interface);
  528. return EFI_EXIT(efi_uninstall_protocol_interface(handle, protocol,
  529. protocol_interface));
  530. }
  531. static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol,
  532. struct efi_event *event,
  533. void **registration)
  534. {
  535. EFI_ENTRY("%p, %p, %p", protocol, event, registration);
  536. return EFI_EXIT(EFI_OUT_OF_RESOURCES);
  537. }
  538. static int efi_search(enum efi_locate_search_type search_type,
  539. efi_guid_t *protocol, void *search_key,
  540. struct efi_object *efiobj)
  541. {
  542. int i;
  543. switch (search_type) {
  544. case all_handles:
  545. return 0;
  546. case by_register_notify:
  547. return -1;
  548. case by_protocol:
  549. for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
  550. const efi_guid_t *guid = efiobj->protocols[i].guid;
  551. if (guid && !guidcmp(guid, protocol))
  552. return 0;
  553. }
  554. return -1;
  555. }
  556. return -1;
  557. }
  558. static efi_status_t efi_locate_handle(
  559. enum efi_locate_search_type search_type,
  560. efi_guid_t *protocol, void *search_key,
  561. unsigned long *buffer_size, efi_handle_t *buffer)
  562. {
  563. struct list_head *lhandle;
  564. unsigned long size = 0;
  565. /* Count how much space we need */
  566. list_for_each(lhandle, &efi_obj_list) {
  567. struct efi_object *efiobj;
  568. efiobj = list_entry(lhandle, struct efi_object, link);
  569. if (!efi_search(search_type, protocol, search_key, efiobj)) {
  570. size += sizeof(void*);
  571. }
  572. }
  573. if (*buffer_size < size) {
  574. *buffer_size = size;
  575. return EFI_BUFFER_TOO_SMALL;
  576. }
  577. *buffer_size = size;
  578. if (size == 0)
  579. return EFI_NOT_FOUND;
  580. /* Then fill the array */
  581. list_for_each(lhandle, &efi_obj_list) {
  582. struct efi_object *efiobj;
  583. efiobj = list_entry(lhandle, struct efi_object, link);
  584. if (!efi_search(search_type, protocol, search_key, efiobj)) {
  585. *(buffer++) = efiobj->handle;
  586. }
  587. }
  588. return EFI_SUCCESS;
  589. }
  590. static efi_status_t EFIAPI efi_locate_handle_ext(
  591. enum efi_locate_search_type search_type,
  592. efi_guid_t *protocol, void *search_key,
  593. unsigned long *buffer_size, efi_handle_t *buffer)
  594. {
  595. EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
  596. buffer_size, buffer);
  597. return EFI_EXIT(efi_locate_handle(search_type, protocol, search_key,
  598. buffer_size, buffer));
  599. }
  600. static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol,
  601. struct efi_device_path **device_path,
  602. efi_handle_t *device)
  603. {
  604. EFI_ENTRY("%p, %p, %p", protocol, device_path, device);
  605. return EFI_EXIT(EFI_NOT_FOUND);
  606. }
  607. /* Collapses configuration table entries, removing index i */
  608. static void efi_remove_configuration_table(int i)
  609. {
  610. struct efi_configuration_table *this = &efi_conf_table[i];
  611. struct efi_configuration_table *next = &efi_conf_table[i+1];
  612. struct efi_configuration_table *end = &efi_conf_table[systab.nr_tables];
  613. memmove(this, next, (ulong)end - (ulong)next);
  614. systab.nr_tables--;
  615. }
  616. efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table)
  617. {
  618. int i;
  619. /* Check for guid override */
  620. for (i = 0; i < systab.nr_tables; i++) {
  621. if (!guidcmp(guid, &efi_conf_table[i].guid)) {
  622. if (table)
  623. efi_conf_table[i].table = table;
  624. else
  625. efi_remove_configuration_table(i);
  626. return EFI_SUCCESS;
  627. }
  628. }
  629. if (!table)
  630. return EFI_NOT_FOUND;
  631. /* No override, check for overflow */
  632. if (i >= ARRAY_SIZE(efi_conf_table))
  633. return EFI_OUT_OF_RESOURCES;
  634. /* Add a new entry */
  635. memcpy(&efi_conf_table[i].guid, guid, sizeof(*guid));
  636. efi_conf_table[i].table = table;
  637. systab.nr_tables = i + 1;
  638. return EFI_SUCCESS;
  639. }
  640. static efi_status_t EFIAPI efi_install_configuration_table_ext(efi_guid_t *guid,
  641. void *table)
  642. {
  643. EFI_ENTRY("%p, %p", guid, table);
  644. return EFI_EXIT(efi_install_configuration_table(guid, table));
  645. }
  646. static efi_status_t EFIAPI efi_load_image(bool boot_policy,
  647. efi_handle_t parent_image,
  648. struct efi_device_path *file_path,
  649. void *source_buffer,
  650. unsigned long source_size,
  651. efi_handle_t *image_handle)
  652. {
  653. static struct efi_object loaded_image_info_obj = {
  654. .protocols = {
  655. {
  656. .guid = &efi_guid_loaded_image,
  657. },
  658. },
  659. };
  660. struct efi_loaded_image *info;
  661. struct efi_object *obj;
  662. EFI_ENTRY("%d, %p, %p, %p, %ld, %p", boot_policy, parent_image,
  663. file_path, source_buffer, source_size, image_handle);
  664. info = malloc(sizeof(*info));
  665. loaded_image_info_obj.protocols[0].protocol_interface = info;
  666. obj = malloc(sizeof(loaded_image_info_obj));
  667. memset(info, 0, sizeof(*info));
  668. memcpy(obj, &loaded_image_info_obj, sizeof(loaded_image_info_obj));
  669. obj->handle = info;
  670. info->file_path = file_path;
  671. info->reserved = efi_load_pe(source_buffer, info);
  672. if (!info->reserved) {
  673. free(info);
  674. free(obj);
  675. return EFI_EXIT(EFI_UNSUPPORTED);
  676. }
  677. *image_handle = info;
  678. list_add_tail(&obj->link, &efi_obj_list);
  679. return EFI_EXIT(EFI_SUCCESS);
  680. }
  681. static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
  682. unsigned long *exit_data_size,
  683. s16 **exit_data)
  684. {
  685. ulong (*entry)(void *image_handle, struct efi_system_table *st);
  686. struct efi_loaded_image *info = image_handle;
  687. EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data);
  688. entry = info->reserved;
  689. efi_is_direct_boot = false;
  690. /* call the image! */
  691. if (setjmp(&info->exit_jmp)) {
  692. /* We returned from the child image */
  693. return EFI_EXIT(info->exit_status);
  694. }
  695. __efi_nesting_dec();
  696. __efi_exit_check();
  697. entry(image_handle, &systab);
  698. __efi_entry_check();
  699. __efi_nesting_inc();
  700. /* Should usually never get here */
  701. return EFI_EXIT(EFI_SUCCESS);
  702. }
  703. static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,
  704. efi_status_t exit_status, unsigned long exit_data_size,
  705. int16_t *exit_data)
  706. {
  707. struct efi_loaded_image *loaded_image_info = (void*)image_handle;
  708. EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
  709. exit_data_size, exit_data);
  710. /* Make sure entry/exit counts for EFI world cross-overs match */
  711. __efi_exit_check();
  712. /*
  713. * But longjmp out with the U-Boot gd, not the application's, as
  714. * the other end is a setjmp call inside EFI context.
  715. */
  716. efi_restore_gd();
  717. loaded_image_info->exit_status = exit_status;
  718. longjmp(&loaded_image_info->exit_jmp, 1);
  719. panic("EFI application exited");
  720. }
  721. static struct efi_object *efi_search_obj(void *handle)
  722. {
  723. struct list_head *lhandle;
  724. list_for_each(lhandle, &efi_obj_list) {
  725. struct efi_object *efiobj;
  726. efiobj = list_entry(lhandle, struct efi_object, link);
  727. if (efiobj->handle == handle)
  728. return efiobj;
  729. }
  730. return NULL;
  731. }
  732. static efi_status_t EFIAPI efi_unload_image(void *image_handle)
  733. {
  734. struct efi_object *efiobj;
  735. EFI_ENTRY("%p", image_handle);
  736. efiobj = efi_search_obj(image_handle);
  737. if (efiobj)
  738. list_del(&efiobj->link);
  739. return EFI_EXIT(EFI_SUCCESS);
  740. }
  741. static void efi_exit_caches(void)
  742. {
  743. #if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
  744. /*
  745. * Grub on 32bit ARM needs to have caches disabled before jumping into
  746. * a zImage, but does not know of all cache layers. Give it a hand.
  747. */
  748. if (efi_is_direct_boot)
  749. cleanup_before_linux();
  750. #endif
  751. }
  752. static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle,
  753. unsigned long map_key)
  754. {
  755. EFI_ENTRY("%p, %ld", image_handle, map_key);
  756. board_quiesce_devices();
  757. /* Fix up caches for EFI payloads if necessary */
  758. efi_exit_caches();
  759. /* This stops all lingering devices */
  760. bootm_disable_interrupts();
  761. /* Give the payload some time to boot */
  762. WATCHDOG_RESET();
  763. return EFI_EXIT(EFI_SUCCESS);
  764. }
  765. static efi_status_t EFIAPI efi_get_next_monotonic_count(uint64_t *count)
  766. {
  767. static uint64_t mono = 0;
  768. EFI_ENTRY("%p", count);
  769. *count = mono++;
  770. return EFI_EXIT(EFI_SUCCESS);
  771. }
  772. static efi_status_t EFIAPI efi_stall(unsigned long microseconds)
  773. {
  774. EFI_ENTRY("%ld", microseconds);
  775. udelay(microseconds);
  776. return EFI_EXIT(EFI_SUCCESS);
  777. }
  778. static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout,
  779. uint64_t watchdog_code,
  780. unsigned long data_size,
  781. uint16_t *watchdog_data)
  782. {
  783. EFI_ENTRY("%ld, 0x%"PRIx64", %ld, %p", timeout, watchdog_code,
  784. data_size, watchdog_data);
  785. return efi_unsupported(__func__);
  786. }
  787. static efi_status_t EFIAPI efi_connect_controller(
  788. efi_handle_t controller_handle,
  789. efi_handle_t *driver_image_handle,
  790. struct efi_device_path *remain_device_path,
  791. bool recursive)
  792. {
  793. EFI_ENTRY("%p, %p, %p, %d", controller_handle, driver_image_handle,
  794. remain_device_path, recursive);
  795. return EFI_EXIT(EFI_NOT_FOUND);
  796. }
  797. static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle,
  798. void *driver_image_handle,
  799. void *child_handle)
  800. {
  801. EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle,
  802. child_handle);
  803. return EFI_EXIT(EFI_INVALID_PARAMETER);
  804. }
  805. static efi_status_t EFIAPI efi_close_protocol(void *handle,
  806. efi_guid_t *protocol,
  807. void *agent_handle,
  808. void *controller_handle)
  809. {
  810. EFI_ENTRY("%p, %p, %p, %p", handle, protocol, agent_handle,
  811. controller_handle);
  812. return EFI_EXIT(EFI_NOT_FOUND);
  813. }
  814. static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,
  815. efi_guid_t *protocol,
  816. struct efi_open_protocol_info_entry **entry_buffer,
  817. unsigned long *entry_count)
  818. {
  819. EFI_ENTRY("%p, %p, %p, %p", handle, protocol, entry_buffer,
  820. entry_count);
  821. return EFI_EXIT(EFI_NOT_FOUND);
  822. }
  823. static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,
  824. efi_guid_t ***protocol_buffer,
  825. unsigned long *protocol_buffer_count)
  826. {
  827. unsigned long buffer_size;
  828. struct efi_object *efiobj;
  829. unsigned long i, j;
  830. struct list_head *lhandle;
  831. efi_status_t r;
  832. EFI_ENTRY("%p, %p, %p", handle, protocol_buffer,
  833. protocol_buffer_count);
  834. if (!handle || !protocol_buffer || !protocol_buffer_count)
  835. return EFI_EXIT(EFI_INVALID_PARAMETER);
  836. *protocol_buffer = NULL;
  837. *protocol_buffer_count = 0;
  838. list_for_each(lhandle, &efi_obj_list) {
  839. efiobj = list_entry(lhandle, struct efi_object, link);
  840. if (efiobj->handle != handle)
  841. continue;
  842. /* Count protocols */
  843. for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
  844. if (efiobj->protocols[i].guid)
  845. ++*protocol_buffer_count;
  846. }
  847. /* Copy guids */
  848. if (*protocol_buffer_count) {
  849. buffer_size = sizeof(efi_guid_t *) *
  850. *protocol_buffer_count;
  851. r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES,
  852. buffer_size,
  853. (void **)protocol_buffer);
  854. if (r != EFI_SUCCESS)
  855. return EFI_EXIT(r);
  856. j = 0;
  857. for (i = 0; i < ARRAY_SIZE(efiobj->protocols); ++i) {
  858. if (efiobj->protocols[i].guid) {
  859. (*protocol_buffer)[j] = (void *)
  860. efiobj->protocols[i].guid;
  861. ++j;
  862. }
  863. }
  864. }
  865. break;
  866. }
  867. return EFI_EXIT(EFI_SUCCESS);
  868. }
  869. static efi_status_t EFIAPI efi_locate_handle_buffer(
  870. enum efi_locate_search_type search_type,
  871. efi_guid_t *protocol, void *search_key,
  872. unsigned long *no_handles, efi_handle_t **buffer)
  873. {
  874. efi_status_t r;
  875. unsigned long buffer_size = 0;
  876. EFI_ENTRY("%d, %p, %p, %p, %p", search_type, protocol, search_key,
  877. no_handles, buffer);
  878. if (!no_handles || !buffer) {
  879. r = EFI_INVALID_PARAMETER;
  880. goto out;
  881. }
  882. *no_handles = 0;
  883. *buffer = NULL;
  884. r = efi_locate_handle(search_type, protocol, search_key, &buffer_size,
  885. *buffer);
  886. if (r != EFI_BUFFER_TOO_SMALL)
  887. goto out;
  888. r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size,
  889. (void **)buffer);
  890. if (r != EFI_SUCCESS)
  891. goto out;
  892. r = efi_locate_handle(search_type, protocol, search_key, &buffer_size,
  893. *buffer);
  894. if (r == EFI_SUCCESS)
  895. *no_handles = buffer_size / sizeof(void *);
  896. out:
  897. return EFI_EXIT(r);
  898. }
  899. static efi_status_t EFIAPI efi_locate_protocol(efi_guid_t *protocol,
  900. void *registration,
  901. void **protocol_interface)
  902. {
  903. struct list_head *lhandle;
  904. int i;
  905. EFI_ENTRY("%p, %p, %p", protocol, registration, protocol_interface);
  906. if (!protocol || !protocol_interface)
  907. return EFI_EXIT(EFI_INVALID_PARAMETER);
  908. EFI_PRINT_GUID("protocol", protocol);
  909. list_for_each(lhandle, &efi_obj_list) {
  910. struct efi_object *efiobj;
  911. efiobj = list_entry(lhandle, struct efi_object, link);
  912. for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
  913. struct efi_handler *handler = &efiobj->protocols[i];
  914. if (!handler->guid)
  915. continue;
  916. if (!guidcmp(handler->guid, protocol)) {
  917. *protocol_interface =
  918. handler->protocol_interface;
  919. return EFI_EXIT(EFI_SUCCESS);
  920. }
  921. }
  922. }
  923. *protocol_interface = NULL;
  924. return EFI_EXIT(EFI_NOT_FOUND);
  925. }
  926. static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces(
  927. void **handle, ...)
  928. {
  929. EFI_ENTRY("%p", handle);
  930. va_list argptr;
  931. efi_guid_t *protocol;
  932. void *protocol_interface;
  933. efi_status_t r = EFI_SUCCESS;
  934. int i = 0;
  935. if (!handle)
  936. return EFI_EXIT(EFI_INVALID_PARAMETER);
  937. va_start(argptr, handle);
  938. for (;;) {
  939. protocol = va_arg(argptr, efi_guid_t*);
  940. if (!protocol)
  941. break;
  942. protocol_interface = va_arg(argptr, void*);
  943. r = efi_install_protocol_interface(handle, protocol,
  944. EFI_NATIVE_INTERFACE,
  945. protocol_interface);
  946. if (r != EFI_SUCCESS)
  947. break;
  948. i++;
  949. }
  950. va_end(argptr);
  951. if (r == EFI_SUCCESS)
  952. return EFI_EXIT(r);
  953. /* If an error occured undo all changes. */
  954. va_start(argptr, handle);
  955. for (; i; --i) {
  956. protocol = va_arg(argptr, efi_guid_t*);
  957. protocol_interface = va_arg(argptr, void*);
  958. efi_uninstall_protocol_interface(handle, protocol,
  959. protocol_interface);
  960. }
  961. va_end(argptr);
  962. return EFI_EXIT(r);
  963. }
  964. static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces(
  965. void *handle, ...)
  966. {
  967. EFI_ENTRY("%p", handle);
  968. return EFI_EXIT(EFI_INVALID_PARAMETER);
  969. }
  970. static efi_status_t EFIAPI efi_calculate_crc32(void *data,
  971. unsigned long data_size,
  972. uint32_t *crc32_p)
  973. {
  974. EFI_ENTRY("%p, %ld", data, data_size);
  975. *crc32_p = crc32(0, data, data_size);
  976. return EFI_EXIT(EFI_SUCCESS);
  977. }
  978. static void EFIAPI efi_copy_mem(void *destination, void *source,
  979. unsigned long length)
  980. {
  981. EFI_ENTRY("%p, %p, %ld", destination, source, length);
  982. memcpy(destination, source, length);
  983. }
  984. static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value)
  985. {
  986. EFI_ENTRY("%p, %ld, 0x%x", buffer, size, value);
  987. memset(buffer, value, size);
  988. }
  989. static efi_status_t EFIAPI efi_open_protocol(
  990. void *handle, efi_guid_t *protocol,
  991. void **protocol_interface, void *agent_handle,
  992. void *controller_handle, uint32_t attributes)
  993. {
  994. struct list_head *lhandle;
  995. int i;
  996. efi_status_t r = EFI_INVALID_PARAMETER;
  997. EFI_ENTRY("%p, %p, %p, %p, %p, 0x%x", handle, protocol,
  998. protocol_interface, agent_handle, controller_handle,
  999. attributes);
  1000. if (!handle || !protocol ||
  1001. (!protocol_interface && attributes !=
  1002. EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {
  1003. goto out;
  1004. }
  1005. EFI_PRINT_GUID("protocol", protocol);
  1006. switch (attributes) {
  1007. case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
  1008. case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
  1009. case EFI_OPEN_PROTOCOL_TEST_PROTOCOL:
  1010. break;
  1011. case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER:
  1012. if (controller_handle == handle)
  1013. goto out;
  1014. case EFI_OPEN_PROTOCOL_BY_DRIVER:
  1015. case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE:
  1016. if (controller_handle == NULL)
  1017. goto out;
  1018. case EFI_OPEN_PROTOCOL_EXCLUSIVE:
  1019. if (agent_handle == NULL)
  1020. goto out;
  1021. break;
  1022. default:
  1023. goto out;
  1024. }
  1025. list_for_each(lhandle, &efi_obj_list) {
  1026. struct efi_object *efiobj;
  1027. efiobj = list_entry(lhandle, struct efi_object, link);
  1028. if (efiobj->handle != handle)
  1029. continue;
  1030. for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
  1031. struct efi_handler *handler = &efiobj->protocols[i];
  1032. const efi_guid_t *hprotocol = handler->guid;
  1033. if (!hprotocol)
  1034. continue;
  1035. if (!guidcmp(hprotocol, protocol)) {
  1036. if (attributes !=
  1037. EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
  1038. *protocol_interface =
  1039. handler->protocol_interface;
  1040. }
  1041. r = EFI_SUCCESS;
  1042. goto out;
  1043. }
  1044. }
  1045. goto unsupported;
  1046. }
  1047. unsupported:
  1048. r = EFI_UNSUPPORTED;
  1049. out:
  1050. return EFI_EXIT(r);
  1051. }
  1052. static efi_status_t EFIAPI efi_handle_protocol(void *handle,
  1053. efi_guid_t *protocol,
  1054. void **protocol_interface)
  1055. {
  1056. return efi_open_protocol(handle, protocol, protocol_interface, NULL,
  1057. NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL);
  1058. }
  1059. static const struct efi_boot_services efi_boot_services = {
  1060. .hdr = {
  1061. .headersize = sizeof(struct efi_table_hdr),
  1062. },
  1063. .raise_tpl = efi_raise_tpl,
  1064. .restore_tpl = efi_restore_tpl,
  1065. .allocate_pages = efi_allocate_pages_ext,
  1066. .free_pages = efi_free_pages_ext,
  1067. .get_memory_map = efi_get_memory_map_ext,
  1068. .allocate_pool = efi_allocate_pool_ext,
  1069. .free_pool = efi_free_pool_ext,
  1070. .create_event = efi_create_event_ext,
  1071. .set_timer = efi_set_timer_ext,
  1072. .wait_for_event = efi_wait_for_event,
  1073. .signal_event = efi_signal_event_ext,
  1074. .close_event = efi_close_event,
  1075. .check_event = efi_check_event,
  1076. .install_protocol_interface = efi_install_protocol_interface_ext,
  1077. .reinstall_protocol_interface = efi_reinstall_protocol_interface,
  1078. .uninstall_protocol_interface = efi_uninstall_protocol_interface_ext,
  1079. .handle_protocol = efi_handle_protocol,
  1080. .reserved = NULL,
  1081. .register_protocol_notify = efi_register_protocol_notify,
  1082. .locate_handle = efi_locate_handle_ext,
  1083. .locate_device_path = efi_locate_device_path,
  1084. .install_configuration_table = efi_install_configuration_table_ext,
  1085. .load_image = efi_load_image,
  1086. .start_image = efi_start_image,
  1087. .exit = efi_exit,
  1088. .unload_image = efi_unload_image,
  1089. .exit_boot_services = efi_exit_boot_services,
  1090. .get_next_monotonic_count = efi_get_next_monotonic_count,
  1091. .stall = efi_stall,
  1092. .set_watchdog_timer = efi_set_watchdog_timer,
  1093. .connect_controller = efi_connect_controller,
  1094. .disconnect_controller = efi_disconnect_controller,
  1095. .open_protocol = efi_open_protocol,
  1096. .close_protocol = efi_close_protocol,
  1097. .open_protocol_information = efi_open_protocol_information,
  1098. .protocols_per_handle = efi_protocols_per_handle,
  1099. .locate_handle_buffer = efi_locate_handle_buffer,
  1100. .locate_protocol = efi_locate_protocol,
  1101. .install_multiple_protocol_interfaces = efi_install_multiple_protocol_interfaces,
  1102. .uninstall_multiple_protocol_interfaces = efi_uninstall_multiple_protocol_interfaces,
  1103. .calculate_crc32 = efi_calculate_crc32,
  1104. .copy_mem = efi_copy_mem,
  1105. .set_mem = efi_set_mem,
  1106. };
  1107. static uint16_t __efi_runtime_data firmware_vendor[] =
  1108. { 'D','a','s',' ','U','-','b','o','o','t',0 };
  1109. struct efi_system_table __efi_runtime_data systab = {
  1110. .hdr = {
  1111. .signature = EFI_SYSTEM_TABLE_SIGNATURE,
  1112. .revision = 0x20005, /* 2.5 */
  1113. .headersize = sizeof(struct efi_table_hdr),
  1114. },
  1115. .fw_vendor = (long)firmware_vendor,
  1116. .con_in = (void*)&efi_con_in,
  1117. .con_out = (void*)&efi_con_out,
  1118. .std_err = (void*)&efi_con_out,
  1119. .runtime = (void*)&efi_runtime_services,
  1120. .boottime = (void*)&efi_boot_services,
  1121. .nr_tables = 0,
  1122. .tables = (void*)efi_conf_table,
  1123. };