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 25 #ifndef __MPU_H__ 26 #define __MPU_H__ 27 28 //***************************************************************************** 29 // 30 // If building with a C++ compiler, make all of the definitions in this header 31 // have a C binding. 32 // 33 //***************************************************************************** 34 #ifdef __cplusplus 35 extern "C" 36 { 37 #endif 38 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 // 50 // Flags for the region size to be passed to MPURegionSet. 51 // 52 //***************************************************************************** 53 #define MPU_RGN_SIZE_32B (4 << 1) 54 #define MPU_RGN_SIZE_64B (5 << 1) 55 #define MPU_RGN_SIZE_128B (6 << 1) 56 #define MPU_RGN_SIZE_256B (7 << 1) 57 #define MPU_RGN_SIZE_512B (8 << 1) 58 59 #define MPU_RGN_SIZE_1K (9 << 1) 60 #define MPU_RGN_SIZE_2K (10 << 1) 61 #define MPU_RGN_SIZE_4K (11 << 1) 62 #define MPU_RGN_SIZE_8K (12 << 1) 63 #define MPU_RGN_SIZE_16K (13 << 1) 64 #define MPU_RGN_SIZE_32K (14 << 1) 65 #define MPU_RGN_SIZE_64K (15 << 1) 66 #define MPU_RGN_SIZE_128K (16 << 1) 67 #define MPU_RGN_SIZE_256K (17 << 1) 68 #define MPU_RGN_SIZE_512K (18 << 1) 69 70 #define MPU_RGN_SIZE_1M (19 << 1) 71 #define MPU_RGN_SIZE_2M (20 << 1) 72 #define MPU_RGN_SIZE_4M (21 << 1) 73 #define MPU_RGN_SIZE_8M (22 << 1) 74 #define MPU_RGN_SIZE_16M (23 << 1) 75 #define MPU_RGN_SIZE_32M (24 << 1) 76 #define MPU_RGN_SIZE_64M (25 << 1) 77 #define MPU_RGN_SIZE_128M (26 << 1) 78 #define MPU_RGN_SIZE_256M (27 << 1) 79 #define MPU_RGN_SIZE_512M (28 << 1) 80 81 #define MPU_RGN_SIZE_1G (29 << 1) 82 #define MPU_RGN_SIZE_2G (30 << 1) 83 #define MPU_RGN_SIZE_4G (31 << 1) 84 85 //***************************************************************************** 86 // 87 // Flags for the permissions to be passed to MPURegionSet. 88 // 89 //***************************************************************************** 90 #define MPU_RGN_PERM_EXEC 0x00000000 91 #define MPU_RGN_PERM_NOEXEC 0x10000000 92 #define MPU_RGN_PERM_PRV_NO_USR_NO 0x00000000 93 #define MPU_RGN_PERM_PRV_RW_USR_NO 0x01000000 94 #define MPU_RGN_PERM_PRV_RW_USR_RO 0x02000000 95 #define MPU_RGN_PERM_PRV_RW_USR_RW 0x03000000 96 #define MPU_RGN_PERM_PRV_RO_USR_NO 0x05000000 97 #define MPU_RGN_PERM_PRV_RO_USR_RO 0x06000000 98 99 //***************************************************************************** 100 // 101 // Flags for the sub-region to be passed to MPURegionSet. 102 // 103 //***************************************************************************** 104 #define MPU_SUB_RGN_DISABLE_0 0x00000100 105 #define MPU_SUB_RGN_DISABLE_1 0x00000200 106 #define MPU_SUB_RGN_DISABLE_2 0x00000400 107 #define MPU_SUB_RGN_DISABLE_3 0x00000800 108 #define MPU_SUB_RGN_DISABLE_4 0x00001000 109 #define MPU_SUB_RGN_DISABLE_5 0x00002000 110 #define MPU_SUB_RGN_DISABLE_6 0x00004000 111 #define MPU_SUB_RGN_DISABLE_7 0x00008000 112 113 //***************************************************************************** 114 // 115 // Flags to enable or disable a region, to be passed to MPURegionSet. 116 // 117 //***************************************************************************** 118 #define MPU_RGN_ENABLE 1 119 #define MPU_RGN_DISABLE 0 120 121 //***************************************************************************** 122 // 123 // API Function prototypes 124 // 125 //***************************************************************************** 126 extern void MPUEnable(unsigned long ulMPUConfig); 127 extern void MPUDisable(void); 128 extern unsigned long MPURegionCountGet(void); 129 extern void MPURegionEnable(unsigned long ulRegion); 130 extern void MPURegionDisable(unsigned long ulRegion); 131 extern void MPURegionSet(unsigned long ulRegion, unsigned long ulAddr, 132 unsigned long ulFlags); 133 extern void MPURegionGet(unsigned long ulRegion, unsigned long *pulAddr, 134 unsigned long *pulFlags); 135 extern void MPUIntRegister(void (*pfnHandler)(void)); 136 extern void MPUIntUnregister(void); 137 138 //***************************************************************************** 139 // 140 // Mark the end of the C bindings section for C++ compilers. 141 // 142 //***************************************************************************** 143 #ifdef __cplusplus 144 } 145 #endif 146 147 #endif // __MPU_H__ 148