Skip to content

Commit abcd342

Browse files
feat(csr): add YAML file for Ssqosid:srmcfg
1 parent 9484dc9 commit abcd342

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

arch/csr/Ssqosid/srmcfg.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,40 @@ fields:
108108
description: |
109109
The `MCID` is used to identify a counter to monitor resource usage.
110110
reset_value: UNDEFINED_LEGAL
111+
sw_write(csr_value): |
112+
if (implemented?(ExtensionName::Smstateen)) {
113+
if (mode() < PrivilegeMode::M && CSR[mstateen0].SRMCFG == 0) {
114+
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
115+
}
116+
if (virtual_mode?() && CSR[mstateen0].SRMCFG == 1) {
117+
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
118+
}
119+
} else {
120+
if (virtual_mode?()) {
121+
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
122+
}
123+
}
124+
value = csr_value;
125+
126+
rcid_mask = 0xFFF
127+
mcid_mask = 0xFFF
128+
129+
rcid = csr_value & rcid_mask
130+
mcid = (csr_value >> 16) & mcid_mask
131+
132+
value = (mcid << 16) | rcid
133+
134+
sw_read(): |
135+
if (implemented?(ExtensionName::Smstateen)) {
136+
if (mode() < PrivilegeMode::M && CSR[mstateen0].SRMCFG == 0) {
137+
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
138+
}
139+
if (virtual_mode?() && CSR[mstateen0].SRMCFG == 1) {
140+
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
141+
}
142+
} else {
143+
if (virtual_mode?()) {
144+
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
145+
}
146+
}
147+
return value;

0 commit comments

Comments
 (0)