Skip to content

Commit ef12b37

Browse files
authored
feat(idl): indirect csr support (#594)
* Adds IDL support to lookup a CSR by indirect address * Removes `CSR[expression]` syntax for CSR direct address lookup * Adds generated functions to lookup by direct address and read/write looked-up CSRs * Adds a writeable field to CSR schemas (rather than depending on direct address convention) * Adds CFG option for `test:idl`. For example: ``` ./do test:idl CFG=qc_iu ``` closes #589 --------- Signed-off-by: Derek Hower <134728312+dhower-qc@users.noreply.github.com>
1 parent fda3869 commit ef12b37

File tree

124 files changed

+623
-371
lines changed

Some content is hidden

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

124 files changed

+623
-371
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ repos:
119119
rev: v5.0.2
120120
hooks:
121121
- id: reuse-lint-file
122+
exclude: COMMIT_EDITMSG
122123

123124
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
124125
rev: v9.22.0

Rakefile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,15 @@ namespace :test do
264264
puts "All files validate against their schema"
265265
end
266266

267-
task idl: ["#{$root}/.stamps/resolve-rv32.stamp", "#{$root}/.stamps/resolve-rv64.stamp"] do
268-
print "Parsing IDL code for RV32..."
269-
cfg_arch32 = cfg_arch_for("rv32")
270-
puts "done"
271-
272-
cfg_arch32.type_check
267+
task :idl do
268+
cfg = ENV["CFG"]
269+
raise "Missing CFG enviornment variable" if cfg.nil?
273270

274-
print "Parsing IDL code for RV64..."
275-
cfg_arch64 = cfg_arch_for("rv64")
271+
print "Parsing IDL code for #{cfg}..."
272+
cfg_arch = cfg_arch_for(cfg)
276273
puts "done"
277274

278-
cfg_arch64.type_check
275+
cfg_arch.type_check
279276

280277
puts "All IDL passed type checking"
281278
end
@@ -442,8 +439,14 @@ namespace :test do
442439
Rake::Task["test:lib"].invoke
443440
$logger.info "Running test:schema"
444441
Rake::Task["test:schema"].invoke
445-
$logger.info "Running test:idl"
442+
$logger.info "UPDATE: Running test:idl for rv32"
443+
ENV["CFG"] = "rv32"
444+
Rake::Task["test:idl"].invoke
445+
$logger.info "UPDATE: Running test:idl for rv64"
446+
ENV["CFG"] = "rv64"
446447
Rake::Task["test:idl"].invoke
448+
$logger.info "UPDATE: Running test:idl for qc_iu"
449+
ENV["CFG"] = "qc_iu"
447450
$logger.info "Running test:inst_encodings"
448451
Rake::Task["test:inst_encodings"].invoke
449452
$logger.info "Running test:llvm"

arch/csr/F/fcsr.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ kind: csr
55
name: fcsr
66
long_name: Floating-point control and status register (`frm` + `fflags`)
77
address: 0x003
8+
writeable: true
89
description: |
910
The floating-point control and status register, `fcsr`, is a RISC-V
1011
control and status register (CSR). It is a 32-bit read/write register

arch/csr/H/henvcfg.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $schema: "csr_schema.json#"
44
kind: csr
55
name: henvcfg
66
address: 0x60A
7+
writeable: true
78
long_name: Hypervisor Environment Configuration
89
description: |
910
The henvcfg CSR is a 64-bit read/write register that controls certain characteristics of the

arch/csr/H/henvcfgh.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $schema: "csr_schema.json#"
44
kind: csr
55
name: henvcfgh
66
address: 0x61A
7+
writeable: true
78
base: 32
89
long_name: most-significant 32 bits of Hypervisor Environment Configuration
910
description: |

arch/csr/H/hgatp.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ description: |
102102
HFENCE.GVMA instruction (see <<hfence.vma>>) before or
103103
after writing `hgatp`.
104104
address: 0x680
105+
writeable: true
105106
priv_mode: S
106107
definedBy: H
107108
length: SXLEN

arch/csr/H/htimedelta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ description: |
1515
`htimedelta` may be used to represent negative time offsets.
1616
1717
address: 0x605
18+
writeable: true
1819
priv_mode: S
1920
definedBy: H
2021
length: 64

arch/csr/H/htimedeltah.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ description: |
88
Upper half of the `htimedelta` CSR.
99
1010
address: 0x615
11+
writeable: true
1112
priv_mode: S
1213
definedBy: H
1314
length: 32

arch/csr/H/htinst.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $schema: "csr_schema.json#"
44
kind: csr
55
name: htinst
66
address: 0x64a
7+
writeable: true
78
long_name: Hypervisor Trap Instruction Register
89
description: |
910
When a trap is taken into HS-mode, mtinst is written with a value that, if nonzero,

arch/csr/H/htval.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $schema: "csr_schema.json#"
44
kind: csr
55
name: htval
66
address: 0x643
7+
writeable: true
78
long_name: Hypervisor Trap Value Register
89
description: |
910
When a trap is taken into HS-mode, htval is written with additional exception-specific information, alongside stval, to assist software in handling the trap.

0 commit comments

Comments
 (0)