summaryrefslogtreecommitdiffstats
path: root/payloads/libpayload
Commit message (Collapse)AuthorAgeFilesLines
* treewide: Move list.h to commonlibMaximilian Brune2024-02-242-0/+6
| | | | | | | | | | | It is needed in order to move device_tree.c into commonlib in a subsequent commit. Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: I16eb7b743fb1d36301f0eda563a62364e7a9cfec Reviewed-on: https://review.coreboot.org/c/coreboot/+/77968 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* vboot: Enable new arm64 SIMD crypto accelerationJulius Werner2024-02-242-0/+13
| | | | | | | | | | | | | | | | This patch passes the correct flag to vboot to enable SIMD crypto acceleration on arm64 devices. This uses a core part of the ISA and should thus be supported on all arm64 SoCs -- so we normally always want it enabled, but there should still be a Kconfig in case a SoC wants to use the hwcrypto interface for its own (off-CPU) crypto acceleration engine instead. (You could also disable it to save a small amount of code size at the cost of speed, if necessary.) Change-Id: I3820bd6b7505202b7edb6768385ce5deb18777a4 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80710 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
* libpayload: Remove legacy CBFS APIJulius Werner2024-02-2218-1268/+0
| | | | | | | | | | | | | | | It's been several years already since we announced the deprecation of the legacy CBFS API for payloads. It's time to remove it completely. Change-Id: I0ed157ac2d1376b8dff4537af9a63731064b45f6 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80650 Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Jakub Czapiga <czapiga@google.com> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
* payloads: Add SPDX headers to KconfigMartin Roth2024-02-184-0/+8
| | | | | | | | | Change-Id: Iea569fd457b3cd1f4746fbc6a96319eb42733a6b Signed-off-by: Martin Roth <gaumless@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80586 Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
* Treewide: Fix incorrect SPDX license stringsMartin Roth2024-02-181-1/+1
| | | | | | | | | | | These strings didn't match the license names exactly, so update them to match. Change-Id: Ib946eb15ca5fa64cbd6b657350b989b4a4c1b7b7 Signed-off-by: Martin Roth <gaumless@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80583 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
* libpayload: timer: Revert timer_hz() return type to 64-bitsJulius Werner2024-02-085-10/+8
| | | | | | | | | | | | | | | | | | It seems that reducing the return type of timer_hz() to uint32_t in CB:78888 was a bad idea... some Intel platforms actually use their raw CPU clock for the timestamp counter which can be higher than 4GHz. This patch reverts it back to uint64_t. Also remove the redundant assertion in timer/generic.c since timer_us() itself already does that check. Cq-Depend: chromium:5274555 Change-Id: I471c7de7a28aec5bb965b23525ed579481ac8361 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80320 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Yidi Lin <yidilin@google.com>
* commonlib: Change GCD function to always use 64 bitsJulius Werner2024-02-082-2/+2
| | | | | | | | | | | | | | | | | | | | It seems that we have some applications where we need to calculate a GCD in 64 bits. Now, we could instantiate the algorithm multiple times for different bit width combinations to be able to use the most efficient one for each problem... but considering that the function usually only gets called once per callsite per stage, and that software emulation of 64-bit division on 32-bit systems doesn't take *that* long either, we would probably usually be paying more time loading the second instance of the function than we save with faster divisions. So let's just make things easy and always do it in 64-bit and then nobody has to spend time thinking on which version to call. Change-Id: I028361444c4048a0d76ba4f80c7334a9d9983c87 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80319 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yidi Lin <yidilin@google.com>
* libpayload: Switch to commonlib ipchksum() algorithmJulius Werner2024-02-025-94/+4
| | | | | | | | | | | | | This patch moves libpayload over to the commonlib implementation for calculating the IP checksum. Change-Id: Ie8d323ce9f8d946758619761b4b22d54bce222b6 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80253 Reviewed-by: Jakub Czapiga <czapiga@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Yidi Lin <yidilin@google.com>
* payloads: Rename Makefiles from .inc to .mkMartin Roth2024-01-2420-7/+7
| | | | | | | | | | | | | | | | The .inc suffix is confusing to various tools as it's not specific to Makefiles. This means that editors don't recognize the files, and don't open them with highlighting and any other specific editor functionality. This issue is also seen in the release notes generation script where Makefiles get renamed before running cloc. Signed-off-by: Martin Roth <gaumless@gmail.com> Change-Id: Ie7038712de8cc646632d5e7d29550e3260bf2c62 Reviewed-on: https://review.coreboot.org/c/coreboot/+/80103 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* Makefiles: Rename top-level Makefiles from .inc to .mkMartin Roth2024-01-241-2/+2
| | | | | | | | | | | | | | | | | | | The .inc suffix is confusing to various tools as it's not specific to Makefiles. This means that editors don't recognize the files, and don't open them with highlighting and any other specific editor functionality. This issue is also seen in the release notes generation script where Makefiles get renamed before running cloc. The rest of the Makefiles will be renamed in following commits. Signed-off-by: Martin Roth <gaumless@gmail.com> Change-Id: Idaf69c6871d0bc1ee5e2e53157b8631c55eb3db9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/80063 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* libpayload/arch/arm64/mmu: Specify ttb_buffer section name explicitlyYu-Ping Wu2024-01-221-4/+7
| | | | | | | | | | | | | | Although a section ".bss.ttb_buffer" is created automatically for 'ttb_buffer' with the GCC option '-fdata-sections', specify the section name explicitly to make the name stand out to code readers, and to reduce the chance of accidentally changing the section name by renaming the variable. Change-Id: I2930f238f63b555c4caa65709768afa314d9cf87 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/80014 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* libpayload/vboot/Makefile.inc: Pass FIRMWARE_ARCH=mock if LP_ARCH_MOCKYu-Ping Wu2024-01-181-8/+11
| | | | | | | | | | | | | | | | If CONFIG_LP_ARCH_MOCK, pass FIRMWARE_ARCH=mock when building vboot fwlib, so that vboot's Makefile will append the correct flags to CFLAGS. BUG=none TEST=(depthcharge) make unit-tests -j BRANCH=none Cq-Depend: chromium:5182247 Change-Id: I9ead7f2f93eac5f5c3887074423fb9aa50a489c0 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79956 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Make sure to install into the right DESTDIRNico Huber2024-01-141-2/+2
| | | | | | | | | | | | | | A recent update broke installation of commonlib headers with a relative path in $(DESTDIR), which is the default. Make sure to install into the right location in case we changed the current directory. Change-Id: I61fa4aa0ecd0f81ee03ff89183e1b65e7875dea6 Signed-off-by: Nico Huber <nico.h@gmx.de> Fixes: ee53dfd07d3b (libpayload: Remove shell for loops in install Makefile target) Reviewed-on: https://review.coreboot.org/c/coreboot/+/79908 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Move back the ttb_buffer sectionYi Chou2024-01-112-4/+5
| | | | | | | | | | | | | | | | | | Moving it into the .ttb_buffer section will accidentally set the LOAD flag. So, move it back to .bss.ttb_buffer section to prevent the binary size bloating. BUG=b:248610274 TEST=Make sure the device is still bootable with this change. BRANCH=none Cq-Depend: chromium:5173448 Change-Id: I9bb08878dd4be01d9ed3f96933f774dd6296f76e Signed-off-by: Yi Chou <yich@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79800 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Remove shell for loops in install Makefile targetPatrick Georgi2023-12-311-12/+5
| | | | | | | | | | | | | They always require special care so that line breaks and variable names are escaped properly. One loop can be removed entirely because install accepts multiple files to install in a target directories, the other loops were filled by find which can just call the commands on its own. Change-Id: I9f9dddfe3f3ceceb6a0510d6dd862351e4b10210 Signed-off-by: Patrick Georgi <patrick@coreboot.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79523 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Add VBOOT_X86_RSA_ACCELERATION configJeremy Compostella2023-12-282-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add `VBOOT_X86_RSA_ACCELERATION' Kconfig option to enable SSE2 instruction set implementation of modulus exponentiation which is part of the RSA signature verification process. This option is enabled on CHROMEOS. | modpow() function call | original on rex0 | SSE2 on rex0 | |------------------------+------------------+--------------| | depthcharge - step 1 | 0.547 | 0.288 | | depthcharge - step 2 | 0.152 | 0.081 | | depthcharge - step 3 | 0.164 | 0.079 | |------------------------+------------------+--------------| | Total (ms) | 0.863 | 0.448 | | modpow() function call | original on brya0 | SSE2 on rex0 | |------------------------+-------------------+--------------| | depthcharge - step 1 | 0.693 | 0.248 | | depthcharge - step 2 | 0.172 | 0.065 | | depthcharge - step 3 | 0.223 | 0.067 | |------------------------+-------------------+--------------| | Total (ms) | 1.088 | 0.38 | BUG=b:312709384 TEST=modular exponentiation is about twice faster on rex0 and brya0 Change-Id: I801ebd7839261c6bd07fb218e1e36a7108e219bf Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79290 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
* libpayload/arm64: Round fb_size up to a multiple of GRANULE_SIZEYidi Lin2023-12-111-2/+3
| | | | | | | | | | | | | If a framebuffer is already configured by coreboot, we need to ensure that the framebuffer size is a multiple of GRANULE_SIZE before passing to `mmu_add_memrange`. Otherwise, we would fail to allocate memory region due to `sanity_check`. Change-Id: Ia6a6400733ca10a61220087e87022f68c28e4789 Signed-off-by: Yidi Lin <yidilin@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79451 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Fix the stack and data labelsYi Chou2023-12-016-15/+33
| | | | | | | | | | | | | | | | | We should make sure _stack/_estack and the other labels are consistent. And _data & _edata is also useful to clean up the sensitive data on the data section. BUG=b:248610274 TEST=emerge-cherry libpayload BRANCH=none Cq-Depend: chromium:5052462 Change-Id: I589040f4db60b35813ea9f4ba9503244bd7def00 Signed-off-by: Yi Chou <yich@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79144 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
* libpayload/unit-tests: Rename ARCH_BIG_ENDIAN to ARCH_MOCK_BIG_ENDIANPatrick Georgi2023-11-251-1/+1
| | | | | | | | | | | | This fixes commit 12ae850dfc1 which used the wrong symbol, and previous versions of Kconfig didn't notice. Change-Id: I7145fd81a30a1455a6dd2c7f24564956a116d180 Signed-off-by: Patrick Georgi <patrick@coreboot.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79263 Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-by: Martin L Roth <gaumless@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Move ttb_buffer to a standalone sectionYi Chou2023-11-232-1/+4
| | | | | | | | | | | | | | | | When cleaning the sensitive data in the memory, we will want to prevent zero out the content of tbb_buffer. Move the ttb_buffer to a standalone section will simplify the problem. BUG=b:248610274 TEST=emerge-cherry libpayload BRANCH=none Change-Id: I610276cbe30552263d791860c15e5ad9a201c744 Signed-off-by: Yi Chou <yich@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/79078 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Add dma_allocator_range()Yi Chou2023-11-212-0/+13
| | | | | | | | | | | | | | | | | | | Some sensitive data may remain DMA buffer, we will want to zero out everything on the DMA buffer before we jump into the kernel to prevent leaking sensitive data into the kernel. To accomplish that, we will need this function to get the range of memory that can be allocated by the dma allocator. BUG=b:248610274 TEST=emerge-cherry libpayload BRANCH=none Signed-off-by: Yi Chou <yich@google.com> Change-Id: I8f3058dfd861ed44f716623967201b8cabe8d166 Reviewed-on: https://review.coreboot.org/c/coreboot/+/78407 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
* libpayload/libc/time: Fix possible overflow in multiplicationYidi Lin2023-11-075-9/+16
| | | | | | | | | | | | | | | | | | | | The value from raw_read_cntfrq_el0() could be large enough to cause overflow when multiplied by USECS_PER_SEC. To prevent this, both USECS_PER_SEC and hz can be reduced by dividing them by their GCD. This patch also modifies the return type of `timer_hz()` from `uint64_t` to `uint32_t`, assuming that in practice the timestamp counter should never be that fast. BUG=b:307790895 TEST=boot to kernel and check the timestamps from `cbmem` Change-Id: Ia55532490651fcf47128b83a8554751f050bcc89 Signed-off-by: Yidi Lin <yidilin@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/78888 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload/libc/getopt_long: Use common GCDYidi Lin2023-11-042-20/+3
| | | | | | | | | | | TEST=emerge-geralt libpayload Change-Id: Ib9dd1d2f658d4411c36d0198774819690686a393 Signed-off-by: Yidi Lin <yidilin@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/78887 Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* {commonlib, libpayload}: Add "has_external_display" in coreboot tableSubrata Banik2023-10-041-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces a new coreboot table entry named "has_external_display" to understand if external display is attached. This information is useful to prevent graceful shutdown by payload when the LID is closed but an external display is present. This piece of the information will be gathered by coreboot and passed into the payload using this new entry aka external_display because payload (i.e., deptcharge) doesn't have any other way to determine if external display is available. BUG=b:299137940 TEST=Able to build and boot google/rex. w/o this patch: LID closed and external display attached (HDMI) in developer mode (GBB 0x39): > System is powered off by depthcharge w/ this patch: LID closed and external display attached (HDMI) in developer mode (GBB 0x39): > Booted to OS and device is alive/usable Change-Id: I0fa7eee4c5a50371a7a66c6ca1ac2c7d046d010b Signed-off-by: Subrata Banik <subratabanik@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/77796 Reviewed-by: Eric Lai <ericllai@google.com> Reviewed-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload/libcbfs: Add VBOOT_CBFS_INTEGRATION supportJakub Czapiga2023-09-182-1/+11
| | | | | | | | | | | | | | | | If LP_VBOOT_CBFS_INTEGRATION is enabled, then libcbfs will reboot with vboot failure in non-recovery mode on CBFS file hash mismatch. BUg=b:197114807 TEST=Build with VBOOT_CBFS_INTEGRATION enabled and boot on google/ovis4es device Change-Id: Ic0f62212b7217b384e8c4cbd9535fe4243301f8c Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/77726 Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Add vboot and reboot utility functionsJakub Czapiga2023-09-184-0/+36
| | | | | | | | | | | | | | | | | | | | | Patch adds: - vboot_fail_and_reboot() for vboot failures handling. - reboot() weak implementation for payloads to implement, used by vboot_fail_and_reboot(). - vboot_recovery_mode_enabled() to check if recovery mode flag is set in vboot context. Implemented for future libcbfs implementation of VBOOT_CBFS_INTEGRATION in libpayload. BUG=b:197114807 TEST=none Change-Id: I53d1955573d54bc56d05f7780c18dcc8ac1fd399 Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/77725 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
* libpayload/vboot: Add vboot context initialization and management codeJakub Czapiga2023-09-185-1/+58
| | | | | | | | | | | | | | | | | | | | | | To fully and easily implement fallback/recovery in libcbfs with vboot support the codebase requires access to vboot context. Moving context management to libpayload allows to avoid unnecessary overhead and code complication and still allows payloads to access it in a way it was designed. Access to this codebase will also allow implementation of e.g. vboot_fail_and_reboot() and other helpful utilities used by coreboot and depthcharge. BUG=b:197114807 TEST=make unit-tests TEST=Build and boot on google/ovis4es with CL:4839296 and VBOOT_CBFS_INTEGRATION enabled Change-Id: Id719be7c4f07251201424b7dc6c1125c6b5756d8 Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/77635 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
* libpayload/drivers/video: Add cursor movement support in consoleEran Mitrani2023-09-182-0/+8
| | | | | | | | | | | | | | Add support for moving the console cursor horizontally and vertically. BUG=b:300405745 TEST=Tested using firmware shell on Rex. Signed-off-by: Eran Mitrani <mitrani@google.com> Change-Id: I585add120b559396bc0e28aa972b0ae2a33f1fa8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77900 Reviewed-by: Kapil Porwal <kapilporwal@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
* libpayload: Add after an if conditional on the next lineArthur Heymans2023-09-071-8/+16
| | | | | | | | | | Clang warns about this. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: I8bdd45a7ef47274b0253397fa8fd9409a70d2192 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77434 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@gmail.com>
* payloads/libpayload: Don't use old style function definitionElyes Haouas2023-08-281-1/+1
| | | | | | | | | | Use "int foo(void)" instead of old-style "int foo()". Change-Id: Ic698dbbba74d579a21ff57005a7aa9bb8ce80253 Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/77485 Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Fix clang fallthrough warningArthur Heymans2023-08-284-5/+7
| | | | | | | | | | | | | Clang does not recognize comments to indicate falltrough is intended behavior. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: Idcf7a24fc763b80863902702172b4ea950e132b8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77431 Reviewed-by: Martin L Roth <gaumless@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
* libpayload: Skip unknown arguments to clangArthur Heymans2023-08-261-0/+2
| | | | | | | | | | This compiler argument only exists on gcc. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: I10902517c86daedc9853e6f6cac8fcf513211bb2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77436 Reviewed-by: Elyes Haouas <ehaouas@noos.fr> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Remove unnecessary bracketsArthur Heymans2023-08-261-1/+1
| | | | | | | | | | This fixes compilation with clang. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: I675056c8a15fe446bba81a144bfea64d106df293 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77435 Reviewed-by: Elyes Haouas <ehaouas@noos.fr> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Fix untyped function argumentsArthur Heymans2023-08-261-1/+1
| | | | | | | | | | This is necessary with clang. Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Change-Id: Icc197fbd48b49bfa8770caf01727669b0ac59090 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77433 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
* libpayload: Outsource delay function into own headerThomas Heijligen2023-08-243-49/+60
| | | | | | | | | | | | For libflashrom we need the delay functions but when including the whole libpayload.h it has conflicting symbols. Change-Id: I6e4a669b8ba25836fb870d74c200985c1bfdb387 Signed-off-by: Thomas Heijligen <src@posteo.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/70139 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Julius Werner <jwerner@chromium.org>
* payloads/libpayload: Remove ARCH_SPECIFIC_OPTIONSElyes Haouas2023-08-204-19/+11
| | | | | | | | | | Remove dummy ARCH_SPECIFIC_OPTIONS. Change-Id: Ia71021b8597b1d6a227292b6568351e994ad62b0 Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/76940 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@gmail.com>
* libpayload/cbfs: Fill size_out even if cbfs_map() failsYu-Ping Wu2023-08-181-3/+7
| | | | | | | | | | | | | | | | | When cbfs_map()/cbfs_ro_map() fails, the caller may still want to know the decompressed size of the CBFS file, for example, to print an error message. Move the assignment earlier in the flow. Note that coreboot's cbfs_map() is already doing the same. BUG=none TEST=emerge-geralt libpayload BRANCH=none Change-Id: I82c6b7e69c95bf597fa3c7d37dd11252893c01af Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/77193 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload/include/stdarg.h: Add va_copy builtinMaximilian Brune2023-08-171-0/+1
| | | | | | | | | | Add the builtin to copy variadic lists/arguments. Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: I4507b901bdce052c5d1701fdf825eb8a96a5b55a Reviewed-on: https://review.coreboot.org/c/coreboot/+/77097 Reviewed-by: Martin L Roth <gaumless@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload: Add parsing of SMBIOS addressMaximilian Brune2023-08-172-0/+4
| | | | | | | | Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: Ie4032048f5f53b25c46f00b3b48eb5f986a5d0b3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/77045 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@gmail.com>
* libpayload/drivers/cbmem_console: Use C99 flexible arraysElyes Haouas2023-08-011-1/+1
| | | | | | | | | | | | | Use C99 flexible arrays instead of older style of one-element or zero-length arrays. It allows the compiler to generate errors when the flexible array does not occur at the end in the structure. Change-Id: I3fd3f068ff731e1d9fed7c38ba6815e1eed86450 Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/76849 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de>
* payloads/libpayload/include/coreboot_tables: Use C99 flexible arraysElyes Haouas2023-08-011-7/+7
| | | | | | | | | | | | | Use C99 flexible arrays instead of older style of one-element or zero-length arrays. It allows the compiler to generate errors when the flexible array does not occur at the end in the structure. Change-Id: Icf3da1b0a0666769ae7b5d5f641b85436b324b4c Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/76851 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload/uhci: Re-write UHCI RH driver w/ generic_hub APINico Huber2023-06-121-152/+91
| | | | | | | | | | | | | | | | | | | | | | This is a complete rewrite of the UHCI root-hub driver, based on the xHCI one. We are doing things by the book as far as possible. One special case is uhci_rh_reset_port() which does the reset se- quencing that usually the hardware would do. This abandons some quirks of the old driver: * Ports are not disabled/re-enabled for every attachment anymore. * We solely rely on the Connect Status Change bit to track changes. * Further status changes are now deferred to the next polling round. The latter fixes endless loops in combination with commit 7faff543da (libpayload: usb: Detach unused USB devices). Change-Id: I5211728775eb94dfc23fa82ebf00fe5c99039709 Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/75504 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
* libpayload/drivers/usb/xhci.c: Check for NULL in xhci_initFred Reitberger2023-06-061-0/+4
| | | | | | | | | | | | | | | Ensure the physical_bar parameter passed to xhci_init is not NULL, else return NULL. This may occur when an XHCI controller is disabled and no resources are allocated for it. BUG=b:284213001 Change-Id: I05c32612606793adcba3f4a5724092387a215d41 Signed-off-by: Fred Reitberger <reitbergerfred@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/75645 Reviewed-by: Jon Murphy <jpmurphy@google.com> Reviewed-by: Karthik Ramasubramanian <kramasub@google.com> Reviewed-by: Martin L Roth <gaumless@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* libpayload/uhci: Return expected length for control/bulk transfersNico Huber2023-06-041-11/+13
| | | | | | | | | | | | | | | Libpayload's USB API was changed in commit e9738dbe2b (libpayload: Make USB transfer functions return amount of bytes). However, the UHCI driver was never adapted. Instead of returning 0 for success, we can return the expected data length as a best effort. We won't be able to catch short transfers this way, but previously working cases will work again. Change-Id: I31d7de495a46af401e2cbe5a3b8f6349facad8ff Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/75349 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
* libpayload;arch,cpu/x86: drop USE_MARCH_586 Kconfig optionFelix Held2023-05-271-8/+0
| | | | | | | | | | | | | Only the Intel Quark SoC selected this option and that SoC was dropped in commit 531023285ea4 ("soc/intel/quark: Drop support"), so drop this Kconfig option too. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Ic4f1c7530cd8ac7a1945b1493a2d53a7904daa06 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75473 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* payloads/libpayload/configs: drop config.galileoFelix Held2023-05-271-6/+0
| | | | | | | | | | | | The Galileo board was dropped in commit 037c25d4dd8d ("mb/intel/ galileo: Drop support"), so also drop this config file. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I8c85dc03c3a4a016d6e13f1bee170d1bc6439470 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75472 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nicholas Chin <nic.c3.14@gmail.com>
* libpayload/arch/x86: Update API handling of CBTABLE handoffMaximilian Brune2023-05-244-29/+12
| | | | | | | | | | | | | | | | | | | | The payload API of coreboot described in https://www.coreboot.org/Payload_API does not reflect the current handoff mechanism to hand the coreboot tables off. Therefore the arguments supplied by coreboot (cbtable) will currently never be parsed correctly and libpayload has to search for the coreboot tables by iterating through memory. This patch removes the old payload API implementation and just takes the coreboot table pointer from the first argument on the stack. Tested: started prodrive/atlas with coreinfo payload Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com> Change-Id: I51fb0cfc81043cbfe3fc9c8ea0776add2d6a42b2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74965 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tree: Replace `egrep` with `grep -E`Felix Singer2023-04-061-1/+1
| | | | | | | | | | | | For compatibility reasons, egrep is just a wrapper around grep today. Thus, replace it with `grep -E`. Change-Id: Ief08a22e4cd7211a3fee278492c95d37f9e058fa Signed-off-by: Felix Singer <felix.singer@secunet.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/74171 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
* libpayload: strings.h: Use builtin __ffs instead of included oneThomas Heijligen2023-03-071-3/+1
| | | | | | | | | Change-Id: Ie4d0b1b19ce6524341449df8bfabc66bff7bd97e Signed-off-by: Thomas Heijligen <src@posteo.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/70118 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* libpayload: bin/lpgcc allow to call without filesThomas Heijligen2023-03-071-1/+1
| | | | | | | | | | | | | | | When building libflashrom ontop of libpayload, meson calls the lpgcc wrapper with -xc but without a file to obtain information about the C compiler. To make this work guard $_LIBGCC with -xnone in the lpgcc wrapper. -xnone tells the compiler to interpret the following files of libpayload by their suffix, not the privious given -x option. Change-Id: I9e037ff44c0a6d0585d8a6f8aeabae6e651142e2 Signed-off-by: Thomas Heijligen <src@posteo.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/70117 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>