Skip to content

Commit 7422231

Browse files
committed
register: add mtinst register
Adds the definition for the `mtinst` Machine trap instruction CSR.
1 parent f68a0e4 commit 7422231

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

riscv/src/register.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub mod mcause;
8888
pub mod mepc;
8989
pub mod mip;
9090
pub mod mscratch;
91+
pub mod mtinst;
9192
pub mod mtval;
9293

9394
// Machine Protection and Translation

riscv/src/register/mtinst.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//! mtinst register.
2+
3+
const MASK: usize = usize::MAX;
4+
5+
read_write_csr! {
6+
/// mtinst register
7+
Mtinst: 0x34a,
8+
mask: MASK,
9+
}
10+
11+
read_write_csr_field! {
12+
Mtinst,
13+
/// Trapped instruction `opcode` field.
14+
opcode: [0:6],
15+
}
16+
17+
read_write_csr_field! {
18+
Mtinst,
19+
/// Trapped instruction `rd` field for load instructions.
20+
rd: [7:11],
21+
}
22+
23+
read_write_csr_field! {
24+
Mtinst,
25+
/// Trapped instruction `funct3` field.
26+
funct3: [12:14],
27+
}
28+
29+
read_write_csr_field! {
30+
Mtinst,
31+
/// Trapped instruction `address offset` field.
32+
address_offset: [15:19],
33+
}
34+
35+
read_write_csr_field! {
36+
Mtinst,
37+
/// Trapped instruction `rs2` field for store instructions.
38+
rs2: [20:24],
39+
}
40+
41+
read_write_csr_field! {
42+
Mtinst,
43+
/// Trapped instruction `rl` field for atomic instructions.
44+
rl: 25,
45+
}
46+
47+
read_write_csr_field! {
48+
Mtinst,
49+
/// Trapped instruction `aq` field for atomic instructions.
50+
aq: 26,
51+
}
52+
53+
read_write_csr_field! {
54+
Mtinst,
55+
/// Trapped instruction `funct5` field for atomic instructions.
56+
funct5: [27:31],
57+
}
58+
59+
read_write_csr_field! {
60+
Mtinst,
61+
/// Trapped instruction `funct7` field for virtual machine instructions.
62+
funct7: [25:31],
63+
}
64+
65+
set!(0x34a);
66+
clear!(0x34a);

0 commit comments

Comments
 (0)