Commit graph

3660 commits

Author SHA1 Message Date
Ilias Apalodimas
6507ec20ba efi_loader: Mark static functions in smbiosdump
Mark functions that are only used locally as static and
quiesce W=1 warnings

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-10-30 21:45:51 +01:00
Ilias Apalodimas
bfc30742b8 efi_loader: Mark static function in dumpdtb
A few functions are only used locally but miss the 'static' keyword.
Add it and quiesce W=1 build wanrings

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-30 21:45:39 +01:00
Ilias Apalodimas
b63cb21221 efi_loader: Mark efi_bootmgr_release_uridp as static
This is only used locally so make it static

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2024-10-30 21:44:42 +01:00
Ilias Apalodimas
4588ab9976 efi_loader: Simplify efi_free_pages()
We currently call efi_free_pages() with a notify flag and explicitly
update the efi memory map. That's not needed as lmb_free_flags() will do
that for us if the LMB_NONOTIFY flag is removed

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-10-30 21:44:38 +01:00
Ilias Apalodimas
e26d2cab42 lmb: Correctly unmap memory after notifications
We never unmap the memory used to update the EFI memory map after
notifications

Fixes: commit 2f6191526a ("lmb: notify of any changes to the LMB memory map")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-10-30 13:02:45 -06:00
Heinrich Schuchardt
1dd01ab1a4 efi_loader: fix CONFIG_EFI_HTTP dependencies
CONFIG_CMD_DNS and CONFIG_CMD_WGET depend on CONFIG_CMD_NET.
CONFIG_CMD_NET depends on CONFIG_NET or CONFIG_NET_LWIP.

We shall only enable CONFIG_EFI_HTTP if there is network support.
We have to select CONFIG_CMD_NET.

Fixes: d7d07a8b50 ("efi_loader: support boot from URI device path")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-30 14:54:28 +01:00
Heinrich Schuchardt
e2f34f4d55 efi_selftest: make HII test data static
Variables that are only used locally in a module should not be exported.

* Make the HII test data variables static.
* Remove unused GUIDs.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-30 14:54:08 +01:00
Heinrich Schuchardt
645f7b299b efi_selftest: fix typo 'got languages' in HII test
%s/got languages are/Available languages:/

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-30 14:53:52 +01:00
Ilias Apalodimas
ede2361998 lmb: Remove lmb_alloc_flags()
lmb_alloc_flags() & lmb_alloc_base_flags() are just a wrappers for
_lmb_alloc_base(). Since the only difference is the max address of the
allowed allocation which _lmb_alloc_base() already supports with the
LMB_ALLOC_ANYWHERE flag, remove one of them.

Keep the lmb_alloc_base_flags() which also prints an error on failures
and adjust efi_allocate_pages() to only use one of them.

While at it clean up the duplicate function description from the header
file.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-29 16:17:47 -06:00
Ilias Apalodimas
f6fb6a8851 lmb: Simplify lmb_should_notify usage
We never call lmb_map_update_notify() without checking the result of
lmb_should_notify(). Instead of running that function everytime fold it
in there and add the additional flags parameter

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-29 16:17:47 -06:00
Ilias Apalodimas
0f57b009e6 lmb: Fix lmb_add_region_flags() return codes and testing
The function description says this should return 0 or -1 on failures.
When regions coalesce though this returns the number of coalescedregions
which is confusing and requires special handling of the return code.
On top of that no one is using the number of coalesced regions.

So let's just return 0 on success and adjust our selftests accordingly

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
2024-10-29 16:17:47 -06:00
Sughosh Ganu
c3cf0dc64f lmb: add a check to prevent memory overrun
When printing the LMB flags for a memory region, there is a need to
check that the array index that is computed is a sane value. Put a
noisy assert in case this check fails, as that implies something with
the LMB code is not working as expected.

Reported-by: Coverity (CID 510463)
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2024-10-29 12:09:49 -06:00
Tom Rini
bfdfc6c12e Revert "acpi_table: Fix coverity defect in acpi_write_spcr"
This commit introduces a number of failure to build issues. For now,
revert it and we will wait for v2 to address the issue and the build
problems as well.

This reverts commit e1c3c720e7.

Signed-off-by: Tom Rini <trini@konsulko.com>
2024-10-28 20:53:34 -06:00
Patrick Rudolph
e1c3c720e7 acpi_table: Fix coverity defect in acpi_write_spcr
Fix "Integer handling issues  (SIGN_EXTENSION)" in newly added code:
Cast serial_info.reg_offset to u64 to prevent an integer overflow when
shifted too many bits to the left. Currently this never happens as the
shift is supposed to be less than 4.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Moritz Fischer <moritzf@google.com>
2024-10-28 16:50:26 -06:00
Tom Rini
2800aecce0 Merge patch series "Implement ACPI on aarch64"
Patrick Rudolph <patrick.rudolph@9elements.com> says:

