cache_ops.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-03-29 quanzhao the first version
  9. */
  10. #include <rthw.h>
  11. #include <rtdef.h>
  12. void __asm_invalidate_icache_all(void);
  13. void __asm_flush_dcache_all(void);
  14. void __asm_flush_dcache_range(rt_size_t start, rt_size_t end);
  15. void __asm_invalidate_dcache_range(rt_size_t start, rt_size_t end);
  16. void __asm_invalidate_icache_range(rt_size_t start, rt_size_t end);
  17. void __asm_invalidate_dcache_all(void);
  18. void __asm_invalidate_icache_all(void);
  19. rt_inline rt_uint32_t rt_cpu_icache_line_size(void)
  20. {
  21. return 0;
  22. }
  23. rt_inline rt_uint32_t rt_cpu_dcache_line_size(void)
  24. {
  25. return 0;
  26. }
  27. void rt_hw_cpu_icache_invalidate(void *addr, rt_size_t size)
  28. {
  29. __asm_invalidate_icache_range((rt_size_t)addr, (rt_size_t)addr + size);
  30. }
  31. void rt_hw_cpu_dcache_invalidate(void *addr, rt_size_t size)
  32. {
  33. __asm_invalidate_dcache_range((rt_size_t)addr, (rt_size_t)addr + size);
  34. }
  35. void rt_hw_cpu_dcache_clean(void *addr, rt_size_t size)
  36. {
  37. __asm_flush_dcache_range((rt_size_t)addr, (rt_size_t)addr + size);
  38. }
  39. void rt_hw_cpu_dcache_clean_and_invalidate(void *addr, rt_size_t size)
  40. {
  41. __asm_flush_dcache_range((rt_size_t)addr, (rt_size_t)addr + size);
  42. }
  43. void rt_hw_cpu_icache_ops(int ops, void *addr, int size)
  44. {
  45. if (ops == RT_HW_CACHE_INVALIDATE)
  46. {
  47. rt_hw_cpu_icache_invalidate(addr, size);
  48. }
  49. }
  50. void rt_hw_cpu_dcache_ops(int ops, void *addr, int size)
  51. {
  52. if (ops == RT_HW_CACHE_FLUSH)
  53. {
  54. rt_hw_cpu_dcache_clean(addr, size);
  55. }
  56. else if (ops == RT_HW_CACHE_INVALIDATE)
  57. {
  58. rt_hw_cpu_dcache_invalidate(addr, size);
  59. }
  60. }
  61. rt_base_t rt_hw_cpu_icache_status(void)
  62. {
  63. return 0;
  64. }
  65. rt_base_t rt_hw_cpu_dcache_status(void)
  66. {
  67. return 0;
  68. }