summaryrefslogtreecommitdiff
path: root/lib/efi
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-08-04 12:33:58 -0600
committerSimon Glass <sjg@chromium.org>2015-08-05 08:44:07 -0600
commit16c220d0a79feed0326c29d64e4bb482e80276d4 (patch)
tree5878dc5d828457588734814af315571c78efc3d5 /lib/efi
parent42fde30500eef6795129c3e4fda9951048c76617 (diff)
downloadu-boot-16c220d0a79feed0326c29d64e4bb482e80276d4.tar.gz
u-boot-16c220d0a79feed0326c29d64e4bb482e80276d4.tar.bz2
u-boot-16c220d0a79feed0326c29d64e4bb482e80276d4.zip
efi: Add functions for decoding the EFI tables
The EFI stub can pass a table to U-Boot with information about the memory map Potentially other things will follow. Add a way to access this table. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'lib/efi')
-rw-r--r--lib/efi/Makefile1
-rw-r--r--lib/efi/efi_info.c47
2 files changed, 48 insertions, 0 deletions
diff --git a/lib/efi/Makefile b/lib/efi/Makefile
index 4bc67f01f9..e32dc14f3d 100644
--- a/lib/efi/Makefile
+++ b/lib/efi/Makefile
@@ -5,6 +5,7 @@
#
obj-$(CONFIG_EFI_APP) += efi_app.o efi.o
+obj-$(CONFIG_EFI_STUB) += efi_info.o
CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \
$(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32)
diff --git a/lib/efi/efi_info.c b/lib/efi/efi_info.c
new file mode 100644
index 0000000000..0cd9a7e9c7
--- /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;
+}