mpu.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //*****************************************************************************
  2. //
  3. // mpu.h - Defines and Macros for the memory protection unit.
  4. //
  5. // Copyright (c) 2005-2011 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24. #ifndef __MPU_H__
  25. #define __MPU_H__
  26. //*****************************************************************************
  27. //
  28. // If building with a C++ compiler, make all of the definitions in this header
  29. // have a C binding.
  30. //
  31. //*****************************************************************************
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. //*****************************************************************************
  37. //
  38. // Flags that can be passed to MPUEnable.
  39. //
  40. //*****************************************************************************
  41. #define MPU_CONFIG_PRIV_DEFAULT 4
  42. #define MPU_CONFIG_HARDFLT_NMI 2
  43. #define MPU_CONFIG_NONE 0
  44. //*****************************************************************************
  45. //
  46. // Flags for the region size to be passed to MPURegionSet.
  47. //
  48. //*****************************************************************************
  49. #define MPU_RGN_SIZE_32B (4 << 1)
  50. #define MPU_RGN_SIZE_64B (5 << 1)
  51. #define MPU_RGN_SIZE_128B (6 << 1)
  52. #define MPU_RGN_SIZE_256B (7 << 1)
  53. #define MPU_RGN_SIZE_512B (8 << 1)
  54. #define MPU_RGN_SIZE_1K (9 << 1)
  55. #define MPU_RGN_SIZE_2K (10 << 1)
  56. #define MPU_RGN_SIZE_4K (11 << 1)
  57. #define MPU_RGN_SIZE_8K (12 << 1)
  58. #define MPU_RGN_SIZE_16K (13 << 1)
  59. #define MPU_RGN_SIZE_32K (14 << 1)
  60. #define MPU_RGN_SIZE_64K (15 << 1)
  61. #define MPU_RGN_SIZE_128K (16 << 1)
  62. #define MPU_RGN_SIZE_256K (17 << 1)
  63. #define MPU_RGN_SIZE_512K (18 << 1)
  64. #define MPU_RGN_SIZE_1M (19 << 1)
  65. #define MPU_RGN_SIZE_2M (20 << 1)
  66. #define MPU_RGN_SIZE_4M (21 << 1)
  67. #define MPU_RGN_SIZE_8M (22 << 1)
  68. #define MPU_RGN_SIZE_16M (23 << 1)
  69. #define MPU_RGN_SIZE_32M (24 << 1)
  70. #define MPU_RGN_SIZE_64M (25 << 1)
  71. #define MPU_RGN_SIZE_128M (26 << 1)
  72. #define MPU_RGN_SIZE_256M (27 << 1)
  73. #define MPU_RGN_SIZE_512M (28 << 1)
  74. #define MPU_RGN_SIZE_1G (29 << 1)
  75. #define MPU_RGN_SIZE_2G (30 << 1)
  76. #define MPU_RGN_SIZE_4G (31 << 1)
  77. //*****************************************************************************
  78. //
  79. // Flags for the permissions to be passed to MPURegionSet.
  80. //
  81. //*****************************************************************************
  82. #define MPU_RGN_PERM_EXEC 0x00000000
  83. #define MPU_RGN_PERM_NOEXEC 0x10000000
  84. #define MPU_RGN_PERM_PRV_NO_USR_NO 0x00000000
  85. #define MPU_RGN_PERM_PRV_RW_USR_NO 0x01000000
  86. #define MPU_RGN_PERM_PRV_RW_USR_RO 0x02000000
  87. #define MPU_RGN_PERM_PRV_RW_USR_RW 0x03000000
  88. #define MPU_RGN_PERM_PRV_RO_USR_NO 0x05000000
  89. #define MPU_RGN_PERM_PRV_RO_USR_RO 0x06000000
  90. //*****************************************************************************
  91. //
  92. // Flags for the sub-region to be passed to MPURegionSet.
  93. //
  94. //*****************************************************************************
  95. #define MPU_SUB_RGN_DISABLE_0 0x00000100
  96. #define MPU_SUB_RGN_DISABLE_1 0x00000200
  97. #define MPU_SUB_RGN_DISABLE_2 0x00000400
  98. #define MPU_SUB_RGN_DISABLE_3 0x00000800
  99. #define MPU_SUB_RGN_DISABLE_4 0x00001000
  100. #define MPU_SUB_RGN_DISABLE_5 0x00002000
  101. #define MPU_SUB_RGN_DISABLE_6 0x00004000
  102. #define MPU_SUB_RGN_DISABLE_7 0x00008000
  103. //*****************************************************************************
  104. //
  105. // Flags to enable or disable a region, to be passed to MPURegionSet.
  106. //
  107. //*****************************************************************************
  108. #define MPU_RGN_ENABLE 1
  109. #define MPU_RGN_DISABLE 0
  110. //*****************************************************************************
  111. //
  112. // API Function prototypes
  113. //
  114. //*****************************************************************************
  115. extern void MPUEnable(unsigned long ulMPUConfig);
  116. extern void MPUDisable(void);
  117. extern unsigned long MPURegionCountGet(void);
  118. extern void MPURegionEnable(unsigned long ulRegion);
  119. extern void MPURegionDisable(unsigned long ulRegion);
  120. extern void MPURegionSet(unsigned long ulRegion, unsigned long ulAddr,
  121. unsigned long ulFlags);
  122. extern void MPURegionGet(unsigned long ulRegion, unsigned long *pulAddr,
  123. unsigned long *pulFlags);
  124. extern void MPUIntRegister(void (*pfnHandler)(void));
  125. extern void MPUIntUnregister(void);
  126. //*****************************************************************************
  127. //
  128. // Mark the end of the C bindings section for C++ compilers.
  129. //
  130. //*****************************************************************************
  131. #ifdef __cplusplus
  132. }
  133. #endif
  134. #endif // __MPU_H__