Based on the existing work done by Simon Glass this series adds
support for booting aarch64 devices using ACPI only.
As first target QEMU SBSA support is added, which relies on ACPI
only to boot an OS. As secondary target the Raspberry Pi4 was used,
which is broadly available and allows easy testing of the proposed
solution.

The series is split into ACPI cleanups and code movements, adding
Arm specific ACPI tables and finally SoC and mainboard related
changes to boot a Linux on the QEMU SBSA and RPi4. Currently only the
mandatory ACPI tables are supported, allowing to boot into Linux
without errors.

The QEMU SBSA support is feature complete and provides the same
functionality as the EDK2 implementation.

The changes were tested on real hardware as well on QEMU v9.0:

qemu-system-aarch64 -machine sbsa-ref -nographic -cpu cortex-a57 \
                    -pflash secure-world.rom \
                    -pflash unsecure-world.rom

qemu-system-aarch64 -machine raspi4b -kernel u-boot.bin -cpu cortex-a72 \
-smp 4 -m 2G -drive file=raspbian.img,format=raw,index=0 \
-dtb bcm2711-rpi-4-b.dtb -nographic

Tested against FWTS V24.03.00.

Known issues:
- The QEMU rpi4 support is currently limited as it doesn't emulate PCI,
  USB or ethernet devices!
- The SMP bringup doesn't work on RPi4, but works in QEMU (Possibly
  cache related).
- PCI on RPI4 isn't working on real hardware since the pcie_brcmstb
  Linux kernel module doesn't support ACPI yet.

Link: https://lore.kernel.org/r/20241023132116.970117-1-patrick.rudolph@9elements.com
2024-10-27 18:44:13 -06:00
Patrick Rudolph
34bfe8eff8 arm: cpu: Add ACPI parking protocol support
On Arm platforms that use ACPI they cannot rely on the "spin-table"
CPU bringup usually defined in the FDT. Thus implement the
'ACPI Multi-processor Startup for ARM Platforms', also referred to as
'ACPI parking protocol'.

The ACPI parking protocol works similar to the spin-table mechanism, but
the specification also covers lots of shortcomings of the spin-table
implementations.

Every CPU defined in the ACPI MADT table has it's own 4K page where the
spinloop code and the OS mailbox resides. When selected the U-Boot board
code must make sure that the secondary CPUs enter u-boot after relocation
as well, so that they can enter the spinloop code residing in the ACPI
parking protocol pages.

The OS will then write to the mailbox and generate an IPI to release the
CPUs from the spinloop code.

For now it's only implemented on ARMv8, but can easily be extended to
other platforms, like ARMv7.

TEST: Boots all CPUs on qemu-system-aarch64 -machine raspi4b

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
6f9b015c13 common: Enable BLOBLIST_TABLES on arm
Allow to use BLOBLIST_TABLES on arm to store ACPI or other tables.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
4ac655cd1a acpi: Add processor device
Add a new method to write the processor device identified by _HID
ACPI0007, that is preferred over the Processor OpCode since ACPI 6.0.

Fixes booting arm using ACPI only since the Processor OpCode isn't
found valid by the Linux kernel.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
f570ab6361 acpi: Allocate and write ACPI tables
Allocate memory for ACPI tables in generic acpi code. When ACPI wasn't
installed in other places, install the ACPI table using BLOBLISTs.

This allows non x86 platforms to boot using ACPI only in case the
EFI loader is being used, since EFI is necessary to advertise the location
of the ACPI tables in memory.

TEST: Booted QEMU SBSA (no QFW) using EFI and ACPI only.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
5dc22f767c acpi_table: Support platforms with unusable RSDT
Since ACPI 2.0 the RSDT is deprecated and the XSDT should be preferred.
Until now the RSDT and XSDT entries were keept in sync as all platforms
that installed ACPI tables placed them below 4GiB and thus the address
would fit into the 32bit RSDT.

On platforms that do not have usable DRAM below 4GiB, like QEMU sbsa,
the RSDT cannot be used. Allow both RSDT and XSDT to be null and only
fill those tables that are present in acpi_add_table().

TEST: Fixes a crash on QEMU sbsa and allows to boot on QEMU sbsa.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
bf5d37662d acpi: acpi_table: Add IORT support
The SoC can implement acpi_fill_iort to update the IORT table.
Add a helper function to fill out the NAMED_COMPONENT node.

