]> git.sur5r.net Git - u-boot/blobdiff - cmd/bootefi.c
fit: Verify all configuration signatures
[u-boot] / cmd / bootefi.c
index 5a2a81005fcf734fbb873537f7b9f216f7d75e38..cd755b6bf44441a9d25ff0356a9d10066f9e4c56 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  *  EFI application loader
  *
  *  Copyright (c) 2016 Alexander Graf
- *
- *  SPDX-License-Identifier:     GPL-2.0+
  */
 
 #include <charset.h>
@@ -18,6 +17,7 @@
 #include <memalign.h>
 #include <asm/global_data.h>
 #include <asm-generic/sections.h>
+#include <asm-generic/unaligned.h>
 #include <linux/linkage.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -56,11 +56,16 @@ efi_status_t efi_init_obj_list(void)
        if (ret != EFI_SUCCESS)
                goto out;
 #endif
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
        ret = efi_net_register();
        if (ret != EFI_SUCCESS)
                goto out;
 #endif
+#ifdef CONFIG_GENERATE_ACPI_TABLE
+       ret = efi_acpi_register();
+       if (ret != EFI_SUCCESS)
+               goto out;
+#endif
 #ifdef CONFIG_GENERATE_SMBIOS_TABLE
        ret = efi_smbios_register();
        if (ret != EFI_SUCCESS)
@@ -83,6 +88,15 @@ out:
        return ret;
 }
 
+/*
+ * Allow unaligned memory access.
+ *
+ * This routine is overridden by architectures providing this feature.
+ */
+void __weak allow_unaligned(void)
+{
+}
+
 /*
  * Set the load options of an image from an environment variable.
  *
@@ -134,11 +148,13 @@ static void *copy_fdt(void *fdt)
 
        /* Safe fdt location is at 128MB */
        new_fdt_addr = fdt_ram_start + (128 * 1024 * 1024) + fdt_size;
-       if (efi_allocate_pages(1, EFI_RUNTIME_SERVICES_DATA, fdt_pages,
+       if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+                              EFI_RUNTIME_SERVICES_DATA, fdt_pages,
                               &new_fdt_addr) != EFI_SUCCESS) {
                /* If we can't put it there, put it somewhere */
                new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
-               if (efi_allocate_pages(1, EFI_RUNTIME_SERVICES_DATA, fdt_pages,
+               if (efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+                                      EFI_RUNTIME_SERVICES_DATA, fdt_pages,
                                       &new_fdt_addr) != EFI_SUCCESS) {
                        printf("ERROR: Failed to reserve space for FDT\n");
                        return NULL;
@@ -252,6 +268,7 @@ static efi_status_t do_bootefi_exec(void *efi,
 {
        struct efi_loaded_image loaded_image_info = {};
        struct efi_object loaded_image_info_obj = {};
+       struct efi_object mem_obj = {};
        struct efi_device_path *memdp = NULL;
        efi_status_t ret;
 
@@ -268,6 +285,12 @@ static efi_status_t do_bootefi_exec(void *efi,
                /* actual addresses filled in after efi_load_pe() */
                memdp = efi_dp_from_mem(0, 0, 0);
                device_path = image_path = memdp;
+               efi_add_handle(&mem_obj);
+
+               ret = efi_add_protocol(mem_obj.handle, &efi_guid_device_path,
+                                      device_path);
+               if (ret != EFI_SUCCESS)
+                       goto exit;
        } else {
                assert(device_path && image_path);
        }
@@ -332,6 +355,8 @@ static efi_status_t do_bootefi_exec(void *efi,
 exit:
        /* image has returned, loaded-image obj goes *poof*: */
        list_del(&loaded_image_info_obj.link);
+       if (mem_obj.handle)
+               list_del(&mem_obj.link);
 
        return ret;
 }
@@ -371,6 +396,9 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        efi_status_t r;
        void *fdt_addr;
 
+       /* Allow unaligned memory access */
+       allow_unaligned();
+
        /* Initialize EFI drivers */
        r = efi_init_obj_list();
        if (r != EFI_SUCCESS) {
@@ -429,8 +457,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                 * callback entry
                 */
                efi_save_gd();
-               /* Initialize and populate EFI object list */
-               efi_init_obj_list();
                /* Transfer environment variable efi_selftest as load options */
                set_load_options(&loaded_image_info, "efi_selftest");
                /* Execute the test */
@@ -511,7 +537,7 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path)
 
                bootefi_device_path = efi_dp_from_part(desc, part);
        } else {
-#ifdef CONFIG_CMD_NET
+#ifdef CONFIG_NET
                bootefi_device_path = efi_dp_from_eth();
 #endif
        }