diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2018-01-19 22:24:42 +0300 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2018-01-23 01:09:13 +0300 |
commit | 0aaabbb2c8eeb187ace38d04d468cc88da331a82 (patch) | |
tree | aa1af297e2769477a93a6e20771eabd872deef48 | |
parent | 36b41a3cedd6626d8c8277b119d4516865da4738 (diff) | |
download | u-boot-0aaabbb2c8eeb187ace38d04d468cc88da331a82.tar.xz |
efi_loader: check tables in helloworld.efi
Check if the device tree and the SMBIOS table are available.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r-- | lib/efi_loader/helloworld.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c index b8c147d7f2..1ec0179226 100644 --- a/lib/efi_loader/helloworld.c +++ b/lib/efi_loader/helloworld.c @@ -14,6 +14,22 @@ #include <efi_api.h> static const efi_guid_t loaded_image_guid = LOADED_IMAGE_GUID; +static const efi_guid_t fdt_guid = EFI_FDT_GUID; +static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID; + +static int hw_memcmp(const void *buf1, const void *buf2, size_t length) +{ + const u8 *pos1 = buf1; + const u8 *pos2 = buf2; + + for (; length; --length) { + if (*pos1 != *pos2) + return *pos1 - *pos2; + ++pos1; + ++pos2; + } + return 0; +} /* * Entry point of the EFI application. @@ -29,6 +45,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, struct efi_boot_services *boottime = systable->boottime; struct efi_loaded_image *loaded_image; efi_status_t ret; + efi_uintn_t i; con_out->output_string(con_out, L"Hello, world!\n"); @@ -40,6 +57,15 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle, L"Cannot open loaded image protocol\n"); goto out; } + /* Find configuration tables */ + for (i = 0; i < systable->nr_tables; ++i) { + if (!hw_memcmp(&systable->tables[i].guid, &fdt_guid, + sizeof(efi_guid_t))) + con_out->output_string(con_out, L"Have device tree\n"); + if (!hw_memcmp(&systable->tables[i].guid, &smbios_guid, + sizeof(efi_guid_t))) + con_out->output_string(con_out, L"Have SMBIOS table\n"); + } /* Output the load options */ con_out->output_string(con_out, L"Load options: "); if (loaded_image->load_options_size && loaded_image->load_options) |