From cf0bf89227594cf3fdcae8242f023685cdd11cb7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 17 Sep 2020 16:49:02 +0200 Subject: rng: stm32mp1: use log() instead of printf() The logging system provides flexible filtering and enhanced output. Signed-off-by: Heinrich Schuchardt Reviewed-by: Sughosh Ganu --- drivers/rng/stm32mp1_rng.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/rng/stm32mp1_rng.c b/drivers/rng/stm32mp1_rng.c index 7ef7ff9..c1bae18 100644 --- a/drivers/rng/stm32mp1_rng.c +++ b/drivers/rng/stm32mp1_rng.c @@ -3,6 +3,8 @@ * Copyright (c) 2019, Linaro Limited */ +#define LOG_CATEGORY UCLASS_RNG + #include #include #include @@ -53,7 +55,7 @@ static int stm32_rng_read(struct udevice *dev, void *data, size_t len) for (i = 0; i < 12; i++) readl(pdata->base + RNG_DR); if (readl(pdata->base + RNG_SR) & RNG_SR_SEIS) { - printf("RNG Noise"); + log_err("RNG Noise"); return -EIO; } /* start again */ -- cgit v1.1 From ffbeafe7e29fe179e2168b82f9c19b8e57293040 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Fri, 28 Aug 2020 22:47:41 +0300 Subject: efi_memory: refine overlap_only_ram description Refine text for overlap_only_ram description to match to what exactly flag does and aling description with other functions. Signed-off-by: Maxim Uvarov Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 7be756e..11e7553 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -235,7 +235,7 @@ static s64 efi_mem_carve_out(struct efi_mem_list *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: the memory area must overlap existing + * @overlap_only_ram: region may only overlap RAM * Return: status code */ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, -- cgit v1.1 From 18161a8a4eb622eae367f688058007d6a565b210 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 17 Sep 2020 07:33:29 +0200 Subject: efi_selftest: rework device tree test Allow specifying the node on which a property is searched. Test the device tree consistency more rigorously. Some efi_st_printf() calls have been converted to efi_st_error(). Signed-off-by: Heinrich Schuchardt --- lib/efi_selftest/efi_selftest_fdt.c | 53 +++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_fdt.c b/lib/efi_selftest/efi_selftest_fdt.c index 94d72d3..52a9630 100644 --- a/lib/efi_selftest/efi_selftest_fdt.c +++ b/lib/efi_selftest/efi_selftest_fdt.c @@ -42,35 +42,48 @@ static uint32_t f2h(fdt32_t val) return *(uint32_t *)buf; } -/* - * Return the value of a property of the FDT root node. +/** + * get_property() - return value of a property of an FDT node * - * @name name of the property + * A property of the root node or one of its direct children can be + * retrieved. + * + * @property name of the property + * @node name of the node or NULL for root node * @return value of the property */ -static char *get_property(const u16 *property) +static char *get_property(const u16 *property, const u16 *node) { struct fdt_header *header = (struct fdt_header *)fdt; + const fdt32_t *end; const fdt32_t *pos; const char *strings; + size_t level = 0; + const char *nodelabel = NULL; - if (!header) + if (!header) { + efi_st_error("Missing device tree\n"); return NULL; + } if (f2h(header->magic) != FDT_MAGIC) { - printf("Wrong magic\n"); + efi_st_error("Wrong device tree magic\n"); return NULL; } pos = (fdt32_t *)(fdt + f2h(header->off_dt_struct)); + end = &pos[f2h(header->totalsize) >> 2]; strings = fdt + f2h(header->off_dt_strings); - for (;;) { + for (; pos < end;) { switch (f2h(pos[0])) { case FDT_BEGIN_NODE: { - char *c = (char *)&pos[1]; + const char *c = (char *)&pos[1]; size_t i; + if (level == 1) + nodelabel = c; + ++level; for (i = 0; c[i]; ++i) ; pos = &pos[2 + (i >> 2)]; @@ -82,7 +95,10 @@ static char *get_property(const u16 *property) efi_status_t ret; /* Check if this is the property to be returned */ - if (!efi_st_strcmp_16_8(property, label)) { + if (!efi_st_strcmp_16_8(property, label) && + ((level == 1 && !node) || + (level == 2 && node && + !efi_st_strcmp_16_8(node, nodelabel)))) { char *str; efi_uintn_t len = f2h(prop->len); @@ -96,7 +112,7 @@ static char *get_property(const u16 *property) EFI_LOADER_DATA, len + 1, (void **)&str); if (ret != EFI_SUCCESS) { - efi_st_printf("AllocatePool failed\n"); + efi_st_error("AllocatePool failed\n"); return NULL; } boottime->copy_mem(str, &pos[3], len); @@ -109,12 +125,21 @@ static char *get_property(const u16 *property) break; } case FDT_NOP: - pos = &pos[1]; + ++pos; + break; + case FDT_END_NODE: + --level; + ++pos; break; + case FDT_END: + return NULL; default: + efi_st_error("Invalid device tree token\n"); return NULL; } } + efi_st_error("Missing FDT_END token\n"); + return NULL; } /** @@ -173,7 +198,7 @@ static int execute(void) char *str; efi_status_t ret; - str = get_property(L"compatible"); + str = get_property(L"compatible", NULL); if (str) { efi_st_printf("compatible: %s\n", str); ret = boottime->free_pool(str); @@ -182,10 +207,10 @@ static int execute(void) return EFI_ST_FAILURE; } } else { - efi_st_printf("Missing property 'compatible'\n"); + efi_st_error("Missing property 'compatible'\n"); return EFI_ST_FAILURE; } - str = get_property(L"serial-number"); + str = get_property(L"serial-number", NULL); if (str) { efi_st_printf("serial-number: %s\n", str); ret = boottime->free_pool(str); -- cgit v1.1 From 52a8481827511a0837b4944d1184214ac924a123 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 17 Sep 2020 07:33:29 +0200 Subject: efi_selftest: check for RISC-V boot-hartid in FDT On RISC-V check that the /chosen node has a boot-hartid property. To run the test configure with CONFIG_CMD_BOOTEFI_SELFTEST=y and issue setenv efi_selftest device tree setenv serial# myserial bootefi selftest If the test succeeds, it reports the boot-hartid, e.g. boot-hartid: 1 Signed-off-by: Heinrich Schuchardt --- lib/efi_selftest/efi_selftest_fdt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/efi_selftest/efi_selftest_fdt.c b/lib/efi_selftest/efi_selftest_fdt.c index 52a9630..eae9820 100644 --- a/lib/efi_selftest/efi_selftest_fdt.c +++ b/lib/efi_selftest/efi_selftest_fdt.c @@ -219,6 +219,21 @@ static int execute(void) return EFI_ST_FAILURE; } } + str = get_property(L"boot-hartid", L"chosen"); + if (IS_ENABLED(CONFIG_RISCV)) { + if (str) { + efi_st_printf("boot-hartid: %u\n", + f2h(*(fdt32_t *)str)); + ret = boottime->free_pool(str); + if (ret != EFI_SUCCESS) { + efi_st_error("FreePool failed\n"); + return EFI_ST_FAILURE; + } + } else { + efi_st_error("boot-hartid not found\n"); + return EFI_ST_FAILURE; + } + } return EFI_ST_SUCCESS; } -- cgit v1.1 From 8f0ac536d4937d07a95fcc56756c14ef7a94e397 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Fri, 28 Aug 2020 22:20:10 +0300 Subject: efi: change 'env -e -i' usage syntax 'env -e -i' syntax was changed from "," to ":". Account for this also in the documentation. Fixes: 2b3fbcb59f41 ("efi_loader: use ':' as separator for setenv -i") Signed-off-by: Maxim Uvarov Correct the usage description for setenv -e too. Reviewed-by: Heinrich Schuchardt --- cmd/nvedit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 9f145dd..7fce723 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -1477,7 +1477,7 @@ static char env_help_text[] = "env select [target] - select environment target\n" #endif #if defined(CONFIG_CMD_NVEDIT_EFI) - "env set -e [-nv][-bs][-rt][-at][-a][-i addr,size][-v] name [arg ...]\n" + "env set -e [-nv][-bs][-rt][-at][-a][-i addr:size][-v] name [arg ...]\n" " - set UEFI variable; unset if '-i' or 'arg' not specified\n" #endif "env set [-f] name [arg ...]\n"; @@ -1541,7 +1541,7 @@ U_BOOT_CMD_COMPLETE( "set environment variables", #if defined(CONFIG_CMD_NVEDIT_EFI) "-e [-guid guid][-nv][-bs][-rt][-at][-a][-v]\n" - " [-i addr,size name], or [name [value ...]]\n" + " [-i addr:size name], or [name [value ...]]\n" " - set UEFI variable 'name' to 'value' ...'\n" " \"-guid\": GUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n" " \"-nv\": set non-volatile attribute\n" -- cgit v1.1