Yu-Ping Wu has submitted this change. ( https://review.coreboot.org/c/coreboot/+/84608?usp=email )
Change subject: libpayload: Remove default empty implementations in mock cache.h ......................................................................
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 yupingso@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/84608 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Julius Werner jwerner@chromium.org Reviewed-by: Hsuan-ting Chen roccochen@google.com --- M payloads/libpayload/include/mock/arch/cache.h 1 file changed, 13 insertions(+), 10 deletions(-)
Approvals: Julius Werner: Looks good to me, approved Hsuan-ting Chen: Looks good to me, approved build bot (Jenkins): Verified
diff --git a/payloads/libpayload/include/mock/arch/cache.h b/payloads/libpayload/include/mock/arch/cache.h index 1e71d5e..0e4bc03 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 <stddef.h>
-#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__ */