fgic_cpu_interface.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /*
  2. * @Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * @FilePath: fgic_cpu_interface.S
  15. * @Date: 2022-03-29 18:04:23
  16. * @LastEditTime: 2022-03-29 18:04:27
  17. * @Description:  This file is for
  18. *
  19. * @Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. */
  23. #ifdef __aarch64__
  24. /*
  25. * Mapping of MSR and MRS to physical and virtual CPU interface registers
  26. *
  27. * ARM Generic Interrupt Controller Architecture Specification
  28. * GIC architecture version 3.0 and version 4.0
  29. * Table 8-5
  30. */
  31. #define ICC_AP0R0_EL1 S3_0_C12_C8_4
  32. #define ICC_AP0R1_EL1 S3_0_C12_C8_5
  33. #define ICC_AP0R2_EL1 S3_0_C12_C8_6
  34. #define ICC_AP0R3_EL1 S3_0_C12_C8_7
  35. #define ICC_AP1R0_EL1 S3_0_C12_C9_0
  36. #define ICC_AP1R1_EL1 S3_0_C12_C9_1
  37. #define ICC_AP1R2_EL1 S3_0_C12_C9_2
  38. #define ICC_AP1R3_EL1 S3_0_C12_C9_3
  39. #define ICC_ASGI1R_EL1 S3_0_C12_C11_6
  40. #define ICC_BPR0_EL1 S3_0_C12_C8_3
  41. #define ICC_BPR1_EL1 S3_0_C12_C12_3
  42. #define ICC_CTLR_EL1 S3_0_C12_C12_4
  43. #define ICC_CTLR_EL3 S3_6_C12_C12_4
  44. #define ICC_DIR_EL1 S3_0_C12_C11_1
  45. #define ICC_EOIR0_EL1 S3_0_C12_C8_1
  46. #define ICC_EOIR1_EL1 S3_0_C12_C12_1
  47. #define ICC_HPPIR0_EL1 S3_0_C12_C8_2
  48. #define ICC_HPPIR1_EL1 S3_0_C12_C12_2
  49. #define ICC_IAR0_EL1 S3_0_C12_C8_0
  50. #define ICC_IAR1_EL1 S3_0_C12_C12_0
  51. #define ICC_IGRPEN0_EL1 S3_0_C12_C12_6
  52. #define ICC_IGRPEN1_EL1 S3_0_C12_C12_7
  53. #define ICC_IGRPEN1_EL3 S3_6_C12_C12_7
  54. #define ICC_PMR_EL1 S3_0_C4_C6_0
  55. #define ICC_RPR_EL1 S3_0_C12_C11_3
  56. #define ICC_SGI0R_EL1 S3_0_C12_C11_7
  57. #define ICC_SGI1R_EL1 S3_0_C12_C11_5
  58. #define ICC_SRE_EL1 S3_0_C12_C12_5
  59. #define ICC_SRE_EL2 S3_4_C12_C9_5
  60. #define ICC_SRE_EL3 S3_6_C12_C12_5
  61. /*
  62. * Mapping of MSR and MRS to virtual interface control registers
  63. *
  64. * ARM Generic Interrupt Controller Architecture Specification
  65. * GIC architecture version 3.0 and version 4.0
  66. * Table 8-6
  67. */
  68. #define ICH_AP0R0_EL2 S3_4_C12_C8_0
  69. #define ICH_AP0R1_EL2 S3_4_C12_C8_1
  70. #define ICH_AP0R2_EL2 S3_4_C12_C8_2
  71. #define ICH_AP0R3_EL2 S3_4_C12_C8_3
  72. #define ICH_AP1R0_EL2 S3_4_C12_C9_0
  73. #define ICH_AP1R1_EL2 S3_4_C12_C9_1
  74. #define ICH_AP1R2_EL2 S3_4_C12_C9_2
  75. #define ICH_AP1R3_EL2 S3_4_C12_C9_3
  76. #define ICH_HCR_EL2 S3_4_C12_C11_0
  77. #define ICH_VTR_EL2 S3_4_C12_C11_1
  78. #define ICH_MISR_EL2 S3_4_C12_C11_2
  79. #define ICH_EISR_EL2 S3_4_C12_C11_3
  80. #define ICH_ELRSR_EL2 S3_4_C12_C11_5
  81. #define ICH_VMCR_EL2 S3_4_C12_C11_7
  82. #define ICH_LR0_EL2 S3_4_C12_C12_0
  83. #define ICH_LR1_EL2 S3_4_C12_C12_1
  84. #define ICH_LR2_EL2 S3_4_C12_C12_2
  85. #define ICH_LR3_EL2 S3_4_C12_C12_3
  86. #define ICH_LR4_EL2 S3_4_C12_C12_4
  87. #define ICH_LR5_EL2 S3_4_C12_C12_5
  88. #define ICH_LR6_EL2 S3_4_C12_C12_6
  89. #define ICH_LR7_EL2 S3_4_C12_C12_7
  90. #define ICH_LR8_EL2 S3_4_C12_C13_0
  91. #define ICH_LR9_EL2 S3_4_C12_C13_1
  92. #define ICH_LR10_EL2 S3_4_C12_C13_2
  93. #define ICH_LR11_EL2 S3_4_C12_C13_3
  94. #define ICH_LR12_EL2 S3_4_C12_C13_4
  95. #define ICH_LR13_EL2 S3_4_C12_C13_5
  96. #define ICH_LR14_EL2 S3_4_C12_C13_6
  97. #define ICH_LR15_EL2 S3_4_C12_C13_7
  98. #define FUNC_DEFINE(name) .global name ;\
  99. .type name, @function ;\
  100. name:
  101. /**
  102. * @name:
  103. * @msg: void FGicSetICC_SRE_EL3(GICC_SRE_BITS bits) --- Interrupt Controller System Register Enable
  104. * @return {*}
  105. */
  106. FUNC_DEFINE(FGicSetICC_SRE_EL3)
  107. MSR ICC_SRE_EL3, x0
  108. ISB
  109. RET
  110. /**
  111. * @name:
  112. * @msg: void FGicSetICC_SRE_EL2(GICC_SRE_BITS bits)
  113. * @return {*}
  114. */
  115. FUNC_DEFINE(FGicSetICC_SRE_EL2)
  116. MSR ICC_SRE_EL2, x0
  117. ISB
  118. RET
  119. /**
  120. * @name:
  121. * @msg: void FGicSetICC_SRE_EL1(GICC_SRE_BITS bits)
  122. * @return {*}
  123. */
  124. FUNC_DEFINE(FGicSetICC_SRE_EL1)
  125. MSR ICC_SRE_EL1, x0
  126. ISB
  127. RET
  128. /**
  129. * @name:
  130. * @msg: u32 FGicGetICC_SRE_EL3(void) -- Interrupt Controller System Register Enable
  131. * @return {*}
  132. */
  133. FUNC_DEFINE(FGicGetICC_SRE_EL3)
  134. MRS x0, ICC_SRE_EL3
  135. RET
  136. /**
  137. * @name:
  138. * @msg: u32 FGicGetICC_SRE_EL2(void)
  139. * @return {*}
  140. */
  141. FUNC_DEFINE(FGicGetICC_SRE_EL2)
  142. MRS x0, ICC_SRE_EL2
  143. RET
  144. /**
  145. * @name:
  146. * @msg: u32 FGicGetICC_SRE_EL1(void)
  147. * @return {*}
  148. */
  149. FUNC_DEFINE(FGicGetICC_SRE_EL1)
  150. MRS x0, ICC_SRE_EL1
  151. RET
  152. /**
  153. * @name:
  154. * @msg: void FGicEnableGroup0(void)
  155. * @return {*}
  156. */
  157. FUNC_DEFINE(FGicEnableGroup0)
  158. MOV w0, #1
  159. MSR ICC_IGRPEN0_EL1, x0
  160. ISB
  161. RET
  162. /**
  163. * @name:
  164. * @msg: void FGicDisableGroup0(void)
  165. * @return {*}
  166. */
  167. FUNC_DEFINE(FGicDisableGroup0)
  168. MOV w0, #0
  169. MSR ICC_IGRPEN0_EL1, x0
  170. ISB
  171. RET
  172. /**
  173. * @name:
  174. * @msg:
  175. * @return {*}
  176. */
  177. FUNC_DEFINE(FGicEnableGroup1_EL3)
  178. MOV w0, #1
  179. MSR ICC_IGRPEN1_EL3, x0
  180. ISB
  181. RET
  182. /**
  183. * @name:
  184. * @msg:
  185. * @return {*}
  186. */
  187. FUNC_DEFINE(FGicEnableGroup1_EL1)
  188. MOV w0, #1
  189. MSR ICC_IGRPEN1_EL1, x0
  190. ISB
  191. RET
  192. /**
  193. * @name:
  194. * @msg: void FGicDisableGroup1_EL1(void)
  195. * @return {*}
  196. */
  197. FUNC_DEFINE(FGicDisableGroup1_EL1)
  198. MOV w0, #0
  199. MSR ICC_IGRPEN1_EL1, x0
  200. ISB
  201. RET
  202. /**
  203. * @name:
  204. * @msg: void FGicDisableGroup1_EL3(void)
  205. * @return {*}
  206. */
  207. FUNC_DEFINE(FGicDisableGroup1_EL3)
  208. MOV w0, #0
  209. MSR ICC_IGRPEN1_EL3, x0
  210. ISB
  211. RET
  212. /**
  213. * @name:
  214. * @msg: void FGicSetICC_CTLR_EL3(GICC_CTLR_BITS reg_bits)
  215. * @return {*}
  216. */
  217. FUNC_DEFINE(FGicSetICC_CTLR_EL3)
  218. MSR ICC_CTLR_EL3, x0
  219. ISB
  220. RET
  221. /**
  222. * @name:
  223. * @msg: void FGicSetICC_CTLR_EL1(GICC_CTLR_BITS reg_bits)
  224. * @return {*}
  225. */
  226. FUNC_DEFINE(FGicSetICC_CTLR_EL1)
  227. MSR ICC_CTLR_EL1, x0
  228. ISB
  229. RET
  230. /**
  231. * @name:
  232. * @msg: u32 FGicGetICC_CTLR_EL3(void) -- Controls aspects of the behavior of the GIC CPU interface and provides information about the features implemented.
  233. * @return {*}
  234. */
  235. FUNC_DEFINE(FGicGetICC_CTLR_EL3)
  236. MRS x0, ICC_CTLR_EL3
  237. RET
  238. /**
  239. * @name:
  240. * @msg: u32 FGicGetICC_CTLR_EL1(void) -- Controls aspects of the behavior of the GIC CPU interface and provides information about the features implemented.
  241. * @return {*}
  242. */
  243. FUNC_DEFINE(FGicGetICC_CTLR_EL1)
  244. MRS x0, ICC_CTLR_EL1
  245. RET
  246. /**
  247. * @name:
  248. * @msg: u32 FGicWriteICC_APR0(void) -- The PE reads this register to obtain the INTID of the signaled Group 0 interrupt.
  249. * @return {*}
  250. */
  251. FUNC_DEFINE(FGicGetICC_APR0)
  252. MRS x0, ICC_IAR0_EL1
  253. RET
  254. /**
  255. * @name:
  256. * @msg: u32 FGicGetICC_APR1(void) -- The PE reads this register to obtain the INTID of the signaled Group 1 interrupt.
  257. * @return {*}
  258. */
  259. FUNC_DEFINE(FGicGetICC_APR1)
  260. MRS x0, ICC_IAR1_EL1
  261. RET
  262. /**
  263. * @name:
  264. * @msg: void FGicSetICC_EOIR0(u32 intnum) -- /* A PE writes to this register to inform the CPU interface that it has completed the processing of the specified Group 0 interrupt
  265. * @return {*}
  266. */
  267. FUNC_DEFINE(FGicSetICC_EOIR0)
  268. MSR ICC_EOIR0_EL1, x0
  269. ISB
  270. RET
  271. /**
  272. * @name:
  273. * @msg: void FGicSetICC_EOIR1(u32 intnum) -- /* A PE writes to this register to inform the CPU interface that it has completed the processing of the specified Group 1 interrupt
  274. * @return {*}
  275. */
  276. FUNC_DEFINE(FGicSetICC_EOIR1)
  277. MSR ICC_EOIR1_EL1, x0
  278. ISB
  279. RET
  280. /**
  281. * @name:
  282. * @msg: void FGicSetICC_DIR(u32 intnum) -- When interrupt priority drop is separated from interrupt deactivation, a write to this register deactivates the specified interrupt.
  283. * @return {*}
  284. */
  285. FUNC_DEFINE(FGicSetICC_DIR)
  286. MSR ICC_DIR_EL1, x0
  287. ISB
  288. RET
  289. /**
  290. * @name:
  291. * @msg: void FGicSetICC_PMR(u32 priority_mask) -- Provides an interrupt priority filter.
  292. * @return {*}
  293. */
  294. FUNC_DEFINE(FGicSetICC_PMR)
  295. MSR ICC_PMR_EL1, x0
  296. ISB
  297. RET
  298. /**
  299. * @name:
  300. * @msg: u32 FGicGetICC_PMR(void)
  301. * @return {*}
  302. */
  303. FUNC_DEFINE(FGicGetICC_PMR)
  304. MRS x0,ICC_PMR_EL1
  305. RET
  306. /**
  307. * @name:
  308. * @msg: u32 FGicGetICC_BPR1(void) --- Defines the point at which the priority value fields split into two parts, the group priority field and the subpriority field. The group priority field determines Group 1 interrupt preemption.
  309. * @return {*}
  310. */
  311. FUNC_DEFINE(FGicGetICC_BPR1)
  312. MRS x0,ICC_BPR1_EL1
  313. RET
  314. /**
  315. * @name:
  316. * @msg: void FGicSetICC_BPR1(u32 binary_point)
  317. * @return {*}
  318. */
  319. FUNC_DEFINE(FGicSetICC_BPR1)
  320. MSR ICC_BPR1_EL1, x0
  321. ISB
  322. RET
  323. /**
  324. * @name:
  325. * @msg: u32 FGicGetICC_BPR0(void) --- Defines the point at which the priority value fields split into two parts, the group priority field and the subpriority field. The group priority field determines Group 0 interrupt preemption.
  326. * @return {*}
  327. */
  328. FUNC_DEFINE(FGicGetICC_BPR0)
  329. MRS x0,ICC_BPR0_EL1
  330. RET
  331. /**
  332. * @name:
  333. * @msg: void FGicSetICC_BPR0(u32 binary_point)
  334. * @return {*}
  335. */
  336. FUNC_DEFINE(FGicSetICC_BPR0)
  337. MSR ICC_BPR0_EL1, x0
  338. ISB
  339. RET
  340. /**
  341. * @name:
  342. * @msg: u32 FGicGetICC_HPPIR1(void) --- Indicates the highest priority pending Group 1 interrupt on the CPU interface.
  343. * @return {*}
  344. */
  345. FUNC_DEFINE(FGicGetICC_HPPIR1)
  346. MRS x0,ICC_HPPIR1_EL1
  347. RET
  348. /**
  349. * @name:
  350. * @msg: void FGicSetICC_HPPIR1(u32 binary_point)
  351. * @return {*}
  352. */
  353. FUNC_DEFINE(FGicSetICC_HPPIR1)
  354. MSR ICC_HPPIR1_EL1, x0
  355. ISB
  356. RET
  357. /**
  358. * @name:
  359. * @msg: u32 FGicGetICC_HPPIR0(void) --- Indicates the highest priority pending Group 0 interrupt on the CPU interface.
  360. * @return {*}
  361. */
  362. FUNC_DEFINE(FGicGetICC_HPPIR0)
  363. MRS x0,ICC_HPPIR0_EL1
  364. RET
  365. /**
  366. * @name:
  367. * @msg: void FGicSetICC_HPPIR0(u32 binary_point)
  368. * @return {*}
  369. */
  370. FUNC_DEFINE(FGicSetICC_HPPIR0)
  371. MSR ICC_HPPIR0_EL1, x0
  372. ISB
  373. RET
  374. /**
  375. * @name:
  376. * @msg: u32 FGicGetICC_RPR(void) --- Indicates the Running priority of the CPU interface.
  377. * @return {*}
  378. */
  379. FUNC_DEFINE(FGicGetICC_RPR)
  380. MRS x0,ICC_RPR_EL1
  381. RET
  382. /* SGI interface */
  383. /**
  384. * @name:
  385. * @msg: void FGicSetICC_SGI0R(u32 intnum,u32 target_list,GICC_SGIR_IRM_BITS mode,u64 affinity_list) --- Generates Secure Group 0 SGIs
  386. * @return {*}
  387. */
  388. FUNC_DEFINE(FGicSetICC_SGI0R)
  389. ORR x0, x0, x1
  390. ORR x0, x0, x2
  391. ORR x0, x0, x3
  392. MSR ICC_SGI0R_EL1, x0
  393. ISB
  394. RET
  395. /**
  396. * @name:
  397. * @msg: void FGicSetICC_SGI1R(u32 intnum,u32 target_list,GICC_SGIR_IRM_BITS mode,u64 affinity_list)
  398. * @return {*}
  399. */
  400. FUNC_DEFINE(FGicSetICC_SGI1R)
  401. ORR x0, x0, x1
  402. ORR x0, x0, x2
  403. ORR x0, x0, x3
  404. MSR ICC_SGI1R_EL1, x0
  405. ISB
  406. RET
  407. /**
  408. * @name:
  409. * @msg: void FGicSetICC_ASGI1R(u32 intnum,u32 target_list,GICC_SGIR_IRM_BITS mode,u64 affinity_list)
  410. * @return {*}
  411. */
  412. FUNC_DEFINE(FGicSetICC_ASGI1R)
  413. ORR x0, x0, x1
  414. ORR x0, x0, x2
  415. ORR x0, x0, x3
  416. MSR ICC_ASGI1R_EL1, x0
  417. ISB
  418. RET
  419. #else
  420. #endif