Add support for NVIDIA CPERs

Support Nvidia CPER entries.

Change-Id: Iea9bde181ead55ad99cdb2a341501bf48e1d82a8
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/generator/sections/gen-section-nvidia.c b/generator/sections/gen-section-nvidia.c
new file mode 100644
index 0000000..83ed84e
--- /dev/null
+++ b/generator/sections/gen-section-nvidia.c
@@ -0,0 +1,44 @@
+/**
+ * Functions for generating pseudo-random CPER NVIDIA error sections.
+ *
+ **/
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "../../edk/BaseTypes.h"
+#include "../gen-utils.h"
+#include "gen-section.h"
+
+//Generates a single pseudo-random NVIDIA error section, saving the resulting address to the given
+//location. Returns the size of the newly created section.
+size_t generate_section_nvidia(void **location)
+{
+	const char *signatures[] = {
+		"DCC-ECC",   "DCC-COH",	      "HSS-BUSY",      "HSS-IDLE",
+		"CLink",     "C2C",	      "C2C-IP-FAIL",   "L0 RESET",
+		"L1 RESET",  "L2 RESET",      "PCIe",	       "PCIe-DPC",
+		"SOCHUB",    "CCPLEXSCF",     "CMET-NULL",     "CMET-SHA256",
+		"CMET-FULL", "DRAM-CHANNELS", "PAGES-RETIRED", "CCPLEXGIC",
+		"MCF",	     "GPU-STATUS",    "GPU-CONTNMT",   "SMMU",
+	};
+
+	init_random();
+
+	//Create random bytes.
+	size_t size = sizeof(EFI_NVIDIA_ERROR_DATA);
+	UINT8 *section = generate_random_bytes(size);
+
+	//Reserved byte.
+	EFI_NVIDIA_ERROR_DATA *nvidia_error = (EFI_NVIDIA_ERROR_DATA *)section;
+	nvidia_error->Reserved = 0;
+
+	//Signature.
+	int idx_random = rand() % (sizeof(signatures) / sizeof(signatures[0]));
+	strncpy(nvidia_error->Signature, signatures[idx_random],
+		sizeof(nvidia_error->Signature));
+
+	//Set return values, exit.
+	*location = section;
+	return size;
+}
diff --git a/generator/sections/gen-section.c b/generator/sections/gen-section.c
index 7240145..819ebdb 100644
--- a/generator/sections/gen-section.c
+++ b/generator/sections/gen-section.c
@@ -42,6 +42,7 @@
 	  generate_section_cxl_component },
 	{ &gEfiCxlMldPortErrorSectionGuid, "cxlcomponent-mld",
 	  generate_section_cxl_component },
+	{ &gEfiNvidiaErrorSectionGuid, "nvidia", generate_section_nvidia },
 };
 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 df1e227..be00b5f 100644
--- a/generator/sections/gen-section.h
+++ b/generator/sections/gen-section.h
@@ -20,6 +20,7 @@
 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_nvidia(void **location);
 
 //Definition structure for a single CPER section generator.
 typedef struct {