1#![allow(non_camel_case_types)]
6
7use super::CsrEncoding;
11use crate::{Ro, RwSafe, RwUnsafe};
12
13macro_rules! for_each_encoding {
20 ($macro:path) => {
21 $macro!(fflags, 0x001, RwSafe);
26 $macro!(frm, 0x002, RwSafe);
27 $macro!(fcsr, 0x003, RwSafe);
28
29 $macro!(vstart, 0x008, RwSafe);
34 $macro!(vxsat, 0x009, RwSafe);
35 $macro!(vxrm, 0x00a, RwSafe);
36 $macro!(vcsr, 0x00f, RwSafe);
37 $macro!(vl, 0xc20, Ro);
38 $macro!(vtype, 0xc21, Ro);
39 $macro!(vlenb, 0xc22, Ro);
40
41 $macro!(ssp, 0x011, RwUnsafe);
47
48 $macro!(seed, 0x015, RwSafe);
53
54 $macro!(jvt, 0x017, RwUnsafe);
60
61 $macro!(cycle, 0xc00, Ro);
66 $macro!(time, 0xc01, Ro);
67 $macro!(instret, 0xc02, Ro);
68 $macro!(hpmcounter3, 0xc03, Ro);
69 $macro!(hpmcounter4, 0xc04, Ro);
70 $macro!(hpmcounter31, 0xc1f, Ro);
71 $macro!(cycleh, 0xc80, Ro);
72 $macro!(timeh, 0xc81, Ro);
73 $macro!(instreth, 0xc82, Ro);
74 $macro!(hpmcounter3h, 0xc83, Ro);
75 $macro!(hpmcounter4h, 0xc84, Ro);
76 $macro!(hpmcounter31h, 0xc9f, Ro);
77
78 $macro!(sstatus, 0x100, RwSafe);
83 $macro!(sie, 0x104, RwSafe);
84 $macro!(stvec, 0x105, RwSafe);
85 $macro!(scounteren, 0x106, RwSafe);
86
87 $macro!(senvcfg, 0x10a, RwSafe);
92
93 $macro!(scountinhibit, 0x120, RwSafe);
98
99 $macro!(sscratch, 0x140, RwSafe);
104 $macro!(sepc, 0x141, RwUnsafe);
106
107 $macro!(scause, 0x142, RwSafe);
108 $macro!(stval, 0x143, RwSafe);
109 $macro!(sip, 0x144, RwSafe);
110 $macro!(scountovf, 0xda0, Ro);
111
112 $macro!(siselect, 0x150, RwSafe);
117 $macro!(sireg, 0x151, RwSafe);
118 $macro!(sireg2, 0x152, RwSafe);
119 $macro!(sireg3, 0x153, RwSafe);
120 $macro!(sireg4, 0x155, RwSafe);
121 $macro!(sireg5, 0x156, RwSafe);
122 $macro!(sireg6, 0x157, RwSafe);
123
124 $macro!(satp, 0x180, RwUnsafe);
130
131 $macro!(stimecmp, 0x14d, RwSafe);
136 $macro!(stimecmph, 0x15d, RwSafe);
137
138 $macro!(scontext, 0x5a8, RwSafe);
143
144 $macro!(srmcfg, 0x181, RwSafe);
149
150 $macro!(sstateen0, 0x10c, RwSafe);
155 $macro!(sstateen1, 0x10d, RwSafe);
156 $macro!(sstateen2, 0x10e, RwSafe);
157 $macro!(sstateen3, 0x10f, RwSafe);
158
159 $macro!(sctrctl, 0x14e, RwSafe);
164 $macro!(sctrstatus, 0x14f, RwSafe);
165 $macro!(sctrdepth, 0x15f, RwSafe);
166
167 $macro!(hstatus, 0x600, RwSafe);
172 $macro!(hedeleg, 0x602, RwSafe);
173 $macro!(hideleg, 0x603, RwSafe);
174 $macro!(hie, 0x604, RwSafe);
175 $macro!(hcounteren, 0x606, RwSafe);
176 $macro!(hgeie, 0x607, RwSafe);
177 $macro!(hedelegh, 0x612, RwSafe);
178
179 $macro!(htval, 0x643, RwSafe);
184 $macro!(hip, 0x644, RwSafe);
185 $macro!(hvip, 0x645, RwSafe);
186 $macro!(htinst, 0x64a, RwSafe);
187 $macro!(hgeip, 0xe12, Ro);
188
189 $macro!(henvcfg, 0x60a, RwSafe);
194 $macro!(henvcfgh, 0x61a, RwSafe);
195
196 $macro!(hgatp, 0x680, RwSafe);
203
204 $macro!(hcontext, 0x6a8, RwSafe);
209
210 $macro!(htimedelta, 0x605, RwSafe);
215 $macro!(htimedeltah, 0x615, RwSafe);
216
217 $macro!(hstateen0, 0x60c, RwSafe);
222 $macro!(hstateen1, 0x60d, RwSafe);
223 $macro!(hstateen2, 0x60e, RwSafe);
224 $macro!(hstateen3, 0x60f, RwSafe);
225 $macro!(hstateen0h, 0x61c, RwSafe);
226 $macro!(hstateen1h, 0x61d, RwSafe);
227 $macro!(hstateen2h, 0x61e, RwSafe);
228 $macro!(hstateen3h, 0x61f, RwSafe);
229
230 $macro!(vsstatus, 0x200, RwSafe);
235 $macro!(vsie, 0x204, RwSafe);
236 $macro!(vstvec, 0x205, RwSafe);
237 $macro!(vsscratch, 0x240, RwSafe);
238
239 $macro!(vsepc, 0x241, RwUnsafe);
241 $macro!(vscause, 0x242, RwSafe);
242 $macro!(vstval, 0x243, RwSafe);
243 $macro!(vsip, 0x244, RwSafe);
244
245 $macro!(vsatp, 0x280, RwUnsafe);
247
248 $macro!(vsiselect, 0x250, RwSafe);
253 $macro!(vsireg, 0x251, RwSafe);
254 $macro!(vsireg2, 0x252, RwSafe);
255 $macro!(vsireg3, 0x253, RwSafe);
256 $macro!(vsireg4, 0x255, RwSafe);
257 $macro!(vsireg5, 0x256, RwSafe);
258 $macro!(vsireg6, 0x257, RwSafe);
259
260 $macro!(vstimecmp, 0x24d, RwSafe);
265 $macro!(vstimecmph, 0x25d, RwSafe);
266
267 $macro!(vsctrctl, 0x24e, RwSafe);
272
273 $macro!(mvendorid, 0xf11, Ro);
278 $macro!(marchid, 0xf12, Ro);
279 $macro!(mimpid, 0xf13, Ro);
280 $macro!(mhartid, 0xf14, Ro);
281 $macro!(mconfigptr, 0xf15, Ro);
282
283 $macro!(mstatus, 0x300, RwSafe);
288 $macro!(misa, 0x301, RwSafe);
289 $macro!(medeleg, 0x302, RwSafe);
290 $macro!(mideleg, 0x303, RwSafe);
291 $macro!(mie, 0x304, RwSafe);
292 $macro!(mtvec, 0x305, RwSafe);
293 $macro!(mcounteren, 0x306, RwSafe);
294 $macro!(mstatush, 0x310, RwSafe);
295 $macro!(medelegh, 0x312, RwSafe);
296
297 $macro!(mscratch, 0x340, RwSafe);
302
303 $macro!(mepc, 0x341, RwUnsafe);
305 $macro!(mcause, 0x342, RwSafe);
306 $macro!(mtval, 0x343, RwSafe);
307 $macro!(mip, 0x344, RwSafe);
308 $macro!(mtinst, 0x34a, RwSafe);
309 $macro!(mtval2, 0x34b, RwSafe);
310
311 $macro!(miselect, 0x350, RwSafe);
316 $macro!(mireg, 0x351, RwSafe);
317 $macro!(mireg2, 0x352, RwSafe);
318 $macro!(mireg3, 0x353, RwSafe);
319 $macro!(mireg4, 0x355, RwSafe);
320 $macro!(mireg5, 0x356, RwSafe);
321 $macro!(mireg6, 0x357, RwSafe);
322
323 $macro!(menvcfg, 0x30a, RwSafe);
328 $macro!(menvcfgh, 0x31a, RwSafe);
329 $macro!(mseccfg, 0x747, RwSafe);
330 $macro!(mseccfgh, 0x757, RwSafe);
331
332 $macro!(pmpcfg0, 0x3a0, RwSafe);
337 $macro!(pmpcfg1, 0x3a1, RwSafe);
338 $macro!(pmpcfg2, 0x3a2, RwSafe);
339 $macro!(pmpcfg3, 0x3a3, RwSafe);
340 $macro!(pmpcfg14, 0x3ae, RwSafe);
341 $macro!(pmpcfg15, 0x3af, RwSafe);
342 $macro!(pmpaddr0, 0x3b0, RwSafe);
343 $macro!(pmpaddr1, 0x3b1, RwSafe);
344 $macro!(pmpaddr63, 0x3ef, RwSafe);
345
346 $macro!(mstateen0, 0x30c, RwSafe);
351 $macro!(mstateen1, 0x30d, RwSafe);
352 $macro!(mstateen2, 0x30e, RwSafe);
353 $macro!(mstateen3, 0x30f, RwSafe);
354 $macro!(mstateen0h, 0x31c, RwSafe);
355 $macro!(mstateen1h, 0x31d, RwSafe);
356 $macro!(mstateen2h, 0x31e, RwSafe);
357 $macro!(mstateen3h, 0x31f, RwSafe);
358
359 $macro!(mnscratch, 0x740, RwSafe);
364
365 $macro!(mnepc, 0x741, RwUnsafe);
367
368 $macro!(mncause, 0x742, RwSafe);
369 $macro!(mnstatus, 0x744, RwSafe);
370
371 $macro!(mcycle, 0xb00, RwSafe);
376 $macro!(minstret, 0xb02, RwSafe);
377 $macro!(mhpmcounter3, 0xb03, RwSafe);
378 $macro!(mhpmcounter4, 0xb04, RwSafe);
379 $macro!(mhpmcounter31, 0xb1f, RwSafe);
380 $macro!(mcycleh, 0xb80, RwSafe);
381 $macro!(minstreth, 0xb82, RwSafe);
382 $macro!(mhpmcounter3h, 0xb83, RwSafe);
383 $macro!(mhpmcounter4h, 0xb84, RwSafe);
384 $macro!(mhpmcounter31h, 0xb9f, RwSafe);
385
386 $macro!(mcountinhibit, 0x320, RwSafe);
391 $macro!(mcyclecfg, 0x321, RwSafe);
392 $macro!(minstretcfg, 0x322, RwSafe);
393 $macro!(mhpmevent3, 0x323, RwSafe);
394 $macro!(mhpmevent4, 0x324, RwSafe);
395 $macro!(mhpmevent31, 0x33f, RwSafe);
396 $macro!(mcyclecfgh, 0x721, RwSafe);
397 $macro!(minstretcfgh, 0x722, RwSafe);
398 $macro!(mhpmevent3h, 0x723, RwSafe);
399 $macro!(mhpmevent4h, 0x724, RwSafe);
400 $macro!(mhpmevent31h, 0x73f, RwSafe);
401
402 $macro!(mctrctl, 0x34e, RwSafe);
407
408 $macro!(tselect, 0x7a0, RwSafe);
413 $macro!(tdata1, 0x7a1, RwSafe);
414 $macro!(tdata2, 0x7a2, RwSafe);
415 $macro!(tdata3, 0x7a3, RwSafe);
416 $macro!(mcontext, 0x7a8, RwSafe);
417
418 $macro!(dcsr, 0x7b0, RwSafe);
423
424 $macro!(dpc, 0x7b1, RwUnsafe);
426
427 $macro!(dscratch0, 0x7b2, RwSafe);
428 $macro!(dscratch1, 0x7b3, RwSafe);
429 };
430}
431
432macro_rules! define_encoding {
433 ($name:ident, $encoding:literal, $access:ty) => {
434 pub type $name = CsrEncoding<$encoding, $access>;
435 };
436}
437
438for_each_encoding!(define_encoding);