| Dung Cao | 04f5771 | 2024-08-29 08:03:59 +0000 | [diff] [blame] | 1 | /** | 
 | 2 |  * Functions for generating pseudo-random CPER AMPERE error sections. | 
 | 3 |  * | 
 | 4 |  **/ | 
 | 5 |  | 
 | 6 | #include <stdlib.h> | 
 | 7 | #include <string.h> | 
 | 8 | #include <stdio.h> | 
| Thu Nguyen | e42fb48 | 2024-10-15 14:43:11 +0000 | [diff] [blame] | 9 | #include <libcper/BaseTypes.h> | 
 | 10 | #include <libcper/generator/gen-utils.h> | 
 | 11 | #include <libcper/generator/sections/gen-section.h> | 
| Dung Cao | 04f5771 | 2024-08-29 08:03:59 +0000 | [diff] [blame] | 12 |  | 
 | 13 | //Generates a single pseudo-random Ampere error section, saving the resulting address to the given | 
 | 14 | //location. Returns the size of the newly created section. | 
| Aushim Nagarkatti | ae8f6d9 | 2025-01-29 17:34:44 -0800 | [diff] [blame] | 15 | size_t generate_section_ampere(void **location, | 
 | 16 | 			       GEN_VALID_BITS_TEST_TYPE validBitsType) | 
| Dung Cao | 04f5771 | 2024-08-29 08:03:59 +0000 | [diff] [blame] | 17 | { | 
| Aushim Nagarkatti | ae8f6d9 | 2025-01-29 17:34:44 -0800 | [diff] [blame] | 18 | 	(void)validBitsType; | 
| Dung Cao | 04f5771 | 2024-08-29 08:03:59 +0000 | [diff] [blame] | 19 | 	//Create random bytes. | 
 | 20 | 	size_t size = sizeof(EFI_AMPERE_ERROR_DATA); | 
 | 21 | 	UINT8 *section = generate_random_bytes(size); | 
 | 22 |  | 
 | 23 | 	//Reserved byte. | 
 | 24 | 	EFI_AMPERE_ERROR_DATA *ampere_error = (EFI_AMPERE_ERROR_DATA *)section; | 
 | 25 | 	ampere_error->TypeId = 10; | 
 | 26 | 	ampere_error->SubtypeId = 1; | 
 | 27 | 	ampere_error->InstanceId = 0; | 
 | 28 |  | 
 | 29 | 	//Set return values, exit. | 
 | 30 | 	*location = section; | 
 | 31 | 	return size; | 
 | 32 | } |