Skip to content
Snippets Groups Projects
Commit 16c220d0 authored by Simon Glass's avatar Simon Glass
Browse files

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: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
parent 42fde305
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
/*
* 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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment