Improve Nvidia CPER decode

Add decoding of registers to the structure.  Note, this requires
COUNTED_BY support which is borrowed from LIBPLDM.

Also add unit-tests for NVIDIA section, and update schema to match
existing register decoding.

Change-Id: If1c9cae97de35ba6a5dad1f462d3989ec6ac6a90
Signed-off-by: Karthik Rajagopalan <krajagopalan@nvidia.com>
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/edk/Cper.h b/edk/Cper.h
index f1bbdb1..5160eba 100644
--- a/edk/Cper.h
+++ b/edk/Cper.h
@@ -14,6 +14,7 @@
 #define __CPER_GUID_H__
 
 #include "BaseTypes.h"
+#include "common-utils.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -1392,6 +1393,11 @@
 /// NVIDIA Error Record Section
 ///
 typedef struct {
+	UINT64 Address;
+	UINT64 Value;
+} EFI_NVIDIA_REGISTER_DATA;
+
+typedef struct {
 	CHAR8 Signature[16];
 	UINT16 ErrorType;
 	UINT16 ErrorInstance;
@@ -1400,6 +1406,11 @@
 	UINT8 NumberRegs;
 	UINT8 Reserved;
 	UINT64 InstanceBase;
+	// Keep this at the end of this struct
+	// and allocate based on NumberRegs
+#ifndef __cplusplus
+	EFI_NVIDIA_REGISTER_DATA Register[] LIBCPER_CC_COUNTED_BY(NumberRegs);
+#endif
 } EFI_NVIDIA_ERROR_DATA;
 
 extern EFI_GUID gEfiNvidiaErrorSectionGuid;