blob: bf8a7ee1d92ba4dc5ce0d34636325a636254f58c [file] [log] [blame]
/**
* Functions for generating pseudo-random CPER firmware error sections.
*
* Author: Lawrence.Tang@arm.com
**/
#include <stdlib.h>
#include <libcper/BaseTypes.h>
#include <libcper/generator/gen-utils.h>
#include <libcper/generator/sections/gen-section.h>
//Generates a single pseudo-random firmware error section, saving the resulting address to the given
//location. Returns the size of the newly created section.
size_t generate_section_firmware(void **location,
GEN_VALID_BITS_TEST_TYPE validBitsType)
{
(void)validBitsType;
//Create random bytes.
int size = 32;
UINT8 *bytes = generate_random_bytes(size);
//Set reserved areas to zero.
for (int i = 0; i < 6; i++) {
*(bytes + 2 + i) = 0; //Reserved bytes 2-7.
}
//Set expected values.
*(bytes + 1) = 2; //Revision, referenced version of spec is 2.
UINT64 *record_id = (UINT64 *)(bytes + 8);
*record_id = 0; //Record ID, should be forced to NULL.
*bytes = cper_rand() % 3; //Record type.
//Set return values, exit.
*location = bytes;
return size;
}