mmu.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. * 2020-01-15 bigmagic the first version
  9. */
  10. #ifndef MMU_H__
  11. #define MMU_H__
  12. #include <rtthread.h>
  13. #include <rthw.h>
  14. #include <board.h>
  15. #include "cp15.h"
  16. #define DESC_SEC (0x2)
  17. #define CB (3<<2) //cache_on, write_back
  18. #define CNB (2<<2) //cache_on, write_through
  19. #define NCB (1<<2) //cache_off,WR_BUF on
  20. #define NCNB (0<<2) //cache_off,WR_BUF off
  21. #define AP_RW (3<<10) //supervisor=RW, user=RW
  22. #define AP_RO (2<<10) //supervisor=RW, user=RO
  23. #define XN (1<<4) // eXecute Never
  24. #define SHARED (1<<16) /* shareable */
  25. #define SHAREDEVICE (1<<2) /* shared device */
  26. #define STRONGORDER (0<<2) /* strong ordered */
  27. #define MEMWBWA ((1<<12)|(3<<2)) /* write back, write allocate */
  28. #define DOMAIN_FAULT (0x0)
  29. #define DOMAIN_CHK (0x1)
  30. #define DOMAIN_NOTCHK (0x3)
  31. #define DOMAIN0 (0x0<<5)
  32. #define DOMAIN1 (0x1<<5)
  33. #define DOMAIN0_ATTR (DOMAIN_CHK<<0)
  34. #define DOMAIN1_ATTR (DOMAIN_FAULT<<2)
  35. /* Read/Write, cache, write back */
  36. #define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC)
  37. /* Read/Write, cache, write through */
  38. #define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC)
  39. /* Read/Write without cache and write buffer */
  40. #define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC)
  41. /* Read/Write without cache and write buffer, no execute */
  42. #define RW_NCNBXN (AP_RW|DOMAIN0|NCNB|DESC_SEC|XN)
  43. /* Read/Write without cache and write buffer */
  44. #define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC)
  45. /* device mapping type */
  46. #define DEVICE_MEM (SHARED|SHAREDEVICE|RW_NCNBXN)
  47. /* normal memory mapping type */
  48. #define NORMAL_MEM (SHARED|AP_RW|DOMAIN0|MEMWBWA|DESC_SEC)
  49. #define STRONG_ORDER_MEM (SHARED|AP_RO|XN|DESC_SEC)
  50. #define BUS_ADDRESS(phys) (((phys) & ~0xC0000000) | 0xC0000000)
  51. void rt_hw_change_mmu_table(rt_uint32_t vaddrStart,
  52. rt_uint32_t size,
  53. rt_uint32_t paddrStart, rt_uint32_t attr);
  54. #endif