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 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 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> |
| 13 | #include <rtc.h> |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 14 | |
| 15 | /* For manual relocation support */ |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 18 | struct efi_runtime_mmio_list { |
| 19 | struct list_head link; |
| 20 | void **ptr; |
| 21 | u64 paddr; |
| 22 | u64 len; |
| 23 | }; |
| 24 | |
| 25 | /* This list contains all runtime available mmio regions */ |
| 26 | LIST_HEAD(efi_runtime_mmio); |
| 27 | |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 28 | static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void); |
| 29 | static efi_status_t __efi_runtime EFIAPI efi_device_error(void); |
| 30 | static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 31 | |
Simon Glass | fff89d4 | 2018-06-11 23:26:40 -0600 | [diff] [blame] | 32 | /* |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 33 | * TODO(sjg@chromium.org): These defines and structures should come from the ELF |
| 34 | * header for each architecture (or a generic header) rather than being repeated |
| 35 | * here. |
Simon Glass | fff89d4 | 2018-06-11 23:26:40 -0600 | [diff] [blame] | 36 | */ |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 37 | #if defined(__aarch64__) |
Alexander Graf | 46c1514 | 2018-06-18 17:23:11 +0200 | [diff] [blame] | 38 | #define R_RELATIVE R_AARCH64_RELATIVE |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 39 | #define R_MASK 0xffffffffULL |
| 40 | #define IS_RELA 1 |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 41 | #elif defined(__arm__) |
Alexander Graf | 46c1514 | 2018-06-18 17:23:11 +0200 | [diff] [blame] | 42 | #define R_RELATIVE R_ARM_RELATIVE |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 43 | #define R_MASK 0xffULL |
Heinrich Schuchardt | 56e82be | 2018-10-13 20:52:08 -0700 | [diff] [blame] | 44 | #elif defined(__i386__) |
Simon Glass | cdfe696 | 2016-09-25 15:27:35 -0600 | [diff] [blame] | 45 | #define R_RELATIVE R_386_RELATIVE |
| 46 | #define R_MASK 0xffULL |
Heinrich Schuchardt | 56e82be | 2018-10-13 20:52:08 -0700 | [diff] [blame] | 47 | #elif defined(__x86_64__) |
| 48 | #define R_RELATIVE R_X86_64_RELATIVE |
| 49 | #define R_MASK 0xffffffffULL |
| 50 | #define IS_RELA 1 |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 51 | #elif defined(__riscv) |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 52 | #define R_RELATIVE R_RISCV_RELATIVE |
| 53 | #define R_MASK 0xffULL |
| 54 | #define IS_RELA 1 |
| 55 | |
| 56 | struct dyn_sym { |
| 57 | ulong foo1; |
| 58 | ulong addr; |
| 59 | u32 foo2; |
| 60 | u32 foo3; |
| 61 | }; |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 62 | #if (__riscv_xlen == 32) |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 63 | #define R_ABSOLUTE R_RISCV_32 |
| 64 | #define SYM_INDEX 8 |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 65 | #elif (__riscv_xlen == 64) |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 66 | #define R_ABSOLUTE R_RISCV_64 |
| 67 | #define SYM_INDEX 32 |
Alexander Graf | 0fe5192 | 2018-06-18 17:23:08 +0200 | [diff] [blame] | 68 | #else |
| 69 | #error unknown riscv target |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 70 | #endif |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 71 | #else |
| 72 | #error Need to add relocation awareness |
| 73 | #endif |
| 74 | |
| 75 | struct elf_rel { |
| 76 | ulong *offset; |
| 77 | ulong info; |
| 78 | }; |
| 79 | |
| 80 | struct elf_rela { |
| 81 | ulong *offset; |
| 82 | ulong info; |
| 83 | long addend; |
| 84 | }; |
| 85 | |
| 86 | /* |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 87 | * 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] | 88 | * payload are running concurrently at the same time. In this mode, we can |
| 89 | * handle a good number of runtime callbacks |
| 90 | */ |
| 91 | |
Heinrich Schuchardt | 69c1576 | 2018-07-29 09:49:04 +0200 | [diff] [blame] | 92 | /** |
| 93 | * efi_update_table_header_crc32() - Update crc32 in table header |
| 94 | * |
| 95 | * @table: EFI table |
| 96 | */ |
| 97 | void __efi_runtime efi_update_table_header_crc32(struct efi_table_hdr *table) |
| 98 | { |
| 99 | table->crc32 = 0; |
| 100 | table->crc32 = crc32(0, (const unsigned char *)table, |
| 101 | table->headersize); |
| 102 | } |
| 103 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 104 | /** |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 105 | * efi_reset_system_boottime() - reset system at boot time |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 106 | * |
| 107 | * This function implements the ResetSystem() runtime service before |
| 108 | * SetVirtualAddressMap() is called. |
| 109 | * |
| 110 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 111 | * details. |
| 112 | * |
| 113 | * @reset_type: type of reset to perform |
| 114 | * @reset_status: status code for the reset |
| 115 | * @data_size: size of reset_data |
| 116 | * @reset_data: information about the reset |
| 117 | */ |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 118 | static void EFIAPI efi_reset_system_boottime( |
| 119 | enum efi_reset_type reset_type, |
| 120 | efi_status_t reset_status, |
| 121 | unsigned long data_size, void *reset_data) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 122 | { |
Heinrich Schuchardt | bf7f169 | 2018-02-18 15:17:52 +0100 | [diff] [blame] | 123 | struct efi_event *evt; |
| 124 | |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 125 | EFI_ENTRY("%d %lx %lx %p", reset_type, reset_status, data_size, |
| 126 | reset_data); |
| 127 | |
Heinrich Schuchardt | bf7f169 | 2018-02-18 15:17:52 +0100 | [diff] [blame] | 128 | /* Notify reset */ |
| 129 | list_for_each_entry(evt, &efi_events, link) { |
| 130 | if (evt->group && |
| 131 | !guidcmp(evt->group, |
| 132 | &efi_guid_event_group_reset_system)) { |
| 133 | efi_signal_event(evt, false); |
| 134 | break; |
| 135 | } |
| 136 | } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 137 | switch (reset_type) { |
| 138 | case EFI_RESET_COLD: |
| 139 | case EFI_RESET_WARM: |
Heinrich Schuchardt | 450d4c8 | 2018-02-06 22:00:22 +0100 | [diff] [blame] | 140 | case EFI_RESET_PLATFORM_SPECIFIC: |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 141 | do_reset(NULL, 0, 0, NULL); |
| 142 | break; |
| 143 | case EFI_RESET_SHUTDOWN: |
Heinrich Schuchardt | 4448945 | 2018-10-16 07:44:53 +0200 | [diff] [blame] | 144 | #ifdef CONFIG_CMD_POWEROFF |
| 145 | do_poweroff(NULL, 0, 0, NULL); |
| 146 | #endif |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 147 | break; |
| 148 | } |
| 149 | |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 150 | while (1) { } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 151 | } |
| 152 | |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 153 | /** |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 154 | * efi_get_time_boottime() - get current time at boot time |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 155 | * |
| 156 | * This function implements the GetTime runtime service before |
| 157 | * SetVirtualAddressMap() is called. |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 158 | * |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 159 | * See the Unified Extensible Firmware Interface (UEFI) specification |
| 160 | * for details. |
| 161 | * |
| 162 | * @time: pointer to structure to receive current time |
| 163 | * @capabilities: pointer to structure to receive RTC properties |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 164 | * Returns: status code |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 165 | */ |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 166 | static efi_status_t EFIAPI efi_get_time_boottime( |
| 167 | struct efi_time *time, |
| 168 | struct efi_time_cap *capabilities) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 169 | { |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 170 | #ifdef CONFIG_DM_RTC |
| 171 | efi_status_t ret = EFI_SUCCESS; |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 172 | struct rtc_time tm; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 173 | struct udevice *dev; |
| 174 | |
| 175 | EFI_ENTRY("%p %p", time, capabilities); |
| 176 | |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 177 | if (!time) { |
| 178 | ret = EFI_INVALID_PARAMETER; |
| 179 | goto out; |
| 180 | } |
Heinrich Schuchardt | b4bd366 | 2019-05-19 21:41:28 +0200 | [diff] [blame] | 181 | if (uclass_get_device(UCLASS_RTC, 0, &dev) || |
| 182 | dm_rtc_get(dev, &tm)) { |
| 183 | ret = EFI_UNSUPPORTED; |
| 184 | goto out; |
| 185 | } |
| 186 | if (dm_rtc_get(dev, &tm)) { |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 187 | ret = EFI_DEVICE_ERROR; |
| 188 | goto out; |
| 189 | } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 190 | |
| 191 | memset(time, 0, sizeof(*time)); |
| 192 | time->year = tm.tm_year; |
| 193 | time->month = tm.tm_mon; |
| 194 | time->day = tm.tm_mday; |
| 195 | time->hour = tm.tm_hour; |
| 196 | time->minute = tm.tm_min; |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 197 | time->second = tm.tm_sec; |
| 198 | time->daylight = EFI_TIME_ADJUST_DAYLIGHT; |
| 199 | if (tm.tm_isdst > 0) |
| 200 | time->daylight |= EFI_TIME_IN_DAYLIGHT; |
| 201 | time->timezone = EFI_UNSPECIFIED_TIMEZONE; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 202 | |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 203 | if (capabilities) { |
| 204 | /* Set reasonable dummy values */ |
| 205 | capabilities->resolution = 1; /* 1 Hz */ |
| 206 | capabilities->accuracy = 100000000; /* 100 ppm */ |
| 207 | capabilities->sets_to_zero = false; |
| 208 | } |
| 209 | out: |
| 210 | return EFI_EXIT(ret); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 211 | #else |
Heinrich Schuchardt | 37035b1 | 2018-07-07 23:39:14 +0200 | [diff] [blame] | 212 | EFI_ENTRY("%p %p", time, capabilities); |
Heinrich Schuchardt | b4bd366 | 2019-05-19 21:41:28 +0200 | [diff] [blame] | 213 | return EFI_EXIT(EFI_UNSUPPORTED); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 214 | #endif |
| 215 | } |
| 216 | |
Heinrich Schuchardt | 33e5a0e | 2019-05-31 07:35:19 +0200 | [diff] [blame] | 217 | #ifdef CONFIG_DM_RTC |
| 218 | |
| 219 | /** |
| 220 | * efi_validate_time() - checks if timestamp is valid |
| 221 | * |
| 222 | * @time: timestamp to validate |
| 223 | * Returns: 0 if timestamp is valid, 1 otherwise |
| 224 | */ |
| 225 | static int efi_validate_time(struct efi_time *time) |
| 226 | { |
| 227 | return (!time || |
| 228 | time->year < 1900 || time->year > 9999 || |
| 229 | !time->month || time->month > 12 || !time->day || |
| 230 | time->day > rtc_month_days(time->month - 1, time->year) || |
| 231 | time->hour > 23 || time->minute > 59 || time->second > 59 || |
| 232 | time->nanosecond > 999999999 || |
| 233 | time->daylight & |
| 234 | ~(EFI_TIME_IN_DAYLIGHT | EFI_TIME_ADJUST_DAYLIGHT) || |
| 235 | ((time->timezone < -1440 || time->timezone > 1440) && |
| 236 | time->timezone != EFI_UNSPECIFIED_TIMEZONE)); |
| 237 | } |
| 238 | |
| 239 | #endif |
| 240 | |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 241 | /** |
| 242 | * efi_set_time_boottime() - set current time |
| 243 | * |
| 244 | * This function implements the SetTime() runtime service before |
| 245 | * SetVirtualAddressMap() is called. |
| 246 | * |
| 247 | * See the Unified Extensible Firmware Interface (UEFI) specification |
| 248 | * for details. |
| 249 | * |
| 250 | * @time: pointer to structure to with current time |
| 251 | * Returns: status code |
| 252 | */ |
| 253 | static efi_status_t EFIAPI efi_set_time_boottime(struct efi_time *time) |
| 254 | { |
| 255 | #ifdef CONFIG_DM_RTC |
| 256 | efi_status_t ret = EFI_SUCCESS; |
| 257 | struct rtc_time tm; |
| 258 | struct udevice *dev; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 259 | |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 260 | EFI_ENTRY("%p", time); |
| 261 | |
Heinrich Schuchardt | 33e5a0e | 2019-05-31 07:35:19 +0200 | [diff] [blame] | 262 | if (efi_validate_time(time)) { |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 263 | ret = EFI_INVALID_PARAMETER; |
| 264 | goto out; |
| 265 | } |
| 266 | |
| 267 | if (uclass_get_device(UCLASS_RTC, 0, &dev)) { |
| 268 | ret = EFI_UNSUPPORTED; |
| 269 | goto out; |
| 270 | } |
| 271 | |
| 272 | memset(&tm, 0, sizeof(tm)); |
| 273 | tm.tm_year = time->year; |
| 274 | tm.tm_mon = time->month; |
| 275 | tm.tm_mday = time->day; |
| 276 | tm.tm_hour = time->hour; |
| 277 | tm.tm_min = time->minute; |
| 278 | tm.tm_sec = time->second; |
| 279 | tm.tm_isdst = time->daylight == EFI_TIME_IN_DAYLIGHT; |
| 280 | /* Calculate day of week */ |
| 281 | rtc_calc_weekday(&tm); |
| 282 | |
| 283 | if (dm_rtc_set(dev, &tm)) |
| 284 | ret = EFI_DEVICE_ERROR; |
| 285 | out: |
| 286 | return EFI_EXIT(ret); |
| 287 | #else |
| 288 | EFI_ENTRY("%p", time); |
| 289 | return EFI_EXIT(EFI_UNSUPPORTED); |
| 290 | #endif |
| 291 | } |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 292 | /** |
| 293 | * efi_reset_system() - reset system |
| 294 | * |
| 295 | * This function implements the ResetSystem() runtime service after |
| 296 | * SetVirtualAddressMap() is called. It only executes an endless loop. |
| 297 | * Boards may override the helpers below to implement reset functionality. |
| 298 | * |
| 299 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 300 | * details. |
| 301 | * |
| 302 | * @reset_type: type of reset to perform |
| 303 | * @reset_status: status code for the reset |
| 304 | * @data_size: size of reset_data |
| 305 | * @reset_data: information about the reset |
| 306 | */ |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 307 | void __weak __efi_runtime EFIAPI efi_reset_system( |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 308 | enum efi_reset_type reset_type, |
| 309 | efi_status_t reset_status, |
| 310 | unsigned long data_size, void *reset_data) |
| 311 | { |
| 312 | /* Nothing we can do */ |
| 313 | while (1) { } |
| 314 | } |
| 315 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 316 | /** |
| 317 | * efi_reset_system_init() - initialize the reset driver |
| 318 | * |
| 319 | * Boards may override this function to initialize the reset driver. |
| 320 | */ |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 321 | efi_status_t __weak efi_reset_system_init(void) |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 322 | { |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 323 | return EFI_SUCCESS; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 324 | } |
| 325 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 326 | /** |
| 327 | * efi_get_time() - get current time |
| 328 | * |
| 329 | * This function implements the GetTime runtime service after |
| 330 | * SetVirtualAddressMap() is called. As the U-Boot driver are not available |
| 331 | * anymore only an error code is returned. |
| 332 | * |
| 333 | * See the Unified Extensible Firmware Interface (UEFI) specification |
| 334 | * for details. |
| 335 | * |
| 336 | * @time: pointer to structure to receive current time |
| 337 | * @capabilities: pointer to structure to receive RTC properties |
| 338 | * Returns: status code |
| 339 | */ |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 340 | efi_status_t __weak __efi_runtime EFIAPI efi_get_time( |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 341 | struct efi_time *time, |
| 342 | struct efi_time_cap *capabilities) |
| 343 | { |
| 344 | /* Nothing we can do */ |
| 345 | return EFI_DEVICE_ERROR; |
| 346 | } |
| 347 | |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 348 | /** |
| 349 | * efi_set_time() - set current time |
| 350 | * |
| 351 | * This function implements the SetTime runtime service after |
| 352 | * SetVirtualAddressMap() is called. As the U-Boot driver are not available |
| 353 | * anymore only an error code is returned. |
| 354 | * |
| 355 | * See the Unified Extensible Firmware Interface (UEFI) specification |
| 356 | * for details. |
| 357 | * |
| 358 | * @time: pointer to structure to with current time |
| 359 | * Returns: status code |
| 360 | */ |
| 361 | efi_status_t __weak __efi_runtime EFIAPI efi_set_time(struct efi_time *time) |
| 362 | { |
| 363 | return EFI_UNSUPPORTED; |
| 364 | } |
| 365 | |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 366 | struct efi_runtime_detach_list_struct { |
| 367 | void *ptr; |
| 368 | void *patchto; |
| 369 | }; |
| 370 | |
| 371 | static const struct efi_runtime_detach_list_struct efi_runtime_detach_list[] = { |
| 372 | { |
| 373 | /* do_reset is gone */ |
| 374 | .ptr = &efi_runtime_services.reset_system, |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 375 | .patchto = efi_reset_system, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 376 | }, { |
| 377 | /* invalidate_*cache_all are gone */ |
| 378 | .ptr = &efi_runtime_services.set_virtual_address_map, |
AKASHI Takahiro | d0ae092 | 2018-11-14 16:18:07 +0900 | [diff] [blame] | 379 | .patchto = &efi_unimplemented, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 380 | }, { |
| 381 | /* RTC accessors are gone */ |
| 382 | .ptr = &efi_runtime_services.get_time, |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 383 | .patchto = &efi_get_time, |
Alexander Graf | c59d360 | 2016-05-18 00:54:47 +0200 | [diff] [blame] | 384 | }, { |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 385 | .ptr = &efi_runtime_services.set_time, |
| 386 | .patchto = &efi_set_time, |
| 387 | }, { |
Alexander Graf | c59d360 | 2016-05-18 00:54:47 +0200 | [diff] [blame] | 388 | /* Clean up system table */ |
| 389 | .ptr = &systab.con_in, |
| 390 | .patchto = NULL, |
| 391 | }, { |
| 392 | /* Clean up system table */ |
| 393 | .ptr = &systab.con_out, |
| 394 | .patchto = NULL, |
| 395 | }, { |
| 396 | /* Clean up system table */ |
| 397 | .ptr = &systab.std_err, |
| 398 | .patchto = NULL, |
| 399 | }, { |
| 400 | /* Clean up system table */ |
| 401 | .ptr = &systab.boottime, |
| 402 | .patchto = NULL, |
Rob Clark | 15f3d74 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 403 | }, { |
| 404 | .ptr = &efi_runtime_services.get_variable, |
| 405 | .patchto = &efi_device_error, |
| 406 | }, { |
Heinrich Schuchardt | d6a6baa | 2018-05-17 07:57:05 +0200 | [diff] [blame] | 407 | .ptr = &efi_runtime_services.get_next_variable_name, |
Rob Clark | 15f3d74 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 408 | .patchto = &efi_device_error, |
| 409 | }, { |
| 410 | .ptr = &efi_runtime_services.set_variable, |
| 411 | .patchto = &efi_device_error, |
| 412 | } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 413 | }; |
| 414 | |
| 415 | static bool efi_runtime_tobedetached(void *p) |
| 416 | { |
| 417 | int i; |
| 418 | |
| 419 | for (i = 0; i < ARRAY_SIZE(efi_runtime_detach_list); i++) |
| 420 | if (efi_runtime_detach_list[i].ptr == p) |
| 421 | return true; |
| 422 | |
| 423 | return false; |
| 424 | } |
| 425 | |
| 426 | static void efi_runtime_detach(ulong offset) |
| 427 | { |
| 428 | int i; |
| 429 | ulong patchoff = offset - (ulong)gd->relocaddr; |
| 430 | |
| 431 | for (i = 0; i < ARRAY_SIZE(efi_runtime_detach_list); i++) { |
| 432 | ulong patchto = (ulong)efi_runtime_detach_list[i].patchto; |
| 433 | ulong *p = efi_runtime_detach_list[i].ptr; |
| 434 | ulong newaddr = patchto ? (patchto + patchoff) : 0; |
| 435 | |
Alexander Graf | 62a6748 | 2016-06-02 11:38:27 +0200 | [diff] [blame] | 436 | debug("%s: Setting %p to %lx\n", __func__, p, newaddr); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 437 | *p = newaddr; |
| 438 | } |
Heinrich Schuchardt | 69c1576 | 2018-07-29 09:49:04 +0200 | [diff] [blame] | 439 | |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 440 | /* Update CRC32 */ |
Heinrich Schuchardt | 69c1576 | 2018-07-29 09:49:04 +0200 | [diff] [blame] | 441 | efi_update_table_header_crc32(&efi_runtime_services.hdr); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | /* Relocate EFI runtime to uboot_reloc_base = offset */ |
| 445 | void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) |
| 446 | { |
| 447 | #ifdef IS_RELA |
| 448 | struct elf_rela *rel = (void*)&__efi_runtime_rel_start; |
| 449 | #else |
| 450 | struct elf_rel *rel = (void*)&__efi_runtime_rel_start; |
| 451 | static ulong lastoff = CONFIG_SYS_TEXT_BASE; |
| 452 | #endif |
| 453 | |
Alexander Graf | 62a6748 | 2016-06-02 11:38:27 +0200 | [diff] [blame] | 454 | debug("%s: Relocating to offset=%lx\n", __func__, offset); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 455 | for (; (ulong)rel < (ulong)&__efi_runtime_rel_stop; rel++) { |
| 456 | ulong base = CONFIG_SYS_TEXT_BASE; |
| 457 | ulong *p; |
| 458 | ulong newaddr; |
| 459 | |
| 460 | p = (void*)((ulong)rel->offset - base) + gd->relocaddr; |
| 461 | |
Heinrich Schuchardt | 56e82be | 2018-10-13 20:52:08 -0700 | [diff] [blame] | 462 | debug("%s: rel->info=%#lx *p=%#lx rel->offset=%p\n", __func__, |
| 463 | rel->info, *p, rel->offset); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 464 | |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 465 | switch (rel->info & R_MASK) { |
| 466 | case R_RELATIVE: |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 467 | #ifdef IS_RELA |
| 468 | newaddr = rel->addend + offset - CONFIG_SYS_TEXT_BASE; |
| 469 | #else |
| 470 | newaddr = *p - lastoff + offset; |
| 471 | #endif |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 472 | break; |
| 473 | #ifdef R_ABSOLUTE |
| 474 | case R_ABSOLUTE: { |
| 475 | ulong symidx = rel->info >> SYM_INDEX; |
| 476 | extern struct dyn_sym __dyn_sym_start[]; |
| 477 | newaddr = __dyn_sym_start[symidx].addr + offset; |
Alexander Graf | df0f6c7 | 2018-11-04 22:25:22 +0100 | [diff] [blame] | 478 | #ifdef IS_RELA |
| 479 | newaddr -= CONFIG_SYS_TEXT_BASE; |
| 480 | #endif |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 481 | break; |
| 482 | } |
| 483 | #endif |
| 484 | default: |
Heinrich Schuchardt | 56e82be | 2018-10-13 20:52:08 -0700 | [diff] [blame] | 485 | if (!efi_runtime_tobedetached(p)) |
| 486 | printf("%s: Unknown relocation type %llx\n", |
| 487 | __func__, rel->info & R_MASK); |
Rick Chen | 9677a37 | 2018-05-28 19:06:37 +0800 | [diff] [blame] | 488 | continue; |
| 489 | } |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 490 | |
| 491 | /* Check if the relocation is inside bounds */ |
| 492 | if (map && ((newaddr < map->virtual_start) || |
Heinrich Schuchardt | 9ebc47f | 2017-09-18 22:11:34 +0200 | [diff] [blame] | 493 | newaddr > (map->virtual_start + |
| 494 | (map->num_pages << EFI_PAGE_SHIFT)))) { |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 495 | if (!efi_runtime_tobedetached(p)) |
Heinrich Schuchardt | 56e82be | 2018-10-13 20:52:08 -0700 | [diff] [blame] | 496 | printf("%s: Relocation at %p is out of " |
| 497 | "range (%lx)\n", __func__, p, newaddr); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 498 | continue; |
| 499 | } |
| 500 | |
Alexander Graf | 62a6748 | 2016-06-02 11:38:27 +0200 | [diff] [blame] | 501 | debug("%s: Setting %p to %lx\n", __func__, p, newaddr); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 502 | *p = newaddr; |
Alexander Graf | e570232 | 2016-04-11 23:20:39 +0200 | [diff] [blame] | 503 | flush_dcache_range((ulong)p & ~(EFI_CACHELINE_SIZE - 1), |
| 504 | ALIGN((ulong)&p[1], EFI_CACHELINE_SIZE)); |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | #ifndef IS_RELA |
| 508 | lastoff = offset; |
| 509 | #endif |
| 510 | |
| 511 | invalidate_icache_all(); |
| 512 | } |
| 513 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 514 | /** |
| 515 | * efi_set_virtual_address_map() - change from physical to virtual mapping |
| 516 | * |
| 517 | * This function implements the SetVirtualAddressMap() runtime service. |
| 518 | * |
| 519 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 520 | * details. |
| 521 | * |
| 522 | * @memory_map_size: size of the virtual map |
| 523 | * @descriptor_size: size of an entry in the map |
| 524 | * @descriptor_version: version of the map entries |
| 525 | * @virtmap: virtual address mapping information |
| 526 | * Return: status code |
| 527 | */ |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 528 | static efi_status_t EFIAPI efi_set_virtual_address_map( |
| 529 | unsigned long memory_map_size, |
| 530 | unsigned long descriptor_size, |
| 531 | uint32_t descriptor_version, |
| 532 | struct efi_mem_desc *virtmap) |
| 533 | { |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 534 | int n = memory_map_size / descriptor_size; |
| 535 | int i; |
Alexander Graf | 86e0021 | 2018-12-11 10:00:42 +0100 | [diff] [blame] | 536 | int rt_code_sections = 0; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 537 | |
| 538 | EFI_ENTRY("%lx %lx %x %p", memory_map_size, descriptor_size, |
| 539 | descriptor_version, virtmap); |
| 540 | |
Alexander Graf | 86e0021 | 2018-12-11 10:00:42 +0100 | [diff] [blame] | 541 | /* |
| 542 | * TODO: |
| 543 | * Further down we are cheating. While really we should implement |
| 544 | * SetVirtualAddressMap() events and ConvertPointer() to allow |
| 545 | * dynamically loaded drivers to expose runtime services, we don't |
| 546 | * today. |
| 547 | * |
| 548 | * So let's ensure we see exactly one single runtime section, as |
| 549 | * that is the built-in one. If we see more (or less), someone must |
| 550 | * have tried adding or removing to that which we don't support yet. |
| 551 | * In that case, let's better fail rather than expose broken runtime |
| 552 | * services. |
| 553 | */ |
| 554 | for (i = 0; i < n; i++) { |
| 555 | struct efi_mem_desc *map = (void*)virtmap + |
| 556 | (descriptor_size * i); |
| 557 | |
| 558 | if (map->type == EFI_RUNTIME_SERVICES_CODE) |
| 559 | rt_code_sections++; |
| 560 | } |
| 561 | |
| 562 | if (rt_code_sections != 1) { |
| 563 | /* |
| 564 | * We expose exactly one single runtime code section, so |
| 565 | * something is definitely going wrong. |
| 566 | */ |
| 567 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
| 568 | } |
| 569 | |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 570 | /* Rebind mmio pointers */ |
| 571 | for (i = 0; i < n; i++) { |
| 572 | struct efi_mem_desc *map = (void*)virtmap + |
| 573 | (descriptor_size * i); |
| 574 | struct list_head *lhandle; |
| 575 | efi_physical_addr_t map_start = map->physical_start; |
| 576 | efi_physical_addr_t map_len = map->num_pages << EFI_PAGE_SHIFT; |
| 577 | efi_physical_addr_t map_end = map_start + map_len; |
Heinrich Schuchardt | 3905456 | 2018-08-04 23:16:06 +0200 | [diff] [blame] | 578 | u64 off = map->virtual_start - map_start; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 579 | |
| 580 | /* Adjust all mmio pointers in this region */ |
| 581 | list_for_each(lhandle, &efi_runtime_mmio) { |
| 582 | struct efi_runtime_mmio_list *lmmio; |
| 583 | |
| 584 | lmmio = list_entry(lhandle, |
| 585 | struct efi_runtime_mmio_list, |
| 586 | link); |
| 587 | if ((map_start <= lmmio->paddr) && |
| 588 | (map_end >= lmmio->paddr)) { |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 589 | uintptr_t new_addr = lmmio->paddr + off; |
| 590 | *lmmio->ptr = (void *)new_addr; |
| 591 | } |
| 592 | } |
Heinrich Schuchardt | 3905456 | 2018-08-04 23:16:06 +0200 | [diff] [blame] | 593 | if ((map_start <= (uintptr_t)systab.tables) && |
| 594 | (map_end >= (uintptr_t)systab.tables)) { |
| 595 | char *ptr = (char *)systab.tables; |
| 596 | |
| 597 | ptr += off; |
| 598 | systab.tables = (struct efi_configuration_table *)ptr; |
| 599 | } |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | /* Move the actual runtime code over */ |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 603 | for (i = 0; i < n; i++) { |
| 604 | struct efi_mem_desc *map; |
| 605 | |
| 606 | map = (void*)virtmap + (descriptor_size * i); |
| 607 | if (map->type == EFI_RUNTIME_SERVICES_CODE) { |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 608 | ulong new_offset = map->virtual_start - |
Alexander Graf | 86e0021 | 2018-12-11 10:00:42 +0100 | [diff] [blame] | 609 | map->physical_start + gd->relocaddr; |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 610 | |
| 611 | efi_runtime_relocate(new_offset, map); |
| 612 | /* Once we're virtual, we can no longer handle |
| 613 | complex callbacks */ |
| 614 | efi_runtime_detach(new_offset); |
| 615 | return EFI_EXIT(EFI_SUCCESS); |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
| 620 | } |
| 621 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 622 | /** |
| 623 | * efi_add_runtime_mmio() - add memory-mapped IO region |
| 624 | * |
| 625 | * This function adds a memory-mapped IO region to the memory map to make it |
| 626 | * available at runtime. |
| 627 | * |
Heinrich Schuchardt | 7e30764 | 2018-12-23 02:35:13 +0100 | [diff] [blame] | 628 | * @mmio_ptr: pointer to a pointer to the start of the memory-mapped |
| 629 | * IO region |
Heinrich Schuchardt | 1112154 | 2018-09-03 19:29:41 +0200 | [diff] [blame] | 630 | * @len: size of the memory-mapped IO region |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 631 | * Returns: status code |
| 632 | */ |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 633 | efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len) |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 634 | { |
| 635 | struct efi_runtime_mmio_list *newmmio; |
xypron.glpk@gmx.de | 93fcc7f | 2017-08-11 21:19:37 +0200 | [diff] [blame] | 636 | u64 pages = (len + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; |
Alexander Graf | 33a83a3 | 2018-03-15 15:08:16 +0100 | [diff] [blame] | 637 | uint64_t addr = *(uintptr_t *)mmio_ptr; |
| 638 | uint64_t retaddr; |
| 639 | |
| 640 | retaddr = efi_add_memory_map(addr, pages, EFI_MMAP_IO, false); |
| 641 | if (retaddr != addr) |
| 642 | return EFI_OUT_OF_RESOURCES; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 643 | |
| 644 | newmmio = calloc(1, sizeof(*newmmio)); |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 645 | if (!newmmio) |
| 646 | return EFI_OUT_OF_RESOURCES; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 647 | newmmio->ptr = mmio_ptr; |
| 648 | newmmio->paddr = *(uintptr_t *)mmio_ptr; |
| 649 | newmmio->len = len; |
| 650 | list_add_tail(&newmmio->link, &efi_runtime_mmio); |
Heinrich Schuchardt | 099b3b7 | 2018-03-03 15:28:59 +0100 | [diff] [blame] | 651 | |
Alexander Graf | 33a83a3 | 2018-03-15 15:08:16 +0100 | [diff] [blame] | 652 | return EFI_SUCCESS; |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 653 | } |
| 654 | |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 655 | /* |
| 656 | * In the second stage, U-Boot has disappeared. To isolate our runtime code |
| 657 | * that at this point still exists from the rest, we put it into a special |
| 658 | * section. |
| 659 | * |
| 660 | * !!WARNING!! |
| 661 | * |
| 662 | * This means that we can not rely on any code outside of this file in any |
| 663 | * function or variable below this line. |
| 664 | * |
| 665 | * Please keep everything fully self-contained and annotated with |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 666 | * __efi_runtime and __efi_runtime_data markers. |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 667 | */ |
| 668 | |
| 669 | /* |
| 670 | * Relocate the EFI runtime stub to a different place. We need to call this |
| 671 | * the first time we expose the runtime interface to a user and on set virtual |
| 672 | * address map calls. |
| 673 | */ |
| 674 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 675 | /** |
| 676 | * efi_unimplemented() - replacement function, returns EFI_UNSUPPORTED |
| 677 | * |
| 678 | * This function is used after SetVirtualAddressMap() is called as replacement |
| 679 | * for services that are not available anymore due to constraints of the U-Boot |
| 680 | * implementation. |
| 681 | * |
| 682 | * Return: EFI_UNSUPPORTED |
| 683 | */ |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 684 | static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 685 | { |
| 686 | return EFI_UNSUPPORTED; |
| 687 | } |
| 688 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 689 | /** |
| 690 | * efi_device_error() - replacement function, returns EFI_DEVICE_ERROR |
| 691 | * |
| 692 | * This function is used after SetVirtualAddressMap() is called as replacement |
| 693 | * for services that are not available anymore due to constraints of the U-Boot |
| 694 | * implementation. |
| 695 | * |
| 696 | * Return: EFI_DEVICE_ERROR |
| 697 | */ |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 698 | static efi_status_t __efi_runtime EFIAPI efi_device_error(void) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 699 | { |
| 700 | return EFI_DEVICE_ERROR; |
| 701 | } |
| 702 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 703 | /** |
| 704 | * efi_invalid_parameter() - replacement function, returns EFI_INVALID_PARAMETER |
| 705 | * |
| 706 | * This function is used after SetVirtualAddressMap() is called as replacement |
| 707 | * for services that are not available anymore due to constraints of the U-Boot |
| 708 | * implementation. |
| 709 | * |
| 710 | * Return: EFI_INVALID_PARAMETER |
| 711 | */ |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 712 | static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void) |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 713 | { |
| 714 | return EFI_INVALID_PARAMETER; |
| 715 | } |
| 716 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 717 | /** |
| 718 | * efi_update_capsule() - process information from operating system |
| 719 | * |
| 720 | * This function implements the UpdateCapsule() runtime service. |
| 721 | * |
| 722 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 723 | * details. |
| 724 | * |
| 725 | * @capsule_header_array: pointer to array of virtual pointers |
| 726 | * @capsule_count: number of pointers in capsule_header_array |
| 727 | * @scatter_gather_list: pointer to arry of physical pointers |
| 728 | * Returns: status code |
| 729 | */ |
Heinrich Schuchardt | 897c072 | 2018-02-09 20:41:21 +0100 | [diff] [blame] | 730 | efi_status_t __efi_runtime EFIAPI efi_update_capsule( |
| 731 | struct efi_capsule_header **capsule_header_array, |
| 732 | efi_uintn_t capsule_count, |
| 733 | u64 scatter_gather_list) |
| 734 | { |
| 735 | return EFI_UNSUPPORTED; |
| 736 | } |
| 737 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 738 | /** |
| 739 | * efi_query_capsule_caps() - check if capsule is supported |
| 740 | * |
| 741 | * This function implements the QueryCapsuleCapabilities() runtime service. |
| 742 | * |
| 743 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 744 | * details. |
| 745 | * |
| 746 | * @capsule_header_array: pointer to array of virtual pointers |
| 747 | * @capsule_count: number of pointers in capsule_header_array |
Heinrich Schuchardt | 1d1be36 | 2018-09-03 20:59:25 +0200 | [diff] [blame] | 748 | * @maximum_capsule_size: maximum capsule size |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 749 | * @reset_type: type of reset needed for capsule update |
| 750 | * Returns: status code |
| 751 | */ |
Heinrich Schuchardt | 897c072 | 2018-02-09 20:41:21 +0100 | [diff] [blame] | 752 | efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps( |
| 753 | struct efi_capsule_header **capsule_header_array, |
| 754 | efi_uintn_t capsule_count, |
AKASHI Takahiro | d840b67 | 2018-11-14 16:18:53 +0900 | [diff] [blame] | 755 | u64 *maximum_capsule_size, |
| 756 | u32 *reset_type) |
Heinrich Schuchardt | 897c072 | 2018-02-09 20:41:21 +0100 | [diff] [blame] | 757 | { |
| 758 | return EFI_UNSUPPORTED; |
| 759 | } |
| 760 | |
Heinrich Schuchardt | 711853b | 2018-07-29 15:10:11 +0200 | [diff] [blame] | 761 | /** |
| 762 | * efi_query_variable_info() - get information about EFI variables |
| 763 | * |
| 764 | * This function implements the QueryVariableInfo() runtime service. |
| 765 | * |
| 766 | * See the Unified Extensible Firmware Interface (UEFI) specification for |
| 767 | * details. |
| 768 | * |
| 769 | * @attributes: bitmask to select variables to be |
| 770 | * queried |
| 771 | * @maximum_variable_storage_size: maximum size of storage area for the |
| 772 | * selected variable types |
| 773 | * @remaining_variable_storage_size: remaining size of storage are for the |
| 774 | * selected variable types |
| 775 | * @maximum_variable_size: maximum size of a variable of the |
| 776 | * selected type |
| 777 | * Returns: status code |
| 778 | */ |
Heinrich Schuchardt | 897c072 | 2018-02-09 20:41:21 +0100 | [diff] [blame] | 779 | efi_status_t __efi_runtime EFIAPI efi_query_variable_info( |
| 780 | u32 attributes, |
Heinrich Schuchardt | d6a6baa | 2018-05-17 07:57:05 +0200 | [diff] [blame] | 781 | u64 *maximum_variable_storage_size, |
| 782 | u64 *remaining_variable_storage_size, |
| 783 | u64 *maximum_variable_size) |
Heinrich Schuchardt | 897c072 | 2018-02-09 20:41:21 +0100 | [diff] [blame] | 784 | { |
| 785 | return EFI_UNSUPPORTED; |
| 786 | } |
| 787 | |
Alexander Graf | 393dd91 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 788 | struct efi_runtime_services __efi_runtime_data efi_runtime_services = { |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 789 | .hdr = { |
| 790 | .signature = EFI_RUNTIME_SERVICES_SIGNATURE, |
Heinrich Schuchardt | e75b3cb | 2018-06-28 12:45:27 +0200 | [diff] [blame] | 791 | .revision = EFI_SPECIFICATION_VERSION, |
Heinrich Schuchardt | 1020425 | 2018-06-28 12:45:29 +0200 | [diff] [blame] | 792 | .headersize = sizeof(struct efi_runtime_services), |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 793 | }, |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 794 | .get_time = &efi_get_time_boottime, |
Heinrich Schuchardt | 411b2d5 | 2019-05-19 20:07:39 +0200 | [diff] [blame] | 795 | .set_time = &efi_set_time_boottime, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 796 | .get_wakeup_time = (void *)&efi_unimplemented, |
| 797 | .set_wakeup_time = (void *)&efi_unimplemented, |
| 798 | .set_virtual_address_map = &efi_set_virtual_address_map, |
| 799 | .convert_pointer = (void *)&efi_invalid_parameter, |
Rob Clark | 15f3d74 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 800 | .get_variable = efi_get_variable, |
Heinrich Schuchardt | d6a6baa | 2018-05-17 07:57:05 +0200 | [diff] [blame] | 801 | .get_next_variable_name = efi_get_next_variable_name, |
Rob Clark | 15f3d74 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 802 | .set_variable = efi_set_variable, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 803 | .get_next_high_mono_count = (void *)&efi_device_error, |
Alexander Graf | 7725609 | 2016-08-16 21:08:45 +0200 | [diff] [blame] | 804 | .reset_system = &efi_reset_system_boottime, |
Heinrich Schuchardt | 897c072 | 2018-02-09 20:41:21 +0100 | [diff] [blame] | 805 | .update_capsule = efi_update_capsule, |
| 806 | .query_capsule_caps = efi_query_capsule_caps, |
| 807 | .query_variable_info = efi_query_variable_info, |
Alexander Graf | 0bd425a | 2016-03-04 01:10:01 +0100 | [diff] [blame] | 808 | }; |