tlb.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-12-12 WangXiaoyao the first version
  9. */
  10. #ifndef __TLB_H__
  11. #define __TLB_H__
  12. #include "mm_aspace.h"
  13. #include <rtthread.h>
  14. #include <stddef.h>
  15. #include <stdint.h>
  16. #define dsb(scope) __asm__ volatile("dsb " #scope : : : "memory")
  17. #define isb() __asm__ volatile("isb" : : : "memory")
  18. #define STORE_CP32(r, name...) "mcr " RT_STRINGIFY(CP32(%r, name)) ";"
  19. #define WRITE_CP32(v, name...) do { \
  20. register uint32_t _r = (v); \
  21. asm volatile(STORE_CP32(0, name) : : "r" (_r)); \
  22. } while (0)
  23. static inline void rt_hw_tlb_invalidate_all(void)
  24. {
  25. asm volatile ("mcr p15, 0, r0, c8, c7, 0\ndsb\nisb" ::: "memory");
  26. }
  27. static inline void rt_hw_tlb_invalidate_all_local(void)
  28. {
  29. rt_hw_tlb_invalidate_all();
  30. }
  31. static inline void rt_hw_tlb_invalidate_aspace(rt_aspace_t aspace)
  32. {
  33. rt_hw_tlb_invalidate_all();
  34. }
  35. static inline void rt_hw_tlb_invalidate_range(rt_aspace_t aspace, void *start,
  36. size_t size, size_t stride)
  37. {
  38. rt_hw_tlb_invalidate_all();
  39. }
  40. #endif /* __TLB_H__ */