diff options
Diffstat (limited to 'payloads/libpayload/include/mock')
-rw-r--r-- | payloads/libpayload/include/mock/arch/barrier.h | 13 | ||||
-rw-r--r-- | payloads/libpayload/include/mock/arch/cache.h | 18 | ||||
-rw-r--r-- | payloads/libpayload/include/mock/arch/io.h | 29 | ||||
-rw-r--r-- | payloads/libpayload/include/mock/arch/types.h | 33 | ||||
-rw-r--r-- | payloads/libpayload/include/mock/arch/virtual.h | 15 |
5 files changed, 108 insertions, 0 deletions
diff --git a/payloads/libpayload/include/mock/arch/barrier.h b/payloads/libpayload/include/mock/arch/barrier.h new file mode 100644 index 0000000000..aed115bb64 --- /dev/null +++ b/payloads/libpayload/include/mock/arch/barrier.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ARCH_BARRIER_H__ +#define __ARCH_BARRIER_H__ + +/* No memory barrier on mock build */ +#define mb() +/* No read memory barrier on mock build */ +#define rmb() +/* No write memory barrier on mock build */ +#define wmb() + +#endif /* __ARCH_BARRIER_H__ */ diff --git a/payloads/libpayload/include/mock/arch/cache.h b/payloads/libpayload/include/mock/arch/cache.h new file mode 100644 index 0000000000..1e71d5e0e2 --- /dev/null +++ b/payloads/libpayload/include/mock/arch/cache.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ARCH_CACHE_H__ +#define __ARCH_CACHE_H__ + +/* No support for cache in the mock architecture */ + +#define dmb() +#define dsb() +#define dcache_clean_all() +#define dcache_clean_by_mva(addr, len) +#define dcache_invalidate_all() +#define dcache_invalidate_by_mva(addr, len) +#define dcache_clean_invalidate_all() +#define dcache_clean_invalidate_by_mva(addr, len) +#define cache_sync_instructions() + +#endif /* __ARCH_CACHE_H__ */ diff --git a/payloads/libpayload/include/mock/arch/io.h b/payloads/libpayload/include/mock/arch/io.h new file mode 100644 index 0000000000..2bb625562e --- /dev/null +++ b/payloads/libpayload/include/mock/arch/io.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _ARCH_IO_H +#define _ARCH_IO_H + +#include <inttypes.h> + +/* Functions in this file are unimplemented by default. Tests are expected to implement + mocks for these functions, if tests will call functions using functions listed below. */ + +uint8_t readb(volatile const void *_a); +uint16_t readw(volatile const void *_a); +uint32_t readl(volatile const void *_a); + +void writeb(uint8_t _v, volatile void *_a); +void writew(uint16_t _v, volatile void *_a); +void writel(uint32_t _v, volatile void *_a); + +uint8_t read8(volatile const void *addr); +uint16_t read16(volatile const void *addr); +uint32_t read32(volatile const void *addr); +uint64_t read64(volatile const void *addr); + +void write8(volatile void *addr, uint8_t val); +void write16(volatile void *addr, uint16_t val); +void write32(volatile void *addr, uint32_t val); +void write64(volatile void *addr, uint64_t val); + +#endif /* _ARCH_IO_H */ diff --git a/payloads/libpayload/include/mock/arch/types.h b/payloads/libpayload/include/mock/arch/types.h new file mode 100644 index 0000000000..8f090caa9b --- /dev/null +++ b/payloads/libpayload/include/mock/arch/types.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _ARCH_TYPES_H +#define _ARCH_TYPES_H + +typedef unsigned char uint8_t; +typedef unsigned char u8; +typedef signed char int8_t; +typedef signed char s8; + +typedef unsigned short uint16_t; +typedef unsigned short u16; +typedef signed short int16_t; +typedef signed short s16; + +typedef unsigned int uint32_t; +typedef unsigned int u32; +typedef signed int int32_t; +typedef signed int s32; + +typedef unsigned long long uint64_t; +typedef unsigned long long u64; +typedef signed long long int64_t; +typedef signed long long s64; + +typedef long time_t; +typedef long suseconds_t; + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#endif /* _ARCH_TYPES_H */ diff --git a/payloads/libpayload/include/mock/arch/virtual.h b/payloads/libpayload/include/mock/arch/virtual.h new file mode 100644 index 0000000000..bf786d5256 --- /dev/null +++ b/payloads/libpayload/include/mock/arch/virtual.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _ARCH_VIRTUAL_H +#define _ARCH_VIRTUAL_H + +/* virtual_offset has to be declared if used */ +extern unsigned long virtual_offset; + +#define virt_to_phys(virt) ((unsigned long)(virt) + virtual_offset) +#define phys_to_virt(phys) ((void *)((unsigned long)(phys) - virtual_offset)) + +#define virt_to_bus(addr) virt_to_phys(addr) +#define bus_to_virt(addr) phys_to_virt(addr) + +#endif |