Skip to content

Commit b2005b4

Browse files
committed
Merge branch 'main' into H_CSRs
2 parents 78cda11 + faf7646 commit b2005b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2176
-381
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@
111111
},
112112
{
113113
"type": "rdbg",
114-
"name": "RVA20",
114+
"name": "RVI20",
115115
"request": "launch",
116116
"command": "bundle exec rake",
117-
"script": "gen:profile_release_pdf[RVA20]",
117+
"script": "gen:profile_release_pdf[RVI20]",
118118
"args": [],
119119
"askParameters": false
120120
},

Rakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,15 @@ file "#{$root}/arch/csr/S/scounteren.yaml" => [
388388
File.write(t.name, insert_warning(erb.result(binding), t.prerequisites.first))
389389
end
390390

391+
file "#{$root}/arch/csr/Sscofpmf/scountovf.yaml" => [
392+
"#{$root}/arch/csr/Sscofpmf/scountovf.layout",
393+
__FILE__
394+
] do |t|
395+
erb = ERB.new(File.read($root / "arch/csr/Sscofpmf/scountovf.layout"), trim_mode: "-")
396+
erb.filename = "#{$root}/arch/csr/Sscofpmf/scountovf.layout"
397+
File.write(t.name, insert_warning(erb.result(binding), t.prerequisites.first))
398+
end
399+
391400
file "#{$root}/arch/csr/H/hcounteren.yaml" => [
392401
"#{$root}/arch/csr/H/hcounteren.layout",
393402
__FILE__
@@ -421,6 +430,7 @@ namespace :gen do
421430

422431
Rake::Task["#{$root}/arch/csr/I/mcounteren.yaml"].invoke
423432
Rake::Task["#{$root}/arch/csr/S/scounteren.yaml"].invoke
433+
Rake::Task["#{$root}/arch/csr/Sscofpmf/scountovf.yaml"].invoke
424434
Rake::Task["#{$root}/arch/csr/H/hcounteren.yaml"].invoke
425435
Rake::Task["#{$root}/arch/csr/Zicntr/mcountinhibit.yaml"].invoke
426436

arch/csr/H/vsie.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ definedBy: H
3939
length: VSXLEN
4040

4141
sw_read(): |
42-
let value = 0;
42+
Bits<64> value = 0;
4343
if (CSR[hideleg][2]) {
4444
value |= (CSR[hie].VSSIE[0] << 1);
4545
}

arch/csr/Sscofpmf/scountovf.layout

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
2+
3+
$schema: csr_schema.json#
4+
kind: csr
5+
name: scountovf
6+
long_name: Supervisor Count Overflow
7+
address: 0xDA0
8+
priv_mode: S
9+
length: 32
10+
definedBy: Sscofpmf
11+
description: |
12+
A 32-bit read-only register that contains shadow copies of the OF bits in the 29 `mhpmevent` CSRs
13+
(`mhpmevent3` - `mhpmevent31`) — where `scountovf` bit X corresponds to `mhpmeventX`.
14+
15+
This register enables supervisor-level overflow interrupt handler
16+
software to quickly and easily determine which counter(s) have overflowed
17+
without needing to make an execution environment call up to M-mode.
18+
19+
Read access to bit X is subject to the same `mcounteren` (or `mcounteren` and `hcounteren`)
20+
CSRs that mediate access to the `hpmcounter` CSRs by S-mode (or VS-mode).
21+
22+
In M-mode, `scountovf` bit X is always readable.
23+
In S/HS-mode, `scountovf` bit X is readable when `mcounteren` bit X is set, and otherwise reads as zero.
24+
Similarly, in VS-mode, it is readable when both `mcounteren` and `hcounteren` bit X are set.
25+
26+
fields:
27+
<%- (3..31).each do |of_num| -%>
28+
OF<%= of_num %>:
29+
alias: mhpmevent<%= of_num %>.OF
30+
location: <%= of_num %>
31+
description: |
32+
[when="HPM_COUNTER_EN[<%= of_num %>] == true"]
33+
Shadow copy of mhpmevent<%= of_num %> overflow (OF) bit.
34+
35+
[when="HPM_COUNTER_EN[<%= of_num %>] == false"]
36+
This field is read-only zero because the counter is not enabled.
37+
type(): |
38+
return HPM_COUNTER_EN[<%= of_num %>] ? CsrFieldType::RO : CsrFieldType::ROH;
39+
reset_value(): |
40+
return HPM_COUNTER_EN[<%= of_num %>] ? UNDEFINED_LEGAL : 0;
41+
<%- end -%>
42+
43+
sw_read(): |
44+
Bits<32> mask;
45+
if (mode() == PrivilegeMode::VS) {
46+
# In VS-mode, scountovf.OFX access is determined by mcounteren/hcounteren
47+
mask = $bits(CSR[mcounteren]) & $bits(CSR[hcounteren]);
48+
} else {
49+
# In M-mode and S-mode, scountovf.OFX access is determined by mcounteren/scounteren
50+
mask = $bits(CSR[mcounteren]) & $bits(CSR[scounteren]);
51+
}
52+
53+
Bits<32> value = 0;
54+
<%- (3..31).each do |num| -%>
55+
value = value | (CSR[mhpmevent<%= num %>].OF << <%= num %>);
56+
<%- end -%>
57+
58+
return value & mask;

0 commit comments

Comments
 (0)