mem_cache.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (c) 2020 Actions Technology Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef ZEPHYR_FRAMEWORK_INCLUDE_MEMORY_MEM_CACHE_H_
  7. #define ZEPHYR_FRAMEWORK_INCLUDE_MEMORY_MEM_CACHE_H_
  8. #include <stdint.h>
  9. #include <stdbool.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief Invalidate memory dcache
  15. *
  16. * @note This function is asynchronous. Call mem_dcache_sync() to synchronize.
  17. *
  18. * @param addr memory base address
  19. * @param length memory length
  20. *
  21. * @retval N/A
  22. */
  23. void mem_dcache_invalidate(const void *addr, uint32_t length);
  24. /**
  25. * @brief Invalidate all memory dcache
  26. *
  27. * @note This function is asynchronous. Call mem_dcache_sync() to synchronize.
  28. *
  29. * @retval N/A
  30. */
  31. void mem_dcache_invalidate_all(void);
  32. /**
  33. * @brief Clean memory dcache
  34. *
  35. * @note This function is asynchronous. Call mem_dcache_sync() to synchronize.
  36. *
  37. * @param addr memory base address
  38. * @param length memory length
  39. *
  40. * @retval N/A
  41. */
  42. void mem_dcache_clean(const void *addr, uint32_t length);
  43. /**
  44. * @brief Clean all memory dcache
  45. *
  46. * @note This function is asynchronous. Call mem_dcache_sync() to synchronize.
  47. *
  48. * @retval N/A
  49. */
  50. void mem_dcache_clean_all(void);
  51. /**
  52. * @brief Flush (clean, then invalidate) memory dcache
  53. *
  54. * @note This function is asynchronous. Call mem_dcache_sync() to synchronize.
  55. *
  56. * @param addr memory base address
  57. * @param length memory length
  58. *
  59. * @retval N/A
  60. */
  61. void mem_dcache_flush(const void *addr, uint32_t length);
  62. /**
  63. * @brief Flush (clean, then invalidate) all memory dcache
  64. *
  65. * @note This function is asynchronous. Call mem_dcache_sync() to synchronize.
  66. *
  67. * @retval N/A
  68. */
  69. void mem_dcache_flush_all(void);
  70. /**
  71. * @brief Synchronize the dcache ops, that is, wait until all the dcache ops finished
  72. *
  73. * @retval N/A
  74. */
  75. void mem_dcache_sync(void);
  76. /**
  77. * @brief Synchronize the dcache ops, that is, wait until all the dcache ops finished
  78. *
  79. * @retval N/A
  80. */
  81. void * mem_addr_to_uncache(void * addr);
  82. /**
  83. * @brief Query whether any part of memory is cacheable
  84. *
  85. * @param addr memory base address
  86. * @param length memory length
  87. *
  88. * @retval query result
  89. */
  90. bool mem_is_cacheable(const void *addr);
  91. /**
  92. * @brief Clean the memory write buffer
  93. *
  94. * @retval N/A
  95. */
  96. void mem_writebuf_clean(const void *addr, uint32_t length);
  97. /**
  98. * @brief Clean all memory write buffer
  99. *
  100. * @param addr memory base address
  101. * @param length memory length
  102. *
  103. * @retval N/A
  104. */
  105. void mem_writebuf_clean_all(void);
  106. /**
  107. * @brief Query whether any part of memory is bufferable
  108. *
  109. * @param addr memory base address
  110. * @param length memory length
  111. *
  112. * @retval query result
  113. */
  114. bool mem_is_bufferable(const void *addr);
  115. #ifdef __cplusplus
  116. }
  117. #endif
  118. #endif /* ZEPHYR_FRAMEWORK_INCLUDE_MEMORY_MEM_CACHE_H_ */