hpm_plic_regs.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*
  2. * Copyright (c) 2021-2023 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_PLIC_H
  8. #define HPM_PLIC_H
  9. typedef struct {
  10. __RW uint32_t FEATURE; /* 0x0: Feature enable register */
  11. __RW uint32_t PRIORITY[127]; /* 0x4 - 0x1FC: Source priority */
  12. __R uint8_t RESERVED0[3584]; /* 0x200 - 0xFFF: Reserved */
  13. __RW uint32_t PENDING[4]; /* 0x1000 - 0x100C: Pending status */
  14. __R uint8_t RESERVED1[112]; /* 0x1010 - 0x107F: Reserved */
  15. __R uint32_t TRIGGER[4]; /* 0x1080 - 0x108C: Trigger type */
  16. __R uint8_t RESERVED2[112]; /* 0x1090 - 0x10FF: Reserved */
  17. __R uint32_t NUMBER; /* 0x1100: Number of supported interrupt sources and targets */
  18. __R uint32_t INFO; /* 0x1104: Version and the maximum priority */
  19. __R uint8_t RESERVED3[3832]; /* 0x1108 - 0x1FFF: Reserved */
  20. struct {
  21. __RW uint32_t INTEN[4]; /* 0x2000 - 0x200C: machine interrupt enable */
  22. __R uint8_t RESERVED0[112]; /* 0x2010 - 0x207F: Reserved */
  23. } TARGETINT[2];
  24. __R uint8_t RESERVED4[2088704]; /* 0x2100 - 0x1FFFFF: Reserved */
  25. struct {
  26. __RW uint32_t THRESHOLD; /* 0x200000: Target0 priority threshold */
  27. __RW uint32_t CLAIM; /* 0x200004: Target claim and complete */
  28. __R uint8_t RESERVED0[1016]; /* 0x200008 - 0x2003FF: Reserved */
  29. __RW uint32_t PPS; /* 0x200400: Preempted priority stack */
  30. __R uint8_t RESERVED1[3068]; /* 0x200404 - 0x200FFF: Reserved */
  31. } TARGETCONFIG[2];
  32. } PLIC_Type;
  33. /* Bitfield definition for register: FEATURE */
  34. /*
  35. * VECTORED (RW)
  36. *
  37. * Vector mode enable
  38. * 0: Disabled
  39. * 1: Enabled
  40. */
  41. #define PLIC_FEATURE_VECTORED_MASK (0x2U)
  42. #define PLIC_FEATURE_VECTORED_SHIFT (1U)
  43. #define PLIC_FEATURE_VECTORED_SET(x) (((uint32_t)(x) << PLIC_FEATURE_VECTORED_SHIFT) & PLIC_FEATURE_VECTORED_MASK)
  44. #define PLIC_FEATURE_VECTORED_GET(x) (((uint32_t)(x) & PLIC_FEATURE_VECTORED_MASK) >> PLIC_FEATURE_VECTORED_SHIFT)
  45. /*
  46. * PREEMPT (RW)
  47. *
  48. * Preemptive priority interrupt enable
  49. * 0: Disabled
  50. * 1: Enabled
  51. */
  52. #define PLIC_FEATURE_PREEMPT_MASK (0x1U)
  53. #define PLIC_FEATURE_PREEMPT_SHIFT (0U)
  54. #define PLIC_FEATURE_PREEMPT_SET(x) (((uint32_t)(x) << PLIC_FEATURE_PREEMPT_SHIFT) & PLIC_FEATURE_PREEMPT_MASK)
  55. #define PLIC_FEATURE_PREEMPT_GET(x) (((uint32_t)(x) & PLIC_FEATURE_PREEMPT_MASK) >> PLIC_FEATURE_PREEMPT_SHIFT)
  56. /* Bitfield definition for register array: PRIORITY */
  57. /*
  58. * PRIORITY (RW)
  59. *
  60. * Interrupt source priority. The valid range of this field is 0-7.
  61. * 0: Never interrupt
  62. * 1-7: Interrupt source priority. The larger the value, the higher the priority.
  63. */
  64. #define PLIC_PRIORITY_PRIORITY_MASK (0xFFFFFFFFUL)
  65. #define PLIC_PRIORITY_PRIORITY_SHIFT (0U)
  66. #define PLIC_PRIORITY_PRIORITY_SET(x) (((uint32_t)(x) << PLIC_PRIORITY_PRIORITY_SHIFT) & PLIC_PRIORITY_PRIORITY_MASK)
  67. #define PLIC_PRIORITY_PRIORITY_GET(x) (((uint32_t)(x) & PLIC_PRIORITY_PRIORITY_MASK) >> PLIC_PRIORITY_PRIORITY_SHIFT)
  68. /* Bitfield definition for register array: PENDING */
  69. /*
  70. * INTERRUPT (RW)
  71. *
  72. * The interrupt pending status of inpterrupt sources. Every interrupt source occupies 1 bit.
  73. */
  74. #define PLIC_PENDING_INTERRUPT_MASK (0xFFFFFFFFUL)
  75. #define PLIC_PENDING_INTERRUPT_SHIFT (0U)
  76. #define PLIC_PENDING_INTERRUPT_SET(x) (((uint32_t)(x) << PLIC_PENDING_INTERRUPT_SHIFT) & PLIC_PENDING_INTERRUPT_MASK)
  77. #define PLIC_PENDING_INTERRUPT_GET(x) (((uint32_t)(x) & PLIC_PENDING_INTERRUPT_MASK) >> PLIC_PENDING_INTERRUPT_SHIFT)
  78. /* Bitfield definition for register array: TRIGGER */
  79. /*
  80. * INTERRUPT (RO)
  81. *
  82. * The interrupt trigger type of interrupt sources. Every interrupt source occupies 1 bit.
  83. * 0: Level-triggered interrupt
  84. * 1: Edge-triggered interrupt
  85. */
  86. #define PLIC_TRIGGER_INTERRUPT_MASK (0xFFFFFFFFUL)
  87. #define PLIC_TRIGGER_INTERRUPT_SHIFT (0U)
  88. #define PLIC_TRIGGER_INTERRUPT_GET(x) (((uint32_t)(x) & PLIC_TRIGGER_INTERRUPT_MASK) >> PLIC_TRIGGER_INTERRUPT_SHIFT)
  89. /* Bitfield definition for register: NUMBER */
  90. /*
  91. * NUM_TARGET (RO)
  92. *
  93. * The number of supported targets
  94. */
  95. #define PLIC_NUMBER_NUM_TARGET_MASK (0xFFFF0000UL)
  96. #define PLIC_NUMBER_NUM_TARGET_SHIFT (16U)
  97. #define PLIC_NUMBER_NUM_TARGET_GET(x) (((uint32_t)(x) & PLIC_NUMBER_NUM_TARGET_MASK) >> PLIC_NUMBER_NUM_TARGET_SHIFT)
  98. /*
  99. * NUM_INTERRUPT (RO)
  100. *
  101. * The number of supported interrupt sources
  102. */
  103. #define PLIC_NUMBER_NUM_INTERRUPT_MASK (0xFFFFU)
  104. #define PLIC_NUMBER_NUM_INTERRUPT_SHIFT (0U)
  105. #define PLIC_NUMBER_NUM_INTERRUPT_GET(x) (((uint32_t)(x) & PLIC_NUMBER_NUM_INTERRUPT_MASK) >> PLIC_NUMBER_NUM_INTERRUPT_SHIFT)
  106. /* Bitfield definition for register: INFO */
  107. /*
  108. * MAX_PRIORITY (RO)
  109. *
  110. * The maximum priority supported
  111. */
  112. #define PLIC_INFO_MAX_PRIORITY_MASK (0xFFFF0000UL)
  113. #define PLIC_INFO_MAX_PRIORITY_SHIFT (16U)
  114. #define PLIC_INFO_MAX_PRIORITY_GET(x) (((uint32_t)(x) & PLIC_INFO_MAX_PRIORITY_MASK) >> PLIC_INFO_MAX_PRIORITY_SHIFT)
  115. /*
  116. * VERSION (RO)
  117. *
  118. * The version of the PLIC design
  119. */
  120. #define PLIC_INFO_VERSION_MASK (0xFFFFU)
  121. #define PLIC_INFO_VERSION_SHIFT (0U)
  122. #define PLIC_INFO_VERSION_GET(x) (((uint32_t)(x) & PLIC_INFO_VERSION_MASK) >> PLIC_INFO_VERSION_SHIFT)
  123. /* Bitfield definition for register of struct array TARGETINT: INTEN0 */
  124. /*
  125. * INTERRUPT (RW)
  126. *
  127. * The interrupt enable bit for interrupt. Every interrupt source occupies 1 bit.
  128. */
  129. #define PLIC_TARGETINT_INTEN_INTERRUPT_MASK (0xFFFFFFFFUL)
  130. #define PLIC_TARGETINT_INTEN_INTERRUPT_SHIFT (0U)
  131. #define PLIC_TARGETINT_INTEN_INTERRUPT_SET(x) (((uint32_t)(x) << PLIC_TARGETINT_INTEN_INTERRUPT_SHIFT) & PLIC_TARGETINT_INTEN_INTERRUPT_MASK)
  132. #define PLIC_TARGETINT_INTEN_INTERRUPT_GET(x) (((uint32_t)(x) & PLIC_TARGETINT_INTEN_INTERRUPT_MASK) >> PLIC_TARGETINT_INTEN_INTERRUPT_SHIFT)
  133. /* Bitfield definition for register of struct array TARGETCONFIG: THRESHOLD */
  134. /*
  135. * THRESHOLD (RW)
  136. *
  137. * Interrupt priority threshold.
  138. */
  139. #define PLIC_TARGETCONFIG_THRESHOLD_THRESHOLD_MASK (0xFFFFFFFFUL)
  140. #define PLIC_TARGETCONFIG_THRESHOLD_THRESHOLD_SHIFT (0U)
  141. #define PLIC_TARGETCONFIG_THRESHOLD_THRESHOLD_SET(x) (((uint32_t)(x) << PLIC_TARGETCONFIG_THRESHOLD_THRESHOLD_SHIFT) & PLIC_TARGETCONFIG_THRESHOLD_THRESHOLD_MASK)
  142. #define PLIC_TARGETCONFIG_THRESHOLD_THRESHOLD_GET(x) (((uint32_t)(x) & PLIC_TARGETCONFIG_THRESHOLD_THRESHOLD_MASK) >> PLIC_TARGETCONFIG_THRESHOLD_THRESHOLD_SHIFT)
  143. /* Bitfield definition for register of struct array TARGETCONFIG: CLAIM */
  144. /*
  145. * INTERRUPT_ID (RW)
  146. *
  147. * On reads, indicating the interrupt source that has being claimed. On writes, indicating the interrupt source that has been handled (completed).
  148. */
  149. #define PLIC_TARGETCONFIG_CLAIM_INTERRUPT_ID_MASK (0x3FFU)
  150. #define PLIC_TARGETCONFIG_CLAIM_INTERRUPT_ID_SHIFT (0U)
  151. #define PLIC_TARGETCONFIG_CLAIM_INTERRUPT_ID_SET(x) (((uint32_t)(x) << PLIC_TARGETCONFIG_CLAIM_INTERRUPT_ID_SHIFT) & PLIC_TARGETCONFIG_CLAIM_INTERRUPT_ID_MASK)
  152. #define PLIC_TARGETCONFIG_CLAIM_INTERRUPT_ID_GET(x) (((uint32_t)(x) & PLIC_TARGETCONFIG_CLAIM_INTERRUPT_ID_MASK) >> PLIC_TARGETCONFIG_CLAIM_INTERRUPT_ID_SHIFT)
  153. /* Bitfield definition for register of struct array TARGETCONFIG: PPS */
  154. /*
  155. * PRIORITY_PREEMPTED (RW)
  156. *
  157. * Each bit indicates if the corresponding priority level has been preempted by a higher-priority interrupt.
  158. */
  159. #define PLIC_TARGETCONFIG_PPS_PRIORITY_PREEMPTED_MASK (0xFFFFFFFFUL)
  160. #define PLIC_TARGETCONFIG_PPS_PRIORITY_PREEMPTED_SHIFT (0U)
  161. #define PLIC_TARGETCONFIG_PPS_PRIORITY_PREEMPTED_SET(x) (((uint32_t)(x) << PLIC_TARGETCONFIG_PPS_PRIORITY_PREEMPTED_SHIFT) & PLIC_TARGETCONFIG_PPS_PRIORITY_PREEMPTED_MASK)
  162. #define PLIC_TARGETCONFIG_PPS_PRIORITY_PREEMPTED_GET(x) (((uint32_t)(x) & PLIC_TARGETCONFIG_PPS_PRIORITY_PREEMPTED_MASK) >> PLIC_TARGETCONFIG_PPS_PRIORITY_PREEMPTED_SHIFT)
  163. /* PRIORITY register group index macro definition */
  164. #define PLIC_PRIORITY_PRIORITY1 (0UL)
  165. #define PLIC_PRIORITY_PRIORITY2 (1UL)
  166. #define PLIC_PRIORITY_PRIORITY3 (2UL)
  167. #define PLIC_PRIORITY_PRIORITY4 (3UL)
  168. #define PLIC_PRIORITY_PRIORITY5 (4UL)
  169. #define PLIC_PRIORITY_PRIORITY6 (5UL)
  170. #define PLIC_PRIORITY_PRIORITY7 (6UL)
  171. #define PLIC_PRIORITY_PRIORITY8 (7UL)
  172. #define PLIC_PRIORITY_PRIORITY9 (8UL)
  173. #define PLIC_PRIORITY_PRIORITY10 (9UL)
  174. #define PLIC_PRIORITY_PRIORITY11 (10UL)
  175. #define PLIC_PRIORITY_PRIORITY12 (11UL)
  176. #define PLIC_PRIORITY_PRIORITY13 (12UL)
  177. #define PLIC_PRIORITY_PRIORITY14 (13UL)
  178. #define PLIC_PRIORITY_PRIORITY15 (14UL)
  179. #define PLIC_PRIORITY_PRIORITY16 (15UL)
  180. #define PLIC_PRIORITY_PRIORITY17 (16UL)
  181. #define PLIC_PRIORITY_PRIORITY18 (17UL)
  182. #define PLIC_PRIORITY_PRIORITY19 (18UL)
  183. #define PLIC_PRIORITY_PRIORITY20 (19UL)
  184. #define PLIC_PRIORITY_PRIORITY21 (20UL)
  185. #define PLIC_PRIORITY_PRIORITY22 (21UL)
  186. #define PLIC_PRIORITY_PRIORITY23 (22UL)
  187. #define PLIC_PRIORITY_PRIORITY24 (23UL)
  188. #define PLIC_PRIORITY_PRIORITY25 (24UL)
  189. #define PLIC_PRIORITY_PRIORITY26 (25UL)
  190. #define PLIC_PRIORITY_PRIORITY27 (26UL)
  191. #define PLIC_PRIORITY_PRIORITY28 (27UL)
  192. #define PLIC_PRIORITY_PRIORITY29 (28UL)
  193. #define PLIC_PRIORITY_PRIORITY30 (29UL)
  194. #define PLIC_PRIORITY_PRIORITY31 (30UL)
  195. #define PLIC_PRIORITY_PRIORITY32 (31UL)
  196. #define PLIC_PRIORITY_PRIORITY33 (32UL)
  197. #define PLIC_PRIORITY_PRIORITY34 (33UL)
  198. #define PLIC_PRIORITY_PRIORITY35 (34UL)
  199. #define PLIC_PRIORITY_PRIORITY36 (35UL)
  200. #define PLIC_PRIORITY_PRIORITY37 (36UL)
  201. #define PLIC_PRIORITY_PRIORITY38 (37UL)
  202. #define PLIC_PRIORITY_PRIORITY39 (38UL)
  203. #define PLIC_PRIORITY_PRIORITY40 (39UL)
  204. #define PLIC_PRIORITY_PRIORITY41 (40UL)
  205. #define PLIC_PRIORITY_PRIORITY42 (41UL)
  206. #define PLIC_PRIORITY_PRIORITY43 (42UL)
  207. #define PLIC_PRIORITY_PRIORITY44 (43UL)
  208. #define PLIC_PRIORITY_PRIORITY45 (44UL)
  209. #define PLIC_PRIORITY_PRIORITY46 (45UL)
  210. #define PLIC_PRIORITY_PRIORITY47 (46UL)
  211. #define PLIC_PRIORITY_PRIORITY48 (47UL)
  212. #define PLIC_PRIORITY_PRIORITY49 (48UL)
  213. #define PLIC_PRIORITY_PRIORITY50 (49UL)
  214. #define PLIC_PRIORITY_PRIORITY51 (50UL)
  215. #define PLIC_PRIORITY_PRIORITY52 (51UL)
  216. #define PLIC_PRIORITY_PRIORITY53 (52UL)
  217. #define PLIC_PRIORITY_PRIORITY54 (53UL)
  218. #define PLIC_PRIORITY_PRIORITY55 (54UL)
  219. #define PLIC_PRIORITY_PRIORITY56 (55UL)
  220. #define PLIC_PRIORITY_PRIORITY57 (56UL)
  221. #define PLIC_PRIORITY_PRIORITY58 (57UL)
  222. #define PLIC_PRIORITY_PRIORITY59 (58UL)
  223. #define PLIC_PRIORITY_PRIORITY60 (59UL)
  224. #define PLIC_PRIORITY_PRIORITY61 (60UL)
  225. #define PLIC_PRIORITY_PRIORITY62 (61UL)
  226. #define PLIC_PRIORITY_PRIORITY63 (62UL)
  227. #define PLIC_PRIORITY_PRIORITY64 (63UL)
  228. #define PLIC_PRIORITY_PRIORITY65 (64UL)
  229. #define PLIC_PRIORITY_PRIORITY66 (65UL)
  230. #define PLIC_PRIORITY_PRIORITY67 (66UL)
  231. #define PLIC_PRIORITY_PRIORITY68 (67UL)
  232. #define PLIC_PRIORITY_PRIORITY69 (68UL)
  233. #define PLIC_PRIORITY_PRIORITY70 (69UL)
  234. #define PLIC_PRIORITY_PRIORITY71 (70UL)
  235. #define PLIC_PRIORITY_PRIORITY72 (71UL)
  236. #define PLIC_PRIORITY_PRIORITY73 (72UL)
  237. #define PLIC_PRIORITY_PRIORITY74 (73UL)
  238. #define PLIC_PRIORITY_PRIORITY75 (74UL)
  239. #define PLIC_PRIORITY_PRIORITY76 (75UL)
  240. #define PLIC_PRIORITY_PRIORITY77 (76UL)
  241. #define PLIC_PRIORITY_PRIORITY78 (77UL)
  242. #define PLIC_PRIORITY_PRIORITY79 (78UL)
  243. #define PLIC_PRIORITY_PRIORITY80 (79UL)
  244. #define PLIC_PRIORITY_PRIORITY81 (80UL)
  245. #define PLIC_PRIORITY_PRIORITY82 (81UL)
  246. #define PLIC_PRIORITY_PRIORITY83 (82UL)
  247. #define PLIC_PRIORITY_PRIORITY84 (83UL)
  248. #define PLIC_PRIORITY_PRIORITY85 (84UL)
  249. #define PLIC_PRIORITY_PRIORITY86 (85UL)
  250. #define PLIC_PRIORITY_PRIORITY87 (86UL)
  251. #define PLIC_PRIORITY_PRIORITY88 (87UL)
  252. #define PLIC_PRIORITY_PRIORITY89 (88UL)
  253. #define PLIC_PRIORITY_PRIORITY90 (89UL)
  254. #define PLIC_PRIORITY_PRIORITY91 (90UL)
  255. #define PLIC_PRIORITY_PRIORITY92 (91UL)
  256. #define PLIC_PRIORITY_PRIORITY93 (92UL)
  257. #define PLIC_PRIORITY_PRIORITY94 (93UL)
  258. #define PLIC_PRIORITY_PRIORITY95 (94UL)
  259. #define PLIC_PRIORITY_PRIORITY96 (95UL)
  260. #define PLIC_PRIORITY_PRIORITY97 (96UL)
  261. #define PLIC_PRIORITY_PRIORITY98 (97UL)
  262. #define PLIC_PRIORITY_PRIORITY99 (98UL)
  263. #define PLIC_PRIORITY_PRIORITY100 (99UL)
  264. #define PLIC_PRIORITY_PRIORITY101 (100UL)
  265. #define PLIC_PRIORITY_PRIORITY102 (101UL)
  266. #define PLIC_PRIORITY_PRIORITY103 (102UL)
  267. #define PLIC_PRIORITY_PRIORITY104 (103UL)
  268. #define PLIC_PRIORITY_PRIORITY105 (104UL)
  269. #define PLIC_PRIORITY_PRIORITY106 (105UL)
  270. #define PLIC_PRIORITY_PRIORITY107 (106UL)
  271. #define PLIC_PRIORITY_PRIORITY108 (107UL)
  272. #define PLIC_PRIORITY_PRIORITY109 (108UL)
  273. #define PLIC_PRIORITY_PRIORITY110 (109UL)
  274. #define PLIC_PRIORITY_PRIORITY111 (110UL)
  275. #define PLIC_PRIORITY_PRIORITY112 (111UL)
  276. #define PLIC_PRIORITY_PRIORITY113 (112UL)
  277. #define PLIC_PRIORITY_PRIORITY114 (113UL)
  278. #define PLIC_PRIORITY_PRIORITY115 (114UL)
  279. #define PLIC_PRIORITY_PRIORITY116 (115UL)
  280. #define PLIC_PRIORITY_PRIORITY117 (116UL)
  281. #define PLIC_PRIORITY_PRIORITY118 (117UL)
  282. #define PLIC_PRIORITY_PRIORITY119 (118UL)
  283. #define PLIC_PRIORITY_PRIORITY120 (119UL)
  284. #define PLIC_PRIORITY_PRIORITY121 (120UL)
  285. #define PLIC_PRIORITY_PRIORITY122 (121UL)
  286. #define PLIC_PRIORITY_PRIORITY123 (122UL)
  287. #define PLIC_PRIORITY_PRIORITY124 (123UL)
  288. #define PLIC_PRIORITY_PRIORITY125 (124UL)
  289. #define PLIC_PRIORITY_PRIORITY126 (125UL)
  290. #define PLIC_PRIORITY_PRIORITY127 (126UL)
  291. /* PENDING register group index macro definition */
  292. #define PLIC_PENDING_PENDING0 (0UL)
  293. #define PLIC_PENDING_PENDING1 (1UL)
  294. #define PLIC_PENDING_PENDING2 (2UL)
  295. #define PLIC_PENDING_PENDING3 (3UL)
  296. /* TRIGGER register group index macro definition */
  297. #define PLIC_TRIGGER_TRIGGER0 (0UL)
  298. #define PLIC_TRIGGER_TRIGGER1 (1UL)
  299. #define PLIC_TRIGGER_TRIGGER2 (2UL)
  300. #define PLIC_TRIGGER_TRIGGER3 (3UL)
  301. /* INTEN register group index macro definition */
  302. #define PLIC_TARGETINT_INTEN_INTEN0 (0UL)
  303. #define PLIC_TARGETINT_INTEN_INTEN1 (1UL)
  304. #define PLIC_TARGETINT_INTEN_INTEN2 (2UL)
  305. #define PLIC_TARGETINT_INTEN_INTEN3 (3UL)
  306. /* TARGETINT register group index macro definition */
  307. #define PLIC_TARGETINT_TARGET0 (0UL)
  308. #define PLIC_TARGETINT_TARGET1 (1UL)
  309. /* TARGETCONFIG register group index macro definition */
  310. #define PLIC_TARGETCONFIG_TARGET0 (0UL)
  311. #define PLIC_TARGETCONFIG_TARGET1 (1UL)
  312. #endif /* HPM_PLIC_H */