summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* efi_loader: error code efi_dp_from_name()Heinrich Schuchardt2023-05-131-1/+1
| | | | | | Use EFI_OUT_OF_RESOURCES if the device path cannot be constructed. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: clean up efi_dp_from_fileHeinrich Schuchardt2023-05-131-7/+9
| | | | | | | | * Improve variable name usage: Use pos instead of buf to indicate the current position in a buffer. * Avoid double assignment in a single code line. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: duplicate code in efi_dp_from_nameHeinrich Schuchardt2023-05-131-13/+1
| | | | | | | efi_dp_from_name() has duplicate code to replace slash by backslash. path_to_uefi() called by efi_dp_from_file() already does this. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: avoid #ifdef in efi_dp_from_name()Heinrich Schuchardt2023-05-131-12/+8
| | | | | | | | | According to our coding style guide #ifdef should be avoided. Use IS_ENABLED() instead. Sort string comparisons alphabetically. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: support booting semihosting fileHeinrich Schuchardt2023-05-131-1/+2
| | | | | | | | | | | | Executing an EFI binary fails for files loaded via semihosting. Construct a dummy device path for EFI binaries loaded via semihosting. A future complete solution may include the creation of a handle with a simple file system protocol. Reported-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi_loader: print file path w/o boot deviceHeinrich Schuchardt2023-05-131-4/+4
| | | | | | | Helloworld.efi should print the file path even if the boot device is not set. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* fwu: fix config FWU_MULTI_BANK_UPDATEHeinrich Schuchardt2023-05-131-1/+1
| | | | | | | | | | | | | | Symbol CONFIG_EFI_SETUP_EARLY does not exist anymore. CONFIG_FWU_MULTI_BANK_UPDATE without CONFIG_FWU_MDATA results in lib/fwu_updates/fwu.c:49: undefined reference to `fwu_get_mdata' Fixes: 86794052418b ("FWU: Add support for the FWU Multi Bank Update feature") Fixes: 023d9c93932c ("efi_loader: remove CONFIG_EFI_SETUP_EARLY") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org>
* acpi: Move the table-finding functions into the libarySimon Glass2023-05-112-0/+47
| | | | | | | | | This is useful for other features. Move the function into library code so it can be used outside just the 'acpi' command. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
* acpi: Create a new Kconfig for ACPISimon Glass2023-05-113-2/+14
| | | | | | | | | | | | | | We have several Kconfig options for ACPI, but all relate to specific functions, such as generating tables and AML code. Add a new option which controls including basic ACPI library code, including the lib/acpi directory. This will allow us to add functions which are available even if table generation is not supported. Adjust the command to avoid a build error when ACPIGEN is not enabled. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxiTom Rini2023-04-301-1/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | Please pull the second part of the sunxi pull request for this cycle. Another bunch of patches that replace old-school U-Boot hacks with proper DM based code, this time for the raw NAND flash driver, and the USB PHY VBUS detection code. Plus two smaller patches that were sitting in my inbox for a while. Gitlab CI passed. In lack of some supported board with NAND flash I couldn't really test this part, but apparently this was tested by the reviewer. I briefly ran the branch on some boards with USB-OTG, and this still worked.
| * mtd: nand: sunxi: Convert from fdtdec to ofnodeSamuel Holland2023-04-281-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | As a first step toward converting this driver to the driver model, use the ofnode abstraction to replace direct references to the FDT blob. Using ofnode_read_u32_index removes an extra pair of loops and makes the allwinner,rb property optional, matching the devicetree binding. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
* | fdt: Indicate that people should use the ofnode APISimon Glass2023-04-281-0/+3
|/ | | | | | Add a note to the comment at the top of this file. Signed-off-by: Simon Glass <sjg@chromium.org>
* efi_loader: remove unused efi_capsule_authenticateHeinrich Schuchardt2023-04-211-6/+0
| | | | | | Remove an unused implementation of efi_capsule_authenticate(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* efi: loader: Make efi_runtime_mmio staticBin Meng2023-04-081-1/+1
| | | | | | efi_runtime_mmio is only referenced in efi_boottime.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi: loader: Make efi_mem staticBin Meng2023-04-081-1/+1
| | | | | | efi_mem is only referenced in efi_memory.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi: loader: Make efi_event_queue and efi_register_notify_events staticBin Meng2023-04-081-2/+2
| | | | | | | efi_event_queue and efi_register_notify_events are only referenced in efi_boottime.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi: selftest: Make load_file() and load_file2() staticBin Meng2023-04-081-10/+10
| | | | | | | load_file() and load_file2() are only referenced in efi_selftest_load_file.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi: selftest: Make record staticBin Meng2023-04-081-1/+1
| | | | | | record is only referenced in efi_selftest_exitbootservices.c Signed-off-by: Bin Meng <bmeng@tinylab.org>
* efi_loader: avoid using HandleProtocol in initrddump.efiHeinrich Schuchardt2023-04-081-2/+3
| | | | | | | | HandleProtocol() is deprecated and leaves an OpenedProtocolInformation behind. Use OpenProtocol(GET_PROTOCOL) instead. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* efi_loader: avoid using HandleProtocol in helloworld.efiHeinrich Schuchardt2023-04-081-5/+8
| | | | | | | | HandleProtocol() is deprecated and leaves an OpenedProtocolInformation behind. Use OpenProtocol(GET_PROTOCOL) instead. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* lib: missing fallthrough comment in vsnprintf_internal()Heinrich Schuchardt2023-04-061-0/+3
| | | | | | | When a case statement intentionally falls through we should add a comment. Cf. -Wimplicit-fallthrough Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* lmb: add max number of region in lmb_dump_region() outputPatrick Delaunay2023-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Add the max number of region in lmb dump; this patch allows to check the limit for usage of the LMB regions, memory or reserved. Result on STM32MP157C-DK2: STM32MP> bdinfo ..... lmb_dump_all: memory.cnt = 0x1 / max = 0x2 memory[0] [0xc0000000-0xdfffffff], 0x20000000 bytes flags: 0 reserved.cnt = 0x6 / max = 0x10 reserved[0] [0x10000000-0x10045fff], 0x00046000 bytes flags: 4 reserved[1] [0x30000000-0x3003ffff], 0x00040000 bytes flags: 4 reserved[2] [0x38000000-0x3800ffff], 0x00010000 bytes flags: 4 reserved[3] [0xd4000000-0xd7ffffff], 0x04000000 bytes flags: 4 reserved[4] [0xdcae5000-0xdfffffff], 0x0351b000 bytes flags: 0 reserved[5] [0xddafb5b8-0xdfffffff], 0x02504a48 bytes flags: 0 .... Reported-by: Mark Millard <marklmi@yahoo.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
* lmb: Fix LMB_MEMORY_REGIONS flag usagePatrick Delaunay2023-04-062-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove test on CONFIG_LMB_MEMORY_REGIONS introduced by commit 7c1860fce4e3 ("lmb: Fix lmb property's defination under struct lmb"). This code in lmb_init() is strange, because if CONFIG_LMB_USE_MAX_REGIONS and CONFIG_LMB_MEMORY_REGIONS are not defined, the implicit #else is empty and the required initialization is not done: lmb->memory.max = ? lmb->reserved.max = ? But this setting is not possible: - CONFIG_LMB_USE_MAX_REGIONS not defined - CONFIG_LMB_MEMORY_REGIONS not defined because CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS are defined as soon as the CONFIG_LMB_USE_MAX_REGIONS is not defined. This patch removes this impossible case #elif and I add some explanation in lmb.h to explain why in the struct lmb {} the lmb property is defined if CONFIG_LMB_MEMORY_REGIONS is NOT defined. This patch also removes CONFIG_LMB_XXX dependency on CONFIG_LMB as these defines are used in API file lmb.h and not only in library file. Fixes: 5e2548c1d6e03 ("lmb: Fix LMB_MEMORY_REGIONS flag usage") Reported-by: Mark Millard <marklmi@yahoo.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Acked-by: Michal Simek <michal.simek@amd.com>
* efi_loader: device_path: support blkmap devicesTobias Waldekranz2023-04-051-0/+30
| | | | | | | Create a distinct EFI device path for each blkmap device. Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* Merge branch 'next'Tom Rini2023-04-0312-57/+136
|\ | | | | | | Signed-off-by: Tom Rini <trini@konsulko.com>
| * lib: Fix SYS_TIMER_COUNTS_DOWN description in KconfigMarek Vasut2023-03-301-1/+1
| | | | | | | | | | | | | | The SYS_TIMER_COUNTS_DOWN description contains a typo, s@rathe@&r@ , fix it. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
| * Merge branch 'master' into nextTom Rini2023-03-271-1/+3
| |\
| * | efi: Include GUID names with EFI app and payloadSimon Glass2023-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | These are currently only available when running with EFI_LOADER. Expand this to include the app and payload, since it is useful to be able to decode things there. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | efi: Add another tranch of GUIDsSimon Glass2023-03-251-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide information about the GUIDs supplied by QEMU, so far as it is known. These values are used in the 'efi table' command as well as the printf format string %sU Signed-off-by: Simon Glass <sjg@chromium.org>
| * | efi_loader: simplify efi_str_to_u16()Heinrich Schuchardt2023-03-251-3/+2
| | | | | | | | | | | | | | | | | | | | | Use efi_alloc() to allocate memory. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * | efi_loader: move dp_alloc() to efi_alloc()Heinrich Schuchardt2023-03-252-48/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The incumbent function efi_alloc() is unused. Replace dp_alloc() by a new function efi_alloc() that we can use more widely. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * | efi_loader: fix device-path for USB devicesHeinrich Schuchardt2023-03-251-12/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EFI device paths for block devices must be unique. If a non-unique device path is discovered, probing of the block device fails. Currently we use UsbClass() device path nodes. As multiple devices may have the same vendor and product id these are non-unique. Instead we should use Usb() device path nodes. They include the USB port on the parent hub. Hence they are unique. A USB storage device may contain multiple logical units. These can be modeled as Ctrl() nodes. Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * | efi_loader: support for Ctrl() device path nodeHeinrich Schuchardt2023-03-251-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add the definitions for Ctrl() device path nodes. * Implement Ctrl() nodes in the device path to text protocol. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * | zlib: trees.c: Fix a warning with clang-15Tom Rini2023-03-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With clang-15 we now will get warnings such as: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes] And it is easy enough to address this warning here, even if we would like to stay in sync more with upstream as it's a single location. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * | libavb: Fix a warning with clang-15Tom Rini2023-03-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With clang-15 we now will get warnings such as: warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes] And it is easy enough to address this warning here, as we aren't concerned with re-syncing with an upstream. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
| * | Merge tag 'v2023.04-rc4' into nextTom Rini2023-03-142-6/+33
| |\ \ | | | | | | | | | | | | | | | | | | | | Prepare v2023.04-rc4 Signed-off-by: Tom Rini <trini@konsulko.com>
| * | | lib: Add an SPL config for LIB_UUIDSimon Glass2023-03-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is selected by PARTITION_UUIDS which has a separate option for SPL. Add an SPL option for LIB_UUID also, so that we can keep them consistent. Also add one for PARTITION_TYPE_GUID to avoid a build error in part_efi.c which wants to call a uuid function in SPL. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | | lib: Fix build condition for tiny-printfSimon Glass2023-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This should be checking for any SPL build. Drop the use of SPL_TPL_ since it is not necessary and will not work with split config. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | | lib: Add VPL options for SHA1 and SHA256Simon Glass2023-03-021-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | Add these options so these algorithms can be used in VPL. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | | lib: Add a Kconfig for SPL_BZIP2Simon Glass2023-03-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | This is implicitly used in the source and seems useful, so add it. Signed-off-by: Simon Glass <sjg@chromium.org>
| * | | tpm: Implement tpm_auto_start() for TPMv1.2Simon Glass2023-02-283-11/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an implementation of this, moving the common call to tpm_init() up into the common API implementation. Add a test. Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * | | efi_loader: use tpm_auto_start for the tpm deviceIlias Apalodimas2023-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous commit is adding a new tpm startup functions which initializes the TPMv2 and performs all the needed selftests. Since the TPM selftests might be needed depending on the requested algorithm or functional module use that instead. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
| * | | tpm: add a function that performs selftest + startupIlias Apalodimas2023-02-282-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described in [0] if a command requires use of an untested algorithm or functional module, the TPM performs the test and then completes the command actions. Since we don't check for TPM_RC_NEEDS_TEST (which is the return code of the TPM in that case) and even if we would, it would complicate our TPM code for no apparent reason, add a wrapper function that performs both the selftest and the startup sequence of the TPM. It's worth noting that this is implemented on TPMv2.0. The code for 1.2 would look similar, but I don't have a device available to test. [0] https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.07-2014-03-13.pdf ยง12.3 Self-test modes Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | | | efi_loader: remove duplicate assignmentHeinrich Schuchardt2023-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Assigning the value of a variable to itself should be avoided. Addresses-Coverity-ID: 451089 ("Evaluation order violation") Fixes: 180b7118bed8 ("efi_loader: fix device-path for USB devices") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | | | efi_loader: correct shortening of device-pathsHeinrich Schuchardt2023-04-011-15/+6
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We use short device-paths in boot options so that a file on a block device can be found independent of the port into which the device is plugged. Usb() device-path nodes only contain port and interface information and therefore cannot identify a block device. UsbWwi() device-path nodes contain the serial number of USB devices. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
* | | efi_loader: fix device-path for USB devicesHeinrich Schuchardt2023-03-251-12/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EFI device paths for block devices must be unique. If a non-unique device path is discovered, probing of the block device fails. Currently we use UsbClass() device path nodes. As multiple devices may have the same vendor and product id these are non-unique. Instead we should use Usb() device path nodes. They include the USB port on the parent hub. Hence they are unique. A USB storage device may contain multiple logical units. These can be modeled as Ctrl() nodes. Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | | efi_loader: support for Ctrl() device path nodeHeinrich Schuchardt2023-03-251-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Add the definitions for Ctrl() device path nodes. * Implement Ctrl() nodes in the device path to text protocol. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | | console: Use flush() before panic and resetTony Dinh2023-03-221-1/+3
| |/ |/| | | | | | | | | | | | | | | | | | | To make sure the panic and the reset messages will go out, console flush() should be used. Sleep periods do not work in early u-boot phase when timer driver is not initialized yet. Reference: https://lists.denx.de/pipermail/u-boot/2023-March/512233.html Signed-off-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de>
* | efi_loader: describe term_get_char()Heinrich Schuchardt2023-03-131-0/+8
| | | | | | | | | | | | | | Add a function description. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* | efi_loader: update SetVariable attribute checkMasahisa Kojima2023-03-131-6/+25
|/ | | | | | | | | | | | | | UEFI specification v2.10 says that EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated and EFI_UNSUPPORTED should be returned in SetVariable variable service. Current implementation returns EFI_INVALID_PARAMETER, let's fix the return value. Together with above change, this commit also updates the SetVariable attribute check to be aligned with the EDK2 reference implementation. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>