mmu.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * File : mmu.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, 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. */
  23. #ifndef __MMU_H__
  24. #define __MMU_H__
  25. #include <rtthread.h>
  26. #define CACHE_LINE_SIZE 32
  27. #define DESC_SEC (0x2|(1<<4))
  28. #define CB (3<<2) //cache_on, write_back
  29. #define CNB (2<<2) //cache_on, write_through
  30. #define NCB (1<<2) //cache_off,WR_BUF on
  31. #define NCNB (0<<2) //cache_off,WR_BUF off
  32. #define AP_RW (3<<10) //supervisor=RW, user=RW
  33. #define AP_RO (2<<10) //supervisor=RW, user=RO
  34. #define DOMAIN_FAULT (0x0)
  35. #define DOMAIN_CHK (0x1)
  36. #define DOMAIN_NOTCHK (0x3)
  37. #define DOMAIN0 (0x0<<5)
  38. #define DOMAIN1 (0x1<<5)
  39. #define DOMAIN0_ATTR (DOMAIN_CHK<<0)
  40. #define DOMAIN1_ATTR (DOMAIN_FAULT<<2)
  41. #define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC) /* Read/Write, cache, write back */
  42. #define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC) /* Read/Write, cache, write through */
  43. #define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */
  44. #define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC) /* Read/Write without cache and write buffer */
  45. #define ARM1176_1MB_NOCACHE_BUFFER 0x00000DE6 // non-cachable/bufferable
  46. #define ARM1176_1MB_CACHE_NOBUFFER 0x00000DEA // cachable/non-bufferable
  47. #define ARM1176_1MB_CACHE_BUFFER 0x00000DEE // cachable/bufferable
  48. #define ARM1176_1MB_NOCACHE_NOBUFFER 0x00000DE2 // non-cachable/non-bufferable
  49. #define ARM1176_1MB_NORMAL_NOCACHE 0x00001DE2 // Normal memory, non-cachable/non-bufferable
  50. #define ARM1176_1MB_CACHE_BUFFER_RO 0x000011EE // cachable/bufferable read-only
  51. #define ARM1176_1MB_NOCACHE_NOBUFFER_RO 0x000011E2 // non-cachable/non-bufferable read-only
  52. struct mem_desc {
  53. rt_uint32_t vaddr_start;
  54. rt_uint32_t vaddr_end;
  55. rt_uint32_t paddr_start;
  56. rt_uint32_t attr;
  57. };
  58. void rt_hw_mmu_init(struct mem_desc *mdesc, rt_uint32_t size);
  59. void rt_hw_cpu_dump_page_table(rt_uint32_t *ptb);
  60. #endif