TEST=Run FWTS V24.03.00 on RPi4 and round no problems.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
7f91bcac1e acpi: Add ACPITAB for PPTT and GTDT
Return the ACPI table revision in acpi_get_table_revision() for
PPTT and GTDT. Match both to ACPI 6.2.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
4b882f63d4 acpi: acpi_table: Bump revisions
The FADT structure found in U-Boot represents FADT revision 6 and the
GICC and GICD structures defined in U-Boot are based on ACPI revision
6.3.

Bump the table revision to fix FWTS failures seen on aarch64.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
763bad3e1c acpi: Add fill_madt to acpi_ops
Add a new method to acpi_ops to let drivers fill out ACPI MADT.
The code is unused for now until drivers implement the new ops.

TEST: Booted on QEMU sbsa using driver model generated MADT.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
2024-10-27 17:24:13 -06:00
Patrick Rudolph
4a3fc0f525 acpi: x86: Move MADT to common code
Write MADT in common code and let the SoC fill out the body by
calling acpi_fill_madt() which must be implemented at SoC level.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
2024-10-27 17:12:44 -06:00
Maximilian Brune
f5f7962091 acpi: x86: Write FADT in common code
Write the FADT in common code since it's used on all architectures.
Since the FADT is mandatory all SoCs or mainboards must implement the
introduced function acpi_fill_fadt() and properly update the FADT.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
2024-10-27 17:12:44 -06:00
Maximilian Brune
1c03efc014 acpi: x86: Move SPCR and DBG2 into common code
This moves the SPCR and DBG2 table generation into common code, so that
they can be used by architectures other than x86.

Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
2024-10-27 17:12:44 -06:00
Tom Rini
deafcdc8e0 Merge patch series "Allow showing the memory map"
Simon Glass <sjg@chromium.org> says:

This little series adds a new 'memmap' command, intended to show the
layout of memory within U-Boot and how much memory is available for
loading images.

Link: https://lore.kernel.org/r/20241021081934.289473-1-sjg@chromium.org
2024-10-25 14:22:36 -06:00
Simon Glass
1c30f7a844 lmb: Export the lmb data structure
Provide a way to access this data structure so that the meminfo command
can use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-25 14:22:24 -06:00
Rasmus Villemoes
ed8a807df8 lib/sha*: include u-boot/schedule.h instead of cyclic.h
These library routines obviously do not make use of the
cyclic_register() etc. API, but do need to call schedule(). Include
the proper header.

Eventually, their ifdef logic should be updated to avoid talking about
CONFIG_WATCHDOG.

Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2024-10-23 06:52:38 +02:00
Tom Rini
a3709638ec Merge patch series "aspeed: ast2700: Add Caliptra ECDSA driver"
Chia-Wei Wang <chiawei_wang@aspeedtech.com> says:

Aspeed AST2700 SoCs integrates the Caliptra secure IP, where an ECDSA384
signature verification HW interface is exported for SoC crypto needs.

This patch series firstly extends the FIT image signing/verify common
code to support the ECDSA384 algorithm. For better convenience, the
device tree for ECDSA public key storage is also revised by referring
to RSA implementations.

After the FIT common code revision, the driver is implemented for
AST2700 to leverage the Caliptra ECDSA384 signature verification.

These are verified by signed FIT images with the algorithm "sha384,ecdsa384".

Link: https://lore.kernel.org/r/20241014095620.216936-1-chiawei_wang@aspeedtech.com
2024-10-21 17:53:11 -06:00
Chia-Wei Wang
75068b1a2d lib: ecdsa: Add ECDSA384 support
Add ECDSA384 algorithm support for image signing and verification.

