diff options
author | 2023-10-10 14:33:42 +0000 | |
---|---|---|
committer | 2023-10-10 14:33:42 +0000 | |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/u-boot/lib/efi/efi_info.c | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/u-boot/lib/efi/efi_info.c')
-rw-r--r-- | roms/u-boot/lib/efi/efi_info.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/roms/u-boot/lib/efi/efi_info.c b/roms/u-boot/lib/efi/efi_info.c new file mode 100644 index 000000000..4d78923c4 --- /dev/null +++ b/roms/u-boot/lib/efi/efi_info.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2015 Google, Inc + * + * Access to the EFI information table + */ + +#include <common.h> +#include <efi.h> +#include <errno.h> +#include <mapmem.h> +#include <asm/global_data.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; +} |