summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
3 dayslmb: add missing fallthrough in lmb_alloc_mem()Heinrich Schuchardt
Add fallthrough to clarify the intent. Addresses-Coverity-ID: CID 569481: Control flow issues (MISSING_BREAK) Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
4 dayslib/rsa: allow matching pkcs11 path by object idTobias Olausson
The object= part matches against the label that the pkcs11 token uses for that object, but in some cases, specifically with a Yubikey using ykcs11, where the keys have been imported, the labels differ between the private and public keys [1], making the object= matching useless. These keys will have the same id however, so matching against that works for both the private and public part. [1]: https://github.com/Yubico/yubico-piv-tool/blob/master/doc/YKCS11/Functions_and_values.adoc#key-alias-per-slot-and-object-type Signed-off-by: Tobias Olausson <tobias@eub.se>
5 dayslwip: add sntp commandJerome Forissier
Implement the sntp command when NET_LWIP=y. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
5 daysnet: lwip: enable IP_FRAG and IP_REASSEMBLYTim Harvey
Enable IP_FRAG and IP_REASSEMBLY to allow packets larger than MTU. Signed-off-by: Tim Harvey <tharvey@gateworks.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
5 daysMerge branch 'next'Tom Rini
10 daysefi_loader: add dbginfodump.efiHeinrich Schuchardt
Provide a test application to dump the EFI_DEBUG_IMAGE_INFO_TABLE as implemented in EDK II. EFI_DEBUG_IMAGE_INFO is not packed in contrast to many other EFI structures. As of today EDK II when removing an entry in the EfiDebugImageInfoTable just sets NormalImage = NULL but does not compact the array. So TableSize reflects the number of non-NULL entries and not the array size as reported independently in https://github.com/tianocore/edk2/pull/11013 and https://github.com/tianocore/edk2/pull/11019. The current implementation tolerates this deviation from the UEFI specification. This is what the output may look like: Debug Info Table Dump ===================== => dump Modified Number of entries: 0x0000004a Info type 0x00000001 Address: [0x000000008315a000, 0x00000000831bafff] File: FvFile(D6A2CB7F-6A18-4E2F-B43B-9920A733700A) Handle: 0x000000017fe3cb18 ... Info type 0x00000001 Address: [0x000000017e8db000, 0x000000017ea00f3f] File: FvFile(7C04A583-9E3E-4F1C-AD65-E05268D0B4D1) Handle: 0x000000017f358e98 Info type 0x00000001 Address: [0x000000017eae5000, 0x000000017eae81ff] File: \dbginfodump.efi Handle: 0x000000017eaf0298 => Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi: selftest: add selftest for EFI_DEBUG_SUPPORTYing-Chun Liu (PaulLiu)
Add selftest to check the installed configuration table that has the correct GUID. Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi: add EFI_DEBUG_IMAGE_INFO for debugYing-Chun Liu (PaulLiu)
This commit adds the functionality of generate EFI_DEBUG_IMAGE_INFO while loading the image. This feature is described in UEFI Spec 2.10. Section 18.4.3. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover the load address of an EFI application. Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Peter Robinson <pbrobinson@gmail.com> Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 dayslib: efi_loader: efi_memory.c: add efi_realloc() for realloc memoryYing-Chun Liu (PaulLiu)
Add efi_realloc() for realloc memory that previously alloc by efi_alloc(). Note that if realloced memory is explicitly allocated as BootServicesData. Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> Cc: Peter Robinson <pbrobinson@gmail.com> Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi: add EFI_DEBUG_IMAGE_INFO_TABLE for debugYing-Chun Liu (PaulLiu)
EFI_DEBUG_IMAGE_INFO_TABLE is used to store EFI_LOADED_IMAGE for debug purpose. This commit adds the table to the EFI_CONFIGURATION_TABLE. This feature is described in UEFI Spec version 2.10. Section 18.4. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover and interact with system-level debug resources. Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Peter Robinson <pbrobinson@gmail.com> Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi: add EFI_SYSTEM_TABLE_POINTER for debugYing-Chun Liu (PaulLiu)
Add EFI_SYSTEM_TABLE_POINTER structure for remote debugger to locate the address of EFI_SYSTEM_TABLE. This feature is described in UEFI SPEC version 2.10. Section 18.4.2. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover the EFI system table. Cc: Peter Robinson <pbrobinson@gmail.com> Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> # change memset(systab_pointer, 0 ...) -> systab_pointer->crc32 = 0; Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi_loader: Prevent free of uninitialised pointerAndrew Goodbody
Taking a goto to out_of_resources before receive_lengths is assigned will result in an attempt to free an unitialised pointer. Instead initialise receive_lengths to NULL on declaration to prevent this from occurring. This issue was found by Smatch. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi_loader: Prevent dereference of uninitialised variableAndrew Goodbody
If phandler is returned as NULL from efi_search_protocol then protocol_interface is never assigned to. Instead return EFI_UNSUPPORTED as per the spec. This issue found by Smatch. Also eliminate the use of the variable protocol_interface as it is not needed. Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi_loader: Prevent dereferencing NULL pointerAndrew Goodbody
Taking the first goto error: in file_open could either result in an attempt to dereference fh when NULL or else free fh->path which has not been assigned to and so will be unknown. Avoid both of these problems by passing path to free instead of fh->path. This issue found by Smatch. Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi_selftest: Add basic partition info check to block io testJavier Martinez Canillas
Test the EFI_PARTITION_INFO_PROTOCOL in the existing EFI_BLOCK_IO_PROTOCOL unit test. It is fairly basic, since it only checks that the values of the struct efi_partition_info .revision, .type and .system fields are correct. It doesn't check the MBR partition record information, because that's not supported by the EFI_PARTITION_INFO_PROTOCOL implementation yet. The test can be extended once the support is implemented, or if the in-memory disk image used for the test is modified to have a GPT partition type instead. Suggested-by: Tom Rini <trini@konsulko.com> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
10 daysefi_loader: disk: add EFI_PARTITION_INFO_PROTOCOL supportJavier Martinez Canillas
The UEFI 2.10 specification mentions that this protocol shall be installed along with EFI_BLOCK_IO_PROTOCOL. It provides cached partition information for MBR and GPT partition types. This patch just implements support for GPT partition types. The legacy MBR partition types is only needed for backward compatibility and can be added as a follow-up if needed, to make it fully compliant with the EFI spec. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
12 daystpm: Make use of TPM2_ALG_INVAL from enumAndrew Goodbody
Now that the enum includes TPM2_ALG_INVAL, use that name in the code. Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-06-28efi_loader: initialize 'total' variableIlias Apalodimas
This variable might end up being uninitialized if we exit early. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-06-25lib: ecdsa: Add support for loading ECDSA public key from FDTJamin Lin
This patch adds support for parsing ECDSA public keys from the device tree blob (FDT) under the `/signature` node. The public key is expected to be defined using: - ecdsa,curve (e.g., "prime256v1", "secp384r1") - ecdsa,x-point - ecdsa,y-point The implementation introduces: - struct ecdsa_public_key to hold parsed key fields - fdt_get_key() to parse the curve and coordinates from the FDT - read_key_from_fdt() to convert the parsed values into an OpenSSL EC_KEY - load_key_from_fdt() to support loading keys using required_keynode, keyname hint, or fallback to scanning all subnodes under "/signature". If "info->fdt_blob" is provided, the key is loaded from the FDT. Otherwise, the code falls back to loading a PEM-formatted key from file as before. This allows for ECDSA signature verification where the public key is embedded in the FIT image device tree, useful for systems that require signature validation without external files. Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
2025-06-25Merge patch series "lmb: use a single API for all allocations"Tom Rini
Sughosh Ganu <sughosh.ganu@linaro.org> says: The LMB module has a bunch for API's which are used for allocating memory. There are a couple of API's for requesting memory, and two more for reserving regions of memory. Replace these different API's with a single one, lmb_alloc_mem(). The type of allocation to be made is specified through one of the parameters to the function. Additionally, the two API's for reserving regions of memory, lmb_reserve() and lmb_alloc_addr() are the same with one difference. One can reserve any memory region with lmb_reserve(), while lmb_alloc_addr() actually checks that the memory region being requested is part of the LMB memory map. Reserving memory that is not part of the LMB memory map is pretty futile -- the allocation functions do not allocate memory which has not been added to the LMB memory map. This series also removes the functionality allowing for reserving memory regions outside the LMB memory map. Any request for reserving a region of memory outside the LMB memory map now returns an -EINVAL error. Certain places in the common code using the LMB API's were not checking the return value of the functions. Checks have been added for them. There are some calls being made from the architecture/platform specific code which too do not check the return value. Those have been kept the same, as I do not have the platform with me to check if it causes any issues on those platforms. In addition, there is a patch which refactors code in lmb_overlaps_region() and lmb_can_reserve_region() so that both functionalities can be put in a single function, lmb_overlap_checks(). Finally, a new patch has been added which checks the return value of the lmb allocation function before copying the device-tree to the allocated address. Link: https://lore.kernel.org/r/20250617104346.1379981-1-sughosh.ganu@linaro.org [trini: Rework arch/arm/mach-snapdragon/board.c merge] Signed-off-by: Tom Rini <trini@konsulko.com>
2025-06-25lmb: use a single function to check for allocation and reservation requestsSughosh Ganu
The functions that handle allocation requests check if a region of memory overlaps with a used region. This is done through lmb_overlaps_region(). Similar checks are done for reservation requests made to the LMB module, where the caller asks specifically for a particular region of memory. These checks are being done through lmb_can_reserve_region(). There are subtle differences in the checking needed for allocation requests, as against reservation requests. In the former, it is only needed to be checked if a region is overlapping with an existing used region, and return as soon as an overlap is found. For reservation request checks, because U-Boot allows for re-use of in-use regions with a particular memory attribute, this check has to iterate through all the regions that might overlap with the requested region, and then check that the necessary conditions are met to allow for the overlap. Combine these two checks in a single function, lmb_overlap_checks() as both lmb_overlaps_region() and lmb_can_reserve_region() are pretty similar otherwise. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-06-25lmb: use a single function to free up memorySughosh Ganu
There is no need to have two separate API's for freeing up memory. Use a single API lmb_free() to achieve this. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-06-25lmb: staticise lmb_add_memory()Sughosh Ganu
lmb_add_memory() is only called from the lmb module. Mark the function as static. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-06-25lmb: replace the lmb_alloc() and lmb_alloc_base() API'sSughosh Ganu
There currently are two API's for requesting memory from the LMB module, lmb_alloc() and lmb_alloc_base(). The function which does the actual allocation is the same. Use the earlier introduced API lmb_alloc_mem() for both types of allocation requests. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-06-25lmb: replace lmb_reserve() and lmb_alloc_addr() API'sSughosh Ganu
There currently are multiple allocation API's in the LMB module. There are a couple of API's for allocating memory(lmb_alloc() and lmb_alloc_base()), and then there are two for requesting a reservation for a particular memory region (lmb_reserve() and lmb_alloc_addr()). Introduce a single API lmb_alloc_mem() which will cater to all types of allocation requests and replace lmb_reserve() and lmb_alloc_addr() with the new API. Moreover, the lmb_reserve() API is pretty similar to the lmb_alloc_addr() API, with the one difference being that the lmb_reserve() API allows for reserving any address passed to it -- the address need not be part of the LMB memory map. The lmb_alloc_addr() does check that the address being requested is actually part of the LMB memory map. There is no need to support reserving memory regions which are outside the LMB memory map. Remove the lmb_reserve() API functionality and use the functionality provided by lmb_alloc_addr() instead. The lmb_alloc_addr() will check if the requested address is part of the LMB memory map and return an error if not. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-06-23Merge tag 'v2025.07-rc5' into nextTom Rini
Prepare v2025.07-rc5 With this merge, tighten up the LTO_FLAGS removal we added to not trigger on ARMv7 (which is Thumb-2 and should be fine).
2025-06-22Merge patch series "rsa and fit_check_sign build fix for v2025.07-rc"Tom Rini
Shiji Yang <yangshiji66@outlook.com> says: This patchset fixes some compilation errors that I caught in version v2025.07-rc4 and branch next. If they are acceptable, please apply them to the master branch. If anyone has a better way to fix these issues, it's fine to ignore this patchset. Link: https://lore.kernel.org/r/OSBPR01MB16702ED24460D23A7ED63440BC7DA@OSBPR01MB1670.jpnprd01.prod.outlook.com
2025-06-22lib: rsa: fix compilation error without opensslShiji Yang
The symbol TOOLS_IMAGE_PRE_LOAD doesn't depend on TOOLS_LIBCRYPTO. If we choose to build tools without openssl, rsa_verify_openssl() will attempt to call the unavailable openssl library functions. Fixes: 942c8c8e6697 ("rsa: Add rsa_verify_openssl() to use openssl for host builds") Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
2025-06-17lib/uuid.c: restore support of system partition type for ESPPatrick Delaunay
Add support of optional shortname for parameter 'type' of gpt command (limited by UUID_STR_LEN) and a separate 'description' for UID format "%pUs" used in 'part list' output. When 'description' is absent in list_guid[], the optional shortname is used as fallback. Many partition types for EFI have no shortcut yet, but only description as they are only used to display information. This patch also restores the "system" as short name for EFI System Partition (ESP). Fixes: d54e1004b8b1 ("lib/uuid.c: use unique name for PARTITION_SYSTEM_GUID") Tested-by: Patrice Chotard <patrice.chotard@foss.st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2025-06-14Merge patch series "Hex value prefix case cleanup"Tom Rini
E Shattow <e@freeshell.de> says: Make consistent use of lowercase hexadecimal prefix '0x' throughout U-Boot. There are a few remaining uses of uppercase 'X' to denote hexadecimal prefix or placeholder in documentation and error messages. External devicetree-rebasing dts/upstream and the generated code of xilinx/zynq are ignored for the series. Link: https://lore.kernel.org/r/20250606224558.1117422-1-e@freeshell.de
2025-06-14lib: use lowercase hex prefix styleE Shattow
Use consistent lowercase hex prefix style in lib/* Signed-off-by: E Shattow <e@freeshell.de>
2025-06-13Merge patch series "drop volatile from global data"Tom Rini
Rasmus Villemoes <ravi@prevas.dk> says: There's really no reason for the gd pointer to have the volatile qualifier. In fact, I claim that it's completely unnecessary and just pessimizes code generation and forces ugly casts in lots of places. For example, see the casts in drivers/core/tag.c where elements are added to gd->dm_taglist, or a helper such as cyclic_get_list() that should not be needed. Also, it is what ends up standing in the way of an otherwise innocent code cleanup of list.h: https://lore.kernel.org/u-boot/20250522165656.GB2179216@bill-the-cat/ Note that riscv, x86 as well as arm64 with LTO enabled has not had this volatile qualifier, so it's unlikely there's any generic code that depends on it. Link: https://lore.kernel.org/r/20250604195612.2312979-1-ravi@prevas.dk
2025-06-13lib/trace: drop volatile qualifier from "save gd" variablesRasmus Villemoes
The global gd pointer is no longer volatile-qualified, so drop that qualifier from these bookkeeping variables. Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
2025-06-13efi: drop volatile qualifier from "save gd" variablesRasmus Villemoes
The global gd pointer is no longer volatile-qualified, so drop that qualifier from these bookkeeping variables. Signed-off-by: Rasmus Villemoes <ravi@prevas.dk> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-06-09Merge tag 'v2025.07-rc4' into nextTom Rini
Prepare v2025.07-rc4
2025-06-08Merge tag 'u-boot-rockchip-20250606' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-rockchip CI: https://source.denx.de/u-boot/custodians/u-boot-rockchip/-/pipelines/26117 - Allow to silent TPL/SPL debug console; - enable exFAT support for Theobroma boards; - Fix SD power initialization in SPL for rk3399-nanopi4
2025-06-07efi_loader: correct EFI_TCG2_PROTOCOL_MEASURE_DTB descriptionHeinrich Schuchardt
%s/data that change/data that changes/ %s/cannot be used has/cannot be used for/ %s/Otherwise/Otherwise,/ %s/allows better measurement/allows for better measurement/ Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-06-06efi: stub: Change _debug_uart_putc function to inlineLukasz Czechowski
Update definition of _debug_uart_putc to static inline. This will allow to avoid compilation warnings about unused code after introduction of patch changing debug uart functions to dummies if CONFIG_DEBUG_UART is not set. This also matches the instructions in include/debug_uart.h and provides consistency with implementations for other platforms. Signed-off-by: Lukasz Czechowski <lukasz.czechowski@thaumatec.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2025-06-02Merge patch series "Audit include list for include/[a-m]*.h"Tom Rini
Tom Rini <trini@konsulko.com> says: Hey all, Related to my other series I've posted recently on cleaning up some headers, this series here is the result of at least lightly auditing the #includes used in include/[a-m]*.h. This ignores subdirectories, as at least in part I think the top-level includes we've constructed are the most likely places to have some extra transitive include paths. I'm sure there's exceptions and I'll likely audit deeper once this first pass is done. This only gets as far as "include/m*.h" because I didn't want this to get too big. This also sets aside <miiphy.h> and <phy.h>. While miiphy.h does not directly need <phy.h> there are *so* many users and I think I had half of the tree just about not building when I first tried. It might be worth further investigation, but it might just be OK as-is. Link: https://lore.kernel.org/r/20250521230119.2084088-1-trini@konsulko.com
2025-06-02include/mtd.h: Cleanup usageTom Rini
There are only a few things found in <mtd.h> today. Go through and audit the C files which include <mtd.h> and remove it when not required. Then, add it to the files which had either missed it or had an indirect inclusion of it. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-06-02include/ide.h: Cleanup usageTom Rini
At this point in time, <ide.h> provides the IDE_BUS macro and the function prototype for ide_set_reset, which is used with IDE_RESET. The only files which should include this header are the ones that either use that macro or that function. Remove <blk.h> from <ide.h> and remove <ide.h> from places which do not need it. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-30abuf: Add a way to printf() into a bufferSimon Glass
It is useful to format a string into a buffer, with the sizing handled automatically. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-30abuf: Add a function to copy a bufferSimon Glass
It is useful to be able to copy an abuf, to allow changes while preserving the original. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-30abuf: Add a helper for initing and allocating a bufferSimon Glass
This construct appears in various places. Reduce code size by adding a function for it. It inits the abuf, then allocates it to the requested size. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-29Merge patch series "Remove <env.h> from <net.h>"Tom Rini
Tom Rini <trini@konsulko.com> says: Hey all, This is a v3 of Simon's series[1] and depends on the series[2] I posted the other day that removes <env.h> from <command.h>. With this series done, I believe we've tackled all of the current cases of headers which include <env.h> without directly needing it. Much of this series is in fact Simon's v2 with the main differneces being: - Removing <env.h> from <net.h> at the end - Removing env_to_ip() given how little it's used rather than shuffling around where it's declared and un-inline'ing it. For a rarely used helper, this ends up being cleaner I think. Especially looking at some of the users (which called env_get repeatedly). If there's strong opinion here about using the other method[3] we can do that instead. - Setting aside for now how to handle CMD_ELF=y and NO_NET=y because today it's actually fine as we unconditionally build lib/net_utils.c where string_to_ip() is defined. I'm unsure if a further series is warranted here or not. We rely on link-time optimization to keep code readable too. [1]: https://lore.kernel.org/all/20250501010456.3930701-1-sjg@chromium.org [2]: https://lore.kernel.org/all/20250514225002.15361-1-trini@konsulko.com [3]: https://lore.kernel.org/all/20250501010456.3930701-23-sjg@chromium.org Link: https://lore.kernel.org/r/20250515234154.1859366-1-trini@konsulko.com
2025-05-29global: Avoid indirect inclusion of <env.h> from <net.h>Tom Rini
Now that env_get_ip() has been removed, the include file <net.h> does not need anything from <env.h>. Furthermore, include/env.h itself includes other headers which can lead to longer indirect inclusion paths. To prepare to remove <env.h> from <net.h> fix all of the remaining places which had relied on this indirect inclusion to instead include <env.h> directly. Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> # net/lwip Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Martyn Welch <martyn.welch@collabora.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-29Merge patch series "Start removing <env.h> from headers when not required"Tom Rini
Tom Rini <trini@konsulko.com> says: Given Simon's series at [1] I started looking in to what brings in <env.h> when not strictly required and in turn has some unintended implicit includes. This series takes care of the places where, commonly, <linux/string.h> or <env.h> itself were required along with a few other less common cases. This sets aside for the moment what to do about net-common.h and env_get_ip() as I'm not entirely sure what's best there. [1]: https://patchwork.ozlabs.org/project/uboot/list/?series=454939&state=* Link: https://lore.kernel.org/r/20250514225002.15361-1-trini@konsulko.com
2025-05-29global: Avoid indirect inclusion of <env.h> from <command.h>Tom Rini
The include file <command.h> does not need anything from <env.h>. Furthermore, include/env.h itself includes other headers which can lead to longer indirect inclusion paths. To prepare to remove <env.h> from <command.h> fix all of the places which had relied on this indirect inclusion to instead include <env.h> directly. Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> # android, bcb Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> # spawn Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-29Merge patch series "regex patches"Tom Rini
Rasmus Villemoes <ravi@prevas.dk> says: This started as a rather simple patch, 1/12, adding the ability to more conveniently do regex matching in shell. But with that, it became very easy to see what the slre library can and especially what it cannot do, and that way I found both outright bugs and a "wow, doesn't it support that syntax" gotcha. I couldn't find any tests ('git grep slre -- test/' was empty), so I added a small test suite and tweaked slre.c. Link: https://lore.kernel.org/r/20250513084034.654865-1-ravi@prevas.dk
2025-05-29slre: implement support for ranges in character classesRasmus Villemoes
When trying to use U-Boot's regex facility, it is a rather large gotcha that [a-z] range syntax is not supported. It doesn't require a lot of extra code to implement that; we just let the regular parsing emit the start and end literal symbols as usual, and add a new "escape" code RANGE. At match time, this means the code will first just see an 'a' and try to match that, and only then recognize that it's actually part of a range and then do the 'a' <= ch <= 'z' test. Of course, this means that a - in the middle of a [] pair no longer matches a literal dash, but I highly doubt anybody relies on that. Putting it first or last, or escaping it with \, as in most other RE engines, continues to work. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>