Skip to content

Commit 82d1340

Browse files
author
Derek Hower
committed
Change certificate class schema
1 parent 7c9e587 commit 82d1340

File tree

9 files changed

+116
-59
lines changed

9 files changed

+116
-59
lines changed

arch/certificate_class/MC.yaml

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
1-
MC:
2-
name: MC
3-
long_name: Microcontroller Certificate Class
1+
# yaml-language-server: $schema=../../schemas/cert_class_schema.json
42

5-
introduction: |
6-
This certification class specifies requirements for microcontrollers.
7-
It targets microcontrollers running low-level software on an RTOS or bare-metal.
8-
This CRD is not intended for the smallest possible microcontrollers but rather for applications
9-
benefiting from a standardized microcontroller.
10-
See the https://docs.google.com/document/d/133SZKc18tLsQcT1o6gEmBUkjwrtg2ow63me54RQ1jiY[RISC-V CRDs]
11-
document for information relevant to all RISC-V CRDs.
3+
$schema: cert_class_schema.json#
4+
kind: certificate class
5+
name: MC
6+
long_name: Microcontroller Certificate Class
127

13-
naming_scheme: |
14-
The MC (M = Microcontroller, C = Certificate) has the following naming scheme (suffixes after MC
15-
are optional but in the below order):
8+
introduction: |
9+
This certification class specifies requirements for microcontrollers.
10+
It targets microcontrollers running low-level software on an RTOS or bare-metal.
11+
This CRD is not intended for the smallest possible microcontrollers but rather for applications
12+
benefiting from a standardized microcontroller.
13+
See the https://docs.google.com/document/d/133SZKc18tLsQcT1o6gEmBUkjwrtg2ow63me54RQ1jiY[RISC-V CRDs]
14+
document for information relevant to all RISC-V CRDs.
1615
17-
MC<model>[v<version>]
16+
naming_scheme: |
17+
The MC (M = Microcontroller, C = Certificate) has the following naming scheme (suffixes after MC
18+
are optional but in the below order):
1819
19-
Where:
20+
MC<model>[v<version>]
2021
21-
* Left & right square braces denote optional.
22-
* \<model> is a 3 digit integer. It is changed only when mandatory extensions are added to a CRD.
23-
** The one's digit is incremented when a small mandatory extension is added (e.g., Zicond)
24-
** The ten's digit is incremented when a medium mandatory extension is addded (e.g., PMP)
25-
** The hundreds's digit is incremented when a large mandatory extension is addded (e.g., V or H)
26-
* \<version> is a semantic version (see semver.org) formatted as <major>[.<minor>.[patch]]. If \<version> is omitted, the reference applies equally to all versions.
27-
** A <major> release indicates support for a new optional extension.
28-
** A <minor> release indicates one or more of the following changes to the certification tests associated with the CRD.
29-
*** Fix test bug or increase test coverage
30-
*** Add more allowed parameter values
31-
*** Support new extension version
32-
** A <patch> release indicates just CRD specification changes without any difference in functional behavior
22+
Where:
3323
34-
mandatory_priv_modes:
35-
- M
24+
* Left & right square braces denote optional.
25+
* \<model> is a 3 digit integer. It is changed only when mandatory extensions are added to a CRD.
26+
** The one's digit is incremented when a small mandatory extension is added (e.g., Zicond)
27+
** The ten's digit is incremented when a medium mandatory extension is addded (e.g., PMP)
28+
** The hundreds's digit is incremented when a large mandatory extension is addded (e.g., V or H)
29+
* \<version> is a semantic version (see semver.org) formatted as <major>[.<minor>.[patch]]. If \<version> is omitted, the reference applies equally to all versions.
30+
** A <major> release indicates support for a new optional extension.
31+
** A <minor> release indicates one or more of the following changes to the certification tests associated with the CRD.
32+
*** Fix test bug or increase test coverage
33+
*** Add more allowed parameter values
34+
*** Support new extension version
35+
** A <patch> release indicates just CRD specification changes without any difference in functional behavior
36+
37+
mandatory_priv_modes:
38+
- M
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
MockCertificateClass:
2-
name: MockCertificateClass
3-
long_name: Mock Certificate Class Long Name
1+
# yaml-language-server: $schema=../../schemas/cert_class_schema.json
42

