mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Olbrich <m.olbrich@pengutronix.de>
Subject: [PATCH 2/2] efi: fill more EFI runtime variables defined by systemd
Date: Wed,  6 Dec 2023 14:11:45 +0100	[thread overview]
Message-ID: <20231206131145.3096043-2-m.olbrich@pengutronix.de> (raw)
In-Reply-To: <20231206131145.3096043-1-m.olbrich@pengutronix.de>

bootctl will use those variables if available, and produce somethink
like this:

System:
      Firmware: UEFI 2.70 (American Megatrends 5.13)
 Firmware Arch: x64
   Secure Boot: disabled (setup)
  TPM2 Support: firmware only, driver unavailable
  Boot into FW: supported

Current Boot Loader:
      Product: barebox-2023.11.0-dirty
     Features: ✗ Boot counting
               ✗ Menu timeout control
               ✗ One-shot menu timeout control
               ✗ Default entry control
               ✗ One-shot entry control
               ✗ Support for XBOOTLDR partition
               ✗ Support for passing random seed to OS
               ✗ Load drop-in drivers
               ✗ Support Type #1 sort-key field
               ✗ Support @saved pseudo-entry
               ✓ Support Type #1 devicetree field
               ✗ Enroll SecureBoot keys
               ✗ Retain SHIM protocols
               ✗ Boot loader sets ESP information
[...]

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 common/efi/payload/init.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/common/efi/payload/init.c b/common/efi/payload/init.c
index 19be7ff07fb6..cfacdffa6761 100644
--- a/common/efi/payload/init.c
+++ b/common/efi/payload/init.c
@@ -36,6 +36,7 @@
 #include <libfile.h>
 #include <state.h>
 #include <bbu.h>
+#include <generated/utsrelease.h>
 
 efi_runtime_services_t *RT;
 efi_boot_services_t *BS;
@@ -322,13 +323,46 @@ static int efi_core_init(void)
 }
 core_initcall(efi_core_init);
 
+/* Features of the loader, i.e. systemd-boot, barebox (imported from systemd) */
+#define EFI_LOADER_FEATURE_CONFIG_TIMEOUT          (1LL << 0)
+#define EFI_LOADER_FEATURE_CONFIG_TIMEOUT_ONE_SHOT (1LL << 1)
+#define EFI_LOADER_FEATURE_ENTRY_DEFAULT           (1LL << 2)
+#define EFI_LOADER_FEATURE_ENTRY_ONESHOT           (1LL << 3)
+#define EFI_LOADER_FEATURE_BOOT_COUNTING           (1LL << 4)
+#define EFI_LOADER_FEATURE_XBOOTLDR                (1LL << 5)
+#define EFI_LOADER_FEATURE_RANDOM_SEED             (1LL << 6)
+#define EFI_LOADER_FEATURE_LOAD_DRIVER             (1LL << 7)
+#define EFI_LOADER_FEATURE_SORT_KEY                (1LL << 8)
+#define EFI_LOADER_FEATURE_SAVED_ENTRY             (1LL << 9)
+#define EFI_LOADER_FEATURE_DEVICETREE              (1LL << 10)
+#define EFI_LOADER_FEATURE_SECUREBOOT_ENROLL       (1LL << 11)
+#define EFI_LOADER_FEATURE_RETAIN_SHIM             (1LL << 12)
+
+
 static int efi_postcore_init(void)
 {
 	char *uuid;
+	static const uint64_t loader_features =
+		EFI_LOADER_FEATURE_DEVICETREE;
 
 	efi_set_variable_usec("LoaderTimeInitUSec", &efi_systemd_vendor_guid,
 			      get_time_ns()/1000);
 
+	efi_set_variable_printf("LoaderInfo", &efi_systemd_vendor_guid,
+			"barebox-" UTS_RELEASE);
+
+	efi_set_variable_printf("LoaderFirmwareInfo", &efi_systemd_vendor_guid,
+				"%ls %u.%02u", efi_sys_table->fw_vendor,
+				efi_sys_table->fw_revision >> 16,
+				efi_sys_table->fw_revision & 0xffff);
+
+	efi_set_variable_printf("LoaderFirmwareType", &efi_systemd_vendor_guid,
+				"UEFI %u.%02u", efi_sys_table->hdr.revision >> 16,
+				efi_sys_table->hdr.revision & 0xffff);
+
+	efi_set_variable_uint64_le("LoaderFeatures", &efi_systemd_vendor_guid,
+				   loader_features);
+
 	uuid = device_path_to_partuuid(device_path_from_handle(
 				       efi_loaded_image->device_handle));
 	if (uuid) {
-- 
2.39.2




  reply	other threads:[~2023-12-06 13:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 13:11 [PATCH 1/2] efi: add more helper functions to write EFI variables Michael Olbrich
2023-12-06 13:11 ` Michael Olbrich [this message]
2023-12-13  6:47 ` Sascha Hauer

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=20231206131145.3096043-2-m.olbrich@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox