drv_cache.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * File : drv_cache.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2018-05-17 ZYH first implementation
  23. */
  24. #include <rthw.h>
  25. #include <stm32f7xx.h>
  26. void rt_hw_cpu_icache_enable(void)
  27. {
  28. SCB_EnableICache();
  29. }
  30. void rt_hw_cpu_icache_disable(void)
  31. {
  32. SCB_DisableICache();
  33. }
  34. rt_base_t rt_hw_cpu_icache_status(void)
  35. {
  36. return 0;
  37. }
  38. void rt_hw_cpu_icache_ops(int ops, void *addr, int size)
  39. {
  40. UNUSED(addr);
  41. UNUSED(size);
  42. if (ops & RT_HW_CACHE_INVALIDATE)
  43. {
  44. SCB_InvalidateICache();
  45. }
  46. }
  47. void rt_hw_cpu_dcache_enable(void)
  48. {
  49. SCB_EnableDCache();
  50. }
  51. void rt_hw_cpu_dcache_disable(void)
  52. {
  53. SCB_DisableDCache();
  54. }
  55. rt_base_t rt_hw_cpu_dcache_status(void)
  56. {
  57. return 0;
  58. }
  59. void rt_hw_cpu_dcache_ops(int ops, void *addr, int size)
  60. {
  61. if (ops & (RT_HW_CACHE_FLUSH | RT_HW_CACHE_INVALIDATE))
  62. {
  63. SCB_CleanInvalidateDCache_by_Addr(addr, size);
  64. }
  65. else if (ops & RT_HW_CACHE_FLUSH)
  66. {
  67. SCB_CleanDCache_by_Addr(addr, size);
  68. }
  69. else if (ops & RT_HW_CACHE_INVALIDATE)
  70. {
  71. SCB_InvalidateDCache_by_Addr(addr, size);
  72. }
  73. else
  74. {
  75. RT_ASSERT(0);
  76. }
  77. }