104f57716SDung Cao /** 204f57716SDung Cao * Functions for generating pseudo-random CPER AMPERE error sections. 304f57716SDung Cao * 404f57716SDung Cao **/ 504f57716SDung Cao 604f57716SDung Cao #include <stdlib.h> 704f57716SDung Cao #include <string.h> 804f57716SDung Cao #include <stdio.h> 9*e42fb487SThu Nguyen #include <libcper/BaseTypes.h> 10*e42fb487SThu Nguyen #include <libcper/generator/gen-utils.h> 11*e42fb487SThu Nguyen #include <libcper/generator/sections/gen-section.h> 1204f57716SDung Cao 1304f57716SDung Cao //Generates a single pseudo-random Ampere error section, saving the resulting address to the given 1404f57716SDung Cao //location. Returns the size of the newly created section. generate_section_ampere(void ** location)1504f57716SDung Caosize_t generate_section_ampere(void **location) 1604f57716SDung Cao { 1704f57716SDung Cao //Create random bytes. 1804f57716SDung Cao size_t size = sizeof(EFI_AMPERE_ERROR_DATA); 1904f57716SDung Cao UINT8 *section = generate_random_bytes(size); 2004f57716SDung Cao 2104f57716SDung Cao //Reserved byte. 2204f57716SDung Cao EFI_AMPERE_ERROR_DATA *ampere_error = (EFI_AMPERE_ERROR_DATA *)section; 2304f57716SDung Cao ampere_error->TypeId = 10; 2404f57716SDung Cao ampere_error->SubtypeId = 1; 2504f57716SDung Cao ampere_error->InstanceId = 0; 2604f57716SDung Cao 2704f57716SDung Cao //Set return values, exit. 2804f57716SDung Cao *location = section; 2904f57716SDung Cao return size; 3004f57716SDung Cao } 31