libpayload: Add mock architecture
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. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ie3a6e6f6cad2f8a2e48a8e546d3b79c577653080 Reviewed-on: https://review.coreboot.org/c/coreboot/+/57708 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
committed by
Felix Held
parent
b40fdbaa64
commit
3d91b47b42
16
payloads/libpayload/arch/mock/Kconfig
Normal file
16
payloads/libpayload/arch/mock/Kconfig
Normal file
@@ -0,0 +1,16 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
if ARCH_MOCK
|
||||
|
||||
config ARCH_MOCK_BIG_ENDIAN
|
||||
bool "Use big-endian for mock architecture"
|
||||
default n
|
||||
help
|
||||
This option enables big-endinan support in the code.
|
||||
|
||||
config ARCH_SPECIFIC_OPTIONS
|
||||
def_bool y
|
||||
select LITTLE_ENDIAN if !ARCH_MOCK_BIG_ENDIAN
|
||||
select BIG_ENDIAN if ARCH_MOCK_BIG_ENDIAN
|
||||
|
||||
endif
|
7
payloads/libpayload/arch/mock/Makefile.inc
Normal file
7
payloads/libpayload/arch/mock/Makefile.inc
Normal file
@@ -0,0 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
head.o-y += head.c
|
||||
|
||||
libc-y += virtual.c
|
||||
|
||||
libcbfs-$(CONFIG_LP_CBFS) += mock_media.c
|
3
payloads/libpayload/arch/mock/head.c
Normal file
3
payloads/libpayload/arch/mock/head.c
Normal file
@@ -0,0 +1,3 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
|
||||
/* This file is empty on purpose. It should not be used. */
|
3
payloads/libpayload/arch/mock/libpayload.ldscript
Normal file
3
payloads/libpayload/arch/mock/libpayload.ldscript
Normal file
@@ -0,0 +1,3 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
|
||||
/* This file is empty on purpose. It is present only to satisfy install script */
|
10
payloads/libpayload/arch/mock/mock_media.c
Normal file
10
payloads/libpayload/arch/mock/mock_media.c
Normal file
@@ -0,0 +1,10 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
|
||||
#include <cbfs.h>
|
||||
|
||||
int libpayload_init_default_cbfs_media(struct cbfs_media *media);
|
||||
|
||||
__attribute__((weak)) int libpayload_init_default_cbfs_media(struct cbfs_media *media)
|
||||
{
|
||||
return -1;
|
||||
}
|
10
payloads/libpayload/arch/mock/virtual.c
Normal file
10
payloads/libpayload/arch/mock/virtual.c
Normal file
@@ -0,0 +1,10 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
unsigned long virtual_offset = 0;
|
||||
|
||||
int getpagesize(void)
|
||||
{
|
||||
return 4096;
|
||||
}
|
Reference in New Issue
Block a user