All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 06/18] efi_loader: check tables in helloworld.efi
Date: Fri, 19 Jan 2018 20:24:42 +0100	[thread overview]
Message-ID: <20180119192454.11172-7-xypron.glpk@gmx.de> (raw)
In-Reply-To: <20180119192454.11172-1-xypron.glpk@gmx.de>

Check if the device tree and the SMBIOS table are available.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v3
	no change
v2
	no change
---
 lib/efi_loader/helloworld.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

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)
-- 
2.14.2

  parent reply	other threads:[~2018-01-19 19:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 19:24 [U-Boot] [PATCH v3 00/18] efi_loader: enable EFI driver provided block device Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 01/18] efi_loader: return NULL from device path functions Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 02/18] efi_loader: address of the simple file system protocol Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 03/18] efi_loader: correct find " Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 04/18] efi_loader: print device path when entering efi_load_image Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 05/18] efi_loader: allocate correct memory type for EFI image Heinrich Schuchardt
2018-01-19 19:24 ` Heinrich Schuchardt [this message]
2018-01-19 19:24 ` [U-Boot] [PATCH v3 07/18] efi_loader: fix StartImage bootservice Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 08/18] efi_loader: efi_disk_register: correctly determine if_type_name Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 09/18] efi_loader: make efi_block_io_guid a global symbol Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 10/18] efi_loader: provide a function to create a partition node Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 11/18] efi_loader: make efi_disk_create_partitions a global symbol Heinrich Schuchardt
2018-02-09  0:15   ` Jonathan Gray
2018-02-09  4:07     ` Heinrich Schuchardt
2018-02-09  9:44       ` Artturi Alm
2018-02-09 16:42         ` Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 12/18] efi_loader: correct EFI_BLOCK_IO_PROTOCOL definitions Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 13/18] efi_loader: provide function to get last node of a device path Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 14/18] efi_loader: provide link between devices and EFI handles Heinrich Schuchardt
2018-01-19 20:20   ` Alexander Graf
2018-01-19 20:33     ` Heinrich Schuchardt
2018-01-19 20:36       ` Alexander Graf
2018-01-19 19:24 ` [U-Boot] [PATCH v3 15/18] efi_loader: add check_tpl parameter to efi_signal_event Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 16/18] efi_loader: fix ExitBootServices Heinrich Schuchardt
2018-01-19 19:24 ` [U-Boot] [PATCH v3 17/18] efi_driver: EFI block driver Heinrich Schuchardt
2018-01-19 21:03   ` Alexander Graf
2018-01-19 19:24 ` [U-Boot] [PATCH v3 18/18] efi_selftest: provide a test for block io Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180119192454.11172-7-xypron.glpk@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.