Signed-off-by: Chia-Wei Wang <chiawei_wang@aspeedtech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-10-21 17:52:52 -06:00
Tom Rini
fa0ed06a74 Pull request efi-2025-01-rc1-2
Documentation:
 
 * Add document describing Ethernet boot on AM62x SoC
 * Fix typo in blkmap command example
 
 UEFI:
 
 * Avoid #ifdef in efi_setup.c
 * Reduce message noisiness if ESP is missing
 * Remove ERROR:, WARNING: prefixes in messages
 * Use blk_create_devicef() in block device driver
 
 Others:
 
 * Let CONFIG_CMD_WGET depend on CONFIG_CMD_NET
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEK7wKXt3/btL6/yA+hO4vgnE3U0sFAmcSnMgACgkQhO4vgnE3
 U0upVA/+L1jXBSSXnR8FnvI40SbACxYFx5MFHEkEyNn5D9wwc2ptzH6zWCamzFkG
 /mH5vaHrjV89WU8EkLFUepCiYz5053KnoK3NlnBNL6mISQcB6YHi2ZNfjWOTwIn9
 z12DrXJcs1gNIOxTMI3AdQ9UespsC4XytBgsm0zpzh1ZpBKnqcaX4p0iU/TBFibi
 rZ9yk+iXp04lfJiz1rPaBMQY7HlByCdlM4o6JwQkqW8RS5ozsuKYzZdrMrNO/ksN
 9Cuqwqrst58JcZXZ4zdnaTCqCAqBfo3h6iiPN6+skn0XGgTC7KWHoLffW/z5cqUy
 2PgyEASlpyB6Q0VX6+tRRj06ZWpSGudp92hNY5kb7ZXyU+boEwrkWZZNCf2HU+KF
 sifu7KMU2yOPTcA2qHIYEJ8gI7Zg9Xpzz9lrtm8a0XUbvOnobzIp7tkDUo27q0/B
 YLEf24BoBEmbFTEvTXbI5Xehq1TGWao0UfAAm6vtZIhZp42Efc0EYVUiZz8zw8mf
 x+GEhP08yT3sMSZXKtxT50w4UTVyfRStwHNQ+f217Q96ndNuj+LNFwpURBwWlQ5E
 59WoM235coc9vwynFspaaPSVuYzpDOuaYtEJRmksslhSj/c4w/sDiROXaOGvBs3S
 ZVH4ObLjnl2x3ngA1x1EVeDCrMt5ujvmKJIEiBHFmFsY707rRAQ=
 =F6+Y
 -----END PGP SIGNATURE-----

Merge tag 'efi-2025-01-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request efi-2025-01-rc1-2

CI: https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/22810

Documentation:

* Add document describing Ethernet boot on AM62x SoC
* Fix typo in blkmap command example

UEFI:

* Avoid #ifdef in efi_setup.c
* Reduce message noisiness if ESP is missing
* Remove ERROR:, WARNING: prefixes in messages
* Use blk_create_devicef() in block device driver

Others:

* Let CONFIG_CMD_WGET depend on CONFIG_CMD_NET
2024-10-20 08:27:15 -06:00
Raymond Mao
7f45377152 mbedtls: fix defects in coverity scan
Fixes of unreleased buffer, deadcode and wrong variable type detected
by coverity scan.

Addresses-Coverity-ID: 510809:  Resource leaks  (RESOURCE_LEAK)
Addresses-Coverity-ID: 510806:  Control flow issues  (DEADCODE)
Addresses-Coverity-ID: 510794 Control flow issues  (NO_EFFECT)

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
2024-10-18 14:18:12 -06:00
Caleb Connolly
491195769d lmb: notify when adjacent regions are added
lmb_add_region() returns a positive integer if the added regions causes
existing regions to be coalesced. We still want to notify the EFI
subsystem about these added regions though, so adjust lmb_add() to only
bail on errors.

This fixes EFI memory allocation on boards with adjacent memory banks as is the
case on several Qualcomm boards like the RB3 Gen 2.

Fixes: 2f6191526a (lmb: notify of any changes to the LMB memory map)
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Reviewed-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-18 14:16:10 -06:00
Heinrich Schuchardt
640c6c6cba efi_driver: use blk_create_devicef()
The EFI block device driver is the only user of blk_create_device() outside
the block device uclass. Use blk_create_devicef() instead like other block
device drivers.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-10-18 17:05:19 +02:00
Heinrich Schuchardt
76a692a2ca efi_loader: remove ERROR:, WARNING: prefixes in messages
We should not write "ERROR:" or "WARNING:" when using log_err() or
log_warning(). These prefixed don't provide additional information.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-10-18 17:05:19 +02:00
Heinrich Schuchardt
640427c6ae efi_loader: add missing lf in error message
Messages written with log_err() should terminate with a linefeed.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-10-18 17:05:12 +02:00
Heinrich Schuchardt
bc4fe5666d efi_loader: reduce noisiness if ESP is missing
EFI variables can be stored in a file on the EFI system partition. If that
partition is missing we are writing two error messages per variable. This
is too noisy.

Just warn once about the missing ESP.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-18 16:17:29 +02:00
Heinrich Schuchardt
3d23dedd92 efi_loader: avoid #ifdef in efi_setup.c
We prefer `if` over `#ifdef` in our code.

