/**
 * Utility functions to assist in generating pseudo-random CPER sections. 
 * 
 * Author: Lawrence.Tang@arm.com
 **/
#include <stdlib.h>
#include <time.h>
#include "../edk/BaseTypes.h"
#include "gen-utils.h"

//Generates a random section of the given byte size, saving the result to the given location.
//Returns the length of the section as passed in.
size_t generate_random_section(void **location, size_t size)
{
	*location = generate_random_bytes(size);
	return size;
}

//Generates a random byte allocation of the given size.
UINT8 *generate_random_bytes(size_t size)
{
	UINT8 *bytes = malloc(size);
	for (size_t i = 0; i < size; i++) {
		bytes[i] = rand();
	}
	return bytes;
}

//Creates a valid common CPER error section, given the start of the error section.
//Clears reserved bits.
void create_valid_error_section(UINT8 *start)
{
	//Fix reserved bits.
	UINT64 *error_section = (UINT64 *)start;
	*error_section &= ~0xFF;    //Reserved bits 0-7.
	*error_section &= 0x7FFFFF; //Reserved bits 23-63

	//Ensure error type has a valid value.
	*(start + 1) =
		CPER_ERROR_TYPES_KEYS[rand() % (sizeof(CPER_ERROR_TYPES_KEYS) /
						sizeof(int))];
}

//Initializes the random seed for rand() using the current time.
void init_random()
{
	srand((unsigned int)time(NULL));
}
