diff --git a/arch/arm64/core/Kconfig b/arch/arm64/core/Kconfig index 21327f62c1b..90246c082c4 100644 --- a/arch/arm64/core/Kconfig +++ b/arch/arm64/core/Kconfig @@ -357,4 +357,11 @@ config MAX_XLAT_TABLES 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 diff --git a/include/zephyr/arch/arm64/cache.h b/include/zephyr/arch/arm64/cache.h index 5519aa150b8..00f75bc3523 100644 --- a/include/zephyr/arch/arm64/cache.h +++ b/include/zephyr/arch/arm64/cache.h @@ -139,6 +139,8 @@ done: return 0; } +#ifdef CONFIG_ARM64_DCACHE_ALL_OPS + /* * operation for all data cache * 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); } +#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) { return arm64_dcache_range(addr, size, K_CACHE_WB);