1 |
608 |
jeremybenn |
;******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
|
2 |
|
|
;* File Name : cortexm3_macro.s
|
3 |
|
|
;* Author : MCD Application Team
|
4 |
|
|
;* Date First Issued : 09/29/2006
|
5 |
|
|
;* Description : Instruction wrappers for special Cortex-M3 instructions.
|
6 |
|
|
;*******************************************************************************
|
7 |
|
|
; History:
|
8 |
|
|
; 05/21/2007: V0.3
|
9 |
|
|
; 04/02/2007: V0.2
|
10 |
|
|
; 02/05/2007: V0.1
|
11 |
|
|
; 09/29/2006: V0.01
|
12 |
|
|
;*******************************************************************************
|
13 |
|
|
; THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
14 |
|
|
; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
15 |
|
|
; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
16 |
|
|
; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
17 |
|
|
; CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
18 |
|
|
; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
19 |
|
|
;*******************************************************************************
|
20 |
|
|
|
21 |
|
|
THUMB
|
22 |
|
|
REQUIRE8
|
23 |
|
|
PRESERVE8
|
24 |
|
|
|
25 |
|
|
AREA |.text|, CODE, READONLY, ALIGN=2
|
26 |
|
|
|
27 |
|
|
; Exported functions
|
28 |
|
|
EXPORT __WFI
|
29 |
|
|
EXPORT __WFE
|
30 |
|
|
EXPORT __SEV
|
31 |
|
|
EXPORT __ISB
|
32 |
|
|
EXPORT __DSB
|
33 |
|
|
EXPORT __DMB
|
34 |
|
|
EXPORT __SVC
|
35 |
|
|
EXPORT __MRS_CONTROL
|
36 |
|
|
EXPORT __MSR_CONTROL
|
37 |
|
|
EXPORT __MRS_PSP
|
38 |
|
|
EXPORT __MSR_PSP
|
39 |
|
|
EXPORT __MRS_MSP
|
40 |
|
|
EXPORT __MSR_MSP
|
41 |
|
|
EXPORT __SETPRIMASK
|
42 |
|
|
EXPORT __RESETPRIMASK
|
43 |
|
|
EXPORT __SETFAULTMASK
|
44 |
|
|
EXPORT __RESETFAULTMASK
|
45 |
|
|
EXPORT __BASEPRICONFIG
|
46 |
|
|
EXPORT __GetBASEPRI
|
47 |
|
|
EXPORT __REV_HalfWord
|
48 |
|
|
EXPORT __REV_Word
|
49 |
|
|
|
50 |
|
|
;*******************************************************************************
|
51 |
|
|
; Function Name : __WFI
|
52 |
|
|
; Description : Assembler function for the WFI instruction.
|
53 |
|
|
; Input : None
|
54 |
|
|
; Return : None
|
55 |
|
|
;*******************************************************************************
|
56 |
|
|
__WFI
|
57 |
|
|
|
58 |
|
|
WFI
|
59 |
|
|
BX r14
|
60 |
|
|
|
61 |
|
|
;*******************************************************************************
|
62 |
|
|
; Function Name : __WFE
|
63 |
|
|
; Description : Assembler function for the WFE instruction.
|
64 |
|
|
; Input : None
|
65 |
|
|
; Return : None
|
66 |
|
|
;*******************************************************************************
|
67 |
|
|
__WFE
|
68 |
|
|
|
69 |
|
|
WFE
|
70 |
|
|
BX r14
|
71 |
|
|
|
72 |
|
|
;*******************************************************************************
|
73 |
|
|
; Function Name : __SEV
|
74 |
|
|
; Description : Assembler function for the SEV instruction.
|
75 |
|
|
; Input : None
|
76 |
|
|
; Return : None
|
77 |
|
|
;*******************************************************************************
|
78 |
|
|
__SEV
|
79 |
|
|
|
80 |
|
|
SEV
|
81 |
|
|
BX r14
|
82 |
|
|
|
83 |
|
|
;*******************************************************************************
|
84 |
|
|
; Function Name : __ISB
|
85 |
|
|
; Description : Assembler function for the ISB instruction.
|
86 |
|
|
; Input : None
|
87 |
|
|
; Return : None
|
88 |
|
|
;*******************************************************************************
|
89 |
|
|
__ISB
|
90 |
|
|
|
91 |
|
|
ISB
|
92 |
|
|
BX r14
|
93 |
|
|
|
94 |
|
|
;*******************************************************************************
|
95 |
|
|
; Function Name : __DSB
|
96 |
|
|
; Description : Assembler function for the DSB instruction.
|
97 |
|
|
; Input : None
|
98 |
|
|
; Return : None
|
99 |
|
|
;*******************************************************************************
|
100 |
|
|
__DSB
|
101 |
|
|
|
102 |
|
|
DSB
|
103 |
|
|
BX r14
|
104 |
|
|
|
105 |
|
|
;*******************************************************************************
|
106 |
|
|
; Function Name : __DMB
|
107 |
|
|
; Description : Assembler function for the DMB instruction.
|
108 |
|
|
; Input : None
|
109 |
|
|
; Return : None
|
110 |
|
|
;*******************************************************************************
|
111 |
|
|
__DMB
|
112 |
|
|
|
113 |
|
|
DMB
|
114 |
|
|
BX r14
|
115 |
|
|
|
116 |
|
|
;*******************************************************************************
|
117 |
|
|
; Function Name : __SVC
|
118 |
|
|
; Description : Assembler function for the SVC instruction.
|
119 |
|
|
; Input : None
|
120 |
|
|
; Return : None
|
121 |
|
|
;*******************************************************************************
|
122 |
|
|
__SVC
|
123 |
|
|
|
124 |
|
|
SVC 0x01
|
125 |
|
|
BX r14
|
126 |
|
|
|
127 |
|
|
;*******************************************************************************
|
128 |
|
|
; Function Name : __MRS_CONTROL
|
129 |
|
|
; Description : Assembler function for the MRS instruction.
|
130 |
|
|
; Input : None
|
131 |
|
|
; Return : - r0 : Cortex-M3 CONTROL register value.
|
132 |
|
|
;*******************************************************************************
|
133 |
|
|
__MRS_CONTROL
|
134 |
|
|
|
135 |
|
|
MRS r0, CONTROL
|
136 |
|
|
BX r14
|
137 |
|
|
|
138 |
|
|
;*******************************************************************************
|
139 |
|
|
; Function Name : __MSR_CONTROL
|
140 |
|
|
; Description : Assembler function for the MSR instruction.
|
141 |
|
|
; Input : - r0 : Cortex-M3 CONTROL register new value.
|
142 |
|
|
; Return : None
|
143 |
|
|
;*******************************************************************************
|
144 |
|
|
__MSR_CONTROL
|
145 |
|
|
|
146 |
|
|
MSR CONTROL, r0
|
147 |
|
|
ISB
|
148 |
|
|
BX r14
|
149 |
|
|
|
150 |
|
|
;*******************************************************************************
|
151 |
|
|
; Function Name : __MRS_PSP
|
152 |
|
|
; Description : Assembler function for the MRS instruction.
|
153 |
|
|
; Input : None
|
154 |
|
|
; Return : - r0 : Process Stack value.
|
155 |
|
|
;*******************************************************************************
|
156 |
|
|
__MRS_PSP
|
157 |
|
|
|
158 |
|
|
MRS r0, PSP
|
159 |
|
|
BX r14
|
160 |
|
|
|
161 |
|
|
;*******************************************************************************
|
162 |
|
|
; Function Name : __MSR_PSP
|
163 |
|
|
; Description : Assembler function for the MSR instruction.
|
164 |
|
|
; Input : - r0 : Process Stack new value.
|
165 |
|
|
; Return : None
|
166 |
|
|
;*******************************************************************************
|
167 |
|
|
__MSR_PSP
|
168 |
|
|
|
169 |
|
|
MSR PSP, r0 ; set Process Stack value
|
170 |
|
|
BX r14
|
171 |
|
|
|
172 |
|
|
;*******************************************************************************
|
173 |
|
|
; Function Name : __MRS_MSP
|
174 |
|
|
; Description : Assembler function for the MRS instruction.
|
175 |
|
|
; Input : None
|
176 |
|
|
; Return : - r0 : Main Stack value.
|
177 |
|
|
;*******************************************************************************
|
178 |
|
|
__MRS_MSP
|
179 |
|
|
|
180 |
|
|
MRS r0, MSP
|
181 |
|
|
BX r14
|
182 |
|
|
|
183 |
|
|
;*******************************************************************************
|
184 |
|
|
; Function Name : __MSR_MSP
|
185 |
|
|
; Description : Assembler function for the MSR instruction.
|
186 |
|
|
; Input : - r0 : Main Stack new value.
|
187 |
|
|
; Return : None
|
188 |
|
|
;*******************************************************************************
|
189 |
|
|
__MSR_MSP
|
190 |
|
|
|
191 |
|
|
MSR MSP, r0 ; set Main Stack value
|
192 |
|
|
BX r14
|
193 |
|
|
|
194 |
|
|
;*******************************************************************************
|
195 |
|
|
; Function Name : __SETPRIMASK
|
196 |
|
|
; Description : Assembler function to set the PRIMASK.
|
197 |
|
|
; Input : None
|
198 |
|
|
; Return : None
|
199 |
|
|
;*******************************************************************************
|
200 |
|
|
__SETPRIMASK
|
201 |
|
|
|
202 |
|
|
CPSID i
|
203 |
|
|
BX r14
|
204 |
|
|
|
205 |
|
|
;*******************************************************************************
|
206 |
|
|
; Function Name : __RESETPRIMASK
|
207 |
|
|
; Description : Assembler function to reset the PRIMASK.
|
208 |
|
|
; Input : None
|
209 |
|
|
; Return : None
|
210 |
|
|
;*******************************************************************************
|
211 |
|
|
__RESETPRIMASK
|
212 |
|
|
|
213 |
|
|
CPSIE i
|
214 |
|
|
BX r14
|
215 |
|
|
|
216 |
|
|
;*******************************************************************************
|
217 |
|
|
; Function Name : __SETFAULTMASK
|
218 |
|
|
; Description : Assembler function to set the FAULTMASK.
|
219 |
|
|
; Input : None
|
220 |
|
|
; Return : None
|
221 |
|
|
;*******************************************************************************
|
222 |
|
|
__SETFAULTMASK
|
223 |
|
|
|
224 |
|
|
CPSID f
|
225 |
|
|
BX r14
|
226 |
|
|
|
227 |
|
|
;*******************************************************************************
|
228 |
|
|
; Function Name : __RESETFAULTMASK
|
229 |
|
|
; Description : Assembler function to reset the FAULTMASK.
|
230 |
|
|
; Input : None
|
231 |
|
|
; Return : None
|
232 |
|
|
;*******************************************************************************
|
233 |
|
|
__RESETFAULTMASK
|
234 |
|
|
|
235 |
|
|
CPSIE f
|
236 |
|
|
BX r14
|
237 |
|
|
|
238 |
|
|
;*******************************************************************************
|
239 |
|
|
; Function Name : __BASEPRICONFIG
|
240 |
|
|
; Description : Assembler function to set the Base Priority.
|
241 |
|
|
; Input : - r0 : Base Priority new value
|
242 |
|
|
; Return : None
|
243 |
|
|
;*******************************************************************************
|
244 |
|
|
__BASEPRICONFIG
|
245 |
|
|
|
246 |
|
|
MSR BASEPRI, r0
|
247 |
|
|
BX r14
|
248 |
|
|
|
249 |
|
|
;*******************************************************************************
|
250 |
|
|
; Function Name : __GetBASEPRI
|
251 |
|
|
; Description : Assembler function to get the Base Priority value.
|
252 |
|
|
; Input : None
|
253 |
|
|
; Return : - r0 : Base Priority value
|
254 |
|
|
;*******************************************************************************
|
255 |
|
|
__GetBASEPRI
|
256 |
|
|
|
257 |
|
|
MRS r0, BASEPRI_MAX
|
258 |
|
|
BX r14
|
259 |
|
|
|
260 |
|
|
;*******************************************************************************
|
261 |
|
|
; Function Name : __REV_HalfWord
|
262 |
|
|
; Description : Reverses the byte order in HalfWord(16-bit) input variable.
|
263 |
|
|
; Input : - r0 : specifies the input variable
|
264 |
|
|
; Return : - r0 : holds tve variable value after byte reversing.
|
265 |
|
|
;*******************************************************************************
|
266 |
|
|
__REV_HalfWord
|
267 |
|
|
|
268 |
|
|
REV16 r0, r0
|
269 |
|
|
BX r14
|
270 |
|
|
|
271 |
|
|
;*******************************************************************************
|
272 |
|
|
; Function Name : __REV_Word
|
273 |
|
|
; Description : Reverses the byte order in Word(32-bit) input variable.
|
274 |
|
|
; Input : - r0 : specifies the input variable
|
275 |
|
|
; Return : - r0 : holds tve variable value after byte reversing.
|
276 |
|
|
;*******************************************************************************
|
277 |
|
|
__REV_Word
|
278 |
|
|
|
279 |
|
|
REV r0, r0
|
280 |
|
|
BX r14
|
281 |
|
|
|
282 |
|
|
END
|
283 |
|
|
|
284 |
|
|
;******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE*****
|