Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1 | /* |
| 2 | * EFI application boot time services |
| 3 | * |
| 4 | * Copyright (c) 2016 Alexander Graf |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 9 | #include <common.h> |
| 10 | #include <efi_loader.h> |
Rob Clark | ad644e7 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 11 | #include <environment.h> |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 12 | #include <malloc.h> |
| 13 | #include <asm/global_data.h> |
| 14 | #include <libfdt_env.h> |
| 15 | #include <u-boot/crc.h> |
| 16 | #include <bootm.h> |
| 17 | #include <inttypes.h> |
| 18 | #include <watchdog.h> |
| 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Heinrich Schuchardt | 32f4b2f | 2017-09-15 10:06:16 +0200 | [diff] [blame] | 22 | /* Task priority level */ |
| 23 | static UINTN efi_tpl = TPL_APPLICATION; |
| 24 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 25 | /* This list contains all the EFI objects our payload has access to */ |
| 26 | LIST_HEAD(efi_obj_list); |
| 27 | |
| 28 | /* |
| 29 | * If we're running on nasty systems (32bit ARM booting into non-EFI Linux) |
| 30 | * we need to do trickery with caches. Since we don't want to break the EFI |
| 31 | * aware boot path, only apply hacks when loading exiting directly (breaking |
| 32 | * direct Linux EFI booting along the way - oh well). |
| 33 | */ |
| 34 | static bool efi_is_direct_boot = true; |
| 35 | |
| 36 | /* |
| 37 | * EFI can pass arbitrary additional "tables" containing vendor specific |
| 38 | * information to the payload. One such table is the FDT table which contains |
| 39 | * a pointer to a flattened device tree blob. |
| 40 | * |
| 41 | * In most cases we want to pass an FDT to the payload, so reserve one slot of |
| 42 | * config table space for it. The pointer gets populated by do_bootefi_exec(). |
| 43 | */ |
Alexander Graf | 3c63db9 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 44 | static struct efi_configuration_table __efi_runtime_data efi_conf_table[2]; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 45 | |
Simon Glass | 65e4c0b | 2016-09-25 15:27:35 -0600 | [diff] [blame] | 46 | #ifdef CONFIG_ARM |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 47 | /* |
| 48 | * The "gd" pointer lives in a register on ARM and AArch64 that we declare |
| 49 | * fixed when compiling U-Boot. However, the payload does not know about that |
| 50 | * restriction so we need to manually swap its and our view of that register on |
| 51 | * EFI callback entry/exit. |
| 52 | */ |
| 53 | static volatile void *efi_gd, *app_gd; |
Simon Glass | 65e4c0b | 2016-09-25 15:27:35 -0600 | [diff] [blame] | 54 | #endif |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 55 | |
Rob Clark | c160d2f | 2017-07-27 08:04:18 -0400 | [diff] [blame] | 56 | static int entry_count; |
Rob Clark | af65db8 | 2017-07-27 08:04:19 -0400 | [diff] [blame] | 57 | static int nesting_level; |
Rob Clark | c160d2f | 2017-07-27 08:04:18 -0400 | [diff] [blame] | 58 | |
| 59 | /* Called on every callback entry */ |
| 60 | int __efi_entry_check(void) |
| 61 | { |
| 62 | int ret = entry_count++ == 0; |
| 63 | #ifdef CONFIG_ARM |
| 64 | assert(efi_gd); |
| 65 | app_gd = gd; |
| 66 | gd = efi_gd; |
| 67 | #endif |
| 68 | return ret; |
| 69 | } |
| 70 | |
| 71 | /* Called on every callback exit */ |
| 72 | int __efi_exit_check(void) |
| 73 | { |
| 74 | int ret = --entry_count == 0; |
| 75 | #ifdef CONFIG_ARM |
| 76 | gd = app_gd; |
| 77 | #endif |
| 78 | return ret; |
| 79 | } |
| 80 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 81 | /* Called from do_bootefi_exec() */ |
| 82 | void efi_save_gd(void) |
| 83 | { |
Simon Glass | 65e4c0b | 2016-09-25 15:27:35 -0600 | [diff] [blame] | 84 | #ifdef CONFIG_ARM |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 85 | efi_gd = gd; |
Simon Glass | 65e4c0b | 2016-09-25 15:27:35 -0600 | [diff] [blame] | 86 | #endif |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 87 | } |
| 88 | |
Rob Clark | c160d2f | 2017-07-27 08:04:18 -0400 | [diff] [blame] | 89 | /* |
| 90 | * Special case handler for error/abort that just forces things back |
| 91 | * to u-boot world so we can dump out an abort msg, without any care |
| 92 | * about returning back to UEFI world. |
| 93 | */ |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 94 | void efi_restore_gd(void) |
| 95 | { |
Simon Glass | 65e4c0b | 2016-09-25 15:27:35 -0600 | [diff] [blame] | 96 | #ifdef CONFIG_ARM |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 97 | /* Only restore if we're already in EFI context */ |
| 98 | if (!efi_gd) |
| 99 | return; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 100 | gd = efi_gd; |
Simon Glass | 65e4c0b | 2016-09-25 15:27:35 -0600 | [diff] [blame] | 101 | #endif |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 102 | } |
| 103 | |
Rob Clark | af65db8 | 2017-07-27 08:04:19 -0400 | [diff] [blame] | 104 | /* |
| 105 | * Two spaces per indent level, maxing out at 10.. which ought to be |
| 106 | * enough for anyone ;-) |
| 107 | */ |
| 108 | static const char *indent_string(int level) |
| 109 | { |
| 110 | const char *indent = " "; |
| 111 | const int max = strlen(indent); |
| 112 | level = min(max, level * 2); |
| 113 | return &indent[max - level]; |
| 114 | } |
| 115 | |
Heinrich Schuchardt | ae0bd3a | 2017-08-18 17:45:16 +0200 | [diff] [blame] | 116 | const char *__efi_nesting(void) |
| 117 | { |
| 118 | return indent_string(nesting_level); |
| 119 | } |
| 120 | |
Rob Clark | af65db8 | 2017-07-27 08:04:19 -0400 | [diff] [blame] | 121 | const char *__efi_nesting_inc(void) |
| 122 | { |
| 123 | return indent_string(nesting_level++); |
| 124 | } |
| 125 | |
| 126 | const char *__efi_nesting_dec(void) |
| 127 | { |
| 128 | return indent_string(--nesting_level); |
| 129 | } |
| 130 | |
xypron.glpk@gmx.de | 8787b02 | 2017-07-18 20:17:23 +0200 | [diff] [blame] | 131 | /* Low 32 bit */ |
| 132 | #define EFI_LOW32(a) (a & 0xFFFFFFFFULL) |
| 133 | /* High 32 bit */ |
| 134 | #define EFI_HIGH32(a) (a >> 32) |
| 135 | |
| 136 | /* |
| 137 | * 64bit division by 10 implemented as multiplication by 1 / 10 |
| 138 | * |
| 139 | * Decimals of one tenth: 0x1 / 0xA = 0x0.19999... |
| 140 | */ |
| 141 | #define EFI_TENTH 0x199999999999999A |
| 142 | static u64 efi_div10(u64 a) |
| 143 | { |
| 144 | u64 prod; |
| 145 | u64 rem; |
| 146 | u64 ret; |
| 147 | |
| 148 | ret = EFI_HIGH32(a) * EFI_HIGH32(EFI_TENTH); |
| 149 | prod = EFI_HIGH32(a) * EFI_LOW32(EFI_TENTH); |
| 150 | rem = EFI_LOW32(prod); |
| 151 | ret += EFI_HIGH32(prod); |
| 152 | prod = EFI_LOW32(a) * EFI_HIGH32(EFI_TENTH); |
| 153 | rem += EFI_LOW32(prod); |
| 154 | ret += EFI_HIGH32(prod); |
| 155 | prod = EFI_LOW32(a) * EFI_LOW32(EFI_TENTH); |
| 156 | rem += EFI_HIGH32(prod); |
| 157 | ret += EFI_HIGH32(rem); |
| 158 | /* Round to nearest integer */ |
| 159 | if (rem >= (1 << 31)) |
| 160 | ++ret; |
| 161 | return ret; |
| 162 | } |
| 163 | |
xypron.glpk@gmx.de | 91be9a7 | 2017-07-18 20:17:22 +0200 | [diff] [blame] | 164 | void efi_signal_event(struct efi_event *event) |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 165 | { |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 166 | if (event->notify_function) { |
| 167 | event->queued = 1; |
Heinrich Schuchardt | 32f4b2f | 2017-09-15 10:06:16 +0200 | [diff] [blame] | 168 | /* Check TPL */ |
| 169 | if (efi_tpl >= event->notify_tpl) |
| 170 | return; |
Heinrich Schuchardt | ea630ce | 2017-09-15 10:06:10 +0200 | [diff] [blame] | 171 | EFI_CALL_VOID(event->notify_function(event, |
| 172 | event->notify_context)); |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 173 | } |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 174 | event->queued = 0; |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 175 | } |
| 176 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 177 | static efi_status_t efi_unsupported(const char *funcname) |
| 178 | { |
Alexander Graf | edcef3b | 2016-06-02 11:38:27 +0200 | [diff] [blame] | 179 | debug("EFI: App called into unimplemented function %s\n", funcname); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 180 | return EFI_EXIT(EFI_UNSUPPORTED); |
| 181 | } |
| 182 | |
xypron.glpk@gmx.de | 503f269 | 2017-07-18 20:17:19 +0200 | [diff] [blame] | 183 | static unsigned long EFIAPI efi_raise_tpl(UINTN new_tpl) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 184 | { |
Heinrich Schuchardt | 32f4b2f | 2017-09-15 10:06:16 +0200 | [diff] [blame] | 185 | UINTN old_tpl = efi_tpl; |
| 186 | |
xypron.glpk@gmx.de | 503f269 | 2017-07-18 20:17:19 +0200 | [diff] [blame] | 187 | EFI_ENTRY("0x%zx", new_tpl); |
Heinrich Schuchardt | 32f4b2f | 2017-09-15 10:06:16 +0200 | [diff] [blame] | 188 | |
| 189 | if (new_tpl < efi_tpl) |
| 190 | debug("WARNING: new_tpl < current_tpl in %s\n", __func__); |
| 191 | efi_tpl = new_tpl; |
| 192 | if (efi_tpl > TPL_HIGH_LEVEL) |
| 193 | efi_tpl = TPL_HIGH_LEVEL; |
| 194 | |
| 195 | EFI_EXIT(EFI_SUCCESS); |
| 196 | return old_tpl; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 197 | } |
| 198 | |
xypron.glpk@gmx.de | 503f269 | 2017-07-18 20:17:19 +0200 | [diff] [blame] | 199 | static void EFIAPI efi_restore_tpl(UINTN old_tpl) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 200 | { |
xypron.glpk@gmx.de | 503f269 | 2017-07-18 20:17:19 +0200 | [diff] [blame] | 201 | EFI_ENTRY("0x%zx", old_tpl); |
Heinrich Schuchardt | 32f4b2f | 2017-09-15 10:06:16 +0200 | [diff] [blame] | 202 | |
| 203 | if (old_tpl > efi_tpl) |
| 204 | debug("WARNING: old_tpl > current_tpl in %s\n", __func__); |
| 205 | efi_tpl = old_tpl; |
| 206 | if (efi_tpl > TPL_HIGH_LEVEL) |
| 207 | efi_tpl = TPL_HIGH_LEVEL; |
| 208 | |
| 209 | EFI_EXIT(EFI_SUCCESS); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 210 | } |
| 211 | |
Masahiro Yamada | 6e0bf8d | 2017-06-22 17:49:03 +0900 | [diff] [blame] | 212 | static efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type, |
| 213 | unsigned long pages, |
| 214 | uint64_t *memory) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 215 | { |
| 216 | efi_status_t r; |
| 217 | |
| 218 | EFI_ENTRY("%d, %d, 0x%lx, %p", type, memory_type, pages, memory); |
| 219 | r = efi_allocate_pages(type, memory_type, pages, memory); |
| 220 | return EFI_EXIT(r); |
| 221 | } |
| 222 | |
Masahiro Yamada | 6e0bf8d | 2017-06-22 17:49:03 +0900 | [diff] [blame] | 223 | static efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory, |
| 224 | unsigned long pages) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 225 | { |
| 226 | efi_status_t r; |
| 227 | |
| 228 | EFI_ENTRY("%"PRIx64", 0x%lx", memory, pages); |
| 229 | r = efi_free_pages(memory, pages); |
| 230 | return EFI_EXIT(r); |
| 231 | } |
| 232 | |
Masahiro Yamada | 6e0bf8d | 2017-06-22 17:49:03 +0900 | [diff] [blame] | 233 | static efi_status_t EFIAPI efi_get_memory_map_ext( |
| 234 | unsigned long *memory_map_size, |
| 235 | struct efi_mem_desc *memory_map, |
| 236 | unsigned long *map_key, |
| 237 | unsigned long *descriptor_size, |
| 238 | uint32_t *descriptor_version) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 239 | { |
| 240 | efi_status_t r; |
| 241 | |
| 242 | EFI_ENTRY("%p, %p, %p, %p, %p", memory_map_size, memory_map, |
| 243 | map_key, descriptor_size, descriptor_version); |
| 244 | r = efi_get_memory_map(memory_map_size, memory_map, map_key, |
| 245 | descriptor_size, descriptor_version); |
| 246 | return EFI_EXIT(r); |
| 247 | } |
| 248 | |
Stefan Brüns | ead1274 | 2016-10-09 22:17:18 +0200 | [diff] [blame] | 249 | static efi_status_t EFIAPI efi_allocate_pool_ext(int pool_type, |
| 250 | unsigned long size, |
| 251 | void **buffer) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 252 | { |
Alexander Graf | 1cd29f0 | 2016-03-24 01:37:37 +0100 | [diff] [blame] | 253 | efi_status_t r; |
| 254 | |
| 255 | EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer); |
Stefan Brüns | ead1274 | 2016-10-09 22:17:18 +0200 | [diff] [blame] | 256 | r = efi_allocate_pool(pool_type, size, buffer); |
Alexander Graf | 1cd29f0 | 2016-03-24 01:37:37 +0100 | [diff] [blame] | 257 | return EFI_EXIT(r); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 258 | } |
| 259 | |
Stefan Brüns | 42417bc | 2016-10-09 22:17:26 +0200 | [diff] [blame] | 260 | static efi_status_t EFIAPI efi_free_pool_ext(void *buffer) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 261 | { |
Alexander Graf | 1cd29f0 | 2016-03-24 01:37:37 +0100 | [diff] [blame] | 262 | efi_status_t r; |
| 263 | |
| 264 | EFI_ENTRY("%p", buffer); |
Stefan Brüns | 42417bc | 2016-10-09 22:17:26 +0200 | [diff] [blame] | 265 | r = efi_free_pool(buffer); |
Alexander Graf | 1cd29f0 | 2016-03-24 01:37:37 +0100 | [diff] [blame] | 266 | return EFI_EXIT(r); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 267 | } |
| 268 | |
Heinrich Schuchardt | 3cc6e3f | 2017-08-27 00:51:09 +0200 | [diff] [blame^] | 269 | static efi_status_t efi_create_handle(void **handle) |
| 270 | { |
| 271 | struct efi_object *obj; |
| 272 | efi_status_t r; |
| 273 | |
| 274 | r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, |
| 275 | sizeof(struct efi_object), |
| 276 | (void **)&obj); |
| 277 | if (r != EFI_SUCCESS) |
| 278 | return r; |
| 279 | memset(obj, 0, sizeof(struct efi_object)); |
| 280 | obj->handle = obj; |
| 281 | list_add_tail(&obj->link, &efi_obj_list); |
| 282 | *handle = obj; |
| 283 | return r; |
| 284 | } |
| 285 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 286 | /* |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 287 | * Our event capabilities are very limited. Only a small limited |
| 288 | * number of events is allowed to coexist. |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 289 | */ |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 290 | static struct efi_event efi_events[16]; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 291 | |
xypron.glpk@gmx.de | b521d29 | 2017-07-19 19:22:34 +0200 | [diff] [blame] | 292 | efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl, |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 293 | void (EFIAPI *notify_function) ( |
xypron.glpk@gmx.de | 2fd945f | 2017-07-18 20:17:17 +0200 | [diff] [blame] | 294 | struct efi_event *event, |
| 295 | void *context), |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 296 | void *notify_context, struct efi_event **event) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 297 | { |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 298 | int i; |
| 299 | |
Jonathan Gray | a95343b | 2017-03-12 19:26:07 +1100 | [diff] [blame] | 300 | if (event == NULL) |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 301 | return EFI_INVALID_PARAMETER; |
Jonathan Gray | a95343b | 2017-03-12 19:26:07 +1100 | [diff] [blame] | 302 | |
| 303 | if ((type & EVT_NOTIFY_SIGNAL) && (type & EVT_NOTIFY_WAIT)) |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 304 | return EFI_INVALID_PARAMETER; |
Jonathan Gray | a95343b | 2017-03-12 19:26:07 +1100 | [diff] [blame] | 305 | |
| 306 | if ((type & (EVT_NOTIFY_SIGNAL|EVT_NOTIFY_WAIT)) && |
| 307 | notify_function == NULL) |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 308 | return EFI_INVALID_PARAMETER; |
Jonathan Gray | a95343b | 2017-03-12 19:26:07 +1100 | [diff] [blame] | 309 | |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 310 | for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { |
| 311 | if (efi_events[i].type) |
| 312 | continue; |
| 313 | efi_events[i].type = type; |
| 314 | efi_events[i].notify_tpl = notify_tpl; |
| 315 | efi_events[i].notify_function = notify_function; |
| 316 | efi_events[i].notify_context = notify_context; |
| 317 | /* Disable timers on bootup */ |
| 318 | efi_events[i].trigger_next = -1ULL; |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 319 | efi_events[i].queued = 0; |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 320 | efi_events[i].signaled = 0; |
| 321 | *event = &efi_events[i]; |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 322 | return EFI_SUCCESS; |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 323 | } |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 324 | return EFI_OUT_OF_RESOURCES; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 325 | } |
| 326 | |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 327 | static efi_status_t EFIAPI efi_create_event_ext( |
xypron.glpk@gmx.de | b521d29 | 2017-07-19 19:22:34 +0200 | [diff] [blame] | 328 | uint32_t type, UINTN notify_tpl, |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 329 | void (EFIAPI *notify_function) ( |
| 330 | struct efi_event *event, |
| 331 | void *context), |
| 332 | void *notify_context, struct efi_event **event) |
| 333 | { |
| 334 | EFI_ENTRY("%d, 0x%zx, %p, %p", type, notify_tpl, notify_function, |
| 335 | notify_context); |
| 336 | return EFI_EXIT(efi_create_event(type, notify_tpl, notify_function, |
| 337 | notify_context, event)); |
| 338 | } |
| 339 | |
| 340 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 341 | /* |
| 342 | * Our timers have to work without interrupts, so we check whenever keyboard |
| 343 | * input or disk accesses happen if enough time elapsed for it to fire. |
| 344 | */ |
| 345 | void efi_timer_check(void) |
| 346 | { |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 347 | int i; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 348 | u64 now = timer_get_us(); |
| 349 | |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 350 | for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 351 | if (!efi_events[i].type) |
| 352 | continue; |
| 353 | if (efi_events[i].queued) |
| 354 | efi_signal_event(&efi_events[i]); |
| 355 | if (!(efi_events[i].type & EVT_TIMER) || |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 356 | now < efi_events[i].trigger_next) |
| 357 | continue; |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 358 | switch (efi_events[i].trigger_type) { |
| 359 | case EFI_TIMER_RELATIVE: |
| 360 | efi_events[i].trigger_type = EFI_TIMER_STOP; |
| 361 | break; |
| 362 | case EFI_TIMER_PERIODIC: |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 363 | efi_events[i].trigger_next += |
xypron.glpk@gmx.de | 8787b02 | 2017-07-18 20:17:23 +0200 | [diff] [blame] | 364 | efi_events[i].trigger_time; |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 365 | break; |
| 366 | default: |
| 367 | continue; |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 368 | } |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 369 | efi_events[i].signaled = 1; |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 370 | efi_signal_event(&efi_events[i]); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 371 | } |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 372 | WATCHDOG_RESET(); |
| 373 | } |
| 374 | |
xypron.glpk@gmx.de | b521d29 | 2017-07-19 19:22:34 +0200 | [diff] [blame] | 375 | efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type, |
xypron.glpk@gmx.de | bfc7246 | 2017-07-18 20:17:21 +0200 | [diff] [blame] | 376 | uint64_t trigger_time) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 377 | { |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 378 | int i; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 379 | |
xypron.glpk@gmx.de | 8787b02 | 2017-07-18 20:17:23 +0200 | [diff] [blame] | 380 | /* |
| 381 | * The parameter defines a multiple of 100ns. |
| 382 | * We use multiples of 1000ns. So divide by 10. |
| 383 | */ |
| 384 | trigger_time = efi_div10(trigger_time); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 385 | |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 386 | for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { |
| 387 | if (event != &efi_events[i]) |
| 388 | continue; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 389 | |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 390 | if (!(event->type & EVT_TIMER)) |
| 391 | break; |
| 392 | switch (type) { |
| 393 | case EFI_TIMER_STOP: |
| 394 | event->trigger_next = -1ULL; |
| 395 | break; |
| 396 | case EFI_TIMER_PERIODIC: |
| 397 | case EFI_TIMER_RELATIVE: |
| 398 | event->trigger_next = |
xypron.glpk@gmx.de | 8787b02 | 2017-07-18 20:17:23 +0200 | [diff] [blame] | 399 | timer_get_us() + trigger_time; |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 400 | break; |
| 401 | default: |
xypron.glpk@gmx.de | bfc7246 | 2017-07-18 20:17:21 +0200 | [diff] [blame] | 402 | return EFI_INVALID_PARAMETER; |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 403 | } |
| 404 | event->trigger_type = type; |
| 405 | event->trigger_time = trigger_time; |
Heinrich Schuchardt | 2eca845 | 2017-09-15 10:06:14 +0200 | [diff] [blame] | 406 | event->signaled = 0; |
xypron.glpk@gmx.de | bfc7246 | 2017-07-18 20:17:21 +0200 | [diff] [blame] | 407 | return EFI_SUCCESS; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 408 | } |
xypron.glpk@gmx.de | bfc7246 | 2017-07-18 20:17:21 +0200 | [diff] [blame] | 409 | return EFI_INVALID_PARAMETER; |
| 410 | } |
| 411 | |
xypron.glpk@gmx.de | b521d29 | 2017-07-19 19:22:34 +0200 | [diff] [blame] | 412 | static efi_status_t EFIAPI efi_set_timer_ext(struct efi_event *event, |
| 413 | enum efi_timer_delay type, |
| 414 | uint64_t trigger_time) |
xypron.glpk@gmx.de | bfc7246 | 2017-07-18 20:17:21 +0200 | [diff] [blame] | 415 | { |
| 416 | EFI_ENTRY("%p, %d, %"PRIx64, event, type, trigger_time); |
| 417 | return EFI_EXIT(efi_set_timer(event, type, trigger_time)); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events, |
xypron.glpk@gmx.de | 2fd945f | 2017-07-18 20:17:17 +0200 | [diff] [blame] | 421 | struct efi_event **event, |
| 422 | unsigned long *index) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 423 | { |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 424 | int i, j; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 425 | |
| 426 | EFI_ENTRY("%ld, %p, %p", num_events, event, index); |
| 427 | |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 428 | /* Check parameters */ |
| 429 | if (!num_events || !event) |
| 430 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
Heinrich Schuchardt | 32f4b2f | 2017-09-15 10:06:16 +0200 | [diff] [blame] | 431 | /* Check TPL */ |
| 432 | if (efi_tpl != TPL_APPLICATION) |
| 433 | return EFI_EXIT(EFI_UNSUPPORTED); |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 434 | for (i = 0; i < num_events; ++i) { |
| 435 | for (j = 0; j < ARRAY_SIZE(efi_events); ++j) { |
| 436 | if (event[i] == &efi_events[j]) |
| 437 | goto known_event; |
| 438 | } |
| 439 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
| 440 | known_event: |
| 441 | if (!event[i]->type || event[i]->type & EVT_NOTIFY_SIGNAL) |
| 442 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 443 | if (!event[i]->signaled) |
| 444 | efi_signal_event(event[i]); |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | /* Wait for signal */ |
| 448 | for (;;) { |
| 449 | for (i = 0; i < num_events; ++i) { |
| 450 | if (event[i]->signaled) |
| 451 | goto out; |
| 452 | } |
| 453 | /* Allow events to occur. */ |
| 454 | efi_timer_check(); |
| 455 | } |
| 456 | |
| 457 | out: |
| 458 | /* |
| 459 | * Reset the signal which is passed to the caller to allow periodic |
| 460 | * events to occur. |
| 461 | */ |
| 462 | event[i]->signaled = 0; |
| 463 | if (index) |
| 464 | *index = i; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 465 | |
| 466 | return EFI_EXIT(EFI_SUCCESS); |
| 467 | } |
| 468 | |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 469 | static efi_status_t EFIAPI efi_signal_event_ext(struct efi_event *event) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 470 | { |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 471 | int i; |
| 472 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 473 | EFI_ENTRY("%p", event); |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 474 | for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { |
| 475 | if (event != &efi_events[i]) |
| 476 | continue; |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 477 | if (event->signaled) |
| 478 | break; |
| 479 | event->signaled = 1; |
| 480 | if (event->type & EVT_NOTIFY_SIGNAL) |
| 481 | efi_signal_event(event); |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 482 | break; |
| 483 | } |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 484 | return EFI_EXIT(EFI_SUCCESS); |
| 485 | } |
| 486 | |
xypron.glpk@gmx.de | 2fd945f | 2017-07-18 20:17:17 +0200 | [diff] [blame] | 487 | static efi_status_t EFIAPI efi_close_event(struct efi_event *event) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 488 | { |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 489 | int i; |
| 490 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 491 | EFI_ENTRY("%p", event); |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 492 | for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { |
| 493 | if (event == &efi_events[i]) { |
| 494 | event->type = 0; |
| 495 | event->trigger_next = -1ULL; |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 496 | event->queued = 0; |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 497 | event->signaled = 0; |
| 498 | return EFI_EXIT(EFI_SUCCESS); |
| 499 | } |
| 500 | } |
| 501 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 502 | } |
| 503 | |
xypron.glpk@gmx.de | 2fd945f | 2017-07-18 20:17:17 +0200 | [diff] [blame] | 504 | static efi_status_t EFIAPI efi_check_event(struct efi_event *event) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 505 | { |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 506 | int i; |
| 507 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 508 | EFI_ENTRY("%p", event); |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 509 | efi_timer_check(); |
| 510 | for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { |
| 511 | if (event != &efi_events[i]) |
| 512 | continue; |
| 513 | if (!event->type || event->type & EVT_NOTIFY_SIGNAL) |
| 514 | break; |
Heinrich Schuchardt | ca62a4f | 2017-09-15 10:06:13 +0200 | [diff] [blame] | 515 | if (!event->signaled) |
| 516 | efi_signal_event(event); |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 517 | if (event->signaled) |
| 518 | return EFI_EXIT(EFI_SUCCESS); |
| 519 | return EFI_EXIT(EFI_NOT_READY); |
| 520 | } |
| 521 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | static efi_status_t EFIAPI efi_install_protocol_interface(void **handle, |
| 525 | efi_guid_t *protocol, int protocol_interface_type, |
| 526 | void *protocol_interface) |
| 527 | { |
xypron.glpk@gmx.de | e0549f8 | 2017-07-11 22:06:16 +0200 | [diff] [blame] | 528 | struct list_head *lhandle; |
| 529 | int i; |
| 530 | efi_status_t r; |
| 531 | |
xypron.glpk@gmx.de | e0549f8 | 2017-07-11 22:06:16 +0200 | [diff] [blame] | 532 | if (!handle || !protocol || |
| 533 | protocol_interface_type != EFI_NATIVE_INTERFACE) { |
| 534 | r = EFI_INVALID_PARAMETER; |
| 535 | goto out; |
| 536 | } |
| 537 | |
| 538 | /* Create new handle if requested. */ |
| 539 | if (!*handle) { |
Heinrich Schuchardt | 3cc6e3f | 2017-08-27 00:51:09 +0200 | [diff] [blame^] | 540 | r = efi_create_handle(handle); |
| 541 | if (r != EFI_SUCCESS) |
| 542 | goto out; |
xypron.glpk@gmx.de | e0549f8 | 2017-07-11 22:06:16 +0200 | [diff] [blame] | 543 | } |
| 544 | /* Find object. */ |
| 545 | list_for_each(lhandle, &efi_obj_list) { |
| 546 | struct efi_object *efiobj; |
| 547 | efiobj = list_entry(lhandle, struct efi_object, link); |
| 548 | |
| 549 | if (efiobj->handle != *handle) |
| 550 | continue; |
| 551 | /* Check if protocol is already installed on the handle. */ |
| 552 | for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) { |
| 553 | struct efi_handler *handler = &efiobj->protocols[i]; |
| 554 | |
| 555 | if (!handler->guid) |
| 556 | continue; |
| 557 | if (!guidcmp(handler->guid, protocol)) { |
| 558 | r = EFI_INVALID_PARAMETER; |
| 559 | goto out; |
| 560 | } |
| 561 | } |
| 562 | /* Install protocol in first empty slot. */ |
| 563 | for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) { |
| 564 | struct efi_handler *handler = &efiobj->protocols[i]; |
| 565 | |
| 566 | if (handler->guid) |
| 567 | continue; |
| 568 | |
| 569 | handler->guid = protocol; |
| 570 | handler->protocol_interface = protocol_interface; |
| 571 | r = EFI_SUCCESS; |
| 572 | goto out; |
| 573 | } |
| 574 | r = EFI_OUT_OF_RESOURCES; |
| 575 | goto out; |
| 576 | } |
| 577 | r = EFI_INVALID_PARAMETER; |
| 578 | out: |
xypron.glpk@gmx.de | 8bee5a3 | 2017-07-11 22:06:18 +0200 | [diff] [blame] | 579 | return r; |
| 580 | } |
| 581 | |
| 582 | static efi_status_t EFIAPI efi_install_protocol_interface_ext(void **handle, |
| 583 | efi_guid_t *protocol, int protocol_interface_type, |
| 584 | void *protocol_interface) |
| 585 | { |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 586 | EFI_ENTRY("%p, %pUl, %d, %p", handle, protocol, protocol_interface_type, |
xypron.glpk@gmx.de | 8bee5a3 | 2017-07-11 22:06:18 +0200 | [diff] [blame] | 587 | protocol_interface); |
| 588 | |
| 589 | return EFI_EXIT(efi_install_protocol_interface(handle, protocol, |
| 590 | protocol_interface_type, |
| 591 | protocol_interface)); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 592 | } |
xypron.glpk@gmx.de | e0549f8 | 2017-07-11 22:06:16 +0200 | [diff] [blame] | 593 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 594 | static efi_status_t EFIAPI efi_reinstall_protocol_interface(void *handle, |
| 595 | efi_guid_t *protocol, void *old_interface, |
| 596 | void *new_interface) |
| 597 | { |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 598 | EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, old_interface, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 599 | new_interface); |
| 600 | return EFI_EXIT(EFI_ACCESS_DENIED); |
| 601 | } |
| 602 | |
| 603 | static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle, |
| 604 | efi_guid_t *protocol, void *protocol_interface) |
| 605 | { |
xypron.glpk@gmx.de | 4b6ed0d | 2017-07-11 22:06:17 +0200 | [diff] [blame] | 606 | struct list_head *lhandle; |
| 607 | int i; |
| 608 | efi_status_t r = EFI_NOT_FOUND; |
| 609 | |
xypron.glpk@gmx.de | 4b6ed0d | 2017-07-11 22:06:17 +0200 | [diff] [blame] | 610 | if (!handle || !protocol) { |
| 611 | r = EFI_INVALID_PARAMETER; |
| 612 | goto out; |
| 613 | } |
| 614 | |
| 615 | list_for_each(lhandle, &efi_obj_list) { |
| 616 | struct efi_object *efiobj; |
| 617 | efiobj = list_entry(lhandle, struct efi_object, link); |
| 618 | |
| 619 | if (efiobj->handle != handle) |
| 620 | continue; |
| 621 | |
| 622 | for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) { |
| 623 | struct efi_handler *handler = &efiobj->protocols[i]; |
| 624 | const efi_guid_t *hprotocol = handler->guid; |
| 625 | |
| 626 | if (!hprotocol) |
| 627 | continue; |
| 628 | if (!guidcmp(hprotocol, protocol)) { |
| 629 | if (handler->protocol_interface) { |
| 630 | r = EFI_ACCESS_DENIED; |
| 631 | } else { |
| 632 | handler->guid = 0; |
| 633 | r = EFI_SUCCESS; |
| 634 | } |
| 635 | goto out; |
| 636 | } |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | out: |
xypron.glpk@gmx.de | 3d8e145 | 2017-07-11 22:06:19 +0200 | [diff] [blame] | 641 | return r; |
| 642 | } |
| 643 | |
| 644 | static efi_status_t EFIAPI efi_uninstall_protocol_interface_ext(void *handle, |
| 645 | efi_guid_t *protocol, void *protocol_interface) |
| 646 | { |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 647 | EFI_ENTRY("%p, %pUl, %p", handle, protocol, protocol_interface); |
xypron.glpk@gmx.de | 3d8e145 | 2017-07-11 22:06:19 +0200 | [diff] [blame] | 648 | |
| 649 | return EFI_EXIT(efi_uninstall_protocol_interface(handle, protocol, |
| 650 | protocol_interface)); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | static efi_status_t EFIAPI efi_register_protocol_notify(efi_guid_t *protocol, |
xypron.glpk@gmx.de | 2fd945f | 2017-07-18 20:17:17 +0200 | [diff] [blame] | 654 | struct efi_event *event, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 655 | void **registration) |
| 656 | { |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 657 | EFI_ENTRY("%pUl, %p, %p", protocol, event, registration); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 658 | return EFI_EXIT(EFI_OUT_OF_RESOURCES); |
| 659 | } |
| 660 | |
| 661 | static int efi_search(enum efi_locate_search_type search_type, |
| 662 | efi_guid_t *protocol, void *search_key, |
| 663 | struct efi_object *efiobj) |
| 664 | { |
| 665 | int i; |
| 666 | |
| 667 | switch (search_type) { |
| 668 | case all_handles: |
| 669 | return 0; |
| 670 | case by_register_notify: |
| 671 | return -1; |
| 672 | case by_protocol: |
| 673 | for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) { |
| 674 | const efi_guid_t *guid = efiobj->protocols[i].guid; |
| 675 | if (guid && !guidcmp(guid, protocol)) |
| 676 | return 0; |
| 677 | } |
| 678 | return -1; |
| 679 | } |
| 680 | |
| 681 | return -1; |
| 682 | } |
| 683 | |
xypron.glpk@gmx.de | ebf199b | 2017-08-09 20:55:00 +0200 | [diff] [blame] | 684 | static efi_status_t efi_locate_handle( |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 685 | enum efi_locate_search_type search_type, |
| 686 | efi_guid_t *protocol, void *search_key, |
| 687 | unsigned long *buffer_size, efi_handle_t *buffer) |
| 688 | { |
| 689 | struct list_head *lhandle; |
| 690 | unsigned long size = 0; |
| 691 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 692 | /* Count how much space we need */ |
| 693 | list_for_each(lhandle, &efi_obj_list) { |
| 694 | struct efi_object *efiobj; |
| 695 | efiobj = list_entry(lhandle, struct efi_object, link); |
| 696 | if (!efi_search(search_type, protocol, search_key, efiobj)) { |
| 697 | size += sizeof(void*); |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | if (*buffer_size < size) { |
| 702 | *buffer_size = size; |
xypron.glpk@gmx.de | 2632958 | 2017-07-11 22:06:21 +0200 | [diff] [blame] | 703 | return EFI_BUFFER_TOO_SMALL; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 704 | } |
| 705 | |
Rob Clark | 796a78c | 2017-08-06 14:10:07 -0400 | [diff] [blame] | 706 | *buffer_size = size; |
| 707 | if (size == 0) |
| 708 | return EFI_NOT_FOUND; |
| 709 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 710 | /* Then fill the array */ |
| 711 | list_for_each(lhandle, &efi_obj_list) { |
| 712 | struct efi_object *efiobj; |
| 713 | efiobj = list_entry(lhandle, struct efi_object, link); |
| 714 | if (!efi_search(search_type, protocol, search_key, efiobj)) { |
| 715 | *(buffer++) = efiobj->handle; |
| 716 | } |
| 717 | } |
| 718 | |
xypron.glpk@gmx.de | 2632958 | 2017-07-11 22:06:21 +0200 | [diff] [blame] | 719 | return EFI_SUCCESS; |
| 720 | } |
| 721 | |
| 722 | static efi_status_t EFIAPI efi_locate_handle_ext( |
| 723 | enum efi_locate_search_type search_type, |
| 724 | efi_guid_t *protocol, void *search_key, |
| 725 | unsigned long *buffer_size, efi_handle_t *buffer) |
| 726 | { |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 727 | EFI_ENTRY("%d, %pUl, %p, %p, %p", search_type, protocol, search_key, |
xypron.glpk@gmx.de | 2632958 | 2017-07-11 22:06:21 +0200 | [diff] [blame] | 728 | buffer_size, buffer); |
| 729 | |
| 730 | return EFI_EXIT(efi_locate_handle(search_type, protocol, search_key, |
| 731 | buffer_size, buffer)); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol, |
| 735 | struct efi_device_path **device_path, |
| 736 | efi_handle_t *device) |
| 737 | { |
Rob Clark | b66c60d | 2017-09-13 18:05:28 -0400 | [diff] [blame] | 738 | struct efi_object *efiobj; |
| 739 | |
| 740 | EFI_ENTRY("%pUl, %p, %p", protocol, device_path, device); |
| 741 | |
| 742 | efiobj = efi_dp_find_obj(*device_path, device_path); |
| 743 | if (!efiobj) |
| 744 | return EFI_EXIT(EFI_NOT_FOUND); |
| 745 | |
| 746 | *device = efiobj->handle; |
| 747 | |
| 748 | return EFI_EXIT(EFI_SUCCESS); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 749 | } |
| 750 | |
Alexander Graf | d98cdf6 | 2017-07-26 13:41:04 +0200 | [diff] [blame] | 751 | /* Collapses configuration table entries, removing index i */ |
| 752 | static void efi_remove_configuration_table(int i) |
| 753 | { |
| 754 | struct efi_configuration_table *this = &efi_conf_table[i]; |
| 755 | struct efi_configuration_table *next = &efi_conf_table[i+1]; |
| 756 | struct efi_configuration_table *end = &efi_conf_table[systab.nr_tables]; |
| 757 | |
| 758 | memmove(this, next, (ulong)end - (ulong)next); |
| 759 | systab.nr_tables--; |
| 760 | } |
| 761 | |
Alexander Graf | 488bf12 | 2016-08-19 01:23:24 +0200 | [diff] [blame] | 762 | efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 763 | { |
| 764 | int i; |
| 765 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 766 | /* Check for guid override */ |
| 767 | for (i = 0; i < systab.nr_tables; i++) { |
| 768 | if (!guidcmp(guid, &efi_conf_table[i].guid)) { |
Alexander Graf | d98cdf6 | 2017-07-26 13:41:04 +0200 | [diff] [blame] | 769 | if (table) |
| 770 | efi_conf_table[i].table = table; |
| 771 | else |
| 772 | efi_remove_configuration_table(i); |
Alexander Graf | 488bf12 | 2016-08-19 01:23:24 +0200 | [diff] [blame] | 773 | return EFI_SUCCESS; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 774 | } |
| 775 | } |
| 776 | |
Alexander Graf | d98cdf6 | 2017-07-26 13:41:04 +0200 | [diff] [blame] | 777 | if (!table) |
| 778 | return EFI_NOT_FOUND; |
| 779 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 780 | /* No override, check for overflow */ |
| 781 | if (i >= ARRAY_SIZE(efi_conf_table)) |
Alexander Graf | 488bf12 | 2016-08-19 01:23:24 +0200 | [diff] [blame] | 782 | return EFI_OUT_OF_RESOURCES; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 783 | |
| 784 | /* Add a new entry */ |
| 785 | memcpy(&efi_conf_table[i].guid, guid, sizeof(*guid)); |
| 786 | efi_conf_table[i].table = table; |
Alexander Graf | aba5e91 | 2016-08-19 01:23:30 +0200 | [diff] [blame] | 787 | systab.nr_tables = i + 1; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 788 | |
Alexander Graf | 488bf12 | 2016-08-19 01:23:24 +0200 | [diff] [blame] | 789 | return EFI_SUCCESS; |
| 790 | } |
| 791 | |
| 792 | static efi_status_t EFIAPI efi_install_configuration_table_ext(efi_guid_t *guid, |
| 793 | void *table) |
| 794 | { |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 795 | EFI_ENTRY("%pUl, %p", guid, table); |
Alexander Graf | 488bf12 | 2016-08-19 01:23:24 +0200 | [diff] [blame] | 796 | return EFI_EXIT(efi_install_configuration_table(guid, table)); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 797 | } |
| 798 | |
Rob Clark | 95c5553 | 2017-09-13 18:05:33 -0400 | [diff] [blame] | 799 | /* Initialize a loaded_image_info + loaded_image_info object with correct |
| 800 | * protocols, boot-device, etc. |
| 801 | */ |
| 802 | void efi_setup_loaded_image(struct efi_loaded_image *info, struct efi_object *obj, |
| 803 | struct efi_device_path *device_path, |
| 804 | struct efi_device_path *file_path) |
| 805 | { |
| 806 | obj->handle = info; |
| 807 | |
| 808 | /* |
| 809 | * When asking for the device path interface, return |
| 810 | * bootefi_device_path |
| 811 | */ |
| 812 | obj->protocols[0].guid = &efi_guid_device_path; |
| 813 | obj->protocols[0].protocol_interface = device_path; |
| 814 | |
| 815 | /* |
| 816 | * When asking for the loaded_image interface, just |
| 817 | * return handle which points to loaded_image_info |
| 818 | */ |
| 819 | obj->protocols[1].guid = &efi_guid_loaded_image; |
| 820 | obj->protocols[1].protocol_interface = info; |
| 821 | |
| 822 | obj->protocols[2].guid = &efi_guid_console_control; |
| 823 | obj->protocols[2].protocol_interface = (void *)&efi_console_control; |
| 824 | |
| 825 | obj->protocols[3].guid = &efi_guid_device_path_to_text_protocol; |
| 826 | obj->protocols[3].protocol_interface = |
| 827 | (void *)&efi_device_path_to_text; |
| 828 | |
| 829 | info->file_path = file_path; |
| 830 | info->device_handle = efi_dp_find_obj(device_path, NULL); |
| 831 | |
| 832 | list_add_tail(&obj->link, &efi_obj_list); |
| 833 | } |
| 834 | |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 835 | efi_status_t efi_load_image_from_path(struct efi_device_path *file_path, |
| 836 | void **buffer) |
Rob Clark | 838ee4b | 2017-09-13 18:05:35 -0400 | [diff] [blame] | 837 | { |
| 838 | struct efi_file_info *info = NULL; |
| 839 | struct efi_file_handle *f; |
| 840 | static efi_status_t ret; |
| 841 | uint64_t bs; |
| 842 | |
| 843 | f = efi_file_from_path(file_path); |
| 844 | if (!f) |
| 845 | return EFI_DEVICE_ERROR; |
| 846 | |
| 847 | bs = 0; |
| 848 | EFI_CALL(ret = f->getinfo(f, (efi_guid_t *)&efi_file_info_guid, |
| 849 | &bs, info)); |
| 850 | if (ret == EFI_BUFFER_TOO_SMALL) { |
| 851 | info = malloc(bs); |
| 852 | EFI_CALL(ret = f->getinfo(f, (efi_guid_t *)&efi_file_info_guid, |
| 853 | &bs, info)); |
| 854 | } |
| 855 | if (ret != EFI_SUCCESS) |
| 856 | goto error; |
| 857 | |
| 858 | ret = efi_allocate_pool(EFI_LOADER_DATA, info->file_size, buffer); |
| 859 | if (ret) |
| 860 | goto error; |
| 861 | |
| 862 | EFI_CALL(ret = f->read(f, &info->file_size, *buffer)); |
| 863 | |
| 864 | error: |
| 865 | free(info); |
| 866 | EFI_CALL(f->close(f)); |
| 867 | |
| 868 | if (ret != EFI_SUCCESS) { |
| 869 | efi_free_pool(*buffer); |
| 870 | *buffer = NULL; |
| 871 | } |
| 872 | |
| 873 | return ret; |
| 874 | } |
| 875 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 876 | static efi_status_t EFIAPI efi_load_image(bool boot_policy, |
| 877 | efi_handle_t parent_image, |
| 878 | struct efi_device_path *file_path, |
| 879 | void *source_buffer, |
| 880 | unsigned long source_size, |
| 881 | efi_handle_t *image_handle) |
| 882 | { |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 883 | struct efi_loaded_image *info; |
| 884 | struct efi_object *obj; |
| 885 | |
| 886 | EFI_ENTRY("%d, %p, %p, %p, %ld, %p", boot_policy, parent_image, |
| 887 | file_path, source_buffer, source_size, image_handle); |
Rob Clark | 838ee4b | 2017-09-13 18:05:35 -0400 | [diff] [blame] | 888 | |
| 889 | info = calloc(1, sizeof(*info)); |
| 890 | obj = calloc(1, sizeof(*obj)); |
| 891 | |
| 892 | if (!source_buffer) { |
| 893 | struct efi_device_path *dp, *fp; |
| 894 | efi_status_t ret; |
| 895 | |
Rob Clark | 9975fe9 | 2017-09-13 18:05:38 -0400 | [diff] [blame] | 896 | ret = efi_load_image_from_path(file_path, &source_buffer); |
Rob Clark | 838ee4b | 2017-09-13 18:05:35 -0400 | [diff] [blame] | 897 | if (ret != EFI_SUCCESS) { |
| 898 | free(info); |
| 899 | free(obj); |
| 900 | return EFI_EXIT(ret); |
| 901 | } |
| 902 | |
| 903 | /* |
| 904 | * split file_path which contains both the device and |
| 905 | * file parts: |
| 906 | */ |
| 907 | efi_dp_split_file_path(file_path, &dp, &fp); |
| 908 | |
| 909 | efi_setup_loaded_image(info, obj, dp, fp); |
| 910 | } else { |
| 911 | /* In this case, file_path is the "device" path, ie. |
| 912 | * something like a HARDWARE_DEVICE:MEMORY_MAPPED |
| 913 | */ |
| 914 | efi_setup_loaded_image(info, obj, file_path, NULL); |
| 915 | } |
| 916 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 917 | info->reserved = efi_load_pe(source_buffer, info); |
| 918 | if (!info->reserved) { |
| 919 | free(info); |
| 920 | free(obj); |
| 921 | return EFI_EXIT(EFI_UNSUPPORTED); |
| 922 | } |
| 923 | |
| 924 | *image_handle = info; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 925 | |
| 926 | return EFI_EXIT(EFI_SUCCESS); |
| 927 | } |
| 928 | |
| 929 | static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, |
| 930 | unsigned long *exit_data_size, |
| 931 | s16 **exit_data) |
| 932 | { |
| 933 | ulong (*entry)(void *image_handle, struct efi_system_table *st); |
| 934 | struct efi_loaded_image *info = image_handle; |
| 935 | |
| 936 | EFI_ENTRY("%p, %p, %p", image_handle, exit_data_size, exit_data); |
| 937 | entry = info->reserved; |
| 938 | |
| 939 | efi_is_direct_boot = false; |
| 940 | |
| 941 | /* call the image! */ |
Alexander Graf | a86aeaf | 2016-05-20 23:28:23 +0200 | [diff] [blame] | 942 | if (setjmp(&info->exit_jmp)) { |
| 943 | /* We returned from the child image */ |
| 944 | return EFI_EXIT(info->exit_status); |
| 945 | } |
| 946 | |
Rob Clark | af65db8 | 2017-07-27 08:04:19 -0400 | [diff] [blame] | 947 | __efi_nesting_dec(); |
Rob Clark | c160d2f | 2017-07-27 08:04:18 -0400 | [diff] [blame] | 948 | __efi_exit_check(); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 949 | entry(image_handle, &systab); |
Rob Clark | c160d2f | 2017-07-27 08:04:18 -0400 | [diff] [blame] | 950 | __efi_entry_check(); |
Rob Clark | af65db8 | 2017-07-27 08:04:19 -0400 | [diff] [blame] | 951 | __efi_nesting_inc(); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 952 | |
| 953 | /* Should usually never get here */ |
| 954 | return EFI_EXIT(EFI_SUCCESS); |
| 955 | } |
| 956 | |
Alexander Graf | a86aeaf | 2016-05-20 23:28:23 +0200 | [diff] [blame] | 957 | static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle, |
| 958 | efi_status_t exit_status, unsigned long exit_data_size, |
| 959 | int16_t *exit_data) |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 960 | { |
Alexander Graf | a86aeaf | 2016-05-20 23:28:23 +0200 | [diff] [blame] | 961 | struct efi_loaded_image *loaded_image_info = (void*)image_handle; |
| 962 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 963 | EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status, |
| 964 | exit_data_size, exit_data); |
Alexander Graf | a86aeaf | 2016-05-20 23:28:23 +0200 | [diff] [blame] | 965 | |
Alexander Graf | a148920 | 2017-09-03 14:14:17 +0200 | [diff] [blame] | 966 | /* Make sure entry/exit counts for EFI world cross-overs match */ |
Heinrich Schuchardt | da94073 | 2017-08-25 19:53:14 +0200 | [diff] [blame] | 967 | __efi_exit_check(); |
| 968 | |
Alexander Graf | a148920 | 2017-09-03 14:14:17 +0200 | [diff] [blame] | 969 | /* |
| 970 | * But longjmp out with the U-Boot gd, not the application's, as |
| 971 | * the other end is a setjmp call inside EFI context. |
| 972 | */ |
| 973 | efi_restore_gd(); |
| 974 | |
Alexander Graf | a86aeaf | 2016-05-20 23:28:23 +0200 | [diff] [blame] | 975 | loaded_image_info->exit_status = exit_status; |
Alexander Graf | 692fcdd | 2016-09-27 09:30:32 +0200 | [diff] [blame] | 976 | longjmp(&loaded_image_info->exit_jmp, 1); |
Alexander Graf | a86aeaf | 2016-05-20 23:28:23 +0200 | [diff] [blame] | 977 | |
| 978 | panic("EFI application exited"); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | static struct efi_object *efi_search_obj(void *handle) |
| 982 | { |
| 983 | struct list_head *lhandle; |
| 984 | |
| 985 | list_for_each(lhandle, &efi_obj_list) { |
| 986 | struct efi_object *efiobj; |
| 987 | efiobj = list_entry(lhandle, struct efi_object, link); |
| 988 | if (efiobj->handle == handle) |
| 989 | return efiobj; |
| 990 | } |
| 991 | |
| 992 | return NULL; |
| 993 | } |
| 994 | |
| 995 | static efi_status_t EFIAPI efi_unload_image(void *image_handle) |
| 996 | { |
| 997 | struct efi_object *efiobj; |
| 998 | |
| 999 | EFI_ENTRY("%p", image_handle); |
| 1000 | efiobj = efi_search_obj(image_handle); |
| 1001 | if (efiobj) |
| 1002 | list_del(&efiobj->link); |
| 1003 | |
| 1004 | return EFI_EXIT(EFI_SUCCESS); |
| 1005 | } |
| 1006 | |
| 1007 | static void efi_exit_caches(void) |
| 1008 | { |
| 1009 | #if defined(CONFIG_ARM) && !defined(CONFIG_ARM64) |
| 1010 | /* |
| 1011 | * Grub on 32bit ARM needs to have caches disabled before jumping into |
| 1012 | * a zImage, but does not know of all cache layers. Give it a hand. |
| 1013 | */ |
| 1014 | if (efi_is_direct_boot) |
| 1015 | cleanup_before_linux(); |
| 1016 | #endif |
| 1017 | } |
| 1018 | |
| 1019 | static efi_status_t EFIAPI efi_exit_boot_services(void *image_handle, |
| 1020 | unsigned long map_key) |
| 1021 | { |
Heinrich Schuchardt | 152a263 | 2017-09-15 10:06:18 +0200 | [diff] [blame] | 1022 | int i; |
| 1023 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1024 | EFI_ENTRY("%p, %ld", image_handle, map_key); |
| 1025 | |
Heinrich Schuchardt | 152a263 | 2017-09-15 10:06:18 +0200 | [diff] [blame] | 1026 | /* Notify that ExitBootServices is invoked. */ |
| 1027 | for (i = 0; i < ARRAY_SIZE(efi_events); ++i) { |
| 1028 | if (efi_events[i].type != EVT_SIGNAL_EXIT_BOOT_SERVICES) |
| 1029 | continue; |
| 1030 | efi_signal_event(&efi_events[i]); |
| 1031 | } |
| 1032 | /* Make sure that notification functions are not called anymore */ |
| 1033 | efi_tpl = TPL_HIGH_LEVEL; |
| 1034 | |
Rob Clark | ad644e7 | 2017-09-13 18:05:37 -0400 | [diff] [blame] | 1035 | #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE) |
| 1036 | /* save any EFI variables that have been written: */ |
| 1037 | env_save(); |
| 1038 | #endif |
| 1039 | |
Alexander Graf | b7b8410 | 2016-11-17 01:02:57 +0100 | [diff] [blame] | 1040 | board_quiesce_devices(); |
| 1041 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1042 | /* Fix up caches for EFI payloads if necessary */ |
| 1043 | efi_exit_caches(); |
| 1044 | |
| 1045 | /* This stops all lingering devices */ |
| 1046 | bootm_disable_interrupts(); |
| 1047 | |
| 1048 | /* Give the payload some time to boot */ |
| 1049 | WATCHDOG_RESET(); |
| 1050 | |
| 1051 | return EFI_EXIT(EFI_SUCCESS); |
| 1052 | } |
| 1053 | |
| 1054 | static efi_status_t EFIAPI efi_get_next_monotonic_count(uint64_t *count) |
| 1055 | { |
| 1056 | static uint64_t mono = 0; |
| 1057 | EFI_ENTRY("%p", count); |
| 1058 | *count = mono++; |
| 1059 | return EFI_EXIT(EFI_SUCCESS); |
| 1060 | } |
| 1061 | |
| 1062 | static efi_status_t EFIAPI efi_stall(unsigned long microseconds) |
| 1063 | { |
| 1064 | EFI_ENTRY("%ld", microseconds); |
| 1065 | udelay(microseconds); |
| 1066 | return EFI_EXIT(EFI_SUCCESS); |
| 1067 | } |
| 1068 | |
| 1069 | static efi_status_t EFIAPI efi_set_watchdog_timer(unsigned long timeout, |
| 1070 | uint64_t watchdog_code, |
| 1071 | unsigned long data_size, |
| 1072 | uint16_t *watchdog_data) |
| 1073 | { |
| 1074 | EFI_ENTRY("%ld, 0x%"PRIx64", %ld, %p", timeout, watchdog_code, |
| 1075 | data_size, watchdog_data); |
Rob Clark | b510482 | 2017-07-25 20:17:59 -0400 | [diff] [blame] | 1076 | return efi_unsupported(__func__); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1077 | } |
| 1078 | |
| 1079 | static efi_status_t EFIAPI efi_connect_controller( |
| 1080 | efi_handle_t controller_handle, |
| 1081 | efi_handle_t *driver_image_handle, |
| 1082 | struct efi_device_path *remain_device_path, |
| 1083 | bool recursive) |
| 1084 | { |
| 1085 | EFI_ENTRY("%p, %p, %p, %d", controller_handle, driver_image_handle, |
| 1086 | remain_device_path, recursive); |
| 1087 | return EFI_EXIT(EFI_NOT_FOUND); |
| 1088 | } |
| 1089 | |
| 1090 | static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle, |
| 1091 | void *driver_image_handle, |
| 1092 | void *child_handle) |
| 1093 | { |
| 1094 | EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle, |
| 1095 | child_handle); |
| 1096 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
| 1097 | } |
| 1098 | |
| 1099 | static efi_status_t EFIAPI efi_close_protocol(void *handle, |
| 1100 | efi_guid_t *protocol, |
| 1101 | void *agent_handle, |
| 1102 | void *controller_handle) |
| 1103 | { |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 1104 | EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, agent_handle, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1105 | controller_handle); |
| 1106 | return EFI_EXIT(EFI_NOT_FOUND); |
| 1107 | } |
| 1108 | |
| 1109 | static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle, |
| 1110 | efi_guid_t *protocol, |
| 1111 | struct efi_open_protocol_info_entry **entry_buffer, |
| 1112 | unsigned long *entry_count) |
| 1113 | { |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 1114 | EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, entry_buffer, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1115 | entry_count); |
| 1116 | return EFI_EXIT(EFI_NOT_FOUND); |
| 1117 | } |
| 1118 | |
| 1119 | static efi_status_t EFIAPI efi_protocols_per_handle(void *handle, |
| 1120 | efi_guid_t ***protocol_buffer, |
| 1121 | unsigned long *protocol_buffer_count) |
| 1122 | { |
xypron.glpk@gmx.de | c0ebfc8 | 2017-07-13 23:24:32 +0200 | [diff] [blame] | 1123 | unsigned long buffer_size; |
| 1124 | struct efi_object *efiobj; |
| 1125 | unsigned long i, j; |
| 1126 | struct list_head *lhandle; |
| 1127 | efi_status_t r; |
| 1128 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1129 | EFI_ENTRY("%p, %p, %p", handle, protocol_buffer, |
| 1130 | protocol_buffer_count); |
xypron.glpk@gmx.de | c0ebfc8 | 2017-07-13 23:24:32 +0200 | [diff] [blame] | 1131 | |
| 1132 | if (!handle || !protocol_buffer || !protocol_buffer_count) |
| 1133 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
| 1134 | |
| 1135 | *protocol_buffer = NULL; |
Rob Clark | 661c832 | 2017-07-20 07:59:39 -0400 | [diff] [blame] | 1136 | *protocol_buffer_count = 0; |
xypron.glpk@gmx.de | c0ebfc8 | 2017-07-13 23:24:32 +0200 | [diff] [blame] | 1137 | list_for_each(lhandle, &efi_obj_list) { |
| 1138 | efiobj = list_entry(lhandle, struct efi_object, link); |
| 1139 | |
| 1140 | if (efiobj->handle != handle) |
| 1141 | continue; |
| 1142 | |
| 1143 | /* Count protocols */ |
| 1144 | for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) { |
| 1145 | if (efiobj->protocols[i].guid) |
| 1146 | ++*protocol_buffer_count; |
| 1147 | } |
| 1148 | /* Copy guids */ |
| 1149 | if (*protocol_buffer_count) { |
| 1150 | buffer_size = sizeof(efi_guid_t *) * |
| 1151 | *protocol_buffer_count; |
| 1152 | r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, |
| 1153 | buffer_size, |
| 1154 | (void **)protocol_buffer); |
| 1155 | if (r != EFI_SUCCESS) |
| 1156 | return EFI_EXIT(r); |
| 1157 | j = 0; |
| 1158 | for (i = 0; i < ARRAY_SIZE(efiobj->protocols); ++i) { |
| 1159 | if (efiobj->protocols[i].guid) { |
| 1160 | (*protocol_buffer)[j] = (void *) |
| 1161 | efiobj->protocols[i].guid; |
| 1162 | ++j; |
| 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | break; |
| 1167 | } |
| 1168 | |
| 1169 | return EFI_EXIT(EFI_SUCCESS); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1170 | } |
| 1171 | |
| 1172 | static efi_status_t EFIAPI efi_locate_handle_buffer( |
| 1173 | enum efi_locate_search_type search_type, |
| 1174 | efi_guid_t *protocol, void *search_key, |
| 1175 | unsigned long *no_handles, efi_handle_t **buffer) |
| 1176 | { |
xypron.glpk@gmx.de | c2e703f | 2017-07-11 22:06:22 +0200 | [diff] [blame] | 1177 | efi_status_t r; |
| 1178 | unsigned long buffer_size = 0; |
| 1179 | |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 1180 | EFI_ENTRY("%d, %pUl, %p, %p, %p", search_type, protocol, search_key, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1181 | no_handles, buffer); |
xypron.glpk@gmx.de | c2e703f | 2017-07-11 22:06:22 +0200 | [diff] [blame] | 1182 | |
| 1183 | if (!no_handles || !buffer) { |
| 1184 | r = EFI_INVALID_PARAMETER; |
| 1185 | goto out; |
| 1186 | } |
| 1187 | *no_handles = 0; |
| 1188 | *buffer = NULL; |
| 1189 | r = efi_locate_handle(search_type, protocol, search_key, &buffer_size, |
| 1190 | *buffer); |
| 1191 | if (r != EFI_BUFFER_TOO_SMALL) |
| 1192 | goto out; |
| 1193 | r = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, buffer_size, |
| 1194 | (void **)buffer); |
| 1195 | if (r != EFI_SUCCESS) |
| 1196 | goto out; |
| 1197 | r = efi_locate_handle(search_type, protocol, search_key, &buffer_size, |
| 1198 | *buffer); |
| 1199 | if (r == EFI_SUCCESS) |
| 1200 | *no_handles = buffer_size / sizeof(void *); |
| 1201 | out: |
| 1202 | return EFI_EXIT(r); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1203 | } |
| 1204 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1205 | static efi_status_t EFIAPI efi_locate_protocol(efi_guid_t *protocol, |
| 1206 | void *registration, |
| 1207 | void **protocol_interface) |
| 1208 | { |
xypron.glpk@gmx.de | 88adae5 | 2017-07-11 22:06:24 +0200 | [diff] [blame] | 1209 | struct list_head *lhandle; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1210 | int i; |
| 1211 | |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 1212 | EFI_ENTRY("%pUl, %p, %p", protocol, registration, protocol_interface); |
xypron.glpk@gmx.de | 88adae5 | 2017-07-11 22:06:24 +0200 | [diff] [blame] | 1213 | |
| 1214 | if (!protocol || !protocol_interface) |
| 1215 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
| 1216 | |
Heinrich Schuchardt | ae0bd3a | 2017-08-18 17:45:16 +0200 | [diff] [blame] | 1217 | EFI_PRINT_GUID("protocol", protocol); |
| 1218 | |
xypron.glpk@gmx.de | 88adae5 | 2017-07-11 22:06:24 +0200 | [diff] [blame] | 1219 | list_for_each(lhandle, &efi_obj_list) { |
| 1220 | struct efi_object *efiobj; |
| 1221 | |
| 1222 | efiobj = list_entry(lhandle, struct efi_object, link); |
| 1223 | for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) { |
| 1224 | struct efi_handler *handler = &efiobj->protocols[i]; |
| 1225 | |
| 1226 | if (!handler->guid) |
| 1227 | continue; |
| 1228 | if (!guidcmp(handler->guid, protocol)) { |
| 1229 | *protocol_interface = |
| 1230 | handler->protocol_interface; |
| 1231 | return EFI_EXIT(EFI_SUCCESS); |
| 1232 | } |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1233 | } |
| 1234 | } |
xypron.glpk@gmx.de | 88adae5 | 2017-07-11 22:06:24 +0200 | [diff] [blame] | 1235 | *protocol_interface = NULL; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1236 | |
| 1237 | return EFI_EXIT(EFI_NOT_FOUND); |
| 1238 | } |
| 1239 | |
| 1240 | static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces( |
| 1241 | void **handle, ...) |
| 1242 | { |
| 1243 | EFI_ENTRY("%p", handle); |
xypron.glpk@gmx.de | 58b8358 | 2017-07-11 22:06:20 +0200 | [diff] [blame] | 1244 | |
| 1245 | va_list argptr; |
| 1246 | efi_guid_t *protocol; |
| 1247 | void *protocol_interface; |
| 1248 | efi_status_t r = EFI_SUCCESS; |
| 1249 | int i = 0; |
| 1250 | |
| 1251 | if (!handle) |
| 1252 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
| 1253 | |
| 1254 | va_start(argptr, handle); |
| 1255 | for (;;) { |
| 1256 | protocol = va_arg(argptr, efi_guid_t*); |
| 1257 | if (!protocol) |
| 1258 | break; |
| 1259 | protocol_interface = va_arg(argptr, void*); |
| 1260 | r = efi_install_protocol_interface(handle, protocol, |
| 1261 | EFI_NATIVE_INTERFACE, |
| 1262 | protocol_interface); |
| 1263 | if (r != EFI_SUCCESS) |
| 1264 | break; |
| 1265 | i++; |
| 1266 | } |
| 1267 | va_end(argptr); |
| 1268 | if (r == EFI_SUCCESS) |
| 1269 | return EFI_EXIT(r); |
| 1270 | |
| 1271 | /* If an error occured undo all changes. */ |
| 1272 | va_start(argptr, handle); |
| 1273 | for (; i; --i) { |
| 1274 | protocol = va_arg(argptr, efi_guid_t*); |
| 1275 | protocol_interface = va_arg(argptr, void*); |
| 1276 | efi_uninstall_protocol_interface(handle, protocol, |
| 1277 | protocol_interface); |
| 1278 | } |
| 1279 | va_end(argptr); |
| 1280 | |
| 1281 | return EFI_EXIT(r); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces( |
| 1285 | void *handle, ...) |
| 1286 | { |
| 1287 | EFI_ENTRY("%p", handle); |
| 1288 | return EFI_EXIT(EFI_INVALID_PARAMETER); |
| 1289 | } |
| 1290 | |
| 1291 | static efi_status_t EFIAPI efi_calculate_crc32(void *data, |
| 1292 | unsigned long data_size, |
| 1293 | uint32_t *crc32_p) |
| 1294 | { |
| 1295 | EFI_ENTRY("%p, %ld", data, data_size); |
| 1296 | *crc32_p = crc32(0, data, data_size); |
| 1297 | return EFI_EXIT(EFI_SUCCESS); |
| 1298 | } |
| 1299 | |
| 1300 | static void EFIAPI efi_copy_mem(void *destination, void *source, |
| 1301 | unsigned long length) |
| 1302 | { |
| 1303 | EFI_ENTRY("%p, %p, %ld", destination, source, length); |
| 1304 | memcpy(destination, source, length); |
| 1305 | } |
| 1306 | |
| 1307 | static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value) |
| 1308 | { |
| 1309 | EFI_ENTRY("%p, %ld, 0x%x", buffer, size, value); |
| 1310 | memset(buffer, value, size); |
| 1311 | } |
| 1312 | |
| 1313 | static efi_status_t EFIAPI efi_open_protocol( |
| 1314 | void *handle, efi_guid_t *protocol, |
| 1315 | void **protocol_interface, void *agent_handle, |
| 1316 | void *controller_handle, uint32_t attributes) |
| 1317 | { |
| 1318 | struct list_head *lhandle; |
| 1319 | int i; |
xypron.glpk@gmx.de | 69baec6 | 2017-07-11 22:06:15 +0200 | [diff] [blame] | 1320 | efi_status_t r = EFI_INVALID_PARAMETER; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1321 | |
Rob Clark | 778e6af | 2017-09-13 18:05:41 -0400 | [diff] [blame] | 1322 | EFI_ENTRY("%p, %pUl, %p, %p, %p, 0x%x", handle, protocol, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1323 | protocol_interface, agent_handle, controller_handle, |
| 1324 | attributes); |
xypron.glpk@gmx.de | b5349f7 | 2017-07-11 22:06:14 +0200 | [diff] [blame] | 1325 | |
xypron.glpk@gmx.de | 69baec6 | 2017-07-11 22:06:15 +0200 | [diff] [blame] | 1326 | if (!handle || !protocol || |
| 1327 | (!protocol_interface && attributes != |
| 1328 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) { |
| 1329 | goto out; |
| 1330 | } |
| 1331 | |
Heinrich Schuchardt | ae0bd3a | 2017-08-18 17:45:16 +0200 | [diff] [blame] | 1332 | EFI_PRINT_GUID("protocol", protocol); |
| 1333 | |
xypron.glpk@gmx.de | 69baec6 | 2017-07-11 22:06:15 +0200 | [diff] [blame] | 1334 | switch (attributes) { |
| 1335 | case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL: |
| 1336 | case EFI_OPEN_PROTOCOL_GET_PROTOCOL: |
| 1337 | case EFI_OPEN_PROTOCOL_TEST_PROTOCOL: |
| 1338 | break; |
| 1339 | case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER: |
| 1340 | if (controller_handle == handle) |
| 1341 | goto out; |
| 1342 | case EFI_OPEN_PROTOCOL_BY_DRIVER: |
| 1343 | case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE: |
| 1344 | if (controller_handle == NULL) |
| 1345 | goto out; |
| 1346 | case EFI_OPEN_PROTOCOL_EXCLUSIVE: |
| 1347 | if (agent_handle == NULL) |
| 1348 | goto out; |
| 1349 | break; |
| 1350 | default: |
xypron.glpk@gmx.de | b5349f7 | 2017-07-11 22:06:14 +0200 | [diff] [blame] | 1351 | goto out; |
| 1352 | } |
| 1353 | |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1354 | list_for_each(lhandle, &efi_obj_list) { |
| 1355 | struct efi_object *efiobj; |
| 1356 | efiobj = list_entry(lhandle, struct efi_object, link); |
| 1357 | |
| 1358 | if (efiobj->handle != handle) |
| 1359 | continue; |
| 1360 | |
| 1361 | for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) { |
| 1362 | struct efi_handler *handler = &efiobj->protocols[i]; |
| 1363 | const efi_guid_t *hprotocol = handler->guid; |
| 1364 | if (!hprotocol) |
xypron.glpk@gmx.de | 4b6ed0d | 2017-07-11 22:06:17 +0200 | [diff] [blame] | 1365 | continue; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1366 | if (!guidcmp(hprotocol, protocol)) { |
xypron.glpk@gmx.de | b5349f7 | 2017-07-11 22:06:14 +0200 | [diff] [blame] | 1367 | if (attributes != |
| 1368 | EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { |
| 1369 | *protocol_interface = |
| 1370 | handler->protocol_interface; |
| 1371 | } |
| 1372 | r = EFI_SUCCESS; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1373 | goto out; |
| 1374 | } |
| 1375 | } |
xypron.glpk@gmx.de | 69baec6 | 2017-07-11 22:06:15 +0200 | [diff] [blame] | 1376 | goto unsupported; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1377 | } |
| 1378 | |
xypron.glpk@gmx.de | 69baec6 | 2017-07-11 22:06:15 +0200 | [diff] [blame] | 1379 | unsupported: |
| 1380 | r = EFI_UNSUPPORTED; |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1381 | out: |
| 1382 | return EFI_EXIT(r); |
| 1383 | } |
| 1384 | |
| 1385 | static efi_status_t EFIAPI efi_handle_protocol(void *handle, |
| 1386 | efi_guid_t *protocol, |
| 1387 | void **protocol_interface) |
| 1388 | { |
xypron.glpk@gmx.de | 8e1d329 | 2017-06-29 21:16:19 +0200 | [diff] [blame] | 1389 | return efi_open_protocol(handle, protocol, protocol_interface, NULL, |
| 1390 | NULL, EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL); |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1391 | } |
| 1392 | |
| 1393 | static const struct efi_boot_services efi_boot_services = { |
| 1394 | .hdr = { |
| 1395 | .headersize = sizeof(struct efi_table_hdr), |
| 1396 | }, |
| 1397 | .raise_tpl = efi_raise_tpl, |
| 1398 | .restore_tpl = efi_restore_tpl, |
| 1399 | .allocate_pages = efi_allocate_pages_ext, |
| 1400 | .free_pages = efi_free_pages_ext, |
| 1401 | .get_memory_map = efi_get_memory_map_ext, |
Stefan Brüns | ead1274 | 2016-10-09 22:17:18 +0200 | [diff] [blame] | 1402 | .allocate_pool = efi_allocate_pool_ext, |
Stefan Brüns | 42417bc | 2016-10-09 22:17:26 +0200 | [diff] [blame] | 1403 | .free_pool = efi_free_pool_ext, |
xypron.glpk@gmx.de | 49deb45 | 2017-07-18 20:17:20 +0200 | [diff] [blame] | 1404 | .create_event = efi_create_event_ext, |
xypron.glpk@gmx.de | bfc7246 | 2017-07-18 20:17:21 +0200 | [diff] [blame] | 1405 | .set_timer = efi_set_timer_ext, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1406 | .wait_for_event = efi_wait_for_event, |
xypron.glpk@gmx.de | c684159 | 2017-07-18 20:17:18 +0200 | [diff] [blame] | 1407 | .signal_event = efi_signal_event_ext, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1408 | .close_event = efi_close_event, |
| 1409 | .check_event = efi_check_event, |
xypron.glpk@gmx.de | 8bee5a3 | 2017-07-11 22:06:18 +0200 | [diff] [blame] | 1410 | .install_protocol_interface = efi_install_protocol_interface_ext, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1411 | .reinstall_protocol_interface = efi_reinstall_protocol_interface, |
xypron.glpk@gmx.de | 3d8e145 | 2017-07-11 22:06:19 +0200 | [diff] [blame] | 1412 | .uninstall_protocol_interface = efi_uninstall_protocol_interface_ext, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1413 | .handle_protocol = efi_handle_protocol, |
| 1414 | .reserved = NULL, |
| 1415 | .register_protocol_notify = efi_register_protocol_notify, |
xypron.glpk@gmx.de | 2632958 | 2017-07-11 22:06:21 +0200 | [diff] [blame] | 1416 | .locate_handle = efi_locate_handle_ext, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1417 | .locate_device_path = efi_locate_device_path, |
Alexander Graf | 488bf12 | 2016-08-19 01:23:24 +0200 | [diff] [blame] | 1418 | .install_configuration_table = efi_install_configuration_table_ext, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1419 | .load_image = efi_load_image, |
| 1420 | .start_image = efi_start_image, |
Alexander Graf | a86aeaf | 2016-05-20 23:28:23 +0200 | [diff] [blame] | 1421 | .exit = efi_exit, |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1422 | .unload_image = efi_unload_image, |
| 1423 | .exit_boot_services = efi_exit_boot_services, |
| 1424 | .get_next_monotonic_count = efi_get_next_monotonic_count, |
| 1425 | .stall = efi_stall, |
| 1426 | .set_watchdog_timer = efi_set_watchdog_timer, |
| 1427 | .connect_controller = efi_connect_controller, |
| 1428 | .disconnect_controller = efi_disconnect_controller, |
| 1429 | .open_protocol = efi_open_protocol, |
| 1430 | .close_protocol = efi_close_protocol, |
| 1431 | .open_protocol_information = efi_open_protocol_information, |
| 1432 | .protocols_per_handle = efi_protocols_per_handle, |
| 1433 | .locate_handle_buffer = efi_locate_handle_buffer, |
| 1434 | .locate_protocol = efi_locate_protocol, |
| 1435 | .install_multiple_protocol_interfaces = efi_install_multiple_protocol_interfaces, |
| 1436 | .uninstall_multiple_protocol_interfaces = efi_uninstall_multiple_protocol_interfaces, |
| 1437 | .calculate_crc32 = efi_calculate_crc32, |
| 1438 | .copy_mem = efi_copy_mem, |
| 1439 | .set_mem = efi_set_mem, |
| 1440 | }; |
| 1441 | |
| 1442 | |
Alexander Graf | 3c63db9 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 1443 | static uint16_t __efi_runtime_data firmware_vendor[] = |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1444 | { 'D','a','s',' ','U','-','b','o','o','t',0 }; |
| 1445 | |
Alexander Graf | 3c63db9 | 2016-10-14 13:45:30 +0200 | [diff] [blame] | 1446 | struct efi_system_table __efi_runtime_data systab = { |
Alexander Graf | bee9116 | 2016-03-04 01:09:59 +0100 | [diff] [blame] | 1447 | .hdr = { |
| 1448 | .signature = EFI_SYSTEM_TABLE_SIGNATURE, |
| 1449 | .revision = 0x20005, /* 2.5 */ |
| 1450 | .headersize = sizeof(struct efi_table_hdr), |
| 1451 | }, |
| 1452 | .fw_vendor = (long)firmware_vendor, |
| 1453 | .con_in = (void*)&efi_con_in, |
| 1454 | .con_out = (void*)&efi_con_out, |
| 1455 | .std_err = (void*)&efi_con_out, |
| 1456 | .runtime = (void*)&efi_runtime_services, |
| 1457 | .boottime = (void*)&efi_boot_services, |
| 1458 | .nr_tables = 0, |
| 1459 | .tables = (void*)efi_conf_table, |
| 1460 | }; |