drv_cache.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * File : drv_cache.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2018-04-02 tanek first implementation
  13. */
  14. #include <rtthread.h>
  15. #include <rthw.h>
  16. #include <fsl_cache.h>
  17. void rt_hw_cpu_icache_enable(void)
  18. {
  19. SCB_EnableICache();
  20. }
  21. void rt_hw_cpu_icache_disable(void)
  22. {
  23. SCB_DisableICache();
  24. }
  25. rt_base_t rt_hw_cpu_icache_status(void)
  26. {
  27. return 0;
  28. }
  29. void rt_hw_cpu_icache_ops(int ops, void* addr, int size)
  30. {
  31. if (ops & RT_HW_CACHE_INVALIDATE)
  32. {
  33. ICACHE_InvalidateByRange((uint32_t)addr, size);
  34. }
  35. }
  36. void rt_hw_cpu_dcache_enable(void)
  37. {
  38. SCB_EnableDCache();
  39. }
  40. void rt_hw_cpu_dcache_disable(void)
  41. {
  42. SCB_DisableDCache();
  43. }
  44. rt_base_t rt_hw_cpu_dcache_status(void)
  45. {
  46. return 0;
  47. }
  48. void rt_hw_cpu_dcache_ops(int ops, void* addr, int size)
  49. {
  50. if (ops & (RT_HW_CACHE_FLUSH | RT_HW_CACHE_INVALIDATE))
  51. {
  52. DCACHE_CleanInvalidateByRange((uint32_t)addr, size);
  53. }
  54. else if (ops & RT_HW_CACHE_FLUSH)
  55. {
  56. DCACHE_CleanByRange((uint32_t)addr, size);
  57. }
  58. else if (ops & RT_HW_CACHE_INVALIDATE)
  59. {
  60. DCACHE_InvalidateByRange((uint32_t)addr, size);
  61. }
  62. else
  63. {
  64. RT_ASSERT(0);
  65. }
  66. }