mmu.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. */
  9. #ifndef __MMU_H__
  10. #define __MMU_H__
  11. #include <rtthread.h>
  12. #define CACHE_LINE_SIZE 32
  13. #define DESC_SEC (0x2|(1<<4))
  14. #define CB (3<<2) //cache_on, write_back
  15. #define CNB (2<<2) //cache_on, write_through
  16. #define NCB (1<<2) //cache_off,WR_BUF on
  17. #define NCNB (0<<2) //cache_off,WR_BUF off
  18. #define AP_RW (3<<10) //supervisor=RW, user=RW
  19. #define AP_RO (2<<10) //supervisor=RW, user=RO
  20. #define DOMAIN_FAULT (0x0)
  21. #define DOMAIN_CHK (0x1)
  22. #define DOMAIN_NOTCHK (0x3)
  23. #define DOMAIN0 (0x0<<5)
  24. #define DOMAIN1 (0x1<<5)
  25. #define DOMAIN0_ATTR (DOMAIN_CHK<<0)
  26. #define DOMAIN1_ATTR (DOMAIN_FAULT<<2)
  27. #define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC) /* Read/Write, cache, write back */
  28. #define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC) /* Read/Write, cache, write through */
  29. #define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */
  30. #define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */
  31. struct mem_desc
  32. {
  33. rt_uint32_t vaddr_start;
  34. rt_uint32_t vaddr_end;
  35. rt_uint32_t paddr_start;
  36. rt_uint32_t attr;
  37. };
  38. void rt_hw_mmu_init(struct mem_desc *mdesc, rt_uint32_t size);
  39. #endif