blob: b2bda16c3e2733afb4ad51f5b5b2dd48a8a77003 [file] [log] [blame]
Lawrence Tang02c801a2022-07-18 14:43:52 +01001/**
2 * Functions for generating psuedo-random CPER generic processor sections.
3 *
4 * Author: Lawrence.Tang@arm.com
5 **/
6
7#include <stdlib.h>
8#include "../../edk/BaseTypes.h"
9#include "../gen-utils.h"
Lawrence Tang67cbed62022-07-18 16:44:51 +010010#include "gen-sections.h"
Lawrence Tang02c801a2022-07-18 14:43:52 +010011
12//Generates a single psuedo-random generic processor section, saving the resulting address to the given
13//location. Returns the size of the newly created section.
14size_t generate_section_generic(void** location)
15{
16 //Create random bytes.
17 size_t size = generate_random_section(location, 192);
18
19 //Set reserved locations to zero.
20 UINT8* start_byte = (UINT8*)*location;
21 *((UINT64*)start_byte) &= 0xFFF;
22 *(start_byte + 12) &= 0b111;
23 *((UINT16*)(start_byte + 14)) = 0x0;
24
25 return size;
26}