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