mpu.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //*****************************************************************************
  2. //
  3. // mpu.h - Defines and Macros for the memory protection unit.
  4. //
  5. // Copyright (c) 2005-2014 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions
  10. // are met:
  11. //
  12. // Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. //
  15. // Redistributions in binary form must reproduce the above copyright
  16. // notice, this list of conditions and the following disclaimer in the
  17. // documentation and/or other materials provided with the
  18. // distribution.
  19. //
  20. // Neither the name of Texas Instruments Incorporated nor the names of
  21. // its contributors may be used to endorse or promote products derived
  22. // from this software without specific prior written permission.
  23. //
  24. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
  37. //
  38. //*****************************************************************************
  39. #ifndef __DRIVERLIB_MPU_H__
  40. #define __DRIVERLIB_MPU_H__
  41. //*****************************************************************************
  42. //
  43. // If building with a C++ compiler, make all of the definitions in this header
  44. // have a C binding.
  45. //
  46. //*****************************************************************************
  47. #ifdef __cplusplus
  48. extern "C"
  49. {
  50. #endif
  51. //*****************************************************************************
  52. //
  53. // Flags that can be passed to MPUEnable.
  54. //
  55. //*****************************************************************************
  56. #define MPU_CONFIG_PRIV_DEFAULT 4
  57. #define MPU_CONFIG_HARDFLT_NMI 2
  58. #define MPU_CONFIG_NONE 0
  59. //*****************************************************************************
  60. //
  61. // Flags for the region size to be passed to MPURegionSet.
  62. //
  63. //*****************************************************************************
  64. #define MPU_RGN_SIZE_32B (4 << 1)
  65. #define MPU_RGN_SIZE_64B (5 << 1)
  66. #define MPU_RGN_SIZE_128B (6 << 1)
  67. #define MPU_RGN_SIZE_256B (7 << 1)
  68. #define MPU_RGN_SIZE_512B (8 << 1)
  69. #define MPU_RGN_SIZE_1K (9 << 1)
  70. #define MPU_RGN_SIZE_2K (10 << 1)
  71. #define MPU_RGN_SIZE_4K (11 << 1)
  72. #define MPU_RGN_SIZE_8K (12 << 1)
  73. #define MPU_RGN_SIZE_16K (13 << 1)
  74. #define MPU_RGN_SIZE_32K (14 << 1)
  75. #define MPU_RGN_SIZE_64K (15 << 1)
  76. #define MPU_RGN_SIZE_128K (16 << 1)
  77. #define MPU_RGN_SIZE_256K (17 << 1)
  78. #define MPU_RGN_SIZE_512K (18 << 1)
  79. #define MPU_RGN_SIZE_1M (19 << 1)
  80. #define MPU_RGN_SIZE_2M (20 << 1)
  81. #define MPU_RGN_SIZE_4M (21 << 1)
  82. #define MPU_RGN_SIZE_8M (22 << 1)
  83. #define MPU_RGN_SIZE_16M (23 << 1)
  84. #define MPU_RGN_SIZE_32M (24 << 1)
  85. #define MPU_RGN_SIZE_64M (25 << 1)
  86. #define MPU_RGN_SIZE_128M (26 << 1)
  87. #define MPU_RGN_SIZE_256M (27 << 1)
  88. #define MPU_RGN_SIZE_512M (28 << 1)
  89. #define MPU_RGN_SIZE_1G (29 << 1)
  90. #define MPU_RGN_SIZE_2G (30 << 1)
  91. #define MPU_RGN_SIZE_4G (31 << 1)
  92. //*****************************************************************************
  93. //
  94. // Flags for the permissions to be passed to MPURegionSet.
  95. //
  96. //*****************************************************************************
  97. #define MPU_RGN_PERM_EXEC 0x00000000
  98. #define MPU_RGN_PERM_NOEXEC 0x10000000
  99. #define MPU_RGN_PERM_PRV_NO_USR_NO 0x00000000
  100. #define MPU_RGN_PERM_PRV_RW_USR_NO 0x01000000
  101. #define MPU_RGN_PERM_PRV_RW_USR_RO 0x02000000
  102. #define MPU_RGN_PERM_PRV_RW_USR_RW 0x03000000
  103. #define MPU_RGN_PERM_PRV_RO_USR_NO 0x05000000
  104. #define MPU_RGN_PERM_PRV_RO_USR_RO 0x06000000
  105. //*****************************************************************************
  106. //
  107. // Flags for the sub-region to be passed to MPURegionSet.
  108. //
  109. //*****************************************************************************
  110. #define MPU_SUB_RGN_DISABLE_0 0x00000100
  111. #define MPU_SUB_RGN_DISABLE_1 0x00000200
  112. #define MPU_SUB_RGN_DISABLE_2 0x00000400
  113. #define MPU_SUB_RGN_DISABLE_3 0x00000800
  114. #define MPU_SUB_RGN_DISABLE_4 0x00001000
  115. #define MPU_SUB_RGN_DISABLE_5 0x00002000
  116. #define MPU_SUB_RGN_DISABLE_6 0x00004000
  117. #define MPU_SUB_RGN_DISABLE_7 0x00008000
  118. //*****************************************************************************
  119. //
  120. // Flags to enable or disable a region, to be passed to MPURegionSet.
  121. //
  122. //*****************************************************************************
  123. #define MPU_RGN_ENABLE 1
  124. #define MPU_RGN_DISABLE 0
  125. //*****************************************************************************
  126. //
  127. // API Function prototypes
  128. //
  129. //*****************************************************************************
  130. extern void MPUEnable(uint32_t ui32MPUConfig);
  131. extern void MPUDisable(void);
  132. extern uint32_t MPURegionCountGet(void);
  133. extern void MPURegionEnable(uint32_t ui32Region);
  134. extern void MPURegionDisable(uint32_t ui32Region);
  135. extern void MPURegionSet(uint32_t ui32Region, uint32_t ui32Addr,
  136. uint32_t ui32Flags);
  137. extern void MPURegionGet(uint32_t ui32Region, uint32_t *pui32Addr,
  138. uint32_t *pui32Flags);
  139. extern void MPUIntRegister(void (*pfnHandler)(void));
  140. extern void MPUIntUnregister(void);
  141. //*****************************************************************************
  142. //
  143. // Mark the end of the C bindings section for C++ compilers.
  144. //
  145. //*****************************************************************************
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif // __DRIVERLIB_MPU_H__