cortexm3_macro.s 9.8 KB

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