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