Eliminate #ifdef statements in efi_setup.c.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-10-18 16:17:29 +02:00
Lad Prabhakar
22371048ed lib: fdtdec: Parse the gzip/lzo headers only when dependencies have met
It might happen that CONFIG_GZIP and CONFIG_LZO are enabled but we might
have CONFIG_MULTI_DTB_FIT_LZO enabled in this case in the code path of
uncompress_blob() we parse the gzip headers first which results in
`Error: Bad gzipped data` being printed. To avoid this parse the gzip/lzo
headers only when dependencies have met.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2024-10-17 15:01:14 -06:00
Jerome Forissier
27d7ccda94 net: lwip: tftp: add support of blksize option to client
The TFTP protocol uses a default block size of 512 bytes. This value is
sub-optimal for ethernet devices, which have a MTU (Maximum Transmission
Unit) of 1500 bytes. When taking into acount the overhead of the IP and
UDP layers, this leaves 1468 bytes for the TFTP payload.

This patch introduces a new function: tftp_client_set_blksize() which
may be used to change the block size from the default. It has to be
called after tftp_client_init() and before tftp_get(). If the server
does not support the option, the client will still accept to receive
512-byte blocks.

Submitted upstream: https://savannah.nongnu.org/patch/index.php?10462

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:57 -06:00
Jerome Forissier
4d4d783812 net: lwip: add TFTP support and tftpboot command
Implement do_tftpb(). This implementation of the tftp command
supports an optional port number. For example:

 tftp 192.168.0.30:9069:file.bin

It also supports taking the server IP from ${tftpserverip} if
defined, before falling back to ${serverip}.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:56 -06:00
Jerome Forissier
5634ecc88e net: lwip: tftp: bind to TFTP port only when in server mode
The TFTP app should not bind to the TFTP server port when configured as
a client. Instead, the local port should be chosen from the dynamic
range (49152 ~ 65535) so that if the application is stopped and started
again, the remote server will not consider the new packets as part of
the same context (which would cause an error since a new RRQ would be
unexpected).

Submitted upstream: https://savannah.nongnu.org/patch/?10480

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:56 -06:00
Jerome Forissier
98ad145db6 net: lwip: add DHCP support and dhcp commmand
Add what it takes to enable NETDEVICES with NET_LWIP and enable DHCP as
well as the dhcp command. CMD_TFTPBOOT is selected by BOOTMETH_EFI due
to this code having an implicit dependency on do_tftpb().

Note that PXE is likely non-fonctional with NET_LWIP (or at least not
100% functional) because DHCP option 209 is not supported by the lwIP
library. Therefore, BOOTP_PXE_DHCP_OPTION cannot be enabled.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:56 -06:00
Jerome Forissier
1c41a7afaa net: lwip: build lwIP
Build the lwIP library when NET_LWIP is enabled. The following files
are adaptation layers written specially for U-Boot:

 lib/lwip/u-boot/arch/cc.h
 lib/lwip/u-boot/arch/sys_arch.h (empty)
 lib/lwip/u-boot/limits.h (empty)
 lib/lwip/u-boot/lwipopts.h

They were initially contributed by Maxim in a previous RFC patch series.

The lwIP stack needs to be added as a Git subtree with the following
command:

 $ git subtree add --squash --prefix lib/lwip/lwip \
   https://github.com/lwip-tcpip/lwip.git  STABLE-2_2_0_RELEASE

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Co-developed-by: Maxim Uvarov <muvarov@gmail.com>
Cc: Maxim Uvarov <muvarov@gmail.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:56 -06:00
Tom Rini
1ca0ddb643 Merge commit 'f3f86fd1fe0fb288356bff78f8a6fa2edf89e3fc' as 'lib/lwip/lwip' 2024-10-16 08:10:14 -06:00
Sughosh Ganu
8d0df5fde3 lmb: replace the double-underscore with single-underscore for all functions
A bunch of static functions in the LMB module have used a
double-undersore for the function names. It was suggested to use a
single-underscore instead, as the double-underscore is usually used
by library functions. Replace the double-underscore with
single-underscore for all functions.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Suggested-by: Simon Glass <sjg@chromium.org>
2024-10-15 13:45:30 -06:00
Sughosh Ganu
f3fe3232a5 efi_memory: rename variable to highlight overlap with free memory
The variable overlap_only_ram is used to specify that the new memory
region that is being created needs to come from the free memory pool
-- this is done by carving out the memory region from the free
memory. The name is a bit confusing though, as other allocated memory
regions, like boot-services code and data are also part of the RAM
memory. Rename the variable to overlap_conventional to highlight the
fact that it is the free/conventional memory that is being referred to
in this context.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-10-15 13:45:30 -06:00
Sughosh Ganu
596516d330 lmb: remove call to efi_lmb_reserve()
The EFI memory allocations are now being done through the LMB
module. With this change, there is no need to get the EFI memory map
and set aside EFI allocated memory.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-10-15 13:45:30 -06:00