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