if (IS_ENABLED(CONFIG_UPDATE_TFTP))
update_tftp(0UL, NULL, NULL);
- if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY))
- efi_launch_capsules();
+ if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) {
+ /* efi_init_early() already called */
+ if (efi_init_obj_list() == EFI_SUCCESS)
+ efi_launch_capsules();
+ }
s = bootdelay_process();
if (cli_process_fdt(&s))
/* List of all events registered by RegisterProtocolNotify() */
extern struct list_head efi_register_notify_events;
+/* called at pre-initialization */
+int efi_init_early(void);
/* Initialize efi execution environment */
efi_status_t efi_init_obj_list(void);
/* Install device tree */
&os_indications_supported, false);
}
-
/**
- * efi_init_obj_list() - Initialize and populate EFI object list
+ * __efi_init_early() - handle initialization at early stage
+ *
+ * This function is called in efi_init_obj_list() only if
+ * !CONFIG_EFI_SETUP_EARLY.
*
* Return: status code
*/
-efi_status_t efi_init_obj_list(void)
+static efi_status_t __efi_init_early(void)
{
efi_status_t ret = EFI_SUCCESS;
- /* Initialize once only */
- if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
- return efi_obj_list_initialized;
-
/* Allow unaligned memory access */
allow_unaligned();
#ifdef CONFIG_PARTITIONS
ret = efi_disk_register();
- if (ret != EFI_SUCCESS)
- goto out;
#endif
+out:
+ return ret;
+}
+
+/**
+ * efi_init_early() - handle initialization at early stage
+ *
+ * external version of __efi_init_early(); expected to be called in
+ * board_init_r().
+ *
+ * Return: status code
+ */
+int efi_init_early(void)
+{
+ efi_status_t ret;
+
+ ret = __efi_init_early();
+ if (ret != EFI_SUCCESS) {
+ /* never re-init UEFI subsystem */
+ efi_obj_list_initialized = ret;
+ return -1;
+ }
+ return 0;
+}
+
+/**
+ * efi_init_obj_list() - Initialize and populate EFI object list
+ *
+ * Return: status code
+ */
+efi_status_t efi_init_obj_list(void)
+{
+ efi_status_t ret = EFI_SUCCESS;
+
+ /* Initialize once only */
+ if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
+ return efi_obj_list_initialized;
+
+ if (!IS_ENABLED(CONFIG_EFI_SETUP_EARLY)) {
+ ret = __efi_init_early();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
+
if (IS_ENABLED(CONFIG_EFI_RNG_PROTOCOL)) {
ret = efi_rng_register();
if (ret != EFI_SUCCESS)