Skip to content

Commit 248c6f0

Browse files
sudo-apt-abdullahThinkOpenly
authored andcommitted
feat: smctr csr
1 parent c735fa3 commit 248c6f0

File tree

3 files changed

+487
-0
lines changed

3 files changed

+487
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Copyright (c) Muhammad Abdullah — 10xEngineers
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# yaml-language-server: $schema=../../../../schemas/csr_schema.json
5+
6+
$schema: csr_schema.json#
7+
kind: csr
8+
name: mctrctl
9+
long_name: Machine Control Transfer Records Control Register
10+
address: 0x34E
11+
writable: true
12+
priv_mode: M
13+
length: 64
14+
definedBy: Smctr
15+
description: |
16+
The `mctrctl` register enables and configures the Control Transfer Records capability in M mode.
17+
fields:
18+
U:
19+
location: 0
20+
type: RW
21+
reset_value: UNDEFINED_LEGAL
22+
description: |
23+
Enable transfer recording in the User mode.
24+
S:
25+
location: 1
26+
type: RW
27+
reset_value: UNDEFINED_LEGAL
28+
description: |
29+
Enable transfer recording in the Supervisor mode.
30+
M:
31+
location: 2
32+
type: RW
33+
reset_value: UNDEFINED_LEGAL
34+
description: |
35+
Enable transfer recording in the Machine mode.
36+
RASEMU:
37+
location: 7
38+
type: RW
39+
reset_value: UNDEFINED_LEGAL
40+
description: |
41+
When set, it enables RAS (Return Address Stack) Emulation Mode.
42+
STE:
43+
location: 8
44+
type: RW
45+
reset_value: UNDEFINED_LEGAL
46+
description: |
47+
Enables recording of traps to S-mode when S=0.
48+
MTE:
49+
location: 9
50+
type: RW
51+
reset_value: UNDEFINED_LEGAL
52+
description: |
53+
Enables recording of traps to M-mode when M=0.
54+
BPFRZ:
55+
location: 11
56+
type: RW
57+
reset_value: UNDEFINED_LEGAL
58+
description: |
59+
Set `sctrstatus.FROZEN` on a breakpoint exception that traps to M or S mode.
60+
LCOFIFRZ:
61+
location: 12
62+
type: RW
63+
reset_value: UNDEFINED_LEGAL
64+
description: |
65+
Set `sctrstatus.FROZEN` on local-counter-overflow interrupt (LCOFI) that traps
66+
to M or S mode.
67+
definedBy: Sscofpmf
68+
EXCINH:
69+
location: 33
70+
type: RW
71+
reset_value: UNDEFINED_LEGAL
72+
description: |
73+
When set, it inhibits recording of exceptions.
74+
INTRINH:
75+
location: 34
76+
type: RW
77+
reset_value: UNDEFINED_LEGAL
78+
description: |
79+
When set, it inhibits recording of interrupts.
80+
TRETINH:
81+
location: 35
82+
type: RW
83+
reset_value: UNDEFINED_LEGAL
84+
description: |
85+
When set, it inhibits recording of trap returns.
86+
NTBREN:
87+
location: 36
88+
type: RW
89+
reset_value: UNDEFINED_LEGAL
90+
description: |
91+
When set, it enables recording of not-taken branches.
92+
TKBRINH:
93+
location: 37
94+
type: RW
95+
reset_value: UNDEFINED_LEGAL
96+
description: |
97+
When set, it inhibits recording of taken branches.
98+
INDCALLINH:
99+
location: 40
100+
type: RW
101+
reset_value: UNDEFINED_LEGAL
102+
description: |
103+
When set, it inhibits recording of indirect calls.
104+
DIRCALLINH:
105+
location: 41
106+
type: RW
107+
reset_value: UNDEFINED_LEGAL
108+
description: |
109+
When set, it inhibits recording of direct calls.
110+
INDJMPINH:
111+
location: 42
112+
type: RW
113+
reset_value: UNDEFINED_LEGAL
114+
description: |
115+
When set, it inhibits recording of indirect jumps (without linkage).
116+
DIRJMPINH:
117+
location: 43
118+
type: RW
119+
reset_value: UNDEFINED_LEGAL
120+
description: |
121+
When set, it inhibits recording of direct jumps (without linkage).
122+
CORSWAPINH:
123+
location: 44
124+
type: RW
125+
reset_value: UNDEFINED_LEGAL
126+
description: |
127+
When set, it inhibits recording of co-routine swaps.
128+
RETINH:
129+
location: 45
130+
type: RW
131+
reset_value: UNDEFINED_LEGAL
132+
description: |
133+
When set, it inhibits recording of function returns.
134+
INDLJMPINH:
135+
location: 46
136+
type: RW
137+
reset_value: UNDEFINED_LEGAL
138+
description: |
139+
When set, it inhibits recording of other indirect jumps (with linkage).
140+
DIRLJMPINH:
141+
location: 47
142+
type: RW
143+
reset_value: UNDEFINED_LEGAL
144+
description: |
145+
When set, it inhibits recording of other direct jumps (with linkage).
146+
CUSTOM:
147+
location: 63-60
148+
type: RW
149+
reset_value: UNDEFINED_LEGAL
150+
description: |
151+
WARL bits designated for custom use. The value 0 must correspond to standard behavior.
152+
sw_read(): |
153+
Bits<12> mctrctl_addr = 0x34E;
154+
Bits<64> mctrctl_mask = 0x787F9F80000FC7;
155+
Csr csr_handle = direct_csr_lookup(mctrctl_addr);
156+
if (!csr_handle.valid) {
157+
unimplemented_csr($encoding);
158+
}
159+
return (CSR[mctrctl] & mctrctl_mask);
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Copyright (c) Muhammad Abdullah — 10xEngineers
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# yaml-language-server: $schema=../../../../schemas/csr_schema.json
5+
6+
$schema: csr_schema.json#
7+
kind: csr
8+
name: sctrctl
9+
long_name: Supervisor Control Transfer Records Control Register
10+
address: 0x14E
11+
writable: true
12+
priv_mode: S
13+
length: 64
14+
definedBy: Smctr
15+
description: The `sctrctl` register enables and configures the Control Transfer Records capability in S mode.
16+
fields:
17+
U:
18+
location: 0
19+
type: RW
20+
alias: mctrctl.U
21+
reset_value: UNDEFINED_LEGAL
22+
description: |
23+
Enable transfer recording in the User mode.
24+
S:
25+
location: 1
26+
type: RW
27+
alias: mctrctl.S
28+
reset_value: UNDEFINED_LEGAL
29+
description: |
30+
Enable transfer recording in the Supervisor mode.
31+
RASEMU:
32+
location: 7
33+
type: RW
34+
alias: mctrctl.RASEMU
35+
reset_value: UNDEFINED_LEGAL
36+
description: |
37+
When set, it enables RAS (Return Address Stack) Emulation Mode.
38+
STE:
39+
location: 8
40+
type: RW
41+
alias: mctrctl.STE
42+
reset_value: UNDEFINED_LEGAL
43+
description: |
44+
Enables recording of traps to S-mode when S=0.
45+
BPFRZ:
46+
location: 11
47+
type: RW
48+
alias: mctrctl.BPFRZ
49+
reset_value: UNDEFINED_LEGAL
50+
description: |
51+
Set `sctrstatus.FROZEN` on a breakpoint exception that traps to M or S mode.
52+
LCOFIFRZ:
53+
location: 12
54+
type: RW
55+
alias: mctrctl.LCOFIFRZ
56+
reset_value: UNDEFINED_LEGAL
57+
description: |
58+
Set `sctrstatus.FROZEN` on local-counter-overflow interrupt (LCOFI) that traps
59+
to M or S mode.
60+
definedBy: Sscofpmf
61+
EXCINH:
62+
location: 33
63+
type: RW
64+
alias: mctrctl.EXCINH
65+
reset_value: UNDEFINED_LEGAL
66+
description: |
67+
When set, it inhibits recording of exceptions.
68+
INTRINH:
69+
location: 34
70+
type: RW
71+
alias: mctrctl.INTRINH
72+
reset_value: UNDEFINED_LEGAL
73+
description: |
74+
When set, it inhibits recording of interrupts.
75+
TRETINH:
76+
location: 35
77+
type: RW
78+
alias: mctrctl.TRETINH
79+
reset_value: UNDEFINED_LEGAL
80+
description: |
81+
When set, it inhibits recording of trap returns.
82+
NTBREN:
83+
location: 36
84+
type: RW
85+
alias: mctrctl.NTBREN
86+
reset_value: UNDEFINED_LEGAL
87+
description: |
88+
When set, it enables recording of not-taken branches.
89+
TKBRINH:
90+
location: 37
91+
type: RW
92+
alias: mctrctl.TKBRINH
93+
reset_value: UNDEFINED_LEGAL
94+
description: |
95+
When set, it inhibits recording of taken branches.
96+
INDCALLINH:
97+
location: 40
98+
type: RW
99+
alias: mctrctl.INDCALLINH
100+
reset_value: UNDEFINED_LEGAL
101+
description: |
102+
When set, it inhibits recording of indirect calls.
103+
DIRCALLINH:
104+
location: 41
105+
type: RW
106+
alias: mctrctl.DIRCALLINH
107+
reset_value: UNDEFINED_LEGAL
108+
description: |
109+
When set, it inhibits recording of direct calls.
110+
INDJMPINH:
111+
location: 42
112+
type: RW
113+
alias: mctrctl.INDJMPINH
114+
reset_value: UNDEFINED_LEGAL
115+
description: |
116+
When set, it inhibits recording of indirect jumps (without linkage).
117+
DIRJMPINH:
118+
location: 43
119+
type: RW
120+
alias: mctrctl.DIRJMPINH
121+
reset_value: UNDEFINED_LEGAL
122+
description: |
123+
When set, it inhibits recording of direct jumps (without linkage).
124+
CORSWAPINH:
125+
location: 44
126+
type: RW
127+
alias: mctrctl.CORSWAPINH
128+
reset_value: UNDEFINED_LEGAL
129+
description: |
130+
When set, it inhibits recording of co-routine swaps.
131+
RETINH:
132+
location: 45
133+
type: RW
134+
alias: mctrctl.RETINH
135+
reset_value: UNDEFINED_LEGAL
136+
description: |
137+
When set, it inhibits recording of function returns.
138+
INDLJMPINH:
139+
location: 46
140+
type: RW
141+
alias: mctrctl.INDLJMPINH
142+
reset_value: UNDEFINED_LEGAL
143+
description: |
144+
When set, it inhibits recording of other indirect jumps (with linkage).
145+
DIRLJMPINH:
146+
location: 47
147+
type: RW
148+
alias: mctrctl.DIRLJMPINH
149+
reset_value: UNDEFINED_LEGAL
150+
description: |
151+
When set, it inhibits recording of other direct jumps (with linkage).
152+
CUSTOM:
153+
location: 63-60
154+
type: RW
155+
alias: mctrctl.CUSTOM
156+
reset_value: UNDEFINED_LEGAL
157+
description: |
158+
WARL bits designated for custom use. The value 0 must correspond to standard behavior.
159+
sw_read(): |
160+
Bits<12> sctrctl_addr = 0x14E;
161+
Bits<64> sctrctl_mask = 0x787F9F80000DC3;
162+
Csr csr_handle = direct_csr_lookup(sctrctl_addr);
163+
if (!csr_handle.valid) {
164+
unimplemented_csr($encoding);
165+
}
166+
return (CSR[mctrctl] & sctrctl_mask);

0 commit comments

Comments
 (0)