1 // SPDX-License-Identifier: GPL-2.0+
3 * EFI application runtime services
5 * Copyright (c) 2016 Alexander Graf
13 #include <efi_loader.h>
17 #include <u-boot/crc.h>
19 /* For manual relocation support */
20 DECLARE_GLOBAL_DATA_PTR;
22 /* GUID of the runtime properties table */
23 static const efi_guid_t efi_rt_properties_table_guid =
24 EFI_RT_PROPERTIES_TABLE_GUID;
26 struct efi_runtime_mmio_list {
27 struct list_head link;
33 /* This list contains all runtime available mmio regions */
34 LIST_HEAD(efi_runtime_mmio);
36 static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void);
39 * TODO(sjg@chromium.org): These defines and structures should come from the ELF
40 * header for each architecture (or a generic header) rather than being repeated
43 #if defined(__aarch64__)
44 #define R_RELATIVE R_AARCH64_RELATIVE
45 #define R_MASK 0xffffffffULL
47 #elif defined(__arm__)
48 #define R_RELATIVE R_ARM_RELATIVE
49 #define R_MASK 0xffULL
50 #elif defined(__i386__)
51 #define R_RELATIVE R_386_RELATIVE
52 #define R_MASK 0xffULL
53 #elif defined(__x86_64__)
54 #define R_RELATIVE R_X86_64_RELATIVE
55 #define R_MASK 0xffffffffULL
57 #elif defined(__riscv)
58 #define R_RELATIVE R_RISCV_RELATIVE
59 #define R_MASK 0xffULL
68 #if (__riscv_xlen == 32)
69 #define R_ABSOLUTE R_RISCV_32
71 #elif (__riscv_xlen == 64)
72 #define R_ABSOLUTE R_RISCV_64
75 #error unknown riscv target
78 #error Need to add relocation awareness
92 static __efi_runtime_data struct efi_mem_desc *efi_virtmap;
93 static __efi_runtime_data efi_uintn_t efi_descriptor_count;
94 static __efi_runtime_data efi_uintn_t efi_descriptor_size;
97 * EFI runtime code lives in two stages. In the first stage, U-Boot and an EFI
98 * payload are running concurrently at the same time. In this mode, we can
99 * handle a good number of runtime callbacks
103 * efi_init_runtime_supported() - create runtime properties table
105 * Create a configuration table specifying which services are available at
108 * Return: status code
110 efi_status_t efi_init_runtime_supported(void)
113 struct efi_rt_properties_table *rt_table;
115 ret = efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA,
116 sizeof(struct efi_rt_properties_table),
118 if (ret != EFI_SUCCESS)
121 rt_table->version = EFI_RT_PROPERTIES_TABLE_VERSION;
122 rt_table->length = sizeof(struct efi_rt_properties_table);
123 rt_table->runtime_services_supported =
124 EFI_RT_SUPPORTED_GET_VARIABLE |
125 EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME |
126 EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP |
127 EFI_RT_SUPPORTED_CONVERT_POINTER;
130 * This value must be synced with efi_runtime_detach_list
131 * as well as efi_runtime_services.
133 #ifdef CONFIG_EFI_HAVE_RUNTIME_RESET
134 rt_table->runtime_services_supported |= EFI_RT_SUPPORTED_RESET_SYSTEM;
137 ret = efi_install_configuration_table(&efi_rt_properties_table_guid,
143 * efi_memcpy_runtime() - copy memory area
145 * At runtime memcpy() is not available.
147 * Overlapping memory areas can be copied safely if src >= dest.
149 * @dest: destination buffer
150 * @src: source buffer
151 * @n: number of bytes to copy
152 * Return: pointer to destination buffer
154 void __efi_runtime efi_memcpy_runtime(void *dest, const void *src, size_t n)
164 * efi_update_table_header_crc32() - Update crc32 in table header
168 void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table)
171 table->crc32 = crc32(0, (const unsigned char *)table,
176 * efi_reset_system_boottime() - reset system at boot time
178 * This function implements the ResetSystem() runtime service before
179 * SetVirtualAddressMap() is called.
181 * See the Unified Extensible Firmware Interface (UEFI) specification for
184 * @reset_type: type of reset to perform
185 * @reset_status: status code for the reset
186 * @data_size: size of reset_data
187 * @reset_data: information about the reset
189 static void EFIAPI efi_reset_system_boottime(
190 enum efi_reset_type reset_type,
191 efi_status_t reset_status,
192 unsigned long data_size, void *reset_data)
194 struct efi_event *evt;
196 EFI_ENTRY("%d %lx %lx %p", reset_type, reset_status, data_size,
200 list_for_each_entry(evt, &efi_events, link) {
203 &efi_guid_event_group_reset_system)) {
204 efi_signal_event(evt);
208 switch (reset_type) {
211 case EFI_RESET_PLATFORM_SPECIFIC:
212 do_reset(NULL, 0, 0, NULL);
214 case EFI_RESET_SHUTDOWN:
215 #ifdef CONFIG_CMD_POWEROFF
216 do_poweroff(NULL, 0, 0, NULL);
225 * efi_get_time_boottime() - get current time at boot time
227 * This function implements the GetTime runtime service before
228 * SetVirtualAddressMap() is called.
230 * See the Unified Extensible Firmware Interface (UEFI) specification
233 * @time: pointer to structure to receive current time
234 * @capabilities: pointer to structure to receive RTC properties
235 * Returns: status code
237 static efi_status_t EFIAPI efi_get_time_boottime(
238 struct efi_time *time,
239 struct efi_time_cap *capabilities)
241 #ifdef CONFIG_EFI_GET_TIME
242 efi_status_t ret = EFI_SUCCESS;
246 EFI_ENTRY("%p %p", time, capabilities);
249 ret = EFI_INVALID_PARAMETER;
252 if (uclass_get_device(UCLASS_RTC, 0, &dev) ||
253 dm_rtc_get(dev, &tm)) {
254 ret = EFI_UNSUPPORTED;
257 if (dm_rtc_get(dev, &tm)) {
258 ret = EFI_DEVICE_ERROR;
262 memset(time, 0, sizeof(*time));
263 time->year = tm.tm_year;
264 time->month = tm.tm_mon;
265 time->day = tm.tm_mday;
266 time->hour = tm.tm_hour;
267 time->minute = tm.tm_min;
268 time->second = tm.tm_sec;
271 EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT;
272 else if (!tm.tm_isdst)
273 time->daylight = EFI_TIME_ADJUST_DAYLIGHT;
276 time->timezone = EFI_UNSPECIFIED_TIMEZONE;
279 /* Set reasonable dummy values */
280 capabilities->resolution = 1; /* 1 Hz */
281 capabilities->accuracy = 100000000; /* 100 ppm */
282 capabilities->sets_to_zero = false;
285 return EFI_EXIT(ret);
287 EFI_ENTRY("%p %p", time, capabilities);
288 return EFI_EXIT(EFI_UNSUPPORTED);
292 #ifdef CONFIG_EFI_SET_TIME
295 * efi_validate_time() - checks if timestamp is valid
297 * @time: timestamp to validate
298 * Returns: 0 if timestamp is valid, 1 otherwise
300 static int efi_validate_time(struct efi_time *time)
303 time->year < 1900 || time->year > 9999 ||
304 !time->month || time->month > 12 || !time->day ||
305 time->day > rtc_month_days(time->month - 1, time->year) ||
306 time->hour > 23 || time->minute > 59 || time->second > 59 ||
307 time->nanosecond > 999999999 ||
309 ~(EFI_TIME_IN_DAYLIGHT | EFI_TIME_ADJUST_DAYLIGHT) ||
310 ((time->timezone < -1440 || time->timezone > 1440) &&
311 time->timezone != EFI_UNSPECIFIED_TIMEZONE));
317 * efi_set_time_boottime() - set current time
319 * This function implements the SetTime() runtime service before
320 * SetVirtualAddressMap() is called.
322 * See the Unified Extensible Firmware Interface (UEFI) specification
325 * @time: pointer to structure to with current time
326 * Returns: status code
328 static efi_status_t EFIAPI efi_set_time_boottime(struct efi_time *time)
330 #ifdef CONFIG_EFI_SET_TIME
331 efi_status_t ret = EFI_SUCCESS;
335 EFI_ENTRY("%p", time);
337 if (efi_validate_time(time)) {
338 ret = EFI_INVALID_PARAMETER;
342 if (uclass_get_device(UCLASS_RTC, 0, &dev)) {
343 ret = EFI_UNSUPPORTED;
347 memset(&tm, 0, sizeof(tm));
348 tm.tm_year = time->year;
349 tm.tm_mon = time->month;
350 tm.tm_mday = time->day;
351 tm.tm_hour = time->hour;
352 tm.tm_min = time->minute;
353 tm.tm_sec = time->second;
354 switch (time->daylight) {
355 case EFI_TIME_ADJUST_DAYLIGHT:
358 case EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT:
365 /* Calculate day of week */
366 rtc_calc_weekday(&tm);
368 if (dm_rtc_set(dev, &tm))
369 ret = EFI_DEVICE_ERROR;
371 return EFI_EXIT(ret);
373 EFI_ENTRY("%p", time);
374 return EFI_EXIT(EFI_UNSUPPORTED);
378 * efi_reset_system() - reset system
380 * This function implements the ResetSystem() runtime service after
381 * SetVirtualAddressMap() is called. As this placeholder cannot reset the
382 * system it simply return to the caller.
384 * Boards may override the helpers below to implement reset functionality.
386 * See the Unified Extensible Firmware Interface (UEFI) specification for
389 * @reset_type: type of reset to perform
390 * @reset_status: status code for the reset
391 * @data_size: size of reset_data
392 * @reset_data: information about the reset
394 void __weak __efi_runtime EFIAPI efi_reset_system(
395 enum efi_reset_type reset_type,
396 efi_status_t reset_status,
397 unsigned long data_size, void *reset_data)
403 * efi_reset_system_init() - initialize the reset driver
405 * Boards may override this function to initialize the reset driver.
407 efi_status_t __weak efi_reset_system_init(void)
413 * efi_get_time() - get current time
415 * This function implements the GetTime runtime service after
416 * SetVirtualAddressMap() is called. As the U-Boot driver are not available
417 * anymore only an error code is returned.
419 * See the Unified Extensible Firmware Interface (UEFI) specification
422 * @time: pointer to structure to receive current time
423 * @capabilities: pointer to structure to receive RTC properties
424 * Returns: status code
426 efi_status_t __weak __efi_runtime EFIAPI efi_get_time(
427 struct efi_time *time,
428 struct efi_time_cap *capabilities)
430 return EFI_UNSUPPORTED;
434 * efi_set_time() - set current time
436 * This function implements the SetTime runtime service after
437 * SetVirtualAddressMap() is called. As the U-Boot driver are not available
438 * anymore only an error code is returned.
440 * See the Unified Extensible Firmware Interface (UEFI) specification
443 * @time: pointer to structure to with current time
444 * Returns: status code
446 efi_status_t __weak __efi_runtime EFIAPI efi_set_time(struct efi_time *time)
448 return EFI_UNSUPPORTED;
452 * efi_update_capsule_unsupported() - process information from operating system
454 * This function implements the UpdateCapsule() runtime service.
456 * See the Unified Extensible Firmware Interface (UEFI) specification for
459 * @capsule_header_array: pointer to array of virtual pointers
460 * @capsule_count: number of pointers in capsule_header_array
461 * @scatter_gather_list: pointer to array of physical pointers
462 * Returns: status code
464 efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported(
465 struct efi_capsule_header **capsule_header_array,
466 efi_uintn_t capsule_count,
467 u64 scatter_gather_list)
469 return EFI_UNSUPPORTED;
473 * efi_query_capsule_caps_unsupported() - check if capsule is supported
475 * This function implements the QueryCapsuleCapabilities() runtime service.
477 * See the Unified Extensible Firmware Interface (UEFI) specification for
480 * @capsule_header_array: pointer to array of virtual pointers
481 * @capsule_count: number of pointers in capsule_header_array
482 * @maximum_capsule_size: maximum capsule size
483 * @reset_type: type of reset needed for capsule update
484 * Returns: status code
486 efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps_unsupported(
487 struct efi_capsule_header **capsule_header_array,
488 efi_uintn_t capsule_count,
489 u64 *maximum_capsule_size,
492 return EFI_UNSUPPORTED;
496 * efi_is_runtime_service_pointer() - check if pointer points to runtime table
498 * @p: pointer to check
499 * Return: true if the pointer points to a service function pointer in the
502 static bool efi_is_runtime_service_pointer(void *p)
504 return (p >= (void *)&efi_runtime_services.get_time &&
505 p <= (void *)&efi_runtime_services.query_variable_info) ||
506 p == (void *)&efi_events.prev ||
507 p == (void *)&efi_events.next;
511 * efi_runtime_detach() - detach unimplemented runtime functions
513 void efi_runtime_detach(void)
515 efi_runtime_services.reset_system = efi_reset_system;
516 efi_runtime_services.get_time = efi_get_time;
517 efi_runtime_services.set_time = efi_set_time;
518 if (IS_ENABLED(CONFIG_EFI_RUNTIME_UPDATE_CAPSULE)) {
519 /* won't support at runtime */
520 efi_runtime_services.update_capsule =
521 efi_update_capsule_unsupported;
522 efi_runtime_services.query_capsule_caps =
523 efi_query_capsule_caps_unsupported;
527 efi_update_table_header_crc32(&efi_runtime_services.hdr);
531 * efi_set_virtual_address_map_runtime() - change from physical to virtual
534 * This function implements the SetVirtualAddressMap() runtime service after
535 * it is first called.
537 * See the Unified Extensible Firmware Interface (UEFI) specification for
540 * @memory_map_size: size of the virtual map
541 * @descriptor_size: size of an entry in the map
542 * @descriptor_version: version of the map entries
543 * @virtmap: virtual address mapping information
544 * Return: status code EFI_UNSUPPORTED
546 static __efi_runtime efi_status_t EFIAPI efi_set_virtual_address_map_runtime(
547 efi_uintn_t memory_map_size,
548 efi_uintn_t descriptor_size,
549 uint32_t descriptor_version,
550 struct efi_mem_desc *virtmap)
552 return EFI_UNSUPPORTED;
556 * efi_convert_pointer_runtime() - convert from physical to virtual pointer
558 * This function implements the ConvertPointer() runtime service after
559 * the first call to SetVirtualAddressMap().
561 * See the Unified Extensible Firmware Interface (UEFI) specification for
564 * @debug_disposition: indicates if pointer may be converted to NULL
565 * @address: pointer to be converted
566 * Return: status code EFI_UNSUPPORTED
568 static __efi_runtime efi_status_t EFIAPI efi_convert_pointer_runtime(
569 efi_uintn_t debug_disposition, void **address)
571 return EFI_UNSUPPORTED;
575 * efi_convert_pointer() - convert from physical to virtual pointer
577 * This function implements the ConvertPointer() runtime service until
578 * the first call to SetVirtualAddressMap().
580 * See the Unified Extensible Firmware Interface (UEFI) specification for
583 * @debug_disposition: indicates if pointer may be converted to NULL
584 * @address: pointer to be converted
585 * Return: status code
587 __efi_runtime efi_status_t EFIAPI
588 efi_convert_pointer(efi_uintn_t debug_disposition, void **address)
590 efi_physical_addr_t addr;
592 efi_status_t ret = EFI_NOT_FOUND;
595 ret = EFI_UNSUPPORTED;
600 ret = EFI_INVALID_PARAMETER;
604 if (debug_disposition & EFI_OPTIONAL_PTR)
607 return EFI_INVALID_PARAMETER;
610 addr = (uintptr_t)*address;
611 for (i = 0; i < efi_descriptor_count; i++) {
612 struct efi_mem_desc *map = (void *)efi_virtmap +
613 (efi_descriptor_size * i);
615 if (addr >= map->physical_start &&
616 (addr < map->physical_start
617 + (map->num_pages << EFI_PAGE_SHIFT))) {
618 *address = (void *)(uintptr_t)
619 (addr + map->virtual_start -
620 map->physical_start);
631 static __efi_runtime void efi_relocate_runtime_table(ulong offset)
636 /* Relocate the runtime services pointers */
637 patchoff = offset - gd->relocaddr;
638 for (pos = (void **)&efi_runtime_services.get_time;
639 pos <= (void **)&efi_runtime_services.query_variable_info; ++pos) {
645 * The entry for SetVirtualAddress() must point to a physical address.
646 * After the first execution the service must return EFI_UNSUPPORTED.
648 efi_runtime_services.set_virtual_address_map =
649 &efi_set_virtual_address_map_runtime;
652 * The entry for ConvertPointer() must point to a physical address.
653 * The service is not usable after SetVirtualAddress().
655 efi_runtime_services.convert_pointer = &efi_convert_pointer_runtime;
658 * TODO: Update UEFI variable RuntimeServicesSupported removing flags
659 * EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP and
660 * EFI_RT_SUPPORTED_CONVERT_POINTER as required by the UEFI spec 2.8.
664 efi_update_table_header_crc32(&efi_runtime_services.hdr);
667 /* Relocate EFI runtime to uboot_reloc_base = offset */
668 void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map)
671 struct elf_rela *rel = (void*)&__efi_runtime_rel_start;
673 struct elf_rel *rel = (void*)&__efi_runtime_rel_start;
674 static ulong lastoff = CONFIG_SYS_TEXT_BASE;
677 debug("%s: Relocating to offset=%lx\n", __func__, offset);
678 for (; (ulong)rel < (ulong)&__efi_runtime_rel_stop; rel++) {
679 ulong base = CONFIG_SYS_TEXT_BASE;
683 p = (void*)((ulong)rel->offset - base) + gd->relocaddr;
686 * The runtime services table is updated in
687 * efi_relocate_runtime_table()
689 if (map && efi_is_runtime_service_pointer(p))
692 debug("%s: rel->info=%#lx *p=%#lx rel->offset=%p\n", __func__,
693 rel->info, *p, rel->offset);
695 switch (rel->info & R_MASK) {
698 newaddr = rel->addend + offset - CONFIG_SYS_TEXT_BASE;
700 newaddr = *p - lastoff + offset;
705 ulong symidx = rel->info >> SYM_INDEX;
706 extern struct dyn_sym __dyn_sym_start[];
707 newaddr = __dyn_sym_start[symidx].addr + offset;
709 newaddr -= CONFIG_SYS_TEXT_BASE;
715 printf("%s: Unknown relocation type %llx\n",
716 __func__, rel->info & R_MASK);
720 /* Check if the relocation is inside bounds */
721 if (map && ((newaddr < map->virtual_start) ||
722 newaddr > (map->virtual_start +
723 (map->num_pages << EFI_PAGE_SHIFT)))) {
724 printf("%s: Relocation at %p is out of range (%lx)\n",
725 __func__, p, newaddr);
729 debug("%s: Setting %p to %lx\n", __func__, p, newaddr);
731 flush_dcache_range((ulong)p & ~(EFI_CACHELINE_SIZE - 1),
732 ALIGN((ulong)&p[1], EFI_CACHELINE_SIZE));
739 invalidate_icache_all();
743 * efi_set_virtual_address_map() - change from physical to virtual mapping
745 * This function implements the SetVirtualAddressMap() runtime service.
747 * See the Unified Extensible Firmware Interface (UEFI) specification for
750 * @memory_map_size: size of the virtual map
751 * @descriptor_size: size of an entry in the map
752 * @descriptor_version: version of the map entries
753 * @virtmap: virtual address mapping information
754 * Return: status code
756 static efi_status_t EFIAPI efi_set_virtual_address_map(
757 efi_uintn_t memory_map_size,
758 efi_uintn_t descriptor_size,
759 uint32_t descriptor_version,
760 struct efi_mem_desc *virtmap)
762 efi_uintn_t n = memory_map_size / descriptor_size;
764 efi_status_t ret = EFI_INVALID_PARAMETER;
765 int rt_code_sections = 0;
766 struct efi_event *event;
768 EFI_ENTRY("%zx %zx %x %p", memory_map_size, descriptor_size,
769 descriptor_version, virtmap);
771 if (descriptor_version != EFI_MEMORY_DESCRIPTOR_VERSION ||
772 descriptor_size < sizeof(struct efi_mem_desc))
775 efi_virtmap = virtmap;
776 efi_descriptor_size = descriptor_size;
777 efi_descriptor_count = n;
781 * Further down we are cheating. While really we should implement
782 * SetVirtualAddressMap() events and ConvertPointer() to allow
783 * dynamically loaded drivers to expose runtime services, we don't
786 * So let's ensure we see exactly one single runtime section, as
787 * that is the built-in one. If we see more (or less), someone must
788 * have tried adding or removing to that which we don't support yet.
789 * In that case, let's better fail rather than expose broken runtime
792 for (i = 0; i < n; i++) {
793 struct efi_mem_desc *map = (void*)virtmap +
794 (descriptor_size * i);
796 if (map->type == EFI_RUNTIME_SERVICES_CODE)
800 if (rt_code_sections != 1) {
802 * We expose exactly one single runtime code section, so
803 * something is definitely going wrong.
808 /* Notify EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE */
809 list_for_each_entry(event, &efi_events, link) {
810 if (event->notify_function)
811 EFI_CALL_VOID(event->notify_function(
812 event, event->notify_context));
815 /* Rebind mmio pointers */
816 for (i = 0; i < n; i++) {
817 struct efi_mem_desc *map = (void*)virtmap +
818 (descriptor_size * i);
819 struct list_head *lhandle;
820 efi_physical_addr_t map_start = map->physical_start;
821 efi_physical_addr_t map_len = map->num_pages << EFI_PAGE_SHIFT;
822 efi_physical_addr_t map_end = map_start + map_len;
823 u64 off = map->virtual_start - map_start;
825 /* Adjust all mmio pointers in this region */
826 list_for_each(lhandle, &efi_runtime_mmio) {
827 struct efi_runtime_mmio_list *lmmio;
829 lmmio = list_entry(lhandle,
830 struct efi_runtime_mmio_list,
832 if ((map_start <= lmmio->paddr) &&
833 (map_end >= lmmio->paddr)) {
834 uintptr_t new_addr = lmmio->paddr + off;
835 *lmmio->ptr = (void *)new_addr;
838 if ((map_start <= (uintptr_t)systab.tables) &&
839 (map_end >= (uintptr_t)systab.tables)) {
840 char *ptr = (char *)systab.tables;
843 systab.tables = (struct efi_configuration_table *)ptr;
847 /* Relocate the runtime. See TODO above */
848 for (i = 0; i < n; i++) {
849 struct efi_mem_desc *map;
851 map = (void*)virtmap + (descriptor_size * i);
852 if (map->type == EFI_RUNTIME_SERVICES_CODE) {
853 ulong new_offset = map->virtual_start -
854 map->physical_start + gd->relocaddr;
856 efi_relocate_runtime_table(new_offset);
857 efi_runtime_relocate(new_offset, map);
864 return EFI_EXIT(ret);
868 * efi_add_runtime_mmio() - add memory-mapped IO region
870 * This function adds a memory-mapped IO region to the memory map to make it
871 * available at runtime.
873 * @mmio_ptr: pointer to a pointer to the start of the memory-mapped
875 * @len: size of the memory-mapped IO region
876 * Returns: status code
878 efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len)
880 struct efi_runtime_mmio_list *newmmio;
881 uint64_t addr = *(uintptr_t *)mmio_ptr;
884 ret = efi_add_memory_map(addr, len, EFI_MMAP_IO);
885 if (ret != EFI_SUCCESS)
886 return EFI_OUT_OF_RESOURCES;
888 newmmio = calloc(1, sizeof(*newmmio));
890 return EFI_OUT_OF_RESOURCES;
891 newmmio->ptr = mmio_ptr;
892 newmmio->paddr = *(uintptr_t *)mmio_ptr;
894 list_add_tail(&newmmio->link, &efi_runtime_mmio);
900 * In the second stage, U-Boot has disappeared. To isolate our runtime code
901 * that at this point still exists from the rest, we put it into a special
906 * This means that we can not rely on any code outside of this file in any
907 * function or variable below this line.
909 * Please keep everything fully self-contained and annotated with
910 * __efi_runtime and __efi_runtime_data markers.
914 * Relocate the EFI runtime stub to a different place. We need to call this
915 * the first time we expose the runtime interface to a user and on set virtual
920 * efi_unimplemented() - replacement function, returns EFI_UNSUPPORTED
922 * This function is used after SetVirtualAddressMap() is called as replacement
923 * for services that are not available anymore due to constraints of the U-Boot
926 * Return: EFI_UNSUPPORTED
928 static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void)
930 return EFI_UNSUPPORTED;
933 struct efi_runtime_services __efi_runtime_data efi_runtime_services = {
935 .signature = EFI_RUNTIME_SERVICES_SIGNATURE,
936 .revision = EFI_SPECIFICATION_VERSION,
937 .headersize = sizeof(struct efi_runtime_services),
939 .get_time = &efi_get_time_boottime,
940 .set_time = &efi_set_time_boottime,
941 .get_wakeup_time = (void *)&efi_unimplemented,
942 .set_wakeup_time = (void *)&efi_unimplemented,
943 .set_virtual_address_map = &efi_set_virtual_address_map,
944 .convert_pointer = efi_convert_pointer,
945 .get_variable = efi_get_variable,
946 .get_next_variable_name = efi_get_next_variable_name,
947 .set_variable = efi_set_variable,
948 .get_next_high_mono_count = (void *)&efi_unimplemented,
949 .reset_system = &efi_reset_system_boottime,
950 #ifdef CONFIG_EFI_RUNTIME_UPDATE_CAPSULE
951 .update_capsule = efi_update_capsule,
952 .query_capsule_caps = efi_query_capsule_caps,
954 .update_capsule = efi_update_capsule_unsupported,
955 .query_capsule_caps = efi_query_capsule_caps_unsupported,
957 .query_variable_info = efi_query_variable_info,