Remove validation bits
Discard invalid properties from json decode. JSON output should only
contain valid properties. This saves time in preventing post
processing of output for valid fields.
Ensure round trip validity with validation bits removed and required
properties populated.
Fix bugs in json decode.
Overhaul unit tests to use valijson. Add tests with static examples
to validate against schema. Use and nlohmann for better schema
validation over intrinsic libcper validation.
Example json output before:
{
"ValidationBits": {
"LevelValid": false,
"CorrectedValid": true
},
"Level": 1,
"Corrected": true
}
After:
{
"Corrected": true
}
Change-Id: I188bdc2827a57d938c22a431238fadfcdc939ab8
Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
diff --git a/generator/sections/gen-section-cxl-protocol.c b/generator/sections/gen-section-cxl-protocol.c
index 5139005..1918d68 100644
--- a/generator/sections/gen-section-cxl-protocol.c
+++ b/generator/sections/gen-section-cxl-protocol.c
@@ -11,7 +11,8 @@
//Generates a single pseudo-random CXL protocol error section, saving the resulting address to the given
//location. Returns the size of the newly created section.
-size_t generate_section_cxl_protocol(void **location)
+size_t generate_section_cxl_protocol(void **location,
+ GEN_VALID_BITS_TEST_TYPE validBitsType)
{
//Create a random length for the CXL DVSEC and CXL error log.
//The logs attached here do not necessarily conform to the specification, and are simply random.
@@ -28,7 +29,12 @@
//Set reserved areas to zero.
UINT64 *validation = (UINT64 *)bytes;
- *validation &= 0x3F; //Validation bits 6-63.
+ *validation &= 0x67;
+ if (validBitsType == ALL_VALID) {
+ *validation = 0x67;
+ } else if (validBitsType == SOME_VALID) {
+ *validation = 0x25;
+ }
for (int i = 0; i < 7; i++) {
*(bytes + 9 + i) = 0; //Reserved bytes 9-15.
}
@@ -38,6 +44,8 @@
for (int i = 0; i < 3; i++) {
*(bytes + 21 + i) = 0; //CXL agent address bytes 5-7.
}
+ *validation |=
+ 0x18; //Device Serial Number depends on agent type
}
*(bytes + 34) &= ~0x7; //Device ID byte 10 bits 0-2.