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-memory.c b/generator/sections/gen-section-memory.c
index 475d6d0..a45f0ce 100644
--- a/generator/sections/gen-section-memory.c
+++ b/generator/sections/gen-section-memory.c
@@ -11,7 +11,8 @@
//Generates a single pseudo-random platform memory error section, saving the resulting address to the given
//location. Returns the size of the newly created section.
-size_t generate_section_memory(void **location)
+size_t generate_section_memory(void **location,
+ GEN_VALID_BITS_TEST_TYPE validBitsType)
{
//Create random bytes.
int size = 80;
@@ -19,8 +20,14 @@
//Set reserved areas to zero.
UINT64 *validation = (UINT64 *)bytes;
- *validation &= 0x2FFFFF; //Validation 22-63
- *(bytes + 73) &= ~0x1C; //Extended bits 2-4
+ //Validation 22-63 reserved. 19/20=0 for bank
+ *validation &= 0x27FFFF;
+ if (validBitsType == ALL_VALID) {
+ *validation = 0x27FFFF;
+ } else if (validBitsType == SOME_VALID) {
+ *validation = 0x275555;
+ }
+ *(bytes + 73) &= ~0x1C; //Extended bits 2-4
//Fix values that could be above range.
*(bytes + 72) = rand() % 16; //Memory error type
@@ -35,7 +42,8 @@
//Generates a single pseudo-random memory 2 error section, saving the resulting address to the given
//location. Returns the size of the newly created section.
-size_t generate_section_memory2(void **location)
+size_t generate_section_memory2(void **location,
+ GEN_VALID_BITS_TEST_TYPE validBitsType)
{
//Create random bytes.
int size = 96;
@@ -43,8 +51,14 @@
//Set reserved areas to zero.
UINT64 *validation = (UINT64 *)bytes;
- *validation &= 0x2FFFFF; //Validation 22-63
- *(bytes + 63) = 0; //Reserved byte 63
+ //Validation 22-63, 20/21 is 0 since 6 is valid
+ *validation &= 0xFFFFF;
+ if (validBitsType == ALL_VALID) {
+ *validation = 0xFFFFF;
+ } else if (validBitsType == SOME_VALID) {
+ *validation = 0x55555;
+ }
+ *(bytes + 63) = 0; //Reserved byte 63
//Fix values that could be above range.
*(bytes + 61) = rand() % 16; //Memory error type