5-
introduction: |
6-
Here's the Mock Certificate Class introduction.
3+
$schema: cert_class_schema.json#
4+
kind: certificate class
5+
name: MockCertificateClass
6+
long_name: Mock Certificate Class Long Name
77

8-
naming_scheme: |
9-
Here's the Mock Certificate Class naming scheme.
8+
introduction: |
9+
Here's the Mock Certificate Class introduction.
1010
11-
mandatory_priv_modes:
12-
- M
11+
naming_scheme: |
12+
Here's the Mock Certificate Class naming scheme.
1313
14-
description: Here's the Mock Certificate Class description.
14+
mandatory_priv_modes:
15+
- M

backends/arch_gen/lib/arch_gen.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,11 @@ def gen_arch_def
296296
profile_release_obj[profile_release_name]["__source"] = f
297297
[profile_release_name, profile_release_obj[profile_release_name]]
298298
end.to_h
299-
cert_class_hash = Dir.glob($root / "arch" / "certificate_class" / "**" / "*.yaml").map do |f|
299+
cert_class_ary = Dir.glob($root / "arch" / "certificate_class" / "**" / "*.yaml").map do |f|
300300
cert_class_obj = YamlLoader.load(f, permitted_classes:[Date])
301-
cert_class_name = cert_class_obj.keys[0]
302-
cert_class_obj[cert_class_name]["name"] = cert_class_name
303-
cert_class_obj[cert_class_name]["__source"] = f
304-
[cert_class_name, cert_class_obj[cert_class_name]]
305-
end.to_h
301+
cert_class_obj["__source"] = f
302+
cert_class_obj
303+
end
306304
cert_model_hash = Dir.glob($root / "arch" / "certificate_model" / "**" / "*.yaml").map do |f|
307305
cert_model_obj = YamlLoader.load(f, permitted_classes:[Date])
308306
cert_model_name = cert_model_obj.keys[0]
@@ -342,7 +340,7 @@ def gen_arch_def
342340
"implemented_csrs" => @implemented_csrs,
343341
"profile_classes" => profile_class_hash,
344342
"profile_releases" => profile_release_hash,
345-
"certificate_classes" => cert_class_hash,
343+
"certificate_classes" => cert_class_ary,
346344
"certificate_models" => cert_model_hash,
347345
"manuals" => manual_hash
348346
}

backends/arch_gen/tasks.rake

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ file "#{$root}/.stamps/arch-gen.stamp" => (
3434
] + Dir.glob($root / "arch" / "**" / "*.yaml")
3535
) do |t|
3636
csr_ary = Dir.glob($root / "arch" / "csr" / "**" / "*.yaml").map do |f|
37-
puts f
3837
csr_obj = YamlLoader.load(f, permitted_classes:[Date])
3938
csr_obj["fields"].map do |k, v|
4039
v["name"] = k
@@ -67,13 +66,11 @@ puts f
6766
profile_release_obj[profile_release_name]["__source"] = f
6867
[profile_release_name, profile_release_obj[profile_release_name]]
6968
end.to_h
70-
cert_class_hash = Dir.glob($root / "arch" / "certificate_class" / "**" / "*.yaml").map do |f|
69+
cert_class_ary = Dir.glob($root / "arch" / "certificate_class" / "**" / "*.yaml").map do |f|
7170
cert_class_obj = YamlLoader.load(f, permitted_classes:[Date])
72-
cert_class_name = cert_class_obj.keys[0]
73-
cert_class_obj[cert_class_name]["name"] = cert_class_name
74-
cert_class_obj[cert_class_name]["__source"] = f
75-
[cert_class_name, cert_class_obj[cert_class_name]]
76-
end.to_h
71+
cert_class_obj["__source"] = f
72+
cert_class_obj
73+
end
7774
cert_model_hash = Dir.glob($root / "arch" / "certificate_model" / "**" / "*.yaml").map do |f|
7875
cert_model_obj = YamlLoader.load(f, permitted_classes:[Date])
7976
cert_model_name = cert_model_obj.keys[0]
@@ -109,7 +106,7 @@ puts f
109106
"csrs" => csr_ary,
110107
"profile_classes" => profile_class_hash,
111108
"profile_releases" => profile_release_hash,
112-
"certificate_classes" => cert_class_hash,
109+
"certificate_classes" => cert_class_ary,
113110
"certificate_models" => cert_model_hash,
114111
"manuals" => manual_hash
115112
}

lib/arch_def.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ def unconfigured_data
10521052
"profile_classes" => profile_classes.map { |f| [f.name, f.data] }.to_h,
10531053
"profile_releases" => profile_releases.map { |p| [p.name, p.data] }.to_h,
10541054
"manuals" => manuals.map { |m| [m.name, m.data] }.to_h,
1055-
"certificate_classes" => cert_classes.map { |f| [f.name, f.data] }.to_h,
1055+
"certificate_classes" => cert_classes.map(&:data),
10561056
"certificate_models" => cert_models.map { |c| [c.name, c.data] }.to_h
10571057
}
10581058
end

lib/validate.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class Validator
2222
ext: $root / "schemas" / "ext_schema.json",
2323
csr: $root / "schemas" / "csr_schema.json",
2424
cfg_impl_ext: $root / "schemas" / "implemented_exts_schema.json",
25-
manual_version: $root / "schemas" / "manual_version_schema.json"
25+
manual_version: $root / "schemas" / "manual_version_schema.json",
26+
cert_class: $root / "schemas" / "cert_class_schema.json"
2627
}.freeze
2728

2829
# types of objects that can be validated
@@ -196,6 +197,8 @@ def validate(path, type: nil)
196197
type = :csr
197198
when %r{.*arch/manual/.*/.*contents\.yaml$}
198199
type = :manual_version
200+
when %r{.*arch/certificate_class/.*\.yaml$}
201+
type = :cert_class
199202
else
200203
warn "Cannot determine type from YAML path '#{path}'; skipping"
201204
return
@@ -204,8 +207,8 @@ def validate(path, type: nil)
204207
begin
205208
obj = validate_str(File.read(path.to_s), path:, type:, schema_path:)
206209

207-
# check that the top key matches the filename
208-
if [:inst, :csr, :ext].include?(type) && obj["name"] != File.basename(path, ".yaml").to_s
210+
# check that the name matches the filename
211+
if [:inst, :csr, :ext, :cert_class].include?(type) && obj["name"] != File.basename(path, ".yaml").to_s
209212
raise ValidationError, "In #{path}, object name '#{obj.keys.first}' does not match filename '#{File.basename(path)}'"
210213
end
211214
obj

schemas/arch_schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@
118118
"type": "object"
119119
},
120120
"certificate_classes": {
121-
"type": "object"
121+
"type": "array",
122+
"items": {
123+
"$ref": "cert_class_schema.json#"
124+
}
122125
},
123126
"certificate_models": {
124127
"type": "object"

schemas/cert_class_schema.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
4+
"type": "object",
5+
"required": ["$schema", "kind", "name", "long_name", "introduction"],
6+
"additionalProperties": false,
7+
"properties": {
8+
"$schema": {
9+
"type": "string",
10+
"const": "cert_class_schema.json#"
11+
},
12+
"kind": {
13+
"type": "string",
14+
"const": "certificate class"
15+
},
16+
"name": {
17+
"type": "string",
18+
"pattern": "^[A-Z][a-zA-Z0-9_]*$",
19+
"description": "The short name of the class, used as a database key"
20+
},
21+
"long_name": {
22+
"type": "string",
23+
"description": "Descriptive name of the class"
24+
},
25+
"introduction": {
26+
"type": "string",
27+
"description": "Asciidoc text containing the introduction prose for the class"
28+
},
29+
"naming_scheme": {
30+
"type": "string",
31+
"description": "Asciidoc text describing the naming scheme for the class"
32+
},
33+
"mandatory_priv_modes": {
34+
"type": "array",
35+
"items": {
36+
"type": "string",
37+
"enum": ["M", "S", "U", "VS", "VU"]
38+
},
39+
"uniqueItems": true,
40+
"minItems": 1,
41+
"description": "List of mandatory privilege modes for the class"
42+
},
43+
"__source": {
44+
"$ref": "schema_defs.json#/$defs/__source"
45+
}
46+
}
47+
}

schemas/schema_defs.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"title": "Common patterns used by all schemas",
55

66
"$defs": {
7+
"__source": {
8+
"type": "string",
9+
"format": "uri-reference",
10+
"description": "Path to the source file containing this object"
11+
},
712
"semantic_version": {
813
"type": "string",
914
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"

0 commit comments

Comments
 (0)