libpayload: Add mock architecture

Hardware / Coreboot - Jakub Czapiga [semihalf.com] - 11 October 2021 12:59 UTC

Mock architecture can be used to build libpayload using host compiler. It can be enabled by setting ARCH_MOCK=y in the dotconfig. It sets LITTLE_ENDIAN=y, as most machines these days use little-endian CPUs. Libpayload will use HOSTCC as CC, HOSTLD as LD, etc. instead of tools provided by xcompile. Mock architecture configuration can be used by payloads for testing purposes. Thanks to it, tests can be architecture-independent, and can be executed without requiring compatible Kconfig options, e.g. ARCH_ARM64=y for ARM64 machine. However, one has to provide implementation for most architecture-specific functions present in arch/* directories.

3d91b47b42 libpayload: Add mock architecture
payloads/libpayload/Kconfig | 10 +++++
payloads/libpayload/Makefile | 41 +++++++++++++++++-
payloads/libpayload/Makefile.inc | 1 +
payloads/libpayload/arch/mock/Kconfig | 16 ++++++++
payloads/libpayload/arch/mock/Makefile.inc | 7 ++++
payloads/libpayload/arch/mock/head.c | 3 ++
payloads/libpayload/arch/mock/libpayload.ldscript | 3 ++
payloads/libpayload/arch/mock/mock_media.c | 10 +++++
payloads/libpayload/arch/mock/virtual.c | 10 +++++
payloads/libpayload/bin/lpgcc | 13 +++++-
payloads/libpayload/include/mock/arch/barrier.h | 13 ++++++
payloads/libpayload/include/mock/arch/cache.h | 18 ++++++++
payloads/libpayload/include/mock/arch/io.h | 29 +++++++++++++
payloads/libpayload/include/mock/arch/types.h | 33 +++++++++++++++
payloads/libpayload/include/mock/arch/virtual.h | 15 +++++++
payloads/libpayload/sample/Makefile | 5 +++
payloads/libpayload/sample/arch_mock/Makefile | 48 ++++++++++++++++++++++
payloads/libpayload/sample/arch_mock/hello.c | 13 ++++++
payloads/libpayload/sample/arch_mock/hello_mocks.c | 43 +++++++++++++++++++
19 files changed, 329 insertions(+), 2 deletions(-)

Upstream: review.coreboot.org


  • Share