summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-09-28 08:26:49 -0400
committerTom Rini <trini@konsulko.com>2020-09-28 08:26:49 -0400
commitd44d46e9fafaae85b0ebbcdc53999537a199fa2f (patch)
tree219ad9e33b8755b5188c39d063b097506d6117ff /lib
parent114c0ebcc10b8a0118d388adcb028b89fbde0eff (diff)
parentc48e9f310b950e39a91cea74b6708dd4fe2eb39c (diff)
Merge tag 'efi-2020-10-rc6' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2020-10-rc6 The following UEFI related issues are fixed: * restore the global data pointer in the RISC-V trap handler * install EFI_RNG_PROTOCOL only if we have a random number generator * display human readable string for EFI_RNG_PROTOCOL in efidebug command
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_rng.c30
-rw-r--r--lib/efi_loader/efi_root_node.c4
-rw-r--r--lib/efi_loader/efi_setup.c5
3 files changed, 34 insertions, 5 deletions
diff --git a/lib/efi_loader/efi_rng.c b/lib/efi_loader/efi_rng.c
index caef4085b0..a8a87007b6 100644
--- a/lib/efi_loader/efi_rng.c
+++ b/lib/efi_loader/efi_rng.c
@@ -3,6 +3,8 @@
* Copyright (c) 2019, Linaro Limited
*/
+#define LOG_CATEGORY LOGC_EFI
+
#include <common.h>
#include <dm.h>
#include <efi_loader.h>
@@ -144,7 +146,33 @@ back:
return EFI_EXIT(status);
}
-const struct efi_rng_protocol efi_rng_protocol = {
+static const struct efi_rng_protocol efi_rng_protocol = {
.get_info = rng_getinfo,
.get_rng = getrng,
};
+
+/**
+ * efi_rng_register() - register EFI_RNG_PROTOCOL
+ *
+ * If a RNG device is available, the Random Number Generator Protocol is
+ * registered.
+ *
+ * Return: An error status is only returned if adding the protocol fails.
+ */
+efi_status_t efi_rng_register(void)
+{
+ efi_status_t ret;
+ struct udevice *dev;
+
+ ret = platform_get_rng_device(&dev);
+ if (ret != EFI_SUCCESS) {
+ log_warning("Missing RNG device for EFI_RNG_PROTOCOL");
+ return EFI_SUCCESS;
+ }
+ ret = efi_add_protocol(efi_root, &efi_guid_rng_protocol,
+ (void *)&efi_rng_protocol);
+ if (ret != EFI_SUCCESS)
+ log_err("Cannot install EFI_RNG_PROTOCOL");
+
+ return ret;
+}
diff --git a/lib/efi_loader/efi_root_node.c b/lib/efi_loader/efi_root_node.c
index 76d18fb1a4..f68b0fdc61 100644
--- a/lib/efi_loader/efi_root_node.c
+++ b/lib/efi_loader/efi_root_node.c
@@ -81,10 +81,6 @@ efi_status_t efi_root_node_register(void)
&efi_guid_hii_config_routing_protocol,
(void *)&efi_hii_config_routing,
#endif
-#if CONFIG_IS_ENABLED(EFI_RNG_PROTOCOL)
- &efi_guid_rng_protocol,
- (void *)&efi_rng_protocol,
-#endif
NULL));
efi_root->type = EFI_OBJECT_TYPE_U_BOOT_FIRMWARE;
return ret;
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 6196c0a06c..45226c5c1a 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -151,6 +151,11 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;
#endif
+ if (IS_ENABLED(CONFIG_EFI_RNG_PROTOCOL)) {
+ ret = efi_rng_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
/* Initialize variable services */
ret = efi_init_variables();
if (ret != EFI_SUCCESS)