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