efi_boottime.c 33 KB

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