1
0

mpu.h 6.1 KB

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