summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2023-01-24efi: Improve logging in efi_diskSimon Glass1-9/+21
When this fails it can be time-consuming to debug. Add some debugging to help with this. Also try to return error codes instead of just using -1. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24lib: Support printing an error stringSimon Glass1-0/+12
It is often useful to show an error code to give the user a clue as to what went wrong. When error strings are compiled into U-Boot it is possible to show a message as well. But at present it is not very convenient, since code must check if the error strings are present, then obtain the error string and use it in a printf() string. Add a %dE option which shows an error code along with an error string, if available. This makes it easy to show one or both. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24lib: Add a function to split a string into substringsSimon Glass1-0/+41
Some environment variables provide a space-separated list of strings. It is easier to process these when they are broken out into an array of strings. Add a utility function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-20Merge tag 'efi-2023-04-rc1-2' of ↵Tom Rini5-6/+34
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2023-04-rc1-2 Documentation * man-pages for source, blkcache, bdinfo * fix references to distro documentation UEFI: * allow clear screen by scrolling * ensure that file ubootefi.var is created * fix CapsuleMax variable reporting Others: * reduce verbosity of fat_read_file()
2023-01-20global: Finish CONFIG -> CFG migrationTom Rini2-10/+10
At this point, the remaining places where we have a symbol that is defined as CONFIG_... are in fairly odd locations. While as much dead code has been removed as possible, some of these locations are simply less obvious at first. In other cases, this code is used, but was defined in such a way as to have been missed by earlier checks. Perform a rename of all such remaining symbols to be CFG_... rather than CONFIG_... Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-20efi_loader: fix CapsuleMax variable reportingIlias Apalodimas1-1/+1
Currently the code that adds the CapsuleMax variable is under a Kconfig named 'EFI_HAVE_CAPSULE_UPDATE. Git history only shows a single occurrence of that. The IS_ENABLED should be checking for EFI_HAVE_CAPSULE_SUPPORT Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-20efi_loader: update the error message of TCG protocol installationIlias Apalodimas1-1/+1
"Unable to find TPMv2 device" doesn't explain much with regards to the error origin. Update it to match what we have in the RNG protocol installation. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-20efi_loader: ensure that file ubootefi.var is createdHeinrich Schuchardt1-3/+5
Currently file ubootefi.var is only created if the user sets a non-volatile EFI variable. If the file is missing, a warning is written. With the change PlatformLang is always persisted. So the file will exist on second boot. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-20efi_loader: Avoid overwriting previous outputs on console screen clearingJan Kiszka2-1/+21
Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs. Tested regarding multi-output against qemu-x86_defconfig. Still, there were remaining concerns about side effects, so this is provided as an opt-in feature. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-20efi_loader: Set default console colors on efi_cout_clear_screen if neededJan Kiszka1-0/+6
Ensures a consistent background color of the whole screen for succeeding outputs as both demanded by the spec and implemented in EDK2 as well. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-19Merge tag 'dm-pull-18jan23' of ↵Tom Rini5-52/+103
https://source.denx.de/u-boot/custodians/u-boot-dm convert rockchip to use binman patman fix for checkpatch binman optional entries, improved support for ELF symbols trace improvements minor fdt refactoring
2023-01-19lib: zstd: update to latest Linux zstd 1.5.2Brandon Maier41-6570/+10732
Update the zstd implementation to match Linux zstd 1.5.2 from commit 2aa14b1ab2. This was motivated by running into decompression corruption issues when trying to uncompress files compressed with newer versions of zstd. zstd users also claim significantly improved decompression times with newer zstd versions which is a side benefit. Original zstd code was copied from Linux commit 2aa14b1ab2 which is a custom-built implementation based on zstd 1.3.1. Linux switched to an implementation that is a copy of the upstream zstd code in Linux commit e0c1b49f5b, this results in a large code diff. However this should make future updates easier along with other benefits[1]. This commit is a straight mirror of the Linux zstd code, except to: - update a few #include that do not translate cleanly - linux/swab.h -> asm/byteorder.h - linux/limits.h -> linux/kernel.h - linux/module.h -> linux/compat.h - remove assert() from debug.h so it doesn't conflict with u-boot's assert() - strip out the compressor code as was done in the previous u-boot zstd - update existing zstd users to the new Linux zstd API - change the #define for MEM_STATIC to use INLINE_KEYWORD for codesize - add a new KConfig option that sets zstd build options to minify code based on zstd's ZSTD_LIB_MINIFY[2]. These changes were tested by booting a zstd 1.5.2 compressed kernel inside a FIT. And the squashfs changes by loading a file from zstd compressed squashfs with sqfsload. buildman was used to compile test other boards and check for binary bloat, as follows: > $ buildman -b zstd2 --boards dh_imx6,m53menlo,mvebu_espressobin-88f3720,sandbox,sandbox64,stm32mp15_dhcom_basic,stm32mp15_dhcor_basic,turris_mox,turris_omnia -sS > Summary of 6 commits for 9 boards (8 threads, 1 job per thread) > 01: Merge branch '2023-01-10-platform-updates' > arm: w+ m53menlo dh_imx6 > 02: lib: zstd: update to latest Linux zstd 1.5.2 > aarch64: (for 2/2 boards) all -3186.0 rodata +920.0 text -4106.0 > arm: (for 5/5 boards) all +1254.4 rodata +940.0 text +314.4 > sandbox: (for 2/2 boards) all -4452.0 data -16.0 rodata +640.0 text -5076.0 [1] https://github.com/torvalds/linux/commit/e0c1b49f5b674cca7b10549c53b3791d0bbc90a8 [2] https://github.com/facebook/zstd/blob/f302ad8811643c428c4e3498e28f53a0578020d3/lib/libzstd.mk#L31 Signed-off-by: Brandon Maier <brandon.maier@collins.com> [trini: Set ret to -EINVAL for the error of "failed to detect compressed" to fix warning, drop ZSTD_SRCSIZEHINT_MAX for non-Linux host tool builds] Signed-off-by: Tom Rini <trini@konsulko.com>
2023-01-18Revert "fdtdec: drop needlessly convoluted CONFIG_PHANDLE_CHECK_SEQ"Simon Glass2-2/+12
The fdt_path_offset() function is slow since it must scan the tree. This substantial overhead now applies to all boards. The original code may not be ideal but it is fit for purpose and is only needed on a few boards. Reverting this reduces time to set up driver model by about 30ms. Before revert: Accumulated time: 47,170 dm_r 53,237 dm_spl 572,986 dm_f Accumulated time: 44,598 dm_r 50,347 dm_spl 549,133 dm_f This reverts commit 26f981f295d00351b6f0c69b5317b254b2361cc0. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18trace: Don't require TIMER_EARLYSimon Glass1-1/+1
Some platforms cannot honour this and don't need trace before relocation. Use 'imply' instead, so boards can disable this. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18trace: Move trace pointer to data sectionSimon Glass1-1/+2
This can be written before relocation. Move it to the data section, since accessing BSS before relocation is not permitted. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18fdt: Check for overlapping data and FDTSimon Glass1-0/+23
If the FDT overlaps with the data region of the image, or with the stack, it can become corrupted before relocation. Add a check for this, behind a debug flag, as it can be very confusing and time-consuming to debug. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18fdt: Pass the device tree to fdtdec_prepare_fdt()Simon Glass1-11/+11
This function uses gd->fdt_blob a lot and cannot be used to check any other device tree. Use a parameter instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18fdt: Drop ifdefs in fdtdec_prepare_fdt()Simon Glass1-15/+17
This function is a bit messy with several #ifdefs. Convert them to use C for the conditions. Rewrite the function comment since most of it is stale. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18fdt: Avoid exporting fdtdec_prepare_fdt()Simon Glass1-13/+13
This function is not used outside this file. Make it static. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18tpm: Add a proper Kconfig option for crc8 in SPLSimon Glass2-1/+20
The current approach is a bit of a hack and only works for the tpm subsystem. Add a Kconfig so that crc8 can be enabled in SPL for other purposes. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18trace: Use notrace for shortSimon Glass2-17/+13
The attribute syntax is quite verbose. Use the macro provided for this purpose. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18event: Correct dependencies on the EVENT frameworkTom Rini1-1/+1
The event framework is just that, a framework. Enabling it by itself does nothing, so we shouldn't ask the user about it. Reword (and correct typos) around this the option and help text. This also applies to DM_EVENT and EVENT_DYNAMIC. Only EVENT_DEBUG and CMD_EVENT should be visible to the user to select, when EVENT is selected. With this, it's time to address the larger problems. When functionality uses events, typically via EVENT_SPY, the appropriate framework then must be select'd and NOT imply'd. As the functionality will cease to work (and so, platforms will fail to boot) this is non-optional and where select is appropriate. Audit the current users of EVENT_SPY to have a more fine-grained approach to select'ing the framework where used. Also ensure the current users of event_register and also select EVENT_DYNAMIC. Cc: AKASHI Takahiro <takahiro.akashi@linaro.org> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Reported-by: Oliver Graute <Oliver.Graute@kococonnector.com> Reported-by: Francesco Dolcini <francesco.dolcini@toradex.com> Fixes: 7fe32b3442f0 ("event: Convert arch_cpu_init_dm() to use events") Fixes: 42fdcebf859f ("event: Convert misc_init_f() to use events") Fixes: c5ef2025579e ("dm: fix DM_EVENT dependencies") Signed-off-by: Tom Rini <trini@konsulko.com> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Fabio Estevam <festevam@denx.de>
2023-01-16rc4: mark key as constJohn Keeping1-1/+1
Key data is never written so the parameter can be const, which allows putting fixed keys in .rodata. Signed-off-by: John Keeping <john@metanate.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@vrull.eu> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-01-13efi_loader: provide agent_handle to efi_disk_add_dev()Heinrich Schuchardt1-21/+29
In efi_disk_add_dev() we have to open protocols with BY_DRIVER and BY_CHILD_CONTROLLER. Provide the handle of the EFI block driver. The actual usage of the value will follow in a later patch. Change function descriptions to Sphinx style. Remove a TODO: tag. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-13efi_selftest: add hii set keyboard layout test caseVincent Stehlé1-0/+12
Add a test for the case when the HII database protocol set_keyboard_layout() function is called with a NULL key_guid argument. Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-13efi_loader: refine set_keyboard_layout() statusVincent Stehlé1-0/+3
As per the EFI specification, the HII database protocol function set_keyboard_layout() must return EFI_INVALID_PARAMETER when it is called with a NULL key_guid argument. Modify the function accordingly to improve conformance. Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-13efi_loader: use EFI_EXIT in efi_riscv_get_boot_hartidHeinrich Schuchardt1-1/+1
After calling EFI_ENTRY we have to call EFI_EXIT before returning. Add a missing EFI_EXIT(). Fixes: 1ccf87165e38 ("efi_loader: Enable RISCV_EFI_BOOT_PROTOCOL support") Reported-by: Dave Jones <dave.jones@canonical.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>
2023-01-13efi_loader: fix description of memory functionsHeinrich Schuchardt1-20/+62
* Add missing function descriptions * Adjust to Sphinx style Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-12Revert "time: add weak annotation to timer_read_counter declaration"Harald Seiler1-1/+1
This reverts commit 65ba7add0d609bbd035b8d42fafdaf428ac24751. A weak extern is a nasty sight to behold: If the symbol is never defined, on ARM, the linker will replace the function call with a NOP. This behavior isn't well documented but there are at least some hints to it [1]. When timer_read_counter() is not defined, this obviously does the wrong thing here and it does so silently. The consequence is that a board without timer_read_counter() will sleep for random amounts and generally have erratic get_ticks() values. Drop the __weak annotation of the extern so a linker error is raised when timer_read_counter() is not defined. This is okay, the original reason for the reverted change - breaking the sandbox build - no longer applies. Final sidenote: This was the only weak extern in the entire tree at this time as far as I can tell. I guess we should avoid introduction of them again as they are obviously a very big footgun. [1]: https://stackoverflow.com/questions/31203402/gcc-behavior-for-unresolved-weak-functions Fixes: 65ba7add0d60 ("time: add weak annotation to timer_read_counter declaration") Reported-by: Serge Bazanski <q3k@q3k.org> Signed-off-by: Harald Seiler <hws@denx.de>
2023-01-11lib: rsa: cosmetic: fix building warningHaijun Qin1-1/+1
add initialization of variable 'node',this can aviod the building warning: 'node' may be used uninitialized [-Wmaybe-uninitialized] Signed-off-by: Haijun Qin <qinhaijun@eswincomputing.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-09Merge branch 'next'Tom Rini3-20/+17
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-01-07lmb: consider EFI memory mapHeinrich Schuchardt1-0/+36
Add reservations for all EFI memory areas that are not EFI_CONVENTIONAL_MEMORY. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-07efi_loader: carve out efi_get_memory_map_alloc()Heinrich Schuchardt1-0/+34
Carve out code from efidebug command used to read the memory map. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-04efi_loader: populate console handles in system tableHeinrich Schuchardt1-0/+3
The fields ConsoleInHandle, ConsoleOutHandle, ConsoleErrHandle must point to the handles with the respective console protocols. Failure to do so leads to an error in the EFI Shell: No SimpleTextInputEx was found. CTRL-based features are not usable. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-04efi_loader: adjust sorting of capsulesHeinrich Schuchardt1-3/+6
Up to now we only compared the first letter of the capsule name to sort them alphabetically. Properly sort by the Unicode alphabet. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-04lib: add function u16_strcasecmp()Heinrich Schuchardt1-0/+26
Provide a function for comparing UTF-16 strings in a case insensitive manner. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-12-29efi_loader: use u16_strlen() in efi_var_mem_ins()Heinrich Schuchardt1-3/+1
Don't duplicate library functionality. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-12-29efi_loader: avoid adding variables twiceIlias Apalodimas2-3/+5
When the efi subsystem starts we restore variables that are both in a file or stored into the .efi_runtime section of U-Boot. However once a variable gets created or changed the preseeded entries will end up in the file. As a consequence on the next boot we will end up adding identical variable entries twice. Fix this by checking if the to be inserted variable already exists. Also swap the restoration order and start with the file instead of the builtin variables, so a user can replace the preseeded ones if needed. Tested-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-12-29efi_loader: typo non-volatile in efi_var_restoreHeinrich Schuchardt1-1/+1
It is volatile variables that we do not allow to be restored from file. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-29efi_loader: fix get_package_list_handle() statusVincent Stehlé1-1/+1
When the HII protocol function get_package_list_handle() is called with an invalid package list handle, it returns EFI_NOT_FOUND but this is not in its list of possible status codes as per the EFI specification. Return EFI_INVALID_PARAMETER instead to fix conformance. Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-12-23rsa-verify: Rework host check for CONFIG_RSA_VERIFY_WITH_PKEYTom Rini1-13/+7
While we do not want to use CONFIG_RSA_VERIFY_WITH_PKEY on the host, we cannot undef the symbol in this manner. As this ends up being a test within another function we can use !tools_build() as a test here. Cc: AKASHI Takahiro <takahiro.akashi@linaro.org> Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-21Merge tag 'v2023.01-rc4' into nextTom Rini6-10/+245
Prepare v2023.01-rc4 Signed-off-by: Tom Rini <trini@konsulko.com>
2022-12-20efi_selftest: conformance test for GetNextVariableNameHeinrich Schuchardt1-0/+35
Test that GetNextVariableName() checks the parameters. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-20efi_loader: fix efi_get_next_variable_name_mem()Heinrich Schuchardt1-3/+3
The VariableNameSize parameter is in bytes but u16_strnlen() counts u16. Fix the parameter check for null termination. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-20eficonfig: carve out efi_get_next_variable_name_int callsMasahisa Kojima1-0/+34
To retrieve the EFI variable name by efi_get_next_variable_name_int(), the sequence of alloc -> efi_get_next_variable_name_int -> realloc -> efi_get_next_variable_name_int is required. In current code, this sequence repeatedly appears in the several functions. It should be curved out a common function. This commit also fixes the missing free() of var_name16 in eficonfig_delete_invalid_boot_option(). Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-12-17efi: adjust ebbr to v2.1 in conformance profileVincent Stehlé3-10/+10
The EFI Conformance Profile Table entry for EBBR appears in v2.1.0 of the EBBR specification[1]. Update naming accordingly. While at it, update the EBBR version referenced in the documentation. [1]: https://github.com/ARM-software/ebbr/releases/tag/v2.1.0 Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-12-08arch/riscv: add semihosting support for RISC-VKautuk Consul1-5/+5
We add RISC-V semihosting based serial console for JTAG based early debugging. The RISC-V semihosting specification is available at: https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc Signed-off-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Kautuk Consul <kconsul@ventanamicro.com> Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2022-12-08lib: Add common semihosting libraryKautuk Consul3-0/+235
We factor out the arch-independent parts of the ARM semihosting implementation as a common library so that it can be shared with RISC-V. Signed-off-by: Kautuk Consul <kconsul@ventanamicro.com> Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2022-12-06global: Move remaining CONFIG_SYS_* to CFG_SYS_*Tom Rini1-7/+7
The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do not easily transition to Kconfig. In many cases they likely should come from the device tree instead. Move these out of CONFIG namespace and in to CFG namespace. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-06Convert CONFIG_SYS_TIMER_COUNTS_DOWN to KconfigTom Rini1-0/+3
This converts the following to Kconfig: CONFIG_SYS_TIMER_COUNTS_DOWN Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>