Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 16c220d | 2015-08-04 12:33:58 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 Google, Inc |
| 4 | * |
Simon Glass | 16c220d | 2015-08-04 12:33:58 -0600 | [diff] [blame] | 5 | * Access to the EFI information table |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <efi.h> |
| 10 | #include <errno.h> |
| 11 | #include <mapmem.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame^] | 12 | #include <asm/global_data.h> |
Simon Glass | 16c220d | 2015-08-04 12:33:58 -0600 | [diff] [blame] | 13 | |
| 14 | int efi_info_get(enum efi_entry_t type, void **datap, int *sizep) |
| 15 | { |
| 16 | struct efi_entry_hdr *entry; |
| 17 | struct efi_info_hdr *info; |
| 18 | int ret; |
| 19 | |
| 20 | if (!gd->arch.table) |
| 21 | return -ENODATA; |
| 22 | |
| 23 | info = map_sysmem(gd->arch.table, 0); |
| 24 | if (info->version != EFI_TABLE_VERSION) { |
| 25 | ret = -EPROTONOSUPPORT; |
| 26 | goto err; |
| 27 | } |
| 28 | |
| 29 | entry = (struct efi_entry_hdr *)((ulong)info + info->hdr_size); |
| 30 | while (entry->type != EFIET_END) { |
| 31 | if (entry->type == type) { |
| 32 | if (entry->addr) |
| 33 | *datap = map_sysmem(entry->addr, entry->size); |
| 34 | else |
| 35 | *datap = entry + 1; |
| 36 | *sizep = entry->size; |
| 37 | return 0; |
| 38 | } |
| 39 | entry = (struct efi_entry_hdr *)((ulong)entry + entry->link); |
| 40 | } |
| 41 | |
| 42 | ret = -ENOENT; |
| 43 | err: |
| 44 | unmap_sysmem(info); |
| 45 | |
| 46 | return ret; |
| 47 | } |