cache.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #include <rtdef.h>
  13. /**
  14. * @brief These APIs may not be supported by a specified architecture
  15. * But we have to include to all the cases to be 'general purpose'
  16. */
  17. rt_always_inline void rt_hw_cpu_dcache_clean_local(void *addr, int size)
  18. {
  19. RT_UNUSED(addr);
  20. RT_UNUSED(size);
  21. }
  22. rt_always_inline void rt_hw_cpu_dcache_invalidate_local(void *addr, int size)
  23. {
  24. RT_UNUSED(addr);
  25. RT_UNUSED(size);
  26. }
  27. rt_always_inline void rt_hw_cpu_dcache_clean_and_invalidate_local(void *addr, int size)
  28. {
  29. RT_UNUSED(addr);
  30. RT_UNUSED(size);
  31. }
  32. rt_always_inline void rt_hw_cpu_dcache_clean_all_local(void)
  33. {
  34. }
  35. rt_always_inline void rt_hw_cpu_dcache_invalidate_all_local(void)
  36. {
  37. }
  38. rt_always_inline void rt_hw_cpu_dcache_clean_and_invalidate_all_local(void)
  39. {
  40. }
  41. rt_always_inline void rt_hw_cpu_icache_invalidate_local(void *addr, int size)
  42. {
  43. RT_UNUSED(addr);
  44. RT_UNUSED(size);
  45. }
  46. rt_always_inline void rt_hw_cpu_icache_invalidate_all_local(void)
  47. {
  48. }
  49. /**
  50. * @brief Multi-core
  51. */
  52. #define rt_hw_cpu_dcache_clean rt_hw_cpu_dcache_clean_local
  53. #define rt_hw_cpu_dcache_invalidate rt_hw_cpu_dcache_invalidate_local
  54. #define rt_hw_cpu_dcache_clean_and_invalidate rt_hw_cpu_dcache_clean_and_invalidate_local
  55. #define rt_hw_cpu_dcache_clean_all rt_hw_cpu_dcache_clean_all_local
  56. #define rt_hw_cpu_dcache_invalidate_all rt_hw_cpu_dcache_invalidate_all_local
  57. #define rt_hw_cpu_dcache_clean_and_invalidate_all rt_hw_cpu_dcache_clean_and_invalidate_all_local
  58. #define rt_hw_cpu_icache_invalidate rt_hw_cpu_icache_invalidate_local
  59. #define rt_hw_cpu_icache_invalidate_all rt_hw_cpu_icache_invalidate_all_local
  60. #define rt_hw_icache_invalidate_all rt_hw_cpu_icache_invalidate_all
  61. /** instruction barrier */
  62. static inline void rt_hw_cpu_sync(void) {}
  63. /**
  64. * @brief local cpu icahce & dcache synchronization
  65. *
  66. * @param addr
  67. * @param size
  68. */
  69. void rt_hw_sync_cache_local(void *addr, int size);
  70. #endif /* __CACHE_H__ */