1 /*
2  * Copyright (c) 2006-2022, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2022-12-18     RT-Thread    the first version
9  */
10 
11 #ifndef __CACHE_H__
12 #define __CACHE_H__
13 
14 #include <rtdef.h>
15 
16 void __asm_invalidate_icache_all(void);
17 
18 void rt_hw_dcache_flush_all(void);
19 void rt_hw_dcache_invalidate_all(void);
20 void rt_hw_dcache_flush_range(unsigned long start_addr, unsigned long size);
21 void rt_hw_cpu_dcache_clean(void *addr, unsigned long size);
22 void rt_hw_cpu_dcache_invalidate(void *start_addr, unsigned long size);
23 
rt_hw_icache_invalidate_all(void)24 static inline void rt_hw_icache_invalidate_all(void)
25 {
26     /* wait for previous modification to complete */
27     __asm__ volatile ("dsb ishst");
28 
29     __asm__ volatile ("ic ialluis");
30     /* wait for ic to retire */
31     __asm__ volatile ("dsb nsh");
32     /* flush instruction pipeline */
33     __asm__ volatile ("isb");
34 }
35 
36 void rt_hw_cpu_icache_invalidate(void *addr, rt_size_t size);
37 void rt_hw_cpu_dcache_clean_and_invalidate(void *addr, rt_size_t size);
38 
39 #endif /* __CACHE_H__ */
40