From e5cce0055239b3c73ea5220c122e183694091ab6 Mon Sep 17 00:00:00 2001 From: Yu-Ping Wu Date: Tue, 1 Oct 2024 06:41:32 +0800 Subject: libpayload: Remove default empty implementations in mock cache.h The mock/arch/cache.h file exists for libpayload unit tests. However, the default implementations (as empty macros) in it make these functions difficult to mock in unit tests. Therefore, we follow what's done for mock/arch/io.h, by only including function declarations in the header. Each test is expected to implement mocks for these cache functions when required. Change-Id: Ie4383bf95435fd7d74d624b19b79b5a117cf6d00 Signed-off-by: Yu-Ping Wu Reviewed-on: https://review.coreboot.org/c/coreboot/+/84608 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner Reviewed-by: Hsuan-ting Chen --- payloads/libpayload/include/mock/arch/cache.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/payloads/libpayload/include/mock/arch/cache.h b/payloads/libpayload/include/mock/arch/cache.h index 1e71d5e0e2..0e4bc033d0 100644 --- a/payloads/libpayload/include/mock/arch/cache.h +++ b/payloads/libpayload/include/mock/arch/cache.h @@ -3,16 +3,19 @@ #ifndef __ARCH_CACHE_H__ #define __ARCH_CACHE_H__ -/* No support for cache in the mock architecture */ +#include -#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() +/* 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. */ + +void dmb(void); +void dsb(void); +void dcache_clean_all(void); +void dcache_clean_by_mva(void const *addr, size_t len); +void dcache_invalidate_all(void); +void dcache_invalidate_by_mva(void const *addr, size_t len); +void dcache_clean_invalidate_all(void); +void dcache_clean_invalidate_by_mva(void const *addr, size_t len); +void cache_sync_instructions(void); #endif /* __ARCH_CACHE_H__ */ -- cgit v1.2.3