cache.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-11-09 RT-Thread The first version
  9. */
  10. #ifndef __CACHE_H__
  11. #define __CACHE_H__
  12. #ifndef ALWAYS_INLINE
  13. #define ALWAYS_INLINE inline __attribute__((always_inline))
  14. #endif
  15. /**
  16. * @brief These APIs may not be supported by a specified architecture
  17. * But we have to include to all the cases to be 'general purpose'
  18. */
  19. ALWAYS_INLINE void rt_hw_cpu_dcache_clean_local(void *addr, int size) {}
  20. ALWAYS_INLINE void rt_hw_cpu_dcache_invalidate_local(void *addr, int size) {}
  21. ALWAYS_INLINE void rt_hw_cpu_dcache_clean_and_invalidate_local(void *addr, int size) {}
  22. ALWAYS_INLINE void rt_hw_cpu_dcache_clean_all_local() {}
  23. ALWAYS_INLINE void rt_hw_cpu_dcache_invalidate_all_local(void) {}
  24. ALWAYS_INLINE void rt_hw_cpu_dcache_clean_and_invalidate_all_local(void) {}
  25. ALWAYS_INLINE void rt_hw_cpu_icache_invalidate_local(void *addr, int size) {}
  26. ALWAYS_INLINE void rt_hw_cpu_icache_invalidate_all_local() {}
  27. /**
  28. * @brief Multi-core
  29. */
  30. #define rt_hw_cpu_dcache_clean rt_hw_cpu_dcache_clean_local
  31. #define rt_hw_cpu_dcache_invalidate rt_hw_cpu_dcache_invalidate_local
  32. #define rt_hw_cpu_dcache_clean_and_invalidate rt_hw_cpu_dcache_clean_and_invalidate_local
  33. #define rt_hw_cpu_dcache_clean_all rt_hw_cpu_dcache_clean_all_local
  34. #define rt_hw_cpu_dcache_invalidate_all rt_hw_cpu_dcache_invalidate_all_local
  35. #define rt_hw_cpu_dcache_clean_and_invalidate_all rt_hw_cpu_dcache_clean_and_invalidate_all_local
  36. #define rt_hw_cpu_icache_invalidate rt_hw_cpu_icache_invalidate_local
  37. #define rt_hw_cpu_icache_invalidate_all rt_hw_cpu_icache_invalidate_all_local
  38. #define rt_hw_icache_invalidate_all rt_hw_cpu_icache_invalidate_all
  39. /** instruction barrier */
  40. static inline void rt_hw_cpu_sync(void) {}
  41. /**
  42. * @brief local cpu icahce & dcache synchronization
  43. *
  44. * @param addr
  45. * @param size
  46. */
  47. void rt_hw_sync_cache_local(void *addr, int size);
  48. #endif /* __CACHE_H__ */