arch: arm64: cache: optionally enable APIs for operation all dcache

Added new configuration item to optionally enable APIs for operation
all data cache, by default these APIs are disabled.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
This commit is contained in:
Jiafei Pan 2025-05-15 13:54:35 +08:00 committed by Benjamin Cabé
commit abcdb18568
2 changed files with 28 additions and 0 deletions

View file

@ -357,4 +357,11 @@ config MAX_XLAT_TABLES
endif # ARM_MMU endif # ARM_MMU
config ARM64_DCACHE_ALL_OPS
bool "Provide data cache APIs to operate all data caches"
depends on CACHE_MANAGEMENT && DCACHE
help
Enable this option to provide the data cache APIs to flush or
invalidate all data caches.
endif # CPU_CORTEX_A || CPU_AARCH64_CORTEX_R endif # CPU_CORTEX_A || CPU_AARCH64_CORTEX_R

View file

@ -139,6 +139,8 @@ done:
return 0; return 0;
} }
#ifdef CONFIG_ARM64_DCACHE_ALL_OPS
/* /*
* operation for all data cache * operation for all data cache
* ops: K_CACHE_INVD: invalidate * ops: K_CACHE_INVD: invalidate
@ -227,6 +229,25 @@ static ALWAYS_INLINE int arch_dcache_flush_and_invd_all(void)
return arm64_dcache_all(K_CACHE_WB_INVD); return arm64_dcache_all(K_CACHE_WB_INVD);
} }
#else
static ALWAYS_INLINE int arch_dcache_flush_all(void)
{
return -ENOTSUP;
}
static ALWAYS_INLINE int arch_dcache_invd_all(void)
{
return -ENOTSUP;
}
static ALWAYS_INLINE int arch_dcache_flush_and_invd_all(void)
{
return -ENOTSUP;
}
#endif /* CONFIG_ARM64_DCACHE_ALL_OPS */
static ALWAYS_INLINE int arch_dcache_flush_range(void *addr, size_t size) static ALWAYS_INLINE int arch_dcache_flush_range(void *addr, size_t size)
{ {
return arm64_dcache_range(addr, size, K_CACHE_WB); return arm64_dcache_range(addr, size, K_CACHE_WB);