summaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_helper.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-12-04 10:01:48 -0500
committerTom Rini <trini@konsulko.com>2022-12-04 10:01:48 -0500
commitd2c5607edde2544e059fa871927877213f6bd532 (patch)
treee57d7db3425ccc950a1b0d5f3d4332eb7be84d54 /lib/efi_loader/efi_helper.c
parenta32f6341ccf2ea69f64fe87b9d07fd87325a2056 (diff)
parent30124c2bb96decd737963c043b26407791859faf (diff)
Merge tag 'efi-2023-01-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request for efi-2023-01-rc3 Documentation: * describe DM firmware needed for j721e_evm * describe management of UEFI security data base with eficonfig UEFI: * code clean-up for eficonfig command * fix handling of DHCP aknowledge * correct EFI memory type used for U-Boot code * unit test for FatToStr() truncation * add an EFI binary to print boot hart ID Other: * improve parameter checks in console functions * fix variable initialization in blk_get_device_part_str
Diffstat (limited to 'lib/efi_loader/efi_helper.c')
-rw-r--r--lib/efi_loader/efi_helper.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index c71e87d1180..788cb9faec5 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -190,3 +190,36 @@ int efi_unlink_dev(efi_handle_t handle)
return 0;
}
+
+static int u16_tohex(u16 c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+
+ /* not hexadecimal */
+ return -1;
+}
+
+bool efi_varname_is_load_option(u16 *var_name16, int *index)
+{
+ int id, i, digit;
+
+ if (memcmp(var_name16, u"Boot", 8))
+ return false;
+
+ for (id = 0, i = 0; i < 4; i++) {
+ digit = u16_tohex(var_name16[4 + i]);
+ if (digit < 0)
+ break;
+ id = (id << 4) + digit;
+ }
+ if (i == 4 && !var_name16[8]) {
+ if (index)
+ *index = id;
+ return true;
+ }
+
+ return false;
+}