Tom Rini | 70df9d6 | 2018-05-07 17:02:21 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 2 | /* |
| 3 | * EFI application runtime services |
| 4 | * |
| 5 | * Copyright (c) 2016 Alexander Graf |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 9 | #include <cpu_func.h> |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 10 | #include <dm.h> |
Alexander Graf | 46c1514 | 2018-06-18 17:23:11 +0200 | [diff] [blame] | 11 | #include <elf.h> |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 12 | #include <efi_loader.h> |
Ilias Apalodimas | 465cb7e | 2024-04-18 15:54:51 +0300 | [diff] [blame] | 13 | #include <efi_variable.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 14 | #include <log.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 15 | #include <malloc.h> |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 16 | #include <rtc.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 17 | #include <asm/global_data.h> |
Simon Glass | 48b6c6b | 2019-11-14 12:57:16 -0700 | [diff] [blame] | 18 | #include <u-boot/crc.h> |
Ilias Apalodimas | 9b37894 | 2024-03-15 08:43:47 +0200 | [diff] [blame] | 19 | #include <asm/sections.h> |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 20 | |
| 21 | /* For manual relocation support */ |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
Heinrich Schuchardt | 956eff3 | 2020-02-19 20:48:49 +0100 | [diff] [blame] | 24 | /* GUID of the runtime properties table */ |
| 25 | static const efi_guid_t efi_rt_properties_table_guid = |
| 26 | EFI_RT_PROPERTIES_TABLE_GUID; |
| 27 | |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 28 | struct efi_runtime_mmio_list { |
| 29 | struct list_head link; |
| 30 | void **ptr; |
| 31 | u64 paddr; |
| 32 | u64 len; |
| 33 | }; |
| 34 | |
| 35 | /* This list contains all runtime available mmio regions */ |
Bin Meng | ba7ad02 | 2023-04-05 20:15:19 +0800 | [diff] [blame] | 36 | static LIST_HEAD(efi_runtime_mmio); |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 37 | |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 38 | static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 39 | |
Simon Glass | fff89d4 | 2018-06-11 23:26:40 -0600 | [diff] [blame] | 40 | /* |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 41 | * TODO(sjg@chromium.org): These defines and structures should come from the ELF |
| 42 | * header for each architecture (or a generic header) rather than being repeated |
| 43 | * here. |
Simon Glass | fff89d4 | 2018-06-11 23:26:40 -0600 | [diff] [blame] | 44 | */ |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 45 | #if defined(__aarch64__) |
Alexander Graf | 46c1514 | 2018-06-18 17:23:11 +0200 | [diff] [blame] | 46 | #define R_RELATIVE R_AARCH64_RELATIVE |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 47 | #define R_MASK 0xffffffffULL |
| 48 | #define IS_RELA 1 |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 49 | #elif defined(__arm__) |
Alexander Graf | 46c1514 | 2018-06-18 17:23:11 +0200 | [diff] [blame] | 50 | #define R_RELATIVE R_ARM_RELATIVE |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 51 | #define R_MASK 0xffULL |
Heinrich Schuchardt | 56e82be | 2018-10-13 20:52:08 -0700 | [diff] [blame] | 52 | #elif defined(__i386__) |
Simon Glass | cdfe696 | 2016-09-25 15:27:35 -0600 | [diff] [blame] | 53 | #define R_RELATIVE R_386_RELATIVE |
| 54 | #define R_MASK 0xffULL |
Heinrich Schuchardt | 56e82be | 2018-10-13 20:52:08 -0700 | [diff] [blame] | 55 | #elif defined(__x86_64__) |
| 56 | #define R_RELATIVE R_X86_64_RELATIVE |
| 57 | #define R_MASK 0xffffffffULL |
| 58 | #define IS_RELA 1 |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 59 | #elif defined(__riscv) |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 60 | #define R_RELATIVE R_RISCV_RELATIVE |
| 61 | #define R_MASK 0xffULL |
| 62 | #define IS_RELA 1 |
| 63 | |
| 64 | struct dyn_sym { |
| 65 | ulong foo1; |
| 66 | ulong addr; |
| 67 | u32 foo2; |
| 68 | u32 foo3; |
| 69 | }; |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 70 | #if (__riscv_xlen == 32) |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 71 | #define R_ABSOLUTE R_RISCV_32 |
| 72 | #define SYM_INDEX 8 |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 73 | #elif (__riscv_xlen == 64) |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 74 | #define R_ABSOLUTE R_RISCV_64 |
| 75 | #define SYM_INDEX 32 |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 76 | #else |
| 77 | #error unknown riscv target |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 78 | #endif |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 79 | #else |
| 80 | #error Need to add relocation awareness |
| 81 | #endif |
| 82 | |
| 83 | struct elf_rel { |
| 84 | ulong *offset; |
| 85 | ulong info; |
| 86 | }; |
| 87 | |
| 88 | struct elf_rela { |
| 89 | ulong *offset; |
| 90 | ulong info; |
| 91 | long addend; |
| 92 | }; |
| 93 | |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 94 | static __efi_runtime_data struct efi_mem_desc *efi_virtmap; |
| 95 | static __efi_runtime_data efi_uintn_t efi_descriptor_count; |
| 96 | static __efi_runtime_data efi_uintn_t efi_descriptor_size; |
| 97 | |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 98 | /* |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 99 | * EFI runtime code lives in two stages. In the first stage, U-Boot and an EFI |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 100 | * payload are running concurrently at the same time. In this mode, we can |
| 101 | * handle a good number of runtime callbacks |
| 102 | */ |
| 103 | |
Heinrich Schuchardt | 956eff3 | 2020-02-19 20:48:49 +0100 | [diff] [blame] | 104 | /** |
| 105 | * efi_init_runtime_supported() - create runtime properties table |
| 106 | * |
| 107 | * Create a configuration table specifying which services are available at |
| 108 | * runtime. |
| 109 | * |
| 110 | * Return: status code |
| 111 | */ |
AKASHI Takahiro | 3240184 | 2019-06-05 13:21:38 +0900 | [diff] [blame] | 112 | efi_status_t efi_init_runtime_supported(void) |
| 113 | { |
Ilias Apalodimas | 465cb7e | 2024-04-18 15:54:51 +0300 | [diff] [blame] | 114 | const efi_guid_t efi_guid_efi_rt_var_file = U_BOOT_EFI_RT_VAR_FILE_GUID; |
Heinrich Schuchardt | 956eff3 | 2020-02-19 20:48:49 +0100 | [diff] [blame] | 115 | efi_status_t ret; |
| 116 | struct efi_rt_properties_table *rt_table; |
| 117 | |
| 118 | ret = efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA, |
| 119 | sizeof(struct efi_rt_properties_table), |
| 120 | (void **)&rt_table); |
| 121 | if (ret != EFI_SUCCESS) |
| 122 | return ret; |
| 123 | |
| 124 | rt_table->version = EFI_RT_PROPERTIES_TABLE_VERSION; |
| 125 | rt_table->length = sizeof(struct efi_rt_properties_table); |
| 126 | rt_table->runtime_services_supported = |
Heinrich Schuchardt | 5be5971 | 2020-03-24 19:54:53 +0000 | [diff] [blame] | 127 | EFI_RT_SUPPORTED_GET_VARIABLE | |
| 128 | EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME | |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 129 | EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP | |
| 130 | EFI_RT_SUPPORTED_CONVERT_POINTER; |
AKASHI Takahiro | 3240184 | 2019-06-05 13:21:38 +0900 | [diff] [blame] | 131 | |
Ilias Apalodimas | 465cb7e | 2024-04-18 15:54:51 +0300 | [diff] [blame] | 132 | if (IS_ENABLED(CONFIG_EFI_RT_VOLATILE_STORE)) { |
Ilias Apalodimas | de70856 | 2024-04-18 15:54:52 +0300 | [diff] [blame^] | 133 | u8 s = 0; |
| 134 | |
Ilias Apalodimas | 465cb7e | 2024-04-18 15:54:51 +0300 | [diff] [blame] | 135 | ret = efi_set_variable_int(u"RTStorageVolatile", |
| 136 | &efi_guid_efi_rt_var_file, |
| 137 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
| 138 | EFI_VARIABLE_RUNTIME_ACCESS | |
| 139 | EFI_VARIABLE_READ_ONLY, |
| 140 | sizeof(EFI_VAR_FILE_NAME), |
| 141 | EFI_VAR_FILE_NAME, false); |
| 142 | if (ret != EFI_SUCCESS) { |
| 143 | log_err("Failed to set RTStorageVolatile\n"); |
| 144 | return ret; |
| 145 | } |
Ilias Apalodimas | de70856 | 2024-04-18 15:54:52 +0300 | [diff] [blame^] | 146 | /* |
| 147 | * This variable needs to be visible so users can read it, |
| 148 | * but the real contents are going to be filled during |
| 149 | * GetVariable |
| 150 | */ |
| 151 | ret = efi_set_variable_int(u"VarToFile", |
| 152 | &efi_guid_efi_rt_var_file, |
| 153 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
| 154 | EFI_VARIABLE_RUNTIME_ACCESS | |
| 155 | EFI_VARIABLE_READ_ONLY, |
| 156 | sizeof(s), |
| 157 | &s, false); |
| 158 | if (ret != EFI_SUCCESS) { |
| 159 | log_err("Failed to set VarToFile\n"); |
| 160 | efi_set_variable_int(u"RTStorageVolatile", |
| 161 | &efi_guid_efi_rt_var_file, |
| 162 | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
| 163 | EFI_VARIABLE_RUNTIME_ACCESS | |
| 164 | EFI_VARIABLE_READ_ONLY, |
| 165 | 0, NULL, false); |
| 166 | |
| 167 | return ret; |
| 168 | } |
Ilias Apalodimas | 465cb7e | 2024-04-18 15:54:51 +0300 | [diff] [blame] | 169 | rt_table->runtime_services_supported |= EFI_RT_SUPPORTED_SET_VARIABLE; |
| 170 | } |
Ilias Apalodimas | 86ba869 | 2024-04-18 15:54:50 +0300 | [diff] [blame] | 171 | |
AKASHI Takahiro | 3240184 | 2019-06-05 13:21:38 +0900 | [diff] [blame] | 172 | /* |
| 173 | * This value must be synced with efi_runtime_detach_list |
| 174 | * as well as efi_runtime_services. |
| 175 | */ |
Heinrich Schuchardt | 05874fb | 2019-07-05 18:12:16 +0200 | [diff] [blame] | 176 | #ifdef CONFIG_EFI_HAVE_RUNTIME_RESET |
Heinrich Schuchardt | 956eff3 | 2020-02-19 20:48:49 +0100 | [diff] [blame] | 177 | rt_table->runtime_services_supported |= EFI_RT_SUPPORTED_RESET_SYSTEM; |
AKASHI Takahiro | 3240184 | 2019-06-05 13:21:38 +0900 | [diff] [blame] | 178 | #endif |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 179 | |
Heinrich Schuchardt | 956eff3 | 2020-02-19 20:48:49 +0100 | [diff] [blame] | 180 | ret = efi_install_configuration_table(&efi_rt_properties_table_guid, |
| 181 | rt_table); |
| 182 | return ret; |
AKASHI Takahiro | 3240184 | 2019-06-05 13:21:38 +0900 | [diff] [blame] | 183 | } |
| 184 | |
Heinrich Schuchardt | 69c1576 | 2018-07-29 09:49:04 +0200 | [diff] [blame] | 185 | /** |
Heinrich Schuchardt | 8cd9975 | 2020-06-28 16:30:29 +0200 | [diff] [blame] | 186 | * efi_memcpy_runtime() - copy memory area |
| 187 | * |
| 188 | * At runtime memcpy() is not available. |
| 189 | * |
Heinrich Schuchardt | 447753e | 2020-07-22 07:56:14 +0200 | [diff] [blame] | 190 | * Overlapping memory areas can be copied safely if src >= dest. |
| 191 | * |
Heinrich Schuchardt | 8cd9975 | 2020-06-28 16:30:29 +0200 | [diff] [blame] | 192 | * @dest: destination buffer |
| 193 | * @src: source buffer |
| 194 | * @n: number of bytes to copy |
| 195 | * Return: pointer to destination buffer |
| 196 | */ |
| 197 | void __efi_runtime efi_memcpy_runtime(void *dest, const void *src, size_t n) |
| 198 | { |
| 199 | u8 *d = dest; |
| 200 | const u8 *s = src; |
| 201 | |
| 202 | for (; n; --n) |
| 203 | *d++ = *s++; |
| 204 | } |
| 205 | |
| 206 | /** |
Heinrich Schuchardt | 69c1576 | 2018-07-29 09:49:04 +0200 | [diff] [blame] | 207 | * efi_update_table_header_crc32() - Update crc32 in table header |
| 208 | * |
| 209 | * @table: EFI table |
| 210 | */ |
| 211 | void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table) |
| 212 | { |
| 213 | table->crc32 = 0; |
| 214 | table->crc32 = crc32(0, (const unsigned char *)table, |
| 215 | table->headersize); |
| 216 | } |
| 217 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 218 | /** |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 219 | * efi_reset_system_boottime() - reset system at boot time |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 220 | * |
| 221 | * This function implements the ResetSystem() runtime service before |
| 222 | * SetVirtualAddressMap() is called. |
| 223 | * |
| 224 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 225 | * details. |
| 226 | * |
| 227 | * @reset_type: type of reset to perform |
| 228 | * @reset_status: status code for the reset |
| 229 | * @data_size: size of reset_data |
| 230 | * @reset_data: information about the reset |
| 231 | */ |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 232 | static void EFIAPI efi_reset_system_boottime( |
| 233 | enum efi_reset_type reset_type, |
| 234 | efi_status_t reset_status, |
| 235 | unsigned long data_size, void *reset_data) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 236 | { |
Heinrich Schuchardt | bf7f169 | 2018-02-18 15:17:52 +0100 | [diff] [blame] | 237 | struct efi_event *evt; |
| 238 | |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 239 | EFI_ENTRY("%d %lx %lx %p", reset_type, reset_status, data_size, |
| 240 | reset_data); |
| 241 | |
Heinrich Schuchardt | bf7f169 | 2018-02-18 15:17:52 +0100 | [diff] [blame] | 242 | /* Notify reset */ |
| 243 | list_for_each_entry(evt, &efi_events, link) { |
| 244 | if (evt->group && |
| 245 | !guidcmp(evt->group, |
| 246 | &efi_guid_event_group_reset_system)) { |
Heinrich Schuchardt | 7b4b8d86 | 2019-06-07 06:47:01 +0200 | [diff] [blame] | 247 | efi_signal_event(evt); |
Heinrich Schuchardt | bf7f169 | 2018-02-18 15:17:52 +0100 | [diff] [blame] | 248 | break; |
| 249 | } |
| 250 | } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 251 | switch (reset_type) { |
| 252 | case EFI_RESET_COLD: |
| 253 | case EFI_RESET_WARM: |
Heinrich Schuchardt | 450d4c8 | 2018-02-06 22:00:22 +0100 | [diff] [blame] | 254 | case EFI_RESET_PLATFORM_SPECIFIC: |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 255 | do_reset(NULL, 0, 0, NULL); |
| 256 | break; |
| 257 | case EFI_RESET_SHUTDOWN: |
Heinrich Schuchardt | 4448945 | 2018-10-16 07:44:53 +0200 | [diff] [blame] | 258 | #ifdef CONFIG_CMD_POWEROFF |
| 259 | do_poweroff(NULL, 0, 0, NULL); |
| 260 | #endif |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 261 | break; |
| 262 | } |
| 263 | |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 264 | while (1) { } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 265 | } |
| 266 | |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 267 | /** |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 268 | * efi_get_time_boottime() - get current time at boot time |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 269 | * |
| 270 | * This function implements the GetTime runtime service before |
| 271 | * SetVirtualAddressMap() is called. |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 272 | * |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 273 | * See the Unified Extensible Firmware Interface (UEFI) specification |
| 274 | * for details. |
| 275 | * |
| 276 | * @time: pointer to structure to receive current time |
| 277 | * @capabilities: pointer to structure to receive RTC properties |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 278 | * Returns: status code |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 279 | */ |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 280 | static efi_status_t EFIAPI efi_get_time_boottime( |
| 281 | struct efi_time *time, |
| 282 | struct efi_time_cap *capabilities) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 283 | { |
Heinrich Schuchardt | f2856ad | 2019-05-31 22:56:02 +0200 | [diff] [blame] | 284 | #ifdef CONFIG_EFI_GET_TIME |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 285 | efi_status_t ret = EFI_SUCCESS; |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 286 | struct rtc_time tm; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 287 | struct udevice *dev; |
| 288 | |
| 289 | EFI_ENTRY("%p %p", time, capabilities); |
| 290 | |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 291 | if (!time) { |
| 292 | ret = EFI_INVALID_PARAMETER; |
| 293 | goto out; |
| 294 | } |
Heinrich Schuchardt | b4bd366 | 2019-05-19 21:41:28 +0200 | [diff] [blame] | 295 | if (uclass_get_device(UCLASS_RTC, 0, &dev) || |
| 296 | dm_rtc_get(dev, &tm)) { |
| 297 | ret = EFI_UNSUPPORTED; |
| 298 | goto out; |
| 299 | } |
| 300 | if (dm_rtc_get(dev, &tm)) { |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 301 | ret = EFI_DEVICE_ERROR; |
| 302 | goto out; |
| 303 | } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 304 | |
| 305 | memset(time, 0, sizeof(*time)); |
| 306 | time->year = tm.tm_year; |
| 307 | time->month = tm.tm_mon; |
| 308 | time->day = tm.tm_mday; |
| 309 | time->hour = tm.tm_hour; |
| 310 | time->minute = tm.tm_min; |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 311 | time->second = tm.tm_sec; |
Heinrich Schuchardt | 6846c57 | 2020-10-23 05:30:29 +0200 | [diff] [blame] | 312 | if (tm.tm_isdst > 0) |
Heinrich Schuchardt | ba3e828 | 2019-05-31 22:08:45 +0200 | [diff] [blame] | 313 | time->daylight = |
| 314 | EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT; |
Heinrich Schuchardt | 6846c57 | 2020-10-23 05:30:29 +0200 | [diff] [blame] | 315 | else if (!tm.tm_isdst) |
| 316 | time->daylight = EFI_TIME_ADJUST_DAYLIGHT; |
| 317 | else |
| 318 | time->daylight = 0; |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 319 | time->timezone = EFI_UNSPECIFIED_TIMEZONE; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 320 | |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 321 | if (capabilities) { |
| 322 | /* Set reasonable dummy values */ |
| 323 | capabilities->resolution = 1; /* 1 Hz */ |
| 324 | capabilities->accuracy = 100000000; /* 100 ppm */ |
| 325 | capabilities->sets_to_zero = false; |
| 326 | } |
| 327 | out: |
| 328 | return EFI_EXIT(ret); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 329 | #else |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 330 | EFI_ENTRY("%p %p", time, capabilities); |
Heinrich Schuchardt | b4bd366 | 2019-05-19 21:41:28 +0200 | [diff] [blame] | 331 | return EFI_EXIT(EFI_UNSUPPORTED); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 332 | #endif |
| 333 | } |
| 334 | |
Heinrich Schuchardt | f2856ad | 2019-05-31 22:56:02 +0200 | [diff] [blame] | 335 | #ifdef CONFIG_EFI_SET_TIME |
Heinrich Schuchardt | 33e5a0e | 2019-05-31 07:35:19 +0200 | [diff] [blame] | 336 | |
| 337 | /** |
| 338 | * efi_validate_time() - checks if timestamp is valid |
| 339 | * |
| 340 | * @time: timestamp to validate |
| 341 | * Returns: 0 if timestamp is valid, 1 otherwise |
| 342 | */ |
| 343 | static int efi_validate_time(struct efi_time *time) |
| 344 | { |
| 345 | return (!time || |
| 346 | time->year < 1900 || time->year > 9999 || |
| 347 | !time->month || time->month > 12 || !time->day || |
| 348 | time->day > rtc_month_days(time->month - 1, time->year) || |
| 349 | time->hour > 23 || time->minute > 59 || time->second > 59 || |
| 350 | time->nanosecond > 999999999 || |
| 351 | time->daylight & |
| 352 | ~(EFI_TIME_IN_DAYLIGHT | EFI_TIME_ADJUST_DAYLIGHT) || |
| 353 | ((time->timezone < -1440 || time->timezone > 1440) && |
| 354 | time->timezone != EFI_UNSPECIFIED_TIMEZONE)); |
| 355 | } |
| 356 | |
| 357 | #endif |
| 358 | |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 359 | /** |
| 360 | * efi_set_time_boottime() - set current time |
| 361 | * |
| 362 | * This function implements the SetTime() runtime service before |
| 363 | * SetVirtualAddressMap() is called. |
| 364 | * |
| 365 | * See the Unified Extensible Firmware Interface (UEFI) specification |
| 366 | * for details. |
| 367 | * |
| 368 | * @time: pointer to structure to with current time |
| 369 | * Returns: status code |
| 370 | */ |
| 371 | static efi_status_t EFIAPI efi_set_time_boottime(struct efi_time *time) |
| 372 | { |
Heinrich Schuchardt | f2856ad | 2019-05-31 22:56:02 +0200 | [diff] [blame] | 373 | #ifdef CONFIG_EFI_SET_TIME |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 374 | efi_status_t ret = EFI_SUCCESS; |
| 375 | struct rtc_time tm; |
| 376 | struct udevice *dev; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 377 | |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 378 | EFI_ENTRY("%p", time); |
| 379 | |
Heinrich Schuchardt | 33e5a0e | 2019-05-31 07:35:19 +0200 | [diff] [blame] | 380 | if (efi_validate_time(time)) { |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 381 | ret = EFI_INVALID_PARAMETER; |
| 382 | goto out; |
| 383 | } |
| 384 | |
| 385 | if (uclass_get_device(UCLASS_RTC, 0, &dev)) { |
| 386 | ret = EFI_UNSUPPORTED; |
| 387 | goto out; |
| 388 | } |
| 389 | |
| 390 | memset(&tm, 0, sizeof(tm)); |
| 391 | tm.tm_year = time->year; |
| 392 | tm.tm_mon = time->month; |
| 393 | tm.tm_mday = time->day; |
| 394 | tm.tm_hour = time->hour; |
| 395 | tm.tm_min = time->minute; |
| 396 | tm.tm_sec = time->second; |
Heinrich Schuchardt | 6846c57 | 2020-10-23 05:30:29 +0200 | [diff] [blame] | 397 | switch (time->daylight) { |
| 398 | case EFI_TIME_ADJUST_DAYLIGHT: |
| 399 | tm.tm_isdst = 0; |
| 400 | break; |
| 401 | case EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT: |
| 402 | tm.tm_isdst = 1; |
| 403 | break; |
| 404 | default: |
| 405 | tm.tm_isdst = -1; |
| 406 | break; |
| 407 | } |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 408 | /* Calculate day of week */ |
| 409 | rtc_calc_weekday(&tm); |
| 410 | |
| 411 | if (dm_rtc_set(dev, &tm)) |
| 412 | ret = EFI_DEVICE_ERROR; |
| 413 | out: |
| 414 | return EFI_EXIT(ret); |
| 415 | #else |
| 416 | EFI_ENTRY("%p", time); |
| 417 | return EFI_EXIT(EFI_UNSUPPORTED); |
| 418 | #endif |
| 419 | } |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 420 | /** |
| 421 | * efi_reset_system() - reset system |
| 422 | * |
| 423 | * This function implements the ResetSystem() runtime service after |
Heinrich Schuchardt | 7b66fcc | 2020-08-22 08:29:53 +0200 | [diff] [blame] | 424 | * SetVirtualAddressMap() is called. As this placeholder cannot reset the |
| 425 | * system it simply return to the caller. |
| 426 | * |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 427 | * Boards may override the helpers below to implement reset functionality. |
| 428 | * |
| 429 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 430 | * details. |
| 431 | * |
| 432 | * @reset_type: type of reset to perform |
| 433 | * @reset_status: status code for the reset |
| 434 | * @data_size: size of reset_data |
| 435 | * @reset_data: information about the reset |
| 436 | */ |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 437 | void __weak __efi_runtime EFIAPI efi_reset_system( |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 438 | enum efi_reset_type reset_type, |
| 439 | efi_status_t reset_status, |
| 440 | unsigned long data_size, void *reset_data) |
| 441 | { |
Heinrich Schuchardt | 7b66fcc | 2020-08-22 08:29:53 +0200 | [diff] [blame] | 442 | return; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 443 | } |
| 444 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 445 | /** |
| 446 | * efi_reset_system_init() - initialize the reset driver |
| 447 | * |
| 448 | * Boards may override this function to initialize the reset driver. |
| 449 | */ |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 450 | efi_status_t __weak efi_reset_system_init(void) |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 451 | { |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 452 | return EFI_SUCCESS; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 453 | } |
| 454 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 455 | /** |
| 456 | * efi_get_time() - get current time |
| 457 | * |
| 458 | * This function implements the GetTime runtime service after |
| 459 | * SetVirtualAddressMap() is called. As the U-Boot driver are not available |
| 460 | * anymore only an error code is returned. |
| 461 | * |
| 462 | * See the Unified Extensible Firmware Interface (UEFI) specification |
| 463 | * for details. |
| 464 | * |
| 465 | * @time: pointer to structure to receive current time |
| 466 | * @capabilities: pointer to structure to receive RTC properties |
| 467 | * Returns: status code |
| 468 | */ |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 469 | efi_status_t __weak __efi_runtime EFIAPI efi_get_time( |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 470 | struct efi_time *time, |
| 471 | struct efi_time_cap *capabilities) |
| 472 | { |
Heinrich Schuchardt | b4ba5be | 2019-06-13 18:42:40 +0200 | [diff] [blame] | 473 | return EFI_UNSUPPORTED; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 474 | } |
| 475 | |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 476 | /** |
| 477 | * efi_set_time() - set current time |
| 478 | * |
| 479 | * This function implements the SetTime runtime service after |
| 480 | * SetVirtualAddressMap() is called. As the U-Boot driver are not available |
| 481 | * anymore only an error code is returned. |
| 482 | * |
| 483 | * See the Unified Extensible Firmware Interface (UEFI) specification |
| 484 | * for details. |
| 485 | * |
| 486 | * @time: pointer to structure to with current time |
| 487 | * Returns: status code |
| 488 | */ |
| 489 | efi_status_t __weak __efi_runtime EFIAPI efi_set_time(struct efi_time *time) |
| 490 | { |
| 491 | return EFI_UNSUPPORTED; |
| 492 | } |
| 493 | |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 494 | /** |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 495 | * efi_update_capsule_unsupported() - process information from operating system |
| 496 | * |
| 497 | * This function implements the UpdateCapsule() runtime service. |
| 498 | * |
| 499 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 500 | * details. |
| 501 | * |
| 502 | * @capsule_header_array: pointer to array of virtual pointers |
| 503 | * @capsule_count: number of pointers in capsule_header_array |
| 504 | * @scatter_gather_list: pointer to array of physical pointers |
| 505 | * Returns: status code |
| 506 | */ |
Heinrich Schuchardt | 6ab9403 | 2023-02-10 08:56:06 +0100 | [diff] [blame] | 507 | static efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported( |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 508 | struct efi_capsule_header **capsule_header_array, |
| 509 | efi_uintn_t capsule_count, |
| 510 | u64 scatter_gather_list) |
| 511 | { |
| 512 | return EFI_UNSUPPORTED; |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * efi_query_capsule_caps_unsupported() - check if capsule is supported |
| 517 | * |
| 518 | * This function implements the QueryCapsuleCapabilities() runtime service. |
| 519 | * |
| 520 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 521 | * details. |
| 522 | * |
| 523 | * @capsule_header_array: pointer to array of virtual pointers |
| 524 | * @capsule_count: number of pointers in capsule_header_array |
| 525 | * @maximum_capsule_size: maximum capsule size |
| 526 | * @reset_type: type of reset needed for capsule update |
| 527 | * Returns: status code |
| 528 | */ |
Heinrich Schuchardt | 6ab9403 | 2023-02-10 08:56:06 +0100 | [diff] [blame] | 529 | static efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps_unsupported( |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 530 | struct efi_capsule_header **capsule_header_array, |
| 531 | efi_uintn_t capsule_count, |
| 532 | u64 *maximum_capsule_size, |
| 533 | u32 *reset_type) |
| 534 | { |
| 535 | return EFI_UNSUPPORTED; |
| 536 | } |
| 537 | |
| 538 | /** |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 539 | * efi_is_runtime_service_pointer() - check if pointer points to runtime table |
| 540 | * |
| 541 | * @p: pointer to check |
| 542 | * Return: true if the pointer points to a service function pointer in the |
| 543 | * runtime table |
| 544 | */ |
| 545 | static bool efi_is_runtime_service_pointer(void *p) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 546 | { |
Heinrich Schuchardt | 4429d87 | 2019-07-11 20:15:09 +0200 | [diff] [blame] | 547 | return (p >= (void *)&efi_runtime_services.get_time && |
| 548 | p <= (void *)&efi_runtime_services.query_variable_info) || |
| 549 | p == (void *)&efi_events.prev || |
| 550 | p == (void *)&efi_events.next; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 551 | } |
| 552 | |
Heinrich Schuchardt | c3f2a9f | 2019-07-05 18:12:21 +0200 | [diff] [blame] | 553 | /** |
| 554 | * efi_runtime_detach() - detach unimplemented runtime functions |
| 555 | */ |
Heinrich Schuchardt | 1943dbb | 2019-07-05 17:42:16 +0200 | [diff] [blame] | 556 | void efi_runtime_detach(void) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 557 | { |
Heinrich Schuchardt | c3f2a9f | 2019-07-05 18:12:21 +0200 | [diff] [blame] | 558 | efi_runtime_services.reset_system = efi_reset_system; |
| 559 | efi_runtime_services.get_time = efi_get_time; |
| 560 | efi_runtime_services.set_time = efi_set_time; |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 561 | if (IS_ENABLED(CONFIG_EFI_RUNTIME_UPDATE_CAPSULE)) { |
| 562 | /* won't support at runtime */ |
| 563 | efi_runtime_services.update_capsule = |
| 564 | efi_update_capsule_unsupported; |
| 565 | efi_runtime_services.query_capsule_caps = |
| 566 | efi_query_capsule_caps_unsupported; |
| 567 | } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 568 | |
Heinrich Schuchardt | c3f2a9f | 2019-07-05 18:12:21 +0200 | [diff] [blame] | 569 | /* Update CRC32 */ |
| 570 | efi_update_table_header_crc32(&efi_runtime_services.hdr); |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 571 | } |
| 572 | |
Heinrich Schuchardt | 2572851 | 2019-06-29 03:32:52 +0200 | [diff] [blame] | 573 | /** |
| 574 | * efi_set_virtual_address_map_runtime() - change from physical to virtual |
| 575 | * mapping |
| 576 | * |
| 577 | * This function implements the SetVirtualAddressMap() runtime service after |
| 578 | * it is first called. |
| 579 | * |
| 580 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 581 | * details. |
| 582 | * |
| 583 | * @memory_map_size: size of the virtual map |
| 584 | * @descriptor_size: size of an entry in the map |
| 585 | * @descriptor_version: version of the map entries |
| 586 | * @virtmap: virtual address mapping information |
| 587 | * Return: status code EFI_UNSUPPORTED |
| 588 | */ |
Heinrich Schuchardt | 2b6bd38 | 2019-07-12 22:41:43 +0200 | [diff] [blame] | 589 | static __efi_runtime efi_status_t EFIAPI efi_set_virtual_address_map_runtime( |
Heinrich Schuchardt | f8599dc | 2019-07-27 20:28:47 +0200 | [diff] [blame] | 590 | efi_uintn_t memory_map_size, |
| 591 | efi_uintn_t descriptor_size, |
Heinrich Schuchardt | 2572851 | 2019-06-29 03:32:52 +0200 | [diff] [blame] | 592 | uint32_t descriptor_version, |
| 593 | struct efi_mem_desc *virtmap) |
| 594 | { |
| 595 | return EFI_UNSUPPORTED; |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * efi_convert_pointer_runtime() - convert from physical to virtual pointer |
| 600 | * |
| 601 | * This function implements the ConvertPointer() runtime service after |
| 602 | * the first call to SetVirtualAddressMap(). |
| 603 | * |
| 604 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 605 | * details. |
| 606 | * |
| 607 | * @debug_disposition: indicates if pointer may be converted to NULL |
| 608 | * @address: pointer to be converted |
| 609 | * Return: status code EFI_UNSUPPORTED |
| 610 | */ |
| 611 | static __efi_runtime efi_status_t EFIAPI efi_convert_pointer_runtime( |
| 612 | efi_uintn_t debug_disposition, void **address) |
| 613 | { |
| 614 | return EFI_UNSUPPORTED; |
| 615 | } |
| 616 | |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 617 | /** |
Heinrich Schuchardt | 582f857 | 2020-03-22 08:28:15 +0100 | [diff] [blame] | 618 | * efi_convert_pointer() - convert from physical to virtual pointer |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 619 | * |
| 620 | * This function implements the ConvertPointer() runtime service until |
| 621 | * the first call to SetVirtualAddressMap(). |
| 622 | * |
| 623 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 624 | * details. |
| 625 | * |
| 626 | * @debug_disposition: indicates if pointer may be converted to NULL |
| 627 | * @address: pointer to be converted |
Heinrich Schuchardt | 582f857 | 2020-03-22 08:28:15 +0100 | [diff] [blame] | 628 | * Return: status code |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 629 | */ |
Heinrich Schuchardt | 699b7c6 | 2020-03-24 18:05:22 +0100 | [diff] [blame] | 630 | __efi_runtime efi_status_t EFIAPI |
| 631 | efi_convert_pointer(efi_uintn_t debug_disposition, void **address) |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 632 | { |
Heinrich Schuchardt | b0818b7 | 2020-07-07 03:10:12 +0200 | [diff] [blame] | 633 | efi_physical_addr_t addr; |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 634 | efi_uintn_t i; |
| 635 | efi_status_t ret = EFI_NOT_FOUND; |
| 636 | |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 637 | if (!efi_virtmap) { |
| 638 | ret = EFI_UNSUPPORTED; |
| 639 | goto out; |
| 640 | } |
| 641 | |
| 642 | if (!address) { |
| 643 | ret = EFI_INVALID_PARAMETER; |
| 644 | goto out; |
| 645 | } |
Heinrich Schuchardt | dabe54a | 2020-03-24 17:52:40 +0100 | [diff] [blame] | 646 | if (!*address) { |
| 647 | if (debug_disposition & EFI_OPTIONAL_PTR) |
| 648 | return EFI_SUCCESS; |
| 649 | else |
| 650 | return EFI_INVALID_PARAMETER; |
| 651 | } |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 652 | |
Heinrich Schuchardt | b0818b7 | 2020-07-07 03:10:12 +0200 | [diff] [blame] | 653 | addr = (uintptr_t)*address; |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 654 | for (i = 0; i < efi_descriptor_count; i++) { |
| 655 | struct efi_mem_desc *map = (void *)efi_virtmap + |
| 656 | (efi_descriptor_size * i); |
| 657 | |
| 658 | if (addr >= map->physical_start && |
| 659 | (addr < map->physical_start |
| 660 | + (map->num_pages << EFI_PAGE_SHIFT))) { |
| 661 | *address = (void *)(uintptr_t) |
| 662 | (addr + map->virtual_start - |
| 663 | map->physical_start); |
| 664 | |
| 665 | ret = EFI_SUCCESS; |
| 666 | break; |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | out: |
Heinrich Schuchardt | 699b7c6 | 2020-03-24 18:05:22 +0100 | [diff] [blame] | 671 | return ret; |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 672 | } |
| 673 | |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 674 | static __efi_runtime void efi_relocate_runtime_table(ulong offset) |
| 675 | { |
| 676 | ulong patchoff; |
| 677 | void **pos; |
| 678 | |
| 679 | /* Relocate the runtime services pointers */ |
| 680 | patchoff = offset - gd->relocaddr; |
| 681 | for (pos = (void **)&efi_runtime_services.get_time; |
| 682 | pos <= (void **)&efi_runtime_services.query_variable_info; ++pos) { |
Heinrich Schuchardt | 2572851 | 2019-06-29 03:32:52 +0200 | [diff] [blame] | 683 | if (*pos) |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 684 | *pos += patchoff; |
| 685 | } |
Heinrich Schuchardt | 69c1576 | 2018-07-29 09:49:04 +0200 | [diff] [blame] | 686 | |
Heinrich Schuchardt | 2572851 | 2019-06-29 03:32:52 +0200 | [diff] [blame] | 687 | /* |
| 688 | * The entry for SetVirtualAddress() must point to a physical address. |
| 689 | * After the first execution the service must return EFI_UNSUPPORTED. |
| 690 | */ |
| 691 | efi_runtime_services.set_virtual_address_map = |
| 692 | &efi_set_virtual_address_map_runtime; |
| 693 | |
| 694 | /* |
| 695 | * The entry for ConvertPointer() must point to a physical address. |
| 696 | * The service is not usable after SetVirtualAddress(). |
| 697 | */ |
| 698 | efi_runtime_services.convert_pointer = &efi_convert_pointer_runtime; |
| 699 | |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 700 | /* |
| 701 | * TODO: Update UEFI variable RuntimeServicesSupported removing flags |
| 702 | * EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP and |
| 703 | * EFI_RT_SUPPORTED_CONVERT_POINTER as required by the UEFI spec 2.8. |
| 704 | */ |
| 705 | |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 706 | /* Update CRC32 */ |
Heinrich Schuchardt | 69c1576 | 2018-07-29 09:49:04 +0200 | [diff] [blame] | 707 | efi_update_table_header_crc32(&efi_runtime_services.hdr); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | /* Relocate EFI runtime to uboot_reloc_base = offset */ |
| 711 | void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) |
| 712 | { |
| 713 | #ifdef IS_RELA |
Ilias Apalodimas | 9bad9cd | 2024-04-04 09:37:37 +0300 | [diff] [blame] | 714 | struct elf_rela *rel = (void *)__efi_runtime_rel_start; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 715 | #else |
Ilias Apalodimas | 9bad9cd | 2024-04-04 09:37:37 +0300 | [diff] [blame] | 716 | struct elf_rel *rel = (void *)__efi_runtime_rel_start; |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 717 | static ulong lastoff = CONFIG_TEXT_BASE; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 718 | #endif |
| 719 | |
Alexander Graf | 62a6748 | 2016-06-02 11:38:27 +0200 | [diff] [blame] | 720 | debug("%s: Relocating to offset=%lx\n", __func__, offset); |
Ilias Apalodimas | 9bad9cd | 2024-04-04 09:37:37 +0300 | [diff] [blame] | 721 | for (; (uintptr_t)rel < (uintptr_t)__efi_runtime_rel_stop; rel++) { |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 722 | ulong base = CONFIG_TEXT_BASE; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 723 | ulong *p; |
| 724 | ulong newaddr; |
| 725 | |
| 726 | p = (void*)((ulong)rel->offset - base) + gd->relocaddr; |
| 727 | |
Heinrich Schuchardt | 3369158 | 2019-08-14 06:49:09 +0200 | [diff] [blame] | 728 | /* |
| 729 | * The runtime services table is updated in |
| 730 | * efi_relocate_runtime_table() |
| 731 | */ |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 732 | if (map && efi_is_runtime_service_pointer(p)) |
| 733 | continue; |
| 734 | |
Heinrich Schuchardt | 56e82be | 2018-10-13 20:52:08 -0700 | [diff] [blame] | 735 | debug("%s: rel->info=%#lx *p=%#lx rel->offset=%p\n", __func__, |
| 736 | rel->info, *p, rel->offset); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 737 | |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 738 | switch (rel->info & R_MASK) { |
| 739 | case R_RELATIVE: |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 740 | #ifdef IS_RELA |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 741 | newaddr = rel->addend + offset - CONFIG_TEXT_BASE; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 742 | #else |
| 743 | newaddr = *p - lastoff + offset; |
| 744 | #endif |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 745 | break; |
| 746 | #ifdef R_ABSOLUTE |
| 747 | case R_ABSOLUTE: { |
| 748 | ulong symidx = rel->info >> SYM_INDEX; |
| 749 | extern struct dyn_sym __dyn_sym_start[]; |
| 750 | newaddr = __dyn_sym_start[symidx].addr + offset; |
Alexander Graf | df0f6c7 | 2018-11-04 22:25:22 +0100 | [diff] [blame] | 751 | #ifdef IS_RELA |
Simon Glass | 72cc538 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 752 | newaddr -= CONFIG_TEXT_BASE; |
Alexander Graf | df0f6c7 | 2018-11-04 22:25:22 +0100 | [diff] [blame] | 753 | #endif |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 754 | break; |
| 755 | } |
| 756 | #endif |
| 757 | default: |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 758 | printf("%s: Unknown relocation type %llx\n", |
| 759 | __func__, rel->info & R_MASK); |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 760 | continue; |
| 761 | } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 762 | |
| 763 | /* Check if the relocation is inside bounds */ |
| 764 | if (map && ((newaddr < map->virtual_start) || |
Heinrich Schuchardt | 9ebc47f | 2017-09-18 22:11:34 +0200 | [diff] [blame] | 765 | newaddr > (map->virtual_start + |
| 766 | (map->num_pages << EFI_PAGE_SHIFT)))) { |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 767 | printf("%s: Relocation at %p is out of range (%lx)\n", |
| 768 | __func__, p, newaddr); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 769 | continue; |
| 770 | } |
| 771 | |
Alexander Graf | 62a6748 | 2016-06-02 11:38:27 +0200 | [diff] [blame] | 772 | debug("%s: Setting %p to %lx\n", __func__, p, newaddr); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 773 | *p = newaddr; |
Alexander Graf | e570232 | 2016-04-11 23:20:39 +0200 | [diff] [blame] | 774 | flush_dcache_range((ulong)p & ~(EFI_CACHELINE_SIZE - 1), |
| 775 | ALIGN((ulong)&p[1], EFI_CACHELINE_SIZE)); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 776 | } |
| 777 | |
| 778 | #ifndef IS_RELA |
| 779 | lastoff = offset; |
| 780 | #endif |
| 781 | |
| 782 | invalidate_icache_all(); |
| 783 | } |
| 784 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 785 | /** |
| 786 | * efi_set_virtual_address_map() - change from physical to virtual mapping |
| 787 | * |
| 788 | * This function implements the SetVirtualAddressMap() runtime service. |
| 789 | * |
| 790 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 791 | * details. |
| 792 | * |
| 793 | * @memory_map_size: size of the virtual map |
| 794 | * @descriptor_size: size of an entry in the map |
| 795 | * @descriptor_version: version of the map entries |
| 796 | * @virtmap: virtual address mapping information |
| 797 | * Return: status code |
| 798 | */ |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 799 | static efi_status_t EFIAPI efi_set_virtual_address_map( |
Heinrich Schuchardt | f8599dc | 2019-07-27 20:28:47 +0200 | [diff] [blame] | 800 | efi_uintn_t memory_map_size, |
| 801 | efi_uintn_t descriptor_size, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 802 | uint32_t descriptor_version, |
| 803 | struct efi_mem_desc *virtmap) |
| 804 | { |
Heinrich Schuchardt | f8599dc | 2019-07-27 20:28:47 +0200 | [diff] [blame] | 805 | efi_uintn_t n = memory_map_size / descriptor_size; |
| 806 | efi_uintn_t i; |
Heinrich Schuchardt | c70a161 | 2019-08-14 05:19:37 +0200 | [diff] [blame] | 807 | efi_status_t ret = EFI_INVALID_PARAMETER; |
Alexander Graf | 86e0021 | 2018-12-11 10:00:42 +0100 | [diff] [blame] | 808 | int rt_code_sections = 0; |
Heinrich Schuchardt | 4429d87 | 2019-07-11 20:15:09 +0200 | [diff] [blame] | 809 | struct efi_event *event; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 810 | |
Heinrich Schuchardt | f8599dc | 2019-07-27 20:28:47 +0200 | [diff] [blame] | 811 | EFI_ENTRY("%zx %zx %x %p", memory_map_size, descriptor_size, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 812 | descriptor_version, virtmap); |
| 813 | |
Heinrich Schuchardt | c70a161 | 2019-08-14 05:19:37 +0200 | [diff] [blame] | 814 | if (descriptor_version != EFI_MEMORY_DESCRIPTOR_VERSION || |
| 815 | descriptor_size < sizeof(struct efi_mem_desc)) |
| 816 | goto out; |
| 817 | |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 818 | efi_virtmap = virtmap; |
| 819 | efi_descriptor_size = descriptor_size; |
| 820 | efi_descriptor_count = n; |
| 821 | |
Alexander Graf | 86e0021 | 2018-12-11 10:00:42 +0100 | [diff] [blame] | 822 | /* |
| 823 | * TODO: |
| 824 | * Further down we are cheating. While really we should implement |
| 825 | * SetVirtualAddressMap() events and ConvertPointer() to allow |
| 826 | * dynamically loaded drivers to expose runtime services, we don't |
| 827 | * today. |
| 828 | * |
| 829 | * So let's ensure we see exactly one single runtime section, as |
| 830 | * that is the built-in one. If we see more (or less), someone must |
| 831 | * have tried adding or removing to that which we don't support yet. |
| 832 | * In that case, let's better fail rather than expose broken runtime |
| 833 | * services. |
| 834 | */ |
| 835 | for (i = 0; i < n; i++) { |
| 836 | struct efi_mem_desc *map = (void*)virtmap + |
| 837 | (descriptor_size * i); |
| 838 | |
| 839 | if (map->type == EFI_RUNTIME_SERVICES_CODE) |
| 840 | rt_code_sections++; |
| 841 | } |
| 842 | |
| 843 | if (rt_code_sections != 1) { |
| 844 | /* |
| 845 | * We expose exactly one single runtime code section, so |
| 846 | * something is definitely going wrong. |
| 847 | */ |
Heinrich Schuchardt | c70a161 | 2019-08-14 05:19:37 +0200 | [diff] [blame] | 848 | goto out; |
Alexander Graf | 86e0021 | 2018-12-11 10:00:42 +0100 | [diff] [blame] | 849 | } |
| 850 | |
Heinrich Schuchardt | 4429d87 | 2019-07-11 20:15:09 +0200 | [diff] [blame] | 851 | /* Notify EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE */ |
| 852 | list_for_each_entry(event, &efi_events, link) { |
| 853 | if (event->notify_function) |
| 854 | EFI_CALL_VOID(event->notify_function( |
| 855 | event, event->notify_context)); |
| 856 | } |
| 857 | |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 858 | /* Rebind mmio pointers */ |
| 859 | for (i = 0; i < n; i++) { |
| 860 | struct efi_mem_desc *map = (void*)virtmap + |
| 861 | (descriptor_size * i); |
| 862 | struct list_head *lhandle; |
| 863 | efi_physical_addr_t map_start = map->physical_start; |
| 864 | efi_physical_addr_t map_len = map->num_pages << EFI_PAGE_SHIFT; |
| 865 | efi_physical_addr_t map_end = map_start + map_len; |
Heinrich Schuchardt | 3905456 | 2018-08-04 23:16:06 +0200 | [diff] [blame] | 866 | u64 off = map->virtual_start - map_start; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 867 | |
| 868 | /* Adjust all mmio pointers in this region */ |
| 869 | list_for_each(lhandle, &efi_runtime_mmio) { |
| 870 | struct efi_runtime_mmio_list *lmmio; |
| 871 | |
| 872 | lmmio = list_entry(lhandle, |
| 873 | struct efi_runtime_mmio_list, |
| 874 | link); |
| 875 | if ((map_start <= lmmio->paddr) && |
| 876 | (map_end >= lmmio->paddr)) { |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 877 | uintptr_t new_addr = lmmio->paddr + off; |
| 878 | *lmmio->ptr = (void *)new_addr; |
| 879 | } |
| 880 | } |
Heinrich Schuchardt | 3905456 | 2018-08-04 23:16:06 +0200 | [diff] [blame] | 881 | if ((map_start <= (uintptr_t)systab.tables) && |
| 882 | (map_end >= (uintptr_t)systab.tables)) { |
| 883 | char *ptr = (char *)systab.tables; |
| 884 | |
| 885 | ptr += off; |
| 886 | systab.tables = (struct efi_configuration_table *)ptr; |
| 887 | } |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 888 | } |
| 889 | |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 890 | /* Relocate the runtime. See TODO above */ |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 891 | for (i = 0; i < n; i++) { |
| 892 | struct efi_mem_desc *map; |
| 893 | |
| 894 | map = (void*)virtmap + (descriptor_size * i); |
| 895 | if (map->type == EFI_RUNTIME_SERVICES_CODE) { |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 896 | ulong new_offset = map->virtual_start - |
Alexander Graf | 86e0021 | 2018-12-11 10:00:42 +0100 | [diff] [blame] | 897 | map->physical_start + gd->relocaddr; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 898 | |
Heinrich Schuchardt | 19cd80b | 2019-06-20 22:00:02 +0000 | [diff] [blame] | 899 | efi_relocate_runtime_table(new_offset); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 900 | efi_runtime_relocate(new_offset, map); |
Heinrich Schuchardt | c70a161 | 2019-08-14 05:19:37 +0200 | [diff] [blame] | 901 | ret = EFI_SUCCESS; |
| 902 | goto out; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 903 | } |
| 904 | } |
| 905 | |
Heinrich Schuchardt | c70a161 | 2019-08-14 05:19:37 +0200 | [diff] [blame] | 906 | out: |
| 907 | return EFI_EXIT(ret); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 908 | } |
| 909 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 910 | /** |
| 911 | * efi_add_runtime_mmio() - add memory-mapped IO region |
| 912 | * |
| 913 | * This function adds a memory-mapped IO region to the memory map to make it |
| 914 | * available at runtime. |
| 915 | * |
Heinrich Schuchardt | 7e30764 | 2018-12-23 02:35:13 +0100 | [diff] [blame] | 916 | * @mmio_ptr: pointer to a pointer to the start of the memory-mapped |
| 917 | * IO region |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 918 | * @len: size of the memory-mapped IO region |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 919 | * Returns: status code |
| 920 | */ |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 921 | efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 922 | { |
| 923 | struct efi_runtime_mmio_list *newmmio; |
Alexander Graf | 33a83a3 | 2018-03-15 15:08:16 +0100 | [diff] [blame] | 924 | uint64_t addr = *(uintptr_t *)mmio_ptr; |
Bryan O'Donoghue | 89a22b4 | 2019-07-15 12:00:39 +0100 | [diff] [blame] | 925 | efi_status_t ret; |
Alexander Graf | 33a83a3 | 2018-03-15 15:08:16 +0100 | [diff] [blame] | 926 | |
Michael Walle | 282d386 | 2020-05-17 12:29:19 +0200 | [diff] [blame] | 927 | ret = efi_add_memory_map(addr, len, EFI_MMAP_IO); |
Bryan O'Donoghue | 89a22b4 | 2019-07-15 12:00:39 +0100 | [diff] [blame] | 928 | if (ret != EFI_SUCCESS) |
Alexander Graf | 33a83a3 | 2018-03-15 15:08:16 +0100 | [diff] [blame] | 929 | return EFI_OUT_OF_RESOURCES; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 930 | |
| 931 | newmmio = calloc(1, sizeof(*newmmio)); |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 932 | if (!newmmio) |
| 933 | return EFI_OUT_OF_RESOURCES; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 934 | newmmio->ptr = mmio_ptr; |
| 935 | newmmio->paddr = *(uintptr_t *)mmio_ptr; |
| 936 | newmmio->len = len; |
| 937 | list_add_tail(&newmmio->link, &efi_runtime_mmio); |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 938 | |
Alexander Graf | 33a83a3 | 2018-03-15 15:08:16 +0100 | [diff] [blame] | 939 | return EFI_SUCCESS; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 940 | } |
| 941 | |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 942 | /* |
| 943 | * In the second stage, U-Boot has disappeared. To isolate our runtime code |
| 944 | * that at this point still exists from the rest, we put it into a special |
| 945 | * section. |
| 946 | * |
| 947 | * !!WARNING!! |
| 948 | * |
| 949 | * This means that we can not rely on any code outside of this file in any |
| 950 | * function or variable below this line. |
| 951 | * |
| 952 | * Please keep everything fully self-contained and annotated with |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 953 | * __efi_runtime and __efi_runtime_data markers. |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 954 | */ |
| 955 | |
| 956 | /* |
| 957 | * Relocate the EFI runtime stub to a different place. We need to call this |
| 958 | * the first time we expose the runtime interface to a user and on set virtual |
| 959 | * address map calls. |
| 960 | */ |
| 961 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 962 | /** |
| 963 | * efi_unimplemented() - replacement function, returns EFI_UNSUPPORTED |
| 964 | * |
| 965 | * This function is used after SetVirtualAddressMap() is called as replacement |
| 966 | * for services that are not available anymore due to constraints of the U-Boot |
| 967 | * implementation. |
| 968 | * |
| 969 | * Return: EFI_UNSUPPORTED |
| 970 | */ |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 971 | static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 972 | { |
| 973 | return EFI_UNSUPPORTED; |
| 974 | } |
| 975 | |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 976 | struct efi_runtime_services __efi_runtime_data efi_runtime_services = { |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 977 | .hdr = { |
| 978 | .signature = EFI_RUNTIME_SERVICES_SIGNATURE, |
Heinrich Schuchardt | e75b3cb | 2018-06-28 12:45:27 +0200 | [diff] [blame] | 979 | .revision = EFI_SPECIFICATION_VERSION, |
Heinrich Schuchardt | 1020425 | 2018-06-28 12:45:29 +0200 | [diff] [blame] | 980 | .headersize = sizeof(struct efi_runtime_services), |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 981 | }, |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 982 | .get_time = &efi_get_time_boottime, |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 983 | .set_time = &efi_set_time_boottime, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 984 | .get_wakeup_time = (void *)&efi_unimplemented, |
| 985 | .set_wakeup_time = (void *)&efi_unimplemented, |
| 986 | .set_virtual_address_map = &efi_set_virtual_address_map, |
Heinrich Schuchardt | c680dc4 | 2019-07-27 20:35:24 +0200 | [diff] [blame] | 987 | .convert_pointer = efi_convert_pointer, |
Rob Clark | 15f3d74 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 988 | .get_variable = efi_get_variable, |
Heinrich Schuchardt | d6a6baa | 2018-05-17 07:57:05 +0200 | [diff] [blame] | 989 | .get_next_variable_name = efi_get_next_variable_name, |
Rob Clark | 15f3d74 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 990 | .set_variable = efi_set_variable, |
Heinrich Schuchardt | 5337a6c | 2019-06-20 15:40:49 +0200 | [diff] [blame] | 991 | .get_next_high_mono_count = (void *)&efi_unimplemented, |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 992 | .reset_system = &efi_reset_system_boottime, |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 993 | #ifdef CONFIG_EFI_RUNTIME_UPDATE_CAPSULE |
Heinrich Schuchardt | 897c072 | 2018-02-09 20:41:21 +0100 | [diff] [blame] | 994 | .update_capsule = efi_update_capsule, |
| 995 | .query_capsule_caps = efi_query_capsule_caps, |
AKASHI Takahiro | 473d9b3 | 2020-11-17 09:27:55 +0900 | [diff] [blame] | 996 | #else |
| 997 | .update_capsule = efi_update_capsule_unsupported, |
| 998 | .query_capsule_caps = efi_query_capsule_caps_unsupported, |
| 999 | #endif |
Heinrich Schuchardt | 897c072 | 2018-02-09 20:41:21 +0100 | [diff] [blame] | 1000 | .query_variable_info = efi_query_variable_info, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 1001 | }; |