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