summaryrefslogtreecommitdiff
path: root/lib/efi/efi_info.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2015-08-05 14:12:37 -0400
committerTom Rini <trini@konsulko.com>2015-08-05 14:12:37 -0400
commit1a2728ae4faf12874173de156b8a7e66cfbbeae5 (patch)
tree9aba8e6c915b341df8ec6077d8ecb28f1eb32b0b /lib/efi/efi_info.c
parentdcc7dbc73169bb4e39f27c1d95bbf031ccfc1744 (diff)
parent12c7510f17ff29190e52336910e43a50c0d620a6 (diff)
Merge git://git.denx.de/u-boot-x86
Diffstat (limited to 'lib/efi/efi_info.c')
-rw-r--r--lib/efi/efi_info.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/efi/efi_info.c b/lib/efi/efi_info.c
new file mode 100644
index 00000000000..0cd9a7e9c76
--- /dev/null
+++ b/lib/efi/efi_info.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * Access to the EFI information table
+ */
+
+#include <common.h>
+#include <efi.h>
+#include <errno.h>
+#include <mapmem.h>
+
+int efi_info_get(enum efi_entry_t type, void **datap, int *sizep)
+{
+ struct efi_entry_hdr *entry;
+ struct efi_info_hdr *info;
+ int ret;
+
+ if (!gd->arch.table)
+ return -ENODATA;
+
+ info = map_sysmem(gd->arch.table, 0);
+ if (info->version != EFI_TABLE_VERSION) {
+ ret = -EPROTONOSUPPORT;
+ goto err;
+ }
+
+ entry = (struct efi_entry_hdr *)((ulong)info + info->hdr_size);
+ while (entry->type != EFIET_END) {
+ if (entry->type == type) {
+ if (entry->addr)
+ *datap = map_sysmem(entry->addr, entry->size);
+ else
+ *datap = entry + 1;
+ *sizep = entry->size;
+ return 0;
+ }
+ entry = (struct efi_entry_hdr *)((ulong)entry + entry->link);
+ }
+
+ ret = -ENOENT;
+err:
+ unmap_sysmem(info);
+
+ return ret;
+}