diff --git a/arch/README.adoc b/arch/README.adoc index 75d07d4a3..81741bf17 100644 --- a/arch/README.adoc +++ b/arch/README.adoc @@ -234,6 +234,6 @@ CSR fields are given a type, which _does not_ necessarily correspond to the WARL | *RW-RH* | Read-write, only a restricted set of values are allowed, and hardware updates the field |=== -In many cases, the values of CSR and/or CSR field data are configuration dependent. Some of that is covered directly by the data model (_e.g._, with `location_rv32`, `location_rv64`), but some cases are too complex to express with YAML. For this reason, many of the keys can be specified as IDL functions. See the schema documentation and examples in the `arch/csr` folder for more information. +In many cases, the values of CSR and/or CSR field data are configuration dependent. Some of that is covered directly by the data model (_e.g._, with `location_rv32`, `location_rv64`), but some cases are too complex to express with YAML. For this reason, many of the keys can be specified as IDL functions. See the xref:csr/schema.adoc[schema] documentation and examples in the `arch/csr` folder for more information. Some keys that only apply to certain CSRs are not shown above. diff --git a/arch/csr/mstatus.yaml b/arch/csr/mstatus.yaml index 1946daf71..889434d0c 100644 --- a/arch/csr/mstatus.yaml +++ b/arch/csr/mstatus.yaml @@ -10,7 +10,7 @@ mstatus: # MXLEN cannot change dynamically, so this will be converted to an integer # in the genrated, configuration-dependent spec length: MXLEN - + description: The mstatus register tracks and controls the hart's current operating state. definedBy: I fields: diff --git a/schemas/csr_schema.json b/schemas/csr_schema.json index b1a71751f..5b5be2907 100644 --- a/schemas/csr_schema.json +++ b/schemas/csr_schema.json @@ -186,7 +186,7 @@ }, "csr_register": { "type": "object", - "required": ["long_name", "description", "address", "priv_mode", "definedBy"], + "required": ["long_name", "length", "description", "priv_mode", "definedBy"], "properties": { "name": { @@ -199,18 +199,31 @@ "description": "When a CSR is only defined in RV32, or RV64, the base that defines it. When defined in both, this field should be absent." }, "long_name": { - "type": "string" + "type": "string", + "description": "Descriptive name for the CSR" }, "description": { - "type": "string" + "type": "string", + "description": "A full Asciidoc description of the CSR, indended to be used as documentation." }, "definedBy": { - "type": "string", - "pattern": "^([A-WY]|([SXZ][a-z]+))$" + "$ref": "schema_defs.json#/$defs/extension_name", + "description": "The extension that defines this CSR." }, "address": { "type": "integer", - "description": "CSR address" + "minValue": 0, + "maxValue": 4095, + "description": "Address of the CSR, as given to the CSR access instructions of the `Zicsr` extension" + }, + "indirect_address": { + "type": "integer", + "description": "Indirect sddress of the CSR, as given to the indirect CSRs of the `Smcsrind`/`Sscdrind` extensions" + }, + "indirect": { + "type": "boolean", + "default": false, + "description": "Whether or not the CSR is accessible via an indirect address" }, "virtual_address": true, "$comment": "Conditionally required; see below", "priv_mode": { @@ -231,6 +244,7 @@ "$ref": "#/$defs/csr_field" } }, + "description": "fields of this CSR", "additionalProperties": false }, "sw_read()": { @@ -241,20 +255,40 @@ "additionalProperties": false, "$comment": "If mode is VS, then there must be a virtual_address field", - "if": { - "properties": { - "priv_mode": { "const": "VS" } - } - }, - "then": { - "properties": { - "virtual_address": { - "type": "number", - "description": "Address of the CSR viewed from VS-mode" + "allOf": [ + { + "if": { + "properties": { + "priv_mode": { "const": "VS" } + } + }, + "then": { + "properties": { + "virtual_address": { + "type": "number", + "description": "Address of the CSR viewed from VS-mode" + } + }, + "required": ["virtual_address"] } }, - "required": ["virtual_address"] - } + { + "oneOf": [ + { + "properties": { + "indirect": { "const": false } + }, + "required": ["address"] + }, + { + "properties": { + "indirect": { "const": true } + }, + "required": ["indirect_address"] + } + ] + } + ] } },