mmu.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio.
  3. This file is part of ChibiOS.
  4. ChibiOS is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. ChibiOS is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. /**
  16. * @file mmu.h
  17. * @brief MMU macros and structures.
  18. *
  19. * @addtogroup MMU
  20. * @{
  21. */
  22. #ifndef MMU_H
  23. #define MMU_H
  24. /*===========================================================================*/
  25. /* Module constants. */
  26. /*===========================================================================*/
  27. #define DCISW_INVALIDATE 0
  28. #define DCISW_CLEAN 1
  29. #define DCISW_CLEAN_AND_INV 2
  30. /*===========================================================================*/
  31. /* Module pre-compile time settings. */
  32. /*===========================================================================*/
  33. /*===========================================================================*/
  34. /* Derived constants and error checks. */
  35. /*===========================================================================*/
  36. /*===========================================================================*/
  37. /* Module data structures and types. */
  38. /*===========================================================================*/
  39. /*===========================================================================*/
  40. /* Module macros. */
  41. /*===========================================================================*/
  42. /*
  43. * Translation Table Entry descriptor macros
  44. *
  45. * Type Section layout:
  46. * +---------+--+-+--+-+-----+--------+-------+-+------+--+-+-+-+---+
  47. * |3 2|1 |1|1 |1|1 |1 1|1 1| | | | | | | |
  48. * |1 0|9 |8|7 |6|5 |4 2|1 0|9|8 5|4 |3|2|1|0 |
  49. * +---------+--+-+--+-+-----+--------+-------+-+------+--+-+-+-+---+
  50. * | section |NS|0|nG|S|AP[2]|TEX[2:0]|AP[1:0]| |domain|XN|C|B|1|PXN|
  51. * +---------+--+-+--+-+-----+--------+-------+-+------+--+-+-+-+---+
  52. *
  53. */
  54. #define TTE_TYPE_SECT (0x01 << 1)
  55. #define TTE_SECT_B (0x01 << 2)
  56. #define TTE_SECT_C (0x01 << 3)
  57. #define TTE_SECT_XN (0x01 << 4)
  58. #define TTE_SECT_DOM(x) ((x) << 5)
  59. #define TTE_SECT_AP0 (0x01 << 10)
  60. #define TTE_SECT_AP1 (0x01 << 11)
  61. #define TTE_SECT_TEX(x) ((x) << 12)
  62. #define TTE_SECT_AP2 (0x01 << 15)
  63. #define TTE_SECT_S (0x01 << 16)
  64. #define TTE_SECT_NG (0x01 << 17)
  65. #define TTE_SECT_NS (0x01 << 19)
  66. #define TTE_SECT_MEM_CACHEABLE (TTE_SECT_TEX(0b111)|TTE_SECT_B|TTE_SECT_C)
  67. #define TTE_SECT_MEM_NO_CACHEABLE (TTE_SECT_TEX(0b100))
  68. #define TTE_SECT_MEM_STRONGLY_ORD (TTE_SECT_TEX(0b000))
  69. #define TTE_SECT_DEVICE (TTE_SECT_B)
  70. #define TTE_SECT_EXE_NEVER (TTE_SECT_XN)
  71. #define TTE_SECT_RW_ACCESS (TTE_SECT_AP1|TTE_SECT_AP0)
  72. #define TTE_SECT_RO_ACCESS (TTE_SECT_AP1)
  73. #define TTE_SECT_UNDEF (0)
  74. #define TTE_SECT_SECTION(addr) ((addr) & 0xFFF00000)
  75. /*===========================================================================*/
  76. /* External declarations. */
  77. /*===========================================================================*/
  78. #ifdef __cplusplus
  79. extern "C" {
  80. #endif
  81. void __mmu_init(void);
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. /*===========================================================================*/
  86. /* Module inline functions. */
  87. /*===========================================================================*/
  88. #endif /* MMU_H */
  89. /** @} */