Formatting .c/.h files and fix memory leakage issues

Signed-off-by: John Chung <john.chung@arm.com>
Change-Id: Id8328f412c2724992d80c0b3f895c8f85bc4ae68
diff --git a/cli-app/cper-convert.c b/cli-app/cper-convert.c
index 86a6d6f..35541c7 100644
--- a/cli-app/cper-convert.c
+++ b/cli-app/cper-convert.c
@@ -8,7 +8,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <libgen.h>
-#include <limits.h>
+#include <linux/limits.h>
 #include <json.h>
 #include "../cper-parse.h"
 #include "../json-schema.h"
@@ -92,10 +92,11 @@
 
 	//Convert.
 	json_object *ir;
-	if (is_single_section)
+	if (is_single_section) {
 		ir = cper_single_section_to_ir(cper_file);
-	else
+	} else {
 		ir = cper_to_ir(cper_file);
+	}
 	fclose(cper_file);
 
 	//Output to string.
@@ -157,8 +158,9 @@
 		}
 
 		//Enable debug mode if indicated.
-		if (debug)
+		if (debug) {
 			validate_schema_debug_enable();
+		}
 
 		//Attempt to verify with the the specification.
 		char *error_message = malloc(JSON_ERROR_MSG_MAX_LEN);
@@ -166,8 +168,9 @@
 							error_message);
 
 		//Free specification path (if necessary).
-		if (using_default_spec_path)
+		if (using_default_spec_path) {
 			free(specification_file);
+		}
 
 		//If failed, early exit before conversion.
 		if (!success) {
@@ -189,11 +192,13 @@
 
 	//Detect the type of CPER (full log, single section) from the IR given.
 	//Run the converter accordingly.
-	if (json_object_object_get(ir, "header") != NULL)
+	if (json_object_object_get(ir, "header") != NULL) {
 		ir_to_cper(ir, cper_file);
-	else
+	} else {
 		ir_single_section_to_cper(ir, cper_file);
+	}
 	fclose(cper_file);
+	json_object_put(ir);
 }
 
 //Command for printing help information.
@@ -216,4 +221,4 @@
 	printf("\tIf '--debug' is set, then debug output for JSON specification parsing will be printed to stdout.\n");
 	printf("\n:: --help\n");
 	printf("\tDisplays help information to the console.\n");
-}
\ No newline at end of file
+}
diff --git a/common-utils.c b/common-utils.c
index 38c4317..9c6de07 100644
--- a/common-utils.c
+++ b/common-utils.c
@@ -25,4 +25,4 @@
 	}
 
 	return result;
-}
\ No newline at end of file
+}
diff --git a/common-utils.h b/common-utils.h
index 436820f..c6b9b60 100644
--- a/common-utils.h
+++ b/common-utils.h
@@ -6,4 +6,4 @@
 int bcd_to_int(UINT8 bcd);
 UINT8 int_to_bcd(int value);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/cper-parse.c b/cper-parse.c
index e66ed28..7d99d20 100644
--- a/cper-parse.c
+++ b/cper-parse.c
@@ -7,7 +7,7 @@
 
 #include <stdio.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "edk/Cper.h"
 #include "cper-parse.h"
 #include "cper-utils.h"
@@ -109,7 +109,7 @@
 			       json_object_new_uint64(header->RecordLength));
 
 	//If a timestamp exists according to validation bits, then add it.
-	if (header->ValidationBits & 0b10) {
+	if (header->ValidationBits & 0x2) {
 		char timestamp_string[TIMESTAMP_LENGTH];
 		timestamp_to_string(timestamp_string, &header->TimeStamp);
 
@@ -122,7 +122,7 @@
 	}
 
 	//If a platform ID exists according to the validation bits, then add it.
-	if (header->ValidationBits & 0b1) {
+	if (header->ValidationBits & 0x1) {
 		char platform_string[GUID_STRING_LENGTH];
 		guid_to_string(platform_string, &header->PlatformID);
 		json_object_object_add(header_ir, "platformID",
@@ -130,7 +130,7 @@
 	}
 
 	//If a partition ID exists according to the validation bits, then add it.
-	if (header->ValidationBits & 0b100) {
+	if (header->ValidationBits & 0x4) {
 		char partition_string[GUID_STRING_LENGTH];
 		guid_to_string(partition_string, &header->PartitionID);
 		json_object_object_add(
@@ -155,41 +155,42 @@
 	//Add the human readable notification type if possible.
 	char *notification_type_readable = "Unknown";
 	if (guid_equal(&header->NotificationType,
-		       &gEfiEventNotificationTypeCmcGuid))
+		       &gEfiEventNotificationTypeCmcGuid)) {
 		notification_type_readable = "CMC";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeCpeGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeCpeGuid)) {
 		notification_type_readable = "CPE";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeMceGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeMceGuid)) {
 		notification_type_readable = "MCE";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypePcieGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypePcieGuid)) {
 		notification_type_readable = "PCIe";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeInitGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeInitGuid)) {
 		notification_type_readable = "INIT";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeNmiGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeNmiGuid)) {
 		notification_type_readable = "NMI";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeBootGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeBootGuid)) {
 		notification_type_readable = "Boot";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeDmarGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeDmarGuid)) {
 		notification_type_readable = "DMAr";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeSeaGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeSeaGuid)) {
 		notification_type_readable = "SEA";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeSeiGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeSeiGuid)) {
 		notification_type_readable = "SEI";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypePeiGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypePeiGuid)) {
 		notification_type_readable = "PEI";
-	else if (guid_equal(&header->NotificationType,
-			    &gEfiEventNotificationTypeCxlGuid))
+	} else if (guid_equal(&header->NotificationType,
+			      &gEfiEventNotificationTypeCxlGuid)) {
 		notification_type_readable = "CXL Component";
+	}
 	json_object_object_add(
 		notification_type, "type",
 		json_object_new_string(notification_type_readable));
@@ -254,7 +255,7 @@
 
 	//Readable section type, if possible.
 	const char *section_type_readable = "Unknown";
-	for (int i = 0; i < section_definitions_len; i++) {
+	for (size_t i = 0; i < section_definitions_len; i++) {
 		if (guid_equal(section_definitions[i].Guid,
 			       &section_descriptor->SectionType)) {
 			section_type_readable =
@@ -269,7 +270,7 @@
 			       section_type);
 
 	//If validation bits indicate it exists, add FRU ID.
-	if (section_descriptor->SecValidMask & 0b1) {
+	if (section_descriptor->SecValidMask & 0x1) {
 		char fru_id_string[GUID_STRING_LENGTH];
 		guid_to_string(fru_id_string, &section_descriptor->FruId);
 		json_object_object_add(section_descriptor_ir, "fruID",
@@ -277,10 +278,11 @@
 	}
 
 	//If validation bits indicate it exists, add FRU text.
-	if ((section_descriptor->SecValidMask & 0b10) >> 1)
+	if ((section_descriptor->SecValidMask & 0x2) >> 1) {
 		json_object_object_add(
 			section_descriptor_ir, "fruText",
 			json_object_new_string(section_descriptor->FruString));
+	}
 
 	//Section severity.
 	json_object *section_severity = json_object_new_object();
@@ -307,7 +309,7 @@
 	fseek(handle, base_pos + descriptor->SectionOffset, SEEK_SET);
 	void *section = malloc(descriptor->SectionLength);
 	if (fread(section, descriptor->SectionLength, 1, handle) != 1) {
-		printf("Section read failed: Could not read %d bytes from global offset %d.\n",
+		printf("Section read failed: Could not read %u bytes from global offset %d.\n",
 		       descriptor->SectionLength, descriptor->SectionOffset);
 		free(section);
 		return NULL;
@@ -319,12 +321,11 @@
 	//Parse section to IR based on GUID.
 	json_object *result = NULL;
 	int section_converted = 0;
-	for (int i = 0; i < section_definitions_len; i++) {
+	for (size_t i = 0; i < section_definitions_len; i++) {
 		if (guid_equal(section_definitions[i].Guid,
 			       &descriptor->SectionType) &&
 		    section_definitions[i].ToIR != NULL) {
-			result = section_definitions[i].ToIR(section,
-							     descriptor);
+			result = section_definitions[i].ToIR(section);
 			section_converted = 1;
 			break;
 		}
@@ -334,11 +335,18 @@
 	if (!section_converted) {
 		//Output the data as formatted base64.
 		result = json_object_new_object();
-		char *encoded = b64_encode((unsigned char *)section,
-					   descriptor->SectionLength);
-		json_object_object_add(result, "data",
-				       json_object_new_string(encoded));
-		free(encoded);
+		char *encoded = malloc(2 * descriptor->SectionLength);
+		size_t encoded_len = 0;
+		if (!encoded) {
+			printf("Failed to allocate encode output buffer. \n");
+		} else {
+			base64_encode(section, descriptor->SectionLength,
+				      encoded, &encoded_len, 0);
+			json_object_object_add(result, "data",
+					       json_object_new_string_len(
+						       encoded, encoded_len));
+			free(encoded);
+		}
 	}
 
 	//Free section memory, return result.
@@ -368,9 +376,9 @@
 	json_object_object_add(ir, "sectionDescriptor", section_descriptor_ir);
 
 	//Parse the single section.
-	json_object *section_ir =
-		cper_section_to_ir(cper_section_file, base_pos, &section_descriptor);
+	json_object *section_ir = cper_section_to_ir(
+		cper_section_file, base_pos, &section_descriptor);
 	json_object_object_add(ir, "section", section_ir);
 
 	return ir;
-}
\ No newline at end of file
+}
diff --git a/cper-parse.h b/cper-parse.h
index 40c2bf4..752036e 100644
--- a/cper-parse.h
+++ b/cper-parse.h
@@ -2,17 +2,38 @@
 #define CPER_PARSE_H
 #include <json.h>
 
-#define CPER_HEADER_VALID_BITFIELD_NAMES (const char*[]) {"platformIDValid", "timestampValid", "partitionIDValid"}
-#define CPER_SECTION_DESCRIPTOR_VALID_BITFIELD_NAMES (const char*[]) {"fruIDValid", "fruStringValid"}
-#define CPER_SECTION_DESCRIPTOR_FLAGS_BITFIELD_NAMES (const char*[]) \
-    {"primary", "containmentWarning", "reset", "errorThresholdExceeded", "resourceNotAccessible", "latentError", \
-    "propagated", "overflow"}
-#define CPER_HEADER_FLAG_TYPES_KEYS (int []){1, 2, 4}
-#define CPER_HEADER_FLAG_TYPES_VALUES (const char*[]){"HW_ERROR_FLAGS_RECOVERED", "HW_ERROR_FLAGS_PREVERR", "HW_ERROR_FLAGS_SIMULATED"}
+#define CPER_HEADER_VALID_BITFIELD_NAMES                                       \
+	(const char *[])                                                       \
+	{                                                                      \
+		"platformIDValid", "timestampValid", "partitionIDValid"        \
+	}
+#define CPER_SECTION_DESCRIPTOR_VALID_BITFIELD_NAMES                           \
+	(const char *[])                                                       \
+	{                                                                      \
+		"fruIDValid", "fruStringValid"                                 \
+	}
+#define CPER_SECTION_DESCRIPTOR_FLAGS_BITFIELD_NAMES                           \
+	(const char *[])                                                       \
+	{                                                                      \
+		"primary", "containmentWarning", "reset",                      \
+			"errorThresholdExceeded", "resourceNotAccessible",     \
+			"latentError", "propagated", "overflow"                \
+	}
+#define CPER_HEADER_FLAG_TYPES_KEYS                                            \
+	(int[])                                                                \
+	{                                                                      \
+		1, 2, 4                                                        \
+	}
+#define CPER_HEADER_FLAG_TYPES_VALUES                                          \
+	(const char *[])                                                       \
+	{                                                                      \
+		"HW_ERROR_FLAGS_RECOVERED", "HW_ERROR_FLAGS_PREVERR",          \
+			"HW_ERROR_FLAGS_SIMULATED"                             \
+	}
 
-json_object* cper_to_ir(FILE* cper_file);
-json_object* cper_single_section_to_ir(FILE* cper_section_file);
-void ir_to_cper(json_object* ir, FILE* out);
-void ir_single_section_to_cper(json_object* ir, FILE* out);
+json_object *cper_to_ir(FILE *cper_file);
+json_object *cper_single_section_to_ir(FILE *cper_section_file);
+void ir_to_cper(json_object *ir, FILE *out);
+void ir_single_section_to_cper(json_object *ir, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/cper-parse.i b/cper-parse.i
index 7ba1da4..e783e7d 100644
--- a/cper-parse.i
+++ b/cper-parse.i
@@ -1,15 +1,17 @@
-%module cperparse
-%{
-    #include "cper-parse.h"
-    #include <json.h>
-    #include <stdio.h>
-%}
+% module cperparse %
+	{
+#include "cper-parse.h"
+#include <json.h>
+#include <stdio.h>
+		%
+	}
 
-//Library function declarations for module export.
-json_object* cper_to_ir(FILE* cper_file);
-void ir_to_cper(json_object* ir, FILE* out);
+	//Library function declarations for module export.
+	json_object *
+	cper_to_ir(FILE *cper_file);
+void ir_to_cper(json_object *ir, FILE *out);
 
 //JSON function symbol export.
 const char *json_object_to_json_string(struct json_object *obj);
 struct json_object *json_object_from_file(const char *filename);
-struct json_object *json_tokener_parse(const char *str);
\ No newline at end of file
+struct json_object *json_tokener_parse(const char *str);
diff --git a/cper-utils.c b/cper-utils.c
index 8fe3a2e..84186ad 100644
--- a/cper-utils.c
+++ b/cper-utils.c
@@ -141,8 +141,9 @@
 	//Search for human readable name, add.
 	const char *name = default_value;
 	for (int i = 0; i < len; i++) {
-		if (keys[i] == value)
+		if ((UINT64)keys[i] == value) {
 			name = values[i];
+		}
 	}
 
 	json_object_object_add(result, "name", json_object_new_string(name));
@@ -188,7 +189,7 @@
 	for (int i = 0; i < num_fields; i++) {
 		json_object_object_add(result, names[i],
 				       json_object_new_boolean((bitfield >> i) &
-							       0b1));
+							       0x1));
 	}
 
 	return result;
@@ -200,8 +201,9 @@
 	UINT64 result = 0x0;
 	for (int i = 0; i < num_fields; i++) {
 		if (json_object_get_boolean(
-			    json_object_object_get(ir, names[i])))
+			    json_object_object_get(ir, names[i]))) {
 			result |= (0x1 << i);
+		}
 	}
 
 	return result;
@@ -211,9 +213,10 @@
 json_object *uint64_array_to_ir_array(UINT64 *array, int len)
 {
 	json_object *array_ir = json_object_new_array();
-	for (int i = 0; i < len; i++)
+	for (int i = 0; i < len; i++) {
 		json_object_array_add(array_ir,
 				      json_object_new_uint64(array[i]));
+	}
 	return array_ir;
 }
 
@@ -240,7 +243,7 @@
 {
 	sprintf(out, "%02hhu%02hhu-%02hhu-%02hhuT%02hhu:%02hhu:%02hhu.000",
 		bcd_to_int(timestamp->Century) %
-			100, //Cannot go to three digits.
+			100,			   //Cannot go to three digits.
 		bcd_to_int(timestamp->Year) % 100, //Cannot go to three digits.
 		bcd_to_int(timestamp->Month), bcd_to_int(timestamp->Day),
 		bcd_to_int(timestamp->Hours), bcd_to_int(timestamp->Minutes),
@@ -251,8 +254,9 @@
 void string_to_timestamp(EFI_ERROR_TIME_STAMP *out, const char *timestamp)
 {
 	//Ignore invalid timestamps.
-	if (timestamp == NULL)
+	if (timestamp == NULL) {
 		return;
+	}
 
 	sscanf(timestamp, "%2hhu%2hhu-%hhu-%hhuT%hhu:%hhu:%hhu.000",
 	       &out->Century, &out->Year, &out->Month, &out->Day, &out->Hours,
@@ -281,8 +285,9 @@
 void string_to_guid(EFI_GUID *out, const char *guid)
 {
 	//Ignore invalid GUIDs.
-	if (guid == NULL)
+	if (guid == NULL) {
 		return;
+	}
 
 	sscanf(guid,
 	       "%08x-%04hx-%04hx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
@@ -302,9 +307,10 @@
 
 	//Check Data4 array for equality.
 	for (int i = 0; i < 8; i++) {
-		if (a->Data4[i] != b->Data4[i])
+		if (a->Data4[i] != b->Data4[i]) {
 			return 0;
+		}
 	}
 
 	return 1;
-}
\ No newline at end of file
+}
diff --git a/cper-utils.h b/cper-utils.h
index 18f1e0f..9ab7a5a 100644
--- a/cper-utils.h
+++ b/cper-utils.h
@@ -1,32 +1,44 @@
 #ifndef CPER_UTILS_H
 #define CPER_UTILS_H
 
-#define GUID_STRING_LENGTH 30
-#define TIMESTAMP_LENGTH 24
+#define GUID_STRING_LENGTH 48
+#define TIMESTAMP_LENGTH   24
 
 #include "common-utils.h"
+#include <json.h>
 
-json_object* cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS* error_status);
-void ir_generic_error_status_to_cper(json_object* error_status, EFI_GENERIC_ERROR_STATUS* error_status_cper);
-json_object* uniform_struct_to_ir(UINT32* start, int len, const char* names[]);
-json_object* uniform_struct64_to_ir(UINT64* start, int len, const char* names[]);
-void ir_to_uniform_struct(json_object* ir, UINT32* start, int len, const char* names[]);
-void ir_to_uniform_struct64(json_object* ir, UINT64* start, int len, const char* names[]);
-json_object* integer_to_readable_pair(UINT64 value, int len, int keys[], const char* values[], const char* default_value);
-json_object* integer_to_readable_pair_with_desc(int value, int len, int keys[], const char* values[], const char* descriptions[], const char* default_value);
-UINT64 readable_pair_to_integer(json_object* pair);
-json_object* bitfield_to_ir(UINT64 bitfield, int num_fields, const char* names[]);
-UINT64 ir_to_bitfield(json_object* ir, int num_fields, const char* names[]);
-json_object* uint64_array_to_ir_array(UINT64* array, int len);
-json_object* revision_to_ir(UINT16 revision);
-const char* severity_to_string(UINT32 severity);
-void timestamp_to_string(char* out, EFI_ERROR_TIME_STAMP* timestamp);
-void string_to_timestamp(EFI_ERROR_TIME_STAMP* out, const char* timestamp);
-void guid_to_string(char* out, EFI_GUID* guid);
-void string_to_guid(EFI_GUID* out, const char* guid);
-int guid_equal(EFI_GUID* a, EFI_GUID* b);
+json_object *
+cper_generic_error_status_to_ir(EFI_GENERIC_ERROR_STATUS *error_status);
+void ir_generic_error_status_to_cper(
+	json_object *error_status, EFI_GENERIC_ERROR_STATUS *error_status_cper);
+json_object *uniform_struct_to_ir(UINT32 *start, int len, const char *names[]);
+json_object *uniform_struct64_to_ir(UINT64 *start, int len,
+				    const char *names[]);
+void ir_to_uniform_struct(json_object *ir, UINT32 *start, int len,
+			  const char *names[]);
+void ir_to_uniform_struct64(json_object *ir, UINT64 *start, int len,
+			    const char *names[]);
+json_object *integer_to_readable_pair(UINT64 value, int len, int keys[],
+				      const char *values[],
+				      const char *default_value);
+json_object *integer_to_readable_pair_with_desc(int value, int len, int keys[],
+						const char *values[],
+						const char *descriptions[],
+						const char *default_value);
+UINT64 readable_pair_to_integer(json_object *pair);
+json_object *bitfield_to_ir(UINT64 bitfield, int num_fields,
+			    const char *names[]);
+UINT64 ir_to_bitfield(json_object *ir, int num_fields, const char *names[]);
+json_object *uint64_array_to_ir_array(UINT64 *array, int len);
+json_object *revision_to_ir(UINT16 revision);
+const char *severity_to_string(UINT32 severity);
+void timestamp_to_string(char *out, EFI_ERROR_TIME_STAMP *timestamp);
+void string_to_timestamp(EFI_ERROR_TIME_STAMP *out, const char *timestamp);
+void guid_to_string(char *out, EFI_GUID *guid);
+void string_to_guid(EFI_GUID *out, const char *guid);
+int guid_equal(EFI_GUID *a, EFI_GUID *b);
 
 //The available severity types for CPER.
-extern const char* CPER_SEVERITY_TYPES[4];
+extern const char *CPER_SEVERITY_TYPES[4];
 
-#endif
\ No newline at end of file
+#endif
diff --git a/edk/BaseTypes.h b/edk/BaseTypes.h
index f7a29de..9958889 100644
--- a/edk/BaseTypes.h
+++ b/edk/BaseTypes.h
@@ -14,57 +14,57 @@
 ///
 /// 8-byte unsigned value
 ///
-typedef unsigned long long  UINT64;
+typedef unsigned long long UINT64;
 ///
 /// 8-byte signed value
 ///
-typedef long long           INT64;
+typedef long long INT64;
 ///
 /// 4-byte unsigned value
 ///
-typedef unsigned int        UINT32;
+typedef unsigned int UINT32;
 ///
 /// 4-byte signed value
 ///
-typedef int                 INT32;
+typedef int INT32;
 ///
 /// 2-byte unsigned value
 ///
-typedef unsigned short      UINT16;
+typedef unsigned short UINT16;
 ///
 /// 2-byte Character.  Unless otherwise specified all strings are stored in the
 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
 ///
-typedef unsigned short      CHAR16;
+typedef unsigned short CHAR16;
 ///
 /// 2-byte signed value
 ///
-typedef short               INT16;
+typedef short INT16;
 ///
 /// Logical Boolean.  1-byte value containing 0 for FALSE or a 1 for TRUE.  Other
 /// values are undefined.
 ///
-typedef unsigned char       BOOLEAN;
+typedef unsigned char BOOLEAN;
 ///
 /// 1-byte unsigned value
 ///
-typedef unsigned char       UINT8;
+typedef unsigned char UINT8;
 ///
 /// 1-byte Character
 ///
-typedef char                CHAR8;
+typedef char CHAR8;
 ///
 /// 1-byte signed value
 ///
-typedef signed char         INT8;
+typedef signed char INT8;
 //
 // Basical data type definitions introduced in UEFI.
 //
 typedef struct {
-  UINT32  Data1;
-  UINT16  Data2;
-  UINT16  Data3;
-  UINT8   Data4[8];
+	UINT32 Data1;
+	UINT16 Data2;
+	UINT16 Data3;
+	UINT8 Data4[8];
 } EFI_GUID;
 
 /**
@@ -79,7 +79,7 @@
   @return A 16-bit value built from the two ASCII characters specified by A and B.
 
 **/
-#define SIGNATURE_16(A, B)        ((A) | (B << 8))
+#define SIGNATURE_16(A, B) ((A) | (B << 8))
 /**
   Returns a 32-bit signature built from 4 ASCII characters.
 
@@ -95,6 +95,7 @@
           C and D.
 
 **/
-#define SIGNATURE_32(A, B, C, D)  (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16))
+#define SIGNATURE_32(A, B, C, D)                                               \
+	(SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16))
 
-#endif
\ No newline at end of file
+#endif
diff --git a/edk/Cper.c b/edk/Cper.c
index a772939..4f80023 100644
--- a/edk/Cper.c
+++ b/edk/Cper.c
@@ -16,45 +16,197 @@
 #include "Cper.h"
 
 //Event notification type GUIDs.
-EFI_GUID gEfiEventNotificationTypeCmcGuid   = { 0x2DCE8BB1, 0xBDD7, 0x450e, { 0xB9, 0xAD, 0x9C, 0xF4, 0xEB, 0xD4, 0xF8, 0x90 }};
-EFI_GUID gEfiEventNotificationTypeCpeGuid   = { 0x4E292F96, 0xD843, 0x4a55, { 0xA8, 0xC2, 0xD4, 0x81, 0xF2, 0x7E, 0xBE, 0xEE }};
-EFI_GUID gEfiEventNotificationTypeMceGuid   = { 0xE8F56FFE, 0x919C, 0x4cc5, { 0xBA, 0x88, 0x65, 0xAB, 0xE1, 0x49, 0x13, 0xBB }};
-EFI_GUID gEfiEventNotificationTypePcieGuid  = { 0xCF93C01F, 0x1A16, 0x4dfc, { 0xB8, 0xBC, 0x9C, 0x4D, 0xAF, 0x67, 0xC1, 0x04 }};
-EFI_GUID gEfiEventNotificationTypeInitGuid  = { 0xCC5263E8, 0x9308, 0x454a, { 0x89, 0xD0, 0x34, 0x0B, 0xD3, 0x9B, 0xC9, 0x8E }};
-EFI_GUID gEfiEventNotificationTypeNmiGuid   = { 0x5BAD89FF, 0xB7E6, 0x42c9, { 0x81, 0x4A, 0xCF, 0x24, 0x85, 0xD6, 0xE9, 0x8A }};
-EFI_GUID gEfiEventNotificationTypeBootGuid  = { 0x3D61A466, 0xAB40, 0x409a, { 0xA6, 0x98, 0xF3, 0x62, 0xD4, 0x64, 0xB3, 0x8F }};
-EFI_GUID gEfiEventNotificationTypeDmarGuid  = { 0x667DD791, 0xC6B3, 0x4c27, { 0x8A, 0x6B, 0x0F, 0x8E, 0x72, 0x2D, 0xEB, 0x41 }};
-EFI_GUID gEfiEventNotificationTypeSeaGuid   = { 0x9A78788A, 0xBBE8, 0x11E4, { 0x80, 0x9E, 0x67, 0x61, 0x1E, 0x5D, 0x46, 0xB0 }};
-EFI_GUID gEfiEventNotificationTypeSeiGuid   = { 0x5C284C81, 0xB0AE, 0x4E87, { 0xA3, 0x22, 0xB0, 0x4C, 0x85, 0x62, 0x43, 0x23 }};
-EFI_GUID gEfiEventNotificationTypePeiGuid   = { 0x09A9D5AC, 0x5204, 0x4214, { 0x96, 0xE5, 0x94, 0x99, 0x2E, 0x75, 0x2B, 0xCD }};
-EFI_GUID gEfiEventNotificationTypeCxlGuid   = { 0x69293BC9, 0x41DF, 0x49A3, { 0xB4, 0xBD, 0x4F, 0xB0, 0xDB, 0x30, 0x41, 0xF6 }};
+EFI_GUID gEfiEventNotificationTypeCmcGuid = { 0x2DCE8BB1,
+					      0xBDD7,
+					      0x450e,
+					      { 0xB9, 0xAD, 0x9C, 0xF4, 0xEB,
+						0xD4, 0xF8, 0x90 } };
+EFI_GUID gEfiEventNotificationTypeCpeGuid = { 0x4E292F96,
+					      0xD843,
+					      0x4a55,
+					      { 0xA8, 0xC2, 0xD4, 0x81, 0xF2,
+						0x7E, 0xBE, 0xEE } };
+EFI_GUID gEfiEventNotificationTypeMceGuid = { 0xE8F56FFE,
+					      0x919C,
+					      0x4cc5,
+					      { 0xBA, 0x88, 0x65, 0xAB, 0xE1,
+						0x49, 0x13, 0xBB } };
+EFI_GUID gEfiEventNotificationTypePcieGuid = { 0xCF93C01F,
+					       0x1A16,
+					       0x4dfc,
+					       { 0xB8, 0xBC, 0x9C, 0x4D, 0xAF,
+						 0x67, 0xC1, 0x04 } };
+EFI_GUID gEfiEventNotificationTypeInitGuid = { 0xCC5263E8,
+					       0x9308,
+					       0x454a,
+					       { 0x89, 0xD0, 0x34, 0x0B, 0xD3,
+						 0x9B, 0xC9, 0x8E } };
+EFI_GUID gEfiEventNotificationTypeNmiGuid = { 0x5BAD89FF,
+					      0xB7E6,
+					      0x42c9,
+					      { 0x81, 0x4A, 0xCF, 0x24, 0x85,
+						0xD6, 0xE9, 0x8A } };
+EFI_GUID gEfiEventNotificationTypeBootGuid = { 0x3D61A466,
+					       0xAB40,
+					       0x409a,
+					       { 0xA6, 0x98, 0xF3, 0x62, 0xD4,
+						 0x64, 0xB3, 0x8F } };
+EFI_GUID gEfiEventNotificationTypeDmarGuid = { 0x667DD791,
+					       0xC6B3,
+					       0x4c27,
+					       { 0x8A, 0x6B, 0x0F, 0x8E, 0x72,
+						 0x2D, 0xEB, 0x41 } };
+EFI_GUID gEfiEventNotificationTypeSeaGuid = { 0x9A78788A,
+					      0xBBE8,
+					      0x11E4,
+					      { 0x80, 0x9E, 0x67, 0x61, 0x1E,
+						0x5D, 0x46, 0xB0 } };
+EFI_GUID gEfiEventNotificationTypeSeiGuid = { 0x5C284C81,
+					      0xB0AE,
+					      0x4E87,
+					      { 0xA3, 0x22, 0xB0, 0x4C, 0x85,
+						0x62, 0x43, 0x23 } };
+EFI_GUID gEfiEventNotificationTypePeiGuid = { 0x09A9D5AC,
+					      0x5204,
+					      0x4214,
+					      { 0x96, 0xE5, 0x94, 0x99, 0x2E,
+						0x75, 0x2B, 0xCD } };
+EFI_GUID gEfiEventNotificationTypeCxlGuid = { 0x69293BC9,
+					      0x41DF,
+					      0x49A3,
+					      { 0xB4, 0xBD, 0x4F, 0xB0, 0xDB,
+						0x30, 0x41, 0xF6 } };
 
 //Error section GUIDs.
-EFI_GUID gEfiProcessorGenericErrorSectionGuid  = { 0x9876ccad, 0x47b4, 0x4bdb, { 0xb6, 0x5e, 0x16, 0xf1, 0x93, 0xc4, 0xf3, 0xdb }};
-EFI_GUID gEfiProcessorSpecificErrorSectionGuid = { 0xdc3ea0b0, 0xa144, 0x4797, { 0xb9, 0x5b, 0x53, 0xfa, 0x24, 0x2b, 0x6e, 0x1d }};
-EFI_GUID gEfiIa32X64ProcessorErrorSectionGuid  = { 0xdc3ea0b0, 0xa144, 0x4797, { 0xb9, 0x5b, 0x53, 0xfa, 0x24, 0x2b, 0x6e, 0x1d }};
-EFI_GUID gEfiIpfProcessorErrorSectionGuid  = { 0xe429faf1, 0x3cb7, 0x11d4, { 0xbc, 0xa7, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81 }};
-EFI_GUID gEfiArmProcessorErrorSectionGuid  = { 0xe19e3d16, 0xbc11, 0x11e4, { 0x9c, 0xaa, 0xc2, 0x05, 0x1d, 0x5d, 0x46, 0xb0 }};
-EFI_GUID gEfiPlatformMemoryErrorSectionGuid = { 0xa5bc1114, 0x6f64, 0x4ede, { 0xb8, 0x63, 0x3e, 0x83, 0xed, 0x7c, 0x83, 0xb1 }};
-EFI_GUID gEfiPlatformMemoryError2SectionGuid = { 0x61EC04FC, 0x48E6, 0xD813, { 0x25, 0xC9, 0x8D, 0xAA, 0x44, 0x75, 0x0B, 0x12 }};
-EFI_GUID gEfiPcieErrorSectionGuid           = { 0xd995e954, 0xbbc1, 0x430f, { 0xad, 0x91, 0xb4, 0x4d, 0xcb, 0x3c, 0x6f, 0x35 }};
-EFI_GUID gEfiFirmwareErrorSectionGuid       = { 0x81212a96, 0x09ed, 0x4996, { 0x94, 0x71, 0x8d, 0x72, 0x9c, 0x8e, 0x69, 0xed }};
-EFI_GUID gEfiPciBusErrorSectionGuid         = { 0xc5753963, 0x3b84, 0x4095, { 0xbf, 0x78, 0xed, 0xda, 0xd3, 0xf9, 0xc9, 0xdd }};
-EFI_GUID gEfiPciDevErrorSectionGuid         = { 0xeb5e4685, 0xca66, 0x4769, { 0xb6, 0xa2, 0x26, 0x06, 0x8b, 0x00, 0x13, 0x26 }};
-EFI_GUID gEfiDMArGenericErrorSectionGuid    = { 0x5b51fef7, 0xc79d, 0x4434, { 0x8f, 0x1b, 0xaa, 0x62, 0xde, 0x3e, 0x2c, 0x64 }};
-EFI_GUID gEfiDirectedIoDMArErrorSectionGuid = { 0x71761d37, 0x32b2, 0x45cd, { 0xa7, 0xd0, 0xb0, 0xfe, 0xdd, 0x93, 0xe8, 0xcf }};
-EFI_GUID gEfiIommuDMArErrorSectionGuid      = { 0x036f84e1, 0x7f37, 0x428c, { 0xa7, 0x9e, 0x57, 0x5f, 0xdf, 0xaa, 0x84, 0xec }};
-EFI_GUID gEfiCcixPerLogErrorSectionGuid     = { 0x91335EF6, 0xEBFB, 0x4478, {0xA6, 0xA6, 0x88, 0xB7, 0x28, 0xCF, 0x75, 0xD7 }};
-EFI_GUID gEfiCxlProtocolErrorSectionGuid    = { 0x80B9EFB4, 0x52B5, 0x4DE3, { 0xA7, 0x77, 0x68, 0x78, 0x4B, 0x77, 0x10, 0x48 }};
-EFI_GUID gEfiCxlGeneralMediaErrorSectionGuid = { 0xfbcd0a77, 0xc260, 0x417f, { 0x85, 0xa9, 0x08, 0x8b, 0x16, 0x21, 0xeb, 0xa6 }};
-EFI_GUID gEfiCxlDramEventErrorSectionGuid = { 0x601dcbb3, 0x9c06, 0x4eab, { 0xb8, 0xaf, 0x4e, 0x9b, 0xfb, 0x5c, 0x96, 0x24 }};
-EFI_GUID gEfiCxlMemoryModuleErrorSectionGuid = { 0xfe927475, 0xdd59, 0x4339, { 0xa5, 0x86, 0x79, 0xba, 0xb1, 0x13, 0xb7, 0x74 }};
-EFI_GUID gEfiCxlPhysicalSwitchErrorSectionGuid = { 0x77cf9271, 0x9c02, 0x470b, { 0x9f, 0xe4, 0xbc, 0x7b, 0x75, 0xf2, 0xda, 0x97 }};
-EFI_GUID gEfiCxlVirtualSwitchErrorSectionGuid = { 0x40d26425, 0x3396, 0x4c4d, { 0xa5, 0xda, 0x3d, 0x47, 0x26, 0x3a, 0xf4, 0x25 }};
-EFI_GUID gEfiCxlMldPortErrorSectionGuid = { 0x8dc44363, 0x0c96, 0x4710, { 0xb7, 0xbf, 0x04, 0xbb, 0x99, 0x53, 0x4c, 0x3f }};
+EFI_GUID gEfiProcessorGenericErrorSectionGuid = { 0x9876ccad,
+						  0x47b4,
+						  0x4bdb,
+						  { 0xb6, 0x5e, 0x16, 0xf1,
+						    0x93, 0xc4, 0xf3, 0xdb } };
+EFI_GUID gEfiProcessorSpecificErrorSectionGuid = { 0xdc3ea0b0,
+						   0xa144,
+						   0x4797,
+						   { 0xb9, 0x5b, 0x53, 0xfa,
+						     0x24, 0x2b, 0x6e, 0x1d } };
+EFI_GUID gEfiIa32X64ProcessorErrorSectionGuid = { 0xdc3ea0b0,
+						  0xa144,
+						  0x4797,
+						  { 0xb9, 0x5b, 0x53, 0xfa,
+						    0x24, 0x2b, 0x6e, 0x1d } };
+EFI_GUID gEfiIpfProcessorErrorSectionGuid = { 0xe429faf1,
+					      0x3cb7,
+					      0x11d4,
+					      { 0xbc, 0xa7, 0x00, 0x80, 0xc7,
+						0x3c, 0x88, 0x81 } };
+EFI_GUID gEfiArmProcessorErrorSectionGuid = { 0xe19e3d16,
+					      0xbc11,
+					      0x11e4,
+					      { 0x9c, 0xaa, 0xc2, 0x05, 0x1d,
+						0x5d, 0x46, 0xb0 } };
+EFI_GUID gEfiPlatformMemoryErrorSectionGuid = { 0xa5bc1114,
+						0x6f64,
+						0x4ede,
+						{ 0xb8, 0x63, 0x3e, 0x83, 0xed,
+						  0x7c, 0x83, 0xb1 } };
+EFI_GUID gEfiPlatformMemoryError2SectionGuid = { 0x61EC04FC,
+						 0x48E6,
+						 0xD813,
+						 { 0x25, 0xC9, 0x8D, 0xAA, 0x44,
+						   0x75, 0x0B, 0x12 } };
+EFI_GUID gEfiPcieErrorSectionGuid = { 0xd995e954,
+				      0xbbc1,
+				      0x430f,
+				      { 0xad, 0x91, 0xb4, 0x4d, 0xcb, 0x3c,
+					0x6f, 0x35 } };
+EFI_GUID gEfiFirmwareErrorSectionGuid = { 0x81212a96,
+					  0x09ed,
+					  0x4996,
+					  { 0x94, 0x71, 0x8d, 0x72, 0x9c, 0x8e,
+					    0x69, 0xed } };
+EFI_GUID gEfiPciBusErrorSectionGuid = { 0xc5753963,
+					0x3b84,
+					0x4095,
+					{ 0xbf, 0x78, 0xed, 0xda, 0xd3, 0xf9,
+					  0xc9, 0xdd } };
+EFI_GUID gEfiPciDevErrorSectionGuid = { 0xeb5e4685,
+					0xca66,
+					0x4769,
+					{ 0xb6, 0xa2, 0x26, 0x06, 0x8b, 0x00,
+					  0x13, 0x26 } };
+EFI_GUID gEfiDMArGenericErrorSectionGuid = { 0x5b51fef7,
+					     0xc79d,
+					     0x4434,
+					     { 0x8f, 0x1b, 0xaa, 0x62, 0xde,
+					       0x3e, 0x2c, 0x64 } };
+EFI_GUID gEfiDirectedIoDMArErrorSectionGuid = { 0x71761d37,
+						0x32b2,
+						0x45cd,
+						{ 0xa7, 0xd0, 0xb0, 0xfe, 0xdd,
+						  0x93, 0xe8, 0xcf } };
+EFI_GUID gEfiIommuDMArErrorSectionGuid = { 0x036f84e1,
+					   0x7f37,
+					   0x428c,
+					   { 0xa7, 0x9e, 0x57, 0x5f, 0xdf, 0xaa,
+					     0x84, 0xec } };
+EFI_GUID gEfiCcixPerLogErrorSectionGuid = { 0x91335EF6,
+					    0xEBFB,
+					    0x4478,
+					    { 0xA6, 0xA6, 0x88, 0xB7, 0x28,
+					      0xCF, 0x75, 0xD7 } };
+EFI_GUID gEfiCxlProtocolErrorSectionGuid = { 0x80B9EFB4,
+					     0x52B5,
+					     0x4DE3,
+					     { 0xA7, 0x77, 0x68, 0x78, 0x4B,
+					       0x77, 0x10, 0x48 } };
+EFI_GUID gEfiCxlGeneralMediaErrorSectionGuid = { 0xfbcd0a77,
+						 0xc260,
+						 0x417f,
+						 { 0x85, 0xa9, 0x08, 0x8b, 0x16,
+						   0x21, 0xeb, 0xa6 } };
+EFI_GUID gEfiCxlDramEventErrorSectionGuid = { 0x601dcbb3,
+					      0x9c06,
+					      0x4eab,
+					      { 0xb8, 0xaf, 0x4e, 0x9b, 0xfb,
+						0x5c, 0x96, 0x24 } };
+EFI_GUID gEfiCxlMemoryModuleErrorSectionGuid = { 0xfe927475,
+						 0xdd59,
+						 0x4339,
+						 { 0xa5, 0x86, 0x79, 0xba, 0xb1,
+						   0x13, 0xb7, 0x74 } };
+EFI_GUID gEfiCxlPhysicalSwitchErrorSectionGuid = { 0x77cf9271,
+						   0x9c02,
+						   0x470b,
+						   { 0x9f, 0xe4, 0xbc, 0x7b,
+						     0x75, 0xf2, 0xda, 0x97 } };
+EFI_GUID gEfiCxlVirtualSwitchErrorSectionGuid = { 0x40d26425,
+						  0x3396,
+						  0x4c4d,
+						  { 0xa5, 0xda, 0x3d, 0x47,
+						    0x26, 0x3a, 0xf4, 0x25 } };
+EFI_GUID gEfiCxlMldPortErrorSectionGuid = { 0x8dc44363,
+					    0x0c96,
+					    0x4710,
+					    { 0xb7, 0xbf, 0x04, 0xbb, 0x99,
+					      0x53, 0x4c, 0x3f } };
 
 //IA32/x64 error segment GUIDs.
-EFI_GUID gEfiIa32x64ErrorTypeCacheCheckGuid = { 0xA55701F5, 0xE3EF, 0x43de, {0xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C } };
-EFI_GUID gEfiIa32x64ErrorTypeTlbCheckGuid = { 0xFC06B535, 0x5E1F, 0x4562, {0x9F, 0x25, 0x0A, 0x3B, 0x9A, 0xDB, 0x63, 0xC3 } };
-EFI_GUID gEfiIa32x64ErrorTypeBusCheckGuid = { 0x1CF3F8B3, 0xC5B1, 0x49a2, {0xAA, 0x59, 0x5E, 0xEF, 0x92, 0xFF, 0xA6, 0x3C } };
-EFI_GUID gEfiIa32x64ErrorTypeMsCheckGuid = { 0x48AB7F57, 0xDC34, 0x4f6c, {0xA7, 0xD3, 0xB0, 0xB5, 0xB0, 0xA7, 0x43, 0x14 } };
\ No newline at end of file
+EFI_GUID gEfiIa32x64ErrorTypeCacheCheckGuid = { 0xA55701F5,
+						0xE3EF,
+						0x43de,
+						{ 0xAC, 0x72, 0x24, 0x9B, 0x57,
+						  0x3F, 0xAD, 0x2C } };
+EFI_GUID gEfiIa32x64ErrorTypeTlbCheckGuid = { 0xFC06B535,
+					      0x5E1F,
+					      0x4562,
+					      { 0x9F, 0x25, 0x0A, 0x3B, 0x9A,
+						0xDB, 0x63, 0xC3 } };
+EFI_GUID gEfiIa32x64ErrorTypeBusCheckGuid = { 0x1CF3F8B3,
+					      0xC5B1,
+					      0x49a2,
+					      { 0xAA, 0x59, 0x5E, 0xEF, 0x92,
+						0xFF, 0xA6, 0x3C } };
+EFI_GUID gEfiIa32x64ErrorTypeMsCheckGuid = { 0x48AB7F57,
+					     0xDC34,
+					     0x4f6c,
+					     { 0xA7, 0xD3, 0xB0, 0xB5, 0xB0,
+					       0xA7, 0x43, 0x14 } };
diff --git a/edk/Cper.h b/edk/Cper.h
index 201bbfe..cc2b3ad 100644
--- a/edk/Cper.h
+++ b/edk/Cper.h
@@ -8,1283 +8,1380 @@
   @par Revision Reference:

   GUIDs defined in UEFI 2.7 Specification.

 

-**/

-#include "BaseTypes.h"

-

-#ifndef __CPER_GUID_H__

-#define __CPER_GUID_H__

-

-#pragma pack(1)

-

-#define EFI_ERROR_RECORD_SIGNATURE_START  SIGNATURE_32('C', 'P', 'E', 'R')

-#define EFI_ERROR_RECORD_SIGNATURE_END    0xFFFFFFFF

-

-#define EFI_ERROR_RECORD_REVISION  0x0101

-

-///

-/// Error Severity in Error Record Header and Error Section Descriptor

-///@{

-#define EFI_GENERIC_ERROR_RECOVERABLE  0x00000000

-#define EFI_GENERIC_ERROR_FATAL        0x00000001

-#define EFI_GENERIC_ERROR_CORRECTED    0x00000002

-#define EFI_GENERIC_ERROR_INFO         0x00000003

-///@}

-

-///

-/// The validation bit mask indicates the validity of the following fields

-/// in Error Record Header.

-///@{

-#define EFI_ERROR_RECORD_HEADER_PLATFORM_ID_VALID   BIT0

-#define EFI_ERROR_RECORD_HEADER_TIME_STAMP_VALID    BIT1

-#define EFI_ERROR_RECORD_HEADER_PARTITION_ID_VALID  BIT2

-///@}

-

-///

-/// Timestamp is precise if this bit is set and correlates to the time of the

-/// error event.

-///

-#define EFI_ERROR_TIME_STAMP_PRECISE  BIT0

-

-///

-/// The timestamp correlates to the time when the error information was collected

-/// by the system software and may not necessarily represent the time of the error

-/// event. The timestamp contains the local time in BCD format.

-///

-typedef struct {

-  UINT8    Seconds;

-  UINT8    Minutes;

-  UINT8    Hours;

-  UINT8    Flag;

-  UINT8    Day;

-  UINT8    Month;

-  UINT8    Year;

-  UINT8    Century;

-} EFI_ERROR_TIME_STAMP;

-

-///

-/// GUID value indicating the record association with an error event notification type.

-///@{

-#define EFI_EVENT_NOTIFICATION_TYEP_CMC_GUID \

-  { \

-    0x2DCE8BB1, 0xBDD7, 0x450e, { 0xB9, 0xAD, 0x9C, 0xF4, 0xEB, 0xD4, 0xF8, 0x90 } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYEP_CPE_GUID \

-  { \

-    0x4E292F96, 0xD843, 0x4a55, { 0xA8, 0xC2, 0xD4, 0x81, 0xF2, 0x7E, 0xBE, 0xEE } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYEP_MCE_GUID \

-  { \

-    0xE8F56FFE, 0x919C, 0x4cc5, { 0xBA, 0x88, 0x65, 0xAB, 0xE1, 0x49, 0x13, 0xBB } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYEP_PCIE_GUID \

-  { \

-    0xCF93C01F, 0x1A16, 0x4dfc, { 0xB8, 0xBC, 0x9C, 0x4D, 0xAF, 0x67, 0xC1, 0x04 } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYEP_INIT_GUID \

-  { \

-    0xCC5263E8, 0x9308, 0x454a, { 0x89, 0xD0, 0x34, 0x0B, 0xD3, 0x9B, 0xC9, 0x8E } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYEP_NMI_GUID \

-  { \

-    0x5BAD89FF, 0xB7E6, 0x42c9, { 0x81, 0x4A, 0xCF, 0x24, 0x85, 0xD6, 0xE9, 0x8A } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYEP_BOOT_GUID \

-  { \

-    0x3D61A466, 0xAB40, 0x409a, { 0xA6, 0x98, 0xF3, 0x62, 0xD4, 0x64, 0xB3, 0x8F } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYEP_DMAR_GUID \

-  { \

-    0x667DD791, 0xC6B3, 0x4c27, { 0x8A, 0x6B, 0x0F, 0x8E, 0x72, 0x2D, 0xEB, 0x41 } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYPE_DMAR_SEA \

-  { \

-    0x9A78788A, 0xBBE8, 0x11E4, { 0x80, 0x9E, 0x67, 0x61, 0x1E, 0x5D, 0x46, 0xB0 } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYPE_DMAR_SEI \

-  { \

-    0x5C284C81, 0xB0AE, 0x4E87, { 0xA3, 0x22, 0xB0, 0x4C, 0x85, 0x62, 0x43, 0x23 } \

-  }

-#define EFI_EVENT_NOTIFICATION_TYPE_DMAR_PEI \

-  { \

-    0x09A9D5AC, 0x5204, 0x4214, { 0x96, 0xE5, 0x94, 0x99, 0x2E, 0x75, 0x2B, 0xCD } \

-  }

-///@}

-

-///

-/// Error Record Header Flags

-///@{

-#define EFI_HW_ERROR_FLAGS_RECOVERED  0x00000001

-#define EFI_HW_ERROR_FLAGS_PREVERR    0x00000002

-#define EFI_HW_ERROR_FLAGS_SIMULATED  0x00000004

-///@}

-

-///

-/// Common error record header

-///

-typedef struct {

-  UINT32                  SignatureStart;

-  UINT16                  Revision;

-  UINT32                  SignatureEnd;

-  UINT16                  SectionCount;

-  UINT32                  ErrorSeverity;

-  UINT32                  ValidationBits;

-  UINT32                  RecordLength;

-  EFI_ERROR_TIME_STAMP    TimeStamp;

-  EFI_GUID                PlatformID;

-  EFI_GUID                PartitionID;

-  EFI_GUID                CreatorID;

-  EFI_GUID                NotificationType;

-  UINT64                  RecordID;

-  UINT32                  Flags;

-  UINT64                  PersistenceInfo;

-  UINT8                   Resv1[12];

-  ///

-  /// An array of SectionCount descriptors for the associated

-  /// sections. The number of valid sections is equivalent to the

-  /// SectionCount. The buffer size of the record may include

-  /// more space to dynamically add additional Section

-  /// Descriptors to the error record.

-  ///

-} EFI_COMMON_ERROR_RECORD_HEADER;

-

-#define EFI_ERROR_SECTION_REVISION  0x0100

-

-///

-/// Validity Fields in Error Section Descriptor.

-///

-#define EFI_ERROR_SECTION_FRU_ID_VALID      BIT0

-#define EFI_ERROR_SECTION_FRU_STRING_VALID  BIT1

-

-///

-/// Flag field contains information that describes the error section

-/// in Error Section Descriptor.

-///

-#define EFI_ERROR_SECTION_FLAGS_PRIMARY                   BIT0

-#define EFI_ERROR_SECTION_FLAGS_CONTAINMENT_WARNING       BIT1

-#define EFI_ERROR_SECTION_FLAGS_RESET                     BIT2

-#define EFI_ERROR_SECTION_FLAGS_ERROR_THRESHOLD_EXCEEDED  BIT3

-#define EFI_ERROR_SECTION_FLAGS_RESOURCE_NOT_ACCESSIBLE   BIT4

-#define EFI_ERROR_SECTION_FLAGS_LATENT_ERROR              BIT5

-

-///

-/// Error Sectition Type GUIDs in Error Section Descriptor

-///@{

-#define EFI_ERROR_SECTION_PROCESSOR_GENERIC_GUID \

-  { \

-    0x9876ccad, 0x47b4, 0x4bdb, { 0xb6, 0x5e, 0x16, 0xf1, 0x93, 0xc4, 0xf3, 0xdb } \

-  }

-#define EFI_ERROR_SECTION_PROCESSOR_SPECIFIC_GUID \

-  { \

-    0xdc3ea0b0, 0xa144, 0x4797, { 0xb9, 0x5b, 0x53, 0xfa, 0x24, 0x2b, 0x6e, 0x1d } \

-  }

-#define EFI_ERROR_SECTION_PROCESSOR_SPECIFIC_IA32X64_GUID \

-  { \

-    0xdc3ea0b0, 0xa144, 0x4797, { 0xb9, 0x5b, 0x53, 0xfa, 0x24, 0x2b, 0x6e, 0x1d } \

-  }

-#define EFI_ERROR_SECTION_PROCESSOR_SPECIFIC_ARM_GUID \

-  { \

-    0xe19e3d16, 0xbc11, 0x11e4, { 0x9c, 0xaa, 0xc2, 0x05, 0x1d, 0x5d, 0x46, 0xb0 } \

-  }

-#define EFI_ERROR_SECTION_PLATFORM_MEMORY_GUID \

-  { \

-    0xa5bc1114, 0x6f64, 0x4ede, { 0xb8, 0x63, 0x3e, 0x83, 0xed, 0x7c, 0x83, 0xb1 } \

-  }

-#define EFI_ERROR_SECTION_PLATFORM_MEMORY2_GUID \

-  { \

-    0x61EC04FC, 0x48E6, 0xD813, { 0x25, 0xC9, 0x8D, 0xAA, 0x44, 0x75, 0x0B, 0x12 } \

-  }

-#define EFI_ERROR_SECTION_PCIE_GUID \

-  { \

-    0xd995e954, 0xbbc1, 0x430f, { 0xad, 0x91, 0xb4, 0x4d, 0xcb, 0x3c, 0x6f, 0x35 } \

-  }

-#define EFI_ERROR_SECTION_FW_ERROR_RECORD_GUID \

-  { \

-    0x81212a96, 0x09ed, 0x4996, { 0x94, 0x71, 0x8d, 0x72, 0x9c, 0x8e, 0x69, 0xed } \

-  }

-#define EFI_ERROR_SECTION_PCI_PCIX_BUS_GUID \

-  { \

-    0xc5753963, 0x3b84, 0x4095, { 0xbf, 0x78, 0xed, 0xda, 0xd3, 0xf9, 0xc9, 0xdd } \

-  }

-#define EFI_ERROR_SECTION_PCI_DEVICE_GUID \

-  { \

-    0xeb5e4685, 0xca66, 0x4769, { 0xb6, 0xa2, 0x26, 0x06, 0x8b, 0x00, 0x13, 0x26 } \

-  }

-#define EFI_ERROR_SECTION_DMAR_GENERIC_GUID \

-  { \

-    0x5b51fef7, 0xc79d, 0x4434, { 0x8f, 0x1b, 0xaa, 0x62, 0xde, 0x3e, 0x2c, 0x64 } \

-  }

-#define EFI_ERROR_SECTION_DIRECTED_IO_DMAR_GUID \

-  { \

-    0x71761d37, 0x32b2, 0x45cd, { 0xa7, 0xd0, 0xb0, 0xfe, 0xdd, 0x93, 0xe8, 0xcf } \

-  }

-#define EFI_ERROR_SECTION_IOMMU_DMAR_GUID \

-  { \

-    0x036f84e1, 0x7f37, 0x428c, { 0xa7, 0x9e, 0x57, 0x5f, 0xdf, 0xaa, 0x84, 0xec } \

-  }

-///@}

-

-///

-/// Error Section Descriptor

-///

-typedef struct {

-  UINT32      SectionOffset;

-  UINT32      SectionLength;

-  UINT16      Revision;

-  UINT8       SecValidMask;

-  UINT8       Resv1;

-  UINT32      SectionFlags;

-  EFI_GUID    SectionType;

-  EFI_GUID    FruId;

-  UINT32      Severity;

-  CHAR8       FruString[20];

-} EFI_ERROR_SECTION_DESCRIPTOR;

-

-///

-/// The validation bit mask indicates whether or not each of the following fields are

-/// valid in Proessor Generic Error section.

-///@{

-#define EFI_GENERIC_ERROR_PROC_TYPE_VALID          BIT0

-#define EFI_GENERIC_ERROR_PROC_ISA_VALID           BIT1

-#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_VALID    BIT2

-#define EFI_GENERIC_ERROR_PROC_OPERATION_VALID     BIT3

-#define EFI_GENERIC_ERROR_PROC_FLAGS_VALID         BIT4

-#define EFI_GENERIC_ERROR_PROC_LEVEL_VALID         BIT5

-#define EFI_GENERIC_ERROR_PROC_VERSION_VALID       BIT6

-#define EFI_GENERIC_ERROR_PROC_BRAND_VALID         BIT7

-#define EFI_GENERIC_ERROR_PROC_ID_VALID            BIT8

-#define EFI_GENERIC_ERROR_PROC_TARGET_ADDR_VALID   BIT9

-#define EFI_GENERIC_ERROR_PROC_REQUESTER_ID_VALID  BIT10

-#define EFI_GENERIC_ERROR_PROC_RESPONDER_ID_VALID  BIT11

-#define EFI_GENERIC_ERROR_PROC_INST_IP_VALID       BIT12

-///@}

-

-///

-/// The type of the processor architecture in Proessor Generic Error section.

-///@{

-#define EFI_GENERIC_ERROR_PROC_TYPE_IA32_X64  0x00

-#define EFI_GENERIC_ERROR_PROC_TYPE_IA64      0x01

-#define EFI_GENERIC_ERROR_PROC_TYPE_ARM       0x02

-///@}

-

-///

-/// The type of the instruction set executing when the error occurred in Proessor

-/// Generic Error section.

-///@{

-#define EFI_GENERIC_ERROR_PROC_ISA_IA32         0x00

-#define EFI_GENERIC_ERROR_PROC_ISA_IA64         0x01

-#define EFI_GENERIC_ERROR_PROC_ISA_X64          0x02

-#define EFI_GENERIC_ERROR_PROC_ISA_ARM_A32_T32  0x03

-#define EFI_GENERIC_ERROR_PROC_ISA_ARM_A64      0x04

-///@}

-

-///

-/// The type of error that occurred in Proessor Generic Error section.

-///@{

-#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_UNKNOWN     0x00

-#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_CACHE       0x01

-#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_TLB         0x02

-#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_BUS         0x04

-#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_MICRO_ARCH  0x08

-///@}

-

-///

-/// The type of operation in Proessor Generic Error section.

-///@{

-#define EFI_GENERIC_ERROR_PROC_OPERATION_GENERIC           0x00

-#define EFI_GENERIC_ERROR_PROC_OPERATION_DATA_READ         0x01

-#define EFI_GENERIC_ERROR_PROC_OPERATION_DATA_WRITE        0x02

-#define EFI_GENERIC_ERROR_PROC_OPERATION_INSTRUCTION_EXEC  0x03

-///@}

-

-///

-/// Flags bit mask indicates additional information about the error in Proessor Generic

-/// Error section

-///@{

-#define EFI_GENERIC_ERROR_PROC_FLAGS_RESTARTABLE  BIT0

-#define EFI_GENERIC_ERROR_PROC_FLAGS_PRECISE_IP   BIT1

-#define EFI_GENERIC_ERROR_PROC_FLAGS_OVERFLOW     BIT2

-#define EFI_GENERIC_ERROR_PROC_FLAGS_CORRECTED    BIT3

-///@}

-

-///

-/// Processor Generic Error Section

-/// describes processor reported hardware errors for logical processors in the system.

-///

-typedef struct {

-  UINT64    ValidFields;

-  UINT8     Type;

-  UINT8     Isa;

-  UINT8     ErrorType;

-  UINT8     Operation;

-  UINT8     Flags;

-  UINT8     Level;

-  UINT16    Resv1;

-  UINT64    VersionInfo;

-  CHAR8     BrandString[128];

-  UINT64    ApicId;

-  UINT64    TargetAddr;

-  UINT64    RequestorId;

-  UINT64    ResponderId;

-  UINT64    InstructionIP;

-} EFI_PROCESSOR_GENERIC_ERROR_DATA;

-

-///

-/// IA32 and x64 Specific definitions.

-///

-

-///

-/// GUID value indicating the type of Processor Error Information structure

-/// in IA32/X64 Processor Error Information Structure.

-///@{

-#define EFI_IA32_X64_ERROR_TYPE_CACHE_CHECK_GUID \

-  { \

-    0xA55701F5, 0xE3EF, 0x43de, {0xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C } \

-  }

-#define EFI_IA32_X64_ERROR_TYPE_TLB_CHECK_GUID \

-  { \

-    0xFC06B535, 0x5E1F, 0x4562, {0x9F, 0x25, 0x0A, 0x3B, 0x9A, 0xDB, 0x63, 0xC3 } \

-  }

-#define EFI_IA32_X64_ERROR_TYPE_BUS_CHECK_GUID \

-  { \

-    0x1CF3F8B3, 0xC5B1, 0x49a2, {0xAA, 0x59, 0x5E, 0xEF, 0x92, 0xFF, 0xA6, 0x3C } \

-  }

-#define EFI_IA32_X64_ERROR_TYPE_MS_CHECK_GUID \

-  { \

-    0x48AB7F57, 0xDC34, 0x4f6c, {0xA7, 0xD3, 0xB0, 0xB5, 0xB0, 0xA7, 0x43, 0x14 } \

-  }

-extern EFI_GUID   gEfiIa32x64ErrorTypeCacheCheckGuid;

-extern EFI_GUID   gEfiIa32x64ErrorTypeTlbCheckGuid;

-extern EFI_GUID   gEfiIa32x64ErrorTypeBusCheckGuid;

-extern EFI_GUID   gEfiIa32x64ErrorTypeMsCheckGuid;

-

-///@}

-

-///

-/// The validation bit mask indicates which fields in the IA32/X64 Processor

-/// Error Record structure are valid.

-///@{

-#define EFI_IA32_X64_PROCESSOR_ERROR_APIC_ID_VALID      BIT0

-#define EFI_IA32_X64_PROCESSOR_ERROR_CPU_ID_INFO_VALID  BIT1

-///@}

-

-///

-/// IA32/X64 Processor Error Record

-///

-typedef struct {

-  UINT64    ValidFields;

-  UINT64    ApicId;

-  UINT8     CpuIdInfo[48];

-} EFI_IA32_X64_PROCESSOR_ERROR_RECORD;

-

-///

-/// The validation bit mask indicates which fields in the Cache Check structure

-/// are valid.

-///@{

-#define EFI_CACHE_CHECK_TRANSACTION_TYPE_VALID  BIT0

-#define EFI_CACHE_CHECK_OPERATION_VALID         BIT1

-#define EFI_CACHE_CHECK_LEVEL_VALID             BIT2

-#define EFI_CACHE_CHECK_CONTEXT_CORRUPT_VALID   BIT3

-#define EFI_CACHE_CHECK_UNCORRECTED_VALID       BIT4

-#define EFI_CACHE_CHECK_PRECISE_IP_VALID        BIT5

-#define EFI_CACHE_CHECK_RESTARTABLE_VALID       BIT6

-#define EFI_CACHE_CHECK_OVERFLOW_VALID          BIT7

-///@}

-

-///

-/// Type of cache error in the Cache Check structure

-///@{

-#define EFI_CACHE_CHECK_ERROR_TYPE_INSTRUCTION  0

-#define EFI_CACHE_CHECK_ERROR_TYPE_DATA_ACCESS  1

-#define EFI_CACHE_CHECK_ERROR_TYPE_GENERIC      2

-///@}

-

-///

-/// Type of cache operation that caused the error in the Cache

-/// Check structure

-///@{

-#define EFI_CACHE_CHECK_OPERATION_TYPE_GENERIC            0

-#define EFI_CACHE_CHECK_OPERATION_TYPE_GENERIC_READ       1

-#define EFI_CACHE_CHECK_OPERATION_TYPE_GENERIC_WRITE      2

-#define EFI_CACHE_CHECK_OPERATION_TYPE_DATA_READ          3

-#define EFI_CACHE_CHECK_OPERATION_TYPE_DATA_WRITE         4

-#define EFI_CACHE_CHECK_OPERATION_TYPE_INSTRUCTION_FETCH  5

-#define EFI_CACHE_CHECK_OPERATION_TYPE_PREFETCH           6

-#define EFI_CACHE_CHECK_OPERATION_TYPE_EVICTION           7

-#define EFI_CACHE_CHECK_OPERATION_TYPE_SNOOP              8

-///@}

-

-///

-/// IA32/X64 Cache Check Structure

-///

-typedef struct {

-  UINT64    ValidFields      : 16;

-  UINT64    TransactionType  : 2;

-  UINT64    Operation        : 4;

-  UINT64    Level            : 3;

-  UINT64    ContextCorrupt   : 1;

-  UINT64    ErrorUncorrected : 1;

-  UINT64    PreciseIp        : 1;

-  UINT64    RestartableIp    : 1;

-  UINT64    Overflow         : 1;

-  UINT64    Resv1            : 34;

-} EFI_IA32_X64_CACHE_CHECK_INFO;

-

-///

-/// The validation bit mask indicates which fields in the TLB Check structure

-/// are valid.

-///@{

-#define EFI_TLB_CHECK_TRANSACTION_TYPE_VALID  BIT0

-#define EFI_TLB_CHECK_OPERATION_VALID         BIT1

-#define EFI_TLB_CHECK_LEVEL_VALID             BIT2

-#define EFI_TLB_CHECK_CONTEXT_CORRUPT_VALID   BIT3

-#define EFI_TLB_CHECK_UNCORRECTED_VALID       BIT4

-#define EFI_TLB_CHECK_PRECISE_IP_VALID        BIT5

-#define EFI_TLB_CHECK_RESTARTABLE_VALID       BIT6

-#define EFI_TLB_CHECK_OVERFLOW_VALID          BIT7

-///@}

-

-///

-/// Type of cache error in the TLB Check structure

-///@{

-#define EFI_TLB_CHECK_ERROR_TYPE_INSTRUCTION  0

-#define EFI_TLB_CHECK_ERROR_TYPE_DATA_ACCESS  1

-#define EFI_TLB_CHECK_ERROR_TYPE_GENERIC      2

-///@}

-

-///

-/// Type of cache operation that caused the error in the TLB

-/// Check structure

-///@{

-#define EFI_TLB_CHECK_OPERATION_TYPE_GENERIC        0

-#define EFI_TLB_CHECK_OPERATION_TYPE_GENERIC_READ   1

-#define EFI_TLB_CHECK_OPERATION_TYPE_GENERIC_WRITE  2

-#define EFI_TLB_CHECK_OPERATION_TYPE_DATA_READ      3

-#define EFI_TLB_CHECK_OPERATION_TYPE_DATA_WRITE     4

-#define EFI_TLB_CHECK_OPERATION_TYPE_INST_FETCH     5

-#define EFI_TLB_CHECK_OPERATION_TYPE_PREFETCH       6

-///@}

-

-///

-/// IA32/X64 TLB Check Structure

-///

-typedef struct {

-  UINT64    ValidFields      : 16;

-  UINT64    TransactionType  : 2;

-  UINT64    Operation        : 4;

-  UINT64    Level            : 3;

-  UINT64    ContextCorrupt   : 1;

-  UINT64    ErrorUncorrected : 1;

-  UINT64    PreciseIp        : 1;

-  UINT64    RestartableIp    : 1;

-  UINT64    Overflow         : 1;

-  UINT64    Resv1            : 34;

-} EFI_IA32_X64_TLB_CHECK_INFO;

-

-///

-/// The validation bit mask indicates which fields in the MS Check structure

-/// are valid.

-///@{

-#define EFI_BUS_CHECK_TRANSACTION_TYPE_VALID    BIT0

-#define EFI_BUS_CHECK_OPERATION_VALID           BIT1

-#define EFI_BUS_CHECK_LEVEL_VALID               BIT2

-#define EFI_BUS_CHECK_CONTEXT_CORRUPT_VALID     BIT3

-#define EFI_BUS_CHECK_UNCORRECTED_VALID         BIT4

-#define EFI_BUS_CHECK_PRECISE_IP_VALID          BIT5

-#define EFI_BUS_CHECK_RESTARTABLE_VALID         BIT6

-#define EFI_BUS_CHECK_OVERFLOW_VALID            BIT7

-#define EFI_BUS_CHECK_PARTICIPATION_TYPE_VALID  BIT8

-#define EFI_BUS_CHECK_TIME_OUT_VALID            BIT9

-#define EFI_BUS_CHECK_ADDRESS_SPACE_VALID       BIT10

-///@}

-

-///

-/// Type of cache error in the Bus Check structure

-///@{

-#define EFI_BUS_CHECK_ERROR_TYPE_INSTRUCTION  0

-#define EFI_BUS_CHECK_ERROR_TYPE_DATA_ACCESS  1

-#define EFI_BUS_CHECK_ERROR_TYPE_GENERIC      2

-///@}

-

-///

-/// Type of cache operation that caused the error in the Bus

-/// Check structure

-///@{

-#define EFI_BUS_CHECK_OPERATION_TYPE_GENERIC        0

-#define EFI_BUS_CHECK_OPERATION_TYPE_GENERIC_READ   1

-#define EFI_BUS_CHECK_OPERATION_TYPE_GENERIC_WRITE  2

-#define EFI_BUS_CHECK_OPERATION_TYPE_DATA_READ      3

-#define EFI_BUS_CHECK_OPERATION_TYPE_DATA_WRITE     4

-#define EFI_BUS_CHECK_OPERATION_TYPE_INST_FETCH     5

-#define EFI_BUS_CHECK_OPERATION_TYPE_PREFETCH       6

-///@}

-

-///

-/// Type of Participation

-///@{

-#define EFI_BUS_CHECK_PARTICIPATION_TYPE_REQUEST    0

-#define EFI_BUS_CHECK_PARTICIPATION_TYPE_RESPONDED  1

-#define EFI_BUS_CHECK_PARTICIPATION_TYPE_OBSERVED   2

-#define EFI_BUS_CHECK_PARTICIPATION_TYPE_GENERIC    3

-///@}

-

-///

-/// Type of Address Space

-///@{

-#define EFI_BUS_CHECK_ADDRESS_SPACE_TYPE_MEMORY    0

-#define EFI_BUS_CHECK_ADDRESS_SPACE_TYPE_RESERVED  1

-#define EFI_BUS_CHECK_ADDRESS_SPACE_TYPE_IO        2

-#define EFI_BUS_CHECK_ADDRESS_SPACE_TYPE_OTHER     3

-///@}

-

-///

-/// IA32/X64 Bus Check Structure

-///

-typedef struct {

-  UINT64    ValidFields       : 16;

-  UINT64    TransactionType   : 2;

-  UINT64    Operation         : 4;

-  UINT64    Level             : 3;

-  UINT64    ContextCorrupt    : 1;

-  UINT64    ErrorUncorrected  : 1;

-  UINT64    PreciseIp         : 1;

-  UINT64    RestartableIp     : 1;

-  UINT64    Overflow          : 1;

-  UINT64    ParticipationType : 2;

-  UINT64    TimeOut           : 1;

-  UINT64    AddressSpace      : 2;

-  UINT64    Resv1             : 29;

-} EFI_IA32_X64_BUS_CHECK_INFO;

-

-///

-/// The validation bit mask indicates which fields in the MS Check structure

-/// are valid.

-///@{

-#define EFI_MS_CHECK_ERROR_TYPE_VALID       BIT0

-#define EFI_MS_CHECK_CONTEXT_CORRUPT_VALID  BIT1

-#define EFI_MS_CHECK_UNCORRECTED_VALID      BIT2

-#define EFI_MS_CHECK_PRECISE_IP_VALID       BIT3

-#define EFI_MS_CHECK_RESTARTABLE_VALID      BIT4

-#define EFI_MS_CHECK_OVERFLOW_VALID         BIT5

-///@}

-

-///

-/// Error type identifies the operation that caused the error.

-///@{

-#define EFI_MS_CHECK_ERROR_TYPE_NO                     0

-#define EFI_MS_CHECK_ERROR_TYPE_UNCLASSIFIED           1

-#define EFI_MS_CHECK_ERROR_TYPE_MICROCODE_PARITY       2

-#define EFI_MS_CHECK_ERROR_TYPE_EXTERNAL               3

-#define EFI_MS_CHECK_ERROR_TYPE_FRC                    4

-#define EFI_MS_CHECK_ERROR_TYPE_INTERNAL_UNCLASSIFIED  5

-///@}

-

-///

-/// IA32/X64 MS Check Field Description

-///

-typedef struct {

-  UINT64    ValidFields      : 16;

-  UINT64    ErrorType        : 3;

-  UINT64    ContextCorrupt   : 1;

-  UINT64    ErrorUncorrected : 1;

-  UINT64    PreciseIp        : 1;

-  UINT64    RestartableIp    : 1;

-  UINT64    Overflow         : 1;

-  UINT64    Resv1            : 40;

-} EFI_IA32_X64_MS_CHECK_INFO;

-

-///

-/// IA32/X64 Check Information Item

-///

-typedef union {

-  EFI_IA32_X64_CACHE_CHECK_INFO    CacheCheck;

-  EFI_IA32_X64_TLB_CHECK_INFO      TlbCheck;

-  EFI_IA32_X64_BUS_CHECK_INFO      BusCheck;

-  EFI_IA32_X64_MS_CHECK_INFO       MsCheck;

-  UINT64                           Data64;

-} EFI_IA32_X64_CHECK_INFO_ITEM;

-

-///

-/// The validation bit mask indicates which fields in the IA32/X64 Processor Error

-/// Information Structure are valid.

-///@{

-#define EFI_IA32_X64_ERROR_PROC_CHECK_INFO_VALID    BIT0

-#define EFI_IA32_X64_ERROR_PROC_TARGET_ADDR_VALID   BIT1

-#define EFI_IA32_X64_ERROR_PROC_REQUESTER_ID_VALID  BIT2

-#define EFI_IA32_X64_ERROR_PROC_RESPONDER_ID_VALID  BIT3

-#define EFI_IA32_X64_ERROR_PROC_INST_IP_VALID       BIT4

-///@}

-

-///

-/// IA32/X64 Processor Error Information Structure

-///

-typedef struct {

-  EFI_GUID                        ErrorType;

-  UINT64                          ValidFields;

-  EFI_IA32_X64_CHECK_INFO_ITEM    CheckInfo;

-  UINT64                          TargetId;

-  UINT64                          RequestorId;

-  UINT64                          ResponderId;

-  UINT64                          InstructionIP;

-} EFI_IA32_X64_PROCESS_ERROR_INFO;

-

-///

-/// IA32/X64 Processor Context Information Structure

-///

-typedef struct {

-  UINT16    RegisterType;

-  UINT16    ArraySize;

-  UINT32    MsrAddress;

-  UINT64    MmRegisterAddress;

-  //

-  // This field will provide the contents of the actual registers or raw data.

-  // The number of Registers or size of the raw data reported is determined

-  // by (Array Size / 8) or otherwise specified by the context structure type

-  // definition.

-  //

-} EFI_IA32_X64_PROCESSOR_CONTEXT_INFO;

-

-///

-/// Register Context Type

-///@{

-#define EFI_REG_CONTEXT_TYPE_UNCLASSIFIED  0x0000

-#define EFI_REG_CONTEXT_TYPE_MSR           0x0001

-#define EFI_REG_CONTEXT_TYPE_IA32          0x0002

-#define EFI_REG_CONTEXT_TYPE_X64           0x0003

-#define EFI_REG_CONTEXT_TYPE_FXSAVE        0x0004

-#define EFI_REG_CONTEXT_TYPE_DR_IA32       0x0005

-#define EFI_REG_CONTEXT_TYPE_DR_X64        0x0006

-#define EFI_REG_CONTEXT_TYPE_MEM_MAP       0x0007

-///@}

-

-///

-/// IA32 Register State

-///

-typedef struct {

-  UINT32    Eax;

-  UINT32    Ebx;

-  UINT32    Ecx;

-  UINT32    Edx;

-  UINT32    Esi;

-  UINT32    Edi;

-  UINT32    Ebp;

-  UINT32    Esp;

-  UINT16    Cs;

-  UINT16    Ds;

-  UINT16    Ss;

-  UINT16    Es;

-  UINT16    Fs;

-  UINT16    Gs;

-  UINT32    Eflags;

-  UINT32    Eip;

-  UINT32    Cr0;

-  UINT32    Cr1;

-  UINT32    Cr2;

-  UINT32    Cr3;

-  UINT32    Cr4;

-  UINT32    Gdtr[2];

-  UINT32    Idtr[2];

-  UINT16    Ldtr;

-  UINT16    Tr;

-} EFI_CONTEXT_IA32_REGISTER_STATE;

-

-///

-/// X64 Register State

-///

-typedef struct {

-  UINT64    Rax;

-  UINT64    Rbx;

-  UINT64    Rcx;

-  UINT64    Rdx;

-  UINT64    Rsi;

-  UINT64    Rdi;

-  UINT64    Rbp;

-  UINT64    Rsp;

-  UINT64    R8;

-  UINT64    R9;

-  UINT64    R10;

-  UINT64    R11;

-  UINT64    R12;

-  UINT64    R13;

-  UINT64    R14;

-  UINT64    R15;

-  UINT16    Cs;

-  UINT16    Ds;

-  UINT16    Ss;

-  UINT16    Es;

-  UINT16    Fs;

-  UINT16    Gs;

-  UINT32    Resv1;

-  UINT64    Rflags;

-  UINT64    Rip;

-  UINT64    Cr0;

-  UINT64    Cr1;

-  UINT64    Cr2;

-  UINT64    Cr3;

-  UINT64    Cr4;

-  UINT64    Cr8;

-  UINT64    Gdtr[2];

-  UINT64    Idtr[2];

-  UINT16    Ldtr;

-  UINT16    Tr;

-} EFI_CONTEXT_X64_REGISTER_STATE;

-

-///

-/// The validation bit mask indicates each of the following field is in IA32/X64

-/// Processor Error Section.

-///

-typedef struct {

-  UINT64    ApicIdValid     : 1;

-  UINT64    CpuIdInforValid : 1;

-  UINT64    ErrorInfoNum    : 6;

-  UINT64    ContextNum      : 6;

-  UINT64    Resv1           : 50;

-} EFI_IA32_X64_VALID_BITS;

-

-///

-/// Error Status Fields

-///

-typedef struct {

-  UINT64    Resv1               : 8;

-  UINT64    Type                : 8;

-  UINT64    AddressSignal       : 1;      ///< Error in Address signals or in Address portion of transaction

-  UINT64    ControlSignal       : 1;      ///< Error in Control signals or in Control portion of transaction

-  UINT64    DataSignal          : 1;      ///< Error in Data signals or in Data portion of transaction

-  UINT64    DetectedByResponder : 1;      ///< Error detected by responder

-  UINT64    DetectedByRequester : 1;      ///< Error detected by requestor

-  UINT64    FirstError          : 1;      ///< First Error in the sequence - option field

-  UINT64    OverflowNotLogged   : 1;      ///< Additional errors were not logged due to lack of resources

-  UINT64    Resv2               : 41;

-} EFI_GENERIC_ERROR_STATUS;

-

-///

-/// CPER Generic Error Codes

-///

-#define CPER_GENERIC_ERROR_TYPES_KEYS (int []){1, 16, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}

-#define CPER_GENERIC_ERROR_TYPES_VALUES (const char*[]){"ERR_INTERNAL", "ERR_BUS", "ERR_MEM", "ERR_TLB", \

-    "ERR_CACHE", "ERR_FUNCTION", "ERR_SELFTEST", "ERR_FLOW", "ERR_MAP", "ERR_IMPROPER", "ERR_UNIMPL", \

-    "ERR_LOL", "ERR_RESPONSE", "ERR_PARITY", "ERR_PROTOCOL", "ERR_ERROR", "ERR_TIMEOUT", "ERR_POISONED"}

-#define CPER_GENERIC_ERROR_TYPES_DESCRIPTIONS (const char*[]){\

-    "Error detected internal to the component.", \

-    "Error detected in the bus.", \

-    "Storage error in memory (DRAM).", \

-    "Storage error in TLB.", \

-    "Storage error in cache.", \

-    "Error in one or more functional units.", \

-    "Component failed self test.", \

-    "Overflow or underflow of internal queue.", \

-    "Virtual address not found on IO-TLB or IO-PDIR.", \

-    "Improper access error.", \

-    "Access to a memory address which is not mapped to any component.", \

-    "Loss of Lockstep error.", \

-    "Response not associated with a request.", \

-    "Bus parity error (must also set the A, C, or D bits).", \

-    "Detection of a protocol error.", \

-    "Detection of a PATH_ERROR.", \

-    "Bus operation timeout.", \

-    "A read was issued to data that has been poisoned."}

-

-///

-/// Error Type

-///

-typedef enum {

-  ///

-  /// General Internal errors

-  ///

-  ErrorInternal = 1,

-  ErrorBus      = 16,

-  ///

-  /// Component Internal errors

-  ///

-  ErrorMemStorage     = 4,        // Error in memory device

-  ErrorTlbStorage     = 5,        // TLB error in cache

-  ErrorCacheStorage   = 6,

-  ErrorFunctionalUnit = 7,

-  ErrorSelftest       = 8,

-  ErrorOverflow       = 9,

-  ///

-  /// Bus internal errors

-  ///

-  ErrorVirtualMap      = 17,

-  ErrorAccessInvalid   = 18,      // Improper access

-  ErrorUnimplAccess    = 19,      // Unimplemented memory access

-  ErrorLossOfLockstep  = 20,

-  ErrorResponseInvalid = 21,       // Response not associated with request

-  ErrorParity          = 22,

-  ErrorProtocol        = 23,

-  ErrorPath            = 24,      // Detected path error

-  ErrorTimeout         = 25,      // Bus timeout

-  ErrorPoisoned        = 26       // Read data poisoned

-} EFI_GENERIC_ERROR_STATUS_ERROR_TYPE;

-

-///

-/// Validation bit mask indicates which fields in the memory error record are valid

-/// in Memory Error section

-///@{

-#define EFI_PLATFORM_MEMORY_ERROR_STATUS_VALID                  BIT0

-#define EFI_PLATFORM_MEMORY_PHY_ADDRESS_VALID                   BIT1

-#define EFI_PLATFORM_MEMORY_PHY_ADDRESS_MASK_VALID              BIT2

-#define EFI_PLATFORM_MEMORY_NODE_VALID                          BIT3

-#define EFI_PLATFORM_MEMORY_CARD_VALID                          BIT4

-#define EFI_PLATFORM_MEMORY_MODULE_VALID                        BIT5

-#define EFI_PLATFORM_MEMORY_BANK_VALID                          BIT6

-#define EFI_PLATFORM_MEMORY_DEVICE_VALID                        BIT7

-#define EFI_PLATFORM_MEMORY_ROW_VALID                           BIT8

-#define EFI_PLATFORM_MEMORY_COLUMN_VALID                        BIT9

-#define EFI_PLATFORM_MEMORY_BIT_POS_VALID                       BIT10

-#define EFI_PLATFORM_MEMORY_REQUESTOR_ID_VALID                  BIT11

-#define EFI_PLATFORM_MEMORY_RESPONDER_ID_VALID                  BIT12

-#define EFI_PLATFORM_MEMORY_TARGET_ID_VALID                     BIT13

-#define EFI_PLATFORM_MEMORY_ERROR_TYPE_VALID                    BIT14

-#define EFI_PLATFORM_MEMORY_ERROR_RANK_NUM_VALID                BIT15

-#define EFI_PLATFORM_MEMORY_ERROR_CARD_HANDLE_VALID             BIT16

-#define EFI_PLATFORM_MEMORY_ERROR_MODULE_HANDLE_VALID           BIT17

-#define EFI_PLATFORM_MEMORY_ERROR_EXTENDED_ROW_BIT_16_17_VALID  BIT18

-#define EFI_PLATFORM_MEMORY_ERROR_BANK_GROUP_VALID              BIT19

-#define EFI_PLATFORM_MEMORY_ERROR_BANK_ADDRESS_VALID            BIT20

-#define EFI_PLATFORM_MEMORY_ERROR_CHIP_IDENTIFICATION_VALID     BIT21

-///@}

-

-///

-/// Memory Error Type identifies the type of error that occurred in Memory

-/// Error section

-///@{

-#define EFI_PLATFORM_MEMORY_ERROR_UNKNOWN                 0x00

-#define EFI_PLATFORM_MEMORY_ERROR_NONE                    0x01

-#define EFI_PLATFORM_MEMORY_ERROR_SINGLEBIT_ECC           0x02

-#define EFI_PLATFORM_MEMORY_ERROR_MLTIBIT_ECC             0x03

-#define EFI_PLATFORM_MEMORY_ERROR_SINGLESYMBOLS_CHIPKILL  0x04

-#define EFI_PLATFORM_MEMORY_ERROR_MULTISYMBOL_CHIPKILL    0x05

-#define EFI_PLATFORM_MEMORY_ERROR_MATER_ABORT             0x06

-#define EFI_PLATFORM_MEMORY_ERROR_TARGET_ABORT            0x07

-#define EFI_PLATFORM_MEMORY_ERROR_PARITY                  0x08

-#define EFI_PLATFORM_MEMORY_ERROR_WDT                     0x09

-#define EFI_PLATFORM_MEMORY_ERROR_INVALID_ADDRESS         0x0A

-#define EFI_PLATFORM_MEMORY_ERROR_MIRROR_FAILED           0x0B

-#define EFI_PLATFORM_MEMORY_ERROR_SPARING                 0x0C

-#define EFI_PLATFORM_MEMORY_ERROR_SCRUB_CORRECTED         0x0D

-#define EFI_PLATFORM_MEMORY_ERROR_SCRUB_UNCORRECTED       0x0E

-#define EFI_PLATFORM_MEMORY_ERROR_MEMORY_MAP_EVENT        0x0F

-///@}

-

-///

-/// Memory Error Section

-///

-typedef struct {

-  UINT64                      ValidFields;

-  EFI_GENERIC_ERROR_STATUS    ErrorStatus;

-  UINT64                      PhysicalAddress;     // Error physical address

-  UINT64                      PhysicalAddressMask; // Grnaularity

-  UINT16                      Node;                // Node #

-  UINT16                      Card;

-  UINT16                      ModuleRank;        // Module or Rank#

-  UINT16                      Bank;

-  UINT16                      Device;

-  UINT16                      Row;

-  UINT16                      Column;

-  UINT16                      BitPosition;

-  UINT64                      RequestorId;

-  UINT64                      ResponderId;

-  UINT64                      TargetId;

-  UINT8                       ErrorType;

-  UINT8                       Extended;

-  UINT16                      RankNum;

-  UINT16                      CardHandle;

-  UINT16                      ModuleHandle;

-} EFI_PLATFORM_MEMORY_ERROR_DATA;

-

-///

-/// Validation bit mask indicates which fields in the memory error record 2 are valid

-/// in Memory Error section 2

-///@{

-#define EFI_PLATFORM_MEMORY2_ERROR_STATUS_VALID       BIT0

-#define EFI_PLATFORM_MEMORY2_PHY_ADDRESS_VALID        BIT1

-#define EFI_PLATFORM_MEMORY2_PHY_ADDRESS_MASK_VALID   BIT2

-#define EFI_PLATFORM_MEMORY2_NODE_VALID               BIT3

-#define EFI_PLATFORM_MEMORY2_CARD_VALID               BIT4

-#define EFI_PLATFORM_MEMORY2_MODULE_VALID             BIT5

-#define EFI_PLATFORM_MEMORY2_BANK_VALID               BIT6

-#define EFI_PLATFORM_MEMORY2_DEVICE_VALID             BIT7

-#define EFI_PLATFORM_MEMORY2_ROW_VALID                BIT8

-#define EFI_PLATFORM_MEMORY2_COLUMN_VALID             BIT9

-#define EFI_PLATFORM_MEMORY2_RANK_VALID               BIT10

-#define EFI_PLATFORM_MEMORY2_BIT_POS_VALID            BIT11

-#define EFI_PLATFORM_MEMORY2_CHIP_ID_VALID            BIT12

-#define EFI_PLATFORM_MEMORY2_MEMORY_ERROR_TYPE_VALID  BIT13

-#define EFI_PLATFORM_MEMORY2_STATUS_VALID             BIT14

-#define EFI_PLATFORM_MEMORY2_REQUESTOR_ID_VALID       BIT15

-#define EFI_PLATFORM_MEMORY2_RESPONDER_ID_VALID       BIT16

-#define EFI_PLATFORM_MEMORY2_TARGET_ID_VALID          BIT17

-#define EFI_PLATFORM_MEMORY2_CARD_HANDLE_VALID        BIT18

-#define EFI_PLATFORM_MEMORY2_MODULE_HANDLE_VALID      BIT19

-#define EFI_PLATFORM_MEMORY2_BANK_GROUP_VALID         BIT20

-#define EFI_PLATFORM_MEMORY2_BANK_ADDRESS_VALID       BIT21

-///@}

-

-///

-/// Memory Error Type identifies the type of error that occurred in Memory

-/// Error section 2

-///@{

-#define EFI_PLATFORM_MEMORY2_ERROR_UNKNOWN                0x00

-#define EFI_PLATFORM_MEMORY2_ERROR_NONE                   0x01

-#define EFI_PLATFORM_MEMORY2_ERROR_SINGLEBIT_ECC          0x02

-#define EFI_PLATFORM_MEMORY2_ERROR_MLTIBIT_ECC            0x03

-#define EFI_PLATFORM_MEMORY2_ERROR_SINGLESYMBOL_CHIPKILL  0x04

-#define EFI_PLATFORM_MEMORY2_ERROR_MULTISYMBOL_CHIPKILL   0x05

-#define EFI_PLATFORM_MEMORY2_ERROR_MASTER_ABORT           0x06

-#define EFI_PLATFORM_MEMORY2_ERROR_TARGET_ABORT           0x07

-#define EFI_PLATFORM_MEMORY2_ERROR_PARITY                 0x08

-#define EFI_PLATFORM_MEMORY2_ERROR_WDT                    0x09

-#define EFI_PLATFORM_MEMORY2_ERROR_INVALID_ADDRESS        0x0A

-#define EFI_PLATFORM_MEMORY2_ERROR_MIRROR_BROKEN          0x0B

-#define EFI_PLATFORM_MEMORY2_ERROR_MEMORY_SPARING         0x0C

-#define EFI_PLATFORM_MEMORY2_ERROR_SCRUB_CORRECTED        0x0D

-#define EFI_PLATFORM_MEMORY2_ERROR_SCRUB_UNCORRECTED      0x0E

-#define EFI_PLATFORM_MEMORY2_ERROR_MEMORY_MAP_EVENT       0x0F

-///@}

-

-///

-/// Memory Error Section 2

-///

-typedef struct {

-  UINT64                      ValidFields;

-  EFI_GENERIC_ERROR_STATUS    ErrorStatus;

-  UINT64                      PhysicalAddress;     // Error physical address

-  UINT64                      PhysicalAddressMask; // Grnaularity

-  UINT16                      Node;                // Node #

-  UINT16                      Card;

-  UINT16                      Module;             // Module or Rank#

-  UINT16                      Bank;

-  UINT32                      Device;

-  UINT32                      Row;

-  UINT32                      Column;

-  UINT32                      Rank;

-  UINT32                      BitPosition;

-  UINT8                       ChipId;

-  UINT8                       MemErrorType;

-  UINT8                       Status;

-  UINT8                       Reserved;

-  UINT64                      RequestorId;

-  UINT64                      ResponderId;

-  UINT64                      TargetId;

-  UINT32                      CardHandle;

-  UINT32                      ModuleHandle;

-} EFI_PLATFORM_MEMORY2_ERROR_DATA;

-

-///

-/// Validation bits mask indicates which of the following fields is valid

-/// in PCI Express Error Record.

-///@{

-#define EFI_PCIE_ERROR_PORT_TYPE_VALID        BIT0

-#define EFI_PCIE_ERROR_VERSION_VALID          BIT1

-#define EFI_PCIE_ERROR_COMMAND_STATUS_VALID   BIT2

-#define EFI_PCIE_ERROR_DEVICE_ID_VALID        BIT3

-#define EFI_PCIE_ERROR_SERIAL_NO_VALID        BIT4

-#define EFI_PCIE_ERROR_BRIDGE_CRL_STS_VALID   BIT5

-#define EFI_PCIE_ERROR_CAPABILITY_INFO_VALID  BIT6

-#define EFI_PCIE_ERROR_AER_INFO_VALID         BIT7

-///@}

-

-///

-/// PCIe Device/Port Type as defined in the PCI Express capabilities register

-///@{

-#define EFI_PCIE_ERROR_PORT_PCIE_ENDPOINT         0x00000000

-#define EFI_PCIE_ERROR_PORT_PCI_ENDPOINT          0x00000001

-#define EFI_PCIE_ERROR_PORT_ROOT_PORT             0x00000004

-#define EFI_PCIE_ERROR_PORT_UPSWITCH_PORT         0x00000005

-#define EFI_PCIE_ERROR_PORT_DOWNSWITCH_PORT       0x00000006

-#define EFI_PCIE_ERROR_PORT_PCIE_TO_PCI_BRIDGE    0x00000007

-#define EFI_PCIE_ERROR_PORT_PCI_TO_PCIE_BRIDGE    0x00000008

-#define EFI_PCIE_ERROR_PORT_ROOT_INT_ENDPOINT     0x00000009

-#define EFI_PCIE_ERROR_PORT_ROOT_EVENT_COLLECTOR  0x0000000A

-///@}

-

-///

-/// PCI Slot number

-///

-typedef struct {

-  UINT16    Resv1  : 3;

-  UINT16    Number : 13;

-} EFI_GENERIC_ERROR_PCI_SLOT;

-

-///

-/// PCIe Root Port PCI/bridge PCI compatible device number and

-/// bus number information to uniquely identify the root port or

-/// bridge. Default values for both the bus numbers is zero.

-///

-typedef struct {

-  UINT16                        VendorId;

-  UINT16                        DeviceId;

-  UINT8                         ClassCode[3];

-  UINT8                         Function;

-  UINT8                         Device;

-  UINT16                        Segment;

-  UINT8                         PrimaryOrDeviceBus;

-  UINT8                         SecondaryBus;

-  EFI_GENERIC_ERROR_PCI_SLOT    Slot;

-  UINT8                         Resv1;

-} EFI_GENERIC_ERROR_PCIE_DEV_BRIDGE_ID;

-

-///

-/// PCIe Capability Structure

-///

-typedef struct {

-  UINT8    PcieCap[60];

-} EFI_PCIE_ERROR_DATA_CAPABILITY;

-

-///

-/// PCIe Advanced Error Reporting Extended Capability Structure.

-///

-typedef struct {

-  UINT8    PcieAer[96];

-} EFI_PCIE_ERROR_DATA_AER;

-

-///

-/// PCI Express Error Record

-///

-typedef struct {

-  UINT64                                  ValidFields;

-  UINT32                                  PortType;

-  UINT32                                  Version;

-  UINT32                                  CommandStatus;

-  UINT32                                  Resv2;

-  EFI_GENERIC_ERROR_PCIE_DEV_BRIDGE_ID    DevBridge;

-  UINT64                                  SerialNo;

-  UINT32                                  BridgeControlStatus;

-  EFI_PCIE_ERROR_DATA_CAPABILITY          Capability;

-  EFI_PCIE_ERROR_DATA_AER                 AerInfo;

-} EFI_PCIE_ERROR_DATA;

-

-///

-/// Validation bits Indicates which of the following fields is valid

-/// in PCI/PCI-X Bus Error Section.

-///@{

-#define EFI_PCI_PCIX_BUS_ERROR_STATUS_VALID        BIT0

-#define EFI_PCI_PCIX_BUS_ERROR_TYPE_VALID          BIT1

-#define EFI_PCI_PCIX_BUS_ERROR_BUS_ID_VALID        BIT2

-#define EFI_PCI_PCIX_BUS_ERROR_BUS_ADDRESS_VALID   BIT3

-#define EFI_PCI_PCIX_BUS_ERROR_BUS_DATA_VALID      BIT4

-#define EFI_PCI_PCIX_BUS_ERROR_COMMAND_VALID       BIT5

-#define EFI_PCI_PCIX_BUS_ERROR_REQUESTOR_ID_VALID  BIT6

-#define EFI_PCI_PCIX_BUS_ERROR_COMPLETER_ID_VALID  BIT7

-#define EFI_PCI_PCIX_BUS_ERROR_TARGET_ID_VALID     BIT8

-///@}

-

-///

-/// PCI Bus Error Type in PCI/PCI-X Bus Error Section

-///@{

-#define EFI_PCI_PCIX_BUS_ERROR_UNKNOWN             0x0000

-#define EFI_PCI_PCIX_BUS_ERROR_DATA_PARITY         0x0001

-#define EFI_PCI_PCIX_BUS_ERROR_SYSTEM              0x0002

-#define EFI_PCI_PCIX_BUS_ERROR_MASTER_ABORT        0x0003

-#define EFI_PCI_PCIX_BUS_ERROR_BUS_TIMEOUT         0x0004

-#define EFI_PCI_PCIX_BUS_ERROR_MASTER_DATA_PARITY  0x0005

-#define EFI_PCI_PCIX_BUS_ERROR_ADDRESS_PARITY      0x0006

-#define EFI_PCI_PCIX_BUS_ERROR_COMMAND_PARITY      0x0007

-///@}

-

-///

-/// PCI/PCI-X Bus Error Section

-///

-typedef struct {

-  UINT64                      ValidFields;

-  EFI_GENERIC_ERROR_STATUS    ErrorStatus;

-  UINT16                      Type;

-  UINT16                      BusId;

-  UINT32                      Resv2;

-  UINT64                      BusAddress;

-  UINT64                      BusData;

-  UINT64                      BusCommand;

-  UINT64                      RequestorId;

-  UINT64                      ResponderId;

-  UINT64                      TargetId;

-} EFI_PCI_PCIX_BUS_ERROR_DATA;

-

-///

-/// Validation bits Indicates which of the following fields is valid

-/// in PCI/PCI-X Component Error Section.

-///@{

-#define EFI_PCI_PCIX_DEVICE_ERROR_STATUS_VALID         BIT0

-#define EFI_PCI_PCIX_DEVICE_ERROR_ID_INFO_VALID        BIT1

-#define EFI_PCI_PCIX_DEVICE_ERROR_MEM_NUM_VALID        BIT2

-#define EFI_PCI_PCIX_DEVICE_ERROR_IO_NUM_VALID         BIT3

-#define EFI_PCI_PCIX_DEVICE_ERROR_REG_DATA_PAIR_VALID  BIT4

-///@}

-

-///

-/// PCI/PCI-X Device Identification Information

-///

-typedef struct {

-  UINT16    VendorId;

-  UINT16    DeviceId;

-  UINT8     ClassCode[3];

-  UINT8     Function;

-  UINT8     Device;

-  UINT8     Bus;

-  UINT8     Segment;

-  UINT8     Resv1;

-  UINT32    Resv2;

-} EFI_GENERIC_ERROR_PCI_DEVICE_ID;

-

-///

-/// Identifies the type of firmware error record

-///@{

-#define EFI_FIRMWARE_ERROR_TYPE_IPF_SAL    0x00

-#define EFI_FIRMWARE_ERROR_TYPE_SOC_TYPE1  0x01

-#define EFI_FIRMWARE_ERROR_TYPE_SOC_TYPE2  0x02

-///@}

-

-///

-/// Firmware Error Record Section

-///

-typedef struct {

-  UINT8       ErrorType;

-  UINT8       Revision;

-  UINT8       Resv1[6];

-  UINT64      RecordId;

-  EFI_GUID    RecordIdGuid;

-} EFI_FIRMWARE_ERROR_DATA;

-

-///

-/// Fault Reason in DMAr Generic Error Section

-///@{

-#define EFI_DMA_FAULT_REASON_TABLE_ENTRY_NOT_PRESENT            0x01

-#define EFI_DMA_FAULT_REASON_TABLE_ENTRY_INVALID                0x02

-#define EFI_DMA_FAULT_REASON_ACCESS_MAPPING_TABLE_ERROR         0x03

-#define EFI_DMA_FAULT_REASON_RESV_BIT_ERROR_IN_MAPPING_TABLE    0x04

-#define EFI_DMA_FAULT_REASON_ACCESS_ADDR_OUT_OF_SPACE           0x05

-#define EFI_DMA_FAULT_REASON_INVALID_ACCESS                     0x06

-#define EFI_DMA_FAULT_REASON_INVALID_REQUEST                    0x07

-#define EFI_DMA_FAULT_REASON_ACCESS_TRANSLATE_TABLE_ERROR       0x08

-#define EFI_DMA_FAULT_REASON_RESV_BIT_ERROR_IN_TRANSLATE_TABLE  0x09

-#define EFI_DMA_FAULT_REASON_INVALID_COMMAOND                   0x0A

-#define EFI_DMA_FAULT_REASON_ACCESS_COMMAND_BUFFER_ERROR        0x0B

-///@}

-

-///

-/// DMA access type in DMAr Generic Error Section

-///@{

-#define EFI_DMA_ACCESS_TYPE_READ   0x00

-#define EFI_DMA_ACCESS_TYPE_WRITE  0x01

-///@}

-

-///

-/// DMA address type in DMAr Generic Error Section

-///@{

-#define EFI_DMA_ADDRESS_UNTRANSLATED  0x00

-#define EFI_DMA_ADDRESS_TRANSLATION   0x01

-///@}

-

-///

-/// Architecture type in DMAr Generic Error Section

-///@{

-#define EFI_DMA_ARCH_TYPE_VT     0x01

-#define EFI_DMA_ARCH_TYPE_IOMMU  0x02

-///@}

-

-///

-/// DMAr Generic Error Section

-///

-typedef struct {

-  UINT16    RequesterId;

-  UINT16    SegmentNumber;

-  UINT8     FaultReason;

-  UINT8     AccessType;

-  UINT8     AddressType;

-  UINT8     ArchType;

-  UINT64    DeviceAddr;

-  UINT8     Resv1[16];

-} EFI_DMAR_GENERIC_ERROR_DATA;

-

-///

-/// Intel VT for Directed I/O specific DMAr Errors

-///

-typedef struct {

-  UINT8     Version;

-  UINT8     Revision;

-  UINT8     OemId[6];

-  UINT64    Capability;

-  UINT64    CapabilityEx;

-  UINT32    GlobalCommand;

-  UINT32    GlobalStatus;

-  UINT32    FaultStatus;

-  UINT8     Resv1[12];

-  UINT64    FaultRecord[2];

-  UINT64    RootEntry[2];

-  UINT64    ContextEntry[2];

-  UINT64    PteL6;

-  UINT64    PteL5;

-  UINT64    PteL4;

-  UINT64    PteL3;

-  UINT64    PteL2;

-  UINT64    PteL1;

-} EFI_DIRECTED_IO_DMAR_ERROR_DATA;

-

-///

-/// IOMMU specific DMAr Errors

-///

-typedef struct {

-  UINT8     Revision;

-  UINT8     Resv1[7];

-  UINT64    Control;

-  UINT64    Status;

-  UINT8     Resv2[8];

-  UINT64    EventLogEntry[2];

-  UINT8     Resv3[16];

-  UINT64    DeviceTableEntry[4];

-  UINT64    PteL6;

-  UINT64    PteL5;

-  UINT64    PteL4;

-  UINT64    PteL3;

-  UINT64    PteL2;

-  UINT64    PteL1;

-} EFI_IOMMU_DMAR_ERROR_DATA;

-

-extern EFI_GUID   gEfiEventNotificationTypeCmcGuid;

-extern EFI_GUID   gEfiEventNotificationTypeCpeGuid;

-extern EFI_GUID   gEfiEventNotificationTypeMceGuid;

-extern EFI_GUID   gEfiEventNotificationTypePcieGuid;

-extern EFI_GUID   gEfiEventNotificationTypeInitGuid;

-extern EFI_GUID   gEfiEventNotificationTypeNmiGuid;

-extern EFI_GUID   gEfiEventNotificationTypeBootGuid;

-extern EFI_GUID   gEfiEventNotificationTypeDmarGuid;

-extern EFI_GUID   gEfiEventNotificationTypeSeaGuid;

-extern EFI_GUID   gEfiEventNotificationTypeSeiGuid;

-extern EFI_GUID   gEfiEventNotificationTypePeiGuid;

-extern EFI_GUID   gEfiEventNotificationTypeCxlGuid;

-extern EFI_GUID   gEfiProcessorGenericErrorSectionGuid;

-extern EFI_GUID   gEfiProcessorSpecificErrorSectionGuid;

-extern EFI_GUID   gEfiIa32X64ProcessorErrorSectionGuid;

-extern EFI_GUID   gEfiIpfProcessorErrorSectionGuid;

-extern EFI_GUID   gEfiArmProcessorErrorSectionGuid;

-extern EFI_GUID   gEfiPlatformMemoryErrorSectionGuid;

-extern EFI_GUID   gEfiPlatformMemoryError2SectionGuid;

-extern EFI_GUID   gEfiPcieErrorSectionGuid;

-extern EFI_GUID   gEfiFirmwareErrorSectionGuid;

-extern EFI_GUID   gEfiPciBusErrorSectionGuid;

-extern EFI_GUID   gEfiPciDevErrorSectionGuid;

-extern EFI_GUID   gEfiDMArGenericErrorSectionGuid;

-extern EFI_GUID   gEfiDirectedIoDMArErrorSectionGuid;

-extern EFI_GUID   gEfiIommuDMArErrorSectionGuid;

-extern EFI_GUID   gEfiCcixPerLogErrorSectionGuid;

-extern EFI_GUID   gEfiCxlProtocolErrorSectionGuid;

-extern EFI_GUID   gEfiCxlGeneralMediaErrorSectionGuid;

-extern EFI_GUID   gEfiCxlDramEventErrorSectionGuid;

-extern EFI_GUID   gEfiCxlMemoryModuleErrorSectionGuid;

-extern EFI_GUID   gEfiCxlPhysicalSwitchErrorSectionGuid;

-extern EFI_GUID   gEfiCxlVirtualSwitchErrorSectionGuid;

-extern EFI_GUID   gEfiCxlMldPortErrorSectionGuid;

-#pragma pack()

-

-#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)

-///

-/// IA32 and x64 Specific definitions.

-///

-

-extern EFI_GUID  gEfiIa32X64ErrorTypeCacheCheckGuid;

-extern EFI_GUID  gEfiIa32X64ErrorTypeTlbCheckGuid;

-extern EFI_GUID  gEfiIa32X64ErrorTypeBusCheckGuid;

-extern EFI_GUID  gEfiIa32X64ErrorTypeMsCheckGuid;

-

-#endif

-

-#endif

+**/
+#include "BaseTypes.h"
+
+#ifndef __CPER_GUID_H__
+#define __CPER_GUID_H__
+
+#pragma pack(1)
+
+#define EFI_ERROR_RECORD_SIGNATURE_START SIGNATURE_32('C', 'P', 'E', 'R')
+#define EFI_ERROR_RECORD_SIGNATURE_END	 0xFFFFFFFF
+
+#define EFI_ERROR_RECORD_REVISION 0x0101
+
+///
+/// Error Severity in Error Record Header and Error Section Descriptor
+///@{
+#define EFI_GENERIC_ERROR_RECOVERABLE 0x00000000
+#define EFI_GENERIC_ERROR_FATAL	      0x00000001
+#define EFI_GENERIC_ERROR_CORRECTED   0x00000002
+#define EFI_GENERIC_ERROR_INFO	      0x00000003
+///@}
+
+///
+/// The validation bit mask indicates the validity of the following fields
+/// in Error Record Header.
+///@{
+#define EFI_ERROR_RECORD_HEADER_PLATFORM_ID_VALID  BIT0
+#define EFI_ERROR_RECORD_HEADER_TIME_STAMP_VALID   BIT1
+#define EFI_ERROR_RECORD_HEADER_PARTITION_ID_VALID BIT2
+///@}
+
+///
+/// Timestamp is precise if this bit is set and correlates to the time of the
+/// error event.
+///
+#define EFI_ERROR_TIME_STAMP_PRECISE BIT0
+
+///
+/// The timestamp correlates to the time when the error information was collected
+/// by the system software and may not necessarily represent the time of the error
+/// event. The timestamp contains the local time in BCD format.
+///
+typedef struct {
+	UINT8 Seconds;
+	UINT8 Minutes;
+	UINT8 Hours;
+	UINT8 Flag;
+	UINT8 Day;
+	UINT8 Month;
+	UINT8 Year;
+	UINT8 Century;
+} EFI_ERROR_TIME_STAMP;
+
+///
+/// GUID value indicating the record association with an error event notification type.
+///@{
+#define EFI_EVENT_NOTIFICATION_TYEP_CMC_GUID                                   \
+	{                                                                      \
+		0x2DCE8BB1, 0xBDD7, 0x450e,                                    \
+		{                                                              \
+			0xB9, 0xAD, 0x9C, 0xF4, 0xEB, 0xD4, 0xF8, 0x90         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYEP_CPE_GUID                                   \
+	{                                                                      \
+		0x4E292F96, 0xD843, 0x4a55,                                    \
+		{                                                              \
+			0xA8, 0xC2, 0xD4, 0x81, 0xF2, 0x7E, 0xBE, 0xEE         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYEP_MCE_GUID                                   \
+	{                                                                      \
+		0xE8F56FFE, 0x919C, 0x4cc5,                                    \
+		{                                                              \
+			0xBA, 0x88, 0x65, 0xAB, 0xE1, 0x49, 0x13, 0xBB         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYEP_PCIE_GUID                                  \
+	{                                                                      \
+		0xCF93C01F, 0x1A16, 0x4dfc,                                    \
+		{                                                              \
+			0xB8, 0xBC, 0x9C, 0x4D, 0xAF, 0x67, 0xC1, 0x04         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYEP_INIT_GUID                                  \
+	{                                                                      \
+		0xCC5263E8, 0x9308, 0x454a,                                    \
+		{                                                              \
+			0x89, 0xD0, 0x34, 0x0B, 0xD3, 0x9B, 0xC9, 0x8E         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYEP_NMI_GUID                                   \
+	{                                                                      \
+		0x5BAD89FF, 0xB7E6, 0x42c9,                                    \
+		{                                                              \
+			0x81, 0x4A, 0xCF, 0x24, 0x85, 0xD6, 0xE9, 0x8A         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYEP_BOOT_GUID                                  \
+	{                                                                      \
+		0x3D61A466, 0xAB40, 0x409a,                                    \
+		{                                                              \
+			0xA6, 0x98, 0xF3, 0x62, 0xD4, 0x64, 0xB3, 0x8F         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYEP_DMAR_GUID                                  \
+	{                                                                      \
+		0x667DD791, 0xC6B3, 0x4c27,                                    \
+		{                                                              \
+			0x8A, 0x6B, 0x0F, 0x8E, 0x72, 0x2D, 0xEB, 0x41         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYPE_DMAR_SEA                                   \
+	{                                                                      \
+		0x9A78788A, 0xBBE8, 0x11E4,                                    \
+		{                                                              \
+			0x80, 0x9E, 0x67, 0x61, 0x1E, 0x5D, 0x46, 0xB0         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYPE_DMAR_SEI                                   \
+	{                                                                      \
+		0x5C284C81, 0xB0AE, 0x4E87,                                    \
+		{                                                              \
+			0xA3, 0x22, 0xB0, 0x4C, 0x85, 0x62, 0x43, 0x23         \
+		}                                                              \
+	}
+#define EFI_EVENT_NOTIFICATION_TYPE_DMAR_PEI                                   \
+	{                                                                      \
+		0x09A9D5AC, 0x5204, 0x4214,                                    \
+		{                                                              \
+			0x96, 0xE5, 0x94, 0x99, 0x2E, 0x75, 0x2B, 0xCD         \
+		}                                                              \
+	}
+///@}
+
+///
+/// Error Record Header Flags
+///@{
+#define EFI_HW_ERROR_FLAGS_RECOVERED 0x00000001
+#define EFI_HW_ERROR_FLAGS_PREVERR   0x00000002
+#define EFI_HW_ERROR_FLAGS_SIMULATED 0x00000004
+///@}
+
+///
+/// Common error record header
+///
+typedef struct {
+	UINT32 SignatureStart;
+	UINT16 Revision;
+	UINT32 SignatureEnd;
+	UINT16 SectionCount;
+	UINT32 ErrorSeverity;
+	UINT32 ValidationBits;
+	UINT32 RecordLength;
+	EFI_ERROR_TIME_STAMP TimeStamp;
+	EFI_GUID PlatformID;
+	EFI_GUID PartitionID;
+	EFI_GUID CreatorID;
+	EFI_GUID NotificationType;
+	UINT64 RecordID;
+	UINT32 Flags;
+	UINT64 PersistenceInfo;
+	UINT8 Resv1[12];
+	///
+	/// An array of SectionCount descriptors for the associated
+	/// sections. The number of valid sections is equivalent to the
+	/// SectionCount. The buffer size of the record may include
+	/// more space to dynamically add additional Section
+	/// Descriptors to the error record.
+	///
+} EFI_COMMON_ERROR_RECORD_HEADER;
+
+#define EFI_ERROR_SECTION_REVISION 0x0100
+
+///
+/// Validity Fields in Error Section Descriptor.
+///
+#define EFI_ERROR_SECTION_FRU_ID_VALID	   BIT0
+#define EFI_ERROR_SECTION_FRU_STRING_VALID BIT1
+
+///
+/// Flag field contains information that describes the error section
+/// in Error Section Descriptor.
+///
+#define EFI_ERROR_SECTION_FLAGS_PRIMARY			 BIT0
+#define EFI_ERROR_SECTION_FLAGS_CONTAINMENT_WARNING	 BIT1
+#define EFI_ERROR_SECTION_FLAGS_RESET			 BIT2
+#define EFI_ERROR_SECTION_FLAGS_ERROR_THRESHOLD_EXCEEDED BIT3
+#define EFI_ERROR_SECTION_FLAGS_RESOURCE_NOT_ACCESSIBLE	 BIT4
+#define EFI_ERROR_SECTION_FLAGS_LATENT_ERROR		 BIT5
+
+///
+/// Error Sectition Type GUIDs in Error Section Descriptor
+///@{
+#define EFI_ERROR_SECTION_PROCESSOR_GENERIC_GUID                               \
+	{                                                                      \
+		0x9876ccad, 0x47b4, 0x4bdb,                                    \
+		{                                                              \
+			0xb6, 0x5e, 0x16, 0xf1, 0x93, 0xc4, 0xf3, 0xdb         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_PROCESSOR_SPECIFIC_GUID                              \
+	{                                                                      \
+		0xdc3ea0b0, 0xa144, 0x4797,                                    \
+		{                                                              \
+			0xb9, 0x5b, 0x53, 0xfa, 0x24, 0x2b, 0x6e, 0x1d         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_PROCESSOR_SPECIFIC_IA32X64_GUID                      \
+	{                                                                      \
+		0xdc3ea0b0, 0xa144, 0x4797,                                    \
+		{                                                              \
+			0xb9, 0x5b, 0x53, 0xfa, 0x24, 0x2b, 0x6e, 0x1d         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_PROCESSOR_SPECIFIC_ARM_GUID                          \
+	{                                                                      \
+		0xe19e3d16, 0xbc11, 0x11e4,                                    \
+		{                                                              \
+			0x9c, 0xaa, 0xc2, 0x05, 0x1d, 0x5d, 0x46, 0xb0         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_PLATFORM_MEMORY_GUID                                 \
+	{                                                                      \
+		0xa5bc1114, 0x6f64, 0x4ede,                                    \
+		{                                                              \
+			0xb8, 0x63, 0x3e, 0x83, 0xed, 0x7c, 0x83, 0xb1         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_PLATFORM_MEMORY2_GUID                                \
+	{                                                                      \
+		0x61EC04FC, 0x48E6, 0xD813,                                    \
+		{                                                              \
+			0x25, 0xC9, 0x8D, 0xAA, 0x44, 0x75, 0x0B, 0x12         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_PCIE_GUID                                            \
+	{                                                                      \
+		0xd995e954, 0xbbc1, 0x430f,                                    \
+		{                                                              \
+			0xad, 0x91, 0xb4, 0x4d, 0xcb, 0x3c, 0x6f, 0x35         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_FW_ERROR_RECORD_GUID                                 \
+	{                                                                      \
+		0x81212a96, 0x09ed, 0x4996,                                    \
+		{                                                              \
+			0x94, 0x71, 0x8d, 0x72, 0x9c, 0x8e, 0x69, 0xed         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_PCI_PCIX_BUS_GUID                                    \
+	{                                                                      \
+		0xc5753963, 0x3b84, 0x4095,                                    \
+		{                                                              \
+			0xbf, 0x78, 0xed, 0xda, 0xd3, 0xf9, 0xc9, 0xdd         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_PCI_DEVICE_GUID                                      \
+	{                                                                      \
+		0xeb5e4685, 0xca66, 0x4769,                                    \
+		{                                                              \
+			0xb6, 0xa2, 0x26, 0x06, 0x8b, 0x00, 0x13, 0x26         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_DMAR_GENERIC_GUID                                    \
+	{                                                                      \
+		0x5b51fef7, 0xc79d, 0x4434,                                    \
+		{                                                              \
+			0x8f, 0x1b, 0xaa, 0x62, 0xde, 0x3e, 0x2c, 0x64         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_DIRECTED_IO_DMAR_GUID                                \
+	{                                                                      \
+		0x71761d37, 0x32b2, 0x45cd,                                    \
+		{                                                              \
+			0xa7, 0xd0, 0xb0, 0xfe, 0xdd, 0x93, 0xe8, 0xcf         \
+		}                                                              \
+	}
+#define EFI_ERROR_SECTION_IOMMU_DMAR_GUID                                      \
+	{                                                                      \
+		0x036f84e1, 0x7f37, 0x428c,                                    \
+		{                                                              \
+			0xa7, 0x9e, 0x57, 0x5f, 0xdf, 0xaa, 0x84, 0xec         \
+		}                                                              \
+	}
+///@}
+
+///
+/// Error Section Descriptor
+///
+typedef struct {
+	UINT32 SectionOffset;
+	UINT32 SectionLength;
+	UINT16 Revision;
+	UINT8 SecValidMask;
+	UINT8 Resv1;
+	UINT32 SectionFlags;
+	EFI_GUID SectionType;
+	EFI_GUID FruId;
+	UINT32 Severity;
+	CHAR8 FruString[20];
+} EFI_ERROR_SECTION_DESCRIPTOR;
+
+///
+/// The validation bit mask indicates whether or not each of the following fields are
+/// valid in Proessor Generic Error section.
+///@{
+#define EFI_GENERIC_ERROR_PROC_TYPE_VALID	  BIT0
+#define EFI_GENERIC_ERROR_PROC_ISA_VALID	  BIT1
+#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_VALID	  BIT2
+#define EFI_GENERIC_ERROR_PROC_OPERATION_VALID	  BIT3
+#define EFI_GENERIC_ERROR_PROC_FLAGS_VALID	  BIT4
+#define EFI_GENERIC_ERROR_PROC_LEVEL_VALID	  BIT5
+#define EFI_GENERIC_ERROR_PROC_VERSION_VALID	  BIT6
+#define EFI_GENERIC_ERROR_PROC_BRAND_VALID	  BIT7
+#define EFI_GENERIC_ERROR_PROC_ID_VALID		  BIT8
+#define EFI_GENERIC_ERROR_PROC_TARGET_ADDR_VALID  BIT9
+#define EFI_GENERIC_ERROR_PROC_REQUESTER_ID_VALID BIT10
+#define EFI_GENERIC_ERROR_PROC_RESPONDER_ID_VALID BIT11
+#define EFI_GENERIC_ERROR_PROC_INST_IP_VALID	  BIT12
+///@}
+
+///
+/// The type of the processor architecture in Proessor Generic Error section.
+///@{
+#define EFI_GENERIC_ERROR_PROC_TYPE_IA32_X64 0x00
+#define EFI_GENERIC_ERROR_PROC_TYPE_IA64     0x01
+#define EFI_GENERIC_ERROR_PROC_TYPE_ARM	     0x02
+///@}
+
+///
+/// The type of the instruction set executing when the error occurred in Proessor
+/// Generic Error section.
+///@{
+#define EFI_GENERIC_ERROR_PROC_ISA_IA32	       0x00
+#define EFI_GENERIC_ERROR_PROC_ISA_IA64	       0x01
+#define EFI_GENERIC_ERROR_PROC_ISA_X64	       0x02
+#define EFI_GENERIC_ERROR_PROC_ISA_ARM_A32_T32 0x03
+#define EFI_GENERIC_ERROR_PROC_ISA_ARM_A64     0x04
+///@}
+
+///
+/// The type of error that occurred in Proessor Generic Error section.
+///@{
+#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_UNKNOWN    0x00
+#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_CACHE	     0x01
+#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_TLB	     0x02
+#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_BUS	     0x04
+#define EFI_GENERIC_ERROR_PROC_ERROR_TYPE_MICRO_ARCH 0x08
+///@}
+
+///
+/// The type of operation in Proessor Generic Error section.
+///@{
+#define EFI_GENERIC_ERROR_PROC_OPERATION_GENERIC	  0x00
+#define EFI_GENERIC_ERROR_PROC_OPERATION_DATA_READ	  0x01
+#define EFI_GENERIC_ERROR_PROC_OPERATION_DATA_WRITE	  0x02
+#define EFI_GENERIC_ERROR_PROC_OPERATION_INSTRUCTION_EXEC 0x03
+///@}
+
+///
+/// Flags bit mask indicates additional information about the error in Proessor Generic
+/// Error section
+///@{
+#define EFI_GENERIC_ERROR_PROC_FLAGS_RESTARTABLE BIT0
+#define EFI_GENERIC_ERROR_PROC_FLAGS_PRECISE_IP	 BIT1
+#define EFI_GENERIC_ERROR_PROC_FLAGS_OVERFLOW	 BIT2
+#define EFI_GENERIC_ERROR_PROC_FLAGS_CORRECTED	 BIT3
+///@}
+
+///
+/// Processor Generic Error Section
+/// describes processor reported hardware errors for logical processors in the system.
+///
+typedef struct {
+	UINT64 ValidFields;
+	UINT8 Type;
+	UINT8 Isa;
+	UINT8 ErrorType;
+	UINT8 Operation;
+	UINT8 Flags;
+	UINT8 Level;
+	UINT16 Resv1;
+	UINT64 VersionInfo;
+	CHAR8 BrandString[128];
+	UINT64 ApicId;
+	UINT64 TargetAddr;
+	UINT64 RequestorId;
+	UINT64 ResponderId;
+	UINT64 InstructionIP;
+} EFI_PROCESSOR_GENERIC_ERROR_DATA;
+
+///
+/// IA32 and x64 Specific definitions.
+///
+
+///
+/// GUID value indicating the type of Processor Error Information structure
+/// in IA32/X64 Processor Error Information Structure.
+///@{
+#define EFI_IA32_X64_ERROR_TYPE_CACHE_CHECK_GUID                               \
+	{                                                                      \
+		0xA55701F5, 0xE3EF, 0x43de,                                    \
+		{                                                              \
+			0xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C         \
+		}                                                              \
+	}
+#define EFI_IA32_X64_ERROR_TYPE_TLB_CHECK_GUID                                 \
+	{                                                                      \
+		0xFC06B535, 0x5E1F, 0x4562,                                    \
+		{                                                              \
+			0x9F, 0x25, 0x0A, 0x3B, 0x9A, 0xDB, 0x63, 0xC3         \
+		}                                                              \
+	}
+#define EFI_IA32_X64_ERROR_TYPE_BUS_CHECK_GUID                                 \
+	{                                                                      \
+		0x1CF3F8B3, 0xC5B1, 0x49a2,                                    \
+		{                                                              \
+			0xAA, 0x59, 0x5E, 0xEF, 0x92, 0xFF, 0xA6, 0x3C         \
+		}                                                              \
+	}
+#define EFI_IA32_X64_ERROR_TYPE_MS_CHECK_GUID                                  \
+	{                                                                      \
+		0x48AB7F57, 0xDC34, 0x4f6c,                                    \
+		{                                                              \
+			0xA7, 0xD3, 0xB0, 0xB5, 0xB0, 0xA7, 0x43, 0x14         \
+		}                                                              \
+	}
+extern EFI_GUID gEfiIa32x64ErrorTypeCacheCheckGuid;
+extern EFI_GUID gEfiIa32x64ErrorTypeTlbCheckGuid;
+extern EFI_GUID gEfiIa32x64ErrorTypeBusCheckGuid;
+extern EFI_GUID gEfiIa32x64ErrorTypeMsCheckGuid;
+
+///@}
+
+///
+/// The validation bit mask indicates which fields in the IA32/X64 Processor
+/// Error Record structure are valid.
+///@{
+#define EFI_IA32_X64_PROCESSOR_ERROR_APIC_ID_VALID     BIT0
+#define EFI_IA32_X64_PROCESSOR_ERROR_CPU_ID_INFO_VALID BIT1
+///@}
+
+///
+/// IA32/X64 Processor Error Record
+///
+typedef struct {
+	UINT64 ValidFields;
+	UINT64 ApicId;
+	UINT8 CpuIdInfo[48];
+} EFI_IA32_X64_PROCESSOR_ERROR_RECORD;
+
+///
+/// The validation bit mask indicates which fields in the Cache Check structure
+/// are valid.
+///@{
+#define EFI_CACHE_CHECK_TRANSACTION_TYPE_VALID BIT0
+#define EFI_CACHE_CHECK_OPERATION_VALID	       BIT1
+#define EFI_CACHE_CHECK_LEVEL_VALID	       BIT2
+#define EFI_CACHE_CHECK_CONTEXT_CORRUPT_VALID  BIT3
+#define EFI_CACHE_CHECK_UNCORRECTED_VALID      BIT4
+#define EFI_CACHE_CHECK_PRECISE_IP_VALID       BIT5
+#define EFI_CACHE_CHECK_RESTARTABLE_VALID      BIT6
+#define EFI_CACHE_CHECK_OVERFLOW_VALID	       BIT7
+///@}
+
+///
+/// Type of cache error in the Cache Check structure
+///@{
+#define EFI_CACHE_CHECK_ERROR_TYPE_INSTRUCTION 0
+#define EFI_CACHE_CHECK_ERROR_TYPE_DATA_ACCESS 1
+#define EFI_CACHE_CHECK_ERROR_TYPE_GENERIC     2
+///@}
+
+///
+/// Type of cache operation that caused the error in the Cache
+/// Check structure
+///@{
+#define EFI_CACHE_CHECK_OPERATION_TYPE_GENERIC		 0
+#define EFI_CACHE_CHECK_OPERATION_TYPE_GENERIC_READ	 1
+#define EFI_CACHE_CHECK_OPERATION_TYPE_GENERIC_WRITE	 2
+#define EFI_CACHE_CHECK_OPERATION_TYPE_DATA_READ	 3
+#define EFI_CACHE_CHECK_OPERATION_TYPE_DATA_WRITE	 4
+#define EFI_CACHE_CHECK_OPERATION_TYPE_INSTRUCTION_FETCH 5
+#define EFI_CACHE_CHECK_OPERATION_TYPE_PREFETCH		 6
+#define EFI_CACHE_CHECK_OPERATION_TYPE_EVICTION		 7
+#define EFI_CACHE_CHECK_OPERATION_TYPE_SNOOP		 8
+///@}
+
+///
+/// IA32/X64 Cache Check Structure
+///
+typedef struct {
+	UINT64 ValidFields : 16;
+	UINT64 TransactionType : 2;
+	UINT64 Operation : 4;
+	UINT64 Level : 3;
+	UINT64 ContextCorrupt : 1;
+	UINT64 ErrorUncorrected : 1;
+	UINT64 PreciseIp : 1;
+	UINT64 RestartableIp : 1;
+	UINT64 Overflow : 1;
+	UINT64 Resv1 : 34;
+} EFI_IA32_X64_CACHE_CHECK_INFO;
+
+///
+/// The validation bit mask indicates which fields in the TLB Check structure
+/// are valid.
+///@{
+#define EFI_TLB_CHECK_TRANSACTION_TYPE_VALID BIT0
+#define EFI_TLB_CHECK_OPERATION_VALID	     BIT1
+#define EFI_TLB_CHECK_LEVEL_VALID	     BIT2
+#define EFI_TLB_CHECK_CONTEXT_CORRUPT_VALID  BIT3
+#define EFI_TLB_CHECK_UNCORRECTED_VALID	     BIT4
+#define EFI_TLB_CHECK_PRECISE_IP_VALID	     BIT5
+#define EFI_TLB_CHECK_RESTARTABLE_VALID	     BIT6
+#define EFI_TLB_CHECK_OVERFLOW_VALID	     BIT7
+///@}
+
+///
+/// Type of cache error in the TLB Check structure
+///@{
+#define EFI_TLB_CHECK_ERROR_TYPE_INSTRUCTION 0
+#define EFI_TLB_CHECK_ERROR_TYPE_DATA_ACCESS 1
+#define EFI_TLB_CHECK_ERROR_TYPE_GENERIC     2
+///@}
+
+///
+/// Type of cache operation that caused the error in the TLB
+/// Check structure
+///@{
+#define EFI_TLB_CHECK_OPERATION_TYPE_GENERIC	   0
+#define EFI_TLB_CHECK_OPERATION_TYPE_GENERIC_READ  1
+#define EFI_TLB_CHECK_OPERATION_TYPE_GENERIC_WRITE 2
+#define EFI_TLB_CHECK_OPERATION_TYPE_DATA_READ	   3
+#define EFI_TLB_CHECK_OPERATION_TYPE_DATA_WRITE	   4
+#define EFI_TLB_CHECK_OPERATION_TYPE_INST_FETCH	   5
+#define EFI_TLB_CHECK_OPERATION_TYPE_PREFETCH	   6
+///@}
+
+///
+/// IA32/X64 TLB Check Structure
+///
+typedef struct {
+	UINT64 ValidFields : 16;
+	UINT64 TransactionType : 2;
+	UINT64 Operation : 4;
+	UINT64 Level : 3;
+	UINT64 ContextCorrupt : 1;
+	UINT64 ErrorUncorrected : 1;
+	UINT64 PreciseIp : 1;
+	UINT64 RestartableIp : 1;
+	UINT64 Overflow : 1;
+	UINT64 Resv1 : 34;
+} EFI_IA32_X64_TLB_CHECK_INFO;
+
+///
+/// The validation bit mask indicates which fields in the MS Check structure
+/// are valid.
+///@{
+#define EFI_BUS_CHECK_TRANSACTION_TYPE_VALID   BIT0
+#define EFI_BUS_CHECK_OPERATION_VALID	       BIT1
+#define EFI_BUS_CHECK_LEVEL_VALID	       BIT2
+#define EFI_BUS_CHECK_CONTEXT_CORRUPT_VALID    BIT3
+#define EFI_BUS_CHECK_UNCORRECTED_VALID	       BIT4
+#define EFI_BUS_CHECK_PRECISE_IP_VALID	       BIT5
+#define EFI_BUS_CHECK_RESTARTABLE_VALID	       BIT6
+#define EFI_BUS_CHECK_OVERFLOW_VALID	       BIT7
+#define EFI_BUS_CHECK_PARTICIPATION_TYPE_VALID BIT8
+#define EFI_BUS_CHECK_TIME_OUT_VALID	       BIT9
+#define EFI_BUS_CHECK_ADDRESS_SPACE_VALID      BIT10
+///@}
+
+///
+/// Type of cache error in the Bus Check structure
+///@{
+#define EFI_BUS_CHECK_ERROR_TYPE_INSTRUCTION 0
+#define EFI_BUS_CHECK_ERROR_TYPE_DATA_ACCESS 1
+#define EFI_BUS_CHECK_ERROR_TYPE_GENERIC     2
+///@}
+
+///
+/// Type of cache operation that caused the error in the Bus
+/// Check structure
+///@{
+#define EFI_BUS_CHECK_OPERATION_TYPE_GENERIC	   0
+#define EFI_BUS_CHECK_OPERATION_TYPE_GENERIC_READ  1
+#define EFI_BUS_CHECK_OPERATION_TYPE_GENERIC_WRITE 2
+#define EFI_BUS_CHECK_OPERATION_TYPE_DATA_READ	   3
+#define EFI_BUS_CHECK_OPERATION_TYPE_DATA_WRITE	   4
+#define EFI_BUS_CHECK_OPERATION_TYPE_INST_FETCH	   5
+#define EFI_BUS_CHECK_OPERATION_TYPE_PREFETCH	   6
+///@}
+
+///
+/// Type of Participation
+///@{
+#define EFI_BUS_CHECK_PARTICIPATION_TYPE_REQUEST   0
+#define EFI_BUS_CHECK_PARTICIPATION_TYPE_RESPONDED 1
+#define EFI_BUS_CHECK_PARTICIPATION_TYPE_OBSERVED  2
+#define EFI_BUS_CHECK_PARTICIPATION_TYPE_GENERIC   3
+///@}
+
+///
+/// Type of Address Space
+///@{
+#define EFI_BUS_CHECK_ADDRESS_SPACE_TYPE_MEMORY	  0
+#define EFI_BUS_CHECK_ADDRESS_SPACE_TYPE_RESERVED 1
+#define EFI_BUS_CHECK_ADDRESS_SPACE_TYPE_IO	  2
+#define EFI_BUS_CHECK_ADDRESS_SPACE_TYPE_OTHER	  3
+///@}
+
+///
+/// IA32/X64 Bus Check Structure
+///
+typedef struct {
+	UINT64 ValidFields : 16;
+	UINT64 TransactionType : 2;
+	UINT64 Operation : 4;
+	UINT64 Level : 3;
+	UINT64 ContextCorrupt : 1;
+	UINT64 ErrorUncorrected : 1;
+	UINT64 PreciseIp : 1;
+	UINT64 RestartableIp : 1;
+	UINT64 Overflow : 1;
+	UINT64 ParticipationType : 2;
+	UINT64 TimeOut : 1;
+	UINT64 AddressSpace : 2;
+	UINT64 Resv1 : 29;
+} EFI_IA32_X64_BUS_CHECK_INFO;
+
+///
+/// The validation bit mask indicates which fields in the MS Check structure
+/// are valid.
+///@{
+#define EFI_MS_CHECK_ERROR_TYPE_VALID	   BIT0
+#define EFI_MS_CHECK_CONTEXT_CORRUPT_VALID BIT1
+#define EFI_MS_CHECK_UNCORRECTED_VALID	   BIT2
+#define EFI_MS_CHECK_PRECISE_IP_VALID	   BIT3
+#define EFI_MS_CHECK_RESTARTABLE_VALID	   BIT4
+#define EFI_MS_CHECK_OVERFLOW_VALID	   BIT5
+///@}
+
+///
+/// Error type identifies the operation that caused the error.
+///@{
+#define EFI_MS_CHECK_ERROR_TYPE_NO		      0
+#define EFI_MS_CHECK_ERROR_TYPE_UNCLASSIFIED	      1
+#define EFI_MS_CHECK_ERROR_TYPE_MICROCODE_PARITY      2
+#define EFI_MS_CHECK_ERROR_TYPE_EXTERNAL	      3
+#define EFI_MS_CHECK_ERROR_TYPE_FRC		      4
+#define EFI_MS_CHECK_ERROR_TYPE_INTERNAL_UNCLASSIFIED 5
+///@}
+
+///
+/// IA32/X64 MS Check Field Description
+///
+typedef struct {
+	UINT64 ValidFields : 16;
+	UINT64 ErrorType : 3;
+	UINT64 ContextCorrupt : 1;
+	UINT64 ErrorUncorrected : 1;
+	UINT64 PreciseIp : 1;
+	UINT64 RestartableIp : 1;
+	UINT64 Overflow : 1;
+	UINT64 Resv1 : 40;
+} EFI_IA32_X64_MS_CHECK_INFO;
+
+///
+/// IA32/X64 Check Information Item
+///
+typedef union {
+	EFI_IA32_X64_CACHE_CHECK_INFO CacheCheck;
+	EFI_IA32_X64_TLB_CHECK_INFO TlbCheck;
+	EFI_IA32_X64_BUS_CHECK_INFO BusCheck;
+	EFI_IA32_X64_MS_CHECK_INFO MsCheck;
+	UINT64 Data64;
+} EFI_IA32_X64_CHECK_INFO_ITEM;
+
+///
+/// The validation bit mask indicates which fields in the IA32/X64 Processor Error
+/// Information Structure are valid.
+///@{
+#define EFI_IA32_X64_ERROR_PROC_CHECK_INFO_VALID   BIT0
+#define EFI_IA32_X64_ERROR_PROC_TARGET_ADDR_VALID  BIT1
+#define EFI_IA32_X64_ERROR_PROC_REQUESTER_ID_VALID BIT2
+#define EFI_IA32_X64_ERROR_PROC_RESPONDER_ID_VALID BIT3
+#define EFI_IA32_X64_ERROR_PROC_INST_IP_VALID	   BIT4
+///@}
+
+///
+/// IA32/X64 Processor Error Information Structure
+///
+typedef struct {
+	EFI_GUID ErrorType;
+	UINT64 ValidFields;
+	EFI_IA32_X64_CHECK_INFO_ITEM CheckInfo;
+	UINT64 TargetId;
+	UINT64 RequestorId;
+	UINT64 ResponderId;
+	UINT64 InstructionIP;
+} EFI_IA32_X64_PROCESS_ERROR_INFO;
+
+///
+/// IA32/X64 Processor Context Information Structure
+///
+typedef struct {
+	UINT16 RegisterType;
+	UINT16 ArraySize;
+	UINT32 MsrAddress;
+	UINT64 MmRegisterAddress;
+	//
+	// This field will provide the contents of the actual registers or raw data.
+	// The number of Registers or size of the raw data reported is determined
+	// by (Array Size / 8) or otherwise specified by the context structure type
+	// definition.
+	//
+} EFI_IA32_X64_PROCESSOR_CONTEXT_INFO;
+
+///
+/// Register Context Type
+///@{
+#define EFI_REG_CONTEXT_TYPE_UNCLASSIFIED 0x0000
+#define EFI_REG_CONTEXT_TYPE_MSR	  0x0001
+#define EFI_REG_CONTEXT_TYPE_IA32	  0x0002
+#define EFI_REG_CONTEXT_TYPE_X64	  0x0003
+#define EFI_REG_CONTEXT_TYPE_FXSAVE	  0x0004
+#define EFI_REG_CONTEXT_TYPE_DR_IA32	  0x0005
+#define EFI_REG_CONTEXT_TYPE_DR_X64	  0x0006
+#define EFI_REG_CONTEXT_TYPE_MEM_MAP	  0x0007
+///@}
+
+///
+/// IA32 Register State
+///
+typedef struct {
+	UINT32 Eax;
+	UINT32 Ebx;
+	UINT32 Ecx;
+	UINT32 Edx;
+	UINT32 Esi;
+	UINT32 Edi;
+	UINT32 Ebp;
+	UINT32 Esp;
+	UINT16 Cs;
+	UINT16 Ds;
+	UINT16 Ss;
+	UINT16 Es;
+	UINT16 Fs;
+	UINT16 Gs;
+	UINT32 Eflags;
+	UINT32 Eip;
+	UINT32 Cr0;
+	UINT32 Cr1;
+	UINT32 Cr2;
+	UINT32 Cr3;
+	UINT32 Cr4;
+	UINT32 Gdtr[2];
+	UINT32 Idtr[2];
+	UINT16 Ldtr;
+	UINT16 Tr;
+} EFI_CONTEXT_IA32_REGISTER_STATE;
+
+///
+/// X64 Register State
+///
+typedef struct {
+	UINT64 Rax;
+	UINT64 Rbx;
+	UINT64 Rcx;
+	UINT64 Rdx;
+	UINT64 Rsi;
+	UINT64 Rdi;
+	UINT64 Rbp;
+	UINT64 Rsp;
+	UINT64 R8;
+	UINT64 R9;
+	UINT64 R10;
+	UINT64 R11;
+	UINT64 R12;
+	UINT64 R13;
+	UINT64 R14;
+	UINT64 R15;
+	UINT16 Cs;
+	UINT16 Ds;
+	UINT16 Ss;
+	UINT16 Es;
+	UINT16 Fs;
+	UINT16 Gs;
+	UINT32 Resv1;
+	UINT64 Rflags;
+	UINT64 Rip;
+	UINT64 Cr0;
+	UINT64 Cr1;
+	UINT64 Cr2;
+	UINT64 Cr3;
+	UINT64 Cr4;
+	UINT64 Cr8;
+	UINT64 Gdtr[2];
+	UINT64 Idtr[2];
+	UINT16 Ldtr;
+	UINT16 Tr;
+} EFI_CONTEXT_X64_REGISTER_STATE;
+
+///
+/// The validation bit mask indicates each of the following field is in IA32/X64
+/// Processor Error Section.
+///
+typedef struct {
+	UINT64 ApicIdValid : 1;
+	UINT64 CpuIdInforValid : 1;
+	UINT64 ErrorInfoNum : 6;
+	UINT64 ContextNum : 6;
+	UINT64 Resv1 : 50;
+} EFI_IA32_X64_VALID_BITS;
+
+///
+/// Error Status Fields
+///
+typedef struct {
+	UINT64 Resv1 : 8;
+	UINT64 Type : 8;
+	UINT64 AddressSignal : 1; ///< Error in Address signals or in Address portion of transaction
+	UINT64 ControlSignal : 1; ///< Error in Control signals or in Control portion of transaction
+	UINT64 DataSignal : 1; ///< Error in Data signals or in Data portion of transaction
+	UINT64 DetectedByResponder : 1; ///< Error detected by responder
+	UINT64 DetectedByRequester : 1; ///< Error detected by requestor
+	UINT64 FirstError : 1; ///< First Error in the sequence - option field
+	UINT64 OverflowNotLogged : 1; ///< Additional errors were not logged due to lack of resources
+	UINT64 Resv2 : 41;
+} EFI_GENERIC_ERROR_STATUS;
+
+///
+/// CPER Generic Error Codes
+///
+#define CPER_GENERIC_ERROR_TYPES_KEYS                                          \
+	(int[])                                                                \
+	{                                                                      \
+		1, 16, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25,   \
+			26                                                     \
+	}
+#define CPER_GENERIC_ERROR_TYPES_VALUES                                        \
+	(const char *[])                                                       \
+	{                                                                      \
+		"ERR_INTERNAL", "ERR_BUS", "ERR_MEM", "ERR_TLB", "ERR_CACHE",  \
+			"ERR_FUNCTION", "ERR_SELFTEST", "ERR_FLOW", "ERR_MAP", \
+			"ERR_IMPROPER", "ERR_UNIMPL", "ERR_LOL",               \
+			"ERR_RESPONSE", "ERR_PARITY", "ERR_PROTOCOL",          \
+			"ERR_ERROR", "ERR_TIMEOUT", "ERR_POISONED"             \
+	}
+#define CPER_GENERIC_ERROR_TYPES_DESCRIPTIONS                                               \
+	(const char *[])                                                                    \
+	{                                                                                   \
+		"Error detected internal to the component.",                                \
+			"Error detected in the bus.",                                       \
+			"Storage error in memory (DRAM).",                                  \
+			"Storage error in TLB.", "Storage error in cache.",                 \
+			"Error in one or more functional units.",                           \
+			"Component failed self test.",                                      \
+			"Overflow or underflow of internal queue.",                         \
+			"Virtual address not found on IO-TLB or IO-PDIR.",                  \
+			"Improper access error.",                                           \
+			"Access to a memory address which is not mapped to any component.", \
+			"Loss of Lockstep error.",                                          \
+			"Response not associated with a request.",                          \
+			"Bus parity error (must also set the A, C, or D bits).",            \
+			"Detection of a protocol error.",                                   \
+			"Detection of a PATH_ERROR.",                                       \
+			"Bus operation timeout.",                                           \
+			"A read was issued to data that has been poisoned."                 \
+	}
+
+///
+/// Error Type
+///
+typedef enum {
+	///
+	/// General Internal errors
+	///
+	ErrorInternal = 1,
+	ErrorBus = 16,
+	///
+	/// Component Internal errors
+	///
+	ErrorMemStorage = 4, // Error in memory device
+	ErrorTlbStorage = 5, // TLB error in cache
+	ErrorCacheStorage = 6,
+	ErrorFunctionalUnit = 7,
+	ErrorSelftest = 8,
+	ErrorOverflow = 9,
+	///
+	/// Bus internal errors
+	///
+	ErrorVirtualMap = 17,
+	ErrorAccessInvalid = 18,   // Improper access
+	ErrorUnimplAccess = 19,	   // Unimplemented memory access
+	ErrorLossOfLockstep = 20,
+	ErrorResponseInvalid = 21, // Response not associated with request
+	ErrorParity = 22,
+	ErrorProtocol = 23,
+	ErrorPath = 24,	   // Detected path error
+	ErrorTimeout = 25, // Bus timeout
+	ErrorPoisoned = 26 // Read data poisoned
+} EFI_GENERIC_ERROR_STATUS_ERROR_TYPE;
+
+///
+/// Validation bit mask indicates which fields in the memory error record are valid
+/// in Memory Error section
+///@{
+#define EFI_PLATFORM_MEMORY_ERROR_STATUS_VALID		       BIT0
+#define EFI_PLATFORM_MEMORY_PHY_ADDRESS_VALID		       BIT1
+#define EFI_PLATFORM_MEMORY_PHY_ADDRESS_MASK_VALID	       BIT2
+#define EFI_PLATFORM_MEMORY_NODE_VALID			       BIT3
+#define EFI_PLATFORM_MEMORY_CARD_VALID			       BIT4
+#define EFI_PLATFORM_MEMORY_MODULE_VALID		       BIT5
+#define EFI_PLATFORM_MEMORY_BANK_VALID			       BIT6
+#define EFI_PLATFORM_MEMORY_DEVICE_VALID		       BIT7
+#define EFI_PLATFORM_MEMORY_ROW_VALID			       BIT8
+#define EFI_PLATFORM_MEMORY_COLUMN_VALID		       BIT9
+#define EFI_PLATFORM_MEMORY_BIT_POS_VALID		       BIT10
+#define EFI_PLATFORM_MEMORY_REQUESTOR_ID_VALID		       BIT11
+#define EFI_PLATFORM_MEMORY_RESPONDER_ID_VALID		       BIT12
+#define EFI_PLATFORM_MEMORY_TARGET_ID_VALID		       BIT13
+#define EFI_PLATFORM_MEMORY_ERROR_TYPE_VALID		       BIT14
+#define EFI_PLATFORM_MEMORY_ERROR_RANK_NUM_VALID	       BIT15
+#define EFI_PLATFORM_MEMORY_ERROR_CARD_HANDLE_VALID	       BIT16
+#define EFI_PLATFORM_MEMORY_ERROR_MODULE_HANDLE_VALID	       BIT17
+#define EFI_PLATFORM_MEMORY_ERROR_EXTENDED_ROW_BIT_16_17_VALID BIT18
+#define EFI_PLATFORM_MEMORY_ERROR_BANK_GROUP_VALID	       BIT19
+#define EFI_PLATFORM_MEMORY_ERROR_BANK_ADDRESS_VALID	       BIT20
+#define EFI_PLATFORM_MEMORY_ERROR_CHIP_IDENTIFICATION_VALID    BIT21
+///@}
+
+///
+/// Memory Error Type identifies the type of error that occurred in Memory
+/// Error section
+///@{
+#define EFI_PLATFORM_MEMORY_ERROR_UNKNOWN		 0x00
+#define EFI_PLATFORM_MEMORY_ERROR_NONE			 0x01
+#define EFI_PLATFORM_MEMORY_ERROR_SINGLEBIT_ECC		 0x02
+#define EFI_PLATFORM_MEMORY_ERROR_MLTIBIT_ECC		 0x03
+#define EFI_PLATFORM_MEMORY_ERROR_SINGLESYMBOLS_CHIPKILL 0x04
+#define EFI_PLATFORM_MEMORY_ERROR_MULTISYMBOL_CHIPKILL	 0x05
+#define EFI_PLATFORM_MEMORY_ERROR_MATER_ABORT		 0x06
+#define EFI_PLATFORM_MEMORY_ERROR_TARGET_ABORT		 0x07
+#define EFI_PLATFORM_MEMORY_ERROR_PARITY		 0x08
+#define EFI_PLATFORM_MEMORY_ERROR_WDT			 0x09
+#define EFI_PLATFORM_MEMORY_ERROR_INVALID_ADDRESS	 0x0A
+#define EFI_PLATFORM_MEMORY_ERROR_MIRROR_FAILED		 0x0B
+#define EFI_PLATFORM_MEMORY_ERROR_SPARING		 0x0C
+#define EFI_PLATFORM_MEMORY_ERROR_SCRUB_CORRECTED	 0x0D
+#define EFI_PLATFORM_MEMORY_ERROR_SCRUB_UNCORRECTED	 0x0E
+#define EFI_PLATFORM_MEMORY_ERROR_MEMORY_MAP_EVENT	 0x0F
+///@}
+
+///
+/// Memory Error Section
+///
+typedef struct {
+	UINT64 ValidFields;
+	EFI_GENERIC_ERROR_STATUS ErrorStatus;
+	UINT64 PhysicalAddress;	    // Error physical address
+	UINT64 PhysicalAddressMask; // Grnaularity
+	UINT16 Node;		    // Node #
+	UINT16 Card;
+	UINT16 ModuleRank;	    // Module or Rank#
+	UINT16 Bank;
+	UINT16 Device;
+	UINT16 Row;
+	UINT16 Column;
+	UINT16 BitPosition;
+	UINT64 RequestorId;
+	UINT64 ResponderId;
+	UINT64 TargetId;
+	UINT8 ErrorType;
+	UINT8 Extended;
+	UINT16 RankNum;
+	UINT16 CardHandle;
+	UINT16 ModuleHandle;
+} EFI_PLATFORM_MEMORY_ERROR_DATA;
+
+///
+/// Validation bit mask indicates which fields in the memory error record 2 are valid
+/// in Memory Error section 2
+///@{
+#define EFI_PLATFORM_MEMORY2_ERROR_STATUS_VALID	     BIT0
+#define EFI_PLATFORM_MEMORY2_PHY_ADDRESS_VALID	     BIT1
+#define EFI_PLATFORM_MEMORY2_PHY_ADDRESS_MASK_VALID  BIT2
+#define EFI_PLATFORM_MEMORY2_NODE_VALID		     BIT3
+#define EFI_PLATFORM_MEMORY2_CARD_VALID		     BIT4
+#define EFI_PLATFORM_MEMORY2_MODULE_VALID	     BIT5
+#define EFI_PLATFORM_MEMORY2_BANK_VALID		     BIT6
+#define EFI_PLATFORM_MEMORY2_DEVICE_VALID	     BIT7
+#define EFI_PLATFORM_MEMORY2_ROW_VALID		     BIT8
+#define EFI_PLATFORM_MEMORY2_COLUMN_VALID	     BIT9
+#define EFI_PLATFORM_MEMORY2_RANK_VALID		     BIT10
+#define EFI_PLATFORM_MEMORY2_BIT_POS_VALID	     BIT11
+#define EFI_PLATFORM_MEMORY2_CHIP_ID_VALID	     BIT12
+#define EFI_PLATFORM_MEMORY2_MEMORY_ERROR_TYPE_VALID BIT13
+#define EFI_PLATFORM_MEMORY2_STATUS_VALID	     BIT14
+#define EFI_PLATFORM_MEMORY2_REQUESTOR_ID_VALID	     BIT15
+#define EFI_PLATFORM_MEMORY2_RESPONDER_ID_VALID	     BIT16
+#define EFI_PLATFORM_MEMORY2_TARGET_ID_VALID	     BIT17
+#define EFI_PLATFORM_MEMORY2_CARD_HANDLE_VALID	     BIT18
+#define EFI_PLATFORM_MEMORY2_MODULE_HANDLE_VALID     BIT19
+#define EFI_PLATFORM_MEMORY2_BANK_GROUP_VALID	     BIT20
+#define EFI_PLATFORM_MEMORY2_BANK_ADDRESS_VALID	     BIT21
+///@}
+
+///
+/// Memory Error Type identifies the type of error that occurred in Memory
+/// Error section 2
+///@{
+#define EFI_PLATFORM_MEMORY2_ERROR_UNKNOWN		 0x00
+#define EFI_PLATFORM_MEMORY2_ERROR_NONE			 0x01
+#define EFI_PLATFORM_MEMORY2_ERROR_SINGLEBIT_ECC	 0x02
+#define EFI_PLATFORM_MEMORY2_ERROR_MLTIBIT_ECC		 0x03
+#define EFI_PLATFORM_MEMORY2_ERROR_SINGLESYMBOL_CHIPKILL 0x04
+#define EFI_PLATFORM_MEMORY2_ERROR_MULTISYMBOL_CHIPKILL	 0x05
+#define EFI_PLATFORM_MEMORY2_ERROR_MASTER_ABORT		 0x06
+#define EFI_PLATFORM_MEMORY2_ERROR_TARGET_ABORT		 0x07
+#define EFI_PLATFORM_MEMORY2_ERROR_PARITY		 0x08
+#define EFI_PLATFORM_MEMORY2_ERROR_WDT			 0x09
+#define EFI_PLATFORM_MEMORY2_ERROR_INVALID_ADDRESS	 0x0A
+#define EFI_PLATFORM_MEMORY2_ERROR_MIRROR_BROKEN	 0x0B
+#define EFI_PLATFORM_MEMORY2_ERROR_MEMORY_SPARING	 0x0C
+#define EFI_PLATFORM_MEMORY2_ERROR_SCRUB_CORRECTED	 0x0D
+#define EFI_PLATFORM_MEMORY2_ERROR_SCRUB_UNCORRECTED	 0x0E
+#define EFI_PLATFORM_MEMORY2_ERROR_MEMORY_MAP_EVENT	 0x0F
+///@}
+
+///
+/// Memory Error Section 2
+///
+typedef struct {
+	UINT64 ValidFields;
+	EFI_GENERIC_ERROR_STATUS ErrorStatus;
+	UINT64 PhysicalAddress;	    // Error physical address
+	UINT64 PhysicalAddressMask; // Grnaularity
+	UINT16 Node;		    // Node #
+	UINT16 Card;
+	UINT16 Module;		    // Module or Rank#
+	UINT16 Bank;
+	UINT32 Device;
+	UINT32 Row;
+	UINT32 Column;
+	UINT32 Rank;
+	UINT32 BitPosition;
+	UINT8 ChipId;
+	UINT8 MemErrorType;
+	UINT8 Status;
+	UINT8 Reserved;
+	UINT64 RequestorId;
+	UINT64 ResponderId;
+	UINT64 TargetId;
+	UINT32 CardHandle;
+	UINT32 ModuleHandle;
+} EFI_PLATFORM_MEMORY2_ERROR_DATA;
+
+///
+/// Validation bits mask indicates which of the following fields is valid
+/// in PCI Express Error Record.
+///@{
+#define EFI_PCIE_ERROR_PORT_TYPE_VALID	     BIT0
+#define EFI_PCIE_ERROR_VERSION_VALID	     BIT1
+#define EFI_PCIE_ERROR_COMMAND_STATUS_VALID  BIT2
+#define EFI_PCIE_ERROR_DEVICE_ID_VALID	     BIT3
+#define EFI_PCIE_ERROR_SERIAL_NO_VALID	     BIT4
+#define EFI_PCIE_ERROR_BRIDGE_CRL_STS_VALID  BIT5
+#define EFI_PCIE_ERROR_CAPABILITY_INFO_VALID BIT6
+#define EFI_PCIE_ERROR_AER_INFO_VALID	     BIT7
+///@}
+
+///
+/// PCIe Device/Port Type as defined in the PCI Express capabilities register
+///@{
+#define EFI_PCIE_ERROR_PORT_PCIE_ENDPOINT	 0x00000000
+#define EFI_PCIE_ERROR_PORT_PCI_ENDPOINT	 0x00000001
+#define EFI_PCIE_ERROR_PORT_ROOT_PORT		 0x00000004
+#define EFI_PCIE_ERROR_PORT_UPSWITCH_PORT	 0x00000005
+#define EFI_PCIE_ERROR_PORT_DOWNSWITCH_PORT	 0x00000006
+#define EFI_PCIE_ERROR_PORT_PCIE_TO_PCI_BRIDGE	 0x00000007
+#define EFI_PCIE_ERROR_PORT_PCI_TO_PCIE_BRIDGE	 0x00000008
+#define EFI_PCIE_ERROR_PORT_ROOT_INT_ENDPOINT	 0x00000009
+#define EFI_PCIE_ERROR_PORT_ROOT_EVENT_COLLECTOR 0x0000000A
+///@}
+
+///
+/// PCI Slot number
+///
+typedef struct {
+	UINT16 Resv1 : 3;
+	UINT16 Number : 13;
+} EFI_GENERIC_ERROR_PCI_SLOT;
+
+///
+/// PCIe Root Port PCI/bridge PCI compatible device number and
+/// bus number information to uniquely identify the root port or
+/// bridge. Default values for both the bus numbers is zero.
+///
+typedef struct {
+	UINT16 VendorId;
+	UINT16 DeviceId;
+	UINT8 ClassCode[3];
+	UINT8 Function;
+	UINT8 Device;
+	UINT16 Segment;
+	UINT8 PrimaryOrDeviceBus;
+	UINT8 SecondaryBus;
+	EFI_GENERIC_ERROR_PCI_SLOT Slot;
+	UINT8 Resv1;
+} EFI_GENERIC_ERROR_PCIE_DEV_BRIDGE_ID;
+
+///
+/// PCIe Capability Structure
+///
+typedef struct {
+	UINT8 PcieCap[60];
+} EFI_PCIE_ERROR_DATA_CAPABILITY;
+
+///
+/// PCIe Advanced Error Reporting Extended Capability Structure.
+///
+typedef struct {
+	UINT8 PcieAer[96];
+} EFI_PCIE_ERROR_DATA_AER;
+
+///
+/// PCI Express Error Record
+///
+typedef struct {
+	UINT64 ValidFields;
+	UINT32 PortType;
+	UINT32 Version;
+	UINT32 CommandStatus;
+	UINT32 Resv2;
+	EFI_GENERIC_ERROR_PCIE_DEV_BRIDGE_ID DevBridge;
+	UINT64 SerialNo;
+	UINT32 BridgeControlStatus;
+	EFI_PCIE_ERROR_DATA_CAPABILITY Capability;
+	EFI_PCIE_ERROR_DATA_AER AerInfo;
+} EFI_PCIE_ERROR_DATA;
+
+///
+/// Validation bits Indicates which of the following fields is valid
+/// in PCI/PCI-X Bus Error Section.
+///@{
+#define EFI_PCI_PCIX_BUS_ERROR_STATUS_VALID	  BIT0
+#define EFI_PCI_PCIX_BUS_ERROR_TYPE_VALID	  BIT1
+#define EFI_PCI_PCIX_BUS_ERROR_BUS_ID_VALID	  BIT2
+#define EFI_PCI_PCIX_BUS_ERROR_BUS_ADDRESS_VALID  BIT3
+#define EFI_PCI_PCIX_BUS_ERROR_BUS_DATA_VALID	  BIT4
+#define EFI_PCI_PCIX_BUS_ERROR_COMMAND_VALID	  BIT5
+#define EFI_PCI_PCIX_BUS_ERROR_REQUESTOR_ID_VALID BIT6
+#define EFI_PCI_PCIX_BUS_ERROR_COMPLETER_ID_VALID BIT7
+#define EFI_PCI_PCIX_BUS_ERROR_TARGET_ID_VALID	  BIT8
+///@}
+
+///
+/// PCI Bus Error Type in PCI/PCI-X Bus Error Section
+///@{
+#define EFI_PCI_PCIX_BUS_ERROR_UNKNOWN		  0x0000
+#define EFI_PCI_PCIX_BUS_ERROR_DATA_PARITY	  0x0001
+#define EFI_PCI_PCIX_BUS_ERROR_SYSTEM		  0x0002
+#define EFI_PCI_PCIX_BUS_ERROR_MASTER_ABORT	  0x0003
+#define EFI_PCI_PCIX_BUS_ERROR_BUS_TIMEOUT	  0x0004
+#define EFI_PCI_PCIX_BUS_ERROR_MASTER_DATA_PARITY 0x0005
+#define EFI_PCI_PCIX_BUS_ERROR_ADDRESS_PARITY	  0x0006
+#define EFI_PCI_PCIX_BUS_ERROR_COMMAND_PARITY	  0x0007
+///@}
+
+///
+/// PCI/PCI-X Bus Error Section
+///
+typedef struct {
+	UINT64 ValidFields;
+	EFI_GENERIC_ERROR_STATUS ErrorStatus;
+	UINT16 Type;
+	UINT16 BusId;
+	UINT32 Resv2;
+	UINT64 BusAddress;
+	UINT64 BusData;
+	UINT64 BusCommand;
+	UINT64 RequestorId;
+	UINT64 ResponderId;
+	UINT64 TargetId;
+} EFI_PCI_PCIX_BUS_ERROR_DATA;
+
+///
+/// Validation bits Indicates which of the following fields is valid
+/// in PCI/PCI-X Component Error Section.
+///@{
+#define EFI_PCI_PCIX_DEVICE_ERROR_STATUS_VALID	      BIT0
+#define EFI_PCI_PCIX_DEVICE_ERROR_ID_INFO_VALID	      BIT1
+#define EFI_PCI_PCIX_DEVICE_ERROR_MEM_NUM_VALID	      BIT2
+#define EFI_PCI_PCIX_DEVICE_ERROR_IO_NUM_VALID	      BIT3
+#define EFI_PCI_PCIX_DEVICE_ERROR_REG_DATA_PAIR_VALID BIT4
+///@}
+
+///
+/// PCI/PCI-X Device Identification Information
+///
+typedef struct {
+	UINT16 VendorId;
+	UINT16 DeviceId;
+	UINT8 ClassCode[3];
+	UINT8 Function;
+	UINT8 Device;
+	UINT8 Bus;
+	UINT8 Segment;
+	UINT8 Resv1;
+	UINT32 Resv2;
+} EFI_GENERIC_ERROR_PCI_DEVICE_ID;
+
+///
+/// Identifies the type of firmware error record
+///@{
+#define EFI_FIRMWARE_ERROR_TYPE_IPF_SAL	  0x00
+#define EFI_FIRMWARE_ERROR_TYPE_SOC_TYPE1 0x01
+#define EFI_FIRMWARE_ERROR_TYPE_SOC_TYPE2 0x02
+///@}
+
+///
+/// Firmware Error Record Section
+///
+typedef struct {
+	UINT8 ErrorType;
+	UINT8 Revision;
+	UINT8 Resv1[6];
+	UINT64 RecordId;
+	EFI_GUID RecordIdGuid;
+} EFI_FIRMWARE_ERROR_DATA;
+
+///
+/// Fault Reason in DMAr Generic Error Section
+///@{
+#define EFI_DMA_FAULT_REASON_TABLE_ENTRY_NOT_PRESENT	       0x01
+#define EFI_DMA_FAULT_REASON_TABLE_ENTRY_INVALID	       0x02
+#define EFI_DMA_FAULT_REASON_ACCESS_MAPPING_TABLE_ERROR	       0x03
+#define EFI_DMA_FAULT_REASON_RESV_BIT_ERROR_IN_MAPPING_TABLE   0x04
+#define EFI_DMA_FAULT_REASON_ACCESS_ADDR_OUT_OF_SPACE	       0x05
+#define EFI_DMA_FAULT_REASON_INVALID_ACCESS		       0x06
+#define EFI_DMA_FAULT_REASON_INVALID_REQUEST		       0x07
+#define EFI_DMA_FAULT_REASON_ACCESS_TRANSLATE_TABLE_ERROR      0x08
+#define EFI_DMA_FAULT_REASON_RESV_BIT_ERROR_IN_TRANSLATE_TABLE 0x09
+#define EFI_DMA_FAULT_REASON_INVALID_COMMAOND		       0x0A
+#define EFI_DMA_FAULT_REASON_ACCESS_COMMAND_BUFFER_ERROR       0x0B
+///@}
+
+///
+/// DMA access type in DMAr Generic Error Section
+///@{
+#define EFI_DMA_ACCESS_TYPE_READ  0x00
+#define EFI_DMA_ACCESS_TYPE_WRITE 0x01
+///@}
+
+///
+/// DMA address type in DMAr Generic Error Section
+///@{
+#define EFI_DMA_ADDRESS_UNTRANSLATED 0x00
+#define EFI_DMA_ADDRESS_TRANSLATION  0x01
+///@}
+
+///
+/// Architecture type in DMAr Generic Error Section
+///@{
+#define EFI_DMA_ARCH_TYPE_VT	0x01
+#define EFI_DMA_ARCH_TYPE_IOMMU 0x02
+///@}
+
+///
+/// DMAr Generic Error Section
+///
+typedef struct {
+	UINT16 RequesterId;
+	UINT16 SegmentNumber;
+	UINT8 FaultReason;
+	UINT8 AccessType;
+	UINT8 AddressType;
+	UINT8 ArchType;
+	UINT64 DeviceAddr;
+	UINT8 Resv1[16];
+} EFI_DMAR_GENERIC_ERROR_DATA;
+
+///
+/// Intel VT for Directed I/O specific DMAr Errors
+///
+typedef struct {
+	UINT8 Version;
+	UINT8 Revision;
+	UINT8 OemId[6];
+	UINT64 Capability;
+	UINT64 CapabilityEx;
+	UINT32 GlobalCommand;
+	UINT32 GlobalStatus;
+	UINT32 FaultStatus;
+	UINT8 Resv1[12];
+	UINT64 FaultRecord[2];
+	UINT64 RootEntry[2];
+	UINT64 ContextEntry[2];
+	UINT64 PteL6;
+	UINT64 PteL5;
+	UINT64 PteL4;
+	UINT64 PteL3;
+	UINT64 PteL2;
+	UINT64 PteL1;
+} EFI_DIRECTED_IO_DMAR_ERROR_DATA;
+
+///
+/// IOMMU specific DMAr Errors
+///
+typedef struct {
+	UINT8 Revision;
+	UINT8 Resv1[7];
+	UINT64 Control;
+	UINT64 Status;
+	UINT8 Resv2[8];
+	UINT64 EventLogEntry[2];
+	UINT8 Resv3[16];
+	UINT64 DeviceTableEntry[4];
+	UINT64 PteL6;
+	UINT64 PteL5;
+	UINT64 PteL4;
+	UINT64 PteL3;
+	UINT64 PteL2;
+	UINT64 PteL1;
+} EFI_IOMMU_DMAR_ERROR_DATA;
+
+extern EFI_GUID gEfiEventNotificationTypeCmcGuid;
+extern EFI_GUID gEfiEventNotificationTypeCpeGuid;
+extern EFI_GUID gEfiEventNotificationTypeMceGuid;
+extern EFI_GUID gEfiEventNotificationTypePcieGuid;
+extern EFI_GUID gEfiEventNotificationTypeInitGuid;
+extern EFI_GUID gEfiEventNotificationTypeNmiGuid;
+extern EFI_GUID gEfiEventNotificationTypeBootGuid;
+extern EFI_GUID gEfiEventNotificationTypeDmarGuid;
+extern EFI_GUID gEfiEventNotificationTypeSeaGuid;
+extern EFI_GUID gEfiEventNotificationTypeSeiGuid;
+extern EFI_GUID gEfiEventNotificationTypePeiGuid;
+extern EFI_GUID gEfiEventNotificationTypeCxlGuid;
+extern EFI_GUID gEfiProcessorGenericErrorSectionGuid;
+extern EFI_GUID gEfiProcessorSpecificErrorSectionGuid;
+extern EFI_GUID gEfiIa32X64ProcessorErrorSectionGuid;
+extern EFI_GUID gEfiIpfProcessorErrorSectionGuid;
+extern EFI_GUID gEfiArmProcessorErrorSectionGuid;
+extern EFI_GUID gEfiPlatformMemoryErrorSectionGuid;
+extern EFI_GUID gEfiPlatformMemoryError2SectionGuid;
+extern EFI_GUID gEfiPcieErrorSectionGuid;
+extern EFI_GUID gEfiFirmwareErrorSectionGuid;
+extern EFI_GUID gEfiPciBusErrorSectionGuid;
+extern EFI_GUID gEfiPciDevErrorSectionGuid;
+extern EFI_GUID gEfiDMArGenericErrorSectionGuid;
+extern EFI_GUID gEfiDirectedIoDMArErrorSectionGuid;
+extern EFI_GUID gEfiIommuDMArErrorSectionGuid;
+extern EFI_GUID gEfiCcixPerLogErrorSectionGuid;
+extern EFI_GUID gEfiCxlProtocolErrorSectionGuid;
+extern EFI_GUID gEfiCxlGeneralMediaErrorSectionGuid;
+extern EFI_GUID gEfiCxlDramEventErrorSectionGuid;
+extern EFI_GUID gEfiCxlMemoryModuleErrorSectionGuid;
+extern EFI_GUID gEfiCxlPhysicalSwitchErrorSectionGuid;
+extern EFI_GUID gEfiCxlVirtualSwitchErrorSectionGuid;
+extern EFI_GUID gEfiCxlMldPortErrorSectionGuid;
+#pragma pack()
+
+#if defined(MDE_CPU_IA32) || defined(MDE_CPU_X64)
+///
+/// IA32 and x64 Specific definitions.
+///
+
+extern EFI_GUID gEfiIa32X64ErrorTypeCacheCheckGuid;
+extern EFI_GUID gEfiIa32X64ErrorTypeTlbCheckGuid;
+extern EFI_GUID gEfiIa32X64ErrorTypeBusCheckGuid;
+extern EFI_GUID gEfiIa32X64ErrorTypeMsCheckGuid;
+
+#endif
+
+#endif
diff --git a/generator/cper-generate-cli.c b/generator/cper-generate-cli.c
index f5b0c85..185702c 100644
--- a/generator/cper-generate-cli.c
+++ b/generator/cper-generate-cli.c
@@ -40,8 +40,9 @@
 			sections = malloc(sizeof(char *) * num_sections);
 			i++;
 
-			for (int j = i; j < argc; j++)
+			for (int j = i; j < argc; j++) {
 				sections[j - i] = argv[j];
+			}
 			break;
 		} else {
 			printf("Unrecognised argument '%s'. For command information, refer to 'cper-generate --help'.\n",
@@ -53,6 +54,9 @@
 	//If no output file passed as argument, exit.
 	if (out_file == NULL) {
 		printf("No output file provided. For command information, refer to 'cper-generate --help'.\n");
+		if (sections) {
+			free(sections);
+		}
 		return -1;
 	}
 
@@ -61,6 +65,9 @@
 	if (cper_file == NULL) {
 		printf("Could not get a handle for output file '%s', file handle returned null.\n",
 		       out_file);
+		if (sections) {
+			free(sections);
+		}
 		return -1;
 	}
 
@@ -72,13 +79,17 @@
 	} else {
 		//Invalid arguments.
 		printf("Invalid argument. Either both '--sections' and '--single-section' were set, or neither. For command information, refer to 'cper-generate --help'.\n");
+		if (sections) {
+			free(sections);
+		}
 		return -1;
 	}
 
 	//Close & free remaining resources.
 	fclose(cper_file);
-	if (sections != NULL)
+	if (sections != NULL) {
 		free(sections);
+	}
 }
 
 //Prints command help for this CPER generator.
@@ -91,10 +102,10 @@
 	printf("\tWhen the '--single-section' flag is set, the next argument is the single section that should be generated, and\n");
 	printf("\ta single section (no header, only a section descriptor & section) CPER file is generated.\n\n");
 	printf("\tValid section type names are the following:\n");
-	for (int i=0; i<generator_definitions_len; i++) {
+	for (size_t i = 0; i < generator_definitions_len; i++) {
 		printf("\t\t- %s\n", generator_definitions[i].ShortName);
 	}
 	printf("\t\t- unknown\n");
 	printf("\n:: --help\n");
 	printf("\tDisplays help information to the console.\n");
-}
\ No newline at end of file
+}
diff --git a/generator/cper-generate.c b/generator/cper-generate.c
index c8819f6..c14cbd3 100644
--- a/generator/cper-generate.c
+++ b/generator/cper-generate.c
@@ -57,18 +57,20 @@
 	header->TimeStamp.Seconds = int_to_bcd(rand() % 60);
 
 	//Turn all validation bits on.
-	header->ValidationBits = 0b11;
+	header->ValidationBits = 0x3;
 
 	//Generate the section descriptors given the number of sections.
 	EFI_ERROR_SECTION_DESCRIPTOR *section_descriptors[num_sections];
-	for (int i = 0; i < num_sections; i++)
+	for (int i = 0; i < num_sections; i++) {
 		section_descriptors[i] = generate_section_descriptor(
 			types[i], section_lengths, i, num_sections);
+	}
 
 	//Calculate total length of structure, set in header.
 	size_t total_len = sizeof(EFI_COMMON_ERROR_RECORD_HEADER);
-	for (int i = 0; i < num_sections; i++)
+	for (int i = 0; i < num_sections; i++) {
 		total_len += section_lengths[i];
+	}
 	total_len += num_sections * sizeof(EFI_ERROR_SECTION_DESCRIPTOR);
 	header->RecordLength = (UINT32)total_len;
 
@@ -93,7 +95,7 @@
 void generate_single_section_record(char *type, FILE *out)
 {
 	//Generate a section.
-	void *section;
+	void *section = NULL;
 	size_t section_len = generate_section(&section, type);
 
 	//Generate a descriptor, correct the offset.
@@ -110,6 +112,7 @@
 
 	//Free remaining resources.
 	free(section_descriptor);
+	free(section);
 }
 
 //Generates a single section descriptor for a section with the given properties.
@@ -127,7 +130,7 @@
 	descriptor->SectionFlags &= 0xFF;
 
 	//Validation bits all set to 'on'.
-	descriptor->SecValidMask = 0b11;
+	descriptor->SecValidMask = 0x3;
 
 	//Set severity.
 	descriptor->Severity = rand() % 4;
@@ -137,17 +140,20 @@
 	descriptor->SectionOffset =
 		sizeof(EFI_COMMON_ERROR_RECORD_HEADER) +
 		(num_sections * sizeof(EFI_ERROR_SECTION_DESCRIPTOR));
-	for (int i = 0; i < index; i++)
+	for (int i = 0; i < index; i++) {
 		descriptor->SectionOffset += lengths[i];
+	}
 
 	//Ensure the FRU text is not null terminated early.
 	for (int i = 0; i < 20; i++) {
-		if (descriptor->FruString[i] == 0x0)
+		if (descriptor->FruString[i] == 0x0) {
 			descriptor->FruString[i] = rand() % 127 + 1;
+		}
 
 		//Null terminate last byte.
-		if (i == 19)
+		if (i == 19) {
 			descriptor->FruString[i] = 0x0;
+		}
 	}
 
 	//If section type is not "unknown", set section type GUID based on type name.
@@ -156,7 +162,7 @@
 		section_guid_found = 1;
 	} else {
 		//Find the appropriate GUID for this section name.
-		for (int i = 0; i < generator_definitions_len; i++) {
+		for (size_t i = 0; i < generator_definitions_len; i++) {
 			if (strcmp(type, generator_definitions[i].ShortName) ==
 			    0) {
 				memcpy(&descriptor->SectionType,
@@ -192,7 +198,7 @@
 		section_generated = 1;
 	} else {
 		//Function defined section, switch on the type, generate accordingly.
-		for (int i = 0; i < generator_definitions_len; i++) {
+		for (size_t i = 0; i < generator_definitions_len; i++) {
 			if (strcmp(type, generator_definitions[i].ShortName) ==
 			    0) {
 				length = generator_definitions[i].Generate(
@@ -211,4 +217,4 @@
 	}
 
 	return length;
-}
\ No newline at end of file
+}
diff --git a/generator/cper-generate.h b/generator/cper-generate.h
index 2874fa5..edbac36 100644
--- a/generator/cper-generate.h
+++ b/generator/cper-generate.h
@@ -4,7 +4,7 @@
 #include <stdio.h>
 #include "../edk/BaseTypes.h"
 
-void generate_cper_record(char **types, UINT16 num_sections, FILE *cper_file);
+void generate_cper_record(char **types, UINT16 num_sections, FILE *out);
 void generate_single_section_record(char *type, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/generator/gen-utils.c b/generator/gen-utils.c
index c986b09..0fa0237 100644
--- a/generator/gen-utils.c
+++ b/generator/gen-utils.c
@@ -20,8 +20,9 @@
 UINT8 *generate_random_bytes(size_t size)
 {
 	UINT8 *bytes = malloc(size);
-	for (size_t i = 0; i < size; i++)
+	for (size_t i = 0; i < size; i++) {
 		bytes[i] = rand();
+	}
 	return bytes;
 }
 
@@ -31,7 +32,7 @@
 {
 	//Fix reserved bits.
 	UINT64 *error_section = (UINT64 *)start;
-	*error_section &= ~0xFF; //Reserved bits 0-7.
+	*error_section &= ~0xFF;    //Reserved bits 0-7.
 	*error_section &= 0x7FFFFF; //Reserved bits 23-63
 
 	//Ensure error type has a valid value.
@@ -44,4 +45,4 @@
 void init_random()
 {
 	srand((unsigned int)time(NULL));
-}
\ No newline at end of file
+}
diff --git a/generator/gen-utils.h b/generator/gen-utils.h
index 4c9e30d..0ed28c2 100644
--- a/generator/gen-utils.h
+++ b/generator/gen-utils.h
@@ -5,12 +5,17 @@
 #include "../edk/BaseTypes.h"
 #include "../common-utils.h"
 
-#define CPER_ERROR_TYPES_KEYS (int []){1, 16, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}
+#define CPER_ERROR_TYPES_KEYS                                                  \
+	(int[])                                                                \
+	{                                                                      \
+		1, 16, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25,   \
+			26                                                     \
+	}
 
-size_t generate_random_section(void** location, size_t size);
-UINT8* generate_random_bytes(size_t size);
+size_t generate_random_section(void **location, size_t size);
+UINT8 *generate_random_bytes(size_t size);
 void init_random();
-void create_valid_error_section(UINT8* start);
+void create_valid_error_section(UINT8 *start);
 UINT8 int_to_bcd(int value);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/generator/sections/gen-section-arm.c b/generator/sections/gen-section-arm.c
index 7ec94a7..cdd71e1 100644
--- a/generator/sections/gen-section-arm.c
+++ b/generator/sections/gen-section-arm.c
@@ -11,174 +11,175 @@
 #include "gen-section.h"
 #define ARM_ERROR_INFO_SIZE 32
 
-void* generate_arm_error_info();
-size_t generate_arm_context_info(void** location);
+void *generate_arm_error_info();
+size_t generate_arm_context_info(void **location);
 
 //Generates a single pseudo-random ARM processor section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_arm(void** location)
+size_t generate_section_arm(void **location)
 {
-    //Set up for generation of error/context structures.
-    UINT16 error_structure_num = rand() % 4 + 1; //Must be at least 1.
-    UINT16 context_structure_num = rand() % 3;
-    void* error_structures[error_structure_num];
-    void* context_structures[context_structure_num];
-    size_t context_structure_lengths[context_structure_num];
+	//Set up for generation of error/context structures.
+	UINT16 error_structure_num = rand() % 4 + 1; //Must be at least 1.
+	UINT16 context_structure_num = rand() % 3 + 1;
+	void *error_structures[error_structure_num];
+	void *context_structures[context_structure_num];
+	size_t context_structure_lengths[context_structure_num];
 
-    //Generate the structures.
-    for (int i=0; i<error_structure_num; i++)
-        error_structures[i] = generate_arm_error_info();
-    for (int i=0; i<context_structure_num; i++)
-        context_structure_lengths[i] = generate_arm_context_info(context_structures + i);
+	//Generate the structures.
+	for (int i = 0; i < error_structure_num; i++) {
+		error_structures[i] = generate_arm_error_info();
+	}
+	for (int i = 0; i < context_structure_num; i++) {
+		context_structure_lengths[i] =
+			generate_arm_context_info(context_structures + i);
+	}
 
-    //Determine a random amount of vendor specific info.
-    int vendor_info_len = rand() % 16;
+	//Determine a random amount of vendor specific info.
+	int vendor_info_len = rand() % 16;
 
-    //Create the section as a whole.
-    size_t total_len = 40 + (error_structure_num * ARM_ERROR_INFO_SIZE);
-    for (int i=0; i<context_structure_num; i++)
-        total_len += context_structure_lengths[i];
-    total_len += vendor_info_len;
-    UINT8* section = generate_random_bytes(total_len);
+	//Create the section as a whole.
+	size_t total_len = 40 + (error_structure_num * ARM_ERROR_INFO_SIZE);
+	for (int i = 0; i < context_structure_num; i++) {
+		total_len += context_structure_lengths[i];
+	}
+	total_len += vendor_info_len;
+	UINT8 *section = generate_random_bytes(total_len);
 
-    //Set header information.
-    UINT16* info_nums = (UINT16*)(section + 4);
-    *info_nums = error_structure_num;
-    *(info_nums + 1) = context_structure_num;
-    UINT32* section_length = (UINT32*)(section + 8);
-    *section_length = total_len;
-    
-    //Error affinity.
-    *(section + 12) = rand() % 4;
+	//Set header information.
+	UINT16 *info_nums = (UINT16 *)(section + 4);
+	*info_nums = error_structure_num;
+	*(info_nums + 1) = context_structure_num;
+	UINT32 *section_length = (UINT32 *)(section + 8);
+	*section_length = total_len;
 
-    //Reserved zero bytes.
-    UINT64* validation = (UINT64*)section;
-    *validation &= 0b111;
-    UINT32* running_state = (UINT32*)(section + 32);
-    *running_state &= 0b1;
-    memset(section + 13, 0, 3);
+	//Error affinity.
+	*(section + 12) = rand() % 4;
 
-    //Copy in the sections/context structures, free resources.
-    UINT8* cur_pos = section + 40;
-    for (int i=0; i<error_structure_num; i++)
-    {
-        memcpy(cur_pos, error_structures[i], ARM_ERROR_INFO_SIZE);
-        free(error_structures[i]);
-        cur_pos += ARM_ERROR_INFO_SIZE;
-    }
-    for (int i=0; i<context_structure_num; i++)
-    {
-        memcpy(cur_pos, context_structures[i], context_structure_lengths[i]);
-        free(context_structures[i]);
-        cur_pos += context_structure_lengths[i];
-    }
+	//Reserved zero bytes.
+	UINT64 *validation = (UINT64 *)section;
+	*validation &= 0x7;
+	UINT32 *running_state = (UINT32 *)(section + 32);
+	*running_state &= 0x1;
+	memset(section + 13, 0, 3);
 
-    //Set return values and exit.
-    *location = section;
-    return total_len;
+	//Copy in the sections/context structures, free resources.
+	UINT8 *cur_pos = section + 40;
+	for (int i = 0; i < error_structure_num; i++) {
+		memcpy(cur_pos, error_structures[i], ARM_ERROR_INFO_SIZE);
+		free(error_structures[i]);
+		cur_pos += ARM_ERROR_INFO_SIZE;
+	}
+	for (int i = 0; i < context_structure_num; i++) {
+		memcpy(cur_pos, context_structures[i],
+		       context_structure_lengths[i]);
+		free(context_structures[i]);
+		cur_pos += context_structure_lengths[i];
+	}
+
+	//Set return values and exit.
+	*location = section;
+	return total_len;
 }
 
 //Generates a single pseudo-random ARM error info structure. Must be later freed.
-void* generate_arm_error_info()
+void *generate_arm_error_info()
 {
-    UINT8* error_info = generate_random_bytes(ARM_ERROR_INFO_SIZE);
+	UINT8 *error_info = generate_random_bytes(ARM_ERROR_INFO_SIZE);
 
-    //Version (zero for revision of table referenced), length.
-    *error_info = 0;
-    *(error_info + 1) = ARM_ERROR_INFO_SIZE;
+	//Version (zero for revision of table referenced), length.
+	*error_info = 0;
+	*(error_info + 1) = ARM_ERROR_INFO_SIZE;
 
-    //Type of error.
-    UINT8 error_type = rand() % 4;
-    *(error_info + 4) = error_type;
+	//Type of error.
+	UINT8 error_type = rand() % 4;
+	*(error_info + 4) = error_type;
 
-    //Reserved bits for error information.
-    UINT16* validation = (UINT16*)(error_info + 2);
-    *validation &= 0x1F;
+	//Reserved bits for error information.
+	UINT16 *validation = (UINT16 *)(error_info + 2);
+	*validation &= 0x1F;
 
-    //Make sure reserved bits are zero according with the type.
-    UINT64* error_subinfo = (UINT64*)(error_info + 8);
-    switch (error_type)
-    {
-        //Cache/TLB
-        case 0:
-        case 1:
-            *error_subinfo &= 0xFFFFFFF;
-            break;
+	//Make sure reserved bits are zero according with the type.
+	UINT64 *error_subinfo = (UINT64 *)(error_info + 8);
+	switch (error_type) {
+	//Cache/TLB
+	case 0:
+	case 1:
+		*error_subinfo &= 0xFFFFFFF;
+		break;
 
-        //Bus
-        case 2:
-            *error_subinfo &= 0xFFFFFFFFFFF;
-            break;
+	//Bus
+	case 2:
+		*error_subinfo &= 0xFFFFFFFFFFF;
+		break;
 
-        //Microarch/other.
-        default:
-            break;
-    }
+	//Microarch/other.
+	default:
+		break;
+	}
 
-    return error_info;
+	return error_info;
 }
 
 //Generates a single pseudo-random ARM context info structure. Must be later freed.
-size_t generate_arm_context_info(void** location)
+size_t generate_arm_context_info(void **location)
 {
-    //Initial length is 8 bytes. Add extra based on type.
-    UINT16 reg_type = rand() % 9;
-    UINT32 reg_size = 0;
+	//Initial length is 8 bytes. Add extra based on type.
+	UINT16 reg_type = rand() % 9;
+	UINT32 reg_size = 0;
 
-    //Set register size.
-    switch (reg_type)
-    {
-        //AARCH32 GPR, AARCH32 EL2
-        case 0:
-        case 2:
-            reg_size = 64;
-            break;
+	//Set register size.
+	switch (reg_type) {
+	//AARCH32 GPR, AARCH32 EL2
+	case 0:
+	case 2:
+		reg_size = 64;
+		break;
 
-        //AARCH32 EL1
-        case 1:
-            reg_size = 96;
-            break;
+	//AARCH32 EL1
+	case 1:
+		reg_size = 96;
+		break;
 
-        //AARCH32 EL3
-        case 3:
-            reg_size = 8;
-            break;
+	//AARCH32 EL3
+	case 3:
+		reg_size = 8;
+		break;
 
-        //AARCH64 GPR
-        case 4:
-            reg_size = 256;
-            break;
+	//AARCH64 GPR
+	case 4:
+		reg_size = 256;
+		break;
 
-        //AARCH64 EL1
-        case 5:
-            reg_size = 136;
-            break;
-        
-        //AARCH64 EL2
-        case 6:
-            reg_size = 120;
-            break;
+	//AARCH64 EL1
+	case 5:
+		reg_size = 136;
+		break;
 
-        //AARCH64 EL3
-        case 7:
-            reg_size = 80;
-            break;
+	//AARCH64 EL2
+	case 6:
+		reg_size = 120;
+		break;
 
-        //Misc. single register.
-        case 8:
-            reg_size = 10;
-            break;
-    }
+	//AARCH64 EL3
+	case 7:
+		reg_size = 80;
+		break;
 
-    //Create context structure randomly.
-    int total_size = 8 + reg_size;
-    UINT16* context_info = (UINT16*)generate_random_bytes(total_size);
+	//Misc. single register.
+	case 8:
+		reg_size = 10;
+		break;
+	}
 
-    //Set header information.
-    *(context_info + 1) = reg_type;
-    *((UINT32*)(context_info + 2)) = reg_size;
+	//Create context structure randomly.
+	int total_size = 8 + reg_size;
+	UINT16 *context_info = (UINT16 *)generate_random_bytes(total_size);
 
-    //Set return values and exit.
-    *location = context_info;
-    return total_size;
-}
\ No newline at end of file
+	//Set header information.
+	*(context_info + 1) = reg_type;
+	*((UINT32 *)(context_info + 2)) = reg_size;
+
+	//Set return values and exit.
+	*location = context_info;
+	return total_size;
+}
diff --git a/generator/sections/gen-section-ccix-per.c b/generator/sections/gen-section-ccix-per.c
index c820d72..1780af7 100644
--- a/generator/sections/gen-section-ccix-per.c
+++ b/generator/sections/gen-section-ccix-per.c
@@ -11,28 +11,29 @@
 
 //Generates a single pseudo-random CCIX PER error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_ccix_per(void** location)
+size_t generate_section_ccix_per(void **location)
 {
-    //Create a random length for the CCIX PER log.
-    //The log attached here does not necessarily conform to the CCIX specification, and is simply random.
-    int log_len = (rand() % 5 + 1) * 32;
+	//Create a random length for the CCIX PER log.
+	//The log attached here does not necessarily conform to the CCIX specification, and is simply random.
+	int log_len = (rand() % 5 + 1) * 32;
 
-    //Create random bytes.
-    int size = 16 + log_len;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    UINT64* validation = (UINT64*)(bytes + 4);
-    *validation &= 0b111; //Validation bits 3-63.
-    *(bytes + 13) &= 0b11111; //CCIX port ID bits 5-7.
-    UINT16* reserved = (UINT16*)(bytes + 14);
-    *reserved = 0; //Reserved bytes 14-15.
+	//Create random bytes.
+	int size = 16 + log_len;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set expected values.
-    UINT32* length = (UINT32*)bytes;
-    *length = size;
+	//Set reserved areas to zero.
+	UINT32 *validation = (UINT32 *)(bytes + 4);
+	*validation &= 0x7;    //Validation bits 3-63.
+	*(validation + 1) = 0; //Validation bits 3-63.
+	*(bytes + 13) &= 0x1F; //CCIX port ID bits 5-7.
+	UINT16 *reserved = (UINT16 *)(bytes + 14);
+	*reserved = 0;	       //Reserved bytes 14-15.
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//Set expected values.
+	UINT32 *length = (UINT32 *)bytes;
+	*length = size;
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section-cxl-component.c b/generator/sections/gen-section-cxl-component.c
index 5fb6789..b13a1f5 100644
--- a/generator/sections/gen-section-cxl-component.c
+++ b/generator/sections/gen-section-cxl-component.c
@@ -11,28 +11,29 @@
 
 //Generates a single pseudo-random CXL component error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_cxl_component(void** location)
+size_t generate_section_cxl_component(void **location)
 {
-    //Create a random length for the CXL component event log.
-    //The logs attached here do not necessarily conform to the specification, and are simply random.
-    int log_len = rand() % 64;
+	//Create a random length for the CXL component event log.
+	//The logs attached here do not necessarily conform to the specification, and are simply random.
+	int log_len = rand() % 64;
 
-    //Create random bytes.
-    int size = 32 + log_len;
-    UINT8* bytes = generate_random_bytes(size);
+	//Create random bytes.
+	int size = 32 + log_len;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set reserved areas to zero.
-    UINT64* validation = (UINT64*)(bytes + 4);
-    *validation &= 0b111;
-    UINT16* slot_number = (UINT16*)(bytes + 21);
-    *slot_number &= ~0b111; //Device ID slot number bits 0-2.
-    *(bytes + 23) = 0; //Device ID byte 11.
+	//Set reserved areas to zero.
+	UINT32 *validation = (UINT32 *)(bytes + 4);
+	*validation &= 0x7;
+	*(validation + 1) = 0;
+	UINT8 *slot_number = (UINT8 *)(bytes + 21);
+	*slot_number &= ~0x7; //Device ID slot number bits 0-2.
+	*(bytes + 23) = 0;    //Device ID byte 11.
 
-    //Set expected values.
-    UINT32* length = (UINT32*)bytes;
-    *length = size;
-    
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//Set expected values.
+	UINT32 *length = (UINT32 *)bytes;
+	*length = size;
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section-cxl-protocol.c b/generator/sections/gen-section-cxl-protocol.c
index 71a1105..cd9d66d 100644
--- a/generator/sections/gen-section-cxl-protocol.c
+++ b/generator/sections/gen-section-cxl-protocol.c
@@ -11,54 +11,56 @@
 
 //Generates a single pseudo-random CXL protocol error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_cxl_protocol(void** location)
+size_t generate_section_cxl_protocol(void **location)
 {
-    //Create a random length for the CXL DVSEC and CXL error log.
-    //The logs attached here do not necessarily conform to the specification, and are simply random.
-    int dvsec_len = rand() % 64;
-    int error_log_len = rand() % 64;
+	//Create a random length for the CXL DVSEC and CXL error log.
+	//The logs attached here do not necessarily conform to the specification, and are simply random.
+	int dvsec_len = rand() % 64;
+	int error_log_len = rand() % 64;
 
-    //Create random bytes.
-    int size = 116 + dvsec_len + error_log_len;
-    UINT8* bytes = generate_random_bytes(size);
+	//Create random bytes.
+	int size = 116 + dvsec_len + error_log_len;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set CXL agent type.
-    int cxl_agent_type = rand() % 2;
-    *(bytes + 8) = cxl_agent_type;
-    
-    //Set reserved areas to zero.
-    UINT64* validation = (UINT64*)bytes;
-    *validation &= 0b111111; //Validation bits 6-63.
-    for (int i=0; i<7; i++)
-        *(bytes + 9 + i) = 0; //Reserved bytes 9-15.
+	//Set CXL agent type.
+	int cxl_agent_type = rand() % 2;
+	*(bytes + 8) = cxl_agent_type;
 
-    //We only reserve bytes if it's a CXL 1.1 device, and not a host downstream port.
-    if (cxl_agent_type == 0)
-    {
-        for (int i=0; i<3; i++)
-            *(bytes + 21 + i) = 0; //CXL agent address bytes 5-7.
-    }
-    
-    *(bytes + 34) &= ~0b111; //Device ID byte 10 bits 0-2.
-    UINT32* reserved = (UINT32*)(bytes + 36);
-    *reserved = 0; //Device ID bytes 12-15.
-    reserved = (UINT32*)(bytes + 112);
-    *reserved = 0; //Reserved bytes 112-115.
+	//Set reserved areas to zero.
+	UINT64 *validation = (UINT64 *)bytes;
+	*validation &= 0x3F;	      //Validation bits 6-63.
+	for (int i = 0; i < 7; i++) {
+		*(bytes + 9 + i) = 0; //Reserved bytes 9-15.
+	}
 
-    //If the device is a host downstream port, serial/capability structure is invalid.
-    if (cxl_agent_type != 0)
-    {
-        for (int i=0; i<68; i++)
-            *(bytes + 40 + i) = 0; //Device serial & capability structure.
-    }
+	//We only reserve bytes if it's a CXL 1.1 device, and not a host downstream port.
+	if (cxl_agent_type == 0) {
+		for (int i = 0; i < 3; i++) {
+			*(bytes + 21 + i) = 0; //CXL agent address bytes 5-7.
+		}
+	}
 
-    //Set expected values.
-    UINT16* dvsec_length_field = (UINT16*)(bytes + 108);
-    UINT16* error_log_len_field = (UINT16*)(bytes + 110);
-    *dvsec_length_field = dvsec_len;
-    *error_log_len_field = error_log_len;
+	*(bytes + 34) &= ~0x7; //Device ID byte 10 bits 0-2.
+	UINT32 *reserved = (UINT32 *)(bytes + 36);
+	*reserved = 0;	       //Device ID bytes 12-15.
+	reserved = (UINT32 *)(bytes + 112);
+	*reserved = 0;	       //Reserved bytes 112-115.
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//If the device is a host downstream port, serial/capability structure is invalid.
+	if (cxl_agent_type != 0) {
+		for (int i = 0; i < 68; i++) {
+			*(bytes + 40 + i) =
+				0; //Device serial & capability structure.
+		}
+	}
+
+	//Set expected values.
+	UINT16 *dvsec_length_field = (UINT16 *)(bytes + 108);
+	UINT16 *error_log_len_field = (UINT16 *)(bytes + 110);
+	*dvsec_length_field = dvsec_len;
+	*error_log_len_field = error_log_len;
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section-dmar.c b/generator/sections/gen-section-dmar.c
index 66cc70a..6e405c8 100644
--- a/generator/sections/gen-section-dmar.c
+++ b/generator/sections/gen-section-dmar.c
@@ -11,68 +11,71 @@
 
 //Generates a single pseudo-random generic DMAr error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_dmar_generic(void** location)
+size_t generate_section_dmar_generic(void **location)
 {
-    //Create random bytes.
-    int size = 32;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    UINT64* reserved = (UINT64*)(bytes + 16);
-    *reserved = 0;
-    *(reserved + 1) = 0;
+	//Create random bytes.
+	int size = 32;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set expected values.
-    *(bytes + 4) = rand() % 0xC; //Fault reason.
-    *(bytes + 5) = rand() % 2; //Access type.
-    *(bytes + 6) = rand() % 2; //Address type.
-    *(bytes + 7) = rand() % 2 + 1; //Architecture type.
+	//Set reserved areas to zero.
+	UINT64 *reserved = (UINT64 *)(bytes + 16);
+	*reserved = 0;
+	*(reserved + 1) = 0;
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
+	//Set expected values.
+	*(bytes + 4) = rand() % 0xC;   //Fault reason.
+	*(bytes + 5) = rand() % 2;     //Access type.
+	*(bytes + 6) = rand() % 2;     //Address type.
+	*(bytes + 7) = rand() % 2 + 1; //Architecture type.
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
 }
 
 //Generates a single pseudo-random VT-d DMAr error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_dmar_vtd(void** location)
+size_t generate_section_dmar_vtd(void **location)
 {
-    //Create random bytes.
-    int size = 144;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    for (int i=0; i<12; i++)
-        *(bytes + 36 + i) = 0; //Reserved bytes 36-47.
-    UINT8* fault_record = bytes + 48;
-    UINT32* reserved = (UINT32*)(fault_record);
-    *reserved &= ~0xFFF; //First 12 bits of fault record.
-    reserved = (UINT32*)(fault_record + 10);
-    *reserved &= ~0x1FFF; //Bits 80-92 of fault record.
-    *(fault_record + 15) &= 0x7; //Very last bit of fault record.
+	//Create random bytes.
+	int size = 144;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
+	//Set reserved areas to zero.
+	for (int i = 0; i < 12; i++) {
+		*(bytes + 36 + i) = 0; //Reserved bytes 36-47.
+	}
+	UINT8 *fault_record = bytes + 48;
+	UINT32 *reserved = (UINT32 *)(fault_record);
+	*reserved &= ~0xFFF;	     //First 12 bits of fault record.
+	reserved = (UINT32 *)(fault_record + 8);
+	*reserved &= ~0x1FFF0000;    //Bits 80-92 of fault record.
+	*(fault_record + 15) &= 0x7; //Very last bit of fault record.
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
 }
 
 //Generates a single pseudo-random IOMMU DMAr error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_dmar_iommu(void** location)
+size_t generate_section_dmar_iommu(void **location)
 {
-    //Create random bytes.
-    int size = 144;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    for (int i=0; i<7; i++)
-        *(bytes + 1 + i) = 0; //Reserved bytes 1 to 7.
-    UINT64* reserved = (UINT64*)(bytes + 24);
-    *reserved = 0; //Reserved bytes 24-31.
-    for (int i=0; i<16; i++)
-        *(bytes + 48 + i) = 0; //Reserved bytes 48-63.
+	//Create random bytes.
+	int size = 144;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//Set reserved areas to zero.
+	for (int i = 0; i < 7; i++) {
+		*(bytes + 1 + i) = 0; //Reserved bytes 1 to 7.
+	}
+	UINT64 *reserved = (UINT64 *)(bytes + 24);
+	*reserved = 0;		       //Reserved bytes 24-31.
+	for (int i = 0; i < 16; i++) {
+		*(bytes + 48 + i) = 0; //Reserved bytes 48-63.
+	}
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section-firmware.c b/generator/sections/gen-section-firmware.c
index 7ba93ee..9eb3f69 100644
--- a/generator/sections/gen-section-firmware.c
+++ b/generator/sections/gen-section-firmware.c
@@ -11,23 +11,24 @@
 
 //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)
+size_t generate_section_firmware(void **location)
 {
-    //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.
+	//Create random bytes.
+	int size = 32;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //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 = rand() % 3; //Record type.
+	//Set reserved areas to zero.
+	for (int i = 0; i < 6; i++) {
+		*(bytes + 2 + i) = 0; //Reserved bytes 2-7.
+	}
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//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 = rand() % 3; //Record type.
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section-generic.c b/generator/sections/gen-section-generic.c
index e9a2ea0..061ff10 100644
--- a/generator/sections/gen-section-generic.c
+++ b/generator/sections/gen-section-generic.c
@@ -11,28 +11,29 @@
 
 //Generates a single pseudo-random generic processor section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_generic(void** location)
+size_t generate_section_generic(void **location)
 {
-    //Create random bytes.
-    size_t size = generate_random_section(location, 192);
+	//Create random bytes.
+	size_t size = generate_random_section(location, 192);
 
-    //Set reserved locations to zero.
-    UINT8* start_byte = (UINT8*)*location;
-    *((UINT64*)start_byte) &= 0xFFF;
-    *(start_byte + 12) &= 0b111;
-    *((UINT16*)(start_byte + 14)) = 0x0;
-    
-    //Ensure CPU brand string does not terminate early.
-    for (int i=0; i<128; i++)
-    {
-        UINT8* byte = start_byte + 24 + i;
-        if (*byte == 0x0)
-            *byte = rand() % 127 + 1;
+	//Set reserved locations to zero.
+	UINT8 *start_byte = (UINT8 *)*location;
+	*((UINT64 *)start_byte) &= 0xFFF;
+	*(start_byte + 12) &= 0x7;
+	*((UINT16 *)(start_byte + 14)) = 0x0;
 
-        //Null terminate last byte.
-        if (i == 127)
-            *byte = 0x0;
-    }
+	//Ensure CPU brand string does not terminate early.
+	for (int i = 0; i < 128; i++) {
+		UINT8 *byte = start_byte + 24 + i;
+		if (*byte == 0x0) {
+			*byte = rand() % 127 + 1;
+		}
 
-    return size;
-}
\ No newline at end of file
+		//Null terminate last byte.
+		if (i == 127) {
+			*byte = 0x0;
+		}
+	}
+
+	return size;
+}
diff --git a/generator/sections/gen-section-ia32x64.c b/generator/sections/gen-section-ia32x64.c
index a01d2b7..2bd9c72 100644
--- a/generator/sections/gen-section-ia32x64.c
+++ b/generator/sections/gen-section-ia32x64.c
@@ -11,155 +11,160 @@
 #include "gen-section.h"
 #define IA32X64_ERROR_STRUCTURE_SIZE 64
 
-void* generate_ia32x64_error_structure();
-size_t generate_ia32x64_context_structure(void** location);
+void *generate_ia32x64_error_structure();
+size_t generate_ia32x64_context_structure(void **location);
 
 //Generates a single pseudo-random IA32/x64 section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_ia32x64(void** location)
+size_t generate_section_ia32x64(void **location)
 {
-    //Set up for generation of error/context structures.
-    UINT16 error_structure_num = rand() % 5;
-    UINT16 context_structure_num = rand() % 5;
-    void* error_structures[error_structure_num];
-    void* context_structures[context_structure_num];
-    size_t context_structure_lengths[context_structure_num];
+	//Set up for generation of error/context structures.
+	UINT16 error_structure_num = rand() % 4 + 1;
+	UINT16 context_structure_num = rand() % 4 + 1;
+	void *error_structures[error_structure_num];
+	void *context_structures[context_structure_num];
+	size_t context_structure_lengths[context_structure_num];
 
-    //Generate the structures.
-    for (int i=0; i<error_structure_num; i++)
-        error_structures[i] = generate_ia32x64_error_structure();
-    for (int i=0; i<context_structure_num; i++)
-        context_structure_lengths[i] = generate_ia32x64_context_structure(context_structures + i);
+	//Generate the structures.
+	for (int i = 0; i < error_structure_num; i++) {
+		error_structures[i] = generate_ia32x64_error_structure();
+	}
+	for (int i = 0; i < context_structure_num; i++) {
+		context_structure_lengths[i] =
+			generate_ia32x64_context_structure(context_structures +
+							   i);
+	}
 
-    //Create a valid IA32/x64 section.
-    size_t total_len = 64 + (IA32X64_ERROR_STRUCTURE_SIZE * error_structure_num);
-    for (int i=0; i<context_structure_num; i++)
-        total_len += context_structure_lengths[i];
-    UINT8* section = generate_random_bytes(total_len);
+	//Create a valid IA32/x64 section.
+	size_t total_len =
+		64 + (IA32X64_ERROR_STRUCTURE_SIZE * error_structure_num);
+	for (int i = 0; i < context_structure_num; i++) {
+		total_len += context_structure_lengths[i];
+	}
+	UINT8 *section = generate_random_bytes(total_len);
 
-    //Null extend the end of the CPUID in the header.
-    for (int i=0; i<16; i++)
-        *(section + 48 + i) = 0x0;
+	//Null extend the end of the CPUID in the header.
+	for (int i = 0; i < 16; i++) {
+		*(section + 48 + i) = 0x0;
+	}
 
-    //Set header information.
-    UINT64* validation = (UINT64*)section;
-    *validation &= 0b11;
-    *validation |= error_structure_num << 2;
-    *validation |= context_structure_num << 8;
+	//Set header information.
+	UINT64 *validation = (UINT64 *)section;
+	*validation &= 0x3;
+	*validation |= error_structure_num << 2;
+	*validation |= context_structure_num << 8;
 
-    //Copy in structures, free resources.
-    UINT8* cur_pos = section + 64;
-    for (int i=0; i<error_structure_num; i++)
-    {
-        memcpy(cur_pos, error_structures[i], IA32X64_ERROR_STRUCTURE_SIZE);
-        free(error_structures[i]);
-        cur_pos += IA32X64_ERROR_STRUCTURE_SIZE;
-    }
-    for (int i=0; i<context_structure_num; i++)
-    {
-        memcpy(cur_pos, context_structures[i], context_structure_lengths[i]);
-        free(context_structures[i]);
-        cur_pos += context_structure_lengths[i];
-    }
+	//Copy in structures, free resources.
+	UINT8 *cur_pos = section + 64;
+	for (int i = 0; i < error_structure_num; i++) {
+		memcpy(cur_pos, error_structures[i],
+		       IA32X64_ERROR_STRUCTURE_SIZE);
+		free(error_structures[i]);
+		cur_pos += IA32X64_ERROR_STRUCTURE_SIZE;
+	}
+	for (int i = 0; i < context_structure_num; i++) {
+		memcpy(cur_pos, context_structures[i],
+		       context_structure_lengths[i]);
+		free(context_structures[i]);
+		cur_pos += context_structure_lengths[i];
+	}
 
-    //Set return values, exist.
-    *location = section;
-    return total_len;
+	//Set return values, exist.
+	*location = section;
+	return total_len;
 }
 
 //Generates a single IA32/x64 error structure. Must later be freed.
-void* generate_ia32x64_error_structure()
+void *generate_ia32x64_error_structure()
 {
-    UINT8* error_structure = generate_random_bytes(IA32X64_ERROR_STRUCTURE_SIZE);
+	UINT8 *error_structure =
+		generate_random_bytes(IA32X64_ERROR_STRUCTURE_SIZE);
 
-    //Set error structure reserved space to zero.
-    UINT64* validation = (UINT64*)(error_structure + 16);
-    *validation &= 0x1F;
+	//Set error structure reserved space to zero.
+	UINT64 *validation = (UINT64 *)(error_structure + 16);
+	*validation &= 0x1F;
 
-    //Create a random type of error structure.
-    EFI_GUID* guid = (EFI_GUID*)error_structure;
-    UINT64* check_info = (UINT64*)(error_structure + 24);
-    int error_structure_type = rand() % 4;
-    switch (error_structure_type)
-    {
-        //Cache
-        case 0:
-            memcpy(guid, &gEfiIa32x64ErrorTypeCacheCheckGuid, sizeof(EFI_GUID));
+	//Create a random type of error structure.
+	EFI_GUID *guid = (EFI_GUID *)error_structure;
+	UINT64 *check_info = (UINT64 *)(error_structure + 24);
+	int error_structure_type = rand() % 4;
+	switch (error_structure_type) {
+	//Cache
+	case 0:
+		memcpy(guid, &gEfiIa32x64ErrorTypeCacheCheckGuid,
+		       sizeof(EFI_GUID));
 
-            //Set reserved space to zero.
-            *check_info &= ~0xFF00;
-            *check_info &= 0x3FFFFFFF;
-            break;
+		//Set reserved space to zero.
+		*check_info &= ~0x20FF00;
+		*check_info &= 0x3FFFFFFF;
+		break;
 
-        //TLB
-        case 1:
-            memcpy(guid, &gEfiIa32x64ErrorTypeTlbCheckGuid, sizeof(EFI_GUID));
+	//TLB
+	case 1:
+		memcpy(guid, &gEfiIa32x64ErrorTypeTlbCheckGuid,
+		       sizeof(EFI_GUID));
 
-            //Set reserved space to zero.
-            *check_info &= ~0xFF00;
-            *check_info &= 0x3FFFFFFF;
-            break;
+		//Set reserved space to zero.
+		*check_info &= ~0x20FF00;
+		*check_info &= 0x3FFFFFFF;
+		break;
 
-        //Bus
-        case 2:
-            memcpy(guid, &gEfiIa32x64ErrorTypeBusCheckGuid, sizeof(EFI_GUID));
+	//Bus
+	case 2:
+		memcpy(guid, &gEfiIa32x64ErrorTypeBusCheckGuid,
+		       sizeof(EFI_GUID));
 
-            //Set reserved space to zero.
-            *check_info &= ~0xF800;
-            *check_info &= 0x7FFFFFFFF;
-            break;
+		//Set reserved space to zero.
+		*check_info &= ~0x20F800;
+		*check_info &= 0x7FFFFFFFF;
+		break;
 
-        //MS
-        case 3:
-            memcpy(guid, &gEfiIa32x64ErrorTypeMsCheckGuid, sizeof(EFI_GUID));
+	//MS
+	case 3:
+		memcpy(guid, &gEfiIa32x64ErrorTypeMsCheckGuid,
+		       sizeof(EFI_GUID));
 
-            //Set reserved space to zero.
-            *check_info &= ~0xFFE0;
-            *check_info &= 0xFFFFFF;
-            break;
-    }
+		//Set reserved space to zero.
+		*check_info &= ~0xFFE0;
+		*check_info &= 0xFFFFFF;
+		break;
+	}
 
-    return error_structure;
+	return error_structure;
 }
 
 //Generates a single IA32/x64 context structure. Must later be freed.
-size_t generate_ia32x64_context_structure(void** location)
+size_t generate_ia32x64_context_structure(void **location)
 {
-    //Initial length is 16 bytes. Add extra based on type.
-    int reg_type = rand() % 8;
-    int reg_size = 0;
+	//Initial length is 16 bytes. Add extra based on type.
+	int reg_type = rand() % 8;
+	int reg_size = 0;
 
-    //Set register size.
-    if (reg_type == 2)
-    {
-        reg_size = 92; //IA32 registers.
-    }
-    else if (reg_type == 3)
-    {
-        reg_size = 244; //x64 registers.
-    }
-    else
-    {
-        reg_size = (rand() % 5 + 1) * 32; //Not table defined.
-    }
+	//Set register size.
+	if (reg_type == 2) {
+		reg_size = 92;			  //IA32 registers.
+	} else if (reg_type == 3) {
+		reg_size = 244;			  //x64 registers.
+	} else {
+		reg_size = (rand() % 5 + 1) * 32; //Not table defined.
+	}
 
-    //Create structure randomly.
-    int total_size = 16 + reg_size;
-    UINT16* context_structure = (UINT16*)generate_random_bytes(total_size);
+	//Create structure randomly.
+	int total_size = 16 + reg_size;
+	UINT16 *context_structure = (UINT16 *)generate_random_bytes(total_size);
 
-    //If it is x64 registers, set reserved area accordingly.
-    if (reg_type == 3)
-    {
-        UINT8* reg_bytes = (UINT8*)(context_structure + 8);
-        UINT32* reserved = (UINT32*)(reg_bytes + 140);
-        *reserved = 0;
-    }
+	//If it is x64 registers, set reserved area accordingly.
+	if (reg_type == 3) {
+		UINT8 *reg_bytes = (UINT8 *)(context_structure + 8);
+		UINT32 *reserved = (UINT32 *)(reg_bytes + 140);
+		*reserved = 0;
+	}
 
-    //Set header information.
-    *(context_structure) = reg_type;
-    *(context_structure + 1) = reg_size;
+	//Set header information.
+	*(context_structure) = reg_type;
+	*(context_structure + 1) = reg_size;
 
-    //Set return values and exit.
-    *location = context_structure;
-    return total_size;
-}
\ No newline at end of file
+	//Set return values and exit.
+	*location = context_structure;
+	return total_size;
+}
diff --git a/generator/sections/gen-section-memory.c b/generator/sections/gen-section-memory.c
index 9d405a4..46eaed3 100644
--- a/generator/sections/gen-section-memory.c
+++ b/generator/sections/gen-section-memory.c
@@ -11,49 +11,49 @@
 
 //Generates a single pseudo-random platform memory error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_memory(void** location)
+size_t generate_section_memory(void **location)
 {
-    //Create random bytes.
-    int size = 80;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    UINT64* validation = (UINT64*)bytes;
-    *validation &= 0x2FFFFF; //Validation 22-63
-    *(bytes + 73) &= ~0b11100; //Extended bits 2-4
+	//Create random bytes.
+	int size = 80;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Fix values that could be above range.
-    *(bytes + 72) = rand() % 16; //Memory error type
+	//Set reserved areas to zero.
+	UINT64 *validation = (UINT64 *)bytes;
+	*validation &= 0x2FFFFF; //Validation 22-63
+	*(bytes + 73) &= ~0x1C;	 //Extended bits 2-4
 
-    //Fix error status.
-    create_valid_error_section(bytes + 8);
+	//Fix values that could be above range.
+	*(bytes + 72) = rand() % 16; //Memory error type
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
+	//Fix error status.
+	create_valid_error_section(bytes + 8);
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
 }
 
 //Generates a single pseudo-random memory 2 error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_memory2(void** location)
+size_t generate_section_memory2(void **location)
 {
-    //Create random bytes.
-    int size = 96;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    UINT64* validation = (UINT64*)bytes;
-    *validation &= 0x2FFFFF; //Validation 22-63
-    *(bytes + 63) = 0; //Reserved byte 63
+	//Create random bytes.
+	int size = 96;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Fix values that could be above range.
-    *(bytes + 61) = rand() % 16; //Memory error type
-    *(bytes + 62) = rand() % 2; //Status
+	//Set reserved areas to zero.
+	UINT64 *validation = (UINT64 *)bytes;
+	*validation &= 0x2FFFFF; //Validation 22-63
+	*(bytes + 63) = 0;	 //Reserved byte 63
 
-    //Fix error status.
-    create_valid_error_section(bytes + 8);
+	//Fix values that could be above range.
+	*(bytes + 61) = rand() % 16; //Memory error type
+	*(bytes + 62) = rand() % 2;  //Status
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//Fix error status.
+	create_valid_error_section(bytes + 8);
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section-pci-bus.c b/generator/sections/gen-section-pci-bus.c
index 1aee19a..c814069 100644
--- a/generator/sections/gen-section-pci-bus.c
+++ b/generator/sections/gen-section-pci-bus.c
@@ -11,28 +11,28 @@
 
 //Generates a single pseudo-random PCI/PCI-X bus error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_pci_bus(void** location)
+size_t generate_section_pci_bus(void **location)
 {
-    //Create random bytes.
-    int size = 72;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    UINT64* validation = (UINT64*)bytes;
-    *validation &= 0x1FF; //Validation 9-63
-    UINT32* reserved = (UINT32*)(bytes + 20);
-    *reserved = 0;
-    UINT64* bus_command = (UINT64*)(bytes + 40);
-    *bus_command &= ((UINT64)0b1 << 56); //Bus command bytes bar bit 56.
+	//Create random bytes.
+	int size = 72;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Fix values that could be above range.
-    UINT16* error_type = (UINT16*)(bytes + 16);
-    *error_type = rand() % 8;
+	//Set reserved areas to zero.
+	UINT64 *validation = (UINT64 *)bytes;
+	*validation &= 0x1FF; //Validation 9-63
+	UINT32 *reserved = (UINT32 *)(bytes + 20);
+	*reserved = 0;
+	UINT64 *bus_command = (UINT64 *)(bytes + 40);
+	*bus_command &= ((UINT64)0x1 << 56); //Bus command bytes bar bit 56.
 
-    //Fix error status.
-    create_valid_error_section(bytes + 8);
+	//Fix values that could be above range.
+	UINT16 *error_type = (UINT16 *)(bytes + 16);
+	*error_type = rand() % 8;
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//Fix error status.
+	create_valid_error_section(bytes + 8);
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section-pci-dev.c b/generator/sections/gen-section-pci-dev.c
index 339f98c..a164719 100644
--- a/generator/sections/gen-section-pci-dev.c
+++ b/generator/sections/gen-section-pci-dev.c
@@ -11,33 +11,34 @@
 
 //Generates a single pseudo-random PCI component error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_pci_dev(void** location)
+size_t generate_section_pci_dev(void **location)
 {
-    //Generate how many register pairs will be attached to this section.
-    UINT32 num_memory_pairs = rand() % 4;
-    UINT32 num_io_pairs = rand() % 4;
-    UINT32 num_registers = num_memory_pairs + num_io_pairs;
+	//Generate how many register pairs will be attached to this section.
+	UINT32 num_memory_pairs = rand() % 4;
+	UINT32 num_io_pairs = rand() % 4;
+	UINT32 num_registers = num_memory_pairs + num_io_pairs;
 
-    //Create random bytes.
-    int size = 40 + (num_registers * 16);
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    UINT64* validation = (UINT64*)bytes;
-    *validation &= 0b11111; //Validation 5-63
-    for (int i=0; i<5; i++)
-        *(bytes + 27 + i) = 0; //Bytes 11-15 of ID info.
-        
-    //Set expected values.
-    UINT32* memory_number_field = (UINT32*)(bytes + 32);
-    UINT32* io_number_field = (UINT32*)(bytes + 36);
-    *memory_number_field = num_memory_pairs;
-    *io_number_field = num_io_pairs;
+	//Create random bytes.
+	int size = 40 + (num_registers * 16);
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Fix error status.
-    create_valid_error_section(bytes + 8);
+	//Set reserved areas to zero.
+	UINT64 *validation = (UINT64 *)bytes;
+	*validation &= 0x1F;	       //Validation 5-63
+	for (int i = 0; i < 5; i++) {
+		*(bytes + 27 + i) = 0; //Bytes 11-15 of ID info.
+	}
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//Set expected values.
+	UINT32 *memory_number_field = (UINT32 *)(bytes + 32);
+	UINT32 *io_number_field = (UINT32 *)(bytes + 36);
+	*memory_number_field = num_memory_pairs;
+	*io_number_field = num_io_pairs;
+
+	//Fix error status.
+	create_valid_error_section(bytes + 8);
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section-pcie.c b/generator/sections/gen-section-pcie.c
index aa1be6b..82b2031 100644
--- a/generator/sections/gen-section-pcie.c
+++ b/generator/sections/gen-section-pcie.c
@@ -9,37 +9,42 @@
 #include "../gen-utils.h"
 #include "gen-section.h"
 
-#define PCIE_PORT_TYPES (int []){0, 1, 4, 5, 6, 7, 8, 9, 10}
+#define PCIE_PORT_TYPES                                                        \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 4, 5, 6, 7, 8, 9, 10                                     \
+	}
 
 //Generates a single pseudo-random PCIe error section, saving the resulting address to the given
 //location. Returns the size of the newly created section.
-size_t generate_section_pcie(void** location)
+size_t generate_section_pcie(void **location)
 {
-    //Create random bytes.
-    int size = 208;
-    UINT8* bytes = generate_random_bytes(size);
-    
-    //Set reserved areas to zero.
-    UINT64* validation = (UINT64*)bytes;
-    *validation &= 0xFF; //Validation 8-63
-    UINT32* version = (UINT32*)(bytes + 12);
-    *version &= 0xFFFF; //Version bytes 2-3
-    UINT32* reserved = (UINT32*)(bytes + 20);
-    *reserved = 0; //Reserved bytes 20-24
-    *(bytes + 37) &= ~0b111; //Device ID byte 13 bits 0-3
-    *(bytes + 39) = 0; //Device ID byte 15
+	//Create random bytes.
+	int size = 208;
+	UINT8 *bytes = generate_random_bytes(size);
 
-    //Set expected values.
-    int minor = rand() % 128;
-    int major = rand() % 128;
-    *version = int_to_bcd(minor);
-    *version |= int_to_bcd(major) << 8;
+	//Set reserved areas to zero.
+	UINT64 *validation = (UINT64 *)bytes;
+	*validation &= 0xFF;   //Validation 8-63
+	UINT32 *version = (UINT32 *)(bytes + 12);
+	*version &= 0xFFFF;    //Version bytes 2-3
+	UINT32 *reserved = (UINT32 *)(bytes + 20);
+	*reserved = 0;	       //Reserved bytes 20-24
+	*(bytes + 37) &= ~0x7; //Device ID byte 13 bits 0-3
+	*(bytes + 39) = 0;     //Device ID byte 15
 
-    //Fix values that could be above range.
-    UINT32* port_type = (UINT32*)(bytes + 8);
-    *port_type = PCIE_PORT_TYPES[rand() % (sizeof(PCIE_PORT_TYPES) / sizeof(int))];
+	//Set expected values.
+	int minor = rand() % 128;
+	int major = rand() % 128;
+	*version = int_to_bcd(minor);
+	*version |= int_to_bcd(major) << 8;
 
-    //Set return values, exit.
-    *location = bytes;
-    return size;
-}
\ No newline at end of file
+	//Fix values that could be above range.
+	UINT32 *port_type = (UINT32 *)(bytes + 8);
+	*port_type = PCIE_PORT_TYPES[rand() %
+				     (sizeof(PCIE_PORT_TYPES) / sizeof(int))];
+
+	//Set return values, exit.
+	*location = bytes;
+	return size;
+}
diff --git a/generator/sections/gen-section.c b/generator/sections/gen-section.c
index 012f88f..0b07af0 100644
--- a/generator/sections/gen-section.c
+++ b/generator/sections/gen-section.c
@@ -6,25 +6,42 @@
 #include "gen-section.h"
 
 CPER_GENERATOR_DEFINITION generator_definitions[] = {
-    {&gEfiProcessorGenericErrorSectionGuid, "generic", generate_section_generic},
-    {&gEfiIa32X64ProcessorErrorSectionGuid, "ia32x64", generate_section_ia32x64},
-    {&gEfiArmProcessorErrorSectionGuid, "arm", generate_section_arm},
-    {&gEfiPlatformMemoryErrorSectionGuid, "memory", generate_section_memory},
-    {&gEfiPlatformMemoryError2SectionGuid, "memory2", generate_section_memory2},
-    {&gEfiPcieErrorSectionGuid, "pcie", generate_section_pcie},
-    {&gEfiFirmwareErrorSectionGuid, "firmware", generate_section_firmware},
-    {&gEfiPciBusErrorSectionGuid, "pcibus", generate_section_pci_bus},
-    {&gEfiPciDevErrorSectionGuid, "pcidev", generate_section_pci_dev},
-    {&gEfiDMArGenericErrorSectionGuid, "dmargeneric", generate_section_dmar_generic},
-    {&gEfiDirectedIoDMArErrorSectionGuid, "dmarvtd", generate_section_dmar_vtd},
-    {&gEfiIommuDMArErrorSectionGuid, "dmariommu", generate_section_dmar_iommu},
-    {&gEfiCcixPerLogErrorSectionGuid, "ccixper", generate_section_ccix_per},
-    {&gEfiCxlProtocolErrorSectionGuid, "cxlprotocol", generate_section_cxl_protocol},
-    {&gEfiCxlGeneralMediaErrorSectionGuid, "cxlcomponent-media", generate_section_cxl_component},
-    {&gEfiCxlDramEventErrorSectionGuid, "cxlcomponent-dram", generate_section_cxl_component},
-    {&gEfiCxlMemoryModuleErrorSectionGuid, "cxlcomponent-memory", generate_section_cxl_component},
-    {&gEfiCxlPhysicalSwitchErrorSectionGuid, "cxlcomponent-pswitch", generate_section_cxl_component},
-    {&gEfiCxlVirtualSwitchErrorSectionGuid, "cxlcomponent-vswitch", generate_section_cxl_component},
-    {&gEfiCxlMldPortErrorSectionGuid, "cxlcomponent-mld", generate_section_cxl_component},
+	{ &gEfiProcessorGenericErrorSectionGuid, "generic",
+	  generate_section_generic },
+	{ &gEfiIa32X64ProcessorErrorSectionGuid, "ia32x64",
+	  generate_section_ia32x64 },
+	{ &gEfiArmProcessorErrorSectionGuid, "arm", generate_section_arm },
+	{ &gEfiPlatformMemoryErrorSectionGuid, "memory",
+	  generate_section_memory },
+	{ &gEfiPlatformMemoryError2SectionGuid, "memory2",
+	  generate_section_memory2 },
+	{ &gEfiPcieErrorSectionGuid, "pcie", generate_section_pcie },
+	{ &gEfiFirmwareErrorSectionGuid, "firmware",
+	  generate_section_firmware },
+	{ &gEfiPciBusErrorSectionGuid, "pcibus", generate_section_pci_bus },
+	{ &gEfiPciDevErrorSectionGuid, "pcidev", generate_section_pci_dev },
+	{ &gEfiDMArGenericErrorSectionGuid, "dmargeneric",
+	  generate_section_dmar_generic },
+	{ &gEfiDirectedIoDMArErrorSectionGuid, "dmarvtd",
+	  generate_section_dmar_vtd },
+	{ &gEfiIommuDMArErrorSectionGuid, "dmariommu",
+	  generate_section_dmar_iommu },
+	{ &gEfiCcixPerLogErrorSectionGuid, "ccixper",
+	  generate_section_ccix_per },
+	{ &gEfiCxlProtocolErrorSectionGuid, "cxlprotocol",
+	  generate_section_cxl_protocol },
+	{ &gEfiCxlGeneralMediaErrorSectionGuid, "cxlcomponent-media",
+	  generate_section_cxl_component },
+	{ &gEfiCxlDramEventErrorSectionGuid, "cxlcomponent-dram",
+	  generate_section_cxl_component },
+	{ &gEfiCxlMemoryModuleErrorSectionGuid, "cxlcomponent-memory",
+	  generate_section_cxl_component },
+	{ &gEfiCxlPhysicalSwitchErrorSectionGuid, "cxlcomponent-pswitch",
+	  generate_section_cxl_component },
+	{ &gEfiCxlVirtualSwitchErrorSectionGuid, "cxlcomponent-vswitch",
+	  generate_section_cxl_component },
+	{ &gEfiCxlMldPortErrorSectionGuid, "cxlcomponent-mld",
+	  generate_section_cxl_component },
 };
-const size_t generator_definitions_len = sizeof(generator_definitions) / sizeof(CPER_GENERATOR_DEFINITION);
\ No newline at end of file
+const size_t generator_definitions_len =
+	sizeof(generator_definitions) / sizeof(CPER_GENERATOR_DEFINITION);
diff --git a/generator/sections/gen-section.h b/generator/sections/gen-section.h
index ac0a024..df1e227 100644
--- a/generator/sections/gen-section.h
+++ b/generator/sections/gen-section.h
@@ -5,30 +5,30 @@
 #include "../../edk/Cper.h"
 
 //Section generator function predefinitions.
-size_t generate_section_generic(void** location);
-size_t generate_section_ia32x64(void** location);
-size_t generate_section_arm(void** location);
-size_t generate_section_memory(void** location);
-size_t generate_section_memory2(void** location);
-size_t generate_section_pcie(void** location);
-size_t generate_section_pci_bus(void** location);
-size_t generate_section_pci_dev(void** location);
-size_t generate_section_firmware(void** location);
-size_t generate_section_dmar_generic(void** location);
-size_t generate_section_dmar_vtd(void** location);
-size_t generate_section_dmar_iommu(void** location);
-size_t generate_section_ccix_per(void** location);
-size_t generate_section_cxl_protocol(void** location);
-size_t generate_section_cxl_component(void** location);
+size_t generate_section_generic(void **location);
+size_t generate_section_ia32x64(void **location);
+size_t generate_section_arm(void **location);
+size_t generate_section_memory(void **location);
+size_t generate_section_memory2(void **location);
+size_t generate_section_pcie(void **location);
+size_t generate_section_pci_bus(void **location);
+size_t generate_section_pci_dev(void **location);
+size_t generate_section_firmware(void **location);
+size_t generate_section_dmar_generic(void **location);
+size_t generate_section_dmar_vtd(void **location);
+size_t generate_section_dmar_iommu(void **location);
+size_t generate_section_ccix_per(void **location);
+size_t generate_section_cxl_protocol(void **location);
+size_t generate_section_cxl_component(void **location);
 
 //Definition structure for a single CPER section generator.
 typedef struct {
-    EFI_GUID* Guid;
-    const char* ShortName;
-    size_t (*Generate)(void**);
+	EFI_GUID *Guid;
+	const char *ShortName;
+	size_t (*Generate)(void **);
 } CPER_GENERATOR_DEFINITION;
 
 extern CPER_GENERATOR_DEFINITION generator_definitions[];
 extern const size_t generator_definitions_len;
 
-#endif
\ No newline at end of file
+#endif
diff --git a/ir-parse.c b/ir-parse.c
index 35c35c8..50c0128 100644
--- a/ir-parse.c
+++ b/ir-parse.c
@@ -7,7 +7,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "edk/Cper.h"
 #include "cper-parse.h"
 #include "cper-utils.h"
@@ -53,18 +53,22 @@
 	//Run through each section in turn.
 	json_object *sections = json_object_object_get(ir, "sections");
 	int amt_sections = json_object_array_length(sections);
-	for (int i = 0; i < amt_sections; i++) {
-		//Get the section itself from the IR.
-		json_object *section = json_object_array_get_idx(sections, i);
+	if (amt_sections == amt_descriptors) {
+		for (int i = 0; i < amt_sections; i++) {
+			//Get the section itself from the IR.
+			json_object *section =
+				json_object_array_get_idx(sections, i);
 
-		//Convert.
-		ir_section_to_cper(section, descriptors[i], out);
+			//Convert.
+			ir_section_to_cper(section, descriptors[i], out);
+		}
 	}
 
 	//Free all remaining resources.
 	free(header);
-	for (int i = 0; i < amt_descriptors; i++)
+	for (int i = 0; i < amt_descriptors; i++) {
 		free(descriptors[i]);
+	}
 }
 
 //Converts a CPER-JSON IR header to a CPER header structure.
@@ -117,12 +121,14 @@
 		json_object_object_get(header_ir, "platformID");
 	json_object *partition_id =
 		json_object_object_get(header_ir, "partitionID");
-	if (platform_id != NULL)
+	if (platform_id != NULL) {
 		string_to_guid(&header->PlatformID,
 			       json_object_get_string(platform_id));
-	if (partition_id != NULL)
+	}
+	if (partition_id != NULL) {
 		string_to_guid(&header->PartitionID,
 			       json_object_get_string(partition_id));
+	}
 	string_to_guid(&header->CreatorID,
 		       json_object_get_string(
 			       json_object_object_get(header_ir, "creatorID")));
@@ -152,7 +158,7 @@
 {
 	//Find the correct section type, and parse.
 	int section_converted = 0;
-	for (int i = 0; i < section_definitions_len; i++) {
+	for (size_t i = 0; i < section_definitions_len; i++) {
 		if (guid_equal(section_definitions[i].Guid,
 			       &descriptor->SectionType) &&
 		    section_definitions[i].ToCPER != NULL) {
@@ -165,12 +171,18 @@
 	//If unknown GUID, so read as a base64 unknown section.
 	if (!section_converted) {
 		json_object *encoded = json_object_object_get(section, "data");
-		UINT8 *decoded =
-			b64_decode(json_object_get_string(encoded),
-				   json_object_get_string_len(encoded));
-		fwrite(decoded, descriptor->SectionLength, 1, out);
-		fflush(out);
-		free(decoded);
+		char *decoded = malloc(json_object_get_string_len(encoded));
+		size_t decoded_len = 0;
+		if (!decoded) {
+			printf("Failed to allocate decode output buffer. \n");
+		} else {
+			base64_decode(json_object_get_string(encoded),
+				      json_object_get_string_len(encoded),
+				      decoded, &decoded_len, 0);
+			fwrite(decoded, decoded_len, 1, out);
+			fflush(out);
+			free(decoded);
+		}
 	}
 }
 
@@ -211,9 +223,10 @@
 	//FRU ID, if present.
 	json_object *fru_id =
 		json_object_object_get(section_descriptor_ir, "fruID");
-	if (fru_id != NULL)
+	if (fru_id != NULL) {
 		string_to_guid(&descriptor->FruId,
 			       json_object_get_string(fru_id));
+	}
 
 	//Severity code.
 	json_object *severity =
@@ -224,9 +237,10 @@
 	//FRU text, if present.
 	json_object *fru_text =
 		json_object_object_get(section_descriptor_ir, "fruText");
-	if (fru_text != NULL)
+	if (fru_text != NULL) {
 		strncpy(descriptor->FruString, json_object_get_string(fru_text),
 			20);
+	}
 }
 
 //Converts IR for a given single section format CPER record into CPER binary.
@@ -249,4 +263,4 @@
 
 	//Free remaining resources.
 	free(section_descriptor);
-}
\ No newline at end of file
+}
diff --git a/json-schema.c b/json-schema.c
index 16ddef5..4a9048a 100644
--- a/json-schema.c
+++ b/json-schema.c
@@ -14,6 +14,7 @@
 #include <json.h>
 #include "json-schema.h"
 #include "edk/BaseTypes.h"
+#include <linux/limits.h>
 
 //Field definitions.
 int json_validator_debug = 0;
@@ -57,6 +58,7 @@
 
 	//Free memory from directory call.
 	free(schema_file_copy);
+	json_object_put(schema_ir);
 
 	return result;
 }
@@ -69,8 +71,8 @@
 {
 	//Check that the schema version is the same as this validator.
 	json_object *schema_ver = json_object_object_get(schema, "$schema");
-	if (schema_ver == NULL ||
-	    strcmp(json_object_get_string(schema_ver), JSON_SCHEMA_VERSION)) {
+	if (schema_ver == NULL || strcmp(json_object_get_string(schema_ver),
+					 JSON_SCHEMA_VERSION) != 0) {
 		log_validator_error(
 			error_message,
 			"Provided schema is not of the same version that is referenced by this validator, or is not a schema.");
@@ -82,11 +84,17 @@
 	if (getcwd(original_cwd, PATH_MAX) == NULL) {
 		log_validator_error(error_message,
 				    "Failed fetching the current directory.");
+		if (original_cwd) {
+			free(original_cwd);
+		}
 		return 0;
 	}
 	if (chdir(schema_directory)) {
 		log_validator_error(error_message,
 				    "Failed to chdir into schema directory.");
+		if (original_cwd) {
+			free(original_cwd);
+		}
 		return 0;
 	}
 
@@ -94,12 +102,17 @@
 	int result = validate_field("parent", schema, object, error_message);
 
 	//Change back to original CWD.
-	chdir(original_cwd);
+	if (chdir(original_cwd)) {
+		log_validator_error(error_message,
+				    "Failed to chdir into original directory.");
+	}
+
 	free(original_cwd);
 
-	if (result)
+	if (result) {
 		log_validator_debug(
 			"Successfully validated the provided object against schema.");
+	}
 	return result;
 }
 
@@ -119,14 +132,15 @@
 
 		//Attempt to load. If loading fails, report error.
 		const char *ref_path = json_object_get_string(ref_schema);
-		schema = json_object_from_file(ref_path);
-		if (schema == NULL) {
+		json_object *tmp = json_object_from_file(ref_path);
+		if (tmp == NULL) {
 			log_validator_error(
 				error_message,
 				"Failed to open referenced schema file '%s'.",
 				ref_path);
 			return -1;
 		}
+		json_object_put(tmp);
 
 		log_validator_debug("loaded schema path '%s' for field '%s'.",
 				    ref_path, field_name);
@@ -190,10 +204,12 @@
 			//Validate field with schema.
 			validated = validate_field(field_name, one_of_option,
 						   object, error_message);
-			if (validated == -1)
+			if (validated == -1) {
 				return -1;
-			if (validated)
+			}
+			if (validated) {
 				break;
+			}
 		}
 
 		//Return if failed all checks.
@@ -240,7 +256,7 @@
 	if (min_value != NULL &&
 	    json_object_is_type(min_value, json_type_int)) {
 		int min_value_int = json_object_get_int(min_value);
-		if (json_object_get_uint64(object) < min_value_int) {
+		if (json_object_get_uint64(object) < (uint64_t)min_value_int) {
 			log_validator_error(
 				error_message,
 				"Failed to validate integer field '%s'. Value was below minimum of %d.",
@@ -254,7 +270,7 @@
 	if (max_value != NULL &&
 	    json_object_is_type(max_value, json_type_int)) {
 		int max_value_int = json_object_get_int(max_value);
-		if (json_object_get_uint64(object) > max_value_int) {
+		if (json_object_get_uint64(object) > (uint64_t)max_value_int) {
 			log_validator_error(
 				error_message,
 				"Failed to validate integer field '%s'. Value was above maximum of %d.",
@@ -271,6 +287,11 @@
 		    json_object *object, char *error_message)
 {
 	//todo: if there is a "pattern" field, verify the string with RegEx.
+	(void)field_name;
+	(void)schema;
+	(void)object;
+	(void)error_message;
+
 	return 1;
 }
 
@@ -320,9 +341,10 @@
 		json_object_object_get(schema, "additionalProperties");
 	int additional_properties_allowed = 0;
 	if (additional_properties != NULL &&
-	    json_object_get_type(additional_properties) == json_type_boolean)
+	    json_object_get_type(additional_properties) == json_type_boolean) {
 		additional_properties_allowed =
 			json_object_get_boolean(additional_properties);
+	}
 
 	//Run through the "properties" object and validate each of those in turn.
 	json_object *properties = json_object_object_get(schema, "properties");
@@ -333,21 +355,26 @@
 			//If the given property name does not exist on the target object, ignore and continue next.
 			json_object *object_prop =
 				json_object_object_get(object, key);
-			if (object_prop == NULL)
+			if (object_prop == NULL) {
 				continue;
+			}
 
 			//Validate against the schema.
 			if (!validate_field(key, value, object_prop,
-					    error_message))
+					    error_message)) {
 				return 0;
+			}
 		}
 
 		//If additional properties are banned, validate that no additional properties exist.
 		if (!additional_properties_allowed) {
 			json_object_object_foreach(object, key, value)
 			{
+				//Avoid compiler warning
+				(void)value;
+
 				//If the given property name does not exist on the schema object, fail validation.
-				json_object *schema_prop =
+				const json_object *schema_prop =
 					json_object_object_get(properties, key);
 				if (schema_prop == NULL) {
 					log_validator_error(
@@ -376,8 +403,9 @@
 			if (!validate_field(field_name, items_schema,
 					    json_object_array_get_idx(object,
 								      i),
-					    error_message))
+					    error_message)) {
 				return 0;
+			}
 		}
 	}
 
@@ -435,4 +463,4 @@
 		vfprintf(stdout, new_format, args);
 		free(new_format);
 	}
-}
\ No newline at end of file
+}
diff --git a/json-schema.h b/json-schema.h
index 02e45c6..59fb58b 100644
--- a/json-schema.h
+++ b/json-schema.h
@@ -3,12 +3,14 @@
 
 #include <json.h>
 
-#define JSON_SCHEMA_VERSION "https://json-schema.org/draft/2020-12/schema"
+#define JSON_SCHEMA_VERSION    "https://json-schema.org/draft/2020-12/schema"
 #define JSON_ERROR_MSG_MAX_LEN 512
 
-int validate_schema(json_object* schema, char* schema_directory, json_object* object, char* error_message);
-int validate_schema_from_file(const char* schema_file, json_object* object, char* error_message);
+int validate_schema(json_object *schema, char *schema_directory,
+		    json_object *object, char *error_message);
+int validate_schema_from_file(const char *schema_file, json_object *object,
+			      char *error_message);
 void validate_schema_debug_enable();
 void validate_schema_debug_disable();
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-arm.c b/sections/cper-section-arm.c
index 6537f40..e0f7cb5 100644
--- a/sections/cper-section-arm.c
+++ b/sections/cper-section-arm.c
@@ -7,7 +7,7 @@
 
 #include <stdio.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "../edk/Cper.h"
 #include "../cper-utils.h"
 #include "cper-section-arm.h"
@@ -40,13 +40,10 @@
 void ir_arm_aarch64_el2_to_cper(json_object *registers, FILE *out);
 void ir_arm_aarch64_el3_to_cper(json_object *registers, FILE *out);
 void ir_arm_misc_registers_to_cper(json_object *registers, FILE *out);
-void ir_arm_unknown_register_to_cper(json_object *registers,
-				     EFI_ARM_CONTEXT_INFORMATION_HEADER *header,
-				     FILE *out);
+void ir_arm_unknown_register_to_cper(json_object *registers, FILE *out);
 
 //Converts the given processor-generic CPER section into JSON IR.
-json_object *cper_section_arm_to_ir(void *section,
-				    EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_arm_to_ir(void *section)
 {
 	EFI_ARM_ERROR_RECORD *record = (EFI_ARM_ERROR_RECORD *)section;
 	json_object *section_ir = json_object_new_object();
@@ -71,8 +68,8 @@
 	json_object_object_add(
 		error_affinity, "type",
 		json_object_new_string(record->ErrorAffinityLevel < 4 ?
-						     "Vendor Defined" :
-						     "Reserved"));
+					       "Vendor Defined" :
+					       "Reserved"));
 	json_object_object_add(section_ir, "errorAffinity", error_affinity);
 
 	//Processor ID (MPIDR_EL1) and chip ID (MIDR_EL1).
@@ -84,7 +81,7 @@
 	//Whether the processor is running, and the state of it if so.
 	json_object_object_add(section_ir, "running",
 			       json_object_new_boolean(record->RunningState &
-						       0b1));
+						       0x1));
 	if (!(record->RunningState >> 31)) {
 		//Bit 32 of running state is on, so PSCI state information is included.
 		//This can't be made human readable, as it is unknown whether this will be the pre-PSCI 1.0 format
@@ -107,29 +104,38 @@
 
 	//Processor context structures.
 	//The current position is moved within the processing, as it is a dynamic size structure.
-	void *cur_pos = (void *)cur_error;
+	uint8_t *cur_pos = (uint8_t *)cur_error;
 	json_object *context_info_array = json_object_new_array();
 	for (int i = 0; i < record->ContextInfoNum; i++) {
 		EFI_ARM_CONTEXT_INFORMATION_HEADER *header =
 			(EFI_ARM_CONTEXT_INFORMATION_HEADER *)cur_pos;
 		json_object *processor_context =
-			cper_arm_processor_context_to_ir(header, &cur_pos);
+			cper_arm_processor_context_to_ir(header,
+							 (void **)&cur_pos);
 		json_object_array_add(context_info_array, processor_context);
 	}
 	json_object_object_add(section_ir, "contextInfo", context_info_array);
 
 	//Is there any vendor-specific information following?
-	if (cur_pos < section + record->SectionLength) {
+	if (cur_pos < (uint8_t *)section + record->SectionLength) {
 		json_object *vendor_specific = json_object_new_object();
-		char *encoded =
-			b64_encode((unsigned char *)cur_pos,
-				   section + record->SectionLength - cur_pos);
-		json_object_object_add(vendor_specific, "data",
-				       json_object_new_string(encoded));
-		free(encoded);
+		size_t input_size =
+			(uint8_t *)section + record->SectionLength - cur_pos;
+		char *encoded = malloc(2 * input_size);
+		size_t encoded_len = 0;
+		if (!encoded) {
+			printf("Failed to allocate encode output buffer. \n");
+		} else {
+			base64_encode((const char *)cur_pos, input_size,
+				      encoded, &encoded_len, 0);
+			json_object_object_add(vendor_specific, "data",
+					       json_object_new_string_len(
+						       encoded, encoded_len));
+			free(encoded);
 
-		json_object_object_add(section_ir, "vendorSpecificInfo",
-				       vendor_specific);
+			json_object_object_add(section_ir, "vendorSpecificInfo",
+					       vendor_specific);
+		}
 	}
 
 	return section_ir;
@@ -166,8 +172,8 @@
 	json_object_object_add(
 		multiple_error, "type",
 		json_object_new_string(error_info->MultipleError < 1 ?
-						     "Single Error" :
-						     "Multiple Errors"));
+					       "Single Error" :
+					       "Multiple Errors"));
 	json_object_object_add(error_info_ir, "multipleError", multiple_error);
 
 	//Flags.
@@ -179,7 +185,7 @@
 	json_object *error_subinfo = NULL;
 	switch (error_info->Type) {
 	case ARM_ERROR_INFORMATION_TYPE_CACHE: //Cache
-	case ARM_ERROR_INFORMATION_TYPE_TLB: //TLB
+	case ARM_ERROR_INFORMATION_TYPE_TLB:   //TLB
 		error_subinfo = cper_arm_cache_tlb_error_to_ir(
 			(EFI_ARM_CACHE_ERROR_STRUCTURE *)&error_info
 				->ErrorInformation,
@@ -340,7 +346,7 @@
 	json_object_object_add(
 		access_mode, "name",
 		json_object_new_string(bus_error->AccessMode == 0 ? "Secure" :
-									  "Normal"));
+								    "Normal"));
 	json_object_object_add(bus_error_ir, "accessMode", access_mode);
 
 	return bus_error_ir;
@@ -435,11 +441,19 @@
 	default:
 		//Unknown register array type, add as base64 data instead.
 		register_array = json_object_new_object();
-		char *encoded = b64_encode((unsigned char *)cur_pos,
-					   header->RegisterArraySize);
-		json_object_object_add(register_array, "data",
-				       json_object_new_string(encoded));
-		free(encoded);
+		char *encoded = malloc(2 * header->RegisterArraySize);
+		size_t encoded_len = 0;
+		if (!encoded) {
+			printf("Failed to allocate encode output buffer. \n");
+		} else {
+			base64_encode((const char *)cur_pos,
+				      header->RegisterArraySize, encoded,
+				      &encoded_len, 0);
+			json_object_object_add(register_array, "data",
+					       json_object_new_string_len(
+						       encoded, encoded_len));
+			free(encoded);
+		}
 		break;
 	}
 	json_object_object_add(context_ir, "registerArray", register_array);
@@ -478,7 +492,6 @@
 {
 	EFI_ARM_ERROR_RECORD *section_cper =
 		(EFI_ARM_ERROR_RECORD *)calloc(1, sizeof(EFI_ARM_ERROR_RECORD));
-	long starting_stream_pos = ftell(out);
 
 	//Validation bits.
 	section_cper->ValidFields = ir_to_bitfield(
@@ -505,8 +518,9 @@
 
 	//Optional PSCI state.
 	json_object *psci_state = json_object_object_get(section, "psciState");
-	if (psci_state != NULL)
+	if (psci_state != NULL) {
 		section_cper->PsciState = json_object_get_uint64(psci_state);
+	}
 
 	//Flush header to stream.
 	fwrite(section_cper, sizeof(EFI_ARM_ERROR_RECORD), 1, out);
@@ -514,16 +528,18 @@
 
 	//Error info structure array.
 	json_object *error_info = json_object_object_get(section, "errorInfo");
-	for (int i = 0; i < section_cper->ErrInfoNum; i++)
+	for (int i = 0; i < section_cper->ErrInfoNum; i++) {
 		ir_arm_error_info_to_cper(
 			json_object_array_get_idx(error_info, i), out);
+	}
 
 	//Context info structure array.
 	json_object *context_info =
 		json_object_object_get(section, "contextInfo");
-	for (int i = 0; i < section_cper->ContextInfoNum; i++)
+	for (int i = 0; i < section_cper->ContextInfoNum; i++) {
 		ir_arm_context_info_to_cper(
 			json_object_array_get_idx(context_info, i), out);
+	}
 
 	//Vendor specific error info.
 	json_object *vendor_specific_info =
@@ -533,18 +549,20 @@
 			json_object_object_get(vendor_specific_info, "data");
 		int vendor_specific_len =
 			json_object_get_string_len(vendor_info_string);
-		UINT8 *decoded =
-			b64_decode(json_object_get_string(vendor_info_string),
-				   vendor_specific_len);
+		char *decoded = malloc(vendor_specific_len);
+		size_t decoded_len = 0;
+		if (!decoded) {
+			printf("Failed to allocate decode output buffer. \n");
+		} else {
+			base64_decode(
+				json_object_get_string(vendor_info_string),
+				vendor_specific_len, decoded, &decoded_len, 0);
 
-		//Write out to file.
-		long cur_stream_pos = ftell(out);
-		fwrite(decoded,
-		       starting_stream_pos + section_cper->SectionLength -
-			       cur_stream_pos,
-		       1, out);
-		fflush(out);
-		free(decoded);
+			//Write out to file.
+			fwrite(decoded, decoded_len, 1, out);
+			fflush(out);
+			free(decoded);
+		}
 	}
 
 	//Free remaining resources.
@@ -730,8 +748,7 @@
 		break;
 	default:
 		//Unknown register structure.
-		ir_arm_unknown_register_to_cper(register_array, &info_header,
-						out);
+		ir_arm_unknown_register_to_cper(register_array, out);
 		break;
 	}
 }
@@ -883,17 +900,22 @@
 }
 
 //Converts a single ARM unknown register CPER-JSON object to CPER binary, outputting to the given stream.
-void ir_arm_unknown_register_to_cper(json_object *registers,
-				     EFI_ARM_CONTEXT_INFORMATION_HEADER *header,
-				     FILE *out)
+void ir_arm_unknown_register_to_cper(json_object *registers, FILE *out)
 {
 	//Get base64 represented data.
 	json_object *encoded = json_object_object_get(registers, "data");
-	UINT8 *decoded = b64_decode(json_object_get_string(encoded),
-				    json_object_get_string_len(encoded));
+	char *decoded = malloc(json_object_get_string_len(encoded));
+	size_t decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
 
-	//Flush out to stream.
-	fwrite(&decoded, header->RegisterArraySize, 1, out);
-	fflush(out);
-	free(decoded);
-}
\ No newline at end of file
+		//Flush out to stream.
+		fwrite(&decoded, decoded_len, 1, out);
+		fflush(out);
+		free(decoded);
+	}
+}
diff --git a/sections/cper-section-arm.h b/sections/cper-section-arm.h
index 1468405..5ee18d8 100644
--- a/sections/cper-section-arm.h
+++ b/sections/cper-section-arm.h
@@ -4,332 +4,458 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define ARM_ERROR_VALID_BITFIELD_NAMES (const char*[]) \
-    {"mpidrValid", "errorAffinityLevelValid", "runningStateValid", "vendorSpecificInfoValid"}
-#define ARM_ERROR_INFO_ENTRY_VALID_BITFIELD_NAMES (const char*[]) \
-    {"multipleErrorValid", "flagsValid", "errorInformationValid", "virtualFaultAddressValid", "physicalFaultAddressValid"}
-#define ARM_ERROR_INFO_ENTRY_FLAGS_NAMES (const char*[]) \
-    {"firstErrorCaptured", "lastErrorCaptured", "propagated", "overflow"}
-#define ARM_CACHE_TLB_ERROR_VALID_BITFIELD_NAMES (const char*[]) \
-    {"transactionTypeValid", "operationValid", "levelValid", "processorContextCorruptValid", "correctedValid", \
-    "precisePCValid", "restartablePCValid"}
-#define ARM_BUS_ERROR_VALID_BITFIELD_NAMES (const char*[]) \
-    {"transactionTypeValid", "operationValid", "levelValid", "processorContextCorruptValid", "correctedValid", \
-    "precisePCValid", "restartablePCValid", "participationTypeValid", "timedOutValid", "addressSpaceValid", \
-    "memoryAttributesValid", "accessModeValid"}
-#define ARM_ERROR_TRANSACTION_TYPES_KEYS (int []){0, 1, 2}
-#define ARM_ERROR_TRANSACTION_TYPES_VALUES (const char*[]){"Instruction", "Data Access", "Generic"}
-#define ARM_ERROR_INFO_ENTRY_INFO_TYPES_KEYS (int []){0, 1, 2, 3}
-#define ARM_ERROR_INFO_ENTRY_INFO_TYPES_VALUES (const char*[]){"Cache Error", "TLB Error", \
-    "Bus Error", "Micro-Architectural Error"}
-#define ARM_CACHE_BUS_OPERATION_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
-#define ARM_CACHE_BUS_OPERATION_TYPES_VALUES (const char*[]){"Generic Error", "Generic Read", "Generic Write", \
-    "Data Read", "Data Write", "Instruction Fetch", "Prefetch", "Eviction", "Snooping", "Snooped", "Management"}
-#define ARM_TLB_OPERATION_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8}
-#define ARM_TLB_OPERATION_TYPES_VALUES (const char*[]){"Generic Error", "Generic Read", "Generic Write", \
-    "Data Read", "Data Write", "Instruction Fetch", "Prefetch", "Local Management Operation", \
-    "External Management Operation"}
-#define ARM_BUS_PARTICIPATION_TYPES_KEYS (int []){0, 1, 2, 3}
-#define ARM_BUS_PARTICIPATION_TYPES_VALUES (const char*[]){"Local Processor Originated Request", \
-    "Local Processor Responded to Request", "Local Processor Observed", "Generic"}
-#define ARM_BUS_ADDRESS_SPACE_TYPES_KEYS (int []){0, 1, 3}
-#define ARM_BUS_ADDRESS_SPACE_TYPES_VALUES (const char*[]){"External Memory Access", "Internal Memory Access", \
-    "Device Memory Access"}
-#define ARM_PROCESSOR_INFO_REGISTER_CONTEXT_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8}
-#define ARM_PROCESSOR_INFO_REGISTER_CONTEXT_TYPES_VALUES (const char*[]){"AArch32 General Purpose Registers", \
-    "AArch32 EL1 Context Registers", "AArch32 EL2 Context Registers", "AArch32 Secure Context Registers", \
-    "AArch64 General Purpose Registers", "AArch64 EL1 Context Registers", "AArch64 EL2 Context Registers", \
-    "AArch64 EL3 Context Registers", "Miscellaneous System Register Structure"}
-#define ARM_AARCH32_GPR_NAMES (const char*[]){"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", \
-    "r10", "r11", "r12", "r13_sp", "r14_lr", "r15_pc"}
-#define ARM_AARCH32_EL1_REGISTER_NAMES (const char*[]){"dfar", "dfsr", "ifar", "isr", "mair0", "mair1", "midr", \
-    "mpidr", "nmrr", "prrr", "sctlr_ns", "spsr", "spsr_abt", "spsr_fiq", "spsr_irq", "spsr_svc", "spsr_und", \
-    "tpidrprw", "tpidruro", "tpidrurw", "ttbcr", "ttbr0", "ttbr1", "dacr"}
-#define ARM_AARCH32_EL2_REGISTER_NAMES (const char*[]){"elr_hyp", "hamair0", "hamair1", "hcr", "hcr2", "hdfar", \
-    "hifar", "hpfar", "hsr", "htcr", "htpidr", "httbr", "spsr_hyp", "vtcr", "vttbr", "dacr32_el2"}
-#define ARM_AARCH32_SECURE_REGISTER_NAMES (const char*[]){"sctlr_s", "spsr_mon"}
-#define ARM_AARCH64_GPR_NAMES (const char*[]){"x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", \
-    "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26", \
-    "x27", "x28", "x29", "x30", "sp"}
-#define ARM_AARCH64_EL1_REGISTER_NAMES (const char*[]){"elr_el1", "esr_el1", "far_el1", "isr_el1", "mair_el1", \
-    "midr_el1", "mpidr_el1", "sctlr_el1", "sp_el0", "sp_el1", "spsr_el1", "tcr_el1", "tpidr_el0", "tpidr_el1", \
-    "tpidrro_el0", "ttbr0_el1", "ttbr1_el1"}
-#define ARM_AARCH64_EL2_REGISTER_NAMES (const char*[]){"elr_el2", "esr_el2", "far_el2", "hacr_el2", "hcr_el2", \
-    "hpfar_el2", "mair_el2", "sctlr_el2", "sp_el2", "spsr_el2", "tcr_el2", "tpidr_el2", "ttbr0_el2", "vtcr_el2", \
-    "vttbr_el2"}
-#define ARM_AARCH64_EL3_REGISTER_NAMES (const char*[]){"elr_el3", "esr_el3", "far_el3", "mair_el3", "sctlr_el3", \
-    "sp_el3", "spsr_el3", "tcr_el3", "tpidr_el3", "ttbr0_el3"}
+#define ARM_ERROR_VALID_BITFIELD_NAMES                                         \
+	(const char *[])                                                       \
+	{                                                                      \
+		"mpidrValid", "errorAffinityLevelValid", "runningStateValid",  \
+			"vendorSpecificInfoValid"                              \
+	}
+#define ARM_ERROR_INFO_ENTRY_VALID_BITFIELD_NAMES                              \
+	(const char *[])                                                       \
+	{                                                                      \
+		"multipleErrorValid", "flagsValid", "errorInformationValid",   \
+			"virtualFaultAddressValid",                            \
+			"physicalFaultAddressValid"                            \
+	}
+#define ARM_ERROR_INFO_ENTRY_FLAGS_NAMES                                       \
+	(const char *[])                                                       \
+	{                                                                      \
+		"firstErrorCaptured", "lastErrorCaptured", "propagated",       \
+			"overflow"                                             \
+	}
+#define ARM_CACHE_TLB_ERROR_VALID_BITFIELD_NAMES                               \
+	(const char *[])                                                       \
+	{                                                                      \
+		"transactionTypeValid", "operationValid", "levelValid",        \
+			"processorContextCorruptValid", "correctedValid",      \
+			"precisePCValid", "restartablePCValid"                 \
+	}
+#define ARM_BUS_ERROR_VALID_BITFIELD_NAMES                                     \
+	(const char *[])                                                       \
+	{                                                                      \
+		"transactionTypeValid", "operationValid", "levelValid",        \
+			"processorContextCorruptValid", "correctedValid",      \
+			"precisePCValid", "restartablePCValid",                \
+			"participationTypeValid", "timedOutValid",             \
+			"addressSpaceValid", "memoryAttributesValid",          \
+			"accessModeValid"                                      \
+	}
+#define ARM_ERROR_TRANSACTION_TYPES_KEYS                                       \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2                                                        \
+	}
+#define ARM_ERROR_TRANSACTION_TYPES_VALUES                                     \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Instruction", "Data Access", "Generic"                        \
+	}
+#define ARM_ERROR_INFO_ENTRY_INFO_TYPES_KEYS                                   \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3                                                     \
+	}
+#define ARM_ERROR_INFO_ENTRY_INFO_TYPES_VALUES                                 \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Cache Error", "TLB Error", "Bus Error",                       \
+			"Micro-Architectural Error"                            \
+	}
+#define ARM_CACHE_BUS_OPERATION_TYPES_KEYS                                     \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10                               \
+	}
+#define ARM_CACHE_BUS_OPERATION_TYPES_VALUES                                   \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Generic Error", "Generic Read", "Generic Write", "Data Read", \
+			"Data Write", "Instruction Fetch", "Prefetch",         \
+			"Eviction", "Snooping", "Snooped", "Management"        \
+	}
+#define ARM_TLB_OPERATION_TYPES_KEYS                                           \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4, 5, 6, 7, 8                                      \
+	}
+#define ARM_TLB_OPERATION_TYPES_VALUES                                         \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Generic Error", "Generic Read", "Generic Write", "Data Read", \
+			"Data Write", "Instruction Fetch", "Prefetch",         \
+			"Local Management Operation",                          \
+			"External Management Operation"                        \
+	}
+#define ARM_BUS_PARTICIPATION_TYPES_KEYS                                       \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3                                                     \
+	}
+#define ARM_BUS_PARTICIPATION_TYPES_VALUES                                     \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Local Processor Originated Request",                          \
+			"Local Processor Responded to Request",                \
+			"Local Processor Observed", "Generic"                  \
+	}
+#define ARM_BUS_ADDRESS_SPACE_TYPES_KEYS                                       \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 3                                                        \
+	}
+#define ARM_BUS_ADDRESS_SPACE_TYPES_VALUES                                     \
+	(const char *[])                                                       \
+	{                                                                      \
+		"External Memory Access", "Internal Memory Access",            \
+			"Device Memory Access"                                 \
+	}
+#define ARM_PROCESSOR_INFO_REGISTER_CONTEXT_TYPES_KEYS                         \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4, 5, 6, 7, 8                                      \
+	}
+#define ARM_PROCESSOR_INFO_REGISTER_CONTEXT_TYPES_VALUES                       \
+	(const char *[])                                                       \
+	{                                                                      \
+		"AArch32 General Purpose Registers",                           \
+			"AArch32 EL1 Context Registers",                       \
+			"AArch32 EL2 Context Registers",                       \
+			"AArch32 Secure Context Registers",                    \
+			"AArch64 General Purpose Registers",                   \
+			"AArch64 EL1 Context Registers",                       \
+			"AArch64 EL2 Context Registers",                       \
+			"AArch64 EL3 Context Registers",                       \
+			"Miscellaneous System Register Structure"              \
+	}
+#define ARM_AARCH32_GPR_NAMES                                                  \
+	(const char *[])                                                       \
+	{                                                                      \
+		"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",    \
+			"r10", "r11", "r12", "r13_sp", "r14_lr", "r15_pc"      \
+	}
+#define ARM_AARCH32_EL1_REGISTER_NAMES                                         \
+	(const char *[])                                                       \
+	{                                                                      \
+		"dfar", "dfsr", "ifar", "isr", "mair0", "mair1", "midr",       \
+			"mpidr", "nmrr", "prrr", "sctlr_ns", "spsr",           \
+			"spsr_abt", "spsr_fiq", "spsr_irq", "spsr_svc",        \
+			"spsr_und", "tpidrprw", "tpidruro", "tpidrurw",        \
+			"ttbcr", "ttbr0", "ttbr1", "dacr"                      \
+	}
+#define ARM_AARCH32_EL2_REGISTER_NAMES                                         \
+	(const char *[])                                                       \
+	{                                                                      \
+		"elr_hyp", "hamair0", "hamair1", "hcr", "hcr2", "hdfar",       \
+			"hifar", "hpfar", "hsr", "htcr", "htpidr", "httbr",    \
+			"spsr_hyp", "vtcr", "vttbr", "dacr32_el2"              \
+	}
+#define ARM_AARCH32_SECURE_REGISTER_NAMES                                      \
+	(const char *[])                                                       \
+	{                                                                      \
+		"sctlr_s", "spsr_mon"                                          \
+	}
+#define ARM_AARCH64_GPR_NAMES                                                  \
+	(const char *[])                                                       \
+	{                                                                      \
+		"x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9",    \
+			"x10", "x11", "x12", "x13", "x14", "x15", "x16",       \
+			"x17", "x18", "x19", "x20", "x21", "x22", "x23",       \
+			"x24", "x25", "x26", "x27", "x28", "x29", "x30", "sp"  \
+	}
+#define ARM_AARCH64_EL1_REGISTER_NAMES                                         \
+	(const char *[])                                                       \
+	{                                                                      \
+		"elr_el1", "esr_el1", "far_el1", "isr_el1", "mair_el1",        \
+			"midr_el1", "mpidr_el1", "sctlr_el1", "sp_el0",        \
+			"sp_el1", "spsr_el1", "tcr_el1", "tpidr_el0",          \
+			"tpidr_el1", "tpidrro_el0", "ttbr0_el1", "ttbr1_el1"   \
+	}
+#define ARM_AARCH64_EL2_REGISTER_NAMES                                         \
+	(const char *[])                                                       \
+	{                                                                      \
+		"elr_el2", "esr_el2", "far_el2", "hacr_el2", "hcr_el2",        \
+			"hpfar_el2", "mair_el2", "sctlr_el2", "sp_el2",        \
+			"spsr_el2", "tcr_el2", "tpidr_el2", "ttbr0_el2",       \
+			"vtcr_el2", "vttbr_el2"                                \
+	}
+#define ARM_AARCH64_EL3_REGISTER_NAMES                                         \
+	(const char *[])                                                       \
+	{                                                                      \
+		"elr_el3", "esr_el3", "far_el3", "mair_el3", "sctlr_el3",      \
+			"sp_el3", "spsr_el3", "tcr_el3", "tpidr_el3",          \
+			"ttbr0_el3"                                            \
+	}
 
 ///
 /// ARM Processor Error Record
 ///
 typedef struct {
-  UINT32    ValidFields;
-  UINT16    ErrInfoNum;
-  UINT16    ContextInfoNum;
-  UINT32    SectionLength;
-  UINT32  ErrorAffinityLevel;
-  UINT64  MPIDR_EL1;
-  UINT64  MIDR_EL1;
-  UINT32 RunningState;
-  UINT32 PsciState;
+	UINT32 ValidFields;
+	UINT16 ErrInfoNum;
+	UINT16 ContextInfoNum;
+	UINT32 SectionLength;
+	UINT32 ErrorAffinityLevel;
+	UINT64 MPIDR_EL1;
+	UINT64 MIDR_EL1;
+	UINT32 RunningState;
+	UINT32 PsciState;
 } __attribute__((packed, aligned(1))) EFI_ARM_ERROR_RECORD;
 
 ///
 /// ARM Processor Error Information Structure
 ///
-#define ARM_ERROR_INFORMATION_TYPE_CACHE 0
-#define ARM_ERROR_INFORMATION_TYPE_TLB 1
-#define ARM_ERROR_INFORMATION_TYPE_BUS 2
+#define ARM_ERROR_INFORMATION_TYPE_CACHE     0
+#define ARM_ERROR_INFORMATION_TYPE_TLB	     1
+#define ARM_ERROR_INFORMATION_TYPE_BUS	     2
 #define ARM_ERROR_INFORMATION_TYPE_MICROARCH 3
 
 typedef struct {
-  UINT64 ValidationBits : 16;
-  UINT64 TransactionType : 2;
-  UINT64 Operation : 4;
-  UINT64 Level : 3;
-  UINT64 ProcessorContextCorrupt : 1;
-  UINT64 Corrected : 1;
-  UINT64 PrecisePC : 1;
-  UINT64 RestartablePC : 1;
-  UINT64 Reserved : 34;
+	UINT64 ValidationBits : 16;
+	UINT64 TransactionType : 2;
+	UINT64 Operation : 4;
+	UINT64 Level : 3;
+	UINT64 ProcessorContextCorrupt : 1;
+	UINT64 Corrected : 1;
+	UINT64 PrecisePC : 1;
+	UINT64 RestartablePC : 1;
+	UINT64 Reserved : 34;
 } EFI_ARM_CACHE_ERROR_STRUCTURE;
 
 typedef struct {
-  UINT64 ValidationBits : 16;
-  UINT64 TransactionType : 2;
-  UINT64 Operation : 4;
-  UINT64 Level : 3;
-  UINT64 ProcessorContextCorrupt : 1;
-  UINT64 Corrected : 1;
-  UINT64 PrecisePC : 1;
-  UINT64 RestartablePC : 1;
-  UINT64 Reserved : 34;
+	UINT64 ValidationBits : 16;
+	UINT64 TransactionType : 2;
+	UINT64 Operation : 4;
+	UINT64 Level : 3;
+	UINT64 ProcessorContextCorrupt : 1;
+	UINT64 Corrected : 1;
+	UINT64 PrecisePC : 1;
+	UINT64 RestartablePC : 1;
+	UINT64 Reserved : 34;
 } EFI_ARM_TLB_ERROR_STRUCTURE;
 
 typedef struct {
-  UINT64 ValidationBits : 16;
-  UINT64 TransactionType : 2;
-  UINT64 Operation : 4;
-  UINT64 Level : 3;
-  UINT64 ProcessorContextCorrupt : 1;
-  UINT64 Corrected : 1;
-  UINT64 PrecisePC : 1;
-  UINT64 RestartablePC : 1;
-  UINT64 ParticipationType : 2;
-  UINT64 TimeOut : 1;
-  UINT64 AddressSpace : 2;
-  UINT64 MemoryAddressAttributes : 8;
-  UINT64 AccessMode : 1;
-  UINT64 Reserved : 19;
+	UINT64 ValidationBits : 16;
+	UINT64 TransactionType : 2;
+	UINT64 Operation : 4;
+	UINT64 Level : 3;
+	UINT64 ProcessorContextCorrupt : 1;
+	UINT64 Corrected : 1;
+	UINT64 PrecisePC : 1;
+	UINT64 RestartablePC : 1;
+	UINT64 ParticipationType : 2;
+	UINT64 TimeOut : 1;
+	UINT64 AddressSpace : 2;
+	UINT64 MemoryAddressAttributes : 8;
+	UINT64 AccessMode : 1;
+	UINT64 Reserved : 19;
 } EFI_ARM_BUS_ERROR_STRUCTURE;
 
 typedef union {
-  EFI_ARM_CACHE_ERROR_STRUCTURE CacheError;
-  EFI_ARM_TLB_ERROR_STRUCTURE TlbError;
-  EFI_ARM_BUS_ERROR_STRUCTURE BusError;
+	EFI_ARM_CACHE_ERROR_STRUCTURE CacheError;
+	EFI_ARM_TLB_ERROR_STRUCTURE TlbError;
+	EFI_ARM_BUS_ERROR_STRUCTURE BusError;
 } EFI_ARM_ERROR_INFORMATION_STRUCTURE;
 
 typedef struct {
-  UINT8 Version;
-  UINT8 Length;
-  UINT16 ValidationBits;
-  UINT8 Type;
-  UINT16 MultipleError;
-  UINT8 Flags;
-  EFI_ARM_ERROR_INFORMATION_STRUCTURE ErrorInformation;
-  UINT64 VirtualFaultAddress;
-  UINT64 PhysicalFaultAddress;
+	UINT8 Version;
+	UINT8 Length;
+	UINT16 ValidationBits;
+	UINT8 Type;
+	UINT16 MultipleError;
+	UINT8 Flags;
+	EFI_ARM_ERROR_INFORMATION_STRUCTURE ErrorInformation;
+	UINT64 VirtualFaultAddress;
+	UINT64 PhysicalFaultAddress;
 } __attribute__((packed, aligned(1))) EFI_ARM_ERROR_INFORMATION_ENTRY;
 
 ///
 /// ARM Processor Context Information Structure
 ///
 typedef struct {
-  UINT16 Version;
-  UINT16 RegisterContextType;
-  UINT32 RegisterArraySize;
+	UINT16 Version;
+	UINT16 RegisterContextType;
+	UINT32 RegisterArraySize;
 } __attribute__((packed, aligned(1))) EFI_ARM_CONTEXT_INFORMATION_HEADER;
 
 ///
 /// ARM Processor Context Register Types
 ///
-#define EFI_ARM_CONTEXT_TYPE_AARCH32_GPR 0
-#define EFI_ARM_CONTEXT_TYPE_AARCH32_EL1 1
-#define EFI_ARM_CONTEXT_TYPE_AARCH32_EL2 2
+#define EFI_ARM_CONTEXT_TYPE_AARCH32_GPR    0
+#define EFI_ARM_CONTEXT_TYPE_AARCH32_EL1    1
+#define EFI_ARM_CONTEXT_TYPE_AARCH32_EL2    2
 #define EFI_ARM_CONTEXT_TYPE_AARCH32_SECURE 3
-#define EFI_ARM_CONTEXT_TYPE_AARCH64_GPR 4
-#define EFI_ARM_CONTEXT_TYPE_AARCH64_EL1 5
-#define EFI_ARM_CONTEXT_TYPE_AARCH64_EL2 6
-#define EFI_ARM_CONTEXT_TYPE_AARCH64_EL3 7
-#define EFI_ARM_CONTEXT_TYPE_MISC 8
+#define EFI_ARM_CONTEXT_TYPE_AARCH64_GPR    4
+#define EFI_ARM_CONTEXT_TYPE_AARCH64_EL1    5
+#define EFI_ARM_CONTEXT_TYPE_AARCH64_EL2    6
+#define EFI_ARM_CONTEXT_TYPE_AARCH64_EL3    7
+#define EFI_ARM_CONTEXT_TYPE_MISC	    8
 
 typedef struct {
-  UINT32 R0;
-  UINT32 R1;
-  UINT32 R2;
-  UINT32 R3;
-  UINT32 R4;
-  UINT32 R5;
-  UINT32 R6;
-  UINT32 R7;
-  UINT32 R8;
-  UINT32 R9;
-  UINT32 R10;
-  UINT32 R11;
-  UINT32 R12;
-  UINT32 R13_sp;
-  UINT32 R14_lr;
-  UINT32 R15_pc;
+	UINT32 R0;
+	UINT32 R1;
+	UINT32 R2;
+	UINT32 R3;
+	UINT32 R4;
+	UINT32 R5;
+	UINT32 R6;
+	UINT32 R7;
+	UINT32 R8;
+	UINT32 R9;
+	UINT32 R10;
+	UINT32 R11;
+	UINT32 R12;
+	UINT32 R13_sp;
+	UINT32 R14_lr;
+	UINT32 R15_pc;
 } EFI_ARM_V8_AARCH32_GPR;
 
 typedef struct {
-  UINT32 Dfar;
-  UINT32 Dfsr;
-  UINT32 Ifar;
-  UINT32 Isr;
-  UINT32 Mair0;
-  UINT32 Mair1;
-  UINT32 Midr;
-  UINT32 Mpidr;
-  UINT32 Nmrr;
-  UINT32 Prrr;
-  UINT32 Sctlr_Ns;
-  UINT32 Spsr;
-  UINT32 Spsr_Abt;
-  UINT32 Spsr_Fiq;
-  UINT32 Spsr_Irq;
-  UINT32 Spsr_Svc;
-  UINT32 Spsr_Und;
-  UINT32 Tpidrprw;
-  UINT32 Tpidruro;
-  UINT32 Tpidrurw;
-  UINT32 Ttbcr;
-  UINT32 Ttbr0;
-  UINT32 Ttbr1;
-  UINT32 Dacr;
+	UINT32 Dfar;
+	UINT32 Dfsr;
+	UINT32 Ifar;
+	UINT32 Isr;
+	UINT32 Mair0;
+	UINT32 Mair1;
+	UINT32 Midr;
+	UINT32 Mpidr;
+	UINT32 Nmrr;
+	UINT32 Prrr;
+	UINT32 Sctlr_Ns;
+	UINT32 Spsr;
+	UINT32 Spsr_Abt;
+	UINT32 Spsr_Fiq;
+	UINT32 Spsr_Irq;
+	UINT32 Spsr_Svc;
+	UINT32 Spsr_Und;
+	UINT32 Tpidrprw;
+	UINT32 Tpidruro;
+	UINT32 Tpidrurw;
+	UINT32 Ttbcr;
+	UINT32 Ttbr0;
+	UINT32 Ttbr1;
+	UINT32 Dacr;
 } EFI_ARM_AARCH32_EL1_CONTEXT_REGISTERS;
 
 typedef struct {
-  UINT32 Elr_Hyp;
-  UINT32 Hamair0;
-  UINT32 Hamair1;
-  UINT32 Hcr;
-  UINT32 Hcr2;
-  UINT32 Hdfar;
-  UINT32 Hifar;
-  UINT32 Hpfar;
-  UINT32 Hsr;
-  UINT32 Htcr;
-  UINT32 Htpidr;
-  UINT32 Httbr;
-  UINT32 Spsr_Hyp;
-  UINT32 Vtcr;
-  UINT32 Vttbr;
-  UINT32 Dacr32_El2;
+	UINT32 Elr_Hyp;
+	UINT32 Hamair0;
+	UINT32 Hamair1;
+	UINT32 Hcr;
+	UINT32 Hcr2;
+	UINT32 Hdfar;
+	UINT32 Hifar;
+	UINT32 Hpfar;
+	UINT32 Hsr;
+	UINT32 Htcr;
+	UINT32 Htpidr;
+	UINT32 Httbr;
+	UINT32 Spsr_Hyp;
+	UINT32 Vtcr;
+	UINT32 Vttbr;
+	UINT32 Dacr32_El2;
 } EFI_ARM_AARCH32_EL2_CONTEXT_REGISTERS;
 
 typedef struct {
-  UINT32 Sctlr_S;
-  UINT32 Spsr_Mon;
+	UINT32 Sctlr_S;
+	UINT32 Spsr_Mon;
 } EFI_ARM_AARCH32_SECURE_CONTEXT_REGISTERS;
 
 typedef struct {
-  UINT64 X0;
-  UINT64 X1;
-  UINT64 X2;
-  UINT64 X3;
-  UINT64 X4;
-  UINT64 X5;
-  UINT64 X6;
-  UINT64 X7;
-  UINT64 X8;
-  UINT64 X9;
-  UINT64 X10;
-  UINT64 X11;
-  UINT64 X12;
-  UINT64 X13;
-  UINT64 X14;
-  UINT64 X15;
-  UINT64 X16;
-  UINT64 X17;
-  UINT64 X18;
-  UINT64 X19;
-  UINT64 X20;
-  UINT64 X21;
-  UINT64 X22;
-  UINT64 X23;
-  UINT64 X24;
-  UINT64 X25;
-  UINT64 X26;
-  UINT64 X27;
-  UINT64 X28;
-  UINT64 X29;
-  UINT64 X30;
-  UINT64 Sp;
+	UINT64 X0;
+	UINT64 X1;
+	UINT64 X2;
+	UINT64 X3;
+	UINT64 X4;
+	UINT64 X5;
+	UINT64 X6;
+	UINT64 X7;
+	UINT64 X8;
+	UINT64 X9;
+	UINT64 X10;
+	UINT64 X11;
+	UINT64 X12;
+	UINT64 X13;
+	UINT64 X14;
+	UINT64 X15;
+	UINT64 X16;
+	UINT64 X17;
+	UINT64 X18;
+	UINT64 X19;
+	UINT64 X20;
+	UINT64 X21;
+	UINT64 X22;
+	UINT64 X23;
+	UINT64 X24;
+	UINT64 X25;
+	UINT64 X26;
+	UINT64 X27;
+	UINT64 X28;
+	UINT64 X29;
+	UINT64 X30;
+	UINT64 Sp;
 } EFI_ARM_V8_AARCH64_GPR;
 
 typedef struct {
-  UINT64 Elr_El1;
-  UINT64 Esr_El1;
-  UINT64 Far_El1;
-  UINT64 Isr_El1;
-  UINT64 Mair_El1;
-  UINT64 Midr_El1;
-  UINT64 Mpidr_El1;
-  UINT64 Sctlr_El1;
-  UINT64 Sp_El0;
-  UINT64 Sp_El1;
-  UINT64 Spsr_El1;
-  UINT64 Tcr_El1;
-  UINT64 Tpidr_El0;
-  UINT64 Tpidr_El1;
-  UINT64 Tpidrro_El0;
-  UINT64 Ttbr0_El1;
-  UINT64 Ttbr1_El1;
+	UINT64 Elr_El1;
+	UINT64 Esr_El1;
+	UINT64 Far_El1;
+	UINT64 Isr_El1;
+	UINT64 Mair_El1;
+	UINT64 Midr_El1;
+	UINT64 Mpidr_El1;
+	UINT64 Sctlr_El1;
+	UINT64 Sp_El0;
+	UINT64 Sp_El1;
+	UINT64 Spsr_El1;
+	UINT64 Tcr_El1;
+	UINT64 Tpidr_El0;
+	UINT64 Tpidr_El1;
+	UINT64 Tpidrro_El0;
+	UINT64 Ttbr0_El1;
+	UINT64 Ttbr1_El1;
 } EFI_ARM_AARCH64_EL1_CONTEXT_REGISTERS;
 
 typedef struct {
-  UINT64 Elr_El2;
-  UINT64 Esr_El2;
-  UINT64 Far_El2;
-  UINT64 Hacr_El2;
-  UINT64 Hcr_El2;
-  UINT64 Hpfar_El2;
-  UINT64 Mair_El2;
-  UINT64 Sctlr_El2;
-  UINT64 Sp_El2;
-  UINT64 Spsr_El2;
-  UINT64 Tcr_El2;
-  UINT64 Tpidr_El2;
-  UINT64 Ttbr0_El2;
-  UINT64 Vtcr_El2;
-  UINT64 Vttbr_El2;
+	UINT64 Elr_El2;
+	UINT64 Esr_El2;
+	UINT64 Far_El2;
+	UINT64 Hacr_El2;
+	UINT64 Hcr_El2;
+	UINT64 Hpfar_El2;
+	UINT64 Mair_El2;
+	UINT64 Sctlr_El2;
+	UINT64 Sp_El2;
+	UINT64 Spsr_El2;
+	UINT64 Tcr_El2;
+	UINT64 Tpidr_El2;
+	UINT64 Ttbr0_El2;
+	UINT64 Vtcr_El2;
+	UINT64 Vttbr_El2;
 } EFI_ARM_AARCH64_EL2_CONTEXT_REGISTERS;
 
 typedef struct {
-  UINT64 Elr_El3;
-  UINT64 Esr_El3;
-  UINT64 Far_El3;
-  UINT64 Mair_El3;
-  UINT64 Sctlr_El3;
-  UINT64 Sp_El3;
-  UINT64 Spsr_El3;
-  UINT64 Tcr_El3;
-  UINT64 Tpidr_El3;
-  UINT64 Ttbr0_El3;
+	UINT64 Elr_El3;
+	UINT64 Esr_El3;
+	UINT64 Far_El3;
+	UINT64 Mair_El3;
+	UINT64 Sctlr_El3;
+	UINT64 Sp_El3;
+	UINT64 Spsr_El3;
+	UINT64 Tcr_El3;
+	UINT64 Tpidr_El3;
+	UINT64 Ttbr0_El3;
 } EFI_ARM_AARCH64_EL3_CONTEXT_REGISTERS;
 
 typedef struct {
-  UINT64 MrsOp2 : 3;
-  UINT64 MrsCrm : 4;
-  UINT64 MrsCrn : 4;
-  UINT64 MrsOp1 : 3;
-  UINT64 MrsO0 : 1;
-  UINT64 Value : 64;
+	UINT64 MrsOp2 : 3;
+	UINT64 MrsCrm : 4;
+	UINT64 MrsCrn : 4;
+	UINT64 MrsOp1 : 3;
+	UINT64 MrsO0 : 1;
+	UINT64 Value : 64;
 } EFI_ARM_MISC_CONTEXT_REGISTER;
 
-json_object* cper_section_arm_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_arm_to_cper(json_object* section, FILE* out);
+json_object *cper_section_arm_to_ir(void *section);
+void ir_section_arm_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-ccix-per.c b/sections/cper-section-ccix-per.c
index 4240afc..3b08cde 100644
--- a/sections/cper-section-ccix-per.c
+++ b/sections/cper-section-ccix-per.c
@@ -7,15 +7,13 @@
 #include <stdio.h>
 #include <string.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "../edk/Cper.h"
 #include "../cper-utils.h"
 #include "cper-section-ccix-per.h"
 
 //Converts a single CCIX PER log CPER section into JSON IR.
-json_object *
-cper_section_ccix_per_to_ir(void *section,
-			    EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_ccix_per_to_ir(void *section)
 {
 	EFI_CCIX_PER_LOG_DATA *ccix_error = (EFI_CCIX_PER_LOG_DATA *)section;
 	json_object *section_ir = json_object_new_object();
@@ -37,14 +35,22 @@
 
 	//CCIX PER Log.
 	//This is formatted as described in Section 7.3.2 of CCIX Base Specification (Rev 1.0).
-	unsigned char *cur_pos = (unsigned char *)(ccix_error + 1);
+	const char *cur_pos = (const char *)(ccix_error + 1);
 	int remaining_length =
 		ccix_error->Length - sizeof(EFI_CCIX_PER_LOG_DATA);
 	if (remaining_length > 0) {
-		char *encoded = b64_encode(cur_pos, remaining_length);
-		json_object_object_add(section_ir, "ccixPERLog",
-				       json_object_new_string(encoded));
-		free(encoded);
+		char *encoded = malloc(2 * remaining_length);
+		size_t encoded_len = 0;
+		if (!encoded) {
+			printf("Failed to allocate encode output buffer. \n");
+		} else {
+			base64_encode((const char *)cur_pos, remaining_length,
+				      encoded, &encoded_len, 0);
+			json_object_object_add(section_ir, "ccixPERLog",
+					       json_object_new_string_len(
+						       encoded, encoded_len));
+			free(encoded);
+		}
 	}
 
 	return section_ir;
@@ -77,13 +83,19 @@
 
 	//Write CCIX PER log itself to stream.
 	json_object *encoded = json_object_object_get(section, "ccixPERLog");
-	UINT8 *decoded = b64_decode(json_object_get_string(encoded),
-				    json_object_get_string_len(encoded));
-	fwrite(decoded, section_cper->Length - sizeof(EFI_CCIX_PER_LOG_DATA), 1,
-	       out);
-	fflush(out);
+	char *decoded = malloc(json_object_get_string_len(encoded));
+	size_t decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		fwrite(decoded, decoded_len, 1, out);
+		fflush(out);
+	}
 
 	//Free resources.
 	free(decoded);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-ccix-per.h b/sections/cper-section-ccix-per.h
index a6a557c..86e277c 100644
--- a/sections/cper-section-ccix-per.h
+++ b/sections/cper-section-ccix-per.h
@@ -4,20 +4,24 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define CCIX_PER_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"ccixSourceIDValid", "ccixPortIDValid", "ccixPERLogValid"}
+#define CCIX_PER_ERROR_VALID_BITFIELD_NAMES                                    \
+	(const char *[])                                                       \
+	{                                                                      \
+		"ccixSourceIDValid", "ccixPortIDValid", "ccixPERLogValid"      \
+	}
 
 ///
 /// CCIX PER Log Error Section
 ///
 typedef struct {
-    UINT32 Length;
-    UINT64 ValidBits;
-    UINT8 CcixSourceId;
-    UINT8 CcixPortId;
-    UINT16 Reserved;
+	UINT32 Length;
+	UINT64 ValidBits;
+	UINT8 CcixSourceId;
+	UINT8 CcixPortId;
+	UINT16 Reserved;
 } __attribute__((packed, aligned(1))) EFI_CCIX_PER_LOG_DATA;
 
-json_object* cper_section_ccix_per_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_ccix_per_to_cper(json_object* section, FILE* out);
+json_object *cper_section_ccix_per_to_ir(void *section);
+void ir_section_ccix_per_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-cxl-component.c b/sections/cper-section-cxl-component.c
index 098b20d..aa5a0d2 100644
--- a/sections/cper-section-cxl-component.c
+++ b/sections/cper-section-cxl-component.c
@@ -6,15 +6,13 @@
  **/
 #include <stdio.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "../edk/Cper.h"
 #include "../cper-utils.h"
 #include "cper-section-cxl-component.h"
 
 //Converts a single CXL component error CPER section into JSON IR.
-json_object *
-cper_section_cxl_component_to_ir(void *section,
-				 EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_cxl_component_to_ir(void *section)
 {
 	EFI_CXL_COMPONENT_EVENT_HEADER *cxl_error =
 		(EFI_CXL_COMPONENT_EVENT_HEADER *)section;
@@ -60,16 +58,26 @@
 			       json_object_new_uint64(cxl_error->DeviceSerial));
 
 	//The specification for this is defined within the CXL Specification Section 8.2.9.1.
-	unsigned char *cur_pos = (unsigned char *)(cxl_error + 1);
-	int remaining_len = cxl_error->Length - sizeof(cxl_error);
+	const char *cur_pos = (const char *)(cxl_error + 1);
+	int remaining_len =
+		cxl_error->Length - sizeof(EFI_CXL_COMPONENT_EVENT_HEADER);
 	if (remaining_len > 0) {
 		json_object *event_log = json_object_new_object();
-		char *encoded = b64_encode(cur_pos, remaining_len);
-		json_object_object_add(event_log, "data",
-				       json_object_new_string(encoded));
-		free(encoded);
-		json_object_object_add(section_ir, "cxlComponentEventLog",
-				       event_log);
+		char *encoded = malloc(2 * remaining_len);
+		size_t encoded_len = 0;
+		if (!encoded) {
+			printf("Failed to allocate encode output buffer. \n");
+		} else {
+			base64_encode((const char *)cur_pos, remaining_len,
+				      encoded, &encoded_len, 0);
+			json_object_object_add(event_log, "data",
+					       json_object_new_string_len(
+						       encoded, encoded_len));
+
+			free(encoded);
+			json_object_object_add(
+				section_ir, "cxlComponentEventLog", event_log);
+		}
 	}
 
 	return section_ir;
@@ -121,13 +129,18 @@
 	json_object *event_log =
 		json_object_object_get(section, "cxlComponentEventLog");
 	json_object *encoded = json_object_object_get(event_log, "data");
-	int log_length =
-		section_cper->Length - sizeof(EFI_CXL_COMPONENT_EVENT_HEADER);
-	char *decoded = b64_decode(json_object_get_string(encoded),
-				   json_object_get_string_len(encoded));
-	fwrite(decoded, log_length, 1, out);
-	fflush(out);
-	free(decoded);
+	char *decoded = malloc(json_object_get_string_len(encoded));
+	size_t decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		fwrite(decoded, decoded_len, 1, out);
+		fflush(out);
+		free(decoded);
+	}
 
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-cxl-component.h b/sections/cper-section-cxl-component.h
index 21a1374..69b9066 100644
--- a/sections/cper-section-cxl-component.h
+++ b/sections/cper-section-cxl-component.h
@@ -4,32 +4,36 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define CXL_COMPONENT_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"deviceIDValid", "deviceSerialValid", \
-    "cxlComponentEventLogValid"}
+#define CXL_COMPONENT_ERROR_VALID_BITFIELD_NAMES                               \
+	(const char *[])                                                       \
+	{                                                                      \
+		"deviceIDValid", "deviceSerialValid",                          \
+			"cxlComponentEventLogValid"                            \
+	}
 
 ///
 /// CXL Generic Component Error Section
 ///
 typedef struct {
-  UINT64 VendorId : 16;
-  UINT64 DeviceId : 16;
-  UINT64 FunctionNumber : 8;
-  UINT64 DeviceNumber : 8;
-  UINT64 BusNumber : 8;
-  UINT64 SegmentNumber : 16;
-  UINT64 Resv1 : 3;
-  UINT64 SlotNumber : 13;
-  UINT64 Resv2 : 8;
+	UINT64 VendorId : 16;
+	UINT64 DeviceId : 16;
+	UINT64 FunctionNumber : 8;
+	UINT64 DeviceNumber : 8;
+	UINT64 BusNumber : 8;
+	UINT64 SegmentNumber : 16;
+	UINT64 Resv1 : 3;
+	UINT64 SlotNumber : 13;
+	UINT64 Resv2 : 8;
 } __attribute__((packed, aligned(1))) EFI_CXL_DEVICE_ID_INFO;
 
 typedef struct {
-    UINT32 Length;
-    UINT64 ValidBits;
-    EFI_CXL_DEVICE_ID_INFO DeviceId;
-    UINT64 DeviceSerial;
+	UINT32 Length;
+	UINT64 ValidBits;
+	EFI_CXL_DEVICE_ID_INFO DeviceId;
+	UINT64 DeviceSerial;
 } __attribute__((packed, aligned(1))) EFI_CXL_COMPONENT_EVENT_HEADER;
 
-json_object* cper_section_cxl_component_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_cxl_component_to_cper(json_object* section, FILE* out);
+json_object *cper_section_cxl_component_to_ir(void *section);
+void ir_section_cxl_component_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-cxl-protocol.c b/sections/cper-section-cxl-protocol.c
index 7cb1bbe..277731a 100644
--- a/sections/cper-section-cxl-protocol.c
+++ b/sections/cper-section-cxl-protocol.c
@@ -6,16 +6,13 @@
  **/
 #include <stdio.h>
 #include <string.h>
-#include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "../edk/Cper.h"
 #include "../cper-utils.h"
 #include "cper-section-cxl-protocol.h"
 
 //Converts a single CXL protocol error CPER section into JSON IR.
-json_object *
-cper_section_cxl_protocol_to_ir(void *section,
-				EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_cxl_protocol_to_ir(void *section)
 {
 	EFI_CXL_PROTOCOL_ERROR_DATA *cxl_protocol_error =
 		(EFI_CXL_PROTOCOL_ERROR_DATA *)section;
@@ -106,11 +103,20 @@
 		//The PCIe capability structure provided here could either be PCIe 1.1 Capability Structure
 		//(36-byte, padded to 60 bytes) or PCIe 2.0 Capability Structure (60-byte). There does not seem
 		//to be a way to differentiate these, so this is left as a b64 dump.
-		char *encoded = b64_encode(
-			cxl_protocol_error->CapabilityStructure.PcieCap, 60);
-		json_object_object_add(section_ir, "capabilityStructure",
-				       json_object_new_string(encoded));
-		free(encoded);
+		char *encoded = malloc(2 * 60);
+		size_t encoded_len = 0;
+		if (!encoded) {
+			printf("Failed to allocate encode output buffer. \n");
+		} else {
+			base64_encode((const char *)cxl_protocol_error
+					      ->CapabilityStructure.PcieCap,
+				      60, encoded, &encoded_len, 0);
+			json_object_object_add(section_ir,
+					       "capabilityStructure",
+					       json_object_new_string_len(
+						       encoded, encoded_len));
+			free(encoded);
+		}
 	}
 
 	//CXL DVSEC & error log length.
@@ -124,20 +130,36 @@
 	//CXL DVSEC
 	//For CXL 1.1 devices, this is the "CXL DVSEC For Flex Bus Device" structure as in CXL 1.1 spec.
 	//For CXL 1.1 host downstream ports, this is the "CXL DVSEC For Flex Bus Port" structure as in CXL 1.1 spec.
-	unsigned char *cur_pos = (unsigned char *)(cxl_protocol_error + 1);
-	char *encoded = b64_encode(cur_pos, cxl_protocol_error->CxlDvsecLength);
-	json_object_object_add(section_ir, "cxlDVSEC",
-			       json_object_new_string(encoded));
-	free(encoded);
+	const char *cur_pos = (const char *)(cxl_protocol_error + 1);
+	char *encoded = malloc(2 * cxl_protocol_error->CxlDvsecLength);
+	size_t encoded_len = 0;
+	if (!encoded) {
+		printf("Failed to allocate encode output buffer. \n");
+	} else {
+		base64_encode(cur_pos, cxl_protocol_error->CxlDvsecLength,
+			      encoded, &encoded_len, 0);
+		json_object_object_add(section_ir, "cxlDVSEC",
+				       json_object_new_string_len(encoded,
+								  encoded_len));
+
+		free(encoded);
+	}
 	cur_pos += cxl_protocol_error->CxlDvsecLength;
 
 	//CXL Error Log
 	//This is the "CXL RAS Capability Structure" as in CXL 1.1 spec.
-	encoded = b64_encode(cur_pos, cxl_protocol_error->CxlErrorLogLength);
-	json_object_object_add(section_ir, "cxlErrorLog",
-			       json_object_new_string(encoded));
-	free(encoded);
-
+	encoded = malloc(2 * cxl_protocol_error->CxlErrorLogLength);
+	encoded_len = 0;
+	if (!encoded) {
+		printf("Failed to allocate encode output buffer. \n");
+	} else {
+		base64_encode(cur_pos, cxl_protocol_error->CxlErrorLogLength,
+			      encoded, &encoded_len, 0);
+		json_object_object_add(section_ir, "cxlErrorLog",
+				       json_object_new_string_len(encoded,
+								  encoded_len));
+		free(encoded);
+	}
 	return section_ir;
 }
 
@@ -207,10 +229,18 @@
 
 		json_object *encoded =
 			json_object_object_get(section, "capabilityStructure");
-		char *decoded = b64_decode(json_object_get_string(encoded),
-					   json_object_get_string_len(encoded));
-		memcpy(section_cper->CapabilityStructure.PcieCap, decoded, 60);
-		free(decoded);
+		char *decoded = malloc(json_object_get_string_len(encoded));
+		size_t decoded_len = 0;
+		if (!decoded) {
+			printf("Failed to allocate decode output buffer. \n");
+		} else {
+			base64_decode(json_object_get_string(encoded),
+				      json_object_get_string_len(encoded),
+				      decoded, &decoded_len, 0);
+			memcpy(section_cper->CapabilityStructure.PcieCap,
+			       decoded, decoded_len);
+			free(decoded);
+		}
 	}
 
 	//DVSEC length & error log length.
@@ -225,19 +255,33 @@
 
 	//DVSEC out to stream.
 	json_object *encoded = json_object_object_get(section, "cxlDVSEC");
-	char *decoded = b64_decode(json_object_get_string(encoded),
-				   json_object_get_string_len(encoded));
-	fwrite(decoded, section_cper->CxlDvsecLength, 1, out);
-	fflush(out);
-	free(decoded);
+	char *decoded = malloc(json_object_get_string_len(encoded));
+	size_t decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		fwrite(decoded, decoded_len, 1, out);
+		fflush(out);
+		free(decoded);
+	}
 
 	//Error log out to stream.
 	encoded = json_object_object_get(section, "cxlErrorLog");
-	decoded = b64_decode(json_object_get_string(encoded),
-			     json_object_get_string_len(encoded));
-	fwrite(decoded, section_cper->CxlErrorLogLength, 1, out);
-	fflush(out);
-	free(decoded);
+	decoded = malloc(json_object_get_string_len(encoded));
+	decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		fwrite(decoded, decoded_len, 1, out);
+		fflush(out);
+		free(decoded);
+	}
 
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-cxl-protocol.h b/sections/cper-section-cxl-protocol.h
index c7c2c1c..9339f57 100644
--- a/sections/cper-section-cxl-protocol.h
+++ b/sections/cper-section-cxl-protocol.h
@@ -4,53 +4,67 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define CXL_PROTOCOL_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"cxlAgentTypeValid", "cxlAgentAddressValid", \
-    "deviceIDValid", "deviceSerialValid", "capabilityStructureValid", "cxlDVSECValid", "cxlErrorLogValid"}
-#define CXL_PROTOCOL_ERROR_AGENT_TYPES_KEYS (int []){0, 1}
-#define CXL_PROTOCOL_ERROR_AGENT_TYPES_VALUES (const char*[]){"CXL 1.1 Device", "CXL 1.1 Host Downstream Port"}
-#define CXL_PROTOCOL_ERROR_DEVICE_AGENT 0
+#define CXL_PROTOCOL_ERROR_VALID_BITFIELD_NAMES                                \
+	(const char *[])                                                       \
+	{                                                                      \
+		"cxlAgentTypeValid", "cxlAgentAddressValid", "deviceIDValid",  \
+			"deviceSerialValid", "capabilityStructureValid",       \
+			"cxlDVSECValid", "cxlErrorLogValid"                    \
+	}
+#define CXL_PROTOCOL_ERROR_AGENT_TYPES_KEYS                                    \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1                                                           \
+	}
+#define CXL_PROTOCOL_ERROR_AGENT_TYPES_VALUES                                  \
+	(const char *[])                                                       \
+	{                                                                      \
+		"CXL 1.1 Device", "CXL 1.1 Host Downstream Port"               \
+	}
+#define CXL_PROTOCOL_ERROR_DEVICE_AGENT		      0
 #define CXL_PROTOCOL_ERROR_HOST_DOWNSTREAM_PORT_AGENT 1
 
 ///
 /// CXL Protocol Error Section
 ///
 typedef struct {
-    UINT64 VendorId : 16;
-    UINT64 DeviceId : 16;
-    UINT64 SubsystemVendorId : 16;
-    UINT64 SubsystemDeviceId : 16;
-    UINT64 ClassCode : 16;
-    UINT64 Reserved1 : 3;
-    UINT64 SlotNumber : 13;
-    UINT64 Reserved2 : 32;
+	UINT64 VendorId : 16;
+	UINT64 DeviceId : 16;
+	UINT64 SubsystemVendorId : 16;
+	UINT64 SubsystemDeviceId : 16;
+	UINT64 ClassCode : 16;
+	UINT64 Reserved1 : 3;
+	UINT64 SlotNumber : 13;
+	UINT64 Reserved2 : 32;
 } EFI_CXL_DEVICE_ID;
 
 typedef struct {
-    UINT64 FunctionNumber : 8;
-    UINT64 DeviceNumber : 8;
-    UINT64 BusNumber : 8;
-    UINT64 SegmentNumber : 16;
-    UINT64 Reserved : 24;
+	UINT64 FunctionNumber : 8;
+	UINT64 DeviceNumber : 8;
+	UINT64 BusNumber : 8;
+	UINT64 SegmentNumber : 16;
+	UINT64 Reserved : 24;
 } EFI_CXL_DEVICE_AGENT_ADDRESS;
 
 typedef union {
-    EFI_CXL_DEVICE_AGENT_ADDRESS DeviceAddress; //Active when the agent is a CXL1.1 device in CxlAgentType.
-    UINT64 PortRcrbBaseAddress; //Active when the agent is a CXL1.1 host downstream port in CxlAgentType.
+	EFI_CXL_DEVICE_AGENT_ADDRESS
+	DeviceAddress; //Active when the agent is a CXL1.1 device in CxlAgentType.
+	UINT64 PortRcrbBaseAddress; //Active when the agent is a CXL1.1 host downstream port in CxlAgentType.
 } EFI_CXL_AGENT_ADDRESS;
 
 typedef struct {
-    UINT64 ValidBits;
-    UINT64 CxlAgentType;
-    EFI_CXL_AGENT_ADDRESS CxlAgentAddress;
-    EFI_CXL_DEVICE_ID DeviceId;
-    UINT64 DeviceSerial;
-    EFI_PCIE_ERROR_DATA_CAPABILITY CapabilityStructure;
-    UINT16 CxlDvsecLength;
-    UINT16 CxlErrorLogLength;
-    UINT32 Reserved;
+	UINT64 ValidBits;
+	UINT64 CxlAgentType;
+	EFI_CXL_AGENT_ADDRESS CxlAgentAddress;
+	EFI_CXL_DEVICE_ID DeviceId;
+	UINT64 DeviceSerial;
+	EFI_PCIE_ERROR_DATA_CAPABILITY CapabilityStructure;
+	UINT16 CxlDvsecLength;
+	UINT16 CxlErrorLogLength;
+	UINT32 Reserved;
 } __attribute__((packed, aligned(1))) EFI_CXL_PROTOCOL_ERROR_DATA;
 
-json_object* cper_section_cxl_protocol_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_cxl_protocol_to_cper(json_object* section, FILE* out);
+json_object *cper_section_cxl_protocol_to_ir(void *section);
+void ir_section_cxl_protocol_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-dmar-generic.c b/sections/cper-section-dmar-generic.c
index 6136232..affe16a 100644
--- a/sections/cper-section-dmar-generic.c
+++ b/sections/cper-section-dmar-generic.c
@@ -11,9 +11,7 @@
 #include "cper-section-dmar-generic.h"
 
 //Converts a single generic DMAr CPER section into JSON IR.
-json_object *
-cper_section_dmar_generic_to_ir(void *section,
-				EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_dmar_generic_to_ir(void *section)
 {
 	EFI_DMAR_GENERIC_ERROR_DATA *firmware_error =
 		(EFI_DMAR_GENERIC_ERROR_DATA *)section;
@@ -91,4 +89,4 @@
 	fwrite(section_cper, sizeof(EFI_DMAR_GENERIC_ERROR_DATA), 1, out);
 	fflush(out);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-dmar-generic.h b/sections/cper-section-dmar-generic.h
index e9757b0..035b25d 100644
--- a/sections/cper-section-dmar-generic.h
+++ b/sections/cper-section-dmar-generic.h
@@ -4,31 +4,68 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_KEYS (int []){0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB}
-#define DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_VALUES (const char*[]){"DMT Entry Missing", "DMT Entry Invalid", \
-    "DMT Access Error", "DMT Reserved Bit Invalid", "DMA Address Out of Bounds", "Invalid Read/Write", \
-    "Invalid Device Request", "ATT Access Error", "ATT Reserved Bit Invalid", "Illegal Command", "Command Buffer Access Error"}
-#define DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_DESCRIPTIONS (const char*[]){ \
-    "Domain mapping table entry is not present.", \
-    "Invalid domain mapping table entry.", \
-    "DMAr unit's attempt to access the domain mapping table resulted in an error.", \
-    "Reserved bit set to non-zero value in the domain mapping table.", \
-    "DMA request to access an address beyond the device address width.", \
-    "Invalid read or write access.", \
-    "Invalid device request.", \
-    "DMAr unit's attempt to access the address translation table resulted in an error.", \
-    "Reserved bit set to non-zero value in the address translation table.", \
-    "Illegal command error.", \
-    "DMAr unit's attempt to access the command buffer resulted in an error."}
-#define DMAR_GENERIC_ERROR_ACCESS_TYPES_KEYS (int []){0x0, 0x1}
-#define DMAR_GENERIC_ERROR_ACCESS_TYPES_VALUES (const char*[]){"DMA Write", "DMA Read"}
-#define DMAR_GENERIC_ERROR_ADDRESS_TYPES_KEYS (int []){0x0, 0x1}
-#define DMAR_GENERIC_ERROR_ADDRESS_TYPES_VALUES (const char*[]){"Untranslated Request", "Translation Request"}
-#define DMAR_GENERIC_ERROR_ARCH_TYPES_KEYS (int []){0x0, 0x1}
-#define DMAR_GENERIC_ERROR_ARCH_TYPES_VALUES (const char*[]){"VT-d", "IOMMU"}
+#define DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_KEYS                             \
+	(int[])                                                                \
+	{                                                                      \
+		0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB          \
+	}
+#define DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_VALUES                           \
+	(const char *[])                                                       \
+	{                                                                      \
+		"DMT Entry Missing", "DMT Entry Invalid", "DMT Access Error",  \
+			"DMT Reserved Bit Invalid",                            \
+			"DMA Address Out of Bounds", "Invalid Read/Write",     \
+			"Invalid Device Request", "ATT Access Error",          \
+			"ATT Reserved Bit Invalid", "Illegal Command",         \
+			"Command Buffer Access Error"                          \
+	}
+#define DMAR_GENERIC_ERROR_FAULT_REASON_TYPES_DESCRIPTIONS                                                   \
+	(const char *[])                                                                                     \
+	{                                                                                                    \
+		"Domain mapping table entry is not present.",                                                \
+			"Invalid domain mapping table entry.",                                               \
+			"DMAr unit's attempt to access the domain mapping table resulted in an error.",      \
+			"Reserved bit set to non-zero value in the domain mapping table.",                   \
+			"DMA request to access an address beyond the device address width.",                 \
+			"Invalid read or write access.",                                                     \
+			"Invalid device request.",                                                           \
+			"DMAr unit's attempt to access the address translation table resulted in an error.", \
+			"Reserved bit set to non-zero value in the address translation table.",              \
+			"Illegal command error.",                                                            \
+			"DMAr unit's attempt to access the command buffer resulted in an error."             \
+	}
+#define DMAR_GENERIC_ERROR_ACCESS_TYPES_KEYS                                   \
+	(int[])                                                                \
+	{                                                                      \
+		0x0, 0x1                                                       \
+	}
+#define DMAR_GENERIC_ERROR_ACCESS_TYPES_VALUES                                 \
+	(const char *[])                                                       \
+	{                                                                      \
+		"DMA Write", "DMA Read"                                        \
+	}
+#define DMAR_GENERIC_ERROR_ADDRESS_TYPES_KEYS                                  \
+	(int[])                                                                \
+	{                                                                      \
+		0x0, 0x1                                                       \
+	}
+#define DMAR_GENERIC_ERROR_ADDRESS_TYPES_VALUES                                \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Untranslated Request", "Translation Request"                  \
+	}
+#define DMAR_GENERIC_ERROR_ARCH_TYPES_KEYS                                     \
+	(int[])                                                                \
+	{                                                                      \
+		0x0, 0x1                                                       \
+	}
+#define DMAR_GENERIC_ERROR_ARCH_TYPES_VALUES                                   \
+	(const char *[])                                                       \
+	{                                                                      \
+		"VT-d", "IOMMU"                                                \
+	}
 
-json_object* cper_section_dmar_generic_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_dmar_generic_to_cper(json_object* section, FILE* out);
+json_object *cper_section_dmar_generic_to_ir(void *section);
+void ir_section_dmar_generic_to_cper(json_object *section, FILE *out);
 
-
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-dmar-iommu.c b/sections/cper-section-dmar-iommu.c
index f33c4ec..1d077a9 100644
--- a/sections/cper-section-dmar-iommu.c
+++ b/sections/cper-section-dmar-iommu.c
@@ -7,15 +7,13 @@
 #include <stdio.h>
 #include <string.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "../edk/Cper.h"
 #include "../cper-utils.h"
 #include "cper-section-dmar-iommu.h"
 
 //Converts a single IOMMU specific DMAr CPER section into JSON IR.
-json_object *
-cper_section_dmar_iommu_to_ir(void *section,
-			      EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_dmar_iommu_to_ir(void *section)
 {
 	EFI_IOMMU_DMAR_ERROR_DATA *iommu_error =
 		(EFI_IOMMU_DMAR_ERROR_DATA *)section;
@@ -33,18 +31,32 @@
 
 	//IOMMU event log entry.
 	//The format of these entries differ widely by the type of error.
-	char *encoded =
-		b64_encode((unsigned char *)iommu_error->EventLogEntry, 16);
-	json_object_object_add(section_ir, "eventLogEntry",
-			       json_object_new_string(encoded));
-	free(encoded);
+	char *encoded = malloc(2 * 16);
+	size_t encoded_len = 0;
+	if (!encoded) {
+		printf("Failed to allocate encode output buffer. \n");
+	} else {
+		base64_encode((const char *)iommu_error->EventLogEntry, 16,
+			      encoded, &encoded_len, 0);
+		json_object_object_add(section_ir, "eventLogEntry",
+				       json_object_new_string_len(encoded,
+								  encoded_len));
+		free(encoded);
+	}
 
 	//Device table entry (as base64).
-	encoded =
-		b64_encode((unsigned char *)iommu_error->DeviceTableEntry, 32);
-	json_object_object_add(section_ir, "deviceTableEntry",
-			       json_object_new_string(encoded));
-	free(encoded);
+	encoded = malloc(2 * 32);
+	encoded_len = 0;
+	if (!encoded) {
+		printf("Failed to allocate encode output buffer. \n");
+	} else {
+		base64_encode((const char *)iommu_error->DeviceTableEntry, 32,
+			      encoded, &encoded_len, 0);
+		json_object_object_add(section_ir, "deviceTableEntry",
+				       json_object_new_string_len(encoded,
+								  encoded_len));
+		free(encoded);
+	}
 
 	//Page table entries.
 	json_object_object_add(section_ir, "pageTableEntry_Level6",
@@ -80,17 +92,31 @@
 
 	//IOMMU event log entry.
 	json_object *encoded = json_object_object_get(section, "eventLogEntry");
-	UINT8 *decoded = b64_decode(json_object_get_string(encoded),
-				    json_object_get_string_len(encoded));
-	memcpy(section_cper->EventLogEntry, decoded, 16);
-	free(decoded);
+	char *decoded = malloc(json_object_get_string_len(encoded));
+	size_t decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		memcpy(section_cper->EventLogEntry, decoded, decoded_len);
+		free(decoded);
+	}
 
 	//Device table entry.
 	encoded = json_object_object_get(section, "deviceTableEntry");
-	decoded = b64_decode(json_object_get_string(encoded),
-			     json_object_get_string_len(encoded));
-	memcpy(section_cper->DeviceTableEntry, decoded, 32);
-	free(decoded);
+	decoded = malloc(json_object_get_string_len(encoded));
+	decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		memcpy(section_cper->DeviceTableEntry, decoded, decoded_len);
+		free(decoded);
+	}
 
 	//Page table entries.
 	section_cper->PteL1 = json_object_get_uint64(
@@ -110,4 +136,4 @@
 	fwrite(section_cper, sizeof(EFI_IOMMU_DMAR_ERROR_DATA), 1, out);
 	fflush(out);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-dmar-iommu.h b/sections/cper-section-dmar-iommu.h
index 0fec283..d15a9d1 100644
--- a/sections/cper-section-dmar-iommu.h
+++ b/sections/cper-section-dmar-iommu.h
@@ -4,7 +4,7 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-json_object* cper_section_dmar_iommu_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_dmar_iommu_to_cper(json_object* section, FILE* out);
+json_object *cper_section_dmar_iommu_to_ir(void *section);
+void ir_section_dmar_iommu_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-dmar-vtd.c b/sections/cper-section-dmar-vtd.c
index 5d938f4..e51b335 100644
--- a/sections/cper-section-dmar-vtd.c
+++ b/sections/cper-section-dmar-vtd.c
@@ -7,15 +7,13 @@
 #include <stdio.h>
 #include <string.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "../edk/Cper.h"
 #include "../cper-utils.h"
 #include "cper-section-dmar-vtd.h"
 
 //Converts a single VT-d specific DMAr CPER section into JSON IR.
-json_object *
-cper_section_dmar_vtd_to_ir(void *section,
-			    EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_dmar_vtd_to_ir(void *section)
 {
 	EFI_DIRECTED_IO_DMAR_ERROR_DATA *vtd_error =
 		(EFI_DIRECTED_IO_DMAR_ERROR_DATA *)section;
@@ -23,8 +21,9 @@
 
 	//Version, revision and OEM ID, as defined in the VT-d architecture.
 	UINT64 oem_id = 0;
-	for (int i = 0; i < 6; i++)
+	for (int i = 0; i < 6; i++) {
 		oem_id |= (UINT64)vtd_error->OemId[i] << (i * 8);
+	}
 	json_object_object_add(section_ir, "version",
 			       json_object_new_int(vtd_error->Version));
 	json_object_object_add(section_ir, "revision",
@@ -83,16 +82,32 @@
 	json_object_object_add(section_ir, "faultRecord", fault_record_ir);
 
 	//Root entry.
-	char *encoded = b64_encode((unsigned char *)vtd_error->RootEntry, 16);
-	json_object_object_add(section_ir, "rootEntry",
-			       json_object_new_string(encoded));
-	free(encoded);
+	char *encoded = malloc(2 * 16);
+	size_t encoded_len = 0;
+	if (!encoded) {
+		printf("Failed to allocate encode output buffer. \n");
+	} else {
+		base64_encode((const char *)vtd_error->RootEntry, 16, encoded,
+			      &encoded_len, 0);
+		json_object_object_add(section_ir, "rootEntry",
+				       json_object_new_string_len(encoded,
+								  encoded_len));
+		free(encoded);
+	}
 
 	//Context entry.
-	encoded = b64_encode((unsigned char *)vtd_error->ContextEntry, 16);
-	json_object_object_add(section_ir, "contextEntry",
-			       json_object_new_string(encoded));
-	free(encoded);
+	encoded = malloc(2 * 16);
+	encoded_len = 0;
+	if (!encoded) {
+		printf("Failed to allocate encode output buffer. \n");
+	} else {
+		base64_encode((const char *)vtd_error->ContextEntry, 16,
+			      encoded, &encoded_len, 0);
+		json_object_object_add(section_ir, "contextEntry",
+				       json_object_new_string_len(encoded,
+								  encoded_len));
+		free(encoded);
+	}
 
 	//PTE entry for all page levels.
 	json_object_object_add(section_ir, "pageTableEntry_Level6",
@@ -121,8 +136,9 @@
 	//OEM ID.
 	UINT64 oem_id = json_object_get_uint64(
 		json_object_object_get(section, "oemID"));
-	for (int i = 0; i < 6; i++)
+	for (int i = 0; i < 6; i++) {
 		section_cper->OemId[i] = (oem_id >> (i * 8)) & 0xFF;
+	}
 
 	//Registers & basic numeric fields.
 	section_cper->Version = (UINT8)json_object_get_int(
@@ -167,17 +183,30 @@
 
 	//Root entry.
 	json_object *encoded = json_object_object_get(section, "rootEntry");
-	UINT8 *decoded = b64_decode(json_object_get_string(encoded),
-				    json_object_get_string_len(encoded));
-	memcpy(section_cper->RootEntry, decoded, 16);
-	free(decoded);
-
+	char *decoded = malloc(json_object_get_string_len(encoded));
+	size_t decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		memcpy(section_cper->RootEntry, decoded, decoded_len);
+		free(decoded);
+	}
 	//Context entry.
 	encoded = json_object_object_get(section, "contextEntry");
-	decoded = b64_decode(json_object_get_string(encoded),
-			     json_object_get_string_len(encoded));
-	memcpy(section_cper->ContextEntry, decoded, 16);
-	free(decoded);
+	decoded = malloc(json_object_get_string_len(encoded));
+	decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		memcpy(section_cper->ContextEntry, decoded, decoded_len);
+		free(decoded);
+	}
 
 	//Page table entries.
 	section_cper->PteL1 = json_object_get_uint64(
@@ -197,4 +226,4 @@
 	fwrite(section_cper, sizeof(EFI_DIRECTED_IO_DMAR_ERROR_DATA), 1, out);
 	fflush(out);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-dmar-vtd.h b/sections/cper-section-dmar-vtd.h
index 4f84657..f78b2d1 100644
--- a/sections/cper-section-dmar-vtd.h
+++ b/sections/cper-section-dmar-vtd.h
@@ -4,25 +4,33 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define VTD_FAULT_RECORD_TYPES_KEYS (int []){0, 1}
-#define VTD_FAULT_RECORD_TYPES_VALUES (const char*[]){"Write Request", "Read/AtomicOp Request"}
+#define VTD_FAULT_RECORD_TYPES_KEYS                                            \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1                                                           \
+	}
+#define VTD_FAULT_RECORD_TYPES_VALUES                                          \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Write Request", "Read/AtomicOp Request"                       \
+	}
 
 typedef struct {
-    UINT64 Resv1 : 12;
-    UINT64 FaultInformation : 52;
-    UINT64 SourceIdentifier : 16;
-    UINT64 Resv2 : 13;
-    UINT64 PrivelegeModeRequested : 1;
-    UINT64 ExecutePermissionRequested : 1;
-    UINT64 PasidPresent : 1;
-    UINT64 FaultReason : 8;
-    UINT64 PasidValue : 20;
-    UINT64 AddressType : 2;
-    UINT64 Type : 1;
-    UINT64 Resv3 : 1;
+	UINT64 Resv1 : 12;
+	UINT64 FaultInformation : 52;
+	UINT64 SourceIdentifier : 16;
+	UINT64 Resv2 : 13;
+	UINT64 PrivelegeModeRequested : 1;
+	UINT64 ExecutePermissionRequested : 1;
+	UINT64 PasidPresent : 1;
+	UINT64 FaultReason : 8;
+	UINT64 PasidValue : 20;
+	UINT64 AddressType : 2;
+	UINT64 Type : 1;
+	UINT64 Resv3 : 1;
 } EFI_VTD_FAULT_RECORD;
 
-json_object* cper_section_dmar_vtd_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_dmar_vtd_to_cper(json_object* section, FILE* out);
+json_object *cper_section_dmar_vtd_to_ir(void *section);
+void ir_section_dmar_vtd_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-firmware.c b/sections/cper-section-firmware.c
index e45015a..c82a28b 100644
--- a/sections/cper-section-firmware.c
+++ b/sections/cper-section-firmware.c
@@ -11,9 +11,7 @@
 #include "cper-section-firmware.h"
 
 //Converts a single firmware CPER section into JSON IR.
-json_object *
-cper_section_firmware_to_ir(void *section,
-			    EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_firmware_to_ir(void *section)
 {
 	EFI_FIRMWARE_ERROR_DATA *firmware_error =
 		(EFI_FIRMWARE_ERROR_DATA *)section;
@@ -63,4 +61,4 @@
 	fwrite(section_cper, sizeof(EFI_FIRMWARE_ERROR_DATA), 1, out);
 	fflush(out);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-firmware.h b/sections/cper-section-firmware.h
index 4e0f528..eab0e99 100644
--- a/sections/cper-section-firmware.h
+++ b/sections/cper-section-firmware.h
@@ -4,11 +4,20 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define FIRMWARE_ERROR_RECORD_TYPES_KEYS (int []){0, 1, 2}
-#define FIRMWARE_ERROR_RECORD_TYPES_VALUES (const char*[]){"IPF SAL Error Record", \
-    "SOC Firmware Error Record (Type1 Legacy)", "SOC Firmware Error Record (Type2)"}
+#define FIRMWARE_ERROR_RECORD_TYPES_KEYS                                       \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2                                                        \
+	}
+#define FIRMWARE_ERROR_RECORD_TYPES_VALUES                                     \
+	(const char *[])                                                       \
+	{                                                                      \
+		"IPF SAL Error Record",                                        \
+			"SOC Firmware Error Record (Type1 Legacy)",            \
+			"SOC Firmware Error Record (Type2)"                    \
+	}
 
-json_object* cper_section_firmware_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_firmware_to_cper(json_object* section, FILE* out);
+json_object *cper_section_firmware_to_ir(void *section);
+void ir_section_firmware_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-generic.c b/sections/cper-section-generic.c
index 6a0de01..f9b1fdf 100644
--- a/sections/cper-section-generic.c
+++ b/sections/cper-section-generic.c
@@ -13,9 +13,7 @@
 #include "cper-section-generic.h"
 
 //Converts the given processor-generic CPER section into JSON IR.
-json_object *
-cper_section_generic_to_ir(void *section,
-			   EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_generic_to_ir(void *section)
 {
 	EFI_PROCESSOR_GENERIC_ERROR_DATA *section_generic =
 		(EFI_PROCESSOR_GENERIC_ERROR_DATA *)section;
@@ -144,11 +142,12 @@
 	//CPU brand string.
 	const char *brand_string = json_object_get_string(
 		json_object_object_get(section, "cpuBrandString"));
-	if (brand_string != NULL)
+	if (brand_string != NULL) {
 		strncpy(section_cper->BrandString, brand_string, 127);
+	}
 
 	//Write & flush out to file, free memory.
 	fwrite(section_cper, sizeof(EFI_PROCESSOR_GENERIC_ERROR_DATA), 1, out);
 	fflush(out);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-generic.h b/sections/cper-section-generic.h
index 95ba66e..765794e 100644
--- a/sections/cper-section-generic.h
+++ b/sections/cper-section-generic.h
@@ -4,22 +4,65 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define GENERIC_PROC_TYPES_KEYS (int []){0, 1, 2}
-#define GENERIC_PROC_TYPES_VALUES (const char*[]){"IA32/X64", "IA64", "ARM"}
-#define GENERIC_ISA_TYPES_KEYS (int []){0, 1, 2, 3, 4}
-#define GENERIC_ISA_TYPES_VALUES (const char*[]){"IA32", "IA64", "X64", "ARM A32/T32", "ARM A64"}
-#define GENERIC_ERROR_TYPES_KEYS (int []){0, 1, 2, 4, 8}
-#define GENERIC_ERROR_TYPES_VALUES (const char*[]){"Unknown", "Cache Error", "TLB Error", "Bus Error", "Micro-Architectural Error"}
-#define GENERIC_OPERATION_TYPES_KEYS (int []){0, 1, 2, 3}
-#define GENERIC_OPERATION_TYPES_VALUES (const char*[]){"Unknown or Generic", "Data Read", "Data Write", "Instruction Execution"}
-#define GENERIC_VALIDATION_BITFIELD_NAMES (const char*[]) \
-    {"processorTypeValid", "processorISAValid", "processorErrorTypeValid", "operationValid", "flagsValid", \
-    "levelValid", "cpuVersionValid", "cpuBrandInfoValid", "cpuIDValid", "targetAddressValid", "requestorIDValid", \
-    "responderIDValid", "instructionIPValid"}
-#define GENERIC_FLAGS_BITFIELD_NAMES (const char*[]) \
-    {"restartable", "preciseIP", "overflow", "corrected"}
+#define GENERIC_PROC_TYPES_KEYS                                                \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2                                                        \
+	}
+#define GENERIC_PROC_TYPES_VALUES                                              \
+	(const char *[])                                                       \
+	{                                                                      \
+		"IA32/X64", "IA64", "ARM"                                      \
+	}
+#define GENERIC_ISA_TYPES_KEYS                                                 \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4                                                  \
+	}
+#define GENERIC_ISA_TYPES_VALUES                                               \
+	(const char *[])                                                       \
+	{                                                                      \
+		"IA32", "IA64", "X64", "ARM A32/T32", "ARM A64"                \
+	}
+#define GENERIC_ERROR_TYPES_KEYS                                               \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 4, 8                                                  \
+	}
+#define GENERIC_ERROR_TYPES_VALUES                                             \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Unknown", "Cache Error", "TLB Error", "Bus Error",            \
+			"Micro-Architectural Error"                            \
+	}
+#define GENERIC_OPERATION_TYPES_KEYS                                           \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3                                                     \
+	}
+#define GENERIC_OPERATION_TYPES_VALUES                                         \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Unknown or Generic", "Data Read", "Data Write",               \
+			"Instruction Execution"                                \
+	}
+#define GENERIC_VALIDATION_BITFIELD_NAMES                                      \
+	(const char *[])                                                       \
+	{                                                                      \
+		"processorTypeValid", "processorISAValid",                     \
+			"processorErrorTypeValid", "operationValid",           \
+			"flagsValid", "levelValid", "cpuVersionValid",         \
+			"cpuBrandInfoValid", "cpuIDValid",                     \
+			"targetAddressValid", "requestorIDValid",              \
+			"responderIDValid", "instructionIPValid"               \
+	}
+#define GENERIC_FLAGS_BITFIELD_NAMES                                           \
+	(const char *[])                                                       \
+	{                                                                      \
+		"restartable", "preciseIP", "overflow", "corrected"            \
+	}
 
-json_object* cper_section_generic_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_generic_to_cper(json_object* section, FILE* out);
+json_object *cper_section_generic_to_ir(void *section);
+void ir_section_generic_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-ia32x64.c b/sections/cper-section-ia32x64.c
index a7dcc18..7a94c3d 100644
--- a/sections/cper-section-ia32x64.c
+++ b/sections/cper-section-ia32x64.c
@@ -7,7 +7,7 @@
 
 #include <stdio.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "../edk/Cper.h"
 #include "../cper-utils.h"
 #include "cper-section-ia32x64.h"
@@ -43,9 +43,7 @@
 //////////////////
 
 //Converts the IA32/x64 error section described in the given descriptor into intermediate format.
-json_object *
-cper_section_ia32x64_to_ir(void *section,
-			   EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_ia32x64_to_ir(void *section)
 {
 	EFI_IA32_X64_PROCESSOR_ERROR_RECORD *record =
 		(EFI_IA32_X64_PROCESSOR_ERROR_RECORD *)section;
@@ -55,14 +53,14 @@
 	json_object *validationBits = json_object_new_object();
 	json_object_object_add(validationBits, "localAPICIDValid",
 			       json_object_new_boolean(record->ValidFields &
-						       0b1));
+						       0x1));
 	json_object_object_add(
 		validationBits, "cpuIDInfoValid",
-		json_object_new_boolean((record->ValidFields >> 1) & 0b1));
-	int processor_error_info_num = (record->ValidFields >> 2) & 0b111111;
+		json_object_new_boolean((record->ValidFields >> 1) & 0x1));
+	int processor_error_info_num = (record->ValidFields >> 2) & 0x3F;
 	json_object_object_add(validationBits, "processorErrorInfoNum",
 			       json_object_new_int(processor_error_info_num));
-	int processor_context_info_num = (record->ValidFields >> 8) & 0b111111;
+	int processor_context_info_num = (record->ValidFields >> 8) & 0x3F;
 	json_object_object_add(validationBits, "processorContextInfoNum",
 			       json_object_new_int(processor_context_info_num));
 	json_object_object_add(record_ir, "validationBits", validationBits);
@@ -133,18 +131,20 @@
 	//Get the error structure type as a readable string.
 	const char *readable_type = "Unknown";
 	if (guid_equal(&error_info->ErrorType,
-		       &gEfiIa32x64ErrorTypeCacheCheckGuid))
+		       &gEfiIa32x64ErrorTypeCacheCheckGuid)) {
 		readable_type = "Cache Check Error";
-	else if (guid_equal(&error_info->ErrorType,
-			    &gEfiIa32x64ErrorTypeTlbCheckGuid))
+	} else if (guid_equal(&error_info->ErrorType,
+			      &gEfiIa32x64ErrorTypeTlbCheckGuid)) {
 		readable_type = "TLB Check Error";
-	else if (guid_equal(&error_info->ErrorType,
-			    &gEfiIa32x64ErrorTypeBusCheckGuid))
+	} else if (guid_equal(&error_info->ErrorType,
+			      &gEfiIa32x64ErrorTypeBusCheckGuid)) {
 		readable_type = "Bus Check Error";
-	else if (guid_equal(&error_info->ErrorType,
-			    &gEfiIa32x64ErrorTypeMsCheckGuid))
+	} else if (guid_equal(&error_info->ErrorType,
+			      &gEfiIa32x64ErrorTypeMsCheckGuid)) {
 		readable_type = "MS Check Error";
-	json_object_object_add(type, "name", json_object_new_string(readable_type));
+	}
+	json_object_object_add(type, "name",
+			       json_object_new_string(readable_type));
 	json_object_object_add(error_info_ir, "type", type);
 
 	//Validation bits.
@@ -390,12 +390,21 @@
 		//No parseable data, just dump as base64 and shift the head to the next item.
 		*cur_pos = (void *)(context_info + 1);
 
-		char *encoded = b64_encode((unsigned char *)*cur_pos,
-					   context_info->ArraySize);
-		register_array = json_object_new_object();
-		json_object_object_add(register_array, "data",
-				       json_object_new_string(encoded));
-		free(encoded);
+		char *encoded = malloc(2 * context_info->ArraySize);
+		size_t encoded_len = 0;
+		if (!encoded) {
+			printf("Failed to allocate encode output buffer. \n");
+		} else {
+			base64_encode((const char *)*cur_pos,
+				      context_info->ArraySize, encoded,
+				      &encoded_len, 0);
+
+			register_array = json_object_new_object();
+			json_object_object_add(register_array, "data",
+					       json_object_new_string_len(
+						       encoded, encoded_len));
+			free(encoded);
+		}
 
 		*cur_pos =
 			(void *)(((char *)*cur_pos) + context_info->ArraySize);
@@ -574,11 +583,11 @@
 	int proc_error_info_num =
 		json_object_get_int(json_object_object_get(
 			validation, "processorErrorInfoNum")) &
-		0b111111;
+		0x3F;
 	int proc_ctx_info_num =
 		json_object_get_int(json_object_object_get(
 			validation, "processorContextInfoNum")) &
-		0b111111;
+		0x3F;
 	section_cper->ValidFields |= proc_error_info_num << 2;
 	section_cper->ValidFields |= proc_ctx_info_num << 8;
 
@@ -610,12 +619,14 @@
 		json_object_object_get(section, "processorErrorInfo");
 	json_object *context_info =
 		json_object_object_get(section, "processorContextInfo");
-	for (int i = 0; i < proc_error_info_num; i++)
+	for (int i = 0; i < proc_error_info_num; i++) {
 		ir_ia32x64_error_info_to_cper(
 			json_object_array_get_idx(error_info, i), out);
-	for (int i = 0; i < proc_ctx_info_num; i++)
+	}
+	for (int i = 0; i < proc_ctx_info_num; i++) {
 		ir_ia32x64_context_info_to_cper(
 			json_object_array_get_idx(context_info, i), out);
+	}
 }
 
 //Converts a single CPER-JSON IA32/x64 error information structure into CPER binary, outputting to the
@@ -649,17 +660,18 @@
 			(EFI_IA32_X64_CACHE_CHECK_INFO *)&error_info_cper
 				->CheckInfo);
 	} else if (guid_equal(&error_info_cper->ErrorType,
-			      &gEfiIa32x64ErrorTypeBusCheckGuid))
+			      &gEfiIa32x64ErrorTypeBusCheckGuid)) {
 		ir_ia32x64_bus_check_error_to_cper(
 			check_info,
 			(EFI_IA32_X64_BUS_CHECK_INFO *)&error_info_cper
 				->CheckInfo);
-	else if (guid_equal(&error_info_cper->ErrorType,
-			    &gEfiIa32x64ErrorTypeMsCheckGuid))
+	} else if (guid_equal(&error_info_cper->ErrorType,
+			      &gEfiIa32x64ErrorTypeMsCheckGuid)) {
 		ir_ia32x64_ms_check_error_to_cper(
 			check_info,
 			(EFI_IA32_X64_MS_CHECK_INFO *)&error_info_cper
 				->CheckInfo);
+	}
 
 	//Miscellaneous numeric fields.
 	error_info_cper->TargetId = json_object_get_uint64(
@@ -807,10 +819,18 @@
 		//Unknown/structure is not defined.
 		json_object *encoded =
 			json_object_object_get(register_array, "data");
-		char *decoded = b64_decode(json_object_get_string(encoded),
-					   json_object_get_string_len(encoded));
-		fwrite(decoded, context_info_cper->ArraySize, 1, out);
-		fflush(out);
+		char *decoded = malloc(json_object_get_string_len(encoded));
+		size_t decoded_len = 0;
+		if (!decoded) {
+			printf("Failed to allocate decode output buffer. \n");
+		} else {
+			base64_decode(json_object_get_string(encoded),
+				      json_object_get_string_len(encoded),
+				      decoded, &decoded_len, 0);
+			fwrite(decoded, decoded_len, 1, out);
+			fflush(out);
+			free(decoded);
+		}
 	}
 
 	//Free remaining resources.
@@ -967,4 +987,4 @@
 	//Write out to stream.
 	fwrite(&register_state, sizeof(EFI_CONTEXT_X64_REGISTER_STATE), 1, out);
 	fflush(out);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-ia32x64.h b/sections/cper-section-ia32x64.h
index 875681e..59a3e60 100644
--- a/sections/cper-section-ia32x64.h
+++ b/sections/cper-section-ia32x64.h
@@ -4,44 +4,110 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define IA32X64_PROCESSOR_ERROR_VALID_BITFIELD_NAMES (const char*[]) \
-    {"checkInfoValid", "targetAddressIDValid", "requestorIDValid", "responderIDValid", \
-    "instructionPointerValid"}
-#define IA32X64_CHECK_INFO_VALID_BITFIELD_NAMES (const char*[]) \
-    {"transactionTypeValid", "operationValid", "levelValid", "processorContextCorruptValid", "uncorrectedValid", \
-    "preciseIPValid", "restartableIPValid", "overflowValid", "participationTypeValid", "timedOutValid", \
-    "addressSpaceValid"}
-#define IA32X64_CHECK_INFO_MS_CHECK_VALID_BITFIELD_NAMES (const char*[]) \
-    {"errorTypeValid", "processorContextCorruptValid", "uncorrectedValid", "preciseIPValid", "restartableIPValid", \
-    "overflowValid"}
-#define IA32X64_CHECK_INFO_TRANSACTION_TYPES_KEYS (int []){0, 1, 2}
-#define IA32X64_CHECK_INFO_TRANSACTION_TYPES_VALUES (const char*[]){"Instruction", "Data Access", "Generic"}
-#define IA32X64_CHECK_INFO_OPERATION_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8}
-#define IA32X64_CHECK_INFO_OPERATION_TYPES_VALUES (const char*[]){"Generic Error", "Generic Read", "Generic Write" \
-    "Data Read", "Data Write", "Instruction Fetch", "Prefetch", "Eviction", "Snoop"}
-#define IA32X64_BUS_CHECK_INFO_PARTICIPATION_TYPES_KEYS (int []){0, 1, 2, 3}
-#define IA32X64_BUS_CHECK_INFO_PARTICIPATION_TYPES_VALUES (const char*[]){"Local processor originated request", \
-    "Local processor responded to request", "Local processor observed", "Generic"}
-#define IA32X64_BUS_CHECK_INFO_ADDRESS_SPACE_TYPES_KEYS (int []){0, 1, 2, 3}
-#define IA32X64_BUS_CHECK_INFO_ADDRESS_SPACE_TYPES_VALUES (const char*[]){"Memory Access", "Reserved", "I/O", \
-    "Other Transaction"}
-#define IA32X64_MS_CHECK_INFO_ERROR_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5}
-#define IA32X64_MS_CHECK_INFO_ERROR_TYPES_VALUES (const char*[]){"No Error", "Unclassified", "Microcode ROM Parity Error", \
-    "External Error", "FRC Error", "Internal Unclassified"}
-#define IA32X64_REGISTER_CONTEXT_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7}
-#define IA32X64_REGISTER_CONTEXT_TYPES_VALUES (const char*[]){"Unclassified Data", "MSR Registers", \
-    "32-bit Mode Execution Context", "64-bit Mode Execution Context", "FXSave Context", \
-    "32-bit Mode Debug Registers", "64-bit Mode Debug Registers", "Memory Mapper Registers"}
+#define IA32X64_PROCESSOR_ERROR_VALID_BITFIELD_NAMES                           \
+	(const char *[])                                                       \
+	{                                                                      \
+		"checkInfoValid", "targetAddressIDValid", "requestorIDValid",  \
+			"responderIDValid", "instructionPointerValid"          \
+	}
+#define IA32X64_CHECK_INFO_VALID_BITFIELD_NAMES                                \
+	(const char *[])                                                       \
+	{                                                                      \
+		"transactionTypeValid", "operationValid", "levelValid",        \
+			"processorContextCorruptValid", "uncorrectedValid",    \
+			"preciseIPValid", "restartableIPValid",                \
+			"overflowValid", "participationTypeValid",             \
+			"timedOutValid", "addressSpaceValid"                   \
+	}
+#define IA32X64_CHECK_INFO_MS_CHECK_VALID_BITFIELD_NAMES                       \
+	(const char *[])                                                       \
+	{                                                                      \
+		"errorTypeValid", "processorContextCorruptValid",              \
+			"uncorrectedValid", "preciseIPValid",                  \
+			"restartableIPValid", "overflowValid"                  \
+	}
+#define IA32X64_CHECK_INFO_TRANSACTION_TYPES_KEYS                              \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2                                                        \
+	}
+#define IA32X64_CHECK_INFO_TRANSACTION_TYPES_VALUES                            \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Instruction", "Data Access", "Generic"                        \
+	}
+#define IA32X64_CHECK_INFO_OPERATION_TYPES_KEYS                                \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4, 5, 6, 7, 8                                      \
+	}
+#define IA32X64_CHECK_INFO_OPERATION_TYPES_VALUES                              \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Generic Error", "Generic Read",                               \
+			"Generic Write"                                        \
+			"Data Read",                                           \
+			"Data Write", "Instruction Fetch", "Prefetch",         \
+			"Eviction", "Snoop"                                    \
+	}
+#define IA32X64_BUS_CHECK_INFO_PARTICIPATION_TYPES_KEYS                        \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3                                                     \
+	}
+#define IA32X64_BUS_CHECK_INFO_PARTICIPATION_TYPES_VALUES                      \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Local processor originated request",                          \
+			"Local processor responded to request",                \
+			"Local processor observed", "Generic"                  \
+	}
+#define IA32X64_BUS_CHECK_INFO_ADDRESS_SPACE_TYPES_KEYS                        \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3                                                     \
+	}
+#define IA32X64_BUS_CHECK_INFO_ADDRESS_SPACE_TYPES_VALUES                      \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Memory Access", "Reserved", "I/O", "Other Transaction"        \
+	}
+#define IA32X64_MS_CHECK_INFO_ERROR_TYPES_KEYS                                 \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4, 5                                               \
+	}
+#define IA32X64_MS_CHECK_INFO_ERROR_TYPES_VALUES                               \
+	(const char *[])                                                       \
+	{                                                                      \
+		"No Error", "Unclassified", "Microcode ROM Parity Error",      \
+			"External Error", "FRC Error", "Internal Unclassified" \
+	}
+#define IA32X64_REGISTER_CONTEXT_TYPES_KEYS                                    \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4, 5, 6, 7                                         \
+	}
+#define IA32X64_REGISTER_CONTEXT_TYPES_VALUES                                  \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Unclassified Data", "MSR Registers",                          \
+			"32-bit Mode Execution Context",                       \
+			"64-bit Mode Execution Context", "FXSave Context",     \
+			"32-bit Mode Debug Registers",                         \
+			"64-bit Mode Debug Registers",                         \
+			"Memory Mapper Registers"                              \
+	}
 
 typedef struct {
-    UINT64 Eax;
-    UINT64 Ebx;
-    UINT64 Ecx;
-    UINT64 Edx;
-    UINT64 Reserved[2];
+	UINT64 Eax;
+	UINT64 Ebx;
+	UINT64 Ecx;
+	UINT64 Edx;
+	UINT64 Reserved[2];
 } EFI_IA32_X64_CPU_ID;
 
-json_object* cper_section_ia32x64_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_ia32x64_to_cper(json_object* section, FILE* out);
+json_object *cper_section_ia32x64_to_ir(void *section);
+void ir_section_ia32x64_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-ipf.c b/sections/cper-section-ipf.c
index bc62493..71720d6 100644
--- a/sections/cper-section-ipf.c
+++ b/sections/cper-section-ipf.c
@@ -15,8 +15,7 @@
 json_object *cper_ipf_mod_error_to_ir(EFI_IPF_MOD_ERROR_INFO *mod_error);
 
 //Converts a single Intel IPF error CPER section into JSON IR.
-json_object *cper_section_ipf_to_ir(void *section,
-				    EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_ipf_to_ir(void *section)
 {
 	EFI_IPF_ERROR_INFO_HEADER *ipf_error =
 		(EFI_IPF_ERROR_INFO_HEADER *)section;
@@ -165,4 +164,4 @@
 			       json_object_new_uint64(mod_error->ModPreciseIp));
 
 	return mod_error_ir;
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-ipf.h b/sections/cper-section-ipf.h
index e90a16e..cf346ef 100644
--- a/sections/cper-section-ipf.h
+++ b/sections/cper-section-ipf.h
@@ -4,60 +4,69 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define IPF_MOD_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"checkInfoValid", "requestorIdentifierValid", \
-    "responderIdentifierValid", "targetIdentifierValid", "preciseIPValid"}
-#define IPF_PSI_STATIC_INFO_VALID_BITFIELD_NAMES (const char*[]) {"minstateValid", "brValid", "crValid", \
-    "arValid", "rrValid", "frValid"}
+#define IPF_MOD_ERROR_VALID_BITFIELD_NAMES                                     \
+	(const char *[])                                                       \
+	{                                                                      \
+		"checkInfoValid", "requestorIdentifierValid",                  \
+			"responderIdentifierValid", "targetIdentifierValid",   \
+			"preciseIPValid"                                       \
+	}
+#define IPF_PSI_STATIC_INFO_VALID_BITFIELD_NAMES                               \
+	(const char *[])                                                       \
+	{                                                                      \
+		"minstateValid", "brValid", "crValid", "arValid", "rrValid",   \
+			"frValid"                                              \
+	}
 
 ///
 /// IPF Error Record Section
 /// Defined as according to B.2.3 of the ItaniumTM Processor Family System Abstraction Layer (SAL) Specification.
 ///
 typedef struct {
-    UINT64 ProcErrorMapValid : 1;
-    UINT64 ProcStateParameterValid : 1;
-    UINT64 ProcCrLidValid : 1;
-    UINT64 PsiStaticStructValid : 1;
-    UINT64 CacheCheckNum : 4;
-    UINT64 TlbCheckNum : 4;
-    UINT64 BusCheckNum : 4;
-    UINT64 RegFileCheckNum : 4;
-    UINT64 MsCheckNum : 4;
-    UINT64 CpuIdInfoValid : 1;
-    UINT64 Reserved : 39;
+	UINT64 ProcErrorMapValid : 1;
+	UINT64 ProcStateParameterValid : 1;
+	UINT64 ProcCrLidValid : 1;
+	UINT64 PsiStaticStructValid : 1;
+	UINT64 CacheCheckNum : 4;
+	UINT64 TlbCheckNum : 4;
+	UINT64 BusCheckNum : 4;
+	UINT64 RegFileCheckNum : 4;
+	UINT64 MsCheckNum : 4;
+	UINT64 CpuIdInfoValid : 1;
+	UINT64 Reserved : 39;
 } EPI_IPF_ERROR_VALID_BITS;
 
 typedef struct {
-    EPI_IPF_ERROR_VALID_BITS ValidBits;
-    UINT64 ProcErrorMap;
-    UINT64 ProcStateParameter;
-    UINT64 ProcCrLid;
+	EPI_IPF_ERROR_VALID_BITS ValidBits;
+	UINT64 ProcErrorMap;
+	UINT64 ProcStateParameter;
+	UINT64 ProcCrLid;
 } EFI_IPF_ERROR_INFO_HEADER;
 
 typedef struct {
-    UINT64 ValidBits;
-    UINT64 ModCheckInfo;
-    UINT64 ModTargetId;
-    UINT64 ModRequestorId; //NOTE: The Intel Itanium specification contains a typo which makes the order
-    UINT64 ModResponderId; // of these two fields undefined. This is a best guess and could be wrong.
-    UINT64 ModPreciseIp;
+	UINT64 ValidBits;
+	UINT64 ModCheckInfo;
+	UINT64 ModTargetId;
+	UINT64 ModRequestorId; //NOTE: The Intel Itanium specification contains a typo which makes the order
+	UINT64 ModResponderId; // of these two fields undefined. This is a best guess and could be wrong.
+	UINT64 ModPreciseIp;
 } EFI_IPF_MOD_ERROR_INFO;
 
 typedef struct {
-    UINT8 CpuIdInfo[40];
-    UINT8 Reserved1[8];
+	UINT8 CpuIdInfo[40];
+	UINT8 Reserved1[8];
 } EFI_IPF_CPU_INFO;
 
 typedef struct {
-    UINT64 ValidBits;
-    UINT8 MinimalSaveStateInfo[1024];
-    UINT64 Brs[8];
-    UINT64 Crs[128];
-    UINT64 Ars[128];
-    UINT64 Rrs[8];
-    UINT64 Frs[256];
+	UINT64 ValidBits;
+	UINT8 MinimalSaveStateInfo[1024];
+	UINT64 Brs[8];
+	UINT64 Crs[128];
+	UINT64 Ars[128];
+	UINT64 Rrs[8];
+	UINT64 Frs[256];
 } EFI_IPF_PSI_STATIC;
 
-json_object* cper_section_ipf_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
+json_object *cper_section_ipf_to_ir(void *section);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-memory.c b/sections/cper-section-memory.c
index 1ed2b9b..3c27a52 100644
--- a/sections/cper-section-memory.c
+++ b/sections/cper-section-memory.c
@@ -11,9 +11,7 @@
 #include "cper-section-memory.h"
 
 //Converts a single memory error CPER section into JSON IR.
-json_object *
-cper_section_platform_memory_to_ir(void *section,
-				   EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_platform_memory_to_ir(void *section)
 {
 	EFI_PLATFORM_MEMORY_ERROR_DATA *memory_error =
 		(EFI_PLATFORM_MEMORY_ERROR_DATA *)section;
@@ -59,10 +57,10 @@
 	json_object *extended = json_object_new_object();
 	json_object_object_add(extended, "rowBit16",
 			       json_object_new_boolean(memory_error->Extended &
-						       0b1));
+						       0x1));
 	json_object_object_add(
 		extended, "rowBit17",
-		json_object_new_boolean((memory_error->Extended >> 1) & 0b1));
+		json_object_new_boolean((memory_error->Extended >> 1) & 0x1));
 	json_object_object_add(extended, "chipIdentification",
 			       json_object_new_int(memory_error->Extended >>
 						   5));
@@ -112,9 +110,7 @@
 }
 
 //Converts a single memory error 2 CPER section into JSON IR.
-json_object *
-cper_section_platform_memory2_to_ir(void *section,
-				    EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_platform_memory2_to_ir(void *section)
 {
 	EFI_PLATFORM_MEMORY2_ERROR_DATA *memory_error =
 		(EFI_PLATFORM_MEMORY2_ERROR_DATA *)section;
@@ -160,11 +156,11 @@
 	json_object *status = json_object_new_object();
 	json_object_object_add(status, "value",
 			       json_object_new_int(memory_error->Status));
-	json_object_object_add(status, "state",
-			       json_object_new_string(memory_error->Status &
-								      0b1 == 0 ?
-								    "Corrected" :
-								    "Uncorrected"));
+	json_object_object_add(
+		status, "state",
+		json_object_new_string((memory_error->Status & 0x1) == 0 ?
+					       "Corrected" :
+					       "Uncorrected"));
 	json_object_object_add(section_ir, "status", status);
 
 	//Miscellaneous numeric fields.
@@ -370,4 +366,4 @@
 	fwrite(section_cper, sizeof(EFI_PLATFORM_MEMORY2_ERROR_DATA), 1, out);
 	fflush(out);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-memory.h b/sections/cper-section-memory.h
index 81be6ff..5134f6e 100644
--- a/sections/cper-section-memory.h
+++ b/sections/cper-section-memory.h
@@ -4,27 +4,54 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define MEMORY_ERROR_VALID_BITFIELD_NAMES (const char*[]) \
-    {"errorStatusValid", "physicalAddressValid", "physicalAddressMaskValid", "nodeValid", "cardValid", "moduleValid", \
-    "bankValid", "deviceValid", "rowValid", "columnValid", "bitPositionValid", "platformRequestorIDValid", \
-    "platformResponderIDValid", "memoryPlatformTargetValid", "memoryErrorTypeValid", "rankNumberValid", \
-    "cardHandleValid", "moduleHandleValid", "extendedRowBitsValid", "bankGroupValid", "bankAddressValid", \
-    "chipIdentificationValid"}
-#define MEMORY_ERROR_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
-#define MEMORY_ERROR_TYPES_VALUES (const char*[]){"Unknown", "No Error", "Single-bit ECC", \
-    "Multi-bit ECC", "Single-symbol ChipKill ECC", "Multi-symbol ChipKill ECC", "Master Abort", \
-    "Target Abort", "Parity Error", "Watchdog Timeout", "Invalid Address", "Mirror Broken", \
-    "Memory Sparing", "Scrub Corrected Error", "Scrub Uncorrected Error", "Physical Memory Map-out Event"}
-#define MEMORY_ERROR_2_VALID_BITFIELD_NAMES (const char*[]) \
-    {"errorStatusValid", "physicalAddressValid", "physicalAddressMaskValid", "nodeValid", "cardValid", "moduleValid", \
-    "bankValid", "deviceValid", "rowValid", "columnValid", "rankValid", "bitPositionValid", "chipIDValid", \
-    "memoryErrorTypeValid", "statusValid", "requestorIDValid", "responderIDValid", "targetIDValid", "cardHandleValid", \
-    "moduleHandleValid", "bankGroupValid", "bankAddressValid"}
+#define MEMORY_ERROR_VALID_BITFIELD_NAMES                                      \
+	(const char *[])                                                       \
+	{                                                                      \
+		"errorStatusValid", "physicalAddressValid",                    \
+			"physicalAddressMaskValid", "nodeValid", "cardValid",  \
+			"moduleValid", "bankValid", "deviceValid", "rowValid", \
+			"columnValid", "bitPositionValid",                     \
+			"platformRequestorIDValid",                            \
+			"platformResponderIDValid",                            \
+			"memoryPlatformTargetValid", "memoryErrorTypeValid",   \
+			"rankNumberValid", "cardHandleValid",                  \
+			"moduleHandleValid", "extendedRowBitsValid",           \
+			"bankGroupValid", "bankAddressValid",                  \
+			"chipIdentificationValid"                              \
+	}
+#define MEMORY_ERROR_TYPES_KEYS                                                \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15           \
+	}
+#define MEMORY_ERROR_TYPES_VALUES                                              \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Unknown", "No Error", "Single-bit ECC", "Multi-bit ECC",      \
+			"Single-symbol ChipKill ECC",                          \
+			"Multi-symbol ChipKill ECC", "Master Abort",           \
+			"Target Abort", "Parity Error", "Watchdog Timeout",    \
+			"Invalid Address", "Mirror Broken", "Memory Sparing",  \
+			"Scrub Corrected Error", "Scrub Uncorrected Error",    \
+			"Physical Memory Map-out Event"                        \
+	}
+#define MEMORY_ERROR_2_VALID_BITFIELD_NAMES                                    \
+	(const char *[])                                                       \
+	{                                                                      \
+		"errorStatusValid", "physicalAddressValid",                    \
+			"physicalAddressMaskValid", "nodeValid", "cardValid",  \
+			"moduleValid", "bankValid", "deviceValid", "rowValid", \
+			"columnValid", "rankValid", "bitPositionValid",        \
+			"chipIDValid", "memoryErrorTypeValid", "statusValid",  \
+			"requestorIDValid", "responderIDValid",                \
+			"targetIDValid", "cardHandleValid",                    \
+			"moduleHandleValid", "bankGroupValid",                 \
+			"bankAddressValid"                                     \
+	}
 
-json_object* cper_section_platform_memory_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-json_object* cper_section_platform_memory2_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_memory_to_cper(json_object* section, FILE* out);
-void ir_section_memory2_to_cper(json_object* section, FILE* out);
+json_object *cper_section_platform_memory_to_ir(void *section);
+json_object *cper_section_platform_memory2_to_ir(void *section);
+void ir_section_memory_to_cper(json_object *section, FILE *out);
+void ir_section_memory2_to_cper(json_object *section, FILE *out);
 
-
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-pci-bus.c b/sections/cper-section-pci-bus.c
index 33d0d03..2636cd2 100644
--- a/sections/cper-section-pci-bus.c
+++ b/sections/cper-section-pci-bus.c
@@ -12,9 +12,7 @@
 #include "cper-section-pci-bus.h"
 
 //Converts a single PCI/PCI-X bus CPER section into JSON IR.
-json_object *
-cper_section_pci_bus_to_ir(void *section,
-			   EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_pci_bus_to_ir(void *section)
 {
 	EFI_PCI_PCIX_BUS_ERROR_DATA *bus_error =
 		(EFI_PCI_PCIX_BUS_ERROR_DATA *)section;
@@ -46,7 +44,7 @@
 
 	//Miscellaneous numeric fields.
 	UINT8 command_type = (bus_error->BusCommand >> 56) &
-			     0b1; //Byte 7, bit 0.
+			     0x1; //Byte 7, bit 0.
 	json_object_object_add(section_ir, "busAddress",
 			       json_object_new_uint64(bus_error->BusAddress));
 	json_object_object_add(section_ir, "busData",
@@ -113,4 +111,4 @@
 	fwrite(section_cper, sizeof(EFI_PCI_PCIX_BUS_ERROR_DATA), 1, out);
 	fflush(out);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-pci-bus.h b/sections/cper-section-pci-bus.h
index cf4371a..6a959e4 100644
--- a/sections/cper-section-pci-bus.h
+++ b/sections/cper-section-pci-bus.h
@@ -4,15 +4,30 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define PCI_BUS_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"errorStatusValid", "errorTypeValid", \
-    "busIDValid", "busAddressValid", "busDataValid", "commandValid", "requestorIDValid", "completerIDValid", \
-    "targetIDValid"}
-#define PCI_BUS_ERROR_TYPES_KEYS (int []){0, 1, 2, 3, 4, 5, 6, 7}
-#define PCI_BUS_ERROR_TYPES_VALUES (const char*[]){"Unknown/OEM Specific Error", "Data Parity Error", \
-    "System Error", "Master Abort", "Bus Timeout/No Device Present (No DEVSEL#)", \
-    "Master Data Parity Error", "Address Parity Error", "Command Parity Error"}
+#define PCI_BUS_ERROR_VALID_BITFIELD_NAMES                                     \
+	(const char *[])                                                       \
+	{                                                                      \
+		"errorStatusValid", "errorTypeValid", "busIDValid",            \
+			"busAddressValid", "busDataValid", "commandValid",     \
+			"requestorIDValid", "completerIDValid",                \
+			"targetIDValid"                                        \
+	}
+#define PCI_BUS_ERROR_TYPES_KEYS                                               \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 2, 3, 4, 5, 6, 7                                         \
+	}
+#define PCI_BUS_ERROR_TYPES_VALUES                                             \
+	(const char *[])                                                       \
+	{                                                                      \
+		"Unknown/OEM Specific Error", "Data Parity Error",             \
+			"System Error", "Master Abort",                        \
+			"Bus Timeout/No Device Present (No DEVSEL#)",          \
+			"Master Data Parity Error", "Address Parity Error",    \
+			"Command Parity Error"                                 \
+	}
 
-json_object* cper_section_pci_bus_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_pci_bus_to_cper(json_object* section, FILE* out);
+json_object *cper_section_pci_bus_to_ir(void *section);
+void ir_section_pci_bus_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-pci-dev.c b/sections/cper-section-pci-dev.c
index 5f40183..f3bd983 100644
--- a/sections/cper-section-pci-dev.c
+++ b/sections/cper-section-pci-dev.c
@@ -11,9 +11,7 @@
 #include "cper-section-pci-dev.h"
 
 //Converts a single PCI/PCI-X device CPER section into JSON IR.
-json_object *
-cper_section_pci_dev_to_ir(void *section,
-			   EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_pci_dev_to_ir(void *section)
 {
 	EFI_PCI_PCIX_DEVICE_ERROR_DATA *dev_error =
 		(EFI_PCI_PCIX_DEVICE_ERROR_DATA *)section;
@@ -149,4 +147,4 @@
 		fwrite(pair, sizeof(UINT64), 2, out);
 		fflush(out);
 	}
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-pci-dev.h b/sections/cper-section-pci-dev.h
index e261d44..5326a8c 100644
--- a/sections/cper-section-pci-dev.h
+++ b/sections/cper-section-pci-dev.h
@@ -4,32 +4,36 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define PCI_DEV_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"errorStatusValid", "idInfoValid", "memoryNumberValid", \
-    "ioNumberValid", "registerDataPairsValid"}
+#define PCI_DEV_ERROR_VALID_BITFIELD_NAMES                                     \
+	(const char *[])                                                       \
+	{                                                                      \
+		"errorStatusValid", "idInfoValid", "memoryNumberValid",        \
+			"ioNumberValid", "registerDataPairsValid"              \
+	}
 
 ///
 /// PCI/PCI-X Device Error Section
 ///
 typedef struct {
-  UINT64 VendorId : 16;
-  UINT64 DeviceId : 16;
-  UINT64 ClassCode : 24;
-  UINT64 FunctionNumber : 8;
-  UINT64 DeviceNumber : 8;
-  UINT64 BusNumber : 8;
-  UINT64 SegmentNumber : 8;
-  UINT64 Reserved : 40;
+	UINT64 VendorId : 16;
+	UINT64 DeviceId : 16;
+	UINT64 ClassCode : 24;
+	UINT64 FunctionNumber : 8;
+	UINT64 DeviceNumber : 8;
+	UINT64 BusNumber : 8;
+	UINT64 SegmentNumber : 8;
+	UINT64 Reserved : 40;
 } EFI_PCI_PCIX_DEVICE_ID_INFO;
 
 typedef struct {
-  UINT64                      ValidFields;
-  EFI_GENERIC_ERROR_STATUS    ErrorStatus;
-  EFI_PCI_PCIX_DEVICE_ID_INFO IdInfo;
-  UINT32                      MemoryNumber;
-  UINT32                      IoNumber;
+	UINT64 ValidFields;
+	EFI_GENERIC_ERROR_STATUS ErrorStatus;
+	EFI_PCI_PCIX_DEVICE_ID_INFO IdInfo;
+	UINT32 MemoryNumber;
+	UINT32 IoNumber;
 } __attribute__((packed, aligned(1))) EFI_PCI_PCIX_DEVICE_ERROR_DATA;
 
-json_object* cper_section_pci_dev_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_pci_dev_to_cper(json_object* section, FILE* out);
+json_object *cper_section_pci_dev_to_ir(void *section);
+void ir_section_pci_dev_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section-pcie.c b/sections/cper-section-pcie.c
index cf68b3f..0642996 100644
--- a/sections/cper-section-pcie.c
+++ b/sections/cper-section-pcie.c
@@ -7,14 +7,13 @@
 #include <stdio.h>
 #include <string.h>
 #include <json.h>
-#include "b64.h"
+#include "libbase64.h"
 #include "../edk/Cper.h"
 #include "../cper-utils.h"
 #include "cper-section-pcie.h"
 
 //Converts a single PCIe CPER section into JSON IR.
-json_object *cper_section_pcie_to_ir(void *section,
-				     EFI_ERROR_SECTION_DESCRIPTOR *descriptor)
+json_object *cper_section_pcie_to_ir(void *section)
 {
 	EFI_PCIE_ERROR_DATA *pcie_error = (EFI_PCIE_ERROR_DATA *)section;
 	json_object *section_ir = json_object_new_object();
@@ -104,21 +103,38 @@
 	//The PCIe capability structure provided here could either be PCIe 1.1 Capability Structure
 	//(36-byte, padded to 60 bytes) or PCIe 2.0 Capability Structure (60-byte). There does not seem
 	//to be a way to differentiate these, so this is left as a b64 dump.
-	char *encoded =
-		b64_encode((unsigned char *)pcie_error->Capability.PcieCap, 60);
-	json_object *capability = json_object_new_object();
-	json_object_object_add(capability, "data",
-			       json_object_new_string(encoded));
-	free(encoded);
-	json_object_object_add(section_ir, "capabilityStructure", capability);
+	char *encoded = malloc(2 * 60);
+	size_t encoded_len = 0;
+	if (!encoded) {
+		printf("Failed to allocate encode output buffer. \n");
+	} else {
+		base64_encode((const char *)pcie_error->Capability.PcieCap, 60,
+			      encoded, &encoded_len, 0);
+		json_object *capability = json_object_new_object();
+		json_object_object_add(capability, "data",
+				       json_object_new_string_len(encoded,
+								  encoded_len));
+		free(encoded);
+		json_object_object_add(section_ir, "capabilityStructure",
+				       capability);
+	}
 
 	//AER information.
 	json_object *aer_capability_ir = json_object_new_object();
-	encoded = b64_encode((unsigned char *)pcie_error->AerInfo.PcieAer, 96);
-	json_object_object_add(aer_capability_ir, "data",
-			       json_object_new_string(encoded));
-	free(encoded);
-	json_object_object_add(section_ir, "aerInfo", aer_capability_ir);
+	encoded = malloc(2 * 96);
+	encoded_len = 0;
+	if (!encoded) {
+		printf("Failed to allocate encode output buffer. \n");
+	} else {
+		base64_encode((const char *)pcie_error->AerInfo.PcieAer, 96,
+			      encoded, &encoded_len, 0);
+		json_object_object_add(aer_capability_ir, "data",
+				       json_object_new_string_len(encoded,
+								  encoded_len));
+		free(encoded);
+		json_object_object_add(section_ir, "aerInfo",
+				       aer_capability_ir);
+	}
 	return section_ir;
 }
 
@@ -190,18 +206,32 @@
 	json_object *capability =
 		json_object_object_get(section, "capabilityStructure");
 	json_object *encoded = json_object_object_get(capability, "data");
-	UINT8 *decoded = b64_decode(json_object_get_string(encoded),
-				    json_object_get_string_len(encoded));
-	memcpy(section_cper->Capability.PcieCap, decoded, 60);
-	free(decoded);
+	char *decoded = malloc(json_object_get_string_len(encoded));
+	size_t decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		memcpy(section_cper->Capability.PcieCap, decoded, decoded_len);
+		free(decoded);
+	}
 
 	//AER capability structure.
 	json_object *aer_info = json_object_object_get(section, "aerInfo");
 	encoded = json_object_object_get(aer_info, "data");
-	decoded = b64_decode(json_object_get_string(encoded),
-			     json_object_get_string_len(encoded));
-	memcpy(section_cper->AerInfo.PcieAer, decoded, 96);
-	free(decoded);
+	decoded = malloc(json_object_get_string_len(encoded));
+	decoded_len = 0;
+	if (!decoded) {
+		printf("Failed to allocate decode output buffer. \n");
+	} else {
+		base64_decode(json_object_get_string(encoded),
+			      json_object_get_string_len(encoded), decoded,
+			      &decoded_len, 0);
+		memcpy(section_cper->AerInfo.PcieAer, decoded, decoded_len);
+		free(decoded);
+	}
 
 	//Miscellaneous value fields.
 	section_cper->PortType = (UINT32)readable_pair_to_integer(
@@ -213,4 +243,4 @@
 	fwrite(section_cper, sizeof(EFI_PCIE_ERROR_DATA), 1, out);
 	fflush(out);
 	free(section_cper);
-}
\ No newline at end of file
+}
diff --git a/sections/cper-section-pcie.h b/sections/cper-section-pcie.h
index a2a43a4..b0042c5 100644
--- a/sections/cper-section-pcie.h
+++ b/sections/cper-section-pcie.h
@@ -4,15 +4,32 @@
 #include <json.h>
 #include "../edk/Cper.h"
 
-#define PCIE_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"portTypeValid", "versionValid", "commandStatusValid", \
-    "deviceIDValid", "deviceSerialNumberValid", "bridgeControlStatusValid", "capabilityStructureStatusValid", \
-    "aerInfoValid"}
-#define PCIE_ERROR_PORT_TYPES_KEYS (int []){0, 1, 4, 5, 6, 7, 8, 9, 10}
-#define PCIE_ERROR_PORT_TYPES_VALUES (const char*[]){"PCI Express End Point", "Legacy PCI End Point Device", \
-    "Root Port", "Upstream Switch Port", "Downstream Switch Port", "PCI Express to PCI/PCI-X Bridge", \
-    "PCI/PCI-X Bridge to PCI Express Bridge", "Root Complex Integrated Endpoint Device", "Root Complex Event Collector"}
+#define PCIE_ERROR_VALID_BITFIELD_NAMES                                        \
+	(const char *[])                                                       \
+	{                                                                      \
+		"portTypeValid", "versionValid", "commandStatusValid",         \
+			"deviceIDValid", "deviceSerialNumberValid",            \
+			"bridgeControlStatusValid",                            \
+			"capabilityStructureStatusValid", "aerInfoValid"       \
+	}
+#define PCIE_ERROR_PORT_TYPES_KEYS                                             \
+	(int[])                                                                \
+	{                                                                      \
+		0, 1, 4, 5, 6, 7, 8, 9, 10                                     \
+	}
+#define PCIE_ERROR_PORT_TYPES_VALUES                                           \
+	(const char *[])                                                       \
+	{                                                                      \
+		"PCI Express End Point", "Legacy PCI End Point Device",        \
+			"Root Port", "Upstream Switch Port",                   \
+			"Downstream Switch Port",                              \
+			"PCI Express to PCI/PCI-X Bridge",                     \
+			"PCI/PCI-X Bridge to PCI Express Bridge",              \
+			"Root Complex Integrated Endpoint Device",             \
+			"Root Complex Event Collector"                         \
+	}
 
-json_object* cper_section_pcie_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
-void ir_section_pcie_to_cper(json_object* section, FILE* out);
+json_object *cper_section_pcie_to_ir(void *section);
+void ir_section_pcie_to_cper(json_object *section, FILE *out);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/sections/cper-section.c b/sections/cper-section.c
index 82a44a5..9bffdcb 100644
--- a/sections/cper-section.c
+++ b/sections/cper-section.c
@@ -23,26 +23,52 @@
 
 //Definitions of all sections available to the CPER parser.
 CPER_SECTION_DEFINITION section_definitions[] = {
-    {&gEfiProcessorGenericErrorSectionGuid, "Processor Generic", cper_section_generic_to_ir, ir_section_generic_to_cper},
-    {&gEfiIa32X64ProcessorErrorSectionGuid, "IA32/X64", cper_section_ia32x64_to_ir, ir_section_ia32x64_to_cper},
-    {&gEfiIpfProcessorErrorSectionGuid, "IPF", NULL, NULL},
-    {&gEfiArmProcessorErrorSectionGuid, "ARM", cper_section_arm_to_ir, ir_section_arm_to_cper},
-    {&gEfiPlatformMemoryErrorSectionGuid, "Platform Memory", cper_section_platform_memory_to_ir, ir_section_memory_to_cper},
-    {&gEfiPlatformMemoryError2SectionGuid, "Platform Memory 2", cper_section_platform_memory2_to_ir, ir_section_memory2_to_cper},
-    {&gEfiPcieErrorSectionGuid, "PCIe", cper_section_pcie_to_ir, ir_section_pcie_to_cper},
-    {&gEfiFirmwareErrorSectionGuid, "Firmware Error Record Reference", cper_section_firmware_to_ir, ir_section_firmware_to_cper},
-    {&gEfiPciBusErrorSectionGuid, "PCI/PCI-X Bus", cper_section_pci_bus_to_ir, ir_section_pci_bus_to_cper},
-    {&gEfiPciDevErrorSectionGuid, "PCI Component/Device", cper_section_pci_dev_to_ir, ir_section_pci_dev_to_cper},
-    {&gEfiDMArGenericErrorSectionGuid, "DMAr Generic", cper_section_dmar_generic_to_ir, ir_section_dmar_generic_to_cper},
-    {&gEfiDirectedIoDMArErrorSectionGuid, "Intel VT for Directed I/O Specific DMAr", cper_section_dmar_vtd_to_ir, ir_section_dmar_vtd_to_cper},
-    {&gEfiIommuDMArErrorSectionGuid, "IOMMU Specific DMAr", cper_section_dmar_iommu_to_ir, ir_section_dmar_iommu_to_cper},
-    {&gEfiCcixPerLogErrorSectionGuid, "CCIX PER Log Error", cper_section_ccix_per_to_ir, ir_section_ccix_per_to_cper},
-    {&gEfiCxlProtocolErrorSectionGuid, "CXL Protocol Error", cper_section_cxl_protocol_to_ir, ir_section_cxl_protocol_to_cper},
-    {&gEfiCxlGeneralMediaErrorSectionGuid, "CXL General Media Component Error", cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper},
-    {&gEfiCxlDramEventErrorSectionGuid, "CXL DRAM Component Error", cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper},
-    {&gEfiCxlMemoryModuleErrorSectionGuid, "CXL Memory Module Component Error", cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper},
-    {&gEfiCxlPhysicalSwitchErrorSectionGuid, "CXL Physical Switch Component Error", cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper},
-    {&gEfiCxlVirtualSwitchErrorSectionGuid, "CXL Virtual Switch Component Error", cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper},
-    {&gEfiCxlMldPortErrorSectionGuid, "CXL MLD Port Component Error", cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper},
+	{ &gEfiProcessorGenericErrorSectionGuid, "Processor Generic",
+	  cper_section_generic_to_ir, ir_section_generic_to_cper },
+	{ &gEfiIa32X64ProcessorErrorSectionGuid, "IA32/X64",
+	  cper_section_ia32x64_to_ir, ir_section_ia32x64_to_cper },
+	{ &gEfiIpfProcessorErrorSectionGuid, "IPF", NULL, NULL },
+	{ &gEfiArmProcessorErrorSectionGuid, "ARM", cper_section_arm_to_ir,
+	  ir_section_arm_to_cper },
+	{ &gEfiPlatformMemoryErrorSectionGuid, "Platform Memory",
+	  cper_section_platform_memory_to_ir, ir_section_memory_to_cper },
+	{ &gEfiPlatformMemoryError2SectionGuid, "Platform Memory 2",
+	  cper_section_platform_memory2_to_ir, ir_section_memory2_to_cper },
+	{ &gEfiPcieErrorSectionGuid, "PCIe", cper_section_pcie_to_ir,
+	  ir_section_pcie_to_cper },
+	{ &gEfiFirmwareErrorSectionGuid, "Firmware Error Record Reference",
+	  cper_section_firmware_to_ir, ir_section_firmware_to_cper },
+	{ &gEfiPciBusErrorSectionGuid, "PCI/PCI-X Bus",
+	  cper_section_pci_bus_to_ir, ir_section_pci_bus_to_cper },
+	{ &gEfiPciDevErrorSectionGuid, "PCI Component/Device",
+	  cper_section_pci_dev_to_ir, ir_section_pci_dev_to_cper },
+	{ &gEfiDMArGenericErrorSectionGuid, "DMAr Generic",
+	  cper_section_dmar_generic_to_ir, ir_section_dmar_generic_to_cper },
+	{ &gEfiDirectedIoDMArErrorSectionGuid,
+	  "Intel VT for Directed I/O Specific DMAr",
+	  cper_section_dmar_vtd_to_ir, ir_section_dmar_vtd_to_cper },
+	{ &gEfiIommuDMArErrorSectionGuid, "IOMMU Specific DMAr",
+	  cper_section_dmar_iommu_to_ir, ir_section_dmar_iommu_to_cper },
+	{ &gEfiCcixPerLogErrorSectionGuid, "CCIX PER Log Error",
+	  cper_section_ccix_per_to_ir, ir_section_ccix_per_to_cper },
+	{ &gEfiCxlProtocolErrorSectionGuid, "CXL Protocol Error",
+	  cper_section_cxl_protocol_to_ir, ir_section_cxl_protocol_to_cper },
+	{ &gEfiCxlGeneralMediaErrorSectionGuid,
+	  "CXL General Media Component Error", cper_section_cxl_component_to_ir,
+	  ir_section_cxl_component_to_cper },
+	{ &gEfiCxlDramEventErrorSectionGuid, "CXL DRAM Component Error",
+	  cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper },
+	{ &gEfiCxlMemoryModuleErrorSectionGuid,
+	  "CXL Memory Module Component Error", cper_section_cxl_component_to_ir,
+	  ir_section_cxl_component_to_cper },
+	{ &gEfiCxlPhysicalSwitchErrorSectionGuid,
+	  "CXL Physical Switch Component Error",
+	  cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper },
+	{ &gEfiCxlVirtualSwitchErrorSectionGuid,
+	  "CXL Virtual Switch Component Error",
+	  cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper },
+	{ &gEfiCxlMldPortErrorSectionGuid, "CXL MLD Port Component Error",
+	  cper_section_cxl_component_to_ir, ir_section_cxl_component_to_cper },
 };
-const size_t section_definitions_len = sizeof(section_definitions) / sizeof(CPER_SECTION_DEFINITION);
\ No newline at end of file
+const size_t section_definitions_len =
+	sizeof(section_definitions) / sizeof(CPER_SECTION_DEFINITION);
diff --git a/sections/cper-section.h b/sections/cper-section.h
index 4379f91..4ec8650 100644
--- a/sections/cper-section.h
+++ b/sections/cper-section.h
@@ -8,13 +8,13 @@
 
 //Definition structure for a single CPER section type.
 typedef struct {
-    EFI_GUID* Guid;
-    const char* ReadableName;
-    json_object* (*ToIR)(void*, EFI_ERROR_SECTION_DESCRIPTOR*);
-    void (*ToCPER)(json_object*, FILE*);
+	EFI_GUID *Guid;
+	const char *ReadableName;
+	json_object *(*ToIR)(void *);
+	void (*ToCPER)(json_object *, FILE *);
 } CPER_SECTION_DEFINITION;
 
 extern CPER_SECTION_DEFINITION section_definitions[];
 extern const size_t section_definitions_len;
 
-#endif
\ No newline at end of file
+#endif
diff --git a/tests/ir-tests.cpp b/tests/ir-tests.cpp
index affa305..542ce8e 100644
--- a/tests/ir-tests.cpp
+++ b/tests/ir-tests.cpp
@@ -4,7 +4,7 @@
  * Author: Lawrence.Tang@arm.com
  **/
 
-#include <ctype.h>
+#include <cctype>
 #include "gtest/gtest.h"
 #include "test-utils.hpp"
 extern "C" {
@@ -31,10 +31,11 @@
 
 	//Convert to IR, free resources.
 	json_object *ir;
-	if (single_section)
+	if (single_section) {
 		ir = cper_single_section_to_ir(record);
-	else
+	} else {
 		ir = cper_to_ir(record);
+	}
 	fclose(record);
 	free(buf);
 
@@ -42,6 +43,7 @@
 	char error_message[JSON_ERROR_MSG_MAX_LEN] = { 0 };
 	int valid = validate_schema_from_file("./specification/cper-json.json",
 					      ir, error_message);
+	json_object_put(ir);
 	ASSERT_TRUE(valid)
 		<< "IR validation test failed (single section mode = "
 		<< single_section << ") with message: " << error_message;
@@ -58,19 +60,21 @@
 
 	//Convert to IR.
 	json_object *ir;
-	if (single_section)
+	if (single_section) {
 		ir = cper_single_section_to_ir(record);
-	else
+	} else {
 		ir = cper_to_ir(record);
+	}
 
 	//Now convert back to binary, and get a stream out.
 	char *cper_buf;
 	size_t cper_buf_size;
 	FILE *stream = open_memstream(&cper_buf, &cper_buf_size);
-	if (single_section)
+	if (single_section) {
 		ir_single_section_to_cper(ir, stream);
-	else
+	} else {
 		ir_to_cper(ir, stream);
+	}
 	size_t cper_len = ftell(stream);
 	fclose(stream);
 
@@ -84,6 +88,7 @@
 	fclose(record);
 	free(buf);
 	free(cper_buf);
+	json_object_put(ir);
 }
 
 //Tests randomly generated CPER sections for IR validity of a given type, in both single section mode and full CPER log mode.
@@ -105,20 +110,23 @@
 */
 TEST(CompileTimeAssertions, TwoWayConversion)
 {
-	for (int i = 0; i < section_definitions_len; i++) {
+	for (size_t i = 0; i < section_definitions_len; i++) {
 		//If a conversion one way exists, a conversion the other way must exist.
 		std::string err =
 			"If a CPER conversion exists one way, there must be an equivalent method in reverse.";
-		if (section_definitions[i].ToCPER != NULL)
-			ASSERT_NE(section_definitions[i].ToIR, NULL) << err;
-		if (section_definitions[i].ToIR != NULL)
-			ASSERT_NE(section_definitions[i].ToCPER, NULL) << err;
+		if (section_definitions[i].ToCPER != NULL) {
+			ASSERT_NE(section_definitions[i].ToIR, nullptr) << err;
+		}
+		if (section_definitions[i].ToIR != NULL) {
+			ASSERT_NE(section_definitions[i].ToCPER, nullptr)
+				<< err;
+		}
 	}
 }
 
 TEST(CompileTimeAssertions, ShortcodeNoSpaces)
 {
-	for (int i = 0; i < generator_definitions_len; i++) {
+	for (size_t i = 0; i < generator_definitions_len; i++) {
 		for (int j = 0;
 		     generator_definitions[i].ShortName[j + 1] != '\0'; j++) {
 			ASSERT_FALSE(
@@ -302,4 +310,4 @@
 {
 	testing::InitGoogleTest();
 	return RUN_ALL_TESTS();
-}
\ No newline at end of file
+}
diff --git a/tests/test-utils.cpp b/tests/test-utils.cpp
index 87cd429..c12e335 100644
--- a/tests/test-utils.cpp
+++ b/tests/test-utils.cpp
@@ -4,8 +4,8 @@
  * Author: Lawrence.Tang@arm.com
  **/
 
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
 #include "test-utils.hpp"
 extern "C" {
 #include "../edk/BaseTypes.h"
@@ -14,18 +14,22 @@
 
 //Returns a ready-for-use memory stream containing a CPER record with the given sections inside.
 FILE *generate_record_memstream(const char **types, UINT16 num_types,
-				char **buf, size_t *buf_size, int single_section)
+				char **buf, size_t *buf_size,
+				int single_section)
 {
 	//Open a memory stream.
 	FILE *stream = open_memstream(buf, buf_size);
 
 	//Generate a section to the stream, close & return.
-	if (!single_section)
-		generate_cper_record((char **)types, num_types, stream);
-	else
-		generate_single_section_record((char*)types[0], stream);
+	if (!single_section) {
+		generate_cper_record(const_cast<char **>(types), num_types,
+				     stream);
+	} else {
+		generate_single_section_record(const_cast<char *>(types[0]),
+					       stream);
+	}
 	fclose(stream);
 
 	//Return fmemopen() buffer for reading.
 	return fmemopen(*buf, *buf_size, "r");
-}
\ No newline at end of file
+}
diff --git a/tests/test-utils.hpp b/tests/test-utils.hpp
index 8e15560..2dedf8b 100644
--- a/tests/test-utils.hpp
+++ b/tests/test-utils.hpp
@@ -5,6 +5,8 @@
 #include "../edk/BaseTypes.h"
 }
 
-FILE* generate_record_memstream(const char** types, UINT16 num_types, char** buf, size_t* buf_size, int single_section);
+FILE *generate_record_memstream(const char **types, UINT16 num_types,
+				char **buf, size_t *buf_size,
+				int single_section);
 
-#endif
\ No newline at end of file
+#endif