File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff 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;
You can’t perform that action at this time.
0 commit comments