summaryrefslogtreecommitdiff
path: root/lib/efi_loader
diff options
context:
space:
mode:
Diffstat (limited to 'lib/efi_loader')
-rw-r--r--lib/efi_loader/Kconfig13
-rw-r--r--lib/efi_loader/Makefile46
-rw-r--r--lib/efi_loader/efi_console.c2
-rw-r--r--lib/efi_loader/efi_dt_fixup.c15
-rw-r--r--lib/efi_loader/efi_file.c2
-rw-r--r--lib/efi_loader/efi_helper.c22
-rw-r--r--lib/efi_loader/efi_memory.c220
-rw-r--r--lib/efi_loader/efi_rng.c2
-rw-r--r--lib/efi_loader/efi_setup.c25
-rw-r--r--lib/efi_loader/efi_unicode_collation.c2
-rw-r--r--lib/efi_loader/efi_var_file.c22
-rw-r--r--lib/efi_loader/helloworld.c37
12 files changed, 173 insertions, 235 deletions
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index e58b8825605..69b2c9360d8 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -20,6 +20,7 @@ config EFI_LOADER
select DM_EVENT
select EVENT_DYNAMIC
select LIB_UUID
+ select LMB
imply PARTITION_UUIDS
select REGEX
imply FAT
@@ -552,6 +553,18 @@ config EFI_HTTP_BOOT
directly boot from network.
endmenu
+config BOOTEFI_HELLO_COMPILE
+ bool "Compile a standard EFI hello world binary for testing"
+ default y
+ help
+ This compiles a standard EFI hello world application with U-Boot so
+ that it can be used with the test/py testing framework. This is useful
+ for testing that EFI is working at a basic level, and for bringing
+ up EFI support on a new architecture.
+
+ No additional space will be required in the resulting U-Boot binary
+ when this option is enabled.
+
endif
source "lib/efi/Kconfig"
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 2af6f2066b5..00d18966f9e 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -11,40 +11,14 @@ asflags-y += -I.
CFLAGS_efi_boottime.o += \
-DFW_VERSION="0x$(VERSION)" \
-DFW_PATCHLEVEL="0x$(PATCHLEVEL)"
-CFLAGS_boothart.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_boothart.o := $(CFLAGS_NON_EFI)
-CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI)
-CFLAGS_smbiosdump.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_smbiosdump.o := $(CFLAGS_NON_EFI)
-CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI)
-CFLAGS_initrddump.o := $(CFLAGS_EFI) -Os -ffreestanding
-CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI)
-
-ifdef CONFIG_RISCV
-always += boothart.efi
-targets += boothart.o
-endif
-
-ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
-always += helloworld.efi
-targets += helloworld.o
-endif
-
-ifneq ($(CONFIG_GENERATE_SMBIOS_TABLE),)
-always += smbiosdump.efi
-targets += smbiosdump.o
-endif
+# These are the apps that are built
+apps-$(CONFIG_RISCV) += boothart
+apps-$(CONFIG_BOOTEFI_HELLO_COMPILE) += helloworld
+apps-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbiosdump
+apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump
ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
-always += dtbdump.efi
-targets += dtbdump.o
-endif
-
-ifdef CONFIG_EFI_LOAD_FILE2_INITRD
-always += initrddump.efi
-targets += initrddump.o
+apps-y += dtbdump
endif
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
@@ -95,3 +69,11 @@ obj-$(CONFIG_EFI_ECPT) += efi_conformance.o
EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE))
$(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE)
+
+# Set the C flags to add and remove for each app
+$(foreach f,$(apps-y),\
+ $(eval CFLAGS_$(f).o := $(CFLAGS_EFI) -Os -ffreestanding)\
+ $(eval CFLAGS_REMOVE_$(f).o := $(CFLAGS_NON_EFI)))
+
+always += $(foreach f,$(apps-y),$(f).efi)
+targets += $(foreach f,$(apps-y),$(f).o)
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index cea50c748aa..9d9f786a6db 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -100,7 +100,7 @@ static int term_get_char(s32 *c)
}
/**
- * Receive and parse a reply from the terminal.
+ * term_read_reply() - receive and parse a reply from the terminal
*
* @n: array of return values
* @num: number of return values expected
diff --git a/lib/efi_loader/efi_dt_fixup.c b/lib/efi_loader/efi_dt_fixup.c
index 9d017804eea..0dac94b0c6c 100644
--- a/lib/efi_loader/efi_dt_fixup.c
+++ b/lib/efi_loader/efi_dt_fixup.c
@@ -41,7 +41,7 @@ static void efi_reserve_memory(u64 addr, u64 size, bool nomap)
}
/**
- * efi_try_purge_kaslr_seed() - Remove unused kaslr-seed
+ * efi_try_purge_rng_seed() - Remove unused kaslr-seed, rng-seed
*
* Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for randomization
* and completely ignores the kaslr-seed for its own randomness needs
@@ -51,8 +51,9 @@ static void efi_reserve_memory(u64 addr, u64 size, bool nomap)
*
* @fdt: Pointer to device tree
*/
-void efi_try_purge_kaslr_seed(void *fdt)
+void efi_try_purge_rng_seed(void *fdt)
{
+ const char * const prop[] = {"kaslr-seed", "rng-seed"};
const efi_guid_t efi_guid_rng_protocol = EFI_RNG_PROTOCOL_GUID;
struct efi_handler *handler;
efi_status_t ret;
@@ -67,9 +68,13 @@ void efi_try_purge_kaslr_seed(void *fdt)
if (nodeoff < 0)
return;
- err = fdt_delprop(fdt, nodeoff, "kaslr-seed");
- if (err < 0 && err != -FDT_ERR_NOTFOUND)
- log_err("Error deleting kaslr-seed\n");
+ for (size_t i = 0; i < ARRAY_SIZE(prop); ++i) {
+ err = fdt_delprop(fdt, nodeoff, prop[i]);
+ if (err < 0 && err != -FDT_ERR_NOTFOUND)
+ log_err("Error deleting %s\n", prop[i]);
+ else
+ log_debug("Deleted /chosen/%s\n", prop[i]);
+ }
}
/**
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 222001d6a3b..c92d8ccf004 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -295,7 +295,7 @@ out:
}
/**
- * efi_file_open_()
+ * efi_file_open() - open file synchronously
*
* This function implements the Open service of the File Protocol.
* See the UEFI spec for details.
diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index 96f847652ec..00167bd2a10 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -412,7 +412,7 @@ static efi_status_t copy_fdt(void **fdtp)
EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
&new_fdt_addr);
if (ret != EFI_SUCCESS) {
- log_err("ERROR: Failed to reserve space for FDT\n");
+ log_err("Failed to reserve space for FDT\n");
goto done;
}
new_fdt = (void *)(uintptr_t)new_fdt_addr;
@@ -468,7 +468,7 @@ efi_status_t efi_install_fdt(void *fdt)
* but not both.
*/
if (CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) && fdt)
- log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n");
+ log_warning("Can't have ACPI table and device tree - ignoring DT.\n");
if (fdt == EFI_FDT_USE_INTERNAL) {
const char *fdt_opt;
@@ -483,13 +483,13 @@ efi_status_t efi_install_fdt(void *fdt)
if (!fdt_opt) {
fdt_opt = env_get("fdtcontroladdr");
if (!fdt_opt) {
- log_err("ERROR: need device tree\n");
+ log_err("need device tree\n");
return EFI_NOT_FOUND;
}
}
fdt_addr = hextoul(fdt_opt, NULL);
if (!fdt_addr) {
- log_err("ERROR: invalid $fdt_addr or $fdtcontroladdr\n");
+ log_err("invalid $fdt_addr or $fdtcontroladdr\n");
return EFI_LOAD_ERROR;
}
fdt = map_sysmem(fdt_addr, 0);
@@ -497,7 +497,7 @@ efi_status_t efi_install_fdt(void *fdt)
/* Install device tree */
if (fdt_check_header(fdt)) {
- log_err("ERROR: invalid device tree\n");
+ log_err("invalid device tree\n");
return EFI_LOAD_ERROR;
}
@@ -510,24 +510,24 @@ efi_status_t efi_install_fdt(void *fdt)
/* Prepare device tree for payload */
ret = copy_fdt(&fdt);
if (ret) {
- log_err("ERROR: out of memory\n");
+ log_err("out of memory\n");
return EFI_OUT_OF_RESOURCES;
}
if (image_setup_libfdt(&img, fdt, false)) {
- log_err("ERROR: failed to process device tree\n");
+ log_err("failed to process device tree\n");
return EFI_LOAD_ERROR;
}
/* Create memory reservations as indicated by the device tree */
efi_carve_out_dt_rsv(fdt);
- efi_try_purge_kaslr_seed(fdt);
+ efi_try_purge_rng_seed(fdt);
if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) {
ret = efi_tcg2_measure_dtb(fdt);
if (ret == EFI_SECURITY_VIOLATION) {
- log_err("ERROR: failed to measure DTB\n");
+ log_err("failed to measure DTB\n");
return ret;
}
}
@@ -535,7 +535,7 @@ efi_status_t efi_install_fdt(void *fdt)
/* Install device tree as UEFI table */
ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
if (ret != EFI_SUCCESS) {
- log_err("ERROR: failed to install device tree\n");
+ log_err("failed to install device tree\n");
return ret;
}
@@ -574,7 +574,7 @@ efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options)
*/
ret = efi_set_watchdog(300);
if (ret != EFI_SUCCESS) {
- log_err("ERROR: Failed to set watchdog timer\n");
+ log_err("failed to set watchdog timer\n");
goto out;
}
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index c6f1dd09456..9f3f0876997 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -9,6 +9,7 @@
#include <efi_loader.h>
#include <init.h>
+#include <lmb.h>
#include <log.h>
#include <malloc.h>
#include <mapmem.h>
@@ -172,17 +173,19 @@ static void efi_mem_sort(void)
/**
* efi_mem_carve_out() - unmap memory region
*
- * @map: memory map
- * @carve_desc: memory region to unmap
- * @overlap_only_ram: the carved out region may only overlap RAM
- * Return: the number of overlapping pages which have been
- * removed from the map,
- * EFI_CARVE_NO_OVERLAP, if the regions don't overlap,
- * EFI_CARVE_OVERLAPS_NONRAM, if the carve and map overlap,
- * and the map contains anything but free ram
- * (only when overlap_only_ram is true),
- * EFI_CARVE_LOOP_AGAIN, if the mapping list should be
- * traversed again, as it has been altered.
+ * @map: memory map
+ * @carve_desc: memory region to unmap
+ * @overlap_conventional: the carved out region may only overlap free,
+ * or conventional memory
+ * Return: the number of overlapping pages which have been
+ * removed from the map,
+ * EFI_CARVE_NO_OVERLAP, if the regions don't
+ * overlap, EFI_CARVE_OVERLAPS_NONRAM, if the carve
+ * and map overlap, and the map contains anything
+ * but free ram(only when overlap_conventional is
+ * true),
+ * EFI_CARVE_LOOP_AGAIN, if the mapping list should
+ * be traversed again, as it has been altered.
*
* Unmaps all memory occupied by the carve_desc region from the list entry
* pointed to by map.
@@ -192,7 +195,7 @@ static void efi_mem_sort(void)
*/
static s64 efi_mem_carve_out(struct efi_mem_list *map,
struct efi_mem_desc *carve_desc,
- bool overlap_only_ram)
+ bool overlap_conventional)
{
struct efi_mem_list *newmap;
struct efi_mem_desc *map_desc = &map->desc;
@@ -207,7 +210,7 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map,
return EFI_CARVE_NO_OVERLAP;
/* We're overlapping with non-RAM, warn the caller if desired */
- if (overlap_only_ram && (map_desc->type != EFI_CONVENTIONAL_MEMORY))
+ if (overlap_conventional && (map_desc->type != EFI_CONVENTIONAL_MEMORY))
return EFI_CARVE_OVERLAPS_NONRAM;
/* Sanitize carve_start and carve_end to lie within our bounds */
@@ -257,15 +260,17 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map,
/**
* efi_add_memory_map_pg() - add pages to the memory map
*
- * @start: start address, must be a multiple of EFI_PAGE_SIZE
- * @pages: number of pages to add
- * @memory_type: type of memory added
- * @overlap_only_ram: region may only overlap RAM
- * Return: status code
+ * @start: start address, must be a multiple of
+ * EFI_PAGE_SIZE
+ * @pages: number of pages to add
+ * @memory_type: type of memory added
+ * @overlap_conventional: region may only overlap free(conventional)
+ * memory
+ * Return: status code
*/
-static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
- int memory_type,
- bool overlap_only_ram)
+efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
+ int memory_type,
+ bool overlap_conventional)
{
struct efi_mem_list *lmem;
struct efi_mem_list *newlist;
@@ -274,7 +279,8 @@ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
struct efi_event *evt;
EFI_PRINT("%s: 0x%llx 0x%llx %d %s\n", __func__,
- start, pages, memory_type, overlap_only_ram ? "yes" : "no");
+ start, pages, memory_type, overlap_conventional ?
+ "yes" : "no");
if (memory_type >= EFI_MAX_MEMORY_TYPE)
return EFI_INVALID_PARAMETER;
@@ -311,7 +317,7 @@ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
s64 r;
r = efi_mem_carve_out(lmem, &newlist->desc,
- overlap_only_ram);
+ overlap_conventional);
switch (r) {
case EFI_CARVE_OUT_OF_RESOURCES:
free(newlist);
@@ -347,7 +353,7 @@ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
}
} while (carve_again);
- if (overlap_only_ram && (carved_pages != pages)) {
+ if (overlap_conventional && (carved_pages != pages)) {
/*
* The payload wanted to have RAM overlaps, but we overlapped
* with an unallocated region. Error out.
@@ -433,53 +439,6 @@ static efi_status_t efi_check_allocated(u64 addr, bool must_be_allocated)
}
/**
- * efi_find_free_memory() - find free memory pages
- *
- * @len: size of memory area needed
- * @max_addr: highest address to allocate
- * Return: pointer to free memory area or 0
- */
-static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr)
-{
- struct efi_mem_list *lmem;
-
- /*
- * Prealign input max address, so we simplify our matching
- * logic below and can just reuse it as return pointer.
- */
- max_addr &= ~EFI_PAGE_MASK;
-
- list_for_each_entry(lmem, &efi_mem, link) {
- struct efi_mem_desc *desc = &lmem->desc;
- uint64_t desc_len = desc->num_pages << EFI_PAGE_SHIFT;
- uint64_t desc_end = desc->physical_start + desc_len;
- uint64_t curmax = min(max_addr, desc_end);
- uint64_t ret = curmax - len;
-
- /* We only take memory from free RAM */
- if (desc->type != EFI_CONVENTIONAL_MEMORY)
- continue;
-
- /* Out of bounds for max_addr */
- if ((ret + len) > max_addr)
- continue;
-
- /* Out of bounds for upper map limit */
- if ((ret + len) > desc_end)
- continue;
-
- /* Out of bounds for lower map limit */
- if (ret < desc->physical_start)
- continue;
-
- /* Return the highest address in this map within bounds */
- return ret;
- }
-
- return 0;
-}
-
-/**
* efi_allocate_pages - allocate memory pages
*
* @type: type of allocation to be performed
@@ -493,8 +452,9 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type,
efi_uintn_t pages, uint64_t *memory)
{
u64 len;
+ uint flags;
efi_status_t ret;
- uint64_t addr;
+ phys_addr_t addr;
/* Check import parameters */
if (memory_type >= EFI_PERSISTENT_MEMORY_TYPE &&
@@ -508,33 +468,38 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type,
(len >> EFI_PAGE_SHIFT) != (u64)pages)
return EFI_OUT_OF_RESOURCES;
+ flags = LMB_NOOVERWRITE | LMB_NONOTIFY;
switch (type) {
case EFI_ALLOCATE_ANY_PAGES:
/* Any page */
- addr = efi_find_free_memory(len, -1ULL);
+ addr = (u64)lmb_alloc_base_flags(len, EFI_PAGE_SIZE,
+ LMB_ALLOC_ANYWHERE, flags);
if (!addr)
return EFI_OUT_OF_RESOURCES;
break;
case EFI_ALLOCATE_MAX_ADDRESS:
/* Max address */
- addr = efi_find_free_memory(len, *memory);
+ addr = map_to_sysmem((void *)(uintptr_t)*memory);
+ addr = (u64)lmb_alloc_base_flags(len, EFI_PAGE_SIZE, addr,
+ flags);
if (!addr)
return EFI_OUT_OF_RESOURCES;
break;
case EFI_ALLOCATE_ADDRESS:
if (*memory & EFI_PAGE_MASK)
return EFI_NOT_FOUND;
- /* Exact address, reserve it. The addr is already in *memory. */
- ret = efi_check_allocated(*memory, false);
- if (ret != EFI_SUCCESS)
+
+ addr = map_to_sysmem((void *)(uintptr_t)*memory);
+ addr = (u64)lmb_alloc_addr_flags(addr, len, flags);
+ if (!addr)
return EFI_NOT_FOUND;
- addr = *memory;
break;
default:
/* UEFI doesn't specify other allocation types */
return EFI_INVALID_PARAMETER;
}
+ addr = (u64)(uintptr_t)map_sysmem(addr, 0);
/* Reserve that map in our memory maps */
ret = efi_add_memory_map_pg(addr, pages, memory_type, true);
if (ret != EFI_SUCCESS)
@@ -555,6 +520,9 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type,
*/
efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
{
+ u64 len;
+ uint flags;
+ long status;
efi_status_t ret;
ret = efi_check_allocated(memory, true);
@@ -568,6 +536,13 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
return EFI_INVALID_PARAMETER;
}
+ flags = LMB_NOOVERWRITE | LMB_NONOTIFY;
+ len = (u64)pages << EFI_PAGE_SHIFT;
+ status = lmb_free_flags(map_to_sysmem((void *)(uintptr_t)memory), len,
+ flags);
+ if (status)
+ return EFI_NOT_FOUND;
+
ret = efi_add_memory_map_pg(memory, pages, EFI_CONVENTIONAL_MEMORY,
false);
if (ret != EFI_SUCCESS)
@@ -678,7 +653,7 @@ void *efi_alloc(size_t size)
if (efi_allocate_pool(EFI_BOOT_SERVICES_DATA, size, &buf) !=
EFI_SUCCESS) {
- log_err("out of memory");
+ log_err("out of memory\n");
return NULL;
}
memset(buf, 0, size);
@@ -814,82 +789,17 @@ efi_status_t efi_get_memory_map_alloc(efi_uintn_t *map_size,
}
/**
- * efi_add_conventional_memory_map() - add a RAM memory area to the map
+ * efi_add_known_memory() - add memory types to the EFI memory map
*
- * @ram_start: start address of a RAM memory area
- * @ram_end: end address of a RAM memory area
- * @ram_top: max address to be used as conventional memory
- * Return: status code
- */
-efi_status_t efi_add_conventional_memory_map(u64 ram_start, u64 ram_end,
- u64 ram_top)
-{
- u64 pages;
-
- /* Remove partial pages */
- ram_end &= ~EFI_PAGE_MASK;
- ram_start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
-
- if (ram_end <= ram_start) {
- /* Invalid mapping */
- return EFI_INVALID_PARAMETER;
- }
-
- pages = (ram_end - ram_start) >> EFI_PAGE_SHIFT;
-
- efi_add_memory_map_pg(ram_start, pages,
- EFI_CONVENTIONAL_MEMORY, false);
-
- /*
- * Boards may indicate to the U-Boot memory core that they
- * can not support memory above ram_top. Let's honor this
- * in the efi_loader subsystem too by declaring any memory
- * above ram_top as "already occupied by firmware".
- */
- if (ram_top < ram_start) {
- /* ram_top is before this region, reserve all */
- efi_add_memory_map_pg(ram_start, pages,
- EFI_BOOT_SERVICES_DATA, true);
- } else if (ram_top < ram_end) {
- /* ram_top is inside this region, reserve parts */
- pages = (ram_end - ram_top) >> EFI_PAGE_SHIFT;
-
- efi_add_memory_map_pg(ram_top, pages,
- EFI_BOOT_SERVICES_DATA, true);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- * efi_add_known_memory() - add memory banks to map
+ * This function is to be used to add different memory types other
+ * than EFI_CONVENTIONAL_MEMORY to the EFI memory map. The conventional
+ * memory is handled by the LMB module and gets added to the memory
+ * map through the LMB module.
*
- * This function may be overridden for specific architectures.
+ * This function may be overridden for architectures specific purposes.
*/
__weak void efi_add_known_memory(void)
{
- u64 ram_top = gd->ram_top & ~EFI_PAGE_MASK;
- int i;
-
- /*
- * ram_top is just outside mapped memory. So use an offset of one for
- * mapping the sandbox address.
- */
- ram_top = (uintptr_t)map_sysmem(ram_top - 1, 0) + 1;
-
- /* Fix for 32bit targets with ram_top at 4G */
- if (!ram_top)
- ram_top = 0x100000000ULL;
-
- /* Add RAM */
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
- u64 ram_end, ram_start;
-
- ram_start = (uintptr_t)map_sysmem(gd->bd->bi_dram[i].start, 0);
- ram_end = ram_start + gd->bd->bi_dram[i].size;
-
- efi_add_conventional_memory_map(ram_start, ram_end, ram_top);
- }
}
/**
@@ -901,16 +811,6 @@ static void add_u_boot_and_runtime(void)
{
unsigned long runtime_start, runtime_end, runtime_pages;
unsigned long runtime_mask = EFI_PAGE_MASK;
- unsigned long uboot_start, uboot_pages;
- unsigned long uboot_stack_size = CONFIG_STACK_SIZE;
-
- /* Add U-Boot */
- uboot_start = ((uintptr_t)map_sysmem(gd->start_addr_sp, 0) -
- uboot_stack_size) & ~EFI_PAGE_MASK;
- uboot_pages = ((uintptr_t)map_sysmem(gd->ram_top - 1, 0) -
- uboot_start + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
- efi_add_memory_map_pg(uboot_start, uboot_pages, EFI_BOOT_SERVICES_CODE,
- false);
#if defined(__aarch64__)
/*
diff --git a/lib/efi_loader/efi_rng.c b/lib/efi_loader/efi_rng.c
index 9bad7ed6931..4734f95eee1 100644
--- a/lib/efi_loader/efi_rng.c
+++ b/lib/efi_loader/efi_rng.c
@@ -91,7 +91,7 @@ back:
}
/**
- * rng_getrng() - get random value
+ * getrng() - get random value
*
* This function implement the GetRng() service of the EFI random number
* generator protocol. See the UEFI spec for details.
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index a610e032d2f..aa59bc7779d 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -86,7 +86,6 @@ out:
return ret;
}
-#ifdef CONFIG_EFI_SECURE_BOOT
/**
* efi_init_secure_boot - initialize secure boot state
*
@@ -112,12 +111,6 @@ static efi_status_t efi_init_secure_boot(void)
return ret;
}
-#else
-static efi_status_t efi_init_secure_boot(void)
-{
- return EFI_SUCCESS;
-}
-#endif /* CONFIG_EFI_SECURE_BOOT */
/**
* efi_init_capsule - initialize capsule update state
@@ -302,9 +295,11 @@ efi_status_t efi_init_obj_list(void)
}
/* Secure boot */
- ret = efi_init_secure_boot();
- if (ret != EFI_SUCCESS)
- goto out;
+ if (IS_ENABLED(CONFIG_EFI_SECURE_BOOT)) {
+ ret = efi_init_secure_boot();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
/* Indicate supported runtime services */
ret = efi_init_runtime_supported();
@@ -322,11 +317,11 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;
}
-#ifdef CONFIG_NETDEVICES
- ret = efi_net_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
+ if (IS_ENABLED(CONFIG_NETDEVICES)) {
+ ret = efi_net_register();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
if (IS_ENABLED(CONFIG_ACPI)) {
ret = efi_acpi_register();
if (ret != EFI_SUCCESS)
diff --git a/lib/efi_loader/efi_unicode_collation.c b/lib/efi_loader/efi_unicode_collation.c
index 627bb9123cf..d48700a352b 100644
--- a/lib/efi_loader/efi_unicode_collation.c
+++ b/lib/efi_loader/efi_unicode_collation.c
@@ -266,7 +266,7 @@ static void EFIAPI efi_fat_to_str(struct efi_unicode_collation_protocol *this,
}
/**
- * efi_fat_to_str() - convert a utf-16 string to legal characters for a FAT
+ * efi_str_to_fat() - convert a utf-16 string to legal characters for a FAT
* file name in an OEM code page
*
* @this: unicode collation protocol instance
diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 413e1794e88..ba0bf33ffbd 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -37,18 +37,16 @@ static efi_status_t __maybe_unused efi_set_blk_dev_to_system_partition(void)
char part_str[PART_STR_LEN];
int r;
- if (efi_system_partition.uclass_id == UCLASS_INVALID) {
- log_err("No EFI system partition\n");
+ if (efi_system_partition.uclass_id == UCLASS_INVALID)
return EFI_DEVICE_ERROR;
- }
+
snprintf(part_str, PART_STR_LEN, "%x:%x",
efi_system_partition.devnum, efi_system_partition.part);
r = fs_set_blk_dev(blk_get_uclass_name(efi_system_partition.uclass_id),
part_str, FS_TYPE_ANY);
- if (r) {
- log_err("Cannot read EFI system partition\n");
+ if (r)
return EFI_DEVICE_ERROR;
- }
+
return EFI_SUCCESS;
}
@@ -67,14 +65,21 @@ efi_status_t efi_var_to_file(void)
loff_t len;
loff_t actlen;
int r;
+ static bool once;
ret = efi_var_collect(&buf, &len, EFI_VARIABLE_NON_VOLATILE);
if (ret != EFI_SUCCESS)
goto error;
ret = efi_set_blk_dev_to_system_partition();
- if (ret != EFI_SUCCESS)
- goto error;
+ if (ret != EFI_SUCCESS) {
+ if (!once) {
+ log_warning("Cannot persist EFI variables without system partition\n");
+ once = true;
+ }
+ goto out;
+ }
+ once = false;
r = fs_write(EFI_VAR_FILE_NAME, map_to_sysmem(buf), 0, len, &actlen);
if (r || len != actlen)
@@ -83,6 +88,7 @@ efi_status_t efi_var_to_file(void)
error:
if (ret != EFI_SUCCESS)
log_err("Failed to persist EFI variables\n");
+out:
free(buf);
return ret;
#else
diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
index 586177de0c8..d10a5229f74 100644
--- a/lib/efi_loader/helloworld.c
+++ b/lib/efi_loader/helloworld.c
@@ -72,6 +72,33 @@ static void uint2dec(u32 value, u16 **buf)
}
/**
+ * Print an unsigned 32bit value as hexadecimal number to an u16 string
+ *
+ * @value: value to be printed
+ * @buf: pointer to buffer address
+ * on return position of terminating zero word
+ */
+static void uint2hex(u32 value, u16 **buf)
+{
+ u16 *pos = *buf;
+ int i;
+ u16 c;
+
+ for (i = 0; i < 8; ++i) {
+ /* Write current digit */
+ c = value >> 28;
+ value <<= 4;
+ if (c < 10)
+ c += '0';
+ else
+ c += 'a' - 10;
+ *pos++ = c;
+ }
+ *pos = 0;
+ *buf = pos;
+}
+
+/**
* print_uefi_revision() - print UEFI revision number
*/
static void print_uefi_revision(void)
@@ -96,6 +123,16 @@ static void print_uefi_revision(void)
con_out->output_string(con_out, u"Running on UEFI ");
con_out->output_string(con_out, rev);
con_out->output_string(con_out, u"\r\n");
+
+ con_out->output_string(con_out, u"Firmware vendor: ");
+ con_out->output_string(con_out, systable->fw_vendor);
+ con_out->output_string(con_out, u"\r\n");
+
+ buf = rev;
+ uint2hex(systable->fw_revision, &buf);
+ con_out->output_string(con_out, u"Firmware revision: ");
+ con_out->output_string(con_out, rev);
+ con_out->output_string(con_out, u"\r\n");
}
/**