mmu.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. struct mem_desc {
  46. rt_uint32_t vaddr_start;
  47. rt_uint32_t vaddr_end;
  48. rt_uint32_t paddr_start;
  49. rt_uint32_t attr;
  50. };
  51. void rt_hw_mmu_init(struct mem_desc *mdesc, rt_uint32_t size);
  52. #endif