Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Base.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Base.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Base.h	(revision 85718)
@@ -29,56 +29,4 @@
 #endif
 
-/**
-  Verifies the storage size of a given data type.
-
-  This macro generates a divide by zero error or a zero size array declaration in
-  the preprocessor if the size is incorrect.  These are declared as "extern" so
-  the space for these arrays will not be in the modules.
-
-  @param  TYPE  The date type to determine the size of.
-  @param  Size  The expected size for the TYPE.
-
-**/
-#define VERIFY_SIZE_OF(TYPE, Size) extern UINT8 _VerifySizeof##TYPE[(sizeof(TYPE) == (Size)) / (sizeof(TYPE) == (Size))]
-
-//
-// Verify that ProcessorBind.h produced UEFI Data Types that are compliant with
-// Section 2.3.1 of the UEFI 2.3 Specification.
-//
-VERIFY_SIZE_OF (BOOLEAN, 1);
-VERIFY_SIZE_OF (INT8, 1);
-VERIFY_SIZE_OF (UINT8, 1);
-VERIFY_SIZE_OF (INT16, 2);
-VERIFY_SIZE_OF (UINT16, 2);
-VERIFY_SIZE_OF (INT32, 4);
-VERIFY_SIZE_OF (UINT32, 4);
-VERIFY_SIZE_OF (INT64, 8);
-VERIFY_SIZE_OF (UINT64, 8);
-VERIFY_SIZE_OF (CHAR8, 1);
-VERIFY_SIZE_OF (CHAR16, 2);
-
-//
-// The following three enum types are used to verify that the compiler
-// configuration for enum types is compliant with Section 2.3.1 of the
-// UEFI 2.3 Specification. These enum types and enum values are not
-// intended to be used. A prefix of '__' is used avoid conflicts with
-// other types.
-//
-typedef enum {
-  __VerifyUint8EnumValue = 0xff
-} __VERIFY_UINT8_ENUM_SIZE;
-
-typedef enum {
-  __VerifyUint16EnumValue = 0xffff
-} __VERIFY_UINT16_ENUM_SIZE;
-
-typedef enum {
-  __VerifyUint32EnumValue = 0xffffffff
-} __VERIFY_UINT32_ENUM_SIZE;
-
-VERIFY_SIZE_OF (__VERIFY_UINT8_ENUM_SIZE, 4);
-VERIFY_SIZE_OF (__VERIFY_UINT16_ENUM_SIZE, 4);
-VERIFY_SIZE_OF (__VERIFY_UINT32_ENUM_SIZE, 4);
-
 //
 // The Microsoft* C compiler can removed references to unreferenced data items
@@ -86,5 +34,5 @@
 //  a non standard extension
 //
-#if defined(_MSC_EXTENSIONS) && _MSC_VER < 1800 && !defined (MDE_CPU_EBC)
+#if defined(_MSC_VER) && _MSC_VER < 1800 && !defined (MDE_CPU_EBC)
   ///
   /// Remove global variable from the linked image if there are no references to
@@ -248,5 +196,5 @@
 #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)
 
-#if __APPLE__
+#ifdef __APPLE__
   //
   // Apple extension that is used by the linker to optimize code size
@@ -674,5 +622,5 @@
 #define VA_COPY(Dest, Start)            ((void)((Dest) = (Start)))
 
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
 
 #if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS)
@@ -834,8 +782,6 @@
 
 **/
-#ifdef __GNUC__
-#if __GNUC__ >= 4
+#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
 #define OFFSET_OF(TYPE, Field) ((UINTN) __builtin_offsetof(TYPE, Field))
-#endif
 #endif
 
@@ -843,4 +789,60 @@
 #define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))
 #endif
+
+/**
+  Portable definition for compile time assertions.
+  Equivalent to C11 static_assert macro from assert.h.
+
+  @param  Expression  Boolean expression.
+  @param  Message     Raised compiler diagnostic message when expression is false.
+
+**/
+#ifdef MDE_CPU_EBC
+  #define STATIC_ASSERT(Expression, Message)
+#elif defined(_MSC_EXTENSIONS)
+  #define STATIC_ASSERT static_assert
+#else
+  #define STATIC_ASSERT _Static_assert
+#endif
+
+//
+// Verify that ProcessorBind.h produced UEFI Data Types that are compliant with
+// Section 2.3.1 of the UEFI 2.3 Specification.
+//
+
+STATIC_ASSERT (sizeof (BOOLEAN) == 1, "sizeof (BOOLEAN) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (INT8)    == 1, "sizeof (INT8) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (UINT8)   == 1, "sizeof (UINT8) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (INT16)   == 2, "sizeof (INT16) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (UINT16)  == 2, "sizeof (UINT16) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (INT32)   == 4, "sizeof (INT32) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (UINT32)  == 4, "sizeof (UINT32) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (INT64)   == 8, "sizeof (INT64) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (UINT64)  == 8, "sizeof (UINT64) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (CHAR8)   == 1, "sizeof (CHAR8) does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (CHAR16)  == 2, "sizeof (CHAR16) does not meet UEFI Specification Data Type requirements");
+
+//
+// The following three enum types are used to verify that the compiler
+// configuration for enum types is compliant with Section 2.3.1 of the
+// UEFI 2.3 Specification. These enum types and enum values are not
+// intended to be used. A prefix of '__' is used avoid conflicts with
+// other types.
+//
+typedef enum {
+  __VerifyUint8EnumValue = 0xff
+} __VERIFY_UINT8_ENUM_SIZE;
+
+typedef enum {
+  __VerifyUint16EnumValue = 0xffff
+} __VERIFY_UINT16_ENUM_SIZE;
+
+typedef enum {
+  __VerifyUint32EnumValue = 0xffffffff
+} __VERIFY_UINT32_ENUM_SIZE;
+
+STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
 
 /**
@@ -1271,5 +1273,5 @@
   **/
   #define RETURN_ADDRESS(L)     ((L == 0) ? _ReturnAddress() : (VOID *) 0)
-#elif defined(__GNUC__)
+#elif defined (__GNUC__) || defined (__clang__)
   void * __builtin_return_address (unsigned int level);
   /**
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/CapsuleReport.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/CapsuleReport.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/CapsuleReport.h	(revision 85718)
@@ -94,4 +94,33 @@
 } EFI_CAPSULE_RESULT_VARIABLE_FMP;
 
+typedef struct {
+
+  ///
+  /// Version of this structure, currently 0x00000001
+  ///
+  UINT32    Version;
+
+  ///
+  /// The unique identifier of the capsule whose processing result is recorded in this variable.
+  /// 0x00000000 - 0xEFFFFFFF - Implementation Reserved
+  /// 0xF0000000 - 0xFFFFFFFF - Specification Reserved
+  /// #define REDFISH_DEFINED_JSON_SCHEMA 0xF000000
+  /// The JSON payload shall conform to a Redfish-defined JSON schema, see DMTF-Redfish
+  /// Specification.
+  ///
+  UINT32 CapsuleId;
+
+  ///
+  /// The length of Resp in bytes.
+  ///
+  UINT32 RespLength;
+
+  ///
+  /// Variable length buffer containing the replied JSON payload to the caller who delivered JSON
+  /// capsule to system. The definition of the JSON schema used in the replied payload is beyond
+  /// the scope of this specification.
+  ///
+  UINT8 Resp[];
+ } EFI_CAPSULE_RESULT_VARIABLE_JSON;
 
 extern EFI_GUID gEfiCapsuleReportGuid;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/Cper.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/Cper.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/Cper.h	(revision 85718)
@@ -95,4 +95,16 @@
   { \
     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 } \
   }
 ///@}
@@ -1208,4 +1220,7 @@
 extern EFI_GUID gEfiEventNotificationTypeBootGuid;
 extern EFI_GUID gEfiEventNotificationTypeDmarGuid;
+extern EFI_GUID gEfiEventNotificationTypeSeaGuid;
+extern EFI_GUID gEfiEventNotificationTypeSeiGuid;
+extern EFI_GUID gEfiEventNotificationTypePeiGuid;
 
 extern EFI_GUID gEfiProcessorGenericErrorSectionGuid;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/FmpCapsule.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/FmpCapsule.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/FmpCapsule.h	(revision 85718)
@@ -80,4 +80,11 @@
   ///
   UINT64   UpdateHardwareInstance;
+
+  ///
+  /// A 64-bit bitmask that determines what sections are added to the payload.
+  /// #define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001
+  /// #define CAPSULE_SUPPORT_DEPENDENCY 0x0000000000000002
+  ///
+  UINT64   ImageCapsuleSupport;
 } EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER;
 
@@ -86,5 +93,7 @@
 
 #define EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION       0x00000001
-#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION 0x00000002
+#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION 0x00000003
+#define CAPSULE_SUPPORT_AUTHENTICATION    0x0000000000000001
+#define CAPSULE_SUPPORT_DEPENDENCY        0x0000000000000002
 
 extern EFI_GUID gEfiFmpCapsuleGuid;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/HiiPlatformSetupFormset.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/HiiPlatformSetupFormset.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/HiiPlatformSetupFormset.h	(revision 85718)
@@ -23,7 +23,11 @@
   { 0x337f4407, 0x5aee, 0x4b83, { 0xb2, 0xa7, 0x4e, 0xad, 0xca, 0x30, 0x88, 0xcd } }
 
+#define EFI_HII_REST_STYLE_FORMSET_GUID \
+  { 0x790217bd, 0xbecf, 0x485b, { 0x91, 0x70, 0x5f, 0xf7, 0x11, 0x31, 0x8b, 0x27 } }
+
 extern EFI_GUID gEfiHiiPlatformSetupFormsetGuid;
 extern EFI_GUID gEfiHiiDriverHealthFormsetGuid;
 extern EFI_GUID gEfiHiiUserCredentialFormsetGuid;
+extern EFI_GUID gEfiHiiRestStyleFormsetGuid;
 
 #endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/JsonCapsule.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/JsonCapsule.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/JsonCapsule.h	(revision 85718)
@@ -0,0 +1,98 @@
+/** @file
+Guid & data structure for tables defined for reporting firmware configuration data to EFI
+Configuration Tables and also for processing JSON payload capsule.
+
+
+Copyright (c) 2020, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __JSON_CAPSULE_GUID_H__
+#define __JSON_CAPSULE_GUID_H__
+
+//
+// The address reported in the table entry identified by EFI_JSON_CAPSULE_DATA_TABLE_GUID will be
+// referenced as physical and will not be fixed up when transition from preboot to runtime phase. The
+// addresses reported in these table entries identified by EFI_JSON_CONFIG_DATA_TABLE_GUID and
+// EFI_JSON_CAPSULE_RESULT_TABLE_GUID will be referenced as virtual and will be fixed up when
+// transition from preboot to runtime phase.
+//
+#define EFI_JSON_CONFIG_DATA_TABLE_GUID \
+    {0x87367f87, 0x1119, 0x41ce, \
+    {0xaa, 0xec, 0x8b, 0xe0, 0x11, 0x1f, 0x55, 0x8a }}
+#define EFI_JSON_CAPSULE_DATA_TABLE_GUID \
+    {0x35e7a725, 0x8dd2, 0x4cac, \
+    {0x80, 0x11, 0x33, 0xcd, 0xa8, 0x10, 0x90, 0x56 }}
+#define EFI_JSON_CAPSULE_RESULT_TABLE_GUID \
+    {0xdbc461c3, 0xb3de, 0x422a,\
+    {0xb9, 0xb4, 0x98, 0x86, 0xfd, 0x49, 0xa1, 0xe5 }}
+#define EFI_JSON_CAPSULE_ID_GUID \
+    {0x67d6f4cd, 0xd6b8,  0x4573, \
+    {0xbf, 0x4a, 0xde, 0x5e, 0x25, 0x2d, 0x61, 0xae }}
+
+
+#pragma pack(1)
+
+typedef struct {
+  ///
+  /// Version of the structure, initially 0x00000001.
+  ///
+  UINT32 Version;
+
+  ///
+  /// The unique identifier of this capsule.
+  ///
+  UINT32 CapsuleId;
+
+  ///
+  /// The length of the JSON payload immediately following this header, in bytes.
+  ///
+  UINT32 PayloadLength;
+
+  ///
+  /// Variable length buffer containing the JSON payload that should be parsed and applied to the system. The
+  /// definition of the JSON schema used in the payload is beyond the scope of this specification.
+  ///
+  UINT8 Payload[];
+} EFI_JSON_CAPSULE_HEADER;
+
+typedef struct {
+  ///
+  /// The length of the following ConfigData, in bytes.
+  ///
+  UINT32 ConfigDataLength;
+
+  ///
+  /// Variable length buffer containing the JSON payload that describes one group of configuration data within
+  /// current system. The definition of the JSON schema used in this payload is beyond the scope of this specification.
+  ///
+  UINT8 ConfigData[];
+} EFI_JSON_CONFIG_DATA_ITEM;
+
+typedef struct {
+  ///
+  /// Version of the structure, initially 0x00000001.
+  ///
+  UINT32 Version;
+
+  ///
+  ////The total length of EFI_JSON_CAPSULE_CONFIG_DATA, in bytes.
+  ///
+  UINT32 TotalLength;
+
+  ///
+  /// Array of configuration data groups.
+  ///
+  EFI_JSON_CONFIG_DATA_ITEM ConfigDataList[];
+} EFI_JSON_CAPSULE_CONFIG_DATA;
+
+#pragma pack()
+
+extern EFI_GUID gEfiJsonConfigDataTableGuid;
+extern EFI_GUID gEfiJsonCapsuleDataTableGuid;
+extern EFI_GUID gEfiJsonCapsuleResultTableGuid;
+extern EFI_GUID gEfiJsonCapsuleIdGuid;
+
+
+#endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/PropertiesTable.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/PropertiesTable.h	(revision 85716)
+++ 	(revision )
@@ -1,31 +1,0 @@
-/** @file
-  GUIDs used for UEFI Properties Table in the UEFI 2.5 specification.
-
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __EFI_PROPERTIES_TABLE_H__
-#define __EFI_PROPERTIES_TABLE_H__
-
-#define EFI_PROPERTIES_TABLE_GUID {\
-  0x880aaca3, 0x4adc, 0x4a04, {0x90, 0x79, 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5} \
-}
-
-typedef struct {
-  UINT32    Version;
-  UINT32    Length;
-  UINT64    MemoryProtectionAttribute;
-} EFI_PROPERTIES_TABLE;
-
-#define EFI_PROPERTIES_TABLE_VERSION  0x00010000
-
-//
-// Memory attribute (Not defined bit is reserved)
-//
-#define EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA        0x1
-
-extern EFI_GUID gEfiPropertiesTableGuid;
-
-#endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/RtPropertiesTable.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/RtPropertiesTable.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/RtPropertiesTable.h	(revision 85718)
@@ -0,0 +1,69 @@
+/** @file
+Guid & data structure for EFI_RT _PROPERTIES_TABLE, designed to be published by a
+platform if it no longer  supports all EFI runtime services once ExitBootServices()
+has been called by the OS. Introduced in UEFI 2.8a.
+
+
+Copyright (c) 2020, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __RT_PROPERTIES_TABLE_GUID_H__
+#define __RT_PROPERTIES_TABLE_GUID_H__
+
+//
+// Table, defined here, should be published by a platform if it no longer supports all EFI runtime
+// services once ExitBootServices() has been called by the OS. Note that this is merely a hint
+// to the OS, which it is free to ignore, and so the platform is still required to provide callable
+// implementations of unsupported runtime services that simply return EFI_UNSUPPORTED.
+//
+#define EFI_RT_PROPERTIES_TABLE_GUID \
+    { 0xeb66918a, 0x7eef, 0x402a, \
+    { 0x84, 0x2e, 0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9 }}
+
+
+
+
+#pragma pack(1)
+
+typedef struct {
+  ///
+  /// Version of the structure, must be 0x1.
+  ///
+  UINT16 Version;
+
+  ///
+  /// Size in bytes of the entire EFI_RT_PROPERTIES_TABLE, must be 8.
+  ///
+  UINT16 Length;
+
+  ///
+  /// Bitmask of which calls are or are not supported, where a bit set to 1 indicates
+  /// that the call is supported, and 0 indicates that it is not.
+  ///
+  UINT32 RuntimeServicesSupported;
+} EFI_RT_PROPERTIES_TABLE;
+
+#pragma pack()
+
+#define EFI_RT_PROPERTIES_TABLE_VERSION 0x1
+
+#define EFI_RT_SUPPORTED_GET_TIME                       0x0001
+#define EFI_RT_SUPPORTED_SET_TIME                       0x0002
+#define EFI_RT_SUPPORTED_GET_WAKEUP_TIME                0x0004
+#define EFI_RT_SUPPORTED_SET_WAKEUP_TIME                0x0008
+#define EFI_RT_SUPPORTED_GET_VARIABLE                   0x0010
+#define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME         0x0020
+#define EFI_RT_SUPPORTED_SET_VARIABLE                   0x0040
+#define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP        0x0080
+#define EFI_RT_SUPPORTED_CONVERT_POINTER                0x0100
+#define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT  0x0200
+#define EFI_RT_SUPPORTED_RESET_SYSTEM                   0x0400
+#define EFI_RT_SUPPORTED_UPDATE_CAPSULE                 0x0800
+#define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES     0x1000
+#define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO            0x2000
+
+extern EFI_GUID gEfiRtPropertiesTableGuid;
+
+#endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/SystemResourceTable.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/SystemResourceTable.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Guid/SystemResourceTable.h	(revision 85718)
@@ -2,5 +2,5 @@
   Guid & data structure used for EFI System Resource Table (ESRT)
 
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -35,12 +35,13 @@
 /// Last Attempt Status Values
 ///
-#define LAST_ATTEMPT_STATUS_SUCCESS                       0x00000000
-#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL            0x00000001
-#define LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES  0x00000002
-#define LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION       0x00000003
-#define LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT          0x00000004
-#define LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR              0x00000005
-#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_AC              0x00000006
-#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT            0x00000007
+#define LAST_ATTEMPT_STATUS_SUCCESS                         0x00000000
+#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL              0x00000001
+#define LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES    0x00000002
+#define LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION         0x00000003
+#define LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT            0x00000004
+#define LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR                0x00000005
+#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_AC                0x00000006
+#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT              0x00000007
+#define LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES  0x00000008
 
 typedef struct {
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ia32/ProcessorBind.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ia32/ProcessorBind.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ia32/ProcessorBind.h	(revision 85718)
@@ -88,5 +88,5 @@
 #pragma warning ( disable : 4206 )
 
-#if _MSC_VER == 1800 || _MSC_VER == 1900 || _MSC_VER >= 1910
+#if defined(_MSC_VER) && _MSC_VER >= 1800
 
 //
@@ -282,5 +282,5 @@
   ///
   #define EFIAPI __cdecl
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) || defined(__clang__)
   ///
   /// GCC specific method for EFIAPI calling convention.
@@ -295,5 +295,5 @@
 #endif
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
   ///
   /// For GNU assembly code, .global or .globl can declare global symbols.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi10.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi10.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi10.h	(revision 85718)
@@ -38,5 +38,5 @@
 
 //
-// Define for Desriptor
+// Define for Descriptor
 //
 #define ACPI_SMALL_ITEM_FLAG                   0x00
@@ -110,5 +110,5 @@
 
 ///
-/// The commond definition of QWORD, DWORD, and WORD
+/// The common definition of QWORD, DWORD, and WORD
 /// Address Space Descriptors.
 ///
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi20.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi20.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi20.h	(revision 85718)
@@ -12,5 +12,5 @@
 
 //
-// Define for Desriptor
+// Define for Descriptor
 //
 #define ACPI_LARGE_GENERIC_REGISTER_DESCRIPTOR_NAME          0x02
@@ -506,5 +506,5 @@
 
 ///
-/// "SPCR" Serial Port Concole Redirection Table
+/// "SPCR" Serial Port Console Redirection Table
 ///
 #define EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  SIGNATURE_32('S', 'P', 'C', 'R')
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi30.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi30.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi30.h	(revision 85718)
@@ -12,5 +12,5 @@
 
 //
-// Define for Desriptor
+// Define for Descriptor
 //
 #define ACPI_LARGE_EXTENDED_ADDRESS_SPACE_DESCRIPTOR_NAME    0x0B
@@ -685,5 +685,5 @@
 
 ///
-/// "SPCR" Serial Port Concole Redirection Table
+/// "SPCR" Serial Port Console Redirection Table
 ///
 #define EFI_ACPI_3_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  SIGNATURE_32('S', 'P', 'C', 'R')
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi40.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi40.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi40.h	(revision 85718)
@@ -1265,5 +1265,5 @@
 
 ///
-/// "SPCR" Serial Port Concole Redirection Table
+/// "SPCR" Serial Port Console Redirection Table
 ///
 #define EFI_ACPI_4_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  SIGNATURE_32('S', 'P', 'C', 'R')
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi50.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi50.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi50.h	(revision 85718)
@@ -4,4 +4,5 @@
   Copyright (c) 2014 Hewlett-Packard Development Company, L.P.<BR>
   Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -13,5 +14,5 @@
 
 //
-// Define for Desriptor
+// Define for Descriptor
 //
 #define ACPI_SMALL_FIXED_DMA_DESCRIPTOR_NAME                         0x0A
@@ -1202,5 +1203,5 @@
   UINT64                                          ExitBootServicesEntry;
   ///
-  /// Timer value logged at the point just prior towhen the OS loader gaining
+  /// Timer value logged at the point just prior to when the OS loader gaining
   /// control back from calls the ExitBootServices function for UEFI compatible firmware.
   /// For non-UEFI compatible boots, this field must be zero.
@@ -2059,4 +2060,9 @@
 
 ///
+/// "PCCT" Platform Communications Channel Table
+///
+#define EFI_ACPI_5_0_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE  SIGNATURE_32('P', 'C', 'C', 'T')
+
+///
 /// "SLIC" MS Software Licensing Table Specification
 ///
@@ -2064,5 +2070,5 @@
 
 ///
-/// "SPCR" Serial Port Concole Redirection Table
+/// "SPCR" Serial Port Console Redirection Table
 ///
 #define EFI_ACPI_5_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  SIGNATURE_32('S', 'P', 'C', 'R')
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi51.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi51.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi51.h	(revision 85718)
@@ -5,4 +5,5 @@
   Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -1155,5 +1156,5 @@
   UINT64                                          ExitBootServicesEntry;
   ///
-  /// Timer value logged at the point just prior towhen the OS loader gaining
+  /// Timer value logged at the point just prior to when the OS loader gaining
   /// control back from calls the ExitBootServices function for UEFI compatible firmware.
   /// For non-UEFI compatible boots, this field must be zero.
@@ -2080,4 +2081,9 @@
 
 ///
+/// "PCCT" Platform Communications Channel Table
+///
+#define EFI_ACPI_5_1_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE  SIGNATURE_32('P', 'C', 'C', 'T')
+
+///
 /// "SLIC" MS Software Licensing Table Specification
 ///
@@ -2085,5 +2091,5 @@
 
 ///
-/// "SPCR" Serial Port Concole Redirection Table
+/// "SPCR" Serial Port Console Redirection Table
 ///
 #define EFI_ACPI_5_1_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  SIGNATURE_32('S', 'P', 'C', 'R')
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi60.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi60.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi60.h	(revision 85718)
@@ -4,4 +4,5 @@
   Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -1170,5 +1171,5 @@
   UINT64                                          ExitBootServicesEntry;
   ///
-  /// Timer value logged at the point just prior towhen the OS loader gaining
+  /// Timer value logged at the point just prior to when the OS loader gaining
   /// control back from calls the ExitBootServices function for UEFI compatible firmware.
   /// For non-UEFI compatible boots, this field must be zero.
@@ -2323,4 +2324,9 @@
 
 ///
+/// "PCCT" Platform Communications Channel Table
+///
+#define EFI_ACPI_6_0_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE  SIGNATURE_32('P', 'C', 'C', 'T')
+
+///
 /// "SLIC" MS Software Licensing Table Specification
 ///
@@ -2328,5 +2334,5 @@
 
 ///
-/// "SPCR" Serial Port Concole Redirection Table
+/// "SPCR" Serial Port Console Redirection Table
 ///
 #define EFI_ACPI_6_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  SIGNATURE_32('S', 'P', 'C', 'R')
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi61.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi61.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi61.h	(revision 85718)
@@ -4,4 +4,5 @@
   Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -1170,5 +1171,5 @@
   UINT64                                          ExitBootServicesEntry;
   ///
-  /// Timer value logged at the point just prior towhen the OS loader gaining
+  /// Timer value logged at the point just prior to when the OS loader gaining
   /// control back from calls the ExitBootServices function for UEFI compatible firmware.
   /// For non-UEFI compatible boots, this field must be zero.
@@ -2355,4 +2356,9 @@
 
 ///
+/// "PCCT" Platform Communications Channel Table
+///
+#define EFI_ACPI_6_1_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE  SIGNATURE_32('P', 'C', 'C', 'T')
+
+///
 /// "SLIC" MS Software Licensing Table Specification
 ///
@@ -2360,5 +2366,5 @@
 
 ///
-/// "SPCR" Serial Port Concole Redirection Table
+/// "SPCR" Serial Port Console Redirection Table
 ///
 #define EFI_ACPI_6_1_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  SIGNATURE_32('S', 'P', 'C', 'R')
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi62.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi62.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi62.h	(revision 85718)
@@ -3,4 +3,5 @@
 
   Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -1282,5 +1283,5 @@
   UINT64                                          ExitBootServicesEntry;
   ///
-  /// Timer value logged at the point just prior towhen the OS loader gaining
+  /// Timer value logged at the point just prior to when the OS loader gaining
   /// control back from calls the ExitBootServices function for UEFI compatible firmware.
   /// For non-UEFI compatible boots, this field must be zero.
@@ -1651,5 +1652,5 @@
 
 ///
-/// Secure Devcice types
+/// Secure Device types
 ///
 #define EFI_ACPI_6_2_SDEV_TYPE_PCIE_ENDPOINT_DEVICE     0x01
@@ -1657,5 +1658,5 @@
 
 ///
-/// Secure Devcice flags
+/// Secure Device flags
 ///
 #define EFI_ACPI_6_2_SDEV_FLAG_ALLOW_HANDOFF            BIT0
@@ -2881,4 +2882,9 @@
 
 ///
+/// "PCCT" Platform Communications Channel Table
+///
+#define EFI_ACPI_6_2_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE  SIGNATURE_32('P', 'C', 'C', 'T')
+
+///
 /// "SDEI" Software Delegated Exceptions Interface Table
 ///
@@ -2891,5 +2897,5 @@
 
 ///
-/// "SPCR" Serial Port Concole Redirection Table
+/// "SPCR" Serial Port Console Redirection Table
 ///
 #define EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE  SIGNATURE_32('S', 'P', 'C', 'R')
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi63.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi63.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Acpi63.h	(revision 85718)
@@ -3,5 +3,5 @@
 
   Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
-  Copyright (c) 2019, ARM Ltd. All rights reserved.<BR>
+  Copyright (c) 2019 - 2020, ARM Ltd. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -2882,4 +2882,9 @@
 
 ///
+/// "PCCT" Platform Communications Channel Table
+///
+#define EFI_ACPI_6_3_PLATFORM_COMMUNICATIONS_CHANNEL_TABLE_SIGNATURE  SIGNATURE_32('P', 'C', 'C', 'T')
+
+///
 /// "SDEI" Software Delegated Exceptions Interface Table
 ///
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/AcpiAml.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/AcpiAml.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/AcpiAml.h	(revision 85718)
@@ -3,4 +3,5 @@
 
   Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2019, ARM Limited. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -31,4 +32,5 @@
 #define AML_VAR_PACKAGE_OP           0x13
 #define AML_METHOD_OP                0x14
+#define AML_EXTERNAL_OP              0x15
 #define AML_DUAL_NAME_PREFIX         0x2e
 #define AML_MULTI_NAME_PREFIX        0x2f
@@ -167,3 +169,11 @@
 #define AML_EXT_DATA_REGION_OP       0x88
 
+//
+// FieldElement OpCode
+//
+#define AML_FIELD_RESERVED_OP        0x00
+#define AML_FIELD_ACCESS_OP          0x01
+#define AML_FIELD_CONNECTION_OP      0x02
+#define AML_FIELD_EXT_ACCESS_OP      0x03
+
 #endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Atapi.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Atapi.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Atapi.h	(revision 85718)
@@ -485,5 +485,5 @@
 // ATA Packet Command Code
 //
-#define ATA_CMD_FORMAT_UNIT                             0x04   ///< defined in ATAPI Removable Rewritable Media Devcies
+#define ATA_CMD_FORMAT_UNIT                             0x04   ///< defined in ATAPI Removable Rewritable Media Devices
 #define ATA_CMD_SOFT_RESET                              0x08   ///< defined from ATA-3
 #define ATA_CMD_PACKET                                  0xA0   ///< defined from ATA-3
@@ -492,24 +492,24 @@
 #define ATA_CMD_TEST_UNIT_READY                         0x00   ///< defined from ATA-1
 #define ATA_CMD_REQUEST_SENSE                           0x03   ///< defined from ATA-4
-#define ATA_CMD_INQUIRY                                 0x12   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_READ_FORMAT_CAPACITY                    0x23   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_READ_CAPACITY                           0x25   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_READ_10                                 0x28   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_WRITE_10                                0x2A   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_ATAPI_SEEK                              0x2B   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_WRITE_AND_VERIFY                        0x2E   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_VERIFY                                  0x2F   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_READ_12                                 0xA8   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_WRITE_12                                0xAA   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_START_STOP_UNIT                         0x1B   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_PREVENT_ALLOW_MEDIA_REMOVAL             0x1E   ///< defined in ATAPI Removable Rewritable Media Devcies
-#define ATA_CMD_MODE_SELECT                             0x55   ///< defined in ATAPI Removable Rewritable Media Devcies
-
-#define ATA_CMD_MODE_SENSE                              0x5A   ///< defined in ATAPI Removable Rewritable Media Devcies
-    #define ATA_PAGE_CODE_READ_WRITE_ERROR                  0x01   ///< defined in ATAPI Removable Rewritable Media Devcies
-    #define ATA_PAGE_CODE_CACHING_PAGE                      0x08   ///< defined in ATAPI Removable Rewritable Media Devcies
-    #define ATA_PAGE_CODE_REMOVABLE_BLOCK_CAPABILITIES      0x1B   ///< defined in ATAPI Removable Rewritable Media Devcies
-    #define ATA_PAGE_CODE_TIMER_PROTECT_PAGE                0x1C   ///< defined in ATAPI Removable Rewritable Media Devcies
-    #define ATA_PAGE_CODE_RETURN_ALL_PAGES                  0x3F   ///< defined in ATAPI Removable Rewritable Media Devcies
+#define ATA_CMD_INQUIRY                                 0x12   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_READ_FORMAT_CAPACITY                    0x23   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_READ_CAPACITY                           0x25   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_READ_10                                 0x28   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_WRITE_10                                0x2A   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_ATAPI_SEEK                              0x2B   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_WRITE_AND_VERIFY                        0x2E   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_VERIFY                                  0x2F   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_READ_12                                 0xA8   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_WRITE_12                                0xAA   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_START_STOP_UNIT                         0x1B   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_PREVENT_ALLOW_MEDIA_REMOVAL             0x1E   ///< defined in ATAPI Removable Rewritable Media Devices
+#define ATA_CMD_MODE_SELECT                             0x55   ///< defined in ATAPI Removable Rewritable Media Devices
+
+#define ATA_CMD_MODE_SENSE                              0x5A   ///< defined in ATAPI Removable Rewritable Media Devices
+    #define ATA_PAGE_CODE_READ_WRITE_ERROR                  0x01   ///< defined in ATAPI Removable Rewritable Media Devices
+    #define ATA_PAGE_CODE_CACHING_PAGE                      0x08   ///< defined in ATAPI Removable Rewritable Media Devices
+    #define ATA_PAGE_CODE_REMOVABLE_BLOCK_CAPABILITIES      0x1B   ///< defined in ATAPI Removable Rewritable Media Devices
+    #define ATA_PAGE_CODE_TIMER_PROTECT_PAGE                0x1C   ///< defined in ATAPI Removable Rewritable Media Devices
+    #define ATA_PAGE_CODE_RETURN_ALL_PAGES                  0x3F   ///< defined in ATAPI Removable Rewritable Media Devices
 
 #define ATA_CMD_GET_CONFIGURATION                       0x46   ///< defined in ATAPI Multimedia Devices
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Dhcp.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Dhcp.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Dhcp.h	(revision 85718)
@@ -4,4 +4,5 @@
 
   Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -267,4 +268,7 @@
 #define PXE_CLIENT_ARCH_ARM              0x000A    /// Arm uefi 32 for PXE
 #define PXE_CLIENT_ARCH_AARCH64          0x000B    /// Arm uefi 64 for PXE
+#define PXE_CLIENT_ARCH_RISCV32          0x0019    /// RISC-V uefi 32 for PXE
+#define PXE_CLIENT_ARCH_RISCV64          0x001B    /// RISC-V uefi 64 for PXE
+#define PXE_CLIENT_ARCH_RISCV128         0x001D    /// RISC-V uefi 128 for PXE
 
 #define HTTP_CLIENT_ARCH_IA32            0x000F    /// x86 uefi boot from http
@@ -273,4 +277,7 @@
 #define HTTP_CLIENT_ARCH_ARM             0x0012    /// Arm uefi 32 boot from http
 #define HTTP_CLIENT_ARCH_AARCH64         0x0013    /// Arm uefi 64 boot from http
+#define HTTP_CLIENT_ARCH_RISCV32         0x001A    /// RISC-V uefi 32 boot from http
+#define HTTP_CLIENT_ARCH_RISCV64         0x001C    /// RISC-V uefi 64 boot from http
+#define HTTP_CLIENT_ARCH_RISCV128        0x001E    /// RISC-V uefi 128 boot from http
 
 #endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/ElTorito.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/ElTorito.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/ElTorito.h	(revision 85718)
@@ -1,5 +1,5 @@
 /** @file
   ElTorito Partitions Format Definition.
-  This file includes some defintions from
+  This file includes some definitions from
   1. "El Torito" Bootable CD-ROM Format Specification, Version 1.0.
   2. Volume and File Structure of CDROM for Information Interchange,
@@ -76,5 +76,5 @@
 
   ///
-  /// Primary Volumn Descriptor, defined in ISO 9660.
+  /// Primary Volume Descriptor, defined in ISO 9660.
   ///
   struct {
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Emmc.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Emmc.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Emmc.h	(revision 85718)
@@ -225,5 +225,5 @@
   UINT8   Reserved17;                             // Reserved [211]
   UINT8   SecCount[4];                            // Sector Count [215:212]
-  UINT8   SleepNotificationTime;                  // Sleep Notification Timout [216]
+  UINT8   SleepNotificationTime;                  // Sleep Notification Timeout [216]
   UINT8   SATimeout;                              // Sleep/awake timeout [217]
   UINT8   ProductionStateAwarenessTimeout;        // Production state awareness timeout [218]
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/IpmiNetFnBridge.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/IpmiNetFnBridge.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/IpmiNetFnBridge.h	(revision 85718)
@@ -128,10 +128,10 @@
 
 //
-//  Definitions for Prepare for Discoveery command
+//  Definitions for Prepare for Discovery command
 //
 #define IPMI_BRIDGE_PREPARE_FOR_DISCOVERY  0x10
 
 //
-//  Constants and Structure definitions for "Prepare for Discoveery" command to follow here
+//  Constants and Structure definitions for "Prepare for Discovery" command to follow here
 //
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Nvme.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Nvme.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Nvme.h	(revision 85718)
@@ -310,9 +310,9 @@
   UINT8  Rrt:5;             /* Relative Read Throughput */
   UINT8  Rsvd3:3;           /* Reserved as of Nvm Express 1.1 Spec */
-  UINT8  Rrl:5;             /* Relative Read Leatency */
+  UINT8  Rrl:5;             /* Relative Read Latency */
   UINT8  Rsvd4:3;           /* Reserved as of Nvm Express 1.1 Spec */
   UINT8  Rwt:5;             /* Relative Write Throughput */
   UINT8  Rsvd5:3;           /* Reserved as of Nvm Express 1.1 Spec */
-  UINT8  Rwl:5;             /* Relative Write Leatency */
+  UINT8  Rwl:5;             /* Relative Write Latency */
   UINT8  Rsvd6:3;           /* Reserved as of Nvm Express 1.1 Spec */
   UINT8  Rsvd7[16];         /* Reserved as of Nvm Express 1.1 Spec */
@@ -330,5 +330,5 @@
   UINT8  Sn[20];              /* Product serial number */
 
-  UINT8  Mn[40];              /* Proeduct model number */
+  UINT8  Mn[40];              /* Product model number */
   UINT8  Fr[8];               /* Firmware Revision */
   UINT8  Rab;                 /* Recommended Arbitration Burst */
@@ -658,5 +658,5 @@
 typedef struct {
   //
-  // CDW 0, Common to all comnmands
+  // CDW 0, Common to all commands
   //
   UINT8  Opc;               // Opcode
@@ -870,5 +870,5 @@
   UINT8  AvailableSpareThreshold;
   //
-  // Contains a vendor specific estimate of the percentage of NVM subsystem life used based on the actual usage and the manufacturer?s prediction of NVM life. A value of 100 indicates that the estimated endurance of the NVM in the NVM subsystem has been consumed, but may not indicate an NVM subsystem failure. The value is allowed to exceed 100. Percentages greater than 254 shall be represented as 255. This value shall be updated once per power-on hour (when the controller is not in a sleep state).
+  // Contains a vendor specific estimate of the percentage of NVM subsystem life used based on the actual usage and the manufacturer's prediction of NVM life. A value of 100 indicates that the estimated endurance of the NVM in the NVM subsystem has been consumed, but may not indicate an NVM subsystem failure. The value is allowed to exceed 100. Percentages greater than 254 shall be represented as 255. This value shall be updated once per power-on hour (when the controller is not in a sleep state).
   //
   UINT8  PercentageUsed;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Pci22.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Pci22.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Pci22.h	(revision 85718)
@@ -6,5 +6,5 @@
     PCI-to-PCI Bridge Architecture Specification, Revision 1.2
     PC Card Standard, 8.0
-    PCI Power Management Interface Specifiction, Revision 1.2
+    PCI Power Management Interface Specification, Revision 1.2
 
   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
@@ -112,9 +112,9 @@
 
 ///
-/// CardBus Conroller Configuration Space,
+/// CardBus Controller Configuration Space,
 /// Section 4.5.1, PC Card Standard. 8.0
 ///
 typedef struct {
-  UINT32  CardBusSocketReg;     ///< Cardus Socket/ExCA Base
+  UINT32  CardBusSocketReg;     ///< Cardbus Socket/ExCA Base
   UINT8   Cap_Ptr;
   UINT8   Reserved;
@@ -223,5 +223,5 @@
 #define     PCI_IF_ISA_PIC                0x01
 #define     PCI_IF_EISA_PIC               0x02
-#define     PCI_IF_APIC_CONTROLLER        0x10  ///< I/O APIC interrupt controller , 32 bye none-prefectable memory.
+#define     PCI_IF_APIC_CONTROLLER        0x10  ///< I/O APIC interrupt controller , 32 byte none-prefetchable memory.
 #define     PCI_IF_APIC_CONTROLLER2       0x20
 #define   PCI_SUBCLASS_DMA              0x01
@@ -510,5 +510,5 @@
 
 ///
-/// Rom Base Address in Bridge, defined in PCI-to-PCI Bridge Architecure Specification,
+/// Rom Base Address in Bridge, defined in PCI-to-PCI Bridge Architecture Specification,
 ///
 #define PCI_BRIDGE_ROMBAR             0x38
@@ -643,5 +643,5 @@
 ///
 /// PMC - Power Management Capabilities
-/// Section 3.2.3, PCI Power Management Interface Specifiction, Revision 1.2
+/// Section 3.2.3, PCI Power Management Interface Specification, Revision 1.2
 ///
 typedef union {
@@ -663,5 +663,5 @@
 ///
 /// PMCSR - Power Management Control/Status
-/// Section 3.2.4, PCI Power Management Interface Specifiction, Revision 1.2
+/// Section 3.2.4, PCI Power Management Interface Specification, Revision 1.2
 ///
 typedef union {
@@ -686,5 +686,5 @@
 ///
 /// PMCSR_BSE - PMCSR PCI-to-PCI Bridge Support Extensions
-/// Section 3.2.5, PCI Power Management Interface Specifiction, Revision 1.2
+/// Section 3.2.5, PCI Power Management Interface Specification, Revision 1.2
 ///
 typedef union {
@@ -699,5 +699,5 @@
 ///
 /// Power Management Register Block Definition
-/// Section 3.2, PCI Power Management Interface Specifiction, Revision 1.2
+/// Section 3.2, PCI Power Management Interface Specification, Revision 1.2
 ///
 typedef struct {
@@ -733,5 +733,5 @@
 ///
 /// Slot Numbering Capabilities Register
-/// Section 3.2.6, PCI-to-PCI Bridge Architeture Specification, Revision 1.2
+/// Section 3.2.6, PCI-to-PCI Bridge Architecture Specification, Revision 1.2
 ///
 typedef struct {
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress21.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress21.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress21.h	(revision 85718)
@@ -305,5 +305,5 @@
     UINT16 IdoRequest : 1;
     UINT16 IdoCompletion : 1;
-    UINT16 LtrMechanism : 2;
+    UINT16 LtrMechanism : 1;
     UINT16 EmergencyPowerReductionRequest : 1;
     UINT16 TenBitTagRequesterEnable : 1;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress40.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress40.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress40.h	(revision 85718)
@@ -5,4 +5,5 @@
 
 Copyright (c) 2018, American Megatrends, Inc. All rights reserved.<BR>
+Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -79,4 +80,31 @@
 ///@}
 
+/// The Designated Vendor Specific Capability definitions
+/// Based on section 7.9.6 of PCI Express Base Specification 4.0.
+///@{
+typedef union {
+  struct {
+    UINT32 DvsecVendorId                                        : 16; //bit 0..15
+    UINT32 DvsecRevision                                        : 4;  //bit 16..19
+    UINT32 DvsecLength                                          : 12; //bit 20..31
+  }Bits;
+  UINT32                                                        Uint32;
+}PCI_EXPRESS_DESIGNATED_VENDOR_SPECIFIC_HEADER_1;
+
+typedef union {
+  struct {
+    UINT16 DvsecId                                              : 16; //bit 0..15
+  }Bits;
+  UINT16                                                        Uint16;
+}PCI_EXPRESS_DESIGNATED_VENDOR_SPECIFIC_HEADER_2;
+
+typedef struct {
+  PCI_EXPRESS_EXTENDED_CAPABILITIES_HEADER                      Header;
+  PCI_EXPRESS_DESIGNATED_VENDOR_SPECIFIC_HEADER_1               DesignatedVendorSpecificHeader1;
+  PCI_EXPRESS_DESIGNATED_VENDOR_SPECIFIC_HEADER_2               DesignatedVendorSpecificHeader2;
+  UINT8                                                         DesignatedVendorSpecific[1];
+}PCI_EXPRESS_EXTENDED_CAPABILITIES_DESIGNATED_VENDOR_SPECIFIC;
+///@}
+
 #pragma pack()
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress50.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress50.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PciExpress50.h	(revision 85718)
@@ -0,0 +1,136 @@
+/** @file
+Support for the PCI Express 5.0 standard.
+
+This header file may not define all structures.  Please extend as required.
+
+Copyright (c) 2020, American Megatrends International LLC. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PCIEXPRESS50_H_
+#define _PCIEXPRESS50_H_
+
+#include <IndustryStandard/PciExpress40.h>
+
+#pragma pack(1)
+
+/// The Physical Layer PCI Express Extended Capability definitions.
+///
+/// Based on section 7.7.6 of PCI Express Base Specification 5.0.
+///@{
+#define PCI_EXPRESS_EXTENDED_CAPABILITY_PHYSICAL_LAYER_32_0_ID    0x002A
+#define PCI_EXPRESS_EXTENDED_CAPABILITY_PHYSICAL_LAYER_32_0_VER1  0x1
+
+// Register offsets from Physical Layer PCI-E Ext Cap Header
+#define PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_CAPABILITIES_OFFSET                         0x04
+#define PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_CONTROL_OFFSET                              0x08
+#define PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_STATUS_OFFSET                               0x0C
+#define PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_RCVD_MODIFIED_TS_DATA1_OFFSET               0x10
+#define PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_RCVD_MODIFIED_TS_DATA2_OFFSET               0x14
+#define PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_TRANS_MODIFIED_TS_DATA1_OFFSET              0x18
+#define PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_TRANS_MODIFIED_TS_DATA2_OFFSET              0x1C
+#define PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_LANE_EQUALIZATION_CONTROL_OFFSET            0x20
+
+typedef union {
+  struct {
+    UINT32 EqualizationByPassToHighestRateSupport                  : 1; // bit 0
+    UINT32 NoEqualizationNeededSupport                             : 1; // bit 1
+    UINT32 Reserved1                                               : 6; // Reserved bit 2:7
+    UINT32 ModifiedTSUsageMode0Support                             : 1; // bit 8
+    UINT32 ModifiedTSUsageMode1Support                             : 1; // bit 9
+    UINT32 ModifiedTSUsageMode2Support                             : 1; // bit 10
+    UINT32 ModifiedTSReservedUsageModes                            : 5; // bit 11:15
+    UINT32 Reserved2                                               : 16; // Reserved bit 16:31
+  } Bits;
+  UINT32   Uint32;
+} PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_CAPABILITIES;
+
+typedef union {
+  struct {
+    UINT32 EqualizationByPassToHighestRateDisable                  : 1; // bit 0
+    UINT32 NoEqualizationNeededDisable                             : 1; // bit 1
+    UINT32 Reserved1                                               : 6; // Reserved bit 2:7
+    UINT32 ModifiedTSUsageModeSelected                             : 3; // bit 8:10
+    UINT32 Reserved2                                               : 21; // Reserved bit 11:31
+  } Bits;
+  UINT32   Uint32;
+} PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_CONTROL;
+
+typedef union {
+  struct {
+    UINT32 EqualizationComplete      : 1; // bit 0
+    UINT32 EqualizationPhase1Success : 1; // bit 1
+    UINT32 EqualizationPhase2Success : 1; // bit 2
+    UINT32 EqualizationPhase3Success : 1; // bit 3
+    UINT32 LinkEqualizationRequest   : 1; // bit 4
+    UINT32 ModifiedTSRcvd            : 1; // bit 5
+    UINT32 RcvdEnhancedLinkControl   : 2; // bit 6:7
+    UINT32 TransmitterPrecodingOn    : 1; // bit 8
+    UINT32 TransmitterPrecodeRequest : 1; // bit 9
+    UINT32 NoEqualizationNeededRcvd  : 1; // bit 10
+    UINT32 Reserved                  : 21; // Reserved bit 11:31
+  } Bits;
+  UINT32   Uint32;
+} PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_STATUS;
+
+typedef union {
+  struct {
+    UINT32 RcvdModifiedTSUsageMode   : 3; // bit 0:2
+    UINT32 RcvdModifiedTSUsageInfo1  : 13; // bit 3:15
+    UINT32 RcvdModifiedTSVendorId    : 16; // bit 16:31
+  } Bits;
+  UINT32   Uint32;
+} PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_RCVD_MODIFIED_TS_DATA1;
+
+typedef union {
+  struct {
+    UINT32 RcvdModifiedTSUsageInfo2     : 24; // bit 0:23
+    UINT32 AltProtocolNegotiationStatus : 2; // bit 24:25
+    UINT32 Reserved                     : 6; // Reserved bit 26:31
+  } Bits;
+  UINT32   Uint32;
+} PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_RCVD_MODIFIED_TS_DATA2;
+
+typedef union {
+  struct {
+    UINT32 TransModifiedTSUsageMode   : 3; // bit 0:2
+    UINT32 TransModifiedTSUsageInfo1  : 13; // bit 3:15
+    UINT32 TransModifiedTSVendorId    : 16; // bit 16:31
+  } Bits;
+  UINT32   Uint32;
+} PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_TRANS_MODIFIED_TS_DATA1;
+
+typedef union {
+  struct {
+    UINT32 TransModifiedTSUsageInfo2    : 24; // bit 0:23
+    UINT32 AltProtocolNegotiationStatus : 2; // bit 24:25
+    UINT32 Reserved                     : 6; // Reserved bit 26:31
+  } Bits;
+  UINT32   Uint32;
+} PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_TRANS_MODIFIED_TS_DATA2;
+
+typedef union {
+  struct {
+    UINT8 DownstreamPortTransmitterPreset : 4; //bit 0..3
+    UINT8 UpstreamPortTransmitterPreset   : 4; //bit 4..7
+  } Bits;
+  UINT8   Uint8;
+} PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_LANE_EQUALIZATION_CONTROL;
+
+typedef struct {
+  PCI_EXPRESS_EXTENDED_CAPABILITIES_HEADER                      Header;
+  PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_CAPABILITIES              Capablities;
+  PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_CONTROL                   Control;
+  PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_STATUS                    Status;
+  PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_RCVD_MODIFIED_TS_DATA1    RcvdModifiedTs1Data;
+  PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_RCVD_MODIFIED_TS_DATA2    RcvdModifiedTs2Data;
+  PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_TRANS_MODIFIED_TS_DATA1   TransModifiedTs1Data;
+  PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_TRANS_MODIFIED_TS_DATA2   TransModifiedTs2Data;
+  PCI_EXPRESS_REG_PHYSICAL_LAYER_32_0_LANE_EQUALIZATION_CONTROL LaneEqualizationControl[1];
+} PCI_EXPRESS_EXTENDED_CAPABILITIES_PHYSICAL_LAYER_32_0;
+///@}
+
+#pragma pack()
+
+#endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PeImage.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PeImage.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/PeImage.h	(revision 85718)
@@ -10,4 +10,6 @@
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+Portions Copyright (c) 2016 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -35,4 +37,7 @@
 #define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED  0x01c2
 #define IMAGE_FILE_MACHINE_ARM64           0xAA64
+#define IMAGE_FILE_MACHINE_RISCV32         0x5032
+#define IMAGE_FILE_MACHINE_RISCV64         0x5064
+#define IMAGE_FILE_MACHINE_RISCV128        0x5128
 
 //
@@ -93,5 +98,5 @@
 #define EFI_IMAGE_FILE_RELOCS_STRIPPED      BIT0     ///< 0x0001  Relocation info stripped from file.
 #define EFI_IMAGE_FILE_EXECUTABLE_IMAGE     BIT1     ///< 0x0002  File is executable  (i.e. no unresolved externel references).
-#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   BIT2     ///< 0x0004  Line nunbers stripped from file.
+#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED   BIT2     ///< 0x0004  Line numbers stripped from file.
 #define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED  BIT3     ///< 0x0008  Local symbols stripped from file.
 #define EFI_IMAGE_FILE_BYTES_REVERSED_LO    BIT7     ///< 0x0080  Bytes of machine word are reversed.
@@ -495,4 +500,11 @@
 
 ///
+/// Relocation types of RISC-V processor.
+///
+#define EFI_IMAGE_REL_BASED_RISCV_HI20      5
+#define EFI_IMAGE_REL_BASED_RISCV_LOW12I    7
+#define EFI_IMAGE_REL_BASED_RISCV_LOW12S    8
+
+///
 /// Line number format.
 ///
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Scsi.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Scsi.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Scsi.h	(revision 85718)
@@ -2,5 +2,5 @@
   Support for SCSI-2 standard
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -155,5 +155,5 @@
 
 //
-// Additional commands for Communition Devices
+// Additional commands for Communication Devices
 //
 #define EFI_SCSI_OP_GET_MESSAGE6    0x08
@@ -165,4 +165,10 @@
 
 //
+// Additional commands for Secure Transactions
+//
+#define EFI_SCSI_OP_SECURITY_PROTOCOL_IN  0xa2
+#define EFI_SCSI_OP_SECURITY_PROTOCOL_OUT 0xb5
+
+//
 // SCSI Data Transfer Direction
 //
@@ -171,22 +177,36 @@
 
 //
+// SCSI Block Command Cache Control Parameters
+//
+#define EFI_SCSI_BLOCK_FUA  BIT3  ///< Force Unit Access
+#define EFI_SCSI_BLOCK_DPO  BIT4  ///< Disable Page Out
+
+//
 // Peripheral Device Type Definitions
 //
-#define EFI_SCSI_TYPE_DISK          0x00  ///< Direct-access device (e.g. magnetic disk)
-#define EFI_SCSI_TYPE_TAPE          0x01  ///< Sequential-access device (e.g. magnetic tape)
-#define EFI_SCSI_TYPE_PRINTER       0x02  ///< Printer device
-#define EFI_SCSI_TYPE_PROCESSOR     0x03  ///< Processor device
-#define EFI_SCSI_TYPE_WORM          0x04  ///< Write-once device (e.g. some optical disks)
-#define EFI_SCSI_TYPE_CDROM         0x05  ///< CD-ROM device
-#define EFI_SCSI_TYPE_SCANNER       0x06  ///< Scanner device
-#define EFI_SCSI_TYPE_OPTICAL       0x07  ///< Optical memory device (e.g. some optical disks)
-#define EFI_SCSI_TYPE_MEDIUMCHANGER 0x08  ///< Medium changer device (e.g. jukeboxes)
-#define EFI_SCSI_TYPE_COMMUNICATION 0x09  ///< Communications device
-#define EFI_SCSI_TYPE_ASCIT8_1      0x0A  ///< Defined by ASC IT8 (Graphic arts pre-press devices)
-#define EFI_SCSI_TYPE_ASCIT8_2      0x0B  ///< Defined by ASC IT8 (Graphic arts pre-press devices)
-//
-// 0Ch - 1Eh are reserved
-//
-#define EFI_SCSI_TYPE_UNKNOWN       0x1F  ///< Unknown or no device type
+#define EFI_SCSI_TYPE_DISK            0x00  ///< Direct-access device (e.g. magnetic disk)
+#define EFI_SCSI_TYPE_TAPE            0x01  ///< Sequential-access device (e.g. magnetic tape)
+#define EFI_SCSI_TYPE_PRINTER         0x02  ///< Printer device
+#define EFI_SCSI_TYPE_PROCESSOR       0x03  ///< Processor device
+#define EFI_SCSI_TYPE_WORM            0x04  ///< Write-once device (e.g. some optical disks)
+#define EFI_SCSI_TYPE_CDROM           0x05  ///< CD/DVD device
+#define EFI_SCSI_TYPE_SCANNER         0x06  ///< Scanner device (obsolete)
+#define EFI_SCSI_TYPE_OPTICAL         0x07  ///< Optical memory device (e.g. some optical disks)
+#define EFI_SCSI_TYPE_MEDIUMCHANGER   0x08  ///< Medium changer device (e.g. jukeboxes)
+#define EFI_SCSI_TYPE_COMMUNICATION   0x09  ///< Communications device (obsolete)
+#define EFI_SCSI_TYPE_ASCIT8_1        0x0A  ///< Defined by ASC IT8 (Graphic arts pre-press devices)
+#define EFI_SCSI_TYPE_ASCIT8_2        0x0B  ///< Defined by ASC IT8 (Graphic arts pre-press devices)
+#define EFI_SCSI_TYPE_RAID            0x0C  ///< Storage array controller device (e.g., RAID)
+#define EFI_SCSI_TYPE_SES             0x0D  ///< Enclosure services device
+#define EFI_SCSI_TYPE_RBC             0x0E  ///< Simplified direct-access device (e.g., magnetic disk)
+#define EFI_SCSI_TYPE_OCRW            0x0F  ///< Optical card reader/writer device
+#define EFI_SCSI_TYPE_BRIDGE          0x10  ///< Bridge Controller Commands
+#define EFI_SCSI_TYPE_OSD             0x11  ///< Object-based Storage Device
+#define EFI_SCSI_TYPE_AUTOMATION      0x12  ///< Automation/Drive Interface
+#define EFI_SCSI_TYPE_SECURITYMANAGER 0x13  ///< Security manager device
+#define EFI_SCSI_TYPE_RESERVED_LOW    0x14  ///< Reserved (low)
+#define EFI_SCSI_TYPE_RESERVED_HIGH   0x1D  ///< Reserved (high)
+#define EFI_SCSI_TYPE_WLUN            0x1E  ///< Well known logical unit
+#define EFI_SCSI_TYPE_UNKNOWN         0x1F  ///< Unknown or no device type
 
 //
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SerialPortConsoleRedirectionTable.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SerialPortConsoleRedirectionTable.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SerialPortConsoleRedirectionTable.h	(revision 85718)
@@ -91,4 +91,14 @@
 #define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_ARM_SBSA_GENERIC_UART     0x0e
 
+///
+/// ARM DCC
+///
+#define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_DCC                       0x0f
+
+///
+/// BCM2835 UART
+///
+#define EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_BCM2835_UART              0x10
+
 //
 // Interrupt Type
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SmBios.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SmBios.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SmBios.h	(revision 85718)
@@ -1,7 +1,8 @@
 /** @file
-  Industry Standard Definitions of SMBIOS Table Specification v3.2.0.
-
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Industry Standard Definitions of SMBIOS Table Specification v3.3.0.
+
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
 (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP<BR>
+(C) Copyright 2015 - 2019 Hewlett Packard Enterprise Development LP<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -47,5 +48,5 @@
 
 //
-// SMBIOS type macros which is according to SMBIOS 2.7 specification.
+// SMBIOS type macros which is according to SMBIOS 3.3.0 specification.
 //
 #define SMBIOS_TYPE_BIOS_INFORMATION                     0
@@ -93,4 +94,5 @@
 #define SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE 42
 #define SMBIOS_TYPE_TPM_DEVICE                           43
+#define SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION     44
 
 ///
@@ -728,5 +730,8 @@
   ProcessorFamilyWinChip               = 0x0140,
   ProcessorFamilyDSP                   = 0x015E,
-  ProcessorFamilyVideoProcessor        = 0x01F4
+  ProcessorFamilyVideoProcessor        = 0x01F4,
+  ProcessorFamilyRiscvRV32             = 0x0200,
+  ProcessorFamilyRiscVRV64             = 0x0201,
+  ProcessorFamilyRiscVRV128            = 0x0202
 } PROCESSOR_FAMILY2_DATA;
 
@@ -858,4 +863,17 @@
 
 typedef struct {
+  UINT32  ProcessorReserved1             :1;
+  UINT32  ProcessorUnknown               :1;
+  UINT32  Processor64BitCapble           :1;
+  UINT32  ProcessorMultiCore             :1;
+  UINT32  ProcessorHardwareThread        :1;
+  UINT32  ProcessorExecuteProtection     :1;
+  UINT32  ProcessorEnhancedVirtulization :1;
+  UINT32  ProcessorPowerPerformanceCtrl  :1;
+  UINT32  Processor128bitCapble          :1;
+  UINT32  ProcessorReserved2             :7;
+} PROCESSOR_CHARACTERISTIC_FLAGS;
+
+typedef struct {
   PROCESSOR_SIGNATURE     Signature;
   PROCESSOR_FEATURE_FLAGS FeatureFlags;
@@ -1268,4 +1286,5 @@
   SlotTypePciExpressMini52pinWithoutBSKO = 0x22,    ///< PCI Express Mini 52-pin (CEM spec. 2.0) without bottom-side keep-outs.
   SlotTypePciExpressMini76pin          = 0x23,      ///< PCI Express Mini 76-pin (CEM spec. 2.0) Corresponds to Display-Mini card.
+  SlotTypeCXLFlexbus10                 = 0x30,
   SlotTypePC98C20                      = 0xA0,
   SlotTypePC98C24                      = 0xA1,
@@ -1290,5 +1309,11 @@
   SlotTypePciExpressGen3X4             = 0xB4,
   SlotTypePciExpressGen3X8             = 0xB5,
-  SlotTypePciExpressGen3X16            = 0xB6
+  SlotTypePciExpressGen3X16            = 0xB6,
+  SlotTypePciExpressGen4               = 0xB8,
+  SlotTypePciExpressGen4X1             = 0xB9,
+  SlotTypePciExpressGen4X2             = 0xBA,
+  SlotTypePciExpressGen4X4             = 0xBB,
+  SlotTypePciExpressGen4X8             = 0xBC,
+  SlotTypePciExpressGen4X16            = 0xBD
 } MISC_SLOT_TYPE;
 
@@ -1589,5 +1614,6 @@
   MemoryArrayLocationPc98C24AddonCard      = 0xA1,
   MemoryArrayLocationPc98EAddonCard        = 0xA2,
-  MemoryArrayLocationPc98LocalBusAddonCard = 0xA3
+  MemoryArrayLocationPc98LocalBusAddonCard = 0xA3,
+  MemoryArrayLocationCXLFlexbus10AddonCard = 0xA4
 } MEMORY_ARRAY_LOCATION;
 
@@ -1656,5 +1682,6 @@
   MemoryFormFactorSodimm                   = 0x0D,
   MemoryFormFactorSrimm                    = 0x0E,
-  MemoryFormFactorFbDimm                   = 0x0F
+  MemoryFormFactorFbDimm                   = 0x0F,
+  MemoryFormFactorDie                      = 0x10
 } MEMORY_FORM_FACTOR;
 
@@ -1690,5 +1717,7 @@
   MemoryTypeLpddr3                         = 0x1D,
   MemoryTypeLpddr4                         = 0x1E,
-  MemoryTypeLogicalNonVolatileDevice       = 0x1F
+  MemoryTypeLogicalNonVolatileDevice       = 0x1F,
+  MemoryTypeHBM                            = 0x20,
+  MemoryTypeHBM2                           = 0x21
 } MEMORY_DEVICE_TYPE;
 
@@ -1725,4 +1754,8 @@
   MemoryTechnologyNvdimmF                   = 0x05,
   MemoryTechnologyNvdimmP                   = 0x06,
+  //
+  // This definition is updated to represent Intel
+  // Optane DC Presistent Memory in SMBIOS spec 3.3.0
+  //
   MemoryTechnologyIntelPersistentMemory     = 0x07
 } MEMORY_DEVICE_TECHNOLOGY;
@@ -1811,4 +1844,9 @@
   UINT64                                    CacheSize;
   UINT64                                    LogicalSize;
+  //
+  // Add for smbios 3.3.0
+  //
+  UINT32                                    ExtendedSpeed;
+  UINT32                                    ExtendedConfiguredMemorySpeed;
 } SMBIOS_TABLE_TYPE17;
 
@@ -2508,4 +2546,55 @@
   UINT8                             InterfaceTypeSpecificData[4];   ///< This field has a minimum of four bytes
 } SMBIOS_TABLE_TYPE42;
+
+
+///
+/// Processor Specific Block - Processor Architecture Type
+///
+typedef enum{
+  ProcessorSpecificBlockArchTypeReserved   = 0x00,
+  ProcessorSpecificBlockArchTypeIa32       = 0x01,
+  ProcessorSpecificBlockArchTypeX64        = 0x02,
+  ProcessorSpecificBlockArchTypeItanium    = 0x03,
+  ProcessorSpecificBlockArchTypeAarch32    = 0x04,
+  ProcessorSpecificBlockArchTypeAarch64    = 0x05,
+  ProcessorSpecificBlockArchTypeRiscVRV32  = 0x06,
+  ProcessorSpecificBlockArchTypeRiscVRV64  = 0x07,
+  ProcessorSpecificBlockArchTypeRiscVRV128 = 0x08
+} PROCESSOR_SPECIFIC_BLOCK_ARCH_TYPE;
+
+///
+/// Processor Specific Block is the standard container of processor-specific data.
+///
+typedef struct {
+  UINT8                              Length;
+  UINT8                              ProcessorArchType;
+  ///
+  /// Below followed by Processor-specific data
+  ///
+  ///
+} PROCESSOR_SPECIFIC_BLOCK;
+
+///
+/// Processor Additional Information(Type 44).
+///
+/// The information in this structure defines the processor additional information in case
+/// SMBIOS type 4 is not sufficient to describe processor characteristics.
+/// The SMBIOS type 44 structure has a reference handle field to link back to the related
+/// SMBIOS type 4 structure. There may be multiple SMBIOS type 44 structures linked to the
+/// same SMBIOS type 4 structure. For example, when cores are not identical in a processor,
+/// SMBIOS type 44 structures describe different core-specific information.
+///
+/// SMBIOS type 44 defines the standard header for the processor-specific block, while the
+/// contents of processor-specific data are maintained by processor
+/// architecture workgroups or vendors in separate documents.
+///
+typedef struct {
+  SMBIOS_STRUCTURE                  Hdr;
+  SMBIOS_HANDLE                     RefHandle;                 ///< This field refer to associated SMBIOS type 4
+  ///
+  /// Below followed by Processor-specific block
+  ///
+  PROCESSOR_SPECIFIC_BLOCK          ProcessorSpecificBlock;
+} SMBIOS_TABLE_TYPE44;
 
 ///
@@ -2587,4 +2676,5 @@
   SMBIOS_TABLE_TYPE42   *Type42;
   SMBIOS_TABLE_TYPE43   *Type43;
+  SMBIOS_TABLE_TYPE44   *Type44;
   SMBIOS_TABLE_TYPE126  *Type126;
   SMBIOS_TABLE_TYPE127  *Type127;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SmBus.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SmBus.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/SmBus.h	(revision 85718)
@@ -1,4 +1,4 @@
 /** @file
-  This file declares the SMBus definitions defined in SmBus Specifciation V2.0
+  This file declares the SMBus definitions defined in SmBus Specification V2.0
   and defined in PI1.0 specification volume 5.
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Spdm.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Spdm.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Spdm.h	(revision 85718)
@@ -0,0 +1,320 @@
+/** @file
+  Definitions of Security Protocol & Data Model Specification (SPDM)
+  version 1.0.0 in Distributed Management Task Force (DMTF).
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#ifndef __SPDM_H__
+#define __SPDM_H__
+
+#pragma pack(1)
+
+///
+/// SPDM response code
+///
+#define SPDM_DIGESTS               0x01
+#define SPDM_CERTIFICATE           0x02
+#define SPDM_CHALLENGE_AUTH        0x03
+#define SPDM_VERSION               0x04
+#define SPDM_MEASUREMENTS          0x60
+#define SPDM_CAPABILITIES          0x61
+#define SPDM_SET_CERT_RESPONSE     0x62
+#define SPDM_ALGORITHMS            0x63
+#define SPDM_ERROR                 0x7F
+///
+/// SPDM request code
+///
+#define SPDM_GET_DIGESTS           0x81
+#define SPDM_GET_CERTIFICATE       0x82
+#define SPDM_CHALLENGE             0x83
+#define SPDM_GET_VERSION           0x84
+#define SPDM_GET_MEASUREMENTS      0xE0
+#define SPDM_GET_CAPABILITIES      0xE1
+#define SPDM_NEGOTIATE_ALGORITHMS  0xE3
+#define SPDM_RESPOND_IF_READY      0xFF
+
+///
+/// SPDM message header
+///
+typedef struct {
+  UINT8   SPDMVersion;
+  UINT8   RequestResponseCode;
+  UINT8   Param1;
+  UINT8   Param2;
+} SPDM_MESSAGE_HEADER;
+
+#define SPDM_MESSAGE_VERSION  0x10
+
+///
+/// SPDM GET_VERSION request
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+} SPDM_GET_VERSION_REQUEST;
+
+///
+/// SPDM GET_VERSION response
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT8                Reserved;
+  UINT8                VersionNumberEntryCount;
+//SPDM_VERSION_NUMBER  VersionNumberEntry[VersionNumberEntryCount];
+} SPDM_VERSION_RESPONSE;
+
+///
+/// SPDM VERSION structure
+///
+typedef struct {
+  UINT16               Alpha:4;
+  UINT16               UpdateVersionNumber:4;
+  UINT16               MinorVersion:4;
+  UINT16               MajorVersion:4;
+} SPDM_VERSION_NUMBER;
+
+///
+/// SPDM GET_CAPABILITIES request
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+} SPDM_GET_CAPABILITIES_REQUEST;
+
+///
+/// SPDM GET_CAPABILITIES response
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT8                Reserved;
+  UINT8                CTExponent;
+  UINT16               Reserved2;
+  UINT32               Flags;
+} SPDM_CAPABILITIES_RESPONSE;
+
+///
+/// SPDM GET_CAPABILITIES response Flags
+///
+#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP       BIT0
+#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP        BIT1
+#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP        BIT2
+#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP        (BIT3 | BIT4)
+#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_NO_SIG   BIT3
+#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG      BIT4
+#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP  BIT5
+
+///
+/// SPDM NEGOTIATE_ALGORITHMS request
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT16               Length;
+  UINT8                MeasurementSpecification;
+  UINT8                Reserved;
+  UINT32               BaseAsymAlgo;
+  UINT32               BaseHashAlgo;
+  UINT8                Reserved2[12];
+  UINT8                ExtAsymCount;
+  UINT8                ExtHashCount;
+  UINT16               Reserved3;
+//UINT32               ExtAsym[ExtAsymCount];
+//UINT32               ExtHash[ExtHashCount];
+} SPDM_NEGOTIATE_ALGORITHMS_REQUEST;
+
+///
+/// SPDM NEGOTIATE_ALGORITHMS request BaseAsymAlgo
+///
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048           BIT0
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSAPSS_2048           BIT1
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_3072           BIT2
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSAPSS_3072           BIT3
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P256   BIT4
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_4096           BIT5
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSAPSS_4096           BIT6
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P384   BIT7
+#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_ECDSA_ECC_NIST_P521   BIT8
+
+///
+/// SPDM NEGOTIATE_ALGORITHMS request BaseHashAlgo
+///
+#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256               BIT0
+#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_384               BIT1
+#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512               BIT2
+#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_256              BIT3
+#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_384              BIT4
+#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_512              BIT5
+
+///
+/// SPDM NEGOTIATE_ALGORITHMS response
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT16               Length;
+  UINT8                MeasurementSpecificationSel;
+  UINT8                Reserved;
+  UINT32               MeasurementHashAlgo;
+  UINT32               BaseAsymSel;
+  UINT32               BaseHashSel;
+  UINT8                Reserved2[12];
+  UINT8                ExtAsymSelCount;
+  UINT8                ExtHashSelCount;
+  UINT16               Reserved3;
+//UINT32               ExtAsymSel[ExtAsymSelCount];
+//UINT32               ExtHashSel[ExtHashSelCount];
+} SPDM_ALGORITHMS_RESPONSE;
+
+///
+/// SPDM NEGOTIATE_ALGORITHMS response MeasurementHashAlgo
+///
+#define SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_RAW_BIT_STREAM_ONLY BIT0
+#define SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA_256     BIT1
+#define SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA_384     BIT2
+#define SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA_512     BIT3
+#define SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA3_256    BIT4
+#define SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA3_384    BIT5
+#define SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA3_512    BIT6
+
+///
+/// SPDM GET_DIGESTS request
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+} SPDM_GET_DIGESTS_REQUEST;
+
+///
+/// SPDM GET_DIGESTS response
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+//UINT8                Digest[DigestSize];
+} SPDM_DIGESTS_RESPONSE;
+
+///
+/// SPDM GET_DIGESTS request
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT16               Offset;
+  UINT16               Length;
+} SPDM_GET_CERTIFICATE_REQUEST;
+
+///
+/// SPDM GET_DIGESTS response
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT16               PortionLength;
+  UINT16               RemainderLength;
+//UINT8                CertChain[CertChainSize];
+} SPDM_CERTIFICATE_RESPONSE;
+
+///
+/// SPDM CHALLENGE request
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT8                Nonce[32];
+} SPDM_CHALLENGE_REQUEST;
+
+///
+/// SPDM CHALLENGE response
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+//UINT8                CertChainHash[DigestSize];
+//UINT8                Nonce[32];
+//UINT8                MeasurementSummaryHash[DigestSize];
+//UINT16               OpaqueLength;
+//UINT8                OpaqueData[OpaqueLength];
+//UINT8                Signature[KeySize];
+} SPDM_CHALLENGE_AUTH_RESPONSE;
+
+///
+/// SPDM GET_MEASUREMENTS request
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT8                Nonce[32];
+} SPDM_GET_MEASUREMENTS_REQUEST;
+
+///
+/// SPDM MEASUREMENTS block common header
+///
+typedef struct {
+  UINT8                Index;
+  UINT8                MeasurementSpecification;
+  UINT16               MeasurementSize;
+//UINT8                Measurement[MeasurementSize];
+} SPDM_MEASUREMENT_BLOCK_COMMON_HEADER;
+
+#define SPDM_MEASUREMENT_BLOCK_HEADER_SPECIFICATION_DMTF BIT0
+
+///
+/// SPDM MEASUREMENTS block DMTF header
+///
+typedef struct {
+  UINT8                DMTFSpecMeasurementValueType;
+  UINT16               DMTFSpecMeasurementValueSize;
+//UINT8                DMTFSpecMeasurementValue[DMTFSpecMeasurementValueSize];
+} SPDM_MEASUREMENT_BLOCK_DMTF_HEADER;
+
+///
+/// SPDM MEASUREMENTS block MeasurementValueType
+///
+#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_IMMUTABLE_ROM           0
+#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_MUTABLE_FIRMWARE        1
+#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_HARDWARE_CONFIGURATION  2
+#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_FIRMWARE_CONFIGURATION  3
+#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_RAW_BIT_STREAM          BIT7
+
+///
+/// SPDM GET_MEASUREMENTS response
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  UINT8                NumberOfBlocks;
+  UINT8                MeasurementRecordLength[3];
+//UINT8                MeasurementRecord[MeasurementRecordLength];
+//UINT8                Nonce[32];
+//UINT16               OpaqueLength;
+//UINT8                OpaqueData[OpaqueLength];
+//UINT8                Signature[KeySize];
+} SPDM_MEASUREMENTS_RESPONSE;
+
+///
+/// SPDM ERROR response
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  // Param1 == Error Code
+  // Param2 == Error Data
+//UINT8                ExtendedErrorData[];
+} SPDM_ERROR_RESPONSE;
+
+///
+/// SPDM error code
+///
+#define SPDM_ERROR_CODE_INVALID_REQUEST         0x01
+#define SPDM_ERROR_CODE_BUSY                    0x03
+#define SPDM_ERROR_CODE_UNEXPECTED_REQUEST      0x04
+#define SPDM_ERROR_CODE_UNSPECIFIED             0x05
+#define SPDM_ERROR_CODE_UNSUPPORTED_REQUEST     0x07
+#define SPDM_ERROR_CODE_MAJOR_VERSION_MISMATCH  0x41
+#define SPDM_ERROR_CODE_RESPONSE_NOT_READY      0x42
+#define SPDM_ERROR_CODE_REQUEST_RESYNCH         0x43
+
+///
+/// SPDM RESPONSE_IF_READY request
+///
+typedef struct {
+  SPDM_MESSAGE_HEADER  Header;
+  // Param1 == RequestCode
+  // Param2 == Token
+} SPDM_RESPONSE_IF_READY_REQUEST;
+
+#pragma pack()
+
+#endif
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Tpm12.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Tpm12.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Tpm12.h	(revision 85718)
@@ -598,5 +598,5 @@
 ///
 /// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
-///   decalared after section 10 to catch declaration of TPM_PUBKEY
+///   declared after section 10 to catch declaration of TPM_PUBKEY
 ///
 /// Part 2 section 10.1: TPM_KEY_PARMS
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Tpm2Acpi.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Tpm2Acpi.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/Tpm2Acpi.h	(revision 85718)
@@ -28,5 +28,5 @@
 //UINT8                       PlatformSpecificParameters[];  // size up to 12
 //UINT32                      Laml;                          // Optional
-//UINT32                      Lasa;                          // Optional
+//UINT64                      Lasa;                          // Optional
 } EFI_TPM2_ACPI_TABLE;
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/UefiTcgPlatform.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/UefiTcgPlatform.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/IndustryStandard/UefiTcgPlatform.h	(revision 85718)
@@ -1,6 +1,7 @@
 /** @file
-  TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final
-
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final and
+  TCG PC Client Platform Firmware Profile Specification, Revision 1.05
+
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -22,4 +23,5 @@
 #define EV_SEPARATOR                ((TCG_EVENTTYPE) 0x00000004)
 #define EV_ACTION                   ((TCG_EVENTTYPE) 0x00000005)
+#define EV_EVENT_TAG                ((TCG_EVENTTYPE) 0x00000006)
 #define EV_S_CRTM_CONTENTS          ((TCG_EVENTTYPE) 0x00000007)
 #define EV_S_CRTM_VERSION           ((TCG_EVENTTYPE) 0x00000008)
@@ -46,6 +48,10 @@
 #define EV_EFI_PLATFORM_FIRMWARE_BLOB       (EV_EFI_EVENT_BASE + 8)
 #define EV_EFI_HANDOFF_TABLES               (EV_EFI_EVENT_BASE + 9)
+#define EV_EFI_PLATFORM_FIRMWARE_BLOB2      (EV_EFI_EVENT_BASE + 0xA)
+#define EV_EFI_HANDOFF_TABLES2              (EV_EFI_EVENT_BASE + 0xB)
 #define EV_EFI_HCRTM_EVENT                  (EV_EFI_EVENT_BASE + 0x10)
 #define EV_EFI_VARIABLE_AUTHORITY           (EV_EFI_EVENT_BASE + 0xE0)
+#define EV_EFI_SPDM_FIRMWARE_BLOB           (EV_EFI_EVENT_BASE + 0xE1)
+#define EV_EFI_SPDM_FIRMWARE_CONFIG         (EV_EFI_EVENT_BASE + 0xE2)
 
 #define EFI_CALLING_EFI_APPLICATION         \
@@ -79,4 +85,7 @@
 #define OPROM_LEN                     (sizeof(EV_POSTCODE_INFO_OPROM) - 1)
 
+#define EV_POSTCODE_INFO_EMBEDDED_UEFI_DRIVER  "Embedded UEFI Driver"
+#define EMBEDDED_UEFI_DRIVER_LEN               (sizeof(EV_POSTCODE_INFO_EMBEDDED_UEFI_DRIVER) - 1)
+
 #define FIRMWARE_DEBUGGER_EVENT_STRING      "UEFI Debug Mode"
 #define FIRMWARE_DEBUGGER_EVENT_STRING_LEN  (sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1)
@@ -125,4 +134,28 @@
 
 ///
+/// UEFI_PLATFORM_FIRMWARE_BLOB
+///
+/// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB
+/// event to facilitate the measurement of firmware volume.
+///
+typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB {
+  EFI_PHYSICAL_ADDRESS              BlobBase;
+  UINT64                            BlobLength;
+} UEFI_PLATFORM_FIRMWARE_BLOB;
+
+///
+/// UEFI_PLATFORM_FIRMWARE_BLOB2
+///
+/// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB2
+/// event to facilitate the measurement of firmware volume.
+///
+typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB2 {
+  UINT8                             BlobDescriptionSize;
+//UINT8                             BlobDescription[BlobDescriptionSize];
+//EFI_PHYSICAL_ADDRESS              BlobBase;
+//UINT64                            BlobLength;
+} UEFI_PLATFORM_FIRMWARE_BLOB2;
+
+///
 /// EFI_IMAGE_LOAD_EVENT
 ///
@@ -139,4 +172,18 @@
 
 ///
+/// UEFI_IMAGE_LOAD_EVENT
+///
+/// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
+/// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
+///
+typedef struct tdUEFI_IMAGE_LOAD_EVENT {
+  EFI_PHYSICAL_ADDRESS              ImageLocationInMemory;
+  UINT64                            ImageLengthInMemory;
+  UINT64                            ImageLinkTimeAddress;
+  UINT64                            LengthOfDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL          DevicePath[1];
+} UEFI_IMAGE_LOAD_EVENT;
+
+///
 /// EFI_HANDOFF_TABLE_POINTERS
 ///
@@ -148,4 +195,28 @@
   EFI_CONFIGURATION_TABLE           TableEntry[1];
 } EFI_HANDOFF_TABLE_POINTERS;
+
+///
+/// UEFI_HANDOFF_TABLE_POINTERS
+///
+/// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
+/// the measurement of given configuration tables.
+///
+typedef struct tdUEFI_HANDOFF_TABLE_POINTERS {
+  UINT64                            NumberOfTables;
+  EFI_CONFIGURATION_TABLE           TableEntry[1];
+} UEFI_HANDOFF_TABLE_POINTERS;
+
+///
+/// UEFI_HANDOFF_TABLE_POINTERS2
+///
+/// This structure is used in EV_EFI_HANDOFF_TABLES2 event to facilitate
+/// the measurement of given configuration tables.
+///
+typedef struct tdUEFI_HANDOFF_TABLE_POINTERS2 {
+  UINT8                             TableDescriptionSize;
+//UINT8                             TableDescription[TableDescriptionSize];
+//UINT64                            NumberOfTables;
+//EFI_CONFIGURATION_TABLE           TableEntry[1];
+} UEFI_HANDOFF_TABLE_POINTERS2;
 
 ///
@@ -198,4 +269,64 @@
 } EFI_GPT_DATA;
 
+typedef struct tdUEFI_GPT_DATA {
+  EFI_PARTITION_TABLE_HEADER  EfiPartitionHeader;
+  UINT64                      NumberOfPartitions;
+  EFI_PARTITION_ENTRY         Partitions[1];
+} UEFI_GPT_DATA;
+
+#define TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE "SPDM Device Sec"
+#define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION   0
+
+#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_NULL  0
+#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_PCI   1
+#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_USB   2
+
+///
+/// TCG_DEVICE_SECURITY_EVENT_DATA_HEADER
+/// This is the header of TCG_DEVICE_SECURITY_EVENT_DATA, which is
+/// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
+///
+typedef struct {
+  UINT8                          Signature[16];
+  UINT16                         Version;
+  UINT16                         Length;
+  UINT32                         SpdmHashAlgo;
+  UINT32                         DeviceType;
+//SPDM_MEASUREMENT_BLOCK         SpdmMeasurementBlock;
+} TCG_DEVICE_SECURITY_EVENT_DATA_HEADER;
+
+#define TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT_VERSION  0
+
+///
+/// TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT
+/// This is the PCI context data of TCG_DEVICE_SECURITY_EVENT_DATA, which is
+/// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
+///
+typedef struct {
+  UINT16  Version;
+  UINT16  Length;
+  UINT16  VendorId;
+  UINT16  DeviceId;
+  UINT8   RevisionID;
+  UINT8   ClassCode[3];
+  UINT16  SubsystemVendorID;
+  UINT16  SubsystemID;
+} TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT;
+
+#define TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT_VERSION  0
+
+///
+/// TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT
+/// This is the USB context data of TCG_DEVICE_SECURITY_EVENT_DATA, which is
+/// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.
+///
+typedef struct {
+  UINT16  Version;
+  UINT16  Length;
+//UINT8   DeviceDescriptor[DescLen];
+//UINT8   BodDescriptor[DescLen];
+//UINT8   ConfigurationDescriptor[DescLen][NumOfConfiguration];
+} TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT;
+
 //
 // Crypto Agile Log Entry Format
@@ -244,4 +375,5 @@
 #define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM2   0
 #define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2          0
+#define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105  105
 
 typedef struct {
@@ -300,5 +432,41 @@
 } TCG_EfiSpecIDEventStruct;
 
-
+typedef struct tdTCG_PCClientTaggedEvent {
+  UINT32              taggedEventID;
+  UINT32              taggedEventDataSize;
+//UINT8               taggedEventData[taggedEventDataSize];
+} TCG_PCClientTaggedEvent;
+
+#define TCG_Sp800_155_PlatformId_Event_SIGNATURE  "SP800-155 Event"
+#define TCG_Sp800_155_PlatformId_Event2_SIGNATURE "SP800-155 Event2"
+
+typedef struct tdTCG_Sp800_155_PlatformId_Event2 {
+  UINT8               Signature[16];
+  //
+  // Where Vendor ID is an integer defined
+  // at http://www.iana.org/assignments/enterprisenumbers
+  //
+  UINT32              VendorId;
+  //
+  // 16-byte identifier of a given platform's static configuration of code
+  //
+  EFI_GUID            ReferenceManifestGuid;
+  //
+  // Below structure is newly added in TCG_Sp800_155_PlatformId_Event2.
+  //
+//UINT8               PlatformManufacturerStrSize;
+//UINT8               PlatformManufacturerStr[PlatformManufacturerStrSize];
+//UINT8               PlatformModelSize;
+//UINT8               PlatformModel[PlatformModelSize];
+//UINT8               PlatformVersionSize;
+//UINT8               PlatformVersion[PlatformVersionSize];
+//UINT8               PlatformModelSize;
+//UINT8               PlatformModel[PlatformModelSize];
+//UINT8               FirmwareManufacturerStrSize;
+//UINT8               FirmwareManufacturerStr[FirmwareManufacturerStrSize];
+//UINT32              FirmwareManufacturerId;
+//UINT8               FirmwareVersion;
+//UINT8               FirmwareVersion[FirmwareVersionSize]];
+} TCG_Sp800_155_PlatformId_Event2;
 
 #define TCG_EfiStartupLocalityEvent_SIGNATURE      "StartupLocality"
@@ -306,12 +474,8 @@
 
 //
-// PC Client PTP spec Table 8 Relationship between Locality and Locality Attribute
-//
-#define LOCALITY_0_INDICATOR        0x01
-#define LOCALITY_1_INDICATOR        0x02
-#define LOCALITY_2_INDICATOR        0x03
-#define LOCALITY_3_INDICATOR        0x04
-#define LOCALITY_4_INDICATOR        0x05
-
+// The Locality Indicator which sent the TPM2_Startup command
+//
+#define LOCALITY_0_INDICATOR        0x00
+#define LOCALITY_3_INDICATOR        0x03
 
 //
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/BaseLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/BaseLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/BaseLib.h	(revision 85718)
@@ -5,4 +5,7 @@
 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.<BR>
+Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -125,4 +128,28 @@
 #endif  // defined (MDE_CPU_AARCH64)
 
+#if defined (MDE_CPU_RISCV64)
+///
+/// The RISC-V architecture context buffer used by SetJump() and LongJump().
+///
+typedef struct {
+  UINT64                            RA;
+  UINT64                            S0;
+  UINT64                            S1;
+  UINT64                            S2;
+  UINT64                            S3;
+  UINT64                            S4;
+  UINT64                            S5;
+  UINT64                            S6;
+  UINT64                            S7;
+  UINT64                            S8;
+  UINT64                            S9;
+  UINT64                            S10;
+  UINT64                            S11;
+  UINT64                            SP;
+} BASE_LIBRARY_JUMP_BUFFER;
+
+#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
+
+#endif // defined (MDE_CPU_RISCV64)
 
 //
@@ -190,5 +217,4 @@
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -226,5 +252,4 @@
   If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -264,5 +289,4 @@
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -304,5 +328,4 @@
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -351,10 +374,5 @@
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid decimal digits in the above format, then 0 is stored
@@ -407,10 +425,5 @@
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid decimal digits in the above format, then 0 is stored
@@ -468,10 +481,5 @@
   whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
@@ -529,10 +537,5 @@
   whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
@@ -623,6 +626,4 @@
   This function is similar as strcpy_s defined in C11.
 
-  If an error would be returned, then the function will also ASSERT().
-
   If an error is returned, then the Destination is unmodified.
 
@@ -656,6 +657,4 @@
 
   This function is similar as strncpy_s defined in C11.
-
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -692,6 +691,4 @@
 
   This function is similar as strcat_s defined in C11.
-
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -731,6 +728,4 @@
   This function is similar as strncat_s defined in C11.
 
-  If an error would be returned, then the function will also ASSERT().
-
   If an error is returned, then the Destination is unmodified.
 
@@ -778,10 +773,4 @@
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than
-  PcdMaximumAsciiStringLength Ascii characters, not including the
-  Null-terminator, then ASSERT().
-
   If String has no valid decimal digits in the above format, then 0 is stored
   at the location pointed to by Data.
@@ -833,10 +822,4 @@
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than
-  PcdMaximumAsciiStringLength Ascii characters, not including the
-  Null-terminator, then ASSERT().
-
   If String has no valid decimal digits in the above format, then 0 is stored
   at the location pointed to by Data.
@@ -892,10 +875,4 @@
   whichever on comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than
-  PcdMaximumAsciiStringLength Ascii characters, not including the
-  Null-terminator, then ASSERT().
-
   If String has no valid hexadecimal digits in the above format, then 0 is
   stored at the location pointed to by Data.
@@ -950,10 +927,4 @@
   character that is a not a valid hexadecimal character or Null-terminator,
   whichever on comes first.
-
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than
-  PcdMaximumAsciiStringLength Ascii characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
@@ -1507,13 +1478,5 @@
   The "::" can only appear once in the String.
 
-  If String is NULL, then ASSERT().
-
-  If Address is NULL, then ASSERT().
-
   If String is not aligned in a 16-bit boundary, then ASSERT().
-
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If EndPointer is not NULL and Address is translated from String, a pointer
@@ -1568,13 +1531,5 @@
   a valid decimal digit character after P is converted.
 
-  If String is NULL, then ASSERT().
-
-  If Address is NULL, then ASSERT().
-
   If String is not aligned in a 16-bit boundary, then ASSERT().
-
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If EndPointer is not NULL and Address is translated from String, a pointer
@@ -1641,6 +1596,4 @@
                   pp          Data4[56:63]
 
-  If String is NULL, then ASSERT().
-  If Guid is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
 
@@ -1676,15 +1629,4 @@
 
   If String is not aligned in a 16-bit boundary, then ASSERT().
-
-  If String is NULL, then ASSERT().
-
-  If Buffer is NULL, then ASSERT().
-
-  If Length is not multiple of 2, then ASSERT().
-
-  If PcdMaximumUnicodeStringLength is not zero and Length is greater than
-  PcdMaximumUnicodeStringLength, then ASSERT().
-
-  If MaxBufferSize is less than (Length / 2), then ASSERT().
 
   @param  String                   Pointer to a Null-terminated Unicode string.
@@ -1778,5 +1720,4 @@
 
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -1825,5 +1766,4 @@
   bits, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -2389,8 +2329,4 @@
   The "::" can only appear once in the String.
 
-  If String is NULL, then ASSERT().
-
-  If Address is NULL, then ASSERT().
-
   If EndPointer is not NULL and Address is translated from String, a pointer
   to the character that stopped the scan is stored at the location pointed to
@@ -2443,8 +2379,4 @@
   When /P is in the String, the function stops at the first character that is not
   a valid decimal digit character after P is converted.
-
-  If String is NULL, then ASSERT().
-
-  If Address is NULL, then ASSERT().
 
   If EndPointer is not NULL and Address is translated from String, a pointer
@@ -2509,7 +2441,4 @@
                   pp          Data4[56:63]
 
-  If String is NULL, then ASSERT().
-  If Guid is NULL, then ASSERT().
-
   @param  String                   Pointer to a Null-terminated ASCII string.
   @param  Guid                     Pointer to the converted GUID.
@@ -2541,15 +2470,4 @@
   decoding stops after Length of characters and outputs Buffer containing
   (Length / 2) bytes.
-
-  If String is NULL, then ASSERT().
-
-  If Buffer is NULL, then ASSERT().
-
-  If Length is not multiple of 2, then ASSERT().
-
-  If PcdMaximumAsciiStringLength is not zero and Length is greater than
-  PcdMaximumAsciiStringLength, then ASSERT().
-
-  If MaxBufferSize is less than (Length / 2), then ASSERT().
 
   @param  String                   Pointer to a Null-terminated ASCII string.
@@ -2633,5 +2551,4 @@
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -2679,5 +2596,4 @@
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then Destination and DestinationLength are
@@ -2973,4 +2889,30 @@
 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)  {&(ListHead), &(ListHead)}
 
+/**
+  Iterates over each node in a doubly linked list using each node's forward link.
+
+  @param  Entry     A pointer to a list node used as a loop cursor during iteration
+  @param  ListHead  The head node of the doubly linked list
+
+**/
+#define BASE_LIST_FOR_EACH(Entry, ListHead)    \
+  for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
+
+/**
+  Iterates over each node in a doubly linked list using each node's forward link
+  with safety against node removal.
+
+  This macro uses NextEntry to temporarily store the next list node so the node
+  pointed to by Entry may be deleted in the current loop iteration step and
+  iteration can continue from the node pointed to by NextEntry.
+
+  @param  Entry     A pointer to a list node used as a loop cursor during iteration
+  @param  NextEntry A pointer to a list node used to temporarily store the next node
+  @param  ListHead  The head node of the doubly linked list
+
+**/
+#define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead)            \
+  for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
+      Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
 
 /**
@@ -5388,8 +5330,17 @@
                             ///< Unmasked SIMD Floating Point
                             ///< Exceptions.
-    UINT32  Reserved_2:1;   ///< Reserved.
+    UINT32  UMIP:1;         ///< User-Mode Instruction Prevention.
     UINT32  LA57:1;         ///< Linear Address 57bit.
-    UINT32  VMXE:1;         ///< VMX Enable
-    UINT32  Reserved_1:18;  ///< Reserved.
+    UINT32  VMXE:1;         ///< VMX Enable.
+    UINT32  SMXE:1;         ///< SMX Enable.
+    UINT32  Reserved_3:1;   ///< Reserved.
+    UINT32  FSGSBASE:1;     ///< FSGSBASE Enable.
+    UINT32  PCIDE:1;        ///< PCID Enable.
+    UINT32  OSXSAVE:1;      ///< XSAVE and Processor Extended States Enable.
+    UINT32  Reserved_4:1;   ///< Reserved.
+    UINT32  SMEP:1;         ///< SMEP Enable.
+    UINT32  SMAP:1;         ///< SMAP Enable.
+    UINT32  PKE:1;          ///< Protection-Key Enable.
+    UINT32  Reserved_5:9;   ///< Reserved.
   } Bits;
   UINTN     UintN;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/DebugLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/DebugLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/DebugLib.h	(revision 85718)
@@ -9,5 +9,5 @@
   defined, then debug and assert related macros wrapped by it are the NULL implementations.
 
-Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -290,5 +290,9 @@
 
 **/
+#if defined(__clang__) && defined(__FILE_NAME__)
+#define _ASSERT(Expression)  DebugAssert (__FILE_NAME__, __LINE__, #Expression)
+#else
 #define _ASSERT(Expression)  DebugAssert (__FILE__, __LINE__, #Expression)
+#endif
 
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/DxeServicesLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/DxeServicesLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/DxeServicesLib.h	(revision 85718)
@@ -172,5 +172,5 @@
 
 /**
-  Searches the FFS file the the currently executing module was loaded from and returns the first matching FFS section.
+  Searches the FFS file the currently executing module was loaded from and returns the first matching FFS section.
 
   This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciCf8Lib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciCf8Lib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciCf8Lib.h	(revision 85718)
@@ -1028,5 +1028,5 @@
   configuration registers from a single PCI function to be read. Size is
   returned. When possible 32-bit PCI configuration read cycles are used to read
-  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+  from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit
   and 16-bit PCI configuration read cycles may be used at the beginning and the
   end of the range.
@@ -1061,5 +1061,5 @@
   configuration registers from a single PCI function to be written. Size is
   returned. When possible 32-bit PCI configuration write cycles are used to
-  write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+  write from StartAddress to StartAddress + Size. Due to alignment restrictions,
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning
   and the end of the range.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciExpressLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciExpressLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciExpressLib.h	(revision 85718)
@@ -998,5 +998,5 @@
   configuration registers from a single PCI function to be read. Size is
   returned. When possible 32-bit PCI configuration read cycles are used to read
-  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+  from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit
   and 16-bit PCI configuration read cycles may be used at the beginning and the
   end of the range.
@@ -1030,5 +1030,5 @@
   configuration registers from a single PCI function to be written. Size is
   returned. When possible 32-bit PCI configuration write cycles are used to
-  write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+  write from StartAddress to StartAddress + Size. Due to alignment restrictions,
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning
   and the end of the range.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciLib.h	(revision 85718)
@@ -998,5 +998,5 @@
   configuration registers from a single PCI function to be read. Size is
   returned. When possible 32-bit PCI configuration read cycles are used to read
-  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+  from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit
   and 16-bit PCI configuration read cycles may be used at the beginning and the
   end of the range.
@@ -1030,5 +1030,5 @@
   configuration registers from a single PCI function to be written. Size is
   returned. When possible 32-bit PCI configuration write cycles are used to
-  write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+  write from StartAddress to StartAddress + Size. Due to alignment restrictions,
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning
   and the end of the range.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciSegmentLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciSegmentLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/PciSegmentLib.h	(revision 85718)
@@ -985,5 +985,5 @@
   configuration registers from a single PCI function to be read. Size is
   returned. When possible 32-bit PCI configuration read cycles are used to read
-  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+  from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit
   and 16-bit PCI configuration read cycles may be used at the beginning and the
   end of the range.
@@ -1017,5 +1017,5 @@
   configuration registers from a single PCI function to be written. Size is
   returned. When possible 32-bit PCI configuration write cycles are used to
-  write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+  write from StartAddress to StartAddress + Size. Due to alignment restrictions,
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning
   and the end of the range.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmLib.h	(revision 85718)
@@ -46,5 +46,5 @@
 
   @retval TRUE   A software SMI triggered at boot time happened.
-  @retval FLASE  No software SMI happened, or the software SMI was triggered at run time.
+  @retval FALSE  No software SMI happened, or the software SMI was triggered at run time.
 
 **/
@@ -63,5 +63,5 @@
 
   @retval TRUE   A software SMI triggered at run time happened.
-  @retval FLASE  No software SMI happened or the software SMI was triggered at boot time.
+  @retval FALSE  No software SMI happened or the software SMI was triggered at boot time.
 
 **/
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmMemLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmMemLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmMemLib.h	(revision 85718)
@@ -68,5 +68,5 @@
   @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.
 
-  @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with SMRAM.
+  @retval EFI_SECURITY_VIOLATION The DestinationBuffer is invalid per processor architecture or overlap with SMRAM.
   @retval EFI_SUCCESS            Memory is copied.
 
@@ -93,5 +93,5 @@
   @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.
 
-  @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with SMRAM.
+  @retval EFI_SECURITY_VIOLATION The DestinationBuffer is invalid per processor architecture or overlap with SMRAM.
   @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with SMRAM.
   @retval EFI_SUCCESS            Memory is copied.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmPeriodicSmiLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmPeriodicSmiLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/SmmPeriodicSmiLib.h	(revision 85718)
@@ -65,5 +65,5 @@
   periodic SMI for the currently executing handler is triggered, the periodic
   SMI handler will be resumed and this function will return.  Use of this
-  function requires a seperate stack for the periodic SMI handler.  A non zero
+  function requires a separate stack for the periodic SMI handler.  A non zero
   stack size must be specified in PeriodicSmiEnable() for this function to be
   used.
@@ -114,5 +114,5 @@
   @param[in]     Context           Optional content to pass into DispatchFunction.
   @param[in]     TickPeriod        The requested tick period in 100ns units that
-                                   control should be givien to the periodic SMI
+                                   control should be given to the periodic SMI
                                    handler.  Must be one of the supported values
                                    returned by PeriodicSmiSupportedPickPeriod().
@@ -138,5 +138,5 @@
                                  periodic SMI handler.
   @retval EFI_OUT_OF_RESOURCES   There are not enough resources to allocate the
-                                 stack speficied by StackSize.
+                                 stack specified by StackSize.
   @retval EFI_SUCCESS            The periodic SMI handler was enabled.
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UefiLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UefiLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UefiLib.h	(revision 85718)
@@ -460,4 +460,22 @@
   IN CONST EFI_HANDLE       ChildHandle,
   IN CONST EFI_GUID         *ProtocolGuid
+  );
+
+/**
+  This function checks the supported languages list for a target language,
+  This only supports RFC 4646 Languages.
+
+  @param  SupportedLanguages  The supported languages
+  @param  TargetLanguage      The target language
+
+  @retval Returns EFI_SUCCESS if the language is supported,
+          EFI_UNSUPPORTED otherwise
+
+**/
+EFI_STATUS
+EFIAPI
+IsLanguageSupported (
+  IN CONST CHAR8 *SupportedLanguages,
+  IN CONST CHAR8 *TargetLanguage
   );
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UefiScsiLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UefiScsiLib.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UefiScsiLib.h	(revision 85718)
@@ -6,5 +6,5 @@
   This library class depends on SCSI I/O Protocol defined in UEFI Specification and SCSI-2 industry standard.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -815,4 +815,132 @@
 
 /**
+  Execute Security Protocol In SCSI command on a specific SCSI target.
+
+  Executes the SCSI Security Protocol In command on the SCSI target specified by ScsiIo.
+  If Timeout is zero, then this function waits indefinitely for the command to complete.
+  If Timeout is greater than zero, then the command is executed and will timeout after
+  Timeout 100 ns units.
+  If ScsiIo is NULL, then ASSERT().
+  If SenseDataLength is NULL, then ASSERT().
+  If HostAdapterStatus is NULL, then ASSERT().
+  If TargetStatus is NULL, then ASSERT().
+  If TransferLength is NULL, then ASSERT().
+
+  If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
+  alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
+  gets returned.
+
+  If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
+  alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
+  gets returned.
+
+  @param[in]      ScsiIo                    SCSI IO Protocol to use.
+  @param[in]      Timeout                   The length of timeout period.
+  @param[in, out] SenseData                 A pointer to output sense data.
+  @param[in, out] SenseDataLength           The length of output sense data.
+  @param[out]     HostAdapterStatus         The status of Host Adapter.
+  @param[out]     TargetStatus              The status of the target.
+  @param[in]      SecurityProtocol          The Security Protocol to use.
+  @param[in]      SecurityProtocolSpecific  The Security Protocol Specific data.
+  @param[in]      Inc512                    If TRUE, 512 increment (INC_512) bit will be set for the
+                                            SECURITY PROTOCOL IN command.
+  @param[in]      DataLength                The size in bytes of the data buffer.
+  @param[in, out] DataBuffer                A pointer to a data buffer.
+  @param[out]     TransferLength            A pointer to a buffer to store the size in
+                                            bytes of the data written to the data buffer.
+
+  @retval  EFI_SUCCESS                 Command is executed successfully.
+  @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire DataBuffer could
+                                       not be transferred. The actual number of bytes transferred is returned in TransferLength.
+  @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because there are too many
+                                       SCSI Command Packets already queued.
+  @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
+  @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet is not supported by
+                                       the SCSI initiator(i.e., SCSI  Host Controller)
+  @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
+  @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
+
+**/
+EFI_STATUS
+EFIAPI
+ScsiSecurityProtocolInCommand (
+  IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
+  IN     UINT64                Timeout,
+  IN OUT VOID                  *SenseData,   OPTIONAL
+  IN OUT UINT8                 *SenseDataLength,
+     OUT UINT8                 *HostAdapterStatus,
+     OUT UINT8                 *TargetStatus,
+  IN     UINT8                 SecurityProtocol,
+  IN     UINT16                SecurityProtocolSpecific,
+  IN     BOOLEAN               Inc512,
+  IN     UINTN                 DataLength,
+  IN OUT VOID                  *DataBuffer,  OPTIONAL
+     OUT UINTN                 *TransferLength
+  );
+
+
+/**
+  Execute Security Protocol Out SCSI command on a specific SCSI target.
+
+  Executes the SCSI Security Protocol Out command on the SCSI target specified by ScsiIo.
+  If Timeout is zero, then this function waits indefinitely for the command to complete.
+  If Timeout is greater than zero, then the command is executed and will timeout after
+  Timeout 100 ns units.
+  If ScsiIo is NULL, then ASSERT().
+  If SenseDataLength is NULL, then ASSERT().
+  If HostAdapterStatus is NULL, then ASSERT().
+  If TargetStatus is NULL, then ASSERT().
+
+  If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
+  alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
+  gets returned.
+
+  If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
+  alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
+  gets returned.
+
+  @param[in]      ScsiIo                    SCSI IO Protocol to use.
+  @param[in]      Timeout                   The length of timeout period.
+  @param[in, out] SenseData                 A pointer to output sense data.
+  @param[in, out] SenseDataLength           The length of output sense data.
+  @param[out]     HostAdapterStatus         The status of Host Adapter.
+  @param[out]     TargetStatus              The status of the target.
+  @param[in]      SecurityProtocol          The Security Protocol to use.
+  @param[in]      SecurityProtocolSpecific  The Security Protocol Specific data.
+  @param[in]      Inc512                    If TRUE, 512 increment (INC_512) bit will be set for the
+                                            SECURITY PROTOCOL OUT command.
+  @param[in]      DataLength                The size in bytes of the transfer data.
+  @param[in, out] DataBuffer                A pointer to a data buffer.
+
+  @retval  EFI_SUCCESS                 Command is executed successfully.
+  @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire DataBuffer could
+                                       not be transferred. The actual number of bytes transferred is returned in DataLength.
+  @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because there are too many
+                                       SCSI Command Packets already queued.
+  @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
+  @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet is not supported by
+                                       the SCSI initiator(i.e., SCSI  Host Controller)
+  @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
+  @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
+
+**/
+EFI_STATUS
+EFIAPI
+ScsiSecurityProtocolOutCommand (
+  IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
+  IN     UINT64                Timeout,
+  IN OUT VOID                  *SenseData,   OPTIONAL
+  IN OUT UINT8                 *SenseDataLength,
+     OUT UINT8                 *HostAdapterStatus,
+     OUT UINT8                 *TargetStatus,
+  IN     UINT8                 SecurityProtocol,
+  IN     UINT16                SecurityProtocolSpecific,
+  IN     BOOLEAN               Inc512,
+  IN     UINTN                 DataLength,
+  IN OUT VOID                  *DataBuffer   OPTIONAL
+  );
+
+
+/**
   Execute blocking/non-blocking Read(10) SCSI command on a specific SCSI
   target.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UnitTestLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UnitTestLib.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Library/UnitTestLib.h	(revision 85718)
@@ -0,0 +1,757 @@
+/** @file
+  Provides a unit test framework.  This allows tests to focus on testing logic
+  and the framework to focus on runnings, reporting, statistics, etc.
+
+  Copyright (c) Microsoft Corporation.<BR>
+  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef __UNIT_TEST_LIB_H__
+#define __UNIT_TEST_LIB_H__
+
+///
+/// Unit Test Status
+///
+typedef UINT32  UNIT_TEST_STATUS;
+#define UNIT_TEST_PASSED                      (0)
+#define UNIT_TEST_ERROR_PREREQUISITE_NOT_MET  (1)
+#define UNIT_TEST_ERROR_TEST_FAILED           (2)
+#define UNIT_TEST_ERROR_CLEANUP_FAILED        (3)
+#define UNIT_TEST_SKIPPED                     (0xFFFFFFFD)
+#define UNIT_TEST_RUNNING                     (0xFFFFFFFE)
+#define UNIT_TEST_PENDING                     (0xFFFFFFFF)
+
+///
+/// Declare PcdUnitTestLogLevel bits and UnitTestLog() ErrorLevel parameter.
+///
+#define UNIT_TEST_LOG_LEVEL_ERROR    BIT0
+#define UNIT_TEST_LOG_LEVEL_WARN     BIT1
+#define UNIT_TEST_LOG_LEVEL_INFO     BIT2
+#define UNIT_TEST_LOG_LEVEL_VERBOSE  BIT3
+
+///
+/// Unit Test Framework Handle
+///
+struct UNIT_TEST_FRAMEWORK_OBJECT;
+typedef struct UNIT_TEST_FRAMEWORK_OBJECT  *UNIT_TEST_FRAMEWORK_HANDLE;
+
+///
+/// Unit Test Suite Handle
+///
+struct UNIT_TEST_SUITE_OBJECT;
+typedef struct UNIT_TEST_SUITE_OBJECT  *UNIT_TEST_SUITE_HANDLE;
+
+///
+/// Unit Test Handle
+///
+struct UNIT_TEST_OBJECT;
+typedef struct UNIT_TEST_OBJECT  *UNIT_TEST_HANDLE;
+
+///
+/// Unit Test Context
+///
+typedef VOID*  UNIT_TEST_CONTEXT;
+
+/**
+  The prototype for a single UnitTest case function.
+
+  Functions with this prototype are registered to be dispatched by the
+  UnitTest framework, and results are recorded as test Pass or Fail.
+
+  @param[in]  Context    [Optional] An optional parameter that enables:
+                         1) test-case reuse with varied parameters and
+                         2) test-case re-entry for Target tests that need a
+                         reboot.  This parameter is a VOID* and it is the
+                         responsibility of the test author to ensure that the
+                         contents are well understood by all test cases that may
+                         consume it.
+
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test
+                                        case was successful.
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.
+
+**/
+typedef
+UNIT_TEST_STATUS
+(EFIAPI *UNIT_TEST_FUNCTION)(
+  IN UNIT_TEST_CONTEXT  Context
+  );
+
+/**
+  Unit-Test Prerequisite Function pointer type.
+
+  Functions with this prototype are registered to be dispatched by the unit test
+  framework prior to a given test case. If this prereq function returns
+  UNIT_TEST_ERROR_PREREQUISITE_NOT_MET, the test case will be skipped.
+
+  @param[in]  Context    [Optional] An optional parameter that enables:
+                         1) test-case reuse with varied parameters and
+                         2) test-case re-entry for Target tests that need a
+                         reboot.  This parameter is a VOID* and it is the
+                         responsibility of the test author to ensure that the
+                         contents are well understood by all test cases that may
+                         consume it.
+
+  @retval  UNIT_TEST_PASSED                      Unit test case prerequisites
+                                                 are met.
+  @retval  UNIT_TEST_ERROR_PREREQUISITE_NOT_MET  Test case should be skipped.
+
+**/
+typedef
+UNIT_TEST_STATUS
+(EFIAPI *UNIT_TEST_PREREQUISITE)(
+  IN UNIT_TEST_CONTEXT  Context
+  );
+
+/**
+  Unit-Test Cleanup (after) function pointer type.
+
+  Functions with this prototype are registered to be dispatched by the
+  unit test framework after a given test case. This will be called even if the
+  test case returns an error, but not if the prerequisite fails and the test is
+  skipped.  The purpose of this function is to clean up any global state or
+  test data.
+
+  @param[in]  Context    [Optional] An optional parameter that enables:
+                         1) test-case reuse with varied parameters and
+                         2) test-case re-entry for Target tests that need a
+                         reboot.  This parameter is a VOID* and it is the
+                         responsibility of the test author to ensure that the
+                         contents are well understood by all test cases that may
+                         consume it.
+
+  @retval  UNIT_TEST_PASSED                Test case cleanup succeeded.
+  @retval  UNIT_TEST_ERROR_CLEANUP_FAILED  Test case cleanup failed.
+
+**/
+typedef
+VOID
+(EFIAPI *UNIT_TEST_CLEANUP)(
+  IN UNIT_TEST_CONTEXT  Context
+  );
+
+/**
+  Unit-Test Test Suite Setup (before) function pointer type. Functions with this
+  prototype are registered to be dispatched by the UnitTest framework prior to
+  running any of the test cases in a test suite.  It will only be run once at
+  the beginning of the suite (not prior to each case).
+
+  The purpose of this function is to set up any global state or test data.
+**/
+typedef
+VOID
+(EFIAPI *UNIT_TEST_SUITE_SETUP)(
+  VOID
+  );
+
+/**
+  Unit-Test Test Suite Teardown (after) function pointer type.  Functions with
+  this prototype are registered to be dispatched by the UnitTest framework after
+  running all of the test cases in a test suite.  It will only be run once at
+  the end of the suite.
+
+  The purpose of this function is to clean up any global state or test data.
+**/
+typedef
+VOID
+(EFIAPI *UNIT_TEST_SUITE_TEARDOWN)(
+  VOID
+  );
+
+/**
+  Method to Initialize the Unit Test framework.  This function registers the
+  test name and also initializes the internal state of the test framework to
+  receive any new suites and tests.
+
+  @param[out]  FrameworkHandle  Unit test framework to be created.
+  @param[in]   Title            Null-terminated ASCII string that is the user
+                                friendly name of the framework. String is
+                                copied.
+  @param[in]   ShortTitle       Null-terminated ASCII short string that is the
+                                short name of the framework with no spaces.
+                                String is copied.
+  @param[in]   VersionString    Null-terminated ASCII version string for the
+                                framework. String is copied.
+
+  @retval  EFI_SUCCESS            The unit test framework was initialized.
+  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.
+  @retval  EFI_INVALID_PARAMETER  Title is NULL.
+  @retval  EFI_INVALID_PARAMETER  ShortTitle is NULL.
+  @retval  EFI_INVALID_PARAMETER  VersionString is NULL.
+  @retval  EFI_INVALID_PARAMETER  ShortTitle is invalid.
+  @retval  EFI_OUT_OF_RESOURCES   There are not enough resources available to
+                                  initialize the unit test framework.
+**/
+EFI_STATUS
+EFIAPI
+InitUnitTestFramework (
+  OUT UNIT_TEST_FRAMEWORK_HANDLE  *FrameworkHandle,
+  IN  CHAR8                       *Title,
+  IN  CHAR8                       *ShortTitle,
+  IN  CHAR8                       *VersionString
+  );
+
+/**
+  Registers a Unit Test Suite in the Unit Test Framework.
+  At least one test suite must be registered, because all test cases must be
+  within a unit test suite.
+
+  @param[out]  SuiteHandle      Unit test suite to create
+  @param[in]   FrameworkHandle  Unit test framework to add unit test suite to
+  @param[in]   Title            Null-terminated ASCII string that is the user
+                                friendly name of the test suite.  String is
+                                copied.
+  @param[in]   Name             Null-terminated ASCII string that is the short
+                                name of the test suite with no spaces.  String
+                                is copied.
+  @param[in]   Setup            Setup function, runs before suite.  This is an
+                                optional parameter that may be NULL.
+  @param[in]   Teardown         Teardown function, runs after suite.  This is an
+                                optional parameter that may be NULL.
+
+  @retval  EFI_SUCCESS            The unit test suite was created.
+  @retval  EFI_INVALID_PARAMETER  SuiteHandle is NULL.
+  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.
+  @retval  EFI_INVALID_PARAMETER  Title is NULL.
+  @retval  EFI_INVALID_PARAMETER  Name is NULL.
+  @retval  EFI_OUT_OF_RESOURCES   There are not enough resources available to
+                                  initialize the unit test suite.
+**/
+EFI_STATUS
+EFIAPI
+CreateUnitTestSuite (
+  OUT UNIT_TEST_SUITE_HANDLE      *SuiteHandle,
+  IN  UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,
+  IN  CHAR8                       *Title,
+  IN  CHAR8                       *Name,
+  IN  UNIT_TEST_SUITE_SETUP       Setup     OPTIONAL,
+  IN  UNIT_TEST_SUITE_TEARDOWN    Teardown  OPTIONAL
+  );
+
+/**
+  Adds test case to Suite
+
+  @param[in]  SuiteHandle   Unit test suite to add test to.
+  @param[in]  Description   Null-terminated ASCII string that is the user
+                            friendly description of a test.  String is copied.
+  @param[in]  Name          Null-terminated ASCII string that is the short name
+                            of the test with no spaces.  String is copied.
+  @param[in]  Function      Unit test function.
+  @param[in]  Prerequisite  Prerequisite function, runs before test.  This is
+                            an optional parameter that may be NULL.
+  @param[in]  CleanUp       Clean up function, runs after test.  This is an
+                            optional parameter that may be NULL.
+  @param[in]  Context       Pointer to context.    This is an optional parameter
+                            that may be NULL.
+
+  @retval  EFI_SUCCESS            The unit test case was added to Suite.
+  @retval  EFI_INVALID_PARAMETER  SuiteHandle is NULL.
+  @retval  EFI_INVALID_PARAMETER  Description is NULL.
+  @retval  EFI_INVALID_PARAMETER  Name is NULL.
+  @retval  EFI_INVALID_PARAMETER  Function is NULL.
+  @retval  EFI_OUT_OF_RESOURCES   There are not enough resources available to
+                                  add the unit test case to Suite.
+**/
+EFI_STATUS
+EFIAPI
+AddTestCase (
+  IN UNIT_TEST_SUITE_HANDLE  SuiteHandle,
+  IN CHAR8                   *Description,
+  IN CHAR8                   *Name,
+  IN UNIT_TEST_FUNCTION      Function,
+  IN UNIT_TEST_PREREQUISITE  Prerequisite  OPTIONAL,
+  IN UNIT_TEST_CLEANUP       CleanUp       OPTIONAL,
+  IN UNIT_TEST_CONTEXT       Context       OPTIONAL
+  );
+
+/**
+  Execute all unit test cases in all unit test suites added to a Framework.
+
+  Once a unit test framework is initialized and all unit test suites and unit
+  test cases are registered, this function will cause the unit test framework to
+  dispatch all unit test cases in sequence and record the results for reporting.
+
+  @param[in]  FrameworkHandle  A handle to the current running framework that
+                               dispatched the test.  Necessary for recording
+                               certain test events with the framework.
+
+  @retval  EFI_SUCCESS            All test cases were dispatched.
+  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.
+**/
+EFI_STATUS
+EFIAPI
+RunAllTestSuites (
+  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle
+  );
+
+/**
+  Cleanup a test framework.
+
+  After tests are run, this will teardown the entire framework and free all
+  allocated data within.
+
+  @param[in]  FrameworkHandle  A handle to the current running framework that
+                               dispatched the test.  Necessary for recording
+                               certain test events with the framework.
+
+  @retval  EFI_SUCCESS            All resources associated with framework were
+                                  freed.
+  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.
+**/
+EFI_STATUS
+EFIAPI
+FreeUnitTestFramework (
+  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle
+  );
+
+/**
+  Leverages a framework-specific mechanism (see UnitTestPersistenceLib if you're
+  a framework author) to save the state of the executing framework along with
+  any allocated data so that the test may be resumed upon reentry. A test case
+  should pass any needed context (which, to prevent an infinite loop, should be
+  at least the current execution count) which will be saved by the framework and
+  passed to the test case upon resume.
+
+  Generally called from within a test case prior to quitting or rebooting.
+
+  @param[in]  FrameworkHandle    A handle to the current running framework that
+                                 dispatched the test.  Necessary for recording
+                                 certain test events with the framework.
+  @param[in]  ContextToSave      A buffer of test case-specific data to be saved
+                                 along with framework state.  Will be passed as
+                                 "Context" to the test case upon resume.  This
+                                 is an optional parameter that may be NULL.
+  @param[in]  ContextToSaveSize  Size of the ContextToSave buffer.
+
+  @retval  EFI_SUCCESS            The framework state and context were saved.
+  @retval  EFI_INVALID_PARAMETER  FrameworkHandle is NULL.
+  @retval  EFI_INVALID_PARAMETER  ContextToSave is not NULL and
+                                  ContextToSaveSize is 0.
+  @retval  EFI_INVALID_PARAMETER  ContextToSave is >= 4GB.
+  @retval  EFI_OUT_OF_RESOURCES   There are not enough resources available to
+                                  save the framework and context state.
+  @retval  EFI_DEVICE_ERROR       The framework and context state could not be
+                                  saved to a persistent storage device due to a
+                                  device error.
+**/
+EFI_STATUS
+EFIAPI
+SaveFrameworkState (
+  IN UNIT_TEST_FRAMEWORK_HANDLE  FrameworkHandle,
+  IN UNIT_TEST_CONTEXT           ContextToSave     OPTIONAL,
+  IN UINTN                       ContextToSaveSize
+  );
+
+/**
+  This macro uses the framework assertion logic to check an expression for
+  "TRUE". If the expression evaluates to TRUE, execution continues.
+  Otherwise, the test case immediately returns UNIT_TEST_ERROR_TEST_FAILED.
+
+  @param[in]  Expression  Expression to be evaluated for TRUE.
+**/
+#define UT_ASSERT_TRUE(Expression)                                                        \
+  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, __LINE__, __FILE__, #Expression)) { \
+    return UNIT_TEST_ERROR_TEST_FAILED;                                                   \
+  }
+
+/**
+  This macro uses the framework assertion logic to check an expression for
+  "FALSE". If the expression evaluates to FALSE, execution continues.
+  Otherwise, the test case immediately returns UNIT_TEST_ERROR_TEST_FAILED.
+
+  @param[in]  Expression  Expression to be evaluated for FALSE.
+**/
+#define UT_ASSERT_FALSE(Expression)                                                        \
+  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, __LINE__, __FILE__, #Expression)) { \
+    return UNIT_TEST_ERROR_TEST_FAILED;                                                    \
+  }
+
+/**
+  This macro uses the framework assertion logic to check whether two simple
+  values are equal.  If the values are equal, execution continues.
+  Otherwise, the test case immediately returns UNIT_TEST_ERROR_TEST_FAILED.
+
+  @param[in]  ValueA  Value to be compared for equality (64-bit comparison).
+  @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
+**/
+#define UT_ASSERT_EQUAL(ValueA, ValueB)                                                                           \
+  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, __LINE__, __FILE__, #ValueA, #ValueB)) { \
+    return UNIT_TEST_ERROR_TEST_FAILED;                                                                           \
+  }
+
+/**
+  This macro uses the framework assertion logic to check whether two memory
+  buffers are equal.  If the buffers are equal, execution continues.
+  Otherwise, the test case immediately returns UNIT_TEST_ERROR_TEST_FAILED.
+
+  @param[in]  BufferA  Pointer to a buffer for comparison.
+  @param[in]  BufferB  Pointer to a buffer for comparison.
+  @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
+**/
+#define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)                                                                               \
+  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__, __LINE__, __FILE__, #BufferA, #BufferB)) { \
+    return UNIT_TEST_ERROR_TEST_FAILED;                                                                                           \
+  }
+
+/**
+  This macro uses the framework assertion logic to check whether two simple
+  values are non-equal.  If the values are non-equal, execution continues.
+  Otherwise, the test case immediately returns UNIT_TEST_ERROR_TEST_FAILED.
+
+  @param[in]  ValueA  Value to be compared for inequality (64-bit comparison).
+  @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
+**/
+#define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)                                                                          \
+  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, __LINE__, __FILE__, #ValueA, #ValueB)) { \
+    return UNIT_TEST_ERROR_TEST_FAILED;                                                                              \
+  }
+
+/**
+  This macro uses the framework assertion logic to check whether an EFI_STATUS
+  value is !EFI_ERROR().  If the status is !EFI_ERROR(), execution continues.
+  Otherwise, the test case immediately returns UNIT_TEST_ERROR_TEST_FAILED.
+
+  @param[in]  Status  EFI_STATUS value to check.
+**/
+#define UT_ASSERT_NOT_EFI_ERROR(Status)                                                \
+  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, __LINE__, __FILE__, #Status)) { \
+    return UNIT_TEST_ERROR_TEST_FAILED;                                                \
+  }
+
+/**
+  This macro uses the framework assertion logic to check whether two EFI_STATUS
+  values are equal.  If the values are equal, execution continues.
+  Otherwise, the test case immediately returns UNIT_TEST_ERROR_TEST_FAILED.
+
+  @param[in]  Status    EFI_STATUS values to compare for equality.
+  @param[in]  Expected  EFI_STATUS values to compare for equality.
+**/
+#define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                 \
+  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, __LINE__, __FILE__, #Status)) { \
+    return UNIT_TEST_ERROR_TEST_FAILED;                                                          \
+  }
+
+/**
+  This macro uses the framework assertion logic to check whether a pointer is
+  not NULL.  If the pointer is not NULL, execution continues. Otherwise, the
+  test case immediately returns UNIT_TEST_ERROR_TEST_FAILED.
+
+  @param[in]  Pointer  Pointer to be checked against NULL.
+**/
+#define UT_ASSERT_NOT_NULL(Pointer)                                                  \
+  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, __LINE__, __FILE__, #Pointer)) { \
+    return UNIT_TEST_ERROR_TEST_FAILED;                                              \
+  }
+
+/**
+  If Expression is TRUE, then TRUE is returned.
+  If Expression is FALSE, then an assert is triggered and the location of the
+  assert provided by FunctionName, LineNumber, FileName, and Description are
+  recorded and FALSE is returned.
+
+  @param[in]  Expression    The BOOLEAN result of the expression evaluation.
+  @param[in]  FunctionName  Null-terminated ASCII string of the function
+                            executing the assert macro.
+  @param[in]  LineNumber    The source file line number of the assert macro.
+  @param[in]  FileName      Null-terminated ASCII string of the filename
+                            executing the assert macro.
+  @param[in]  Description   Null-terminated ASCII string of the expression being
+                            evaluated.
+
+  @retval  TRUE   Expression is TRUE.
+  @retval  FALSE  Expression is FALSE.
+**/
+BOOLEAN
+EFIAPI
+UnitTestAssertTrue (
+  IN BOOLEAN      Expression,
+  IN CONST CHAR8  *FunctionName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *FileName,
+  IN CONST CHAR8  *Description
+  );
+
+/**
+  If Expression is FALSE, then TRUE is returned.
+  If Expression is TRUE, then an assert is triggered and the location of the
+  assert provided by FunctionName, LineNumber, FileName, and Description are
+  recorded and FALSE is returned.
+
+  @param[in]  Expression    The BOOLEAN result of the expression evaluation.
+  @param[in]  FunctionName  Null-terminated ASCII string of the function
+                            executing the assert macro.
+  @param[in]  LineNumber    The source file line number of the assert macro.
+  @param[in]  FileName      Null-terminated ASCII string of the filename
+                            executing the assert macro.
+  @param[in]  Description   Null-terminated ASCII string of the expression being
+                            evaluated.
+
+  @retval  TRUE   Expression is FALSE.
+  @retval  FALSE  Expression is TRUE.
+**/
+BOOLEAN
+EFIAPI
+UnitTestAssertFalse (
+  IN BOOLEAN      Expression,
+  IN CONST CHAR8  *FunctionName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *FileName,
+  IN CONST CHAR8  *Description
+  );
+
+/**
+  If Status is not an EFI_ERROR(), then TRUE is returned.
+  If Status is an EFI_ERROR(), then an assert is triggered and the location of
+  the assert provided by FunctionName, LineNumber, FileName, and Description are
+  recorded and FALSE is returned.
+
+  @param[in]  Status        The EFI_STATUS value to evaluate.
+  @param[in]  FunctionName  Null-terminated ASCII string of the function
+                            executing the assert macro.
+  @param[in]  LineNumber    The source file line number of the assert macro.
+  @param[in]  FileName      Null-terminated ASCII string of the filename
+                            executing the assert macro.
+  @param[in]  Description   Null-terminated ASCII string of the status
+                            expression being evaluated.
+
+  @retval  TRUE   Status is not an EFI_ERROR().
+  @retval  FALSE  Status is an EFI_ERROR().
+**/
+BOOLEAN
+EFIAPI
+UnitTestAssertNotEfiError (
+  IN EFI_STATUS   Status,
+  IN CONST CHAR8  *FunctionName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *FileName,
+  IN CONST CHAR8  *Description
+  );
+
+/**
+  If ValueA is equal ValueB, then TRUE is returned.
+  If ValueA is not equal to ValueB, then an assert is triggered and the location
+  of the assert provided by FunctionName, LineNumber, FileName, DescriptionA,
+  and DescriptionB are recorded and FALSE is returned.
+
+  @param[in]  ValueA        64-bit value.
+  @param[in]  ValueB        64-bit value.
+  @param[in]  FunctionName  Null-terminated ASCII string of the function
+                            executing the assert macro.
+  @param[in]  LineNumber    The source file line number of the assert macro.
+  @param[in]  FileName      Null-terminated ASCII string of the filename
+                            executing the assert macro.
+  @param[in]  DescriptionA  Null-terminated ASCII string that is a description
+                            of ValueA.
+  @param[in]  DescriptionB  Null-terminated ASCII string that is a description
+                            of ValueB.
+
+  @retval  TRUE   ValueA is equal to ValueB.
+  @retval  FALSE  ValueA is not equal to ValueB.
+**/
+BOOLEAN
+EFIAPI
+UnitTestAssertEqual (
+  IN UINT64       ValueA,
+  IN UINT64       ValueB,
+  IN CONST CHAR8  *FunctionName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *FileName,
+  IN CONST CHAR8  *DescriptionA,
+  IN CONST CHAR8  *DescriptionB
+  );
+
+/**
+  If the contents of BufferA are identical to the contents of BufferB, then TRUE
+  is returned.  If the contents of BufferA are not identical to the contents of
+  BufferB, then an assert is triggered and the location of the assert provided
+  by FunctionName, LineNumber, FileName, DescriptionA, and DescriptionB are
+  recorded and FALSE is returned.
+
+  @param[in]  BufferA       Pointer to a buffer for comparison.
+  @param[in]  BufferB       Pointer to a buffer for comparison.
+  @param[in]  Length        Number of bytes to compare in BufferA and BufferB.
+  @param[in]  FunctionName  Null-terminated ASCII string of the function
+                            executing the assert macro.
+  @param[in]  LineNumber    The source file line number of the assert macro.
+  @param[in]  FileName      Null-terminated ASCII string of the filename
+                            executing the assert macro.
+  @param[in]  DescriptionA  Null-terminated ASCII string that is a description
+                            of BufferA.
+  @param[in]  DescriptionB  Null-terminated ASCII string that is a description
+                            of BufferB.
+
+  @retval  TRUE   The contents of BufferA are identical to the contents of
+                  BufferB.
+  @retval  FALSE  The contents of BufferA are not identical to the contents of
+                  BufferB.
+**/
+BOOLEAN
+EFIAPI
+UnitTestAssertMemEqual (
+  IN VOID         *BufferA,
+  IN VOID         *BufferB,
+  IN UINTN        Length,
+  IN CONST CHAR8  *FunctionName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *FileName,
+  IN CONST CHAR8  *DescriptionA,
+  IN CONST CHAR8  *DescriptionB
+  );
+
+/**
+  If ValueA is not equal ValueB, then TRUE is returned.
+  If ValueA is equal to ValueB, then an assert is triggered and the location
+  of the assert provided by FunctionName, LineNumber, FileName, DescriptionA
+  and DescriptionB are recorded and FALSE is returned.
+
+  @param[in]  ValueA        64-bit value.
+  @param[in]  ValueB        64-bit value.
+  @param[in]  FunctionName  Null-terminated ASCII string of the function
+                            executing the assert macro.
+  @param[in]  LineNumber    The source file line number of the assert macro.
+  @param[in]  FileName      Null-terminated ASCII string of the filename
+                            executing the assert macro.
+  @param[in]  DescriptionA  Null-terminated ASCII string that is a description
+                            of ValueA.
+  @param[in]  DescriptionB  Null-terminated ASCII string that is a description
+                            of ValueB.
+
+  @retval  TRUE   ValueA is not equal to ValueB.
+  @retval  FALSE  ValueA is equal to ValueB.
+**/
+BOOLEAN
+EFIAPI
+UnitTestAssertNotEqual (
+  IN UINT64       ValueA,
+  IN UINT64       ValueB,
+  IN CONST CHAR8  *FunctionName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *FileName,
+  IN CONST CHAR8  *DescriptionA,
+  IN CONST CHAR8  *DescriptionB
+  );
+
+/**
+  If Status is equal to Expected, then TRUE is returned.
+  If Status is not equal to Expected, then an assert is triggered and the
+  location of the assert provided by FunctionName, LineNumber, FileName, and
+  Description are recorded and FALSE is returned.
+
+  @param[in]  Status        EFI_STATUS value returned from an API under test.
+  @param[in]  Expected      The expected EFI_STATUS return value from an API
+                            under test.
+  @param[in]  FunctionName  Null-terminated ASCII string of the function
+                            executing the assert macro.
+  @param[in]  LineNumber    The source file line number of the assert macro.
+  @param[in]  FileName      Null-terminated ASCII string of the filename
+                            executing the assert macro.
+  @param[in]  Description   Null-terminated ASCII string that is a description
+                            of Status.
+
+  @retval  TRUE   Status is equal to Expected.
+  @retval  FALSE  Status is not equal to Expected.
+**/
+BOOLEAN
+EFIAPI
+UnitTestAssertStatusEqual (
+  IN EFI_STATUS   Status,
+  IN EFI_STATUS   Expected,
+  IN CONST CHAR8  *FunctionName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *FileName,
+  IN CONST CHAR8  *Description
+  );
+
+/**
+  If Pointer is not equal to NULL, then TRUE is returned.
+  If Pointer is equal to NULL, then an assert is triggered and the location of
+  the assert provided by FunctionName, LineNumber, FileName, and PointerName
+  are recorded and FALSE is returned.
+
+  @param[in]  Pointer       Pointer value to be checked against NULL.
+  @param[in]  Expected      The expected EFI_STATUS return value from a function
+                            under test.
+  @param[in]  FunctionName  Null-terminated ASCII string of the function
+                            executing the assert macro.
+  @param[in]  LineNumber    The source file line number of the assert macro.
+  @param[in]  FileName      Null-terminated ASCII string of the filename
+                            executing the assert macro.
+  @param[in]  PointerName   Null-terminated ASCII string that is a description
+                            of Pointer.
+
+  @retval  TRUE   Pointer is not equal to NULL.
+  @retval  FALSE  Pointer is equal to NULL.
+**/
+BOOLEAN
+EFIAPI
+UnitTestAssertNotNull (
+  IN VOID         *Pointer,
+  IN CONST CHAR8  *FunctionName,
+  IN UINTN        LineNumber,
+  IN CONST CHAR8  *FileName,
+  IN CONST CHAR8  *PointerName
+  );
+
+/**
+  Test logging macro that records an ERROR message in the test framework log.
+  Record is associated with the currently executing test case.
+
+  @param[in]  Format  Formatting string following the format defined in
+                      MdePkg/Include/Library/PrintLib.h.
+  @param[in]  ...     Print args.
+**/
+#define UT_LOG_ERROR(Format, ...)  \
+  UnitTestLog (UNIT_TEST_LOG_LEVEL_ERROR, Format, ##__VA_ARGS__)
+
+/**
+  Test logging macro that records a WARNING message in the test framework log.
+  Record is associated with the currently executing test case.
+
+  @param[in]  Format  Formatting string following the format defined in
+                      MdePkg/Include/Library/PrintLib.h.
+  @param[in]  ...     Print args.
+**/
+#define UT_LOG_WARNING(Format, ...)  \
+  UnitTestLog (UNIT_TEST_LOG_LEVEL_WARN, Format, ##__VA_ARGS__)
+
+/**
+  Test logging macro that records an INFO message in the test framework log.
+  Record is associated with the currently executing test case.
+
+  @param[in]  Format  Formatting string following the format defined in
+                      MdePkg/Include/Library/PrintLib.h.
+  @param[in]  ...     Print args.
+**/
+#define UT_LOG_INFO(Format, ...)  \
+  UnitTestLog (UNIT_TEST_LOG_LEVEL_INFO, Format, ##__VA_ARGS__)
+
+/**
+  Test logging macro that records a VERBOSE message in the test framework log.
+  Record is associated with the currently executing test case.
+
+  @param[in]  Format  Formatting string following the format defined in
+                      MdePkg/Include/Library/PrintLib.h.
+  @param[in]  ...     Print args.
+**/
+#define UT_LOG_VERBOSE(Format, ...)  \
+  UnitTestLog (UNIT_TEST_LOG_LEVEL_VERBOSE, Format, ##__VA_ARGS__)
+
+/**
+  Test logging function that records a messages in the test framework log.
+  Record is associated with the currently executing test case.
+
+  @param[in]  ErrorLevel  The error level of the unit test log message.
+  @param[in]  Format      Formatting string following the format defined in the
+                          MdePkg/Include/Library/PrintLib.h.
+  @param[in]  ...         Print args.
+**/
+VOID
+EFIAPI
+UnitTestLog (
+  IN  UINTN        ErrorLevel,
+  IN  CONST CHAR8  *Format,
+  ...
+  );
+
+#endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiDxeCis.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiDxeCis.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiDxeCis.h	(revision 85718)
@@ -6,5 +6,5 @@
 
   @par Revision Reference:
-  PI Version 1.6
+  PI Version 1.7
 
 **/
@@ -691,5 +691,5 @@
 #define DXE_SERVICES_SIGNATURE            0x565245535f455844ULL
 #define DXE_SPECIFICATION_MAJOR_REVISION  1
-#define DXE_SPECIFICATION_MINOR_REVISION  60
+#define DXE_SPECIFICATION_MINOR_REVISION  70
 #define DXE_SERVICES_REVISION             ((DXE_SPECIFICATION_MAJOR_REVISION<<16) | (DXE_SPECIFICATION_MINOR_REVISION))
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiPeiCis.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiPeiCis.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiPeiCis.h	(revision 85718)
@@ -6,5 +6,5 @@
 
   @par Revision Reference:
-  PI Version 1.6.
+  PI Version 1.7.
 
 **/
@@ -851,5 +851,5 @@
 //
 #define PEI_SPECIFICATION_MAJOR_REVISION  1
-#define PEI_SPECIFICATION_MINOR_REVISION  60
+#define PEI_SPECIFICATION_MINOR_REVISION  70
 ///
 /// Specification inconsistency here:
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiStatusCode.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiStatusCode.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Pi/PiStatusCode.h	(revision 85718)
@@ -341,4 +341,5 @@
 #define EFI_CHIPSET_EC_DXE_NB_ERROR     (EFI_SUBCLASS_SPECIFIC | 0x00000001)
 #define EFI_CHIPSET_EC_DXE_SB_ERROR     (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_CHIPSET_EC_INTRUDER_DETECT  (EFI_SUBCLASS_SPECIFIC | 0x00000003)
 ///@}
 
@@ -362,4 +363,5 @@
 #define EFI_PERIPHERAL_LCD_DEVICE       (EFI_PERIPHERAL | 0x000B0000)
 #define EFI_PERIPHERAL_NETWORK          (EFI_PERIPHERAL | 0x000C0000)
+#define EFI_PERIPHERAL_DOCKING          (EFI_PERIPHERAL | 0x000D0000)
 ///@}
 
@@ -376,4 +378,5 @@
 #define EFI_P_PC_RECONFIG         0x00000005
 #define EFI_P_PC_DETECTED         0x00000006
+#define EFI_P_PC_REMOVED          0x00000007
 ///@}
 
@@ -465,6 +468,7 @@
 ///
 ///@{
-#define EFI_P_KEYBOARD_EC_LOCKED    (EFI_SUBCLASS_SPECIFIC | 0x00000000)
-#define EFI_P_KEYBOARD_EC_STUCK_KEY (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_P_KEYBOARD_EC_LOCKED      (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_P_KEYBOARD_EC_STUCK_KEY   (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_P_KEYBOARD_EC_BUFFER_FULL (EFI_SUBCLASS_SPECIFIC | 0x00000002)
 ///@}
 
@@ -763,4 +767,5 @@
 #define EFI_SW_PEI_PC_S3_BOOT_SCRIPT  (EFI_SUBCLASS_SPECIFIC | 0x00000005)
 #define EFI_SW_PEI_PC_OS_WAKE         (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define EFI_SW_PEI_PC_S3_STARTED      (EFI_SUBCLASS_SPECIFIC | 0x00000007)
 ///@}
 
@@ -785,5 +790,9 @@
 #define EFI_SW_DXE_BS_PC_EXIT_BOOT_SERVICES_EVENT     (EFI_SUBCLASS_SPECIFIC | 0x00000003)
 #define EFI_SW_DXE_BS_PC_VIRTUAL_ADDRESS_CHANGE_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_SW_DXE_BS_PC_VARIABLE_SERVICES_INIT       (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_SW_DXE_BS_PC_VARIABLE_RECLAIM             (EFI_SUBCLASS_SPECIFIC | 0x00000006)
 #define EFI_SW_DXE_BS_PC_ATTEMPT_BOOT_ORDER_EVENT     (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_SW_DXE_BS_PC_CONFIG_RESET                 (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+#define EFI_SW_DXE_BS_PC_CSM_INIT                     (EFI_SUBCLASS_SPECIFIC | 0x00000009)
 ///@}
 
@@ -975,4 +984,6 @@
 #define EFI_SW_EC_PWD_CLEARED             0x00000010
 #define EFI_SW_EC_EVENT_LOG_FULL          0x00000011
+#define EFI_SW_EC_WRITE_PROTECTED         0x00000012
+#define EFI_SW_EC_FV_CORRUPTED            0x00000013
 ///@}
 
@@ -1006,4 +1017,6 @@
 #define EFI_SW_PEI_EC_RECOVERY_PPI_NOT_FOUND       (EFI_SUBCLASS_SPECIFIC | 0x00000006)
 #define EFI_SW_PEI_EC_RECOVERY_FAILED              (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_SW_PEI_EC_S3_RESUME_ERROR              (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+#define EFI_SW_PEI_EC_INVALID_CAPSULE              (EFI_SUBCLASS_SPECIFIC | 0x00000009)
 ///@}
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/BlockIo.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/BlockIo.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/BlockIo.h	(revision 85718)
@@ -16,5 +16,5 @@
   @par Revision Reference:
   This PPI is defined in UEFI Platform Initialization Specification 1.2 Volume 1:
-  Pre-EFI Initalization Core Interface.
+  Pre-EFI Initialization Core Interface.
 
 **/
@@ -59,5 +59,5 @@
 /// PEI_BLOCK_IO_MEDIA has been changed to EFI_PEI_BLOCK_IO_MEDIA.
 /// Inconsistency exists in UEFI Platform Initialization Specification 1.2
-/// Volume 1: Pre-EFI Initalization Core Interface, where all referrences to
+/// Volume 1: Pre-EFI Initialization Core Interface, where all references to
 /// this structure name are with the "EFI_" prefix, except for the definition
 /// which is without "EFI_".  So the name of PEI_BLOCK_IO_MEDIA is taken as the
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/BlockIo2.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/BlockIo2.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/BlockIo2.h	(revision 85718)
@@ -8,5 +8,5 @@
   @par Revision Reference:
   This PPI is defined in UEFI Platform Initialization Specification 1.4 Volume 1:
-  Pre-EFI Initalization Core Interface.
+  Pre-EFI Initialization Core Interface.
 
 **/
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Capsule.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Capsule.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Capsule.h	(revision 85718)
@@ -46,5 +46,5 @@
                             coalesced capsule.
 
-  @retval EFI_NOT_FOUND          If: boot modecould not be determined, or the
+  @retval EFI_NOT_FOUND          If: boot mode could not be determined, or the
                                  boot mode is not flash-update, or the capsule descriptors were not found.
   @retval EFI_BUFFER_TOO_SMALL   The capsule could not be coalesced in the provided memory region.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Decompress.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Decompress.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Decompress.h	(revision 85718)
@@ -1,4 +1,4 @@
 /** @file
-  Provides decompression services to the PEI Foundatoin.
+  Provides decompression services to the PEI Foundation.
 
   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/DelayedDispatch.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/DelayedDispatch.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/DelayedDispatch.h	(revision 85718)
@@ -0,0 +1,85 @@
+/** @file
+    EFI Delayed Dispatch PPI as defined in the PI 1.7 Specification
+
+    Provide timed event service in PEI
+
+    Copyright (c) 2020, American Megatrends International LLC. All rights reserved.
+    SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef __DELAYED_DISPATCH_PPI_H__
+#define __DELAYED_DISPATCH_PPI_H__
+
+///
+/// Global ID for EFI_DELAYED_DISPATCH_PPI_GUID
+///
+#define EFI_DELAYED_DISPATCH_PPI_GUID \
+  { \
+    0x869c711d, 0x649c, 0x44fe, { 0x8b, 0x9e, 0x2c, 0xbb, 0x29, 0x11, 0xc3, 0xe6} } \
+  }
+
+
+/**
+  Delayed Dispatch function.  This routine is called sometime after the required
+  delay.  Upon return, if NewDelay is 0, the function is unregistered.  If NewDelay
+  is not zero, this routine will be called again after the new delay period.
+
+  @param[in,out] Context         Pointer to Context. Can be updated by routine.
+  @param[out]    NewDelay        The new delay in us.  Leave at 0 to unregister callback.
+
+**/
+
+typedef
+VOID
+(EFIAPI *EFI_DELAYED_DISPATCH_FUNCTION) (
+  IN OUT UINT64 *Context,
+     OUT UINT32 *NewDelay
+  );
+
+
+///
+/// The forward declaration for EFI_DELAYED_DISPATCH_PPI
+///
+
+typedef  struct _EFI_DELAYED_DISPATCH_PPI  EFI_DELAYED_DISPATCH_PPI;
+
+
+/**
+Register a callback to be called after a minimum delay has occurred.
+
+This service is the single member function of the EFI_DELAYED_DISPATCH_PPI
+
+  @param This           Pointer to the EFI_DELAYED_DISPATCH_PPI instance
+  @param Function       Function to call back
+  @param Context        Context data
+  @param Delay          Delay interval
+
+  @retval EFI_SUCCESS               Function successfully loaded
+  @retval EFI_INVALID_PARAMETER     One of the Arguments is not supported
+  @retval EFI_OUT_OF_RESOURCES      No more entries
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DELAYED_DISPATCH_REGISTER)(
+  IN  EFI_DELAYED_DISPATCH_PPI      *This,
+  IN  EFI_DELAYED_DISPATCH_FUNCTION  Function,
+  IN  UINT64                     Context,
+  OUT UINT32                     Delay
+  );
+
+
+///
+/// This PPI is a pointer to the Delayed Dispatch Service.
+/// This service will be published by the Pei Foundation. The PEI Foundation
+/// will use this service to relaunch a known function that requests a delayed
+/// execution.
+///
+struct _EFI_DELAYED_DISPATCH_PPI {
+  EFI_DELAYED_DISPATCH_REGISTER      Register;
+};
+
+
+extern EFI_GUID gEfiPeiDelayedDispatchPpiGuid;
+
+#endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/DeviceRecoveryModule.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/DeviceRecoveryModule.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/DeviceRecoveryModule.h	(revision 85718)
@@ -16,5 +16,5 @@
   @par Revision Reference:
   This PPI is defined in UEFI Platform Initialization Specification 1.2 Volume 1:
-  Pre-EFI Initalization Core Interface
+  Pre-EFI Initialization Core Interface
 
 **/
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/IsaHc.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/IsaHc.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/IsaHc.h	(revision 85718)
@@ -29,5 +29,5 @@
   It may be possible that a single hardware aperture may be used for more than
   one device. This function tracks the number of times that each aperture is
-  referenced, and doesa not close the hardware aperture (via CloseIoAperture())
+  referenced, and does not close the hardware aperture (via CloseIoAperture())
   until there are no more references to it.
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/MpServices.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/MpServices.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/MpServices.h	(revision 85718)
@@ -76,5 +76,5 @@
 
 /**
-  Activate all of the application proessors.
+  Activate all of the application processors.
 
   @param[in] PeiServices          An indirect pointer to the PEI Services Table
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Pcd.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Pcd.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/Pcd.h	(revision 85718)
@@ -138,5 +138,5 @@
   @param[in]  TokenNumber The PCD token number.
 
-  @return The pointer to the buffer to be retrived.
+  @return The pointer to the buffer to be retrieved.
 
 **/
@@ -292,5 +292,5 @@
   @param[in]  TokenNumber The PCD token number.
 
-  @return The pointer to the buffer to be retrived.
+  @return The pointer to the buffer to be retrieved.
 
 **/
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/RecoveryModule.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/RecoveryModule.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/RecoveryModule.h	(revision 85718)
@@ -37,5 +37,5 @@
   @par Revision Reference:
   This PPI is defined in UEFI Platform Initialization Specification 1.2 Errata B Volume 1:
-  Pre-EFI Initalization Core Interface
+  Pre-EFI Initialization Core Interface
 
 **/
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/TemporaryRamDone.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/TemporaryRamDone.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/TemporaryRamDone.h	(revision 85718)
@@ -19,5 +19,5 @@
 /**
   TemporaryRamDone() disables the use of Temporary RAM. If present, this service is invoked
-  by the PEI Foundation after the EFI_PEI_PERMANANT_MEMORY_INSTALLED_PPI is installed.
+  by the PEI Foundation after the EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI is installed.
 
   @retval EFI_SUCCESS           Use of Temporary RAM was disabled.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/VectorHandoffInfo.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/VectorHandoffInfo.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Ppi/VectorHandoffInfo.h	(revision 85718)
@@ -44,5 +44,5 @@
   UINT32    VectorNumber;
   //
-  // A bitmask that describes the attributes ofthe interrupt or exception vector.
+  // A bitmask that describes the attributes of the interrupt or exception vector.
   //
   UINT32    Attribute;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/AbsolutePointer.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/AbsolutePointer.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/AbsolutePointer.h	(revision 85718)
@@ -170,5 +170,5 @@
 (EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE)(
   IN      EFI_ABSOLUTE_POINTER_PROTOCOL  *This,
-  IN OUT  EFI_ABSOLUTE_POINTER_STATE     *State
+  OUT  EFI_ABSOLUTE_POINTER_STATE        *State
 );
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/AtaPassThru.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/AtaPassThru.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/AtaPassThru.h	(revision 85718)
@@ -316,5 +316,5 @@
                                      device path node is to be allocated and built. If there is no
                                      port multiplier, then specify 0xFFFF.
-  @param[in,out] DevicePath          A pointer to a single device path node that describes the ATA
+  @param[out]    DevicePath          A pointer to a single device path node that describes the ATA
                                      device specified by Port and PortMultiplierPort. This function
                                      is responsible for allocating the buffer DevicePath with the
@@ -335,5 +335,5 @@
   IN     UINT16                     Port,
   IN     UINT16                     PortMultiplierPort,
-  IN OUT EFI_DEVICE_PATH_PROTOCOL   **DevicePath
+  OUT    EFI_DEVICE_PATH_PROTOCOL   **DevicePath
   );
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/BluetoothLeConfig.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/BluetoothLeConfig.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/BluetoothLeConfig.h	(revision 85718)
@@ -3,5 +3,5 @@
   This protocol abstracts user interface configuration for BluetoothLe device.
 
-  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -452,4 +452,6 @@
   EfiBluetoothSmpLocalSignCounter,
   EfiBluetoothSmpLocalDIV,
+  EfiBluetoothSmpPeerAddressList,
+  EfiBluetoothSmpMax,
 } EFI_BLUETOOTH_LE_SMP_DATA_TYPE;
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/DebugSupport.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/DebugSupport.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/DebugSupport.h	(revision 85718)
@@ -8,4 +8,5 @@
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
+Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -604,4 +605,57 @@
 } EFI_SYSTEM_CONTEXT_AARCH64;
 
+///
+/// RISC-V processor exception types.
+///
+#define EXCEPT_RISCV_INST_MISALIGNED              0
+#define EXCEPT_RISCV_INST_ACCESS_FAULT            1
+#define EXCEPT_RISCV_ILLEGAL_INST                 2
+#define EXCEPT_RISCV_BREAKPOINT                   3
+#define EXCEPT_RISCV_LOAD_ADDRESS_MISALIGNED      4
+#define EXCEPT_RISCV_LOAD_ACCESS_FAULT            5
+#define EXCEPT_RISCV_STORE_AMO_ADDRESS_MISALIGNED 6
+#define EXCEPT_RISCV_STORE_AMO_ACCESS_FAULT       7
+#define EXCEPT_RISCV_ENV_CALL_FROM_UMODE          8
+#define EXCEPT_RISCV_ENV_CALL_FROM_SMODE          9
+#define EXCEPT_RISCV_ENV_CALL_FROM_HMODE          10
+#define EXCEPT_RISCV_ENV_CALL_FROM_MMODE          11
+
+#define EXCEPT_RISCV_SOFTWARE_INT       0x0
+#define EXCEPT_RISCV_TIMER_INT          0x1
+
+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  X31;
+} EFI_SYSTEM_CONTEXT_RISCV64;
 
 ///
@@ -615,4 +669,5 @@
   EFI_SYSTEM_CONTEXT_ARM  *SystemContextArm;
   EFI_SYSTEM_CONTEXT_AARCH64  *SystemContextAArch64;
+  EFI_SYSTEM_CONTEXT_RISCV64  *SystemContextRiscV64;
 } EFI_SYSTEM_CONTEXT;
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/DevicePath.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/DevicePath.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/DevicePath.h	(revision 85718)
@@ -283,4 +283,19 @@
 } ACPI_ADR_DEVICE_PATH;
 
+///
+/// ACPI NVDIMM Device Path SubType.
+///
+#define ACPI_NVDIMM_DP               0x04
+///
+///
+typedef struct {
+  EFI_DEVICE_PATH_PROTOCOL        Header;
+  ///
+  /// NFIT Device Handle, the _ADR of the NVDIMM device.
+  /// The value of this field comes from Section 9.20.3 of the ACPI 6.2A specification.
+  ///
+  UINT32                          NFITDeviceHandle;
+} ACPI_NVDIMM_DEVICE_PATH;
+
 #define ACPI_ADR_DISPLAY_TYPE_OTHER             0
 #define ACPI_ADR_DISPLAY_TYPE_VGA               1
@@ -712,4 +727,16 @@
   UINT8                           StopBits;
 } UART_DEVICE_PATH;
+
+///
+/// NVDIMM Namespace Device Path SubType.
+///
+#define NVDIMM_NAMESPACE_DP               0x20
+typedef struct {
+  EFI_DEVICE_PATH_PROTOCOL        Header;
+  ///
+  /// Namespace unique label identifier UUID.
+  ///
+  EFI_GUID Uuid;
+} NVDIMM_NAMESPACE_DEVICE_PATH;
 
 //
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/EdidOverride.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/EdidOverride.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/EdidOverride.h	(revision 85718)
@@ -45,6 +45,6 @@
   IN  EFI_HANDLE                          *ChildHandle,
   OUT UINT32                              *Attributes,
-  IN OUT UINTN                            *EdidSize,
-  IN OUT UINT8                            **Edid
+  OUT UINTN                               *EdidSize,
+  OUT UINT8                               **Edid
   );
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/FirmwareManagement.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/FirmwareManagement.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/FirmwareManagement.h	(revision 85718)
@@ -9,5 +9,5 @@
   EFI_UNSUPPORTED if not supported by the driver.
 
-  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2013 - 2014, Hewlett-Packard Development Company, L.P.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -28,4 +28,29 @@
 
 typedef struct _EFI_FIRMWARE_MANAGEMENT_PROTOCOL EFI_FIRMWARE_MANAGEMENT_PROTOCOL;
+
+///
+/// Dependency Expression Opcode
+///
+#define EFI_FMP_DEP_PUSH_GUID        0x00
+#define EFI_FMP_DEP_PUSH_VERSION     0x01
+#define EFI_FMP_DEP_VERSION_STR      0x02
+#define EFI_FMP_DEP_AND              0x03
+#define EFI_FMP_DEP_OR               0x04
+#define EFI_FMP_DEP_NOT              0x05
+#define EFI_FMP_DEP_TRUE             0x06
+#define EFI_FMP_DEP_FALSE            0x07
+#define EFI_FMP_DEP_EQ               0x08
+#define EFI_FMP_DEP_GT               0x09
+#define EFI_FMP_DEP_GTE              0x0A
+#define EFI_FMP_DEP_LT               0x0B
+#define EFI_FMP_DEP_LTE              0x0C
+#define EFI_FMP_DEP_END              0x0D
+
+///
+/// Image Attribute - Dependency
+///
+typedef struct {
+  UINT8 Dependencies[1];
+} EFI_FIRMWARE_IMAGE_DEP;
 
 ///
@@ -112,4 +137,5 @@
   ///
   UINT64                           HardwareInstance;
+  EFI_FIRMWARE_IMAGE_DEP           *Dependencies;
 } EFI_FIRMWARE_IMAGE_DESCRIPTOR;
 
@@ -144,4 +170,9 @@
 ///
 #define    IMAGE_ATTRIBUTE_UEFI_IMAGE              0x0000000000000010
+///
+/// The attribute IMAGE_ATTRIBUTE_DEPENDENCY indicates that there is an EFI_FIRMWARE_IMAGE_DEP
+/// section associated with the image.
+///
+#define    IMAGE_ATTRIBUTE_DEPENDENCY              0x0000000000000020
 
 
@@ -159,5 +190,5 @@
 /// Descriptor Version exposed by GetImageInfo() function
 ///
-#define   EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION   3
+#define   EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION   4
 
 
@@ -315,5 +346,5 @@
   @param[in]      ImageIndex     A unique number identifying the firmware image(s) within the device.
                                  The number is between 1 and DescriptorCount.
-  @param[in, out] Image          Points to the buffer where the current image is copied to.
+  @param[out]     Image          Points to the buffer where the current image is copied to.
   @param[in, out] ImageSize      On entry, points to the size of the buffer pointed to by Image, in bytes.
                                  On return, points to the length of the image, in bytes.
@@ -334,5 +365,5 @@
   IN  EFI_FIRMWARE_MANAGEMENT_PROTOCOL  *This,
   IN  UINT8                             ImageIndex,
-  IN  OUT  VOID                         *Image,
+  OUT  VOID                             *Image,
   IN  OUT  UINTN                        *ImageSize
   );
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/MmCommunication2.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/MmCommunication2.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/MmCommunication2.h	(revision 85718)
@@ -0,0 +1,69 @@
+/** @file
+  EFI MM Communication Protocol 2 as defined in the PI 1.7 errata A specification.
+
+  This protocol provides a means of communicating between drivers outside of MM and MMI
+  handlers inside of MM.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2019, Arm Limited. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _MM_COMMUNICATION2_H_
+#define _MM_COMMUNICATION2_H_
+
+#include <Protocol/MmCommunication.h>
+
+#define EFI_MM_COMMUNICATION2_PROTOCOL_GUID \
+  { \
+    0x378daedc, 0xf06b, 0x4446, { 0x83, 0x14, 0x40, 0xab, 0x93, 0x3c, 0x87, 0xa3 } \
+  }
+
+typedef struct _EFI_MM_COMMUNICATION2_PROTOCOL  EFI_MM_COMMUNICATION2_PROTOCOL;
+
+/**
+  Communicates with a registered handler.
+
+  This function provides a service to send and receive messages from a registered UEFI service.
+
+  @param[in] This                The EFI_MM_COMMUNICATION_PROTOCOL instance.
+  @param[in] CommBufferPhysical  Physical address of the MM communication buffer
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer
+  @param[in] CommSize            The size of the data buffer being passed in. On exit, the size of data
+                                 being returned. Zero if the handler does not wish to reply with any data.
+                                 This parameter is optional and may be NULL.
+
+  @retval EFI_SUCCESS            The message was successfully posted.
+  @retval EFI_INVALID_PARAMETER  CommBufferPhysical was NULL or CommBufferVirtual was NULL.
+  @retval EFI_BAD_BUFFER_SIZE    The buffer is too large for the MM implementation.
+                                 If this error is returned, the MessageLength field
+                                 in the CommBuffer header or the integer pointed by
+                                 CommSize, are updated to reflect the maximum payload
+                                 size the implementation can accommodate.
+  @retval EFI_ACCESS_DENIED      The CommunicateBuffer parameter or CommSize parameter,
+                                 if not omitted, are in address range that cannot be
+                                 accessed by the MM environment.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MM_COMMUNICATE2)(
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,
+  IN OUT VOID                               *CommBufferPhysical,
+  IN OUT VOID                               *CommBufferVirtual,
+  IN OUT UINTN                              *CommSize OPTIONAL
+  );
+
+///
+/// EFI MM Communication Protocol provides runtime services for communicating
+/// between DXE drivers and a registered MMI handler.
+///
+struct _EFI_MM_COMMUNICATION2_PROTOCOL {
+  EFI_MM_COMMUNICATE2  Communicate;
+};
+
+extern EFI_GUID gEfiMmCommunication2ProtocolGuid;
+
+#endif
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/MpService.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/MpService.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/MpService.h	(revision 85718)
@@ -49,4 +49,9 @@
 
 ///
+/// Value used in the NumberProcessors parameter of the GetProcessorInfo function
+///
+#define CPU_V2_EXTENDED_TOPOLOGY BIT24
+
+///
 /// Forward declaration for the EFI_MP_SERVICES_PROTOCOL.
 ///
@@ -96,4 +101,45 @@
   UINT32  Thread;
 } EFI_CPU_PHYSICAL_LOCATION;
+
+///
+///  Structure that defines the 6-level physical location of the processor
+///
+typedef struct {
+///
+///    Package     Zero-based physical package number that identifies the cartridge of the processor.
+///
+UINT32  Package;
+///
+///    Module      Zero-based physical module number within package of the processor.
+///
+UINT32  Module;
+///
+///    Tile        Zero-based physical tile number within module of the processor.
+///
+UINT32  Tile;
+///
+///    Die         Zero-based physical die number within tile of the processor.
+///
+UINT32  Die;
+///
+///     Core        Zero-based physical core number within die of the processor.
+///
+UINT32  Core;
+///
+///     Thread      Zero-based logical thread number within core of the processor.
+///
+UINT32  Thread;
+} EFI_CPU_PHYSICAL_LOCATION2;
+
+
+typedef union {
+  /// The 6-level physical location of the processor, including the
+  /// physical package number that identifies the cartridge, the physical
+  /// module number within package, the physical tile number within the module,
+  /// the physical die number within the tile, the physical core number within
+  /// package, and logical thread number within core.
+  EFI_CPU_PHYSICAL_LOCATION2  Location2;
+} EXTENDED_PROCESSOR_INFORMATION;
+
 
 ///
@@ -133,4 +179,8 @@
   ///
   EFI_CPU_PHYSICAL_LOCATION  Location;
+  ///
+  /// The extended information of the processor. This field is filled only when
+  /// CPU_V2_EXTENDED_TOPOLOGY is set in parameter ProcessorNumber.
+  EXTENDED_PROCESSOR_INFORMATION ExtendedInformation;
 } EFI_PROCESSOR_INFORMATION;
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/NvmExpressPassthru.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/NvmExpressPassthru.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/NvmExpressPassthru.h	(revision 85718)
@@ -215,5 +215,5 @@
                                      allocated and built. Caller must set the NamespaceId to zero if the
                                      device path node will contain a valid UUID.
-  @param[in,out] DevicePath          A pointer to a single device path node that describes the NVM Express
+  @param[out]    DevicePath          A pointer to a single device path node that describes the NVM Express
                                      namespace specified by NamespaceId. This function is responsible for
                                      allocating the buffer DevicePath with the boot service AllocatePool().
@@ -232,5 +232,5 @@
   IN     EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL          *This,
   IN     UINT32                                      NamespaceId,
-  IN OUT EFI_DEVICE_PATH_PROTOCOL                    **DevicePath
+  OUT    EFI_DEVICE_PATH_PROTOCOL                    **DevicePath
   );
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/PxeBaseCode.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/PxeBaseCode.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/PxeBaseCode.h	(revision 85718)
@@ -4,4 +4,6 @@
 
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -154,4 +156,6 @@
 #elif defined (MDE_CPU_AARCH64)
 #define EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE    0x000B
+#elif defined (MDE_CPU_RISCV64)
+#define EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE    0x001B
 #endif
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/ScsiPassThruExt.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/ScsiPassThruExt.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/ScsiPassThruExt.h	(revision 85718)
@@ -260,5 +260,5 @@
   IN UINT8                                         *Target,
   IN UINT64                                        Lun,
-  IN OUT EFI_DEVICE_PATH_PROTOCOL                  **DevicePath
+  OUT EFI_DEVICE_PATH_PROTOCOL                     **DevicePath
   );
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SdMmcPassThru.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SdMmcPassThru.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SdMmcPassThru.h	(revision 85718)
@@ -165,5 +165,5 @@
   @param[in]     Slot           Specifies the slot number of the SD card for which a device
                                 path node is to be allocated and built.
-  @param[in,out] DevicePath     A pointer to a single device path node that describes the SD
+  @param[out]    DevicePath     A pointer to a single device path node that describes the SD
                                 card specified by Slot. This function is responsible for
                                 allocating the buffer DevicePath with the boot service
@@ -183,5 +183,5 @@
   IN     EFI_SD_MMC_PASS_THRU_PROTOCOL       *This,
   IN     UINT8                               Slot,
-  IN OUT EFI_DEVICE_PATH_PROTOCOL            **DevicePath
+  OUT    EFI_DEVICE_PATH_PROTOCOL            **DevicePath
 );
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/Security2.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/Security2.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/Security2.h	(revision 85718)
@@ -81,5 +81,5 @@
 typedef EFI_STATUS (EFIAPI *EFI_SECURITY2_FILE_AUTHENTICATION) (
   IN CONST EFI_SECURITY2_ARCH_PROTOCOL *This,
-  IN CONST EFI_DEVICE_PATH_PROTOCOL    *DevicePath,
+  IN CONST EFI_DEVICE_PATH_PROTOCOL    *File, OPTIONAL
   IN VOID                              *FileBuffer,
   IN UINTN                             FileSize,
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SerialIo.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SerialIo.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SerialIo.h	(revision 85718)
@@ -264,4 +264,5 @@
 
 #define EFI_SERIAL_IO_PROTOCOL_REVISION    0x00010000
+#define EFI_SERIAL_IO_PROTOCOL_REVISION1p1 0x00010001
 #define SERIAL_IO_INTERFACE_REVISION  EFI_SERIAL_IO_PROTOCOL_REVISION
 
@@ -288,4 +289,12 @@
   ///
   EFI_SERIAL_IO_MODE          *Mode;
+  ///
+  /// Pointer to a GUID identifying the device connected to the serial port.
+  /// This field is NULL when the protocol is installed by the serial port
+  /// driver and may be populated by a platform driver for a serial port
+  /// with a known device attached. The field will remain NULL if there is
+  /// no platform serial device identification information available.
+  ///
+  CONST EFI_GUID              *DeviceTypeGuid; // Revision 1.1
 };
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SimplePointer.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SimplePointer.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/SimplePointer.h	(revision 85718)
@@ -110,5 +110,5 @@
 (EFIAPI *EFI_SIMPLE_POINTER_GET_STATE)(
   IN EFI_SIMPLE_POINTER_PROTOCOL          *This,
-  IN OUT EFI_SIMPLE_POINTER_STATE         *State
+  OUT EFI_SIMPLE_POINTER_STATE            *State
   );
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/Tls.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/Tls.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Protocol/Tls.h	(revision 85718)
@@ -43,8 +43,4 @@
 typedef enum {
   ///
-  /// Session Configuration
-  ///
-
-  ///
   /// TLS session Version. The corresponding Data is of type EFI_TLS_VERSION.
   ///
@@ -87,9 +83,4 @@
   ///
   EfiTlsSessionState,
-
-  ///
-  /// Session information
-  ///
-
   ///
   /// TLS session data client random.
@@ -107,7 +98,13 @@
   ///
   EfiTlsKeyMaterial,
+  ///
+  /// TLS session hostname for validation which is used to verify whether the name
+  /// within the peer certificate matches a given host name.
+  /// This parameter is invalid when EfiTlsVerifyMethod is EFI_TLS_VERIFY_NONE.
+  /// The corresponding Data is of type EFI_TLS_VERIFY_HOST.
+  ///
+  EfiTlsVerifyHost,
 
   EfiTlsSessionDataTypeMaximum
-
 } EFI_TLS_SESSION_DATA_TYPE;
 
@@ -179,5 +176,6 @@
 #define EFI_TLS_VERIFY_PEER                  0x1
 ///
-/// TLS session will fail peer certificate is absent.
+/// EFI_TLS_VERIFY_FAIL_IF_NO_PEER_CERT is only meaningful in the server mode.
+/// TLS session will fail if client certificate is absent.
 ///
 #define EFI_TLS_VERIFY_FAIL_IF_NO_PEER_CERT  0x2
@@ -187,4 +185,52 @@
 ///
 #define EFI_TLS_VERIFY_CLIENT_ONCE           0x4
+
+///
+/// EFI_TLS_VERIFY_HOST_FLAG
+///
+typedef UINT32 EFI_TLS_VERIFY_HOST_FLAG;
+///
+/// There is no additional flags set for hostname validation.
+/// Wildcards are supported and they match only in the left-most label.
+///
+#define EFI_TLS_VERIFY_FLAG_NONE                    0x00
+///
+/// Always check the Subject Distinguished Name (DN) in the peer certificate even if the
+/// certificate contains Subject Alternative Name (SAN).
+///
+#define EFI_TLS_VERIFY_FLAG_ALWAYS_CHECK_SUBJECT    0x01
+///
+/// Disable the match of all wildcards.
+///
+#define EFI_TLS_VERIFY_FLAG_NO_WILDCARDS            0x02
+///
+/// Disable the "*" as wildcard in labels that have a prefix or suffix (e.g. "www*" or "*www").
+///
+#define EFI_TLS_VERIFY_FLAG_NO_PARTIAL_WILDCARDS    0x04
+///
+/// Allow the "*" to match more than one labels. Otherwise, only matches a single label.
+///
+#define EFI_TLS_VERIFY_FLAG_MULTI_LABEL_WILDCARDS   0x08
+///
+/// Restrict to only match direct child sub-domains which start with ".".
+/// For example, a name of ".example.com" would match "www.example.com" with this flag,
+/// but would not match "www.sub.example.com".
+///
+#define EFI_TLS_VERIFY_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10
+///
+/// Never check the Subject Distinguished Name (DN) even there is no
+/// Subject Alternative Name (SAN) in the certificate.
+///
+#define EFI_TLS_VERIFY_FLAG_NEVER_CHECK_SUBJECT     0x20
+
+///
+/// EFI_TLS_VERIFY_HOST
+///
+#pragma pack (1)
+typedef struct {
+  EFI_TLS_VERIFY_HOST_FLAG Flags;
+  CHAR8                    *HostName;
+} EFI_TLS_VERIFY_HOST;
+#pragma pack ()
 
 ///
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Cpuid.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Cpuid.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Cpuid.h	(revision 85718)
@@ -12,5 +12,5 @@
 
   @par Specification Reference:
-  AMD64 Architecture Programming Manaul volume 2, March 2017, Sections 15.34
+  AMD64 Architecture Programming Manual volume 2, March 2017, Sections 15.34
 
 **/
@@ -365,5 +365,5 @@
     UINT32  Page1GB:1;
     ///
-    /// [Bit 27] RDTSCP intructions.
+    /// [Bit 27] RDTSCP instructions.
     ///
     UINT32  RDTSCP:1;
@@ -514,7 +514,7 @@
   @retval  EAX  Extended APIC ID described by the type
                 CPUID_AMD_PROCESSOR_TOPOLOGY_EAX.
-  @retval  EBX  Core Indentifiers described by the type
+  @retval  EBX  Core Identifiers described by the type
                 CPUID_AMD_PROCESSOR_TOPOLOGY_EBX.
-  @retval  ECX  Node Indentifiers described by the type
+  @retval  ECX  Node Identifiers described by the type
                 CPUID_AMD_PROCESSOR_TOPOLOGY_ECX.
   @retval  EDX  Reserved.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Fam17Msr.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Fam17Msr.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Fam17Msr.h	(revision 85718)
@@ -11,5 +11,5 @@
 
   @par Specification Reference:
-  AMD64 Architecture Programming Manaul volume 2, March 2017, Sections 15.34
+  AMD64 Architecture Programming Manual volume 2, March 2017, Sections 15.34
 
 **/
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Msr.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Msr.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Amd/Msr.h	(revision 85718)
@@ -11,5 +11,5 @@
 
   @par Specification Reference:
-  AMD64 Architecture Programming Manaul volume 2, March 2017, Sections 15.34
+  AMD64 Architecture Programming Manual volume 2, March 2017, Sections 15.34
 
 **/
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/Msr/GoldmontPlusMsr.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/Msr/GoldmontPlusMsr.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/Msr/GoldmontPlusMsr.h	(revision 85718)
@@ -1,4 +1,4 @@
 /** @file
-  MSR Defintions for Intel Atom processors based on the Goldmont Plus microarchitecture.
+  MSR Definitions for Intel Atom processors based on the Goldmont Plus microarchitecture.
 
   Provides defines for Machine Specific Registers(MSR) indexes. Data structures
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/Msr/SkylakeMsr.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/Msr/SkylakeMsr.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/Msr/SkylakeMsr.h	(revision 85718)
@@ -1,4 +1,4 @@
 /** @file
-  MSR Defintions for Intel processors based on the Skylake/Kabylake/Coffeelake/Cannonlake microarchitecture.
+  MSR Definitions for Intel processors based on the Skylake/Kabylake/Coffeelake/Cannonlake microarchitecture.
 
   Provides defines for Machine Specific Registers(MSR) indexes. Data structures
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/StmResourceDescriptor.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/StmResourceDescriptor.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Register/Intel/StmResourceDescriptor.h	(revision 85718)
@@ -180,5 +180,5 @@
 
 /**
-  STM Register Volation Descriptor
+  STM Register Violation Descriptor
 **/
 typedef struct {
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/RiscV64/ProcessorBind.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/RiscV64/ProcessorBind.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/RiscV64/ProcessorBind.h	(revision 85718)
@@ -0,0 +1,173 @@
+/** @file
+  Processor or Compiler specific defines and types for RISC-V
+
+  Copyright (c) 2016 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PROCESSOR_BIND_H__
+#define PROCESSOR_BIND_H__
+
+///
+/// Define the processor type so other code can make processor based choices
+///
+#define MDE_CPU_RISCV64
+
+//
+// Make sure we are using the correct packing rules per EFI specification
+//
+#if !defined(__GNUC__)
+#pragma pack()
+#endif
+
+///
+/// 8-byte unsigned value
+///
+typedef unsigned long long  UINT64  __attribute__ ((aligned (8)));
+///
+/// 8-byte signed value
+///
+typedef long long           INT64  __attribute__ ((aligned (8)));
+///
+/// 4-byte unsigned value
+///
+typedef unsigned int        UINT32 __attribute__ ((aligned (4)));
+///
+/// 4-byte signed value
+///
+typedef int                 INT32  __attribute__ ((aligned (4)));
+///
+/// 2-byte unsigned value
+///
+typedef unsigned short      UINT16  __attribute__ ((aligned (2)));
+///
+/// 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  __attribute__ ((aligned (2)));
+///
+/// 2-byte signed value
+///
+typedef short               INT16  __attribute__ ((aligned (2)));
+///
+/// Logical Boolean.  1-byte value containing 0 for FALSE or a 1 for TRUE.  Other
+/// values are undefined.
+///
+typedef unsigned char       BOOLEAN;
+///
+/// 1-byte unsigned value
+///
+typedef unsigned char       UINT8;
+///
+/// 1-byte Character
+///
+typedef char                CHAR8;
+///
+/// 1-byte signed value
+///
+typedef signed char         INT8;
+///
+/// Unsigned value of native width.  (4 bytes on supported 32-bit processor instructions,
+/// 8 bytes on supported 64-bit processor instructions)
+///
+typedef UINT64  UINTN __attribute__ ((aligned (8)));
+///
+/// Signed value of native width.  (4 bytes on supported 32-bit processor instructions,
+/// 8 bytes on supported 64-bit processor instructions)
+///
+typedef INT64   INTN __attribute__ ((aligned (8)));
+
+//
+// Processor specific defines
+//
+
+///
+/// A value of native width with the highest bit set.
+///
+#define MAX_BIT     0x8000000000000000ULL
+///
+/// A value of native width with the two highest bits set.
+///
+#define MAX_2_BITS  0xC000000000000000ULL
+
+///
+/// Maximum legal RV64 address
+///
+#define MAX_ADDRESS   0xFFFFFFFFFFFFFFFFULL
+
+///
+/// Maximum usable address at boot time (48 bits using 4 KB pages in Supervisor mode)
+///
+#define MAX_ALLOC_ADDRESS   0xFFFFFFFFFFFFULL
+
+///
+/// Maximum legal RISC-V INTN and UINTN values.
+///
+#define MAX_INTN   ((INTN)0x7FFFFFFFFFFFFFFFULL)
+#define MAX_UINTN  ((UINTN)0xFFFFFFFFFFFFFFFFULL)
+
+///
+/// The stack alignment required for RISC-V
+///
+#define CPU_STACK_ALIGNMENT   16
+
+///
+/// Page allocation granularity for RISC-V
+///
+#define DEFAULT_PAGE_ALLOCATION_GRANULARITY   (0x1000)
+#define RUNTIME_PAGE_ALLOCATION_GRANULARITY   (0x1000)
+
+//
+// Modifier to ensure that all protocol member functions and EFI intrinsics
+// use the correct C calling convention. All protocol member functions and
+// EFI intrinsics are required to modify their member functions with EFIAPI.
+//
+#ifdef EFIAPI
+  ///
+  /// If EFIAPI is already defined, then we use that definition.
+  ///
+#elif defined(__GNUC__)
+  ///
+  /// Define the standard calling convention regardless of optimization level
+  /// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI
+  /// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)
+  /// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for
+  /// x64. Warning the assembly code in the MDE x64 does not follow the correct
+  /// ABI for the standard x64 (x86-64) GCC.
+  ///
+  #define EFIAPI
+#else
+  ///
+  /// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
+  /// is the standard.
+  ///
+  #define EFIAPI
+#endif
+
+#if defined(__GNUC__)
+  ///
+  /// For GNU assembly code, .global or .globl can declare global symbols.
+  /// Define this macro to unify the usage.
+  ///
+  #define ASM_GLOBAL .globl
+#endif
+
+/**
+  Return the pointer to the first instruction of a function given a function pointer.
+  On x64 CPU architectures, these two pointer values are the same,
+  so the implementation of this macro is very simple.
+
+  @param  FunctionPointer   A pointer to a function.
+
+  @return The pointer to the first instruction of a function given a function pointer.
+
+**/
+#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
+
+#ifndef __USER_LABEL_PREFIX__
+#define __USER_LABEL_PREFIX__
+#endif
+
+#endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiBaseType.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiBaseType.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiBaseType.h	(revision 85718)
@@ -4,4 +4,5 @@
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 Portions copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.<BR>
+Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -241,4 +242,10 @@
 #define EFI_IMAGE_MACHINE_AARCH64  0xAA64
 
+///
+/// PE32+ Machine type for RISC-V 32/64/128
+///
+#define EFI_IMAGE_MACHINE_RISCV32   0x5032
+#define EFI_IMAGE_MACHINE_RISCV64   0x5064
+#define EFI_IMAGE_MACHINE_RISCV128  0x5128
 
 #if   defined (MDE_CPU_IA32)
@@ -266,4 +273,10 @@
 #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
   ((Machine) == EFI_IMAGE_MACHINE_AARCH64)
+
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
+
+#elif defined (MDE_CPU_RISCV64)
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
+  ((Machine) == EFI_IMAGE_MACHINE_RISCV64)
 
 #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiInternalFormRepresentation.h	(revision 85718)
@@ -826,4 +826,5 @@
 #define EFI_IFR_FLAG_CALLBACK           0x04
 #define EFI_IFR_FLAG_RESET_REQUIRED     0x10
+#define EFI_IFR_FLAG_REST_STYLE         0x20
 #define EFI_IFR_FLAG_RECONNECT_REQUIRED 0x40
 #define EFI_IFR_FLAG_OPTIONS_ONLY       0x80
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiSpec.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiSpec.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/Uefi/UefiSpec.h	(revision 85718)
@@ -7,4 +7,6 @@
 
 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -83,4 +85,24 @@
 //
 #define EFI_MEMORY_MORE_RELIABLE    0x0000000000010000ULL
+
+//
+// Note: UEFI spec 2.8 and following:
+//
+// Specific-purpose memory (SPM). The memory is earmarked for
+// specific purposes such as for specific device drivers or applications.
+// The SPM attribute serves as a hint to the OS to avoid allocating this
+// memory for core OS data or code that can not be relocated.
+//
+#define EFI_MEMORY_SP               0x0000000000040000ULL
+//
+// If this flag is set, the memory region is capable of being
+// protected with the CPU?s memory cryptographic
+// capabilities. If this flag is clear, the memory region is not
+// capable of being protected with the CPU?s memory
+// cryptographic capabilities or the CPU does not support CPU
+// memory cryptographic capabilities.
+//
+#define EFI_MEMORY_CPU_CRYPTO       0x0000000000080000ULL
+
 //
 // Runtime memory attribute
@@ -190,5 +212,5 @@
                                          the buffer was large enough, or the size of the buffer needed to contain
                                          the map if the buffer was too small.
-  @param[in, out]  MemoryMap             A pointer to the buffer in which firmware places the current memory
+  @param[out]      MemoryMap             A pointer to the buffer in which firmware places the current memory
                                          map.
   @param[out]      MapKey                A pointer to the location in which firmware returns the key for the
@@ -211,5 +233,5 @@
 (EFIAPI *EFI_GET_MEMORY_MAP)(
   IN OUT UINTN                       *MemoryMapSize,
-  IN OUT EFI_MEMORY_DESCRIPTOR       *MemoryMap,
+  OUT    EFI_MEMORY_DESCRIPTOR       *MemoryMap,
   OUT    UINTN                       *MapKey,
   OUT    UINTN                       *DescriptorSize,
@@ -1535,5 +1557,5 @@
                                 This parameter is only valid for a SearchType of ByProtocol.
   @param[in]       SearchKey    Supplies the search key depending on the SearchType.
-  @param[in, out]  NoHandles    The number of handles returned in Buffer.
+  @param[out]      NoHandles    The number of handles returned in Buffer.
   @param[out]      Buffer       A pointer to the buffer to return the requested array of handles that
                                 support Protocol.
@@ -1553,5 +1575,5 @@
   IN     EFI_GUID                     *Protocol,      OPTIONAL
   IN     VOID                         *SearchKey,     OPTIONAL
-  IN OUT UINTN                        *NoHandles,
+  OUT    UINTN                        *NoHandles,
   OUT    EFI_HANDLE                   **Buffer
   );
@@ -1762,4 +1784,5 @@
 #define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED     0x0000000000000010
 #define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY          0x0000000000000040
+#define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH         0x0000000000000080
 
 //
@@ -1767,4 +1790,5 @@
 //
 #define EFI_SYSTEM_TABLE_SIGNATURE      SIGNATURE_64 ('I','B','I',' ','S','Y','S','T')
+#define EFI_2_80_SYSTEM_TABLE_REVISION  ((2 << 16) | (80))
 #define EFI_2_70_SYSTEM_TABLE_REVISION  ((2 << 16) | (70))
 #define EFI_2_60_SYSTEM_TABLE_REVISION  ((2 << 16) | (60))
@@ -2193,4 +2217,5 @@
 #define EFI_REMOVABLE_MEDIA_FILE_NAME_ARM     L"\\EFI\\BOOT\\BOOTARM.EFI"
 #define EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64 L"\\EFI\\BOOT\\BOOTAA64.EFI"
+#define EFI_REMOVABLE_MEDIA_FILE_NAME_RISCV64 L"\\EFI\\BOOT\\BOOTRISCV64.EFI"
 
 #if   defined (MDE_CPU_IA32)
@@ -2203,4 +2228,6 @@
 #elif defined (MDE_CPU_AARCH64)
   #define EFI_REMOVABLE_MEDIA_FILE_NAME   EFI_REMOVABLE_MEDIA_FILE_NAME_AARCH64
+#elif defined (MDE_CPU_RISCV64)
+  #define EFI_REMOVABLE_MEDIA_FILE_NAME   EFI_REMOVABLE_MEDIA_FILE_NAME_RISCV64
 #else
   #error Unknown Processor Type
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/X64/ProcessorBind.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/X64/ProcessorBind.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/X64/ProcessorBind.h	(revision 85718)
@@ -102,5 +102,5 @@
 #pragma warning ( disable : 4206 )
 
-#if _MSC_VER == 1800 || _MSC_VER == 1900 || _MSC_VER >= 1910
+#if defined(_MSC_VER) && _MSC_VER >= 1800
 
 //
@@ -314,5 +314,5 @@
 #endif
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
   ///
   /// For GNU assembly code, .global or .globl can declare global symbols.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf	(revision 85718)
@@ -7,4 +7,5 @@
 #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+#  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -42,4 +43,7 @@
   ArmCache.c
 
+[Sources.RISCV64]
+  RiscVCache.c
+
 [Packages]
   MdePkg/MdePkg.dec
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c	(revision 85718)
@@ -0,0 +1,250 @@
+/** @file
+  RISC-V specific functionality for cache.
+
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+/**
+  RISC-V invalidate instruction cache.
+
+**/
+VOID
+EFIAPI
+RiscVInvalidateInstCacheAsm (
+  VOID
+  );
+
+/**
+  RISC-V invalidate data cache.
+
+**/
+VOID
+EFIAPI
+RiscVInvalidateDataCacheAsm (
+  VOID
+  );
+
+/**
+  Invalidates the entire instruction cache in cache coherency domain of the
+  calling CPU.
+
+**/
+VOID
+EFIAPI
+InvalidateInstructionCache (
+  VOID
+  )
+{
+  RiscVInvalidateInstCacheAsm ();
+}
+
+/**
+  Invalidates a range of instruction cache lines in the cache coherency domain
+  of the calling CPU.
+
+  Invalidates the instruction cache lines specified by Address and Length. If
+  Address is not aligned on a cache line boundary, then entire instruction
+  cache line containing Address is invalidated. If Address + Length is not
+  aligned on a cache line boundary, then the entire instruction cache line
+  containing Address + Length -1 is invalidated. This function may choose to
+  invalidate the entire instruction cache if that is more efficient than
+  invalidating the specified range. If Length is 0, then no instruction cache
+  lines are invalidated. Address is returned.
+
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+  @param  Address The base address of the instruction cache lines to
+                  invalidate. If the CPU is in a physical addressing mode, then
+                  Address is a physical address. If the CPU is in a virtual
+                  addressing mode, then Address is a virtual address.
+
+  @param  Length  The number of bytes to invalidate from the instruction cache.
+
+  @return Address.
+
+**/
+VOID *
+EFIAPI
+InvalidateInstructionCacheRange (
+  IN VOID *Address,
+  IN UINTN Length
+  )
+{
+  DEBUG((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  return Address;
+}
+
+/**
+  Writes back and invalidates the entire data cache in cache coherency domain
+  of the calling CPU.
+
+  Writes back and invalidates the entire data cache in cache coherency domain
+  of the calling CPU. This function guarantees that all dirty cache lines are
+  written back to system memory, and also invalidates all the data cache lines
+  in the cache coherency domain of the calling CPU.
+
+**/
+VOID
+EFIAPI
+WriteBackInvalidateDataCache (
+  VOID
+  )
+{
+  DEBUG((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+}
+
+/**
+  Writes back and invalidates a range of data cache lines in the cache
+  coherency domain of the calling CPU.
+
+  Writes back and invalidates the data cache lines specified by Address and
+  Length. If Address is not aligned on a cache line boundary, then entire data
+  cache line containing Address is written back and invalidated. If Address +
+  Length is not aligned on a cache line boundary, then the entire data cache
+  line containing Address + Length -1 is written back and invalidated. This
+  function may choose to write back and invalidate the entire data cache if
+  that is more efficient than writing back and invalidating the specified
+  range. If Length is 0, then no data cache lines are written back and
+  invalidated. Address is returned.
+
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+  @param  Address The base address of the data cache lines to write back and
+                  invalidate. If the CPU is in a physical addressing mode, then
+                  Address is a physical address. If the CPU is in a virtual
+                  addressing mode, then Address is a virtual address.
+  @param  Length  The number of bytes to write back and invalidate from the
+                  data cache.
+
+  @return Address of cache invalidation.
+
+**/
+VOID *
+EFIAPI
+WriteBackInvalidateDataCacheRange (
+  IN      VOID                      *Address,
+  IN      UINTN                     Length
+  )
+{
+  DEBUG((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  return Address;
+}
+
+/**
+  Writes back the entire data cache in cache coherency domain of the calling
+  CPU.
+
+  Writes back the entire data cache in cache coherency domain of the calling
+  CPU. This function guarantees that all dirty cache lines are written back to
+  system memory. This function may also invalidate all the data cache lines in
+  the cache coherency domain of the calling CPU.
+
+**/
+VOID
+EFIAPI
+WriteBackDataCache (
+  VOID
+  )
+{
+  DEBUG((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+}
+
+/**
+  Writes back a range of data cache lines in the cache coherency domain of the
+  calling CPU.
+
+  Writes back the data cache lines specified by Address and Length. If Address
+  is not aligned on a cache line boundary, then entire data cache line
+  containing Address is written back. If Address + Length is not aligned on a
+  cache line boundary, then the entire data cache line containing Address +
+  Length -1 is written back. This function may choose to write back the entire
+  data cache if that is more efficient than writing back the specified range.
+  If Length is 0, then no data cache lines are written back. This function may
+  also invalidate all the data cache lines in the specified range of the cache
+  coherency domain of the calling CPU. Address is returned.
+
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+  @param  Address The base address of the data cache lines to write back. If
+                  the CPU is in a physical addressing mode, then Address is a
+                  physical address. If the CPU is in a virtual addressing
+                  mode, then Address is a virtual address.
+  @param  Length  The number of bytes to write back from the data cache.
+
+  @return Address of cache written in main memory.
+
+**/
+VOID *
+EFIAPI
+WriteBackDataCacheRange (
+  IN      VOID                      *Address,
+  IN      UINTN                     Length
+  )
+{
+  DEBUG((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  return Address;
+}
+
+/**
+  Invalidates the entire data cache in cache coherency domain of the calling
+  CPU.
+
+  Invalidates the entire data cache in cache coherency domain of the calling
+  CPU. This function must be used with care because dirty cache lines are not
+  written back to system memory. It is typically used for cache diagnostics. If
+  the CPU does not support invalidation of the entire data cache, then a write
+  back and invalidate operation should be performed on the entire data cache.
+
+**/
+VOID
+EFIAPI
+InvalidateDataCache (
+  VOID
+  )
+{
+  RiscVInvalidateDataCacheAsm ();
+}
+
+/**
+  Invalidates a range of data cache lines in the cache coherency domain of the
+  calling CPU.
+
+  Invalidates the data cache lines specified by Address and Length. If Address
+  is not aligned on a cache line boundary, then entire data cache line
+  containing Address is invalidated. If Address + Length is not aligned on a
+  cache line boundary, then the entire data cache line containing Address +
+  Length -1 is invalidated. This function must never invalidate any cache lines
+  outside the specified range. If Length is 0, then no data cache lines are
+  invalidated. Address is returned. This function must be used with care
+  because dirty cache lines are not written back to system memory. It is
+  typically used for cache diagnostics. If the CPU does not support
+  invalidation of a data cache range, then a write back and invalidate
+  operation should be performed on the data cache range.
+
+  If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+  @param  Address The base address of the data cache lines to invalidate. If
+                  the CPU is in a physical addressing mode, then Address is a
+                  physical address. If the CPU is in a virtual addressing mode,
+                  then Address is a virtual address.
+  @param  Length  The number of bytes to invalidate from the data cache.
+
+  @return Address.
+
+**/
+VOID *
+EFIAPI
+InvalidateDataCacheRange (
+  IN      VOID                      *Address,
+  IN      UINTN                     Length
+  )
+{
+  DEBUG((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  return Address;
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf	(revision 85718)
@@ -8,4 +8,5 @@
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
 #  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
+#  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -25,5 +26,5 @@
 
 #
-#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64
+#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64 RISCV64
 #
 
@@ -60,4 +61,7 @@
   AArch64/CpuSleep.asm    | MSFT
 
+[Sources.RISCV64]
+  RiscV/Cpu.S
+
 [Packages]
   MdePkg/MdePkg.dec
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni	(revision 85718)
@@ -2,5 +2,5 @@
 // Instance of CPU Library for various architecture.
 //
-// CPU Library implemented using ASM functions for IA-32 and X64,
+// CPU Library implemented using ASM functions for IA-32, X64 and RISCV64,
 // PAL CALLs for IPF, and empty functions for EBC.
 //
@@ -8,4 +8,5 @@
 // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
 // Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -16,4 +17,4 @@
 #string STR_MODULE_ABSTRACT             #language en-US "Instance of CPU Library for various architectures"
 
-#string STR_MODULE_DESCRIPTION          #language en-US "CPU Library implemented using ASM functions for IA-32 and X64, PAL CALLs for IPF, and empty functions for EBC."
+#string STR_MODULE_DESCRIPTION          #language en-US "CPU Library implemented using ASM functions for IA-32, X64 and RISCV64, PAL CALLs for IPF, and empty functions for EBC."
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/RiscV/Cpu.S
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/RiscV/Cpu.S	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseCpuLib/RiscV/Cpu.S	(revision 85718)
@@ -0,0 +1,19 @@
+//------------------------------------------------------------------------------
+//
+// CpuSleep for RISC-V
+//
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//------------------------------------------------------------------------------
+.data
+.align 3
+.section .text
+
+.global ASM_PFX(_CpuSleep)
+
+ASM_PFX(_CpuSleep):
+    wfi
+    ret
+
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf	(revision 85718)
@@ -5,9 +5,11 @@
 #  for IA-32 and x64.  On IPF, I/O port requests are translated into MMIO requests.
 #  MMIO requests are forwarded directly to memory.  For EBC, I/O port requests
-#  ASSERT().
+#  ASSERT(). For ARM, AARCH64 and RISCV64, this I/O library only provides non I/O
+#  read and write.
 #
 #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
 #  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+#  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -26,5 +28,5 @@
 
 #
-#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64
+#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64 RISCV64
 #
 
@@ -51,8 +53,11 @@
 
 [Sources.ARM]
-  IoLibArm.c
+  IoLibNoIo.c
 
 [Sources.AARCH64]
-  IoLibArm.c
+  IoLibNoIo.c
+
+[Sources.RISCV64]
+  IoLibNoIo.c
 
 [Packages]
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/IoLibArm.c	(revision 85716)
+++ 	(revision )
@@ -1,593 +1,0 @@
-/** @file
-  I/O Library for ARM.
-
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
-  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
-
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-
-//
-// Include common header file for this module.
-//
-#include "BaseIoLibIntrinsicInternal.h"
-
-/**
-  Reads an 8-bit I/O port.
-
-  Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
-  This function must guarantee that all I/O read and write operations are
-  serialized.
-
-  If 8-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port  The I/O port to read.
-
-  @return The value read.
-
-**/
-UINT8
-EFIAPI
-IoRead8 (
-  IN      UINTN                     Port
-  )
-{
-  ASSERT (FALSE);
-  return 0;
-}
-
-/**
-  Writes an 8-bit I/O port.
-
-  Writes the 8-bit I/O port specified by Port with the value specified by Value
-  and returns Value. This function must guarantee that all I/O read and write
-  operations are serialized.
-
-  If 8-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port  The I/O port to write.
-  @param  Value The value to write to the I/O port.
-
-  @return The value written the I/O port.
-
-**/
-UINT8
-EFIAPI
-IoWrite8 (
-  IN      UINTN                     Port,
-  IN      UINT8                     Value
-  )
-{
-  ASSERT (FALSE);
-  return Value;
-}
-
-/**
-  Reads a 16-bit I/O port.
-
-  Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
-  This function must guarantee that all I/O read and write operations are
-  serialized.
-
-  If 16-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port  The I/O port to read.
-
-  @return The value read.
-
-**/
-UINT16
-EFIAPI
-IoRead16 (
-  IN      UINTN                     Port
-  )
-{
-  ASSERT (FALSE);
-  return 0;
-}
-
-/**
-  Writes a 16-bit I/O port.
-
-  Writes the 16-bit I/O port specified by Port with the value specified by Value
-  and returns Value. This function must guarantee that all I/O read and write
-  operations are serialized.
-
-  If 16-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port  The I/O port to write.
-  @param  Value The value to write to the I/O port.
-
-  @return The value written the I/O port.
-
-**/
-UINT16
-EFIAPI
-IoWrite16 (
-  IN      UINTN                     Port,
-  IN      UINT16                    Value
-  )
-{
-  ASSERT (FALSE);
-  return Value;
-}
-
-/**
-  Reads a 32-bit I/O port.
-
-  Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
-  This function must guarantee that all I/O read and write operations are
-  serialized.
-
-  If 32-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port  The I/O port to read.
-
-  @return The value read.
-
-**/
-UINT32
-EFIAPI
-IoRead32 (
-  IN      UINTN                     Port
-  )
-{
-  ASSERT (FALSE);
-  return 0;
-}
-
-/**
-  Writes a 32-bit I/O port.
-
-  Writes the 32-bit I/O port specified by Port with the value specified by Value
-  and returns Value. This function must guarantee that all I/O read and write
-  operations are serialized.
-
-  If 32-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port  The I/O port to write.
-  @param  Value The value to write to the I/O port.
-
-  @return The value written the I/O port.
-
-**/
-UINT32
-EFIAPI
-IoWrite32 (
-  IN      UINTN                     Port,
-  IN      UINT32                    Value
-  )
-{
-  ASSERT (FALSE);
-  return Value;
-}
-
-/**
-  Reads a 64-bit I/O port.
-
-  Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
-  This function must guarantee that all I/O read and write operations are
-  serialized.
-
-  If 64-bit I/O port operations are not supported, then ASSERT().
-  If Port is not aligned on a 64-bit boundary, then ASSERT().
-
-  @param  Port  The I/O port to read.
-
-  @return The value read.
-
-**/
-UINT64
-EFIAPI
-IoRead64 (
-  IN      UINTN                     Port
-  )
-{
-  ASSERT (FALSE);
-  return 0;
-}
-
-/**
-  Writes a 64-bit I/O port.
-
-  Writes the 64-bit I/O port specified by Port with the value specified by Value
-  and returns Value. This function must guarantee that all I/O read and write
-  operations are serialized.
-
-  If 64-bit I/O port operations are not supported, then ASSERT().
-  If Port is not aligned on a 64-bit boundary, then ASSERT().
-
-  @param  Port  The I/O port to write.
-  @param  Value The value to write to the I/O port.
-
-  @return The value written to the I/O port.
-
-**/
-UINT64
-EFIAPI
-IoWrite64 (
-  IN      UINTN                     Port,
-  IN      UINT64                    Value
-  )
-{
-  ASSERT (FALSE);
-  return 0;
-}
-
-/**
-  Reads an 8-bit I/O port fifo into a block of memory.
-
-  Reads the 8-bit I/O fifo port specified by Port.
-  The port is read Count times, and the read data is
-  stored in the provided Buffer.
-
-  This function must guarantee that all I/O read and write operations are
-  serialized.
-
-  If 8-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port    The I/O port to read.
-  @param  Count   The number of times to read I/O port.
-  @param  Buffer  The buffer to store the read data into.
-
-**/
-VOID
-EFIAPI
-IoReadFifo8 (
-  IN      UINTN                     Port,
-  IN      UINTN                     Count,
-  OUT     VOID                      *Buffer
-  )
-{
-  ASSERT (FALSE);
-}
-
-/**
-  Writes a block of memory into an 8-bit I/O port fifo.
-
-  Writes the 8-bit I/O fifo port specified by Port.
-  The port is written Count times, and the write data is
-  retrieved from the provided Buffer.
-
-  This function must guarantee that all I/O write and write operations are
-  serialized.
-
-  If 8-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port    The I/O port to write.
-  @param  Count   The number of times to write I/O port.
-  @param  Buffer  The buffer to retrieve the write data from.
-
-**/
-VOID
-EFIAPI
-IoWriteFifo8 (
-  IN      UINTN                     Port,
-  IN      UINTN                     Count,
-  IN      VOID                      *Buffer
-  )
-{
-  ASSERT (FALSE);
-}
-
-/**
-  Reads a 16-bit I/O port fifo into a block of memory.
-
-  Reads the 16-bit I/O fifo port specified by Port.
-  The port is read Count times, and the read data is
-  stored in the provided Buffer.
-
-  This function must guarantee that all I/O read and write operations are
-  serialized.
-
-  If 16-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port    The I/O port to read.
-  @param  Count   The number of times to read I/O port.
-  @param  Buffer  The buffer to store the read data into.
-
-**/
-VOID
-EFIAPI
-IoReadFifo16 (
-  IN      UINTN                     Port,
-  IN      UINTN                     Count,
-  OUT     VOID                      *Buffer
-  )
-{
-  ASSERT (FALSE);
-}
-
-/**
-  Writes a block of memory into a 16-bit I/O port fifo.
-
-  Writes the 16-bit I/O fifo port specified by Port.
-  The port is written Count times, and the write data is
-  retrieved from the provided Buffer.
-
-  This function must guarantee that all I/O write and write operations are
-  serialized.
-
-  If 16-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port    The I/O port to write.
-  @param  Count   The number of times to write I/O port.
-  @param  Buffer  The buffer to retrieve the write data from.
-
-**/
-VOID
-EFIAPI
-IoWriteFifo16 (
-  IN      UINTN                     Port,
-  IN      UINTN                     Count,
-  IN      VOID                      *Buffer
-  )
-{
-  ASSERT (FALSE);
-}
-
-/**
-  Reads a 32-bit I/O port fifo into a block of memory.
-
-  Reads the 32-bit I/O fifo port specified by Port.
-  The port is read Count times, and the read data is
-  stored in the provided Buffer.
-
-  This function must guarantee that all I/O read and write operations are
-  serialized.
-
-  If 32-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port    The I/O port to read.
-  @param  Count   The number of times to read I/O port.
-  @param  Buffer  The buffer to store the read data into.
-
-**/
-VOID
-EFIAPI
-IoReadFifo32 (
-  IN      UINTN                     Port,
-  IN      UINTN                     Count,
-  OUT     VOID                      *Buffer
-  )
-{
-  ASSERT (FALSE);
-}
-
-/**
-  Writes a block of memory into a 32-bit I/O port fifo.
-
-  Writes the 32-bit I/O fifo port specified by Port.
-  The port is written Count times, and the write data is
-  retrieved from the provided Buffer.
-
-  This function must guarantee that all I/O write and write operations are
-  serialized.
-
-  If 32-bit I/O port operations are not supported, then ASSERT().
-
-  @param  Port    The I/O port to write.
-  @param  Count   The number of times to write I/O port.
-  @param  Buffer  The buffer to retrieve the write data from.
-
-**/
-VOID
-EFIAPI
-IoWriteFifo32 (
-  IN      UINTN                     Port,
-  IN      UINTN                     Count,
-  IN      VOID                      *Buffer
-  )
-{
-  ASSERT (FALSE);
-}
-
-/**
-  Reads an 8-bit MMIO register.
-
-  Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
-  returned. This function must guarantee that all MMIO read and write
-  operations are serialized.
-
-  If 8-bit MMIO register operations are not supported, then ASSERT().
-
-  @param  Address The MMIO register to read.
-
-  @return The value read.
-
-**/
-UINT8
-EFIAPI
-MmioRead8 (
-  IN      UINTN                     Address
-  )
-{
-  UINT8                             Value;
-
-  Value = *(volatile UINT8*)Address;
-  return Value;
-}
-
-/**
-  Writes an 8-bit MMIO register.
-
-  Writes the 8-bit MMIO register specified by Address with the value specified
-  by Value and returns Value. This function must guarantee that all MMIO read
-  and write operations are serialized.
-
-  If 8-bit MMIO register operations are not supported, then ASSERT().
-
-  @param  Address The MMIO register to write.
-  @param  Value   The value to write to the MMIO register.
-
-**/
-UINT8
-EFIAPI
-MmioWrite8 (
-  IN      UINTN                     Address,
-  IN      UINT8                     Value
-  )
-{
-  *(volatile UINT8*)Address = Value;
-  return Value;
-}
-
-/**
-  Reads a 16-bit MMIO register.
-
-  Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
-  returned. This function must guarantee that all MMIO read and write
-  operations are serialized.
-
-  If 16-bit MMIO register operations are not supported, then ASSERT().
-
-  @param  Address The MMIO register to read.
-
-  @return The value read.
-
-**/
-UINT16
-EFIAPI
-MmioRead16 (
-  IN      UINTN                     Address
-  )
-{
-  UINT16                            Value;
-
-  ASSERT ((Address & 1) == 0);
-  Value = *(volatile UINT16*)Address;
-  return Value;
-}
-
-/**
-  Writes a 16-bit MMIO register.
-
-  Writes the 16-bit MMIO register specified by Address with the value specified
-  by Value and returns Value. This function must guarantee that all MMIO read
-  and write operations are serialized.
-
-  If 16-bit MMIO register operations are not supported, then ASSERT().
-
-  @param  Address The MMIO register to write.
-  @param  Value   The value to write to the MMIO register.
-
-**/
-UINT16
-EFIAPI
-MmioWrite16 (
-  IN      UINTN                     Address,
-  IN      UINT16                    Value
-  )
-{
-  ASSERT ((Address & 1) == 0);
-  *(volatile UINT16*)Address = Value;
-  return Value;
-}
-
-/**
-  Reads a 32-bit MMIO register.
-
-  Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
-  returned. This function must guarantee that all MMIO read and write
-  operations are serialized.
-
-  If 32-bit MMIO register operations are not supported, then ASSERT().
-
-  @param  Address The MMIO register to read.
-
-  @return The value read.
-
-**/
-UINT32
-EFIAPI
-MmioRead32 (
-  IN      UINTN                     Address
-  )
-{
-  UINT32                            Value;
-
-  ASSERT ((Address & 3) == 0);
-  Value = *(volatile UINT32*)Address;
-  return Value;
-}
-
-/**
-  Writes a 32-bit MMIO register.
-
-  Writes the 32-bit MMIO register specified by Address with the value specified
-  by Value and returns Value. This function must guarantee that all MMIO read
-  and write operations are serialized.
-
-  If 32-bit MMIO register operations are not supported, then ASSERT().
-
-  @param  Address The MMIO register to write.
-  @param  Value   The value to write to the MMIO register.
-
-**/
-UINT32
-EFIAPI
-MmioWrite32 (
-  IN      UINTN                     Address,
-  IN      UINT32                    Value
-  )
-{
-  ASSERT ((Address & 3) == 0);
-  *(volatile UINT32*)Address = Value;
-  return Value;
-}
-
-/**
-  Reads a 64-bit MMIO register.
-
-  Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
-  returned. This function must guarantee that all MMIO read and write
-  operations are serialized.
-
-  If 64-bit MMIO register operations are not supported, then ASSERT().
-
-  @param  Address The MMIO register to read.
-
-  @return The value read.
-
-**/
-UINT64
-EFIAPI
-MmioRead64 (
-  IN      UINTN                     Address
-  )
-{
-  UINT64                            Value;
-
-  ASSERT ((Address & 7) == 0);
-  Value = *(volatile UINT64*)Address;
-  return Value;
-}
-
-/**
-  Writes a 64-bit MMIO register.
-
-  Writes the 64-bit MMIO register specified by Address with the value specified
-  by Value and returns Value. This function must guarantee that all MMIO read
-  and write operations are serialized.
-
-  If 64-bit MMIO register operations are not supported, then ASSERT().
-
-  @param  Address The MMIO register to write.
-  @param  Value   The value to write to the MMIO register.
-
-**/
-UINT64
-EFIAPI
-MmioWrite64 (
-  IN      UINTN                     Address,
-  IN      UINT64                    Value
-  )
-{
-  ASSERT ((Address & 7) == 0);
-  *(volatile UINT64*)Address = Value;
-  return Value;
-}
-
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c	(revision 85718)
@@ -33,5 +33,4 @@
 
 **/
-__inline__
 UINT8
 EFIAPI
@@ -61,5 +60,4 @@
 
 **/
-__inline__
 UINT8
 EFIAPI
@@ -88,5 +86,4 @@
 
 **/
-__inline__
 UINT16
 EFIAPI
@@ -118,5 +115,4 @@
 
 **/
-__inline__
 UINT16
 EFIAPI
@@ -146,5 +142,4 @@
 
 **/
-__inline__
 UINT32
 EFIAPI
@@ -176,5 +171,4 @@
 
 **/
-__inline__
 UINT32
 EFIAPI
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseIoLibIntrinsic/IoLibNoIo.c	(revision 85718)
@@ -0,0 +1,595 @@
+/** @file
+  I/O library for non I/O read and write access (memory map I/O read and
+  write only) architecture, such as ARM and RISC-V processor.
+
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+  Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+//
+// Include common header file for this module.
+//
+#include "BaseIoLibIntrinsicInternal.h"
+
+/**
+  Reads an 8-bit I/O port.
+
+  Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
+  This function must guarantee that all I/O read and write operations are
+  serialized.
+
+  If 8-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT8
+EFIAPI
+IoRead8 (
+  IN      UINTN                     Port
+  )
+{
+  ASSERT (FALSE);
+  return 0;
+}
+
+/**
+  Writes an 8-bit I/O port.
+
+  Writes the 8-bit I/O port specified by Port with the value specified by Value
+  and returns Value. This function must guarantee that all I/O read and write
+  operations are serialized.
+
+  If 8-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port  The I/O port to write.
+  @param  Value The value to write to the I/O port.
+
+  @return The value written the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoWrite8 (
+  IN      UINTN                     Port,
+  IN      UINT8                     Value
+  )
+{
+  ASSERT (FALSE);
+  return Value;
+}
+
+/**
+  Reads a 16-bit I/O port.
+
+  Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
+  This function must guarantee that all I/O read and write operations are
+  serialized.
+
+  If 16-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT16
+EFIAPI
+IoRead16 (
+  IN      UINTN                     Port
+  )
+{
+  ASSERT (FALSE);
+  return 0;
+}
+
+/**
+  Writes a 16-bit I/O port.
+
+  Writes the 16-bit I/O port specified by Port with the value specified by Value
+  and returns Value. This function must guarantee that all I/O read and write
+  operations are serialized.
+
+  If 16-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port  The I/O port to write.
+  @param  Value The value to write to the I/O port.
+
+  @return The value written the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoWrite16 (
+  IN      UINTN                     Port,
+  IN      UINT16                    Value
+  )
+{
+  ASSERT (FALSE);
+  return Value;
+}
+
+/**
+  Reads a 32-bit I/O port.
+
+  Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
+  This function must guarantee that all I/O read and write operations are
+  serialized.
+
+  If 32-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT32
+EFIAPI
+IoRead32 (
+  IN      UINTN                     Port
+  )
+{
+  ASSERT (FALSE);
+  return 0;
+}
+
+/**
+  Writes a 32-bit I/O port.
+
+  Writes the 32-bit I/O port specified by Port with the value specified by Value
+  and returns Value. This function must guarantee that all I/O read and write
+  operations are serialized.
+
+  If 32-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port  The I/O port to write.
+  @param  Value The value to write to the I/O port.
+
+  @return The value written the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoWrite32 (
+  IN      UINTN                     Port,
+  IN      UINT32                    Value
+  )
+{
+  ASSERT (FALSE);
+  return Value;
+}
+
+/**
+  Reads a 64-bit I/O port.
+
+  Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
+  This function must guarantee that all I/O read and write operations are
+  serialized.
+
+  If 64-bit I/O port operations are not supported, then ASSERT().
+  If Port is not aligned on a 64-bit boundary, then ASSERT().
+
+  @param  Port  The I/O port to read.
+
+  @return The value read.
+
+**/
+UINT64
+EFIAPI
+IoRead64 (
+  IN      UINTN                     Port
+  )
+{
+  ASSERT (FALSE);
+  return 0;
+}
+
+/**
+  Writes a 64-bit I/O port.
+
+  Writes the 64-bit I/O port specified by Port with the value specified by Value
+  and returns Value. This function must guarantee that all I/O read and write
+  operations are serialized.
+
+  If 64-bit I/O port operations are not supported, then ASSERT().
+  If Port is not aligned on a 64-bit boundary, then ASSERT().
+
+  @param  Port  The I/O port to write.
+  @param  Value The value to write to the I/O port.
+
+  @return The value written to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoWrite64 (
+  IN      UINTN                     Port,
+  IN      UINT64                    Value
+  )
+{
+  ASSERT (FALSE);
+  return 0;
+}
+
+/**
+  Reads an 8-bit I/O port fifo into a block of memory.
+
+  Reads the 8-bit I/O fifo port specified by Port.
+  The port is read Count times, and the read data is
+  stored in the provided Buffer.
+
+  This function must guarantee that all I/O read and write operations are
+  serialized.
+
+  If 8-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port    The I/O port to read.
+  @param  Count   The number of times to read I/O port.
+  @param  Buffer  The buffer to store the read data into.
+
+**/
+VOID
+EFIAPI
+IoReadFifo8 (
+  IN      UINTN                     Port,
+  IN      UINTN                     Count,
+  OUT     VOID                      *Buffer
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Writes a block of memory into an 8-bit I/O port fifo.
+
+  Writes the 8-bit I/O fifo port specified by Port.
+  The port is written Count times, and the write data is
+  retrieved from the provided Buffer.
+
+  This function must guarantee that all I/O write and write operations are
+  serialized.
+
+  If 8-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port    The I/O port to write.
+  @param  Count   The number of times to write I/O port.
+  @param  Buffer  The buffer to retrieve the write data from.
+
+**/
+VOID
+EFIAPI
+IoWriteFifo8 (
+  IN      UINTN                     Port,
+  IN      UINTN                     Count,
+  IN      VOID                      *Buffer
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Reads a 16-bit I/O port fifo into a block of memory.
+
+  Reads the 16-bit I/O fifo port specified by Port.
+  The port is read Count times, and the read data is
+  stored in the provided Buffer.
+
+  This function must guarantee that all I/O read and write operations are
+  serialized.
+
+  If 16-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port    The I/O port to read.
+  @param  Count   The number of times to read I/O port.
+  @param  Buffer  The buffer to store the read data into.
+
+**/
+VOID
+EFIAPI
+IoReadFifo16 (
+  IN      UINTN                     Port,
+  IN      UINTN                     Count,
+  OUT     VOID                      *Buffer
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Writes a block of memory into a 16-bit I/O port fifo.
+
+  Writes the 16-bit I/O fifo port specified by Port.
+  The port is written Count times, and the write data is
+  retrieved from the provided Buffer.
+
+  This function must guarantee that all I/O write and write operations are
+  serialized.
+
+  If 16-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port    The I/O port to write.
+  @param  Count   The number of times to write I/O port.
+  @param  Buffer  The buffer to retrieve the write data from.
+
+**/
+VOID
+EFIAPI
+IoWriteFifo16 (
+  IN      UINTN                     Port,
+  IN      UINTN                     Count,
+  IN      VOID                      *Buffer
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Reads a 32-bit I/O port fifo into a block of memory.
+
+  Reads the 32-bit I/O fifo port specified by Port.
+  The port is read Count times, and the read data is
+  stored in the provided Buffer.
+
+  This function must guarantee that all I/O read and write operations are
+  serialized.
+
+  If 32-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port    The I/O port to read.
+  @param  Count   The number of times to read I/O port.
+  @param  Buffer  The buffer to store the read data into.
+
+**/
+VOID
+EFIAPI
+IoReadFifo32 (
+  IN      UINTN                     Port,
+  IN      UINTN                     Count,
+  OUT     VOID                      *Buffer
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Writes a block of memory into a 32-bit I/O port fifo.
+
+  Writes the 32-bit I/O fifo port specified by Port.
+  The port is written Count times, and the write data is
+  retrieved from the provided Buffer.
+
+  This function must guarantee that all I/O write and write operations are
+  serialized.
+
+  If 32-bit I/O port operations are not supported, then ASSERT().
+
+  @param  Port    The I/O port to write.
+  @param  Count   The number of times to write I/O port.
+  @param  Buffer  The buffer to retrieve the write data from.
+
+**/
+VOID
+EFIAPI
+IoWriteFifo32 (
+  IN      UINTN                     Port,
+  IN      UINTN                     Count,
+  IN      VOID                      *Buffer
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Reads an 8-bit MMIO register.
+
+  Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
+  returned. This function must guarantee that all MMIO read and write
+  operations are serialized.
+
+  If 8-bit MMIO register operations are not supported, then ASSERT().
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT8
+EFIAPI
+MmioRead8 (
+  IN      UINTN                     Address
+  )
+{
+  UINT8                             Value;
+
+  Value = *(volatile UINT8*)Address;
+  return Value;
+}
+
+/**
+  Writes an 8-bit MMIO register.
+
+  Writes the 8-bit MMIO register specified by Address with the value specified
+  by Value and returns Value. This function must guarantee that all MMIO read
+  and write operations are serialized.
+
+  If 8-bit MMIO register operations are not supported, then ASSERT().
+
+  @param  Address The MMIO register to write.
+  @param  Value   The value to write to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioWrite8 (
+  IN      UINTN                     Address,
+  IN      UINT8                     Value
+  )
+{
+  *(volatile UINT8*)Address = Value;
+  return Value;
+}
+
+/**
+  Reads a 16-bit MMIO register.
+
+  Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
+  returned. This function must guarantee that all MMIO read and write
+  operations are serialized.
+
+  If 16-bit MMIO register operations are not supported, then ASSERT().
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT16
+EFIAPI
+MmioRead16 (
+  IN      UINTN                     Address
+  )
+{
+  UINT16                            Value;
+
+  ASSERT ((Address & 1) == 0);
+  Value = *(volatile UINT16*)Address;
+  return Value;
+}
+
+/**
+  Writes a 16-bit MMIO register.
+
+  Writes the 16-bit MMIO register specified by Address with the value specified
+  by Value and returns Value. This function must guarantee that all MMIO read
+  and write operations are serialized.
+
+  If 16-bit MMIO register operations are not supported, then ASSERT().
+
+  @param  Address The MMIO register to write.
+  @param  Value   The value to write to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioWrite16 (
+  IN      UINTN                     Address,
+  IN      UINT16                    Value
+  )
+{
+  ASSERT ((Address & 1) == 0);
+  *(volatile UINT16*)Address = Value;
+  return Value;
+}
+
+/**
+  Reads a 32-bit MMIO register.
+
+  Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
+  returned. This function must guarantee that all MMIO read and write
+  operations are serialized.
+
+  If 32-bit MMIO register operations are not supported, then ASSERT().
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT32
+EFIAPI
+MmioRead32 (
+  IN      UINTN                     Address
+  )
+{
+  UINT32                            Value;
+
+  ASSERT ((Address & 3) == 0);
+  Value = *(volatile UINT32*)Address;
+  return Value;
+}
+
+/**
+  Writes a 32-bit MMIO register.
+
+  Writes the 32-bit MMIO register specified by Address with the value specified
+  by Value and returns Value. This function must guarantee that all MMIO read
+  and write operations are serialized.
+
+  If 32-bit MMIO register operations are not supported, then ASSERT().
+
+  @param  Address The MMIO register to write.
+  @param  Value   The value to write to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioWrite32 (
+  IN      UINTN                     Address,
+  IN      UINT32                    Value
+  )
+{
+  ASSERT ((Address & 3) == 0);
+  *(volatile UINT32*)Address = Value;
+  return Value;
+}
+
+/**
+  Reads a 64-bit MMIO register.
+
+  Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
+  returned. This function must guarantee that all MMIO read and write
+  operations are serialized.
+
+  If 64-bit MMIO register operations are not supported, then ASSERT().
+
+  @param  Address The MMIO register to read.
+
+  @return The value read.
+
+**/
+UINT64
+EFIAPI
+MmioRead64 (
+  IN      UINTN                     Address
+  )
+{
+  UINT64                            Value;
+
+  ASSERT ((Address & 7) == 0);
+  Value = *(volatile UINT64*)Address;
+  return Value;
+}
+
+/**
+  Writes a 64-bit MMIO register.
+
+  Writes the 64-bit MMIO register specified by Address with the value specified
+  by Value and returns Value. This function must guarantee that all MMIO read
+  and write operations are serialized.
+
+  If 64-bit MMIO register operations are not supported, then ASSERT().
+
+  @param  Address The MMIO register to write.
+  @param  Value   The value to write to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioWrite64 (
+  IN      UINTN                     Address,
+  IN      UINT64                    Value
+  )
+{
+  ASSERT ((Address & 7) == 0);
+  *(volatile UINT64*)Address = Value;
+  return Value;
+}
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/BaseLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/BaseLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/BaseLib.inf	(revision 85718)
@@ -5,4 +5,5 @@
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
 #  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
+#  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -21,5 +22,5 @@
 
 #
-#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64
+#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64 RISCV64
 #
 
@@ -395,4 +396,19 @@
   AArch64/SpeculationBarrier.asm    | MSFT
 
+[Sources.RISCV64]
+  Math64.c
+  Unaligned.c
+  RiscV64/InternalSwitchStack.c
+  RiscV64/CpuBreakpoint.c
+  RiscV64/GetInterruptState.c
+  RiscV64/DisableInterrupts.c
+  RiscV64/EnableInterrupts.c
+  RiscV64/CpuPause.c
+  RiscV64/RiscVSetJumpLongJump.S    | GCC
+  RiscV64/RiscVCpuBreakpoint.S      | GCC
+  RiscV64/RiscVCpuPause.S           | GCC
+  RiscV64/RiscVInterrupt.S          | GCC
+  RiscV64/FlushCache.S              | GCC
+
 [Packages]
   MdePkg/MdePkg.dec
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/CpuBreakpoint.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/CpuBreakpoint.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/CpuBreakpoint.c	(revision 85718)
@@ -0,0 +1,27 @@
+/** @file
+  CPU breakpoint for RISC-V
+
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "BaseLibInternals.h"
+
+extern VOID RiscVCpuBreakpoint (VOID);
+
+/**
+  Generates a breakpoint on the CPU.
+
+  Generates a breakpoint on the CPU. The breakpoint must be implemented such
+  that code can resume normal execution after the breakpoint.
+
+**/
+VOID
+EFIAPI
+CpuBreakpoint (
+  VOID
+  )
+{
+  RiscVCpuBreakpoint ();
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/CpuPause.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/CpuPause.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/CpuPause.c	(revision 85718)
@@ -0,0 +1,29 @@
+/** @file
+  CPU pause for RISC-V
+
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "BaseLibInternals.h"
+
+extern VOID RiscVCpuPause (VOID);
+
+
+/**
+  Requests CPU to pause for a short period of time.
+
+  Requests CPU to pause for a short period of time. Typically used in MP
+  systems to prevent memory starvation while waiting for a spin lock.
+
+**/
+VOID
+EFIAPI
+CpuPause (
+  VOID
+  )
+{
+  RiscVCpuPause ();
+}
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/DisableInterrupts.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/DisableInterrupts.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/DisableInterrupts.c	(revision 85718)
@@ -0,0 +1,24 @@
+/** @file
+  CPU disable interrupt function for RISC-V
+
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+#include "BaseLibInternals.h"
+
+extern VOID RiscVDisableSupervisorModeInterrupts (VOID);
+
+/**
+  Disables CPU interrupts.
+
+**/
+VOID
+EFIAPI
+DisableInterrupts (
+  VOID
+  )
+{
+  RiscVDisableSupervisorModeInterrupts ();
+}
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/EnableInterrupts.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/EnableInterrupts.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/EnableInterrupts.c	(revision 85718)
@@ -0,0 +1,25 @@
+/** @file
+  CPU enable interrupt function for RISC-V
+
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "BaseLibInternals.h"
+
+extern VOID RiscVEnableSupervisorModeInterrupt (VOID);
+
+/**
+  Enables CPU interrupts.
+
+**/
+VOID
+EFIAPI
+EnableInterrupts (
+  VOID
+  )
+{
+  RiscVEnableSupervisorModeInterrupt ();
+}
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/FlushCache.S
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/FlushCache.S	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/FlushCache.S	(revision 85718)
@@ -0,0 +1,21 @@
+//------------------------------------------------------------------------------
+//
+// RISC-V cache operation.
+//
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//------------------------------------------------------------------------------
+
+.align 3
+ASM_GLOBAL ASM_PFX(RiscVInvalidateInstCacheAsm)
+ASM_GLOBAL ASM_PFX(RiscVInvalidateDataCacheAsm)
+
+ASM_PFX(RiscVInvalidateInstCacheAsm):
+    fence.i
+    ret
+
+ASM_PFX(RiscVInvalidateDataCacheAsm):
+    fence
+    ret
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/GetInterruptState.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/GetInterruptState.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/GetInterruptState.c	(revision 85718)
@@ -0,0 +1,35 @@
+/** @file
+  CPU get interrupt state function for RISC-V
+
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "BaseLibInternals.h"
+
+extern UINT32 RiscVGetSupervisorModeInterrupts (VOID);
+
+/**
+  Retrieves the current CPU interrupt state.
+
+  Returns TRUE is interrupts are currently enabled. Otherwise
+  returns FALSE.
+
+  @retval TRUE  CPU interrupts are enabled.
+  @retval FALSE CPU interrupts are disabled.
+
+**/
+BOOLEAN
+EFIAPI
+GetInterruptState (
+  VOID
+  )
+{
+  unsigned long RetValue;
+
+  RetValue = RiscVGetSupervisorModeInterrupts ();
+  return RetValue? TRUE: FALSE;
+}
+
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c	(revision 85718)
@@ -0,0 +1,55 @@
+/** @file
+  Switch stack function for RISC-V
+
+  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include "BaseLibInternals.h"
+
+/**
+  Transfers control to a function starting with a new stack.
+
+  Transfers control to the function specified by EntryPoint using the
+  new stack specified by NewStack and passing in the parameters specified
+  by Context1 and Context2.  Context1 and Context2 are optional and may
+  be NULL.  The function EntryPoint must never return.
+  Marker will be ignored on IA-32, x64, and EBC.
+  IPF CPUs expect one additional parameter of type VOID * that specifies
+  the new backing store pointer.
+
+  If EntryPoint is NULL, then ASSERT().
+  If NewStack is NULL, then ASSERT().
+
+  @param  EntryPoint  A pointer to function to call with the new stack.
+  @param  Context1    A pointer to the context to pass into the EntryPoint
+                      function.
+  @param  Context2    A pointer to the context to pass into the EntryPoint
+                      function.
+  @param  NewStack    A pointer to the new stack to use for the EntryPoint
+                      function.
+  @param  Marker      VA_LIST marker for the variable argument list.
+
+**/
+VOID
+EFIAPI
+InternalSwitchStack (
+  IN      SWITCH_STACK_ENTRY_POINT  EntryPoint,
+  IN      VOID                      *Context1,   OPTIONAL
+  IN      VOID                      *Context2,   OPTIONAL
+  IN      VOID                      *NewStack,
+  IN      VA_LIST                   Marker
+  )
+{
+  BASE_LIBRARY_JUMP_BUFFER  JumpBuffer;
+
+  DEBUG ((DEBUG_INFO, "RISC-V InternalSwitchStack Entry:%x Context1:%x Context2:%x NewStack%x\n", \
+          EntryPoint, Context1, Context2, NewStack));
+  JumpBuffer.RA = (UINTN)EntryPoint;
+  JumpBuffer.SP = (UINTN)NewStack - sizeof (VOID *);
+  JumpBuffer.S0 = (UINT64)(UINTN)Context1;
+  JumpBuffer.S1 = (UINT64)(UINTN)Context2;
+  LongJump (&JumpBuffer, (UINTN)-1);
+  ASSERT(FALSE);
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVCpuBreakpoint.S
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVCpuBreakpoint.S	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVCpuBreakpoint.S	(revision 85718)
@@ -0,0 +1,14 @@
+//------------------------------------------------------------------------------
+//
+// CpuBreakpoint for RISC-V
+//
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//------------------------------------------------------------------------------
+
+ASM_GLOBAL ASM_PFX(RiscVCpuBreakpoint)
+ASM_PFX(RiscVCpuBreakpoint):
+  ebreak
+  ret
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVCpuPause.S
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVCpuPause.S	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVCpuPause.S	(revision 85718)
@@ -0,0 +1,14 @@
+//------------------------------------------------------------------------------
+//
+// CpuPause for RISC-V
+//
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//------------------------------------------------------------------------------
+
+ASM_GLOBAL ASM_PFX(RiscVCpuPause)
+ASM_PFX(RiscVCpuPause):
+  nop
+  ret
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVInterrupt.S	(revision 85718)
@@ -0,0 +1,32 @@
+//------------------------------------------------------------------------------
+//
+// RISC-V Supervisor Mode interrupt enable/disable
+//
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//------------------------------------------------------------------------------
+
+ASM_GLOBAL ASM_PFX(RiscVDisableSupervisorModeInterrupts)
+ASM_GLOBAL ASM_PFX(RiscVEnableSupervisorModeInterrupt)
+ASM_GLOBAL ASM_PFX(RiscVGetSupervisorModeInterrupts)
+
+# define  MSTATUS_SIE    0x00000002
+# define  CSR_SSTATUS    0x100
+
+ASM_PFX(RiscVDisableSupervisorModeInterrupts):
+  li   a1, MSTATUS_SIE
+  csrc CSR_SSTATUS, a1
+  ret
+
+ASM_PFX(RiscVEnableSupervisorModeInterrupt):
+  li   a1, MSTATUS_SIE
+  csrs CSR_SSTATUS, a1
+  ret
+
+ASM_PFX(RiscVGetSupervisorModeInterrupts):
+  csrr a0, CSR_SSTATUS
+  andi a0, a0, MSTATUS_SIE
+  ret
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVSetJumpLongJump.S
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVSetJumpLongJump.S	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/RiscV64/RiscVSetJumpLongJump.S	(revision 85718)
@@ -0,0 +1,55 @@
+//------------------------------------------------------------------------------
+//
+// Set/Long jump for RISC-V
+//
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//------------------------------------------------------------------------------
+# define REG_S  sd
+# define REG_L  ld
+# define SZREG  8
+.align 3
+    .globl  SetJump
+
+SetJump:
+    REG_S ra,  0*SZREG(a0)
+    REG_S s0,  1*SZREG(a0)
+    REG_S s1,  2*SZREG(a0)
+    REG_S s2,  3*SZREG(a0)
+    REG_S s3,  4*SZREG(a0)
+    REG_S s4,  5*SZREG(a0)
+    REG_S s5,  6*SZREG(a0)
+    REG_S s6,  7*SZREG(a0)
+    REG_S s7,  8*SZREG(a0)
+    REG_S s8,  9*SZREG(a0)
+    REG_S s9,  10*SZREG(a0)
+    REG_S s10, 11*SZREG(a0)
+    REG_S s11, 12*SZREG(a0)
+    REG_S sp,  13*SZREG(a0)
+    li    a0,  0
+    ret
+
+    .globl  InternalLongJump
+InternalLongJump:
+    REG_L ra,  0*SZREG(a0)
+    REG_L s0,  1*SZREG(a0)
+    REG_L s1,  2*SZREG(a0)
+    REG_L s2,  3*SZREG(a0)
+    REG_L s3,  4*SZREG(a0)
+    REG_L s4,  5*SZREG(a0)
+    REG_L s5,  6*SZREG(a0)
+    REG_L s6,  7*SZREG(a0)
+    REG_L s7,  8*SZREG(a0)
+    REG_L s8,  9*SZREG(a0)
+    REG_L s9,  10*SZREG(a0)
+    REG_L s10, 11*SZREG(a0)
+    REG_L s11, 12*SZREG(a0)
+    REG_L sp,  13*SZREG(a0)
+
+    add   a0, s0, 0
+    add   a1, s1, 0
+    add   a2, s2, 0
+    add   a3, s3, 0
+    ret
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/SafeString.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/SafeString.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseLib/SafeString.c	(revision 85718)
@@ -15,6 +15,8 @@
 #define SAFE_STRING_CONSTRAINT_CHECK(Expression, Status)  \
   do { \
-    ASSERT (Expression); \
     if (!(Expression)) { \
+      DEBUG ((DEBUG_VERBOSE, \
+        "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
+        __FILE__, __LINE__, __FUNCTION__, #Expression, Status)); \
       return Status; \
     } \
@@ -198,5 +200,4 @@
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -280,5 +281,4 @@
   If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -373,5 +373,4 @@
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -474,5 +473,4 @@
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -591,10 +589,5 @@
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid decimal digits in the above format, then 0 is stored
@@ -706,10 +699,5 @@
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid decimal digits in the above format, then 0 is stored
@@ -826,10 +814,5 @@
   whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
@@ -957,10 +940,5 @@
   whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
@@ -1092,13 +1070,5 @@
   The "::" can only appear once in the String.
 
-  If String is NULL, then ASSERT().
-
-  If Address is NULL, then ASSERT().
-
   If String is not aligned in a 16-bit boundary, then ASSERT().
-
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If EndPointer is not NULL and Address is translated from String, a pointer
@@ -1318,13 +1288,5 @@
   a valid decimal digit character after P is converted.
 
-  If String is NULL, then ASSERT().
-
-  If Address is NULL, then ASSERT().
-
   If String is not aligned in a 16-bit boundary, then ASSERT().
-
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If EndPointer is not NULL and Address is translated from String, a pointer
@@ -1483,6 +1445,4 @@
                   pp          Data4[56:63]
 
-  If String is NULL, then ASSERT().
-  If Guid is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
 
@@ -1589,15 +1549,4 @@
 
   If String is not aligned in a 16-bit boundary, then ASSERT().
-
-  If String is NULL, then ASSERT().
-
-  If Buffer is NULL, then ASSERT().
-
-  If Length is not multiple of 2, then ASSERT().
-
-  If PcdMaximumUnicodeStringLength is not zero and Length is greater than
-  PcdMaximumUnicodeStringLength, then ASSERT().
-
-  If MaxBufferSize is less than (Length / 2), then ASSERT().
 
   @param  String                   Pointer to a Null-terminated Unicode string.
@@ -1780,6 +1729,4 @@
   This function is similar as strcpy_s defined in C11.
 
-  If an error would be returned, then the function will also ASSERT().
-
   If an error is returned, then the Destination is unmodified.
 
@@ -1856,6 +1803,4 @@
 
   This function is similar as strncpy_s defined in C11.
-
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -1944,6 +1889,4 @@
 
   This function is similar as strcat_s defined in C11.
-
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -2040,6 +1983,4 @@
 
   This function is similar as strncat_s defined in C11.
-
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -2155,10 +2096,4 @@
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than
-  PcdMaximumAsciiStringLength Ascii characters, not including the
-  Null-terminator, then ASSERT().
-
   If String has no valid decimal digits in the above format, then 0 is stored
   at the location pointed to by Data.
@@ -2267,10 +2202,4 @@
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than
-  PcdMaximumAsciiStringLength Ascii characters, not including the
-  Null-terminator, then ASSERT().
-
   If String has no valid decimal digits in the above format, then 0 is stored
   at the location pointed to by Data.
@@ -2383,10 +2312,4 @@
   whichever on comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than
-  PcdMaximumAsciiStringLength Ascii characters, not including the
-  Null-terminator, then ASSERT().
-
   If String has no valid hexadecimal digits in the above format, then 0 is
   stored at the location pointed to by Data.
@@ -2510,10 +2433,4 @@
   whichever on comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than
-  PcdMaximumAsciiStringLength Ascii characters, not including the
-  Null-terminator, then ASSERT().
-
   If String has no valid hexadecimal digits in the above format, then 0 is
   stored at the location pointed to by Data.
@@ -2636,5 +2553,4 @@
 
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -2736,5 +2652,4 @@
   bits, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then Destination and DestinationLength are
@@ -2856,5 +2771,4 @@
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
@@ -2949,5 +2863,4 @@
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then Destination and DestinationLength are
@@ -3072,8 +2985,4 @@
   "::" can be used to compress one or more groups of X when X contains only 0.
   The "::" can only appear once in the String.
-
-  If String is NULL, then ASSERT().
-
-  If Address is NULL, then ASSERT().
 
   If EndPointer is not NULL and Address is translated from String, a pointer
@@ -3291,8 +3200,4 @@
   When /P is in the String, the function stops at the first character that is not
   a valid decimal digit character after P is converted.
-
-  If String is NULL, then ASSERT().
-
-  If Address is NULL, then ASSERT().
 
   If EndPointer is not NULL and Address is translated from String, a pointer
@@ -3449,7 +3354,4 @@
                   pp          Data4[56:63]
 
-  If String is NULL, then ASSERT().
-  If Guid is NULL, then ASSERT().
-
   @param  String                   Pointer to a Null-terminated ASCII string.
   @param  Guid                     Pointer to the converted GUID.
@@ -3550,15 +3452,4 @@
   decoding stops after Length of characters and outputs Buffer containing
   (Length / 2) bytes.
-
-  If String is NULL, then ASSERT().
-
-  If Buffer is NULL, then ASSERT().
-
-  If Length is not multiple of 2, then ASSERT().
-
-  If PcdMaximumAsciiStringLength is not zero and Length is greater than
-  PcdMaximumAsciiStringLength, then ASSERT().
-
-  If MaxBufferSize is less than (Length / 2), then ASSERT().
 
   @param  String                   Pointer to a Null-terminated ASCII string.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoff.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoff.c	(revision 85718)
@@ -1,5 +1,5 @@
 /** @file
   Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but
-  only supports relocating IA32, x64, IPF, and EBC images.
+  only supports relocating IA32, x64, IPF, ARM, RISC-V and EBC images.
 
   Caution: This file requires additional review when modified.
@@ -18,4 +18,5 @@
   Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
   Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf	(revision 85718)
@@ -4,4 +4,5 @@
 #  The IA32 version library support loading IA32, X64 and EBC PE/COFF images.
 #  The X64 version library support loading IA32, X64 and EBC PE/COFF images.
+#  The RISC-V version library support loading RISC-V images.
 #
 #  Caution: This module requires additional review when modified.
@@ -12,4 +13,5 @@
 #  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+#  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -42,4 +44,7 @@
   Arm/PeCoffLoaderEx.c
 
+[Sources.RISCV64]
+  RiscV/PeCoffLoaderEx.c
+
 [Packages]
   MdePkg/MdePkg.dec
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni	(revision 85718)
@@ -5,4 +5,5 @@
 // The IA32 version library support loading IA32, X64 and EBC PE/COFF images.
 // The X64 version library support loading IA32, X64 and EBC PE/COFF images.
+// The RISC-V version library support loading RISC-V32 and RISC-V64 PE/COFF images.
 //
 // Caution: This module requires additional review when modified.
@@ -13,4 +14,5 @@
 // Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
 // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+// Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/BasePeCoffLibInternals.h	(revision 85718)
@@ -3,4 +3,5 @@
 
   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -17,4 +18,12 @@
 #include <IndustryStandard/PeImage.h>
 
+//
+// Macro definitions for RISC-V architecture.
+//
+#define RV_X(x, s, n) (((x) >> (s)) & ((1<<(n))-1))
+#define RISCV_IMM_BITS 12
+#define RISCV_IMM_REACH (1LL<<RISCV_IMM_BITS)
+#define RISCV_CONST_HIGH_PART(VALUE) \
+  (((VALUE) + (RISCV_IMM_REACH/2)) & ~(RISCV_IMM_REACH-1))
 
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c	(revision 85718)
@@ -0,0 +1,133 @@
+/** @file
+  PE/Coff loader for RISC-V PE image
+
+  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+#include "BasePeCoffLibInternals.h"
+#include <Library/BaseLib.h>
+
+/**
+  Performs an RISC-V specific relocation fixup and is a no-op on
+  other instruction sets.
+  RISC-V splits 32-bit fixup into 20bit and 12-bit with two relocation
+  types. We have to know the lower 12-bit fixup first then we can deal
+  carry over on high 20-bit fixup. So we log the high 20-bit in
+  FixupData.
+
+  @param  Reloc       The pointer to the relocation record.
+  @param  Fixup       The pointer to the address to fix up.
+  @param  FixupData   The pointer to a buffer to log the fixups.
+  @param  Adjust      The offset to adjust the fixup.
+
+  @return Status code.
+
+**/
+RETURN_STATUS
+PeCoffLoaderRelocateImageEx (
+  IN UINT16      *Reloc,
+  IN OUT CHAR8   *Fixup,
+  IN OUT CHAR8   **FixupData,
+  IN UINT64      Adjust
+  )
+{
+  UINT32 Value;
+  UINT32 Value2;
+  UINT32 *RiscVHi20Fixup;
+
+  switch ((*Reloc) >> 12) {
+  case EFI_IMAGE_REL_BASED_RISCV_HI20:
+      *(UINT64 *)(*FixupData) = (UINT64)(UINTN)Fixup;
+      break;
+
+  case EFI_IMAGE_REL_BASED_RISCV_LOW12I:
+      RiscVHi20Fixup =  (UINT32 *)(*(UINT64 *)(*FixupData));
+      if (RiscVHi20Fixup != NULL) {
+
+        Value = (UINT32)(RV_X(*RiscVHi20Fixup, 12, 20) << 12);
+        Value2 = (UINT32)(RV_X(*(UINT32 *)Fixup, 20, 12));
+        if (Value2 & (RISCV_IMM_REACH/2)) {
+          Value2 |= ~(RISCV_IMM_REACH-1);
+        }
+        Value += Value2;
+        Value += (UINT32)Adjust;
+        Value2 = RISCV_CONST_HIGH_PART (Value);
+        *(UINT32 *)RiscVHi20Fixup = (RV_X (Value2, 12, 20) << 12) |\
+                                           (RV_X (*(UINT32 *)RiscVHi20Fixup, 0, 12));
+        *(UINT32 *)Fixup = (RV_X (Value, 0, 12) << 20) |\
+                           (RV_X (*(UINT32 *)Fixup, 0, 20));
+      }
+      break;
+
+  case EFI_IMAGE_REL_BASED_RISCV_LOW12S:
+      RiscVHi20Fixup =  (UINT32 *)(*(UINT64 *)(*FixupData));
+      if (RiscVHi20Fixup != NULL) {
+        Value = (UINT32)(RV_X(*RiscVHi20Fixup, 12, 20) << 12);
+        Value2 = (UINT32)(RV_X(*(UINT32 *)Fixup, 7, 5) | (RV_X(*(UINT32 *)Fixup, 25, 7) << 5));
+        if (Value2 & (RISCV_IMM_REACH/2)) {
+          Value2 |= ~(RISCV_IMM_REACH-1);
+        }
+        Value += Value2;
+        Value += (UINT32)Adjust;
+        Value2 = RISCV_CONST_HIGH_PART (Value);
+        *(UINT32 *)RiscVHi20Fixup = (RV_X (Value2, 12, 20) << 12) | \
+                                           (RV_X (*(UINT32 *)RiscVHi20Fixup, 0, 12));
+        Value2 = *(UINT32 *)Fixup & 0x01fff07f;
+        Value &= RISCV_IMM_REACH - 1;
+        *(UINT32 *)Fixup = Value2 | (UINT32)(((RV_X(Value, 0, 5) << 7) | (RV_X(Value, 5, 7) << 25)));
+      }
+      break;
+
+  default:
+      return RETURN_UNSUPPORTED;
+
+  }
+  return RETURN_SUCCESS;
+}
+
+/**
+  Returns TRUE if the machine type of PE/COFF image is supported. Supported
+  does not mean the image can be executed it means the PE/COFF loader supports
+  loading and relocating of the image type. It's up to the caller to support
+  the entry point.
+
+  @param  Machine   Machine type from the PE Header.
+
+  @return TRUE if this PE/COFF loader can load the image
+
+**/
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+  IN  UINT16  Machine
+  )
+{
+  if (Machine ==  IMAGE_FILE_MACHINE_RISCV64) {
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+/**
+  Performs an Itanium-based specific re-relocation fixup and is a no-op on other
+  instruction sets. This is used to re-relocated the image into the EFI virtual
+  space for runtime calls.
+
+  @param  Reloc       The pointer to the relocation record.
+  @param  Fixup       The pointer to the address to fix up.
+  @param  FixupData   The pointer to a buffer to log the fixups.
+  @param  Adjust      The offset to adjust the fixup.
+
+  @return Status code.
+
+**/
+RETURN_STATUS
+PeHotRelocateImageEx (
+  IN UINT16      *Reloc,
+  IN OUT CHAR8   *Fixup,
+  IN OUT CHAR8   **FixupData,
+  IN UINT64      Adjust
+  )
+{
+  return RETURN_UNSUPPORTED;
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c	(revision 85718)
@@ -0,0 +1,94 @@
+/** @file
+  Null version of Random number generator services.
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/DebugLib.h>
+#include <Library/RngLib.h>
+
+/**
+  Generates a 16-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand     Buffer pointer to store the 16-bit random value.
+
+  @retval TRUE         Random number generated successfully.
+  @retval FALSE        Failed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber16 (
+  OUT     UINT16                    *Rand
+  )
+{
+  ASSERT (FALSE);
+  return FALSE;
+}
+
+/**
+  Generates a 32-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand     Buffer pointer to store the 32-bit random value.
+
+  @retval TRUE         Random number generated successfully.
+  @retval FALSE        Failed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber32 (
+  OUT     UINT32                    *Rand
+  )
+{
+  ASSERT (FALSE);
+  return FALSE;
+}
+
+/**
+  Generates a 64-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand     Buffer pointer to store the 64-bit random value.
+
+  @retval TRUE         Random number generated successfully.
+  @retval FALSE        Failed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber64 (
+  OUT     UINT64                    *Rand
+  )
+{
+  ASSERT (FALSE);
+  return FALSE;
+}
+
+/**
+  Generates a 128-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand     Buffer pointer to store the 128-bit random value.
+
+  @retval TRUE         Random number generated successfully.
+  @retval FALSE        Failed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber128 (
+  OUT     UINT64                    *Rand
+  )
+{
+  ASSERT (FALSE);
+  return FALSE;
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf	(revision 85718)
@@ -0,0 +1,30 @@
+## @file
+#  Null instance of RNG (Random Number Generator) Library.
+#
+#  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010029
+  BASE_NAME                      = BaseRngLibNull
+  MODULE_UNI_FILE                = BaseRngLibNull.uni
+  FILE_GUID                      = CD8991F8-2061-4084-8C9E-9C6F352DC58D
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = RngLib
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64 EBC
+#
+
+[Sources]
+  BaseRngLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni	(revision 85718)
@@ -0,0 +1,14 @@
+// /** @file
+// Null Instance of RNG (Random Number Generator) Library.
+//
+// Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "Null Instance of RNG Library"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "This library instance should be used with modules that inherit an (indirect) dependency on the RngLib class, but never actually call RngLib APIs for consuming randomness."
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf	(revision 85718)
@@ -7,4 +7,6 @@
 #  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
 # Copyright (c) 2017, Microsoft Corporation
+#  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+
 #
 # All rights reserved.
@@ -24,5 +26,5 @@
 # The following information is for reference only and not required by the build tools.
 #
-#  VALID_ARCHITECTURES           = IA32 X64
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64 RISCV64
 #
 
@@ -33,5 +35,5 @@
   SafeIntLib32.c
 
-[Sources.X64, Sources.AARCH64]
+[Sources.X64, Sources.AARCH64, Sources.RISCV64]
   SafeIntLib64.c
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c	(revision 85718)
@@ -3381,5 +3381,5 @@
       // a * d must be less than 2^32 or there would be bits set in the high 64-bits
       //
-      ProductAD = (((UINT64)DwordA) *(UINT64)DwordD);
+      ProductAD = MultU64x64 ((UINT64)DwordA, (UINT64)DwordD);
       if ((ProductAD & 0xffffffff00000000) == 0) {
         DwordB = (UINT32)Multiplicand;
@@ -3388,5 +3388,5 @@
         // b * c must be less than 2^32 or there would be bits set in the high 64-bits
         //
-        ProductBC = (((UINT64)DwordB) *(UINT64)DwordC);
+        ProductBC = MultU64x64 ((UINT64)DwordB, (UINT64)DwordC);
         if ((ProductBC & 0xffffffff00000000) == 0) {
           //
@@ -3398,5 +3398,5 @@
             // b * d
             //
-            ProductBD = (((UINT64)DwordB) *(UINT64)DwordD);
+            ProductBD = MultU64x64 ((UINT64)DwordB, (UINT64)DwordD);
 
             if (!RETURN_ERROR (SafeUint64Add (UnsignedResult, ProductBD, &UnsignedResult))) {
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf	(revision 85718)
@@ -4,4 +4,5 @@
 #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
 #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+#  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -79,4 +80,8 @@
   AArch64/Synchronization.asm   | MSFT
 
+[Sources.RISCV64]
+  Synchronization.c
+  RiscV64/Synchronization.S
+
 [Packages]
   MdePkg/MdePkg.dec
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/RiscV64/Synchronization.S
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/RiscV64/Synchronization.S	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/BaseSynchronizationLib/RiscV64/Synchronization.S	(revision 85718)
@@ -0,0 +1,78 @@
+//------------------------------------------------------------------------------
+//
+// RISC-V synchronization functions.
+//
+// Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//------------------------------------------------------------------------------
+#include <Base.h>
+
+.data
+
+.text
+.align 3
+
+.global ASM_PFX(InternalSyncCompareExchange32)
+.global ASM_PFX(InternalSyncCompareExchange64)
+.global ASM_PFX(InternalSyncIncrement)
+.global ASM_PFX(InternalSyncDecrement)
+
+//
+// ompare and xchange a 32-bit value.
+//
+// @param a0 : Pointer to 32-bit value.
+// @param a1 : Compare value.
+// @param a2 : Exchange value.
+//
+ASM_PFX (InternalSyncCompareExchange32):
+    lr.w  a3, (a0)        // Load the value from a0 and make
+                          // the reservation of address.
+    bne   a3, a1, exit
+    sc.w  a3, a2, (a0)    // Write the value back to the address.
+    mv    a3, a1
+exit:
+    mv    a0, a3
+    ret
+
+.global ASM_PFX(InternalSyncCompareExchange64)
+
+//
+// Compare and xchange a 64-bit value.
+//
+// @param a0 : Pointer to 64-bit value.
+// @param a1 : Compare value.
+// @param a2 : Exchange value.
+//
+ASM_PFX (SyncCompareExchange64):
+    lr.d  a3, (a0)       // Load the value from a0 and make
+                         // the reservation of address.
+    bne   a3, a1, exit
+    sc.d  a3, a2, (a0)   // Write the value back to the address.
+    mv    a3, a1
+exit2:
+    mv    a0, a3
+    ret
+
+//
+// Performs an atomic increment of an 32-bit unsigned integer.
+//
+// @param a0 : Pointer to 32-bit value.
+//
+ASM_PFX (InternalSyncIncrement):
+    li  a1, 1
+    amoadd.w  a2, a1, (a0)
+    mv  a0, a2
+    ret
+
+//
+// Performs an atomic decrement of an 32-bit unsigned integer.
+//
+// @param a0 : Pointer to 32-bit value.
+//
+ASM_PFX (InternalSyncDecrement):
+    li  a1, -1
+    amoadd.w  a2, a1, (a0)
+    mv  a0, a2
+    ret
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.c	(revision 85718)
@@ -151,5 +151,5 @@
   If DecodeHandler is NULL, then ASSERT().
 
-  @param[in]  SectionGuid    A pointer to the GUID associated with the the handlers
+  @param[in]  SectionGuid    A pointer to the GUID associated with the handlers
                              of the GUIDed section type being registered.
   @param[in]  GetInfoHandler The pointer to a function that examines a GUIDed section and returns the
@@ -232,7 +232,7 @@
   If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),
   then RETURN_UNSUPPORTED is returned.
-  If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler
+  If the GUID of InputSection does match the GUID that this handler supports, then the associated handler
   of type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()
-  is used to retrieve the OututBufferSize, ScratchSize, and Attributes values. The return status from the handler of
+  is used to retrieve the OutputBufferSize, ScratchSize, and Attributes values. The return status from the handler of
   type EXTRACT_GUIDED_SECTION_GET_INFO_HANDLER is returned.
 
@@ -312,5 +312,5 @@
   If GUID for InputSection does not match any of the GUIDs registered through ExtractGuidedSectionRegisterHandlers(),
   then RETURN_UNSUPPORTED is returned.
-  If the GUID of InputSection does match the GUID that this handler supports, then the the associated handler
+  If the GUID of InputSection does match the GUID that this handler supports, then the associated handler
   of type EXTRACT_GUIDED_SECTION_DECODE_HANDLER that was registered with ExtractGuidedSectionRegisterHandlers()
   is used to decode InputSection into the buffer specified by OutputBuffer and the authentication status of this
@@ -398,5 +398,5 @@
   If SectionGuid is NULL, then ASSERT().
 
-  @param[in]  SectionGuid    A pointer to the GUID associated with the handlersof the GUIDed
+  @param[in]  SectionGuid    A pointer to the GUID associated with the handlers of the GUIDed
                              section type being retrieved.
   @param[out] GetInfoHandler Pointer to a function that examines a GUIDed section and returns
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeHobLib/HobLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeHobLib/HobLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeHobLib/HobLib.c	(revision 85718)
@@ -1,4 +1,4 @@
 /** @file
-  HOB Library implemenation for Dxe Phase.
+  HOB Library implementation for Dxe Phase.
 
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeHstiLib/HstiDxe.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeHstiLib/HstiDxe.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeHstiLib/HstiDxe.c	(revision 85718)
@@ -78,5 +78,5 @@
                     &InfoTypesBufferCount
                     );
-    if (EFI_ERROR (Status)) {
+    if (EFI_ERROR (Status) || (InfoTypesBuffer == NULL) || (InfoTypesBufferCount == 0)) {
       continue;
     }
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeIoLibCpuIo2/IoLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeIoLibCpuIo2/IoLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeIoLibCpuIo2/IoLib.c	(revision 85718)
@@ -12,5 +12,5 @@
 
 //
-// Globle varible to cache pointer to CpuIo2 protocol.
+// Global variable to cache pointer to CpuIo2 protocol.
 //
 EFI_CPU_IO2_PROTOCOL  *mCpuIo = NULL;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxePcdLib/DxePcdLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxePcdLib/DxePcdLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxePcdLib/DxePcdLib.inf	(revision 85718)
@@ -17,5 +17,5 @@
 #  in their initialization without any issues to access Dynamic and DynamicEx PCD. They can't
 #  access Dynamic and DynamicEx PCD in the implementation of runtime services and SMI handlers.
-#  Because EFI_PCD_PROTOCOL is DXE protocol that is not aviable in OS runtime phase.
+#  Because EFI_PCD_PROTOCOL is DXE protocol that is not available in OS runtime phase.
 #
 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxePcdLib/DxePcdLib.uni
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxePcdLib/DxePcdLib.uni	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxePcdLib/DxePcdLib.uni	(revision 85718)
@@ -23,4 +23,4 @@
 #string STR_MODULE_ABSTRACT             #language en-US "PCD Library using PCD Protocol"
 
-#string STR_MODULE_DESCRIPTION          #language en-US "There are two PCD protocols: 1) PCD_PROTOCOL It is an EDKII implementation that supporst Dynamic/DynamicEx PCDs. 2) EFI_PCD_PROTOCOL It is defined by PI Specification 1.2, Vol 3, which only support dynamicEx type PCD.  For dynamicEx type PCDs, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL.  This library instance uses the PCD_PROTOCOL to handle dynamic PCD requests and uses EFI_PCD_PROTOCOL to handle DynamicEx type PCDs."
+#string STR_MODULE_DESCRIPTION          #language en-US "There are two PCD protocols: 1) PCD_PROTOCOL It is an EDKII implementation that supports Dynamic/DynamicEx PCDs. 2) EFI_PCD_PROTOCOL It is defined by PI Specification 1.2, Vol 3, which only support dynamicEx type PCD.  For dynamicEx type PCDs, it is compatible between PCD_PROTOCOL and EFI_PCD_PROTOCOL.  This library instance uses the PCD_PROTOCOL to handle dynamic PCD requests and uses EFI_PCD_PROTOCOL to handle DynamicEx type PCDs."
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DebugLib.c	(revision 85718)
@@ -78,7 +78,6 @@
   }
 
-  return SystemTable->BootServices->CreateEventEx (EVT_NOTIFY_SIGNAL,
+  return SystemTable->BootServices->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES,
                                       TPL_NOTIFY, ExitBootServicesEvent, NULL,
-                                      &gEfiEventExitBootServicesGuid,
                                       &mEfiExitBootServicesEvent);
 }
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf	(revision 85718)
@@ -42,7 +42,4 @@
   SerialPortLib
 
-[Guids]
-  gEfiEventExitBootServicesGuid                         ## CONSUMES ## Event
-
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue     ## SOMETIMES_CONSUMES
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimePciExpressLib/DxeRuntimePciExpressLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimePciExpressLib/DxeRuntimePciExpressLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimePciExpressLib/DxeRuntimePciExpressLib.inf	(revision 85718)
@@ -48,6 +48,2 @@
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress  ## CONSUMES
-
-[Guids]
-  gEfiEventVirtualAddressChangeGuid         ## CONSUMES ## Event
-
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimePciExpressLib/PciExpressLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimePciExpressLib/PciExpressLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeRuntimePciExpressLib/PciExpressLib.c	(revision 85718)
@@ -125,10 +125,9 @@
   // Register SetVirtualAddressMap () notify function
   //
-  Status = gBS->CreateEventEx (
-                  EVT_NOTIFY_SIGNAL,
+  Status = gBS->CreateEvent (
+                  EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
                   TPL_NOTIFY,
                   DxeRuntimePciExpressLibVirtualNotify,
                   NULL,
-                  &gEfiEventVirtualAddressChangeGuid,
                   &mDxeRuntimePciExpressLibVirtualNotifyEvent
                   );
@@ -300,5 +299,5 @@
 
   //
-  // See if Address has already been registerd for runtime access
+  // See if Address has already been registered for runtime access
   //
   for (Index = 0; Index < mDxeRuntimePciExpressLibNumberOfRuntimeRanges; Index++) {
@@ -1458,5 +1457,5 @@
   configuration registers from a single PCI function to be read. Size is
   returned. When possible 32-bit PCI configuration read cycles are used to read
-  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+  from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit
   and 16-bit PCI configuration read cycles may be used at the beginning and the
   end of the range.
@@ -1561,5 +1560,5 @@
   configuration registers from a single PCI function to be written. Size is
   returned. When possible 32-bit PCI configuration write cycles are used to
-  write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+  write from StartAddress to StartAddress + Size. Due to alignment restrictions,
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning
   and the end of the range.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesLib/DxeServicesLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesLib/DxeServicesLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesLib/DxeServicesLib.c	(revision 85718)
@@ -26,5 +26,5 @@
   Identify the device handle from which the Image is loaded from. As this device handle is passed to
   GetSectionFromFv as the identifier for a Firmware Volume, an EFI_FIRMWARE_VOLUME2_PROTOCOL
-  protocol instance should be located succesfully by calling gBS->HandleProtocol ().
+  protocol instance should be located successfully by calling gBS->HandleProtocol ().
 
   This function locates the EFI_LOADED_IMAGE_PROTOCOL instance installed
@@ -50,5 +50,5 @@
 
   Status = gBS->HandleProtocol (
-             (EFI_HANDLE *) ImageHandle,
+             ImageHandle,
              &gEfiLoadedImageProtocolGuid,
              (VOID **) &LoadedImage
@@ -72,5 +72,5 @@
 
   This functions first locate the EFI_FIRMWARE_VOLUME2_PROTOCOL protocol instance on FvHandle in order to
-  carry out the Firmware Volume read operation. The function then reads the Firmware Section found sepcifed
+  carry out the Firmware Volume read operation. The function then reads the Firmware Section found specified
   by NameGuid, SectionType and SectionInstance.
 
@@ -95,5 +95,5 @@
   @param  SectionInstance         The instance number of Firmware Section to
                                   read from starting from 0.
-  @param  Buffer                  On output, Buffer contains the the data read
+  @param  Buffer                  On output, Buffer contains the data read
                                   from the section in the Firmware File found.
   @param  Size                    On output, the size of Buffer.
@@ -518,5 +518,5 @@
 
 /**
-  Searches the FFS file the the currently executing module was loaded from and returns the first matching FFS section.
+  Searches the FFS file the currently executing module was loaded from and returns the first matching FFS section.
 
   This function searches the FFS file that the currently executing module was loaded from for a FFS sections of type SectionType.
@@ -598,5 +598,5 @@
                                         match an exact file to be loaded.
   @param[in]       FilePath             The pointer to the device path of the file
-                                        that is absracted to the file buffer.
+                                        that is abstracted to the file buffer.
   @param[out]      FileSize             The pointer to the size of the abstracted
                                         file buffer.
@@ -746,5 +746,5 @@
         //
         // Parse each MEDIA_FILEPATH_DP node. There may be more than one, since the
-        // directory information and filename can be seperate. The goal is to inch
+        // directory information and filename can be separate. The goal is to inch
         // our way down each device path node and close the previous node
         //
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesLib/DxeServicesLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesLib/DxeServicesLib.inf	(revision 85718)
@@ -23,5 +23,5 @@
 
 #
-#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64
+#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64 RISCV64
 #
 
@@ -29,5 +29,5 @@
   DxeServicesLib.c
 
-[Sources.IA32, Sources.EBC, Sources.ARM, Sources.AARCH64]
+[Sources.IA32, Sources.EBC, Sources.ARM, Sources.AARCH64, Sources.RISCV64]
   Allocate.c
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.c	(revision 85718)
@@ -10,5 +10,5 @@
   initialized.
 
-  This library contains contruct function to retrieve EFI_DXE_SERIVCE, this construct
+  This library contains construct function to retrieve EFI_DXE_SERVICE, this construct
   function will be invoked in DXE driver's autogen file.
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeSmbusLib/DxeSmbusLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeSmbusLib/DxeSmbusLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/DxeSmbusLib/DxeSmbusLib.c	(revision 85718)
@@ -13,5 +13,5 @@
 
 //
-// Globle varible to cache pointer to Smbus protocol.
+// Global variable to cache pointer to Smbus protocol.
 //
 EFI_SMBUS_HC_PROTOCOL      *mSmbus = NULL;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/DxeRuntimePciSegmentLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/DxeRuntimePciSegmentLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/DxeRuntimePciSegmentLib.c	(revision 85718)
@@ -110,10 +110,9 @@
   // Register SetVirtualAddressMap () notify function
   //
-  Status = gBS->CreateEventEx (
-                  EVT_NOTIFY_SIGNAL,
+  Status = gBS->CreateEvent (
+                  EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
                   TPL_NOTIFY,
                   DxeRuntimePciSegmentLibVirtualNotify,
                   NULL,
-                  &gEfiEventVirtualAddressChangeGuid,
                   &mDxeRuntimePciSegmentLibVirtualNotifyEvent
                   );
@@ -212,5 +211,5 @@
 
   //
-  // See if Address has already been registerd for runtime access
+  // See if Address has already been registered for runtime access
   //
   for (Index = 0; Index < mDxeRuntimePciSegmentLibNumberOfRuntimeRanges; Index++) {
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/DxeRuntimePciSegmentLibSegmentInfo.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/DxeRuntimePciSegmentLibSegmentInfo.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/DxeRuntimePciSegmentLibSegmentInfo.inf	(revision 85718)
@@ -46,5 +46,2 @@
   DxeServicesTableLib
   UefiBootServicesTableLib
-
-[Guids]
-  gEfiEventVirtualAddressChangeGuid         ## CONSUMES ## Event
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/PciSegmentLibCommon.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/PciSegmentLibCommon.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/PciSegmentLibSegmentInfo/PciSegmentLibCommon.c	(revision 85718)
@@ -1170,5 +1170,5 @@
   configuration registers from a single PCI function to be read. Size is
   returned. When possible 32-bit PCI configuration read cycles are used to read
-  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+  from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit
   and 16-bit PCI configuration read cycles may be used at the beginning and the
   end of the range.
@@ -1273,5 +1273,5 @@
   configuration registers from a single PCI function to be written. Size is
   returned. When possible 32-bit PCI configuration write cycles are used to
-  write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+  write from StartAddress to StartAddress + Size. Due to alignment restrictions,
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning
   and the end of the range.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmMemLib/SmmMemLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmMemLib/SmmMemLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmMemLib/SmmMemLib.c	(revision 85718)
@@ -276,5 +276,5 @@
   @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.
 
-  @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with SMRAM.
+  @retval EFI_SECURITY_VIOLATION The DestinationBuffer is invalid per processor architecture or overlap with SMRAM.
   @retval EFI_SUCCESS            Memory is copied.
 
@@ -309,5 +309,5 @@
   @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.
 
-  @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with SMRAM.
+  @retval EFI_SECURITY_VIOLATION The DestinationBuffer is invalid per processor architecture or overlap with SMRAM.
   @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with SMRAM.
   @retval EFI_SUCCESS            Memory is copied.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPciExpressLib/PciExpressLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPciExpressLib/PciExpressLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPciExpressLib/PciExpressLib.c	(revision 85718)
@@ -1227,5 +1227,5 @@
  configuration registers from a single PCI function to be read. Size is
  returned. When possible 32-bit PCI configuration read cycles are used to read
- from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+ from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit
  and 16-bit PCI configuration read cycles may be used at the beginning and the
  end of the range.
@@ -1330,5 +1330,5 @@
  configuration registers from a single PCI function to be written. Size is
  returned. When possible 32-bit PCI configuration write cycles are used to
- write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+ write from StartAddress to StartAddress + Size. Due to alignment restrictions,
  8-bit and 16-bit PCI configuration write cycles may be used at the beginning
  and the end of the range.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPciLibPciRootBridgeIo/PciLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPciLibPciRootBridgeIo/PciLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPciLibPciRootBridgeIo/PciLib.c	(revision 85718)
@@ -36,5 +36,5 @@
 
 //
-// Global varible to cache pointer to PCI Root Bridge I/O protocol.
+// Global variable to cache pointer to PCI Root Bridge I/O protocol.
 //
 EFI_SMM_PCI_ROOT_BRIDGE_IO_PROTOCOL      *mSmmPciRootBridgeIo = NULL;
@@ -1239,5 +1239,5 @@
   configuration registers from a single PCI function to be read. Size is
   returned. When possible 32-bit PCI configuration read cycles are used to read
-  from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+  from StartAddress to StartAddress + Size. Due to alignment restrictions, 8-bit
   and 16-bit PCI configuration read cycles may be used at the beginning and the
   end of the range.
@@ -1337,5 +1337,5 @@
   configuration registers from a single PCI function to be written. Size is
   returned. When possible 32-bit PCI configuration write cycles are used to
-  write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+  write from StartAddress to StartAddress + Size. Due to alignment restrictions,
   8-bit and 16-bit PCI configuration write cycles may be used at the beginning
   and the end of the range.
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c	(revision 85718)
@@ -108,6 +108,6 @@
   ///
   /// The performance counter value that was captured the last time that the
-  /// periodic SMI handler called PeriodcSmiExecutionTime().  This allows the
-  /// time value returned by PeriodcSmiExecutionTime() to be accurate even when
+  /// periodic SMI handler called PeriodicSmiExecutionTime().  This allows the
+  /// time value returned by PeriodicSmiExecutionTime() to be accurate even when
   /// the performance counter rolls over.
   ///
@@ -128,5 +128,5 @@
   /// Buffer used to save the context when a periodic SMI handler requests to
   /// yield using PeriodicSmiYield().  This context is used to resume the
-  /// execution of a periodic SMI handler the next time control is transferd
+  /// execution of a periodic SMI handler the next time control is transferred
   /// to the periodic SMI handler that yielded.
   ///
@@ -153,5 +153,5 @@
 
 ///
-/// Pointer to the SMM Periodic Timer Disatch Protocol that was located in the constuctor.
+/// Pointer to the SMM Periodic Timer Dispatch Protocol that was located in the constructor.
 ///
 EFI_SMM_PERIODIC_TIMER_DISPATCH2_PROTOCOL  *gSmmPeriodicTimerDispatch2           = NULL;
@@ -523,5 +523,5 @@
   periodic SMI for the currently executing handler is triggered, the periodic
   SMI handler will be resumed and this function will return.  Use of this
-  function requires a seperate stack for the periodic SMI handler.  A non zero
+  function requires a separate stack for the periodic SMI handler.  A non zero
   stack size must be specified in PeriodicSmiEnable() for this function to be
   used.
@@ -573,5 +573,5 @@
   if (SetJumpFlag == 0) {
     //
-    // The intial call to SetJump() always returns 0.
+    // The initial call to SetJump() always returns 0.
     // If this is the initial call, then exit the current periodic SMI handler
     //
@@ -589,5 +589,5 @@
 
   //
-  // Return the amount elapsed time that occured while yielded
+  // Return the amount elapsed time that occurred while yielded
   //
   return PeriodicSmiLibraryHandler->ElapsedTime;
@@ -621,5 +621,5 @@
   // Dispatch the registered handler passing in the context that was registered
   // and the amount of time that has elapsed since the previous time this
-  // periodic SMI handler was dispacthed.
+  // periodic SMI handler was dispatched.
   //
   PeriodicSmiLibraryHandler->DispatchFunction (
@@ -629,7 +629,7 @@
 
   //
-  // If this DispatchFunction() returns, then unconditially call PeriodicSmiExit()
+  // If this DispatchFunction() returns, then unconditionally call PeriodicSmiExit()
   // to perform a LongJump() back to PeriodicSmiDispatchFunctionOnCpu(). The
-  // LongJump() will resume exection on the original stack.
+  // LongJump() will resume execution on the original stack.
   //
   PeriodicSmiExit ();
@@ -638,5 +638,5 @@
 /**
   Internal worker function that transfers control to an enabled periodic SMI
-  handler on the specified logial CPU.  This function determines if the periodic
+  handler on the specified logical CPU.  This function determines if the periodic
   SMI handler yielded and needs to be resumed.  It also and switches to an
   allocated stack if one was allocated in PeriodicSmiEnable().
@@ -653,7 +653,7 @@
 {
   //
-  // Save context in DispatchJumpBuffer.  The intial call to SetJump() always
+  // Save context in DispatchJumpBuffer.  The initial call to SetJump() always
   // returns 0.  If this is the initial call, then either resume from a prior
-  // call to PeriodicSmiYield() or call the DispatchFunction registerd in
+  // call to PeriodicSmiYield() or call the DispatchFunction registered in
   // PeriodicSmiEnable() using an allocated stack if one was specified.
   //
@@ -680,5 +680,5 @@
     // If Stack is NULL then call DispatchFunction using current stack passing
     // in the context that was registered and the amount of time that has
-    // elapsed since the previous time this periodic SMI handler was dispacthed.
+    // elapsed since the previous time this periodic SMI handler was dispatched.
     //
     PeriodicSmiLibraryHandler->DispatchFunction (
@@ -688,5 +688,5 @@
 
     //
-    // If this DispatchFunction() returns, then unconditially call PeriodicSmiExit()
+    // If this DispatchFunction() returns, then unconditionally call PeriodicSmiExit()
     // to perform a LongJump() back to this function.
     //
@@ -713,5 +713,5 @@
 /**
   Internal worker function that transfers control to an enabled periodic SMI
-  handler on the specified logial CPU.  This worker function is only called
+  handler on the specified logical CPU.  This worker function is only called
   using the SMM Services Table function SmmStartupThisAp() to execute the
   periodic SMI handler on a logical CPU that is different than the one that is
@@ -737,5 +737,5 @@
 
   //
-  // Execute dispatch function on the currently excuting logical CPU
+  // Execute dispatch function on the currently executing logical CPU
   //
   PeriodicSmiDispatchFunctionOnCpu (PeriodicSmiLibraryHandler);
@@ -806,5 +806,5 @@
     //
     // Dispatch on the currently execution CPU if the CPU specified in PeriodicSmiEnable()
-    // was PERIODIC_SMI_LIBARRY_ANY_CPU or the currently executing CPU matches the CPU
+    // was PERIODIC_SMI_LIBRARY_ANY_CPU or the currently executing CPU matches the CPU
     // that was specified in PeriodicSmiEnable().
     //
@@ -868,5 +868,5 @@
   @param[in]     Context           Optional content to pass into DispatchFunction.
   @param[in]     TickPeriod        The requested tick period in 100ns units that
-                                   control should be givien to the periodic SMI
+                                   control should be given to the periodic SMI
                                    handler.  Must be one of the supported values
                                    returned by PeriodicSmiSupportedPickPeriod().
@@ -892,5 +892,5 @@
                                  periodic SMI handler.
   @retval EFI_OUT_OF_RESOURCES   There are not enough resources to allocate the
-                                 stack speficied by StackSize.
+                                 stack specified by StackSize.
   @retval EFI_SUCCESS            The periodic SMI handler was enabled.
 
@@ -1078,5 +1078,5 @@
   //
   // Count the number of periodic SMI tick intervals that the SMM Periodic Timer
-  // Dipatch 2 Protocol supports.
+  // Dispatch 2 Protocol supports.
   //
   SmiTickInterval = NULL;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c	(revision 85718)
@@ -37,5 +37,5 @@
   // Retrieve SMM Base2 Protocol,  Do not use gBS from UefiBootServicesTableLib on purpose
   // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the
-  // SMM driver explicity declares that dependency.
+  // SMM driver explicitly declares that dependency.
   //
   Status = SystemTable->BootServices->LocateProtocol (
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/DebugLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/DebugLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/DebugLib.c	(revision 85718)
@@ -105,7 +105,7 @@
     //
     if (BaseListMarker == NULL) {
-      UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH,  Format, VaListMarker);
+      UnicodeVSPrintAsciiFormat (Buffer, sizeof (Buffer), Format, VaListMarker);
     } else {
-      UnicodeBSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH,  Format, BaseListMarker);
+      UnicodeBSPrintAsciiFormat (Buffer, sizeof (Buffer), Format, BaseListMarker);
     }
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/DebugLibConstructor.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/DebugLibConstructor.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/DebugLibConstructor.c	(revision 85718)
@@ -65,10 +65,9 @@
   mDebugST = SystemTable;
 
-  SystemTable->BootServices->CreateEventEx (
-                                EVT_NOTIFY_SIGNAL,
+  SystemTable->BootServices->CreateEvent (
+                                EVT_SIGNAL_EXIT_BOOT_SERVICES,
                                 TPL_NOTIFY,
                                 ExitBootServicesCallback,
                                 NULL,
-                                &gEfiEventExitBootServicesGuid,
                                 &mExitBootServicesEvent
                                 );
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf	(revision 85718)
@@ -47,7 +47,4 @@
   DebugPrintErrorLevelLib
 
-[Guids]
-  gEfiEventExitBootServicesGuid                 ## CONSUMES
-
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue        ## SOMETIMES_CONSUMES
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLibConstructor.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLibConstructor.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibDebugPortProtocol/DebugLibConstructor.c	(revision 85718)
@@ -65,10 +65,9 @@
   mDebugBS = SystemTable->BootServices;
 
-  mDebugBS->CreateEventEx (
-              EVT_NOTIFY_SIGNAL,
+  mDebugBS->CreateEvent (
+              EVT_SIGNAL_EXIT_BOOT_SERVICES,
               TPL_NOTIFY,
               ExitBootServicesCallback,
               NULL,
-              &gEfiEventExitBootServicesGuid,
               &mExitBootServicesEvent
               );
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf	(revision 85718)
@@ -47,7 +47,4 @@
   DebugPrintErrorLevelLib
 
-[Guids]
-  gEfiEventExitBootServicesGuid                 ## CONSUMES
-
 [Protocols]
   gEfiDebugPortProtocolGuid                     ## CONSUMES
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/DebugLib.c	(revision 85718)
@@ -107,7 +107,7 @@
     //
     if (BaseListMarker == NULL) {
-      UnicodeVSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, VaListMarker);
+      UnicodeVSPrintAsciiFormat (Buffer, sizeof (Buffer), Format, VaListMarker);
     } else {
-      UnicodeBSPrintAsciiFormat (Buffer, MAX_DEBUG_MESSAGE_LENGTH, Format, BaseListMarker);
+      UnicodeBSPrintAsciiFormat (Buffer, sizeof (Buffer), Format, BaseListMarker);
     }
 
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/DebugLibConstructor.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/DebugLibConstructor.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/DebugLibConstructor.c	(revision 85718)
@@ -65,10 +65,9 @@
   mDebugST = SystemTable;
 
-  SystemTable->BootServices->CreateEventEx (
-                                EVT_NOTIFY_SIGNAL,
+  SystemTable->BootServices->CreateEvent (
+                                EVT_SIGNAL_EXIT_BOOT_SERVICES,
                                 TPL_NOTIFY,
                                 ExitBootServicesCallback,
                                 NULL,
-                                &gEfiEventExitBootServicesGuid,
                                 &mExitBootServicesEvent
                                 );
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf	(revision 85718)
@@ -45,7 +45,4 @@
   DebugPrintErrorLevelLib
 
-[Guids]
-  gEfiEventExitBootServicesGuid                 ## CONSUMES
-
 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue   ## SOMETIMES_CONSUMES
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c	(revision 85718)
@@ -69,17 +69,19 @@
     //
     FileInfo = AllocateZeroPool(FileInfoSize);
-    //
-    // now get the information
-    //
-    Status = FileHandle->GetInfo(FileHandle,
-                                 &gEfiFileInfoGuid,
-                                 &FileInfoSize,
-                                 FileInfo);
-    //
-    // if we got an error free the memory and return NULL
-    //
-    if (EFI_ERROR(Status) && (FileInfo != NULL)) {
-      FreePool(FileInfo);
-      FileInfo = NULL;
+    if (FileInfo != NULL) {
+      //
+      // now get the information
+      //
+      Status = FileHandle->GetInfo(FileHandle,
+                                   &gEfiFileInfoGuid,
+                                   &FileInfoSize,
+                                   FileInfo);
+      //
+      // if we got an error free the memory and return NULL
+      //
+      if (EFI_ERROR(Status)) {
+        FreePool(FileInfo);
+        FileInfo = NULL;
+      }
     }
   }
@@ -816,7 +818,22 @@
       } else {
         //
+        // Prepare to move to the parent directory.
+        // Also determine whether CurrentHandle refers to the Root directory.
+        //
+        Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle, L"..", EFI_FILE_MODE_READ, 0);
+        //
         // We got info... do we have a name? if yes precede the current path with it...
         //
-        if (StrLen (FileInfo->FileName) == 0) {
+        if ((StrLen (FileInfo->FileName) == 0) || EFI_ERROR (Status)) {
+          //
+          // Both FileInfo->FileName being '\0' and EFI_ERROR() suggest that
+          // CurrentHandle refers to the Root directory.  As this loop ensures
+          // FullFileName is starting with '\\' at all times, signal success
+          // and exit the loop.
+          // While FileInfo->FileName could theoretically be a value other than
+          // '\0' or '\\', '\\' is guaranteed to be supported by the
+          // specification and hence its value can safely be ignored.
+          //
+          Status = EFI_SUCCESS;
           if (*FullFileName == NULL) {
             ASSERT((*FullFileName == NULL && Size == 0) || (*FullFileName != NULL));
@@ -836,13 +853,9 @@
         }
       }
+
+      FileHandleClose(CurrentHandle);
       //
       // Move to the parent directory
       //
-      Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle, L"..", EFI_FILE_MODE_READ, 0);
-      if (EFI_ERROR (Status)) {
-        break;
-      }
-
-      FileHandleClose(CurrentHandle);
       CurrentHandle = NextHigherHandle;
     }
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiLib/UefiLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiLib/UefiLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiLib/UefiLib.c	(revision 85718)
@@ -639,4 +639,34 @@
   FreePool (OpenInfoBuffer);
   return Status;
+}
+
+/**
+  This function checks the supported languages list for a target language,
+  This only supports RFC 4646 Languages.
+
+  @param  SupportedLanguages  The supported languages
+  @param  TargetLanguage      The target language
+
+  @retval Returns EFI_SUCCESS if the language is supported,
+          EFI_UNSUPPORTED otherwise
+**/
+EFI_STATUS
+EFIAPI
+IsLanguageSupported (
+  IN CONST CHAR8 *SupportedLanguages,
+  IN CONST CHAR8 *TargetLanguage
+  )
+{
+  UINTN Index;
+  while (*SupportedLanguages != 0) {
+    for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
+    if ((AsciiStrnCmp(SupportedLanguages, TargetLanguage, Index) == 0) && (TargetLanguage[Index] == 0)) {
+      return EFI_SUCCESS;
+    }
+    SupportedLanguages += Index;
+    for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
+  }
+
+  return EFI_UNSUPPORTED;
 }
 
@@ -801,6 +831,6 @@
   //
   Found = FALSE;
-  while (*SupportedLanguages != 0) {
-    if (Iso639Language) {
+  if (Iso639Language) {
+    while (*SupportedLanguages != 0) {
       if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
         Found = TRUE;
@@ -808,14 +838,9 @@
       }
       SupportedLanguages += 3;
-    } else {
-      for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
-      if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {
-        Found = TRUE;
-        break;
-      }
-      SupportedLanguages += Index;
-      for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
     }
-  }
+  } else {
+    Found = !IsLanguageSupported(Language, SupportedLanguages);
+  }
+
 
   //
@@ -1100,6 +1125,6 @@
   //
   Found = FALSE;
-  while (*SupportedLanguages != 0) {
-    if (Iso639Language) {
+  if (Iso639Language) {
+    while (*SupportedLanguages != 0) {
       if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
         Found = TRUE;
@@ -1107,15 +1132,8 @@
       }
       SupportedLanguages += 3;
-    } else {
-      for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
-      if (AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) {
-        Found = TRUE;
-        break;
-      }
-      SupportedLanguages += Index;
-      for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
     }
-  }
-
+  } else {
+    Found = !IsLanguageSupported(Language, SupportedLanguages);
+  }
   //
   // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiRuntimeLib/RuntimeLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiRuntimeLib/RuntimeLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiRuntimeLib/RuntimeLib.c	(revision 85718)
@@ -94,10 +94,9 @@
   // Register SetVirtualAddressMap () notify function
   //
-  Status = gBS->CreateEventEx (
-                  EVT_NOTIFY_SIGNAL,
+  Status = gBS->CreateEvent (
+                  EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
                   TPL_NOTIFY,
                   RuntimeLibVirtualNotifyEvent,
                   NULL,
-                  &gEfiEventVirtualAddressChangeGuid,
                   &mEfiVirtualNotifyEvent
                   );
@@ -105,10 +104,9 @@
   ASSERT_EFI_ERROR (Status);
 
-  Status = gBS->CreateEventEx (
-                  EVT_NOTIFY_SIGNAL,
+  Status = gBS->CreateEvent (
+                  EVT_SIGNAL_EXIT_BOOT_SERVICES,
                   TPL_NOTIFY,
                   RuntimeLibExitBootServicesEvent,
                   NULL,
-                  &gEfiEventExitBootServicesGuid,
                   &mEfiExitBootServicesEvent
                   );
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf	(revision 85718)
@@ -40,7 +40,2 @@
   UefiRuntimeServicesTableLib
   DebugLib
-
-[Guids]
-  gEfiEventExitBootServicesGuid             ## CONSUMES ## Event
-  gEfiEventVirtualAddressChangeGuid         ## CONSUMES ## Event
-
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiScsiLib/UefiScsiLib.c	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiScsiLib/UefiScsiLib.c	(revision 85718)
@@ -2,5 +2,5 @@
   UEFI SCSI Library implementation
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -24,4 +24,5 @@
 #define EFI_SCSI_OP_LENGTH_SIX      0x6
 #define EFI_SCSI_OP_LENGTH_TEN      0xa
+#define EFI_SCSI_OP_LENGTH_TWELVE   0xc
 #define EFI_SCSI_OP_LENGTH_SIXTEEN  0x10
 
@@ -1055,13 +1056,14 @@
   ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TEN);
 
-  CommandPacket.Timeout         = Timeout;
-  CommandPacket.OutDataBuffer    = DataBuffer;
-  CommandPacket.SenseData       = SenseData;
-  CommandPacket.OutTransferLength= *DataLength;
-  CommandPacket.Cdb             = Cdb;
+  CommandPacket.Timeout           = Timeout;
+  CommandPacket.OutDataBuffer     = DataBuffer;
+  CommandPacket.SenseData         = SenseData;
+  CommandPacket.OutTransferLength = *DataLength;
+  CommandPacket.Cdb               = Cdb;
   //
   // Fill Cdb for Write (10) Command
   //
   Cdb[0]                        = EFI_SCSI_OP_WRITE10;
+  Cdb[1]                        = EFI_SCSI_BLOCK_FUA;
   WriteUnaligned32 ((UINT32 *)&Cdb[2], SwapBytes32 (StartLba));
   WriteUnaligned16 ((UINT16 *)&Cdb[7], SwapBytes16 ((UINT16) SectorSize));
@@ -1263,4 +1265,5 @@
   //
   Cdb[0]                        = EFI_SCSI_OP_WRITE16;
+  Cdb[1]                        = EFI_SCSI_BLOCK_FUA;
   WriteUnaligned64 ((UINT64 *)&Cdb[2], SwapBytes64 (StartLba));
   WriteUnaligned32 ((UINT32 *)&Cdb[10], SwapBytes32 (SectorSize));
@@ -1276,4 +1279,230 @@
   *SenseDataLength              = CommandPacket.SenseDataLength;
   *DataLength                   = CommandPacket.OutTransferLength;
+
+  return Status;
+}
+
+
+/**
+  Execute Security Protocol In SCSI command on a specific SCSI target.
+
+  Executes the SCSI Security Protocol In command on the SCSI target specified by ScsiIo.
+  If Timeout is zero, then this function waits indefinitely for the command to complete.
+  If Timeout is greater than zero, then the command is executed and will timeout after
+  Timeout 100 ns units.
+  If ScsiIo is NULL, then ASSERT().
+  If SenseDataLength is NULL, then ASSERT().
+  If HostAdapterStatus is NULL, then ASSERT().
+  If TargetStatus is NULL, then ASSERT().
+  If TransferLength is NULL, then ASSERT().
+
+  If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
+  alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
+  gets returned.
+
+  If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
+  alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
+  gets returned.
+
+  @param[in]      ScsiIo                    SCSI IO Protocol to use.
+  @param[in]      Timeout                   The length of timeout period.
+  @param[in, out] SenseData                 A pointer to output sense data.
+  @param[in, out] SenseDataLength           The length of output sense data.
+  @param[out]     HostAdapterStatus         The status of Host Adapter.
+  @param[out]     TargetStatus              The status of the target.
+  @param[in]      SecurityProtocol          The Security Protocol to use.
+  @param[in]      SecurityProtocolSpecific  The Security Protocol Specific data.
+  @param[in]      Inc512                    If TRUE, 512 increment (INC_512) bit will be set for the
+                                            SECURITY PROTOCOL IN command.
+  @param[in]      DataLength                The size in bytes of the data buffer.
+  @param[in, out] DataBuffer                A pointer to a data buffer.
+  @param[out]     TransferLength            A pointer to a buffer to store the size in
+                                            bytes of the data written to the data buffer.
+
+  @retval  EFI_SUCCESS                 Command is executed successfully.
+  @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire DataBuffer could
+                                       not be transferred. The actual number of bytes transferred is returned in TransferLength.
+  @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because there are too many
+                                       SCSI Command Packets already queued.
+  @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
+  @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet is not supported by
+                                       the SCSI initiator(i.e., SCSI  Host Controller)
+  @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
+  @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
+
+**/
+EFI_STATUS
+EFIAPI
+ScsiSecurityProtocolInCommand (
+  IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
+  IN     UINT64                Timeout,
+  IN OUT VOID                  *SenseData,   OPTIONAL
+  IN OUT UINT8                 *SenseDataLength,
+     OUT UINT8                 *HostAdapterStatus,
+     OUT UINT8                 *TargetStatus,
+  IN     UINT8                 SecurityProtocol,
+  IN     UINT16                SecurityProtocolSpecific,
+  IN     BOOLEAN               Inc512,
+  IN     UINTN                 DataLength,
+  IN OUT VOID                  *DataBuffer,  OPTIONAL
+     OUT UINTN                 *TransferLength
+  )
+{
+  EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+  EFI_STATUS                      Status;
+  UINT8                           Cdb[EFI_SCSI_OP_LENGTH_TWELVE];
+
+  ASSERT (SenseDataLength != NULL);
+  ASSERT (HostAdapterStatus != NULL);
+  ASSERT (TargetStatus != NULL);
+  ASSERT (ScsiIo != NULL);
+  ASSERT (TransferLength != NULL);
+  ASSERT (DataLength <= MAX_UINT32);
+
+  ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+  ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TWELVE);
+
+  CommandPacket.Timeout           = Timeout;
+  CommandPacket.InDataBuffer      = DataBuffer;
+  CommandPacket.SenseData         = SenseData;
+  CommandPacket.InTransferLength  = (UINT32) DataLength;
+  CommandPacket.Cdb               = Cdb;
+  //
+  // Fill Cdb for Security Protocol In Command
+  //
+  Cdb[0]                        = EFI_SCSI_OP_SECURITY_PROTOCOL_IN;
+  Cdb[1]                        = SecurityProtocol;
+  WriteUnaligned16 ((UINT16 *)&Cdb[2], SwapBytes16 (SecurityProtocolSpecific));
+
+  if (Inc512) {
+    if (DataLength % 512 != 0) {
+      return EFI_INVALID_PARAMETER;
+    }
+    Cdb[4]                      = BIT7;
+    WriteUnaligned32 ((UINT32 *)&Cdb[6], SwapBytes32 ((UINT32) DataLength / 512));
+  } else {
+    WriteUnaligned32 ((UINT32 *)&Cdb[6], SwapBytes32 ((UINT32) DataLength));
+  }
+
+  CommandPacket.CdbLength       = EFI_SCSI_OP_LENGTH_TWELVE;
+  CommandPacket.DataDirection   = EFI_SCSI_DATA_IN;
+  CommandPacket.SenseDataLength = *SenseDataLength;
+
+  Status                        = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);
+
+  *HostAdapterStatus            = CommandPacket.HostAdapterStatus;
+  *TargetStatus                 = CommandPacket.TargetStatus;
+  *SenseDataLength              = CommandPacket.SenseDataLength;
+  *TransferLength               = (UINTN) CommandPacket.InTransferLength;
+
+  return Status;
+}
+
+
+/**
+  Execute Security Protocol Out SCSI command on a specific SCSI target.
+
+  Executes the SCSI Security Protocol Out command on the SCSI target specified by ScsiIo.
+  If Timeout is zero, then this function waits indefinitely for the command to complete.
+  If Timeout is greater than zero, then the command is executed and will timeout after
+  Timeout 100 ns units.
+  If ScsiIo is NULL, then ASSERT().
+  If SenseDataLength is NULL, then ASSERT().
+  If HostAdapterStatus is NULL, then ASSERT().
+  If TargetStatus is NULL, then ASSERT().
+
+  If SenseDataLength is non-zero and SenseData is not NULL, SenseData must meet buffer
+  alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
+  gets returned.
+
+  If DataLength is non-zero and DataBuffer is not NULL, DataBuffer must meet buffer
+  alignment requirement defined in EFI_SCSI_IO_PROTOCOL. Otherwise EFI_INVALID_PARAMETER
+  gets returned.
+
+  @param[in]      ScsiIo                    SCSI IO Protocol to use.
+  @param[in]      Timeout                   The length of timeout period.
+  @param[in, out] SenseData                 A pointer to output sense data.
+  @param[in, out] SenseDataLength           The length of output sense data.
+  @param[out]     HostAdapterStatus         The status of Host Adapter.
+  @param[out]     TargetStatus              The status of the target.
+  @param[in]      SecurityProtocol          The Security Protocol to use.
+  @param[in]      SecurityProtocolSpecific  The Security Protocol Specific data.
+  @param[in]      Inc512                    If TRUE, 512 increment (INC_512) bit will be set for the
+                                            SECURITY PROTOCOL OUT command.
+  @param[in]      DataLength                The size in bytes of the transfer data.
+  @param[in, out] DataBuffer                A pointer to a data buffer.
+
+  @retval  EFI_SUCCESS                 Command is executed successfully.
+  @retval  EFI_BAD_BUFFER_SIZE         The SCSI Request Packet was executed, but the entire DataBuffer could
+                                       not be transferred. The actual number of bytes transferred is returned in DataLength.
+  @retval  EFI_NOT_READY               The SCSI Request Packet could not be sent because there are too many
+                                       SCSI Command Packets already queued.
+  @retval  EFI_DEVICE_ERROR            A device error occurred while attempting to send SCSI Request Packet.
+  @retval  EFI_UNSUPPORTED             The command described by the SCSI Request Packet is not supported by
+                                       the SCSI initiator(i.e., SCSI  Host Controller)
+  @retval  EFI_TIMEOUT                 A timeout occurred while waiting for the SCSI Request Packet to execute.
+  @retval  EFI_INVALID_PARAMETER       The contents of the SCSI Request Packet are invalid.
+
+**/
+EFI_STATUS
+EFIAPI
+ScsiSecurityProtocolOutCommand (
+  IN     EFI_SCSI_IO_PROTOCOL  *ScsiIo,
+  IN     UINT64                Timeout,
+  IN OUT VOID                  *SenseData,   OPTIONAL
+  IN OUT UINT8                 *SenseDataLength,
+     OUT UINT8                 *HostAdapterStatus,
+     OUT UINT8                 *TargetStatus,
+  IN     UINT8                 SecurityProtocol,
+  IN     UINT16                SecurityProtocolSpecific,
+  IN     BOOLEAN               Inc512,
+  IN     UINTN                 DataLength,
+  IN OUT VOID                  *DataBuffer   OPTIONAL
+  )
+{
+  EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+  EFI_STATUS                      Status;
+  UINT8                           Cdb[EFI_SCSI_OP_LENGTH_TWELVE];
+
+  ASSERT (SenseDataLength != NULL);
+  ASSERT (HostAdapterStatus != NULL);
+  ASSERT (TargetStatus != NULL);
+  ASSERT (ScsiIo != NULL);
+  ASSERT (DataLength <= MAX_UINT32);
+
+  ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));
+  ZeroMem (Cdb, EFI_SCSI_OP_LENGTH_TWELVE);
+
+  CommandPacket.Timeout           = Timeout;
+  CommandPacket.OutDataBuffer     = DataBuffer;
+  CommandPacket.SenseData         = SenseData;
+  CommandPacket.OutTransferLength = (UINT32) DataLength;
+  CommandPacket.Cdb               = Cdb;
+  //
+  // Fill Cdb for Security Protocol Out Command
+  //
+  Cdb[0]                        = EFI_SCSI_OP_SECURITY_PROTOCOL_OUT;
+  Cdb[1]                        = SecurityProtocol;
+  WriteUnaligned16 ((UINT16 *)&Cdb[2], SwapBytes16 (SecurityProtocolSpecific));
+
+  if (Inc512) {
+    if (DataLength % 512 != 0) {
+      return EFI_INVALID_PARAMETER;
+    }
+    Cdb[4]                      = BIT7;
+    WriteUnaligned32 ((UINT32 *)&Cdb[6], SwapBytes32 ((UINT32) DataLength / 512));
+  } else {
+    WriteUnaligned32 ((UINT32 *)&Cdb[6], SwapBytes32 ((UINT32) DataLength));
+  }
+
+  CommandPacket.CdbLength       = EFI_SCSI_OP_LENGTH_TWELVE;
+  CommandPacket.DataDirection   = EFI_SCSI_DATA_OUT;
+  CommandPacket.SenseDataLength = *SenseDataLength;
+
+  Status                        = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);
+
+  *HostAdapterStatus            = CommandPacket.HostAdapterStatus;
+  *TargetStatus                 = CommandPacket.TargetStatus;
+  *SenseDataLength              = CommandPacket.SenseDataLength;
 
   return Status;
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.ci.yaml
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.ci.yaml	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.ci.yaml	(revision 85718)
@@ -0,0 +1,102 @@
+## @file
+# CI configuration for MdePkg
+#
+# Copyright (c) Microsoft Corporation
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+{
+    ## options defined ci/Plugin/CompilerPlugin
+    "CompilerPlugin": {
+        "DscPath": "MdePkg.dsc"
+    },
+
+    ## options defined ci/Plugin/HostUnitTestCompilerPlugin
+    "HostUnitTestCompilerPlugin": {
+        "DscPath": "Test/MdePkgHostTest.dsc"
+    },
+
+    ## options defined ci/Plugin/CharEncodingCheck
+    "CharEncodingCheck": {
+        "IgnoreFiles": []
+    },
+
+    ## options defined ci/Plugin/DependencyCheck
+    "DependencyCheck": {
+        "AcceptableDependencies": [
+            "MdePkg/MdePkg.dec"
+        ],
+        # For host based unit tests
+        "AcceptableDependencies-HOST_APPLICATION":[
+            "UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec"
+        ],
+        # For UEFI shell based apps
+        "AcceptableDependencies-UEFI_APPLICATION":[],
+        "IgnoreInf": []
+    },
+
+    ## options defined ci/Plugin/DscCompleteCheck
+    "DscCompleteCheck": {
+        "IgnoreInf": [""],
+        "DscPath": "MdePkg.dsc"
+    },
+
+    ## options defined ci/Plugin/HostUnitTestDscCompleteCheck
+    "HostUnitTestDscCompleteCheck": {
+        "IgnoreInf": [""],
+        "DscPath": "Test/MdePkgHostTest.dsc"
+    },
+
+    ## options defined ci/Plugin/GuidCheck
+    "GuidCheck": {
+        "IgnoreGuidName": [
+            "gEfiFirmwareVolumeTopFileGuid" # sec modules must be set to this guid
+        ],
+        "IgnoreGuidValue": ["00000000-0000-0000-0000-000000000000"],
+        "IgnoreFoldersAndFiles": [],
+        "IgnoreDuplicates": [
+            "gEfiFirmwareVolumeBlockProtocolGuid=gEfiFirmwareVolumeBlock2ProtocolGuid",
+            "gEfiMmAccessProtocolGuid=gEfiSmmAccess2ProtocolGuid",
+            "gEfiSmmCommunicationProtocolGuid=gEfiMmCommunicationProtocolGuid",
+            "gEfiMmPciRootBridgeIoProtocolGuid=gEfiSmmPciRootBridgeIoProtocolGuid",
+            "gEfiTrEEProtocolGuid=gEfiTcg2ProtocolGuid",
+            "gEfiSmmPowerButtonDispatch2ProtocolGuid=gEfiMmPowerButtonDispatchProtocolGuid",
+            "gEfiSmmBase2ProtocolGuid=gEfiMmBaseProtocolGuid",
+            "gEfiSmmUsbDispatch2ProtocolGuid=gEfiMmUsbDispatchProtocolGuid",
+            "gEfiSmmCpuProtocolGuid=gEfiMmCpuProtocolGuid",
+            "gEfiAcpiTableGuid=gEfiAcpi20TableGuid",
+            "gEfiSmmControl2ProtocolGuid=gEfiMmControlProtocolGuid",
+            "gEfiSmmStandbyButtonDispatch2ProtocolGuid=gEfiMmStandbyButtonDispatchProtocolGuid",
+            "gEfiSmmStatusCodeProtocolGuid=gEfiMmStatusCodeProtocolGuid",
+            "gEfiDxeSmmReadyToLockProtocolGuid=gEfiDxeMmReadyToLockProtocolGuid",
+            "gEfiSmmIoTrapDispatch2ProtocolGuid=gEfiMmIoTrapDispatchProtocolGuid",
+            "gEfiSmmReadyToLockProtocolGuid=gEfiMmReadyToLockProtocolGuid",
+            "gEfiSmmSxDispatch2ProtocolGuid=gEfiMmSxDispatchProtocolGuid",
+            "gEfiPeiCapsulePpiGuid=gPeiCapsulePpiGuid",
+            "gEfiSmmCpuIo2ProtocolGuid=gEfiMmCpuIoProtocolGuid",
+            "gEfiSmmRscHandlerProtocolGuid=gEfiMmRscHandlerProtocolGuid",
+            "gEfiSmmConfigurationProtocolGuid=gEfiMmConfigurationProtocolGuid",
+            "gEfiSmmGpiDispatch2ProtocolGuid=gEfiMmGpiDispatchProtocolGuid",
+            "gEfiSmmEndOfDxeProtocolGuid=gEfiMmEndOfDxeProtocolGuid",
+            "gEfiSmmSwDispatch2ProtocolGuid=gEfiMmSwDispatchProtocolGuid",
+            "gEfiDebugPortProtocolGuid=gEfiDebugPortVariableGuid=gEfiDebugPortDevicePathGuid", ## is this a bug
+            "gEfiProcessorSpecificErrorSectionGuid=gEfiIa32X64ProcessorErrorSectionGuid",  ## is this a bug
+            "gEfiSmmPeriodicTimerDispatch2ProtocolGuid=gEfiMmPeriodicTimerDispatchProtocolGuid",
+            "gEfiPeiMmAccessPpiGuid=gPeiSmmAccessPpiGuid",
+            "gPeiSmmControlPpiGuid=gEfiPeiMmControlPpiGuid"
+            ]
+    },
+
+    ## options defined ci/Plugin/LibraryClassCheck
+    "LibraryClassCheck": {
+        "IgnoreHeaderFile": []
+    },
+
+    ## options defined ci/Plugin/SpellCheck
+    "SpellCheck": {
+        "AuditOnly": True,           # Fails test but run in AuditOnly mode to collect log
+        "IgnoreFiles": [],           # use gitignore syntax to ignore errors in matching files
+        "ExtendWords": [],           # words to extend to the dictionary for this package
+        "IgnoreStandardPaths": [],   # Standard Plugin defined paths that should be ignore
+        "AdditionalIncludePaths": [] # Additional paths to spell check (wildcards supported)
+    }
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.dec
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.dec	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.dec	(revision 85718)
@@ -7,5 +7,5 @@
 # Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
+# (C) Copyright 2016 - 2020 Hewlett Packard Enterprise Development LP<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -40,4 +40,7 @@
   Include/AArch64
 
+[Includes.RISCV64]
+  Include/RiscV64
+
 [LibraryClasses]
   ##  @libraryclass  Provides most usb APIs to support the Hid requests defined in Usb Hid 1.1 spec
@@ -132,5 +135,5 @@
   ##                 PCI configuration and enable the PCI operations to be replayed during an
   ##                 S3 resume. This library class maps directly on top of the PciSegmentLib class.
-  S3PciSegmentLib|Include/Library/PciSegmentLib.h
+  S3PciSegmentLib|Include/Library/S3PciSegmentLib.h
 
   ##  @libraryclass  Provides services to access PCI Configuration Space.
@@ -245,4 +248,8 @@
   StandaloneMmDriverEntryPoint|Include/Library/StandaloneMmDriverEntryPoint.h
 
+  ## @libraryclass Provides a unit test framework
+  #
+  UnitTestLib|Include/Library/UnitTestLib.h
+
 [LibraryClasses.IA32, LibraryClasses.X64]
   ##  @libraryclass  Abstracts both S/W SMI generation and detection.
@@ -429,4 +436,13 @@
   ## Include/Guid/Cper.h
   gEfiEventNotificationTypeDmarGuid  = { 0x667DD791, 0xC6B3, 0x4c27, { 0x8A, 0x6B, 0x0F, 0x8E, 0x72, 0x2D, 0xEB, 0x41 }}
+
+  ## Include/Guid/Cper.h
+  gEfiEventNotificationTypeSeaGuid   = { 0x9A78788A, 0xBBE8, 0x11E4, { 0x80, 0x9E, 0x67, 0x61, 0x1E, 0x5D, 0x46, 0xB0 }}
+
+  ## Include/Guid/Cper.h
+  gEfiEventNotificationTypeSeiGuid   = { 0x5C284C81, 0xB0AE, 0x4E87, { 0xA3, 0x22, 0xB0, 0x4C, 0x85, 0x62, 0x43, 0x23 }}
+
+  ## Include/Guid/Cper.h
+  gEfiEventNotificationTypePeiGuid   = { 0x09A9D5AC, 0x5204, 0x4214, { 0x96, 0xE5, 0x94, 0x99, 0x2E, 0x75, 0x2B, 0xCD }}
 
   ## Include/Guid/Cper.h
@@ -575,7 +591,4 @@
   #
 
-  ## Include/Guid/PropertiesTable.h
-  gEfiPropertiesTableGuid        = { 0x880aaca3, 0x4adc, 0x4a04, {0x90, 0x79, 0xb7, 0x47, 0x34, 0x8, 0x25, 0xe5 }}
-
   ## Include/Guid/SystemResourceTable.h
   gEfiSystemResourceTableGuid    = { 0xb122a263, 0x3661, 0x4f68, {0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 }}
@@ -642,4 +655,20 @@
   gEfiBttAbstractionGuid         = { 0x18633bfc, 0x1735, 0x4217, { 0x8a, 0xc9, 0x17, 0x23, 0x92, 0x82, 0xd3, 0xf8 }}
 
+  # GUIDs defined in UEFI2.8
+  #
+  ## Include/Guid/JsonCapsule.h
+  gEfiJsonConfigDataTableGuid      = { 0x87367f87, 0x1119, 0x41ce, { 0xaa, 0xec, 0x8b, 0xe0, 0x11, 0x1f, 0x55, 0x8a }}
+  gEfiJsonCapsuleDataTableGuid     = { 0x35e7a725, 0x8dd2, 0x4cac, { 0x80, 0x11, 0x33, 0xcd, 0xa8, 0x10, 0x90, 0x56 }}
+  gEfiJsonCapsuleResultTableGuid   = { 0xdbc461c3, 0xb3de, 0x422a, { 0xb9, 0xb4, 0x98, 0x86, 0xfd, 0x49, 0xa1, 0xe5 }}
+  gEfiJsonCapsuleIdGuid            = { 0x67d6f4cd, 0xd6b8, 0x4573, { 0xbf, 0x4a, 0xde, 0x5e, 0x25, 0x2d, 0x61, 0xae }}
+
+  ## Include/Guid/HiiPlatformSetupFormset.h
+  gEfiHiiResetStyleFormsetGuid     = { 0x790217bd, 0xbecf, 0x485b, { 0x91, 0x70, 0x5f, 0xf7, 0x11, 0x31, 0x8b, 0x27 }}
+
+  # GUIDs defined in UEFI2.8a
+  #
+  ## Include/Guid/RtPropertiesTable.h
+  gEfiRtPropertiesTableGuid      = { 0xeb66918a, 0x7eef, 0x402a, { 0x84, 0x2e, 0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9 }}
+
   #
   # GUID defined in PI1.0
@@ -942,4 +971,7 @@
   gEfiPeiCoreFvLocationPpiGuid   = { 0x52888eae, 0x5b10, 0x47d0, { 0xa8, 0x7f, 0xb8, 0x22, 0xab, 0xa0, 0xca, 0xf4 }}
 
+  ## Include/Ppi/DelayedDispatch.h
+  gEfiPeiDelayedDispatchPpiGuid  = { 0x869c711d, 0x649c, 0x44fe, { 0x8b, 0x9e, 0x2c, 0xbb, 0x29, 0x11, 0xc3, 0xe6 }}
+
 [Protocols]
   ## Include/Protocol/Pcd.h
@@ -1276,4 +1308,11 @@
   ## Include/Protocol/SpiSmmNorFlash.h
   gEfiSpiSmmNorFlashProtocolGuid         = { 0xaab18f19, 0xfe14, 0x4666, { 0x86, 0x04, 0x87, 0xff, 0x6d, 0x66, 0x2c, 0x9a }}
+
+  #
+  # Protocols defined in PI 1.7.
+  #
+
+  ## Include/Protocol/MmCommunication2.h
+  gEfiMmCommunication2ProtocolGuid  = { 0x378daedc, 0xf06b, 0x4446, { 0x83, 0x14, 0x40, 0xab, 0x93, 0x3c, 0x87, 0xa3 }}
 
   #
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.dsc
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.dsc	(revision 85716)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/MdePkg.dsc	(revision 85718)
@@ -4,4 +4,5 @@
 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
 # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+# (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
 #
 #    SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -15,7 +16,9 @@
   DSC_SPECIFICATION              = 0x00010005
   OUTPUT_DIRECTORY               = Build/Mde
-  SUPPORTED_ARCHITECTURES        = IA32|X64|EBC|ARM|AARCH64
+  SUPPORTED_ARCHITECTURES        = IA32|X64|EBC|ARM|AARCH64|RISCV64
   BUILD_TARGETS                  = DEBUG|RELEASE|NOOPT
   SKUID_IDENTIFIER               = DEFAULT
+
+!include UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
 
 [PcdsFeatureFlag]
@@ -27,5 +30,9 @@
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000
 
+[LibraryClasses]
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+
 [Components]
+  MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
   MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
   MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
@@ -61,4 +68,5 @@
   MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
   MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+  MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf
 
   MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
@@ -114,4 +122,18 @@
   MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
 
+[Components.IA32, Components.X64, Components.ARM, Components.AARCH64]
+  #
+  # Add UEFI Target Based Unit Tests
+  #
+  MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsUefi.inf
+
+  #
+  # Build PEIM, DXE_DRIVER, SMM_DRIVER, UEFI Shell components that test SafeIntLib
+  #
+  MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibPei.inf
+  MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibDxe.inf
+  MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibSmm.inf
+  MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibUefiShell.inf
+
 [Components.IA32, Components.X64]
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/MdePkgHostTest.dsc
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/MdePkgHostTest.dsc	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/MdePkgHostTest.dsc	(revision 85718)
@@ -0,0 +1,30 @@
+## @file
+# MdePkg DSC file used to build host-based unit tests.
+#
+# Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
+# Copyright (C) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  PLATFORM_NAME           = MdePkgHostTest
+  PLATFORM_GUID           = 50652B4C-88CB-4481-96E8-37F2D0034440
+  PLATFORM_VERSION        = 0.1
+  DSC_SPECIFICATION       = 0x00010005
+  OUTPUT_DIRECTORY        = Build/MdePkg/HostTest
+  SUPPORTED_ARCHITECTURES = IA32|X64
+  BUILD_TARGETS           = NOOPT
+  SKUID_IDENTIFIER        = DEFAULT
+
+!include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
+
+[LibraryClasses]
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+
+[Components]
+  #
+  # Build HOST_APPLICATION that tests the SafeIntLib
+  #
+  MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibHost.inf
+  MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsHost.inf
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c	(revision 85718)
@@ -0,0 +1,513 @@
+/** @file
+  Unit tests of Base64 conversion APIs in BaseLib.
+
+  Copyright (C) Microsoft Corporation.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UnitTestLib.h>
+
+#define UNIT_TEST_APP_NAME     "BaseLib Unit Test Application"
+#define UNIT_TEST_APP_VERSION  "1.0"
+
+/**
+  RFC 4648  https://tools.ietf.org/html/rfc4648 test vectors
+
+  BASE64("") = ""
+  BASE64("f") = "Zg=="
+  BASE64("fo") = "Zm8="
+  BASE64("foo") = "Zm9v"
+  BASE64("foob") = "Zm9vYg=="
+  BASE64("fooba") = "Zm9vYmE="
+  BASE64("foobar") = "Zm9vYmFy"
+
+  The test vectors are using ascii strings for the binary data
+ */
+
+typedef struct {
+    CHAR8      *TestInput;
+    CHAR8      *TestOutput;
+    EFI_STATUS  ExpectedStatus;
+    VOID       *BufferToFree;
+    UINTN       ExpectedSize;
+} BASIC_TEST_CONTEXT;
+
+#define B64_TEST_1     ""
+#define BIN_TEST_1     ""
+
+#define B64_TEST_2     "Zg=="
+#define BIN_TEST_2     "f"
+
+#define B64_TEST_3     "Zm8="
+#define BIN_TEST_3     "fo"
+
+#define B64_TEST_4     "Zm9v"
+#define BIN_TEST_4     "foo"
+
+#define B64_TEST_5     "Zm9vYg=="
+#define BIN_TEST_5     "foob"
+
+#define B64_TEST_6     "Zm9vYmE="
+#define BIN_TEST_6     "fooba"
+
+#define B64_TEST_7     "Zm9vYmFy"
+#define BIN_TEST_7     "foobar"
+
+// Adds all white space - also ends the last quantum with only spaces afterwards
+#define B64_TEST_8_IN   " \t\v  Zm9\r\nvYmFy \f  "
+#define BIN_TEST_8      "foobar"
+
+// Not a quantum multiple of 4
+#define B64_ERROR_1  "Zm9vymFy="
+
+// Invalid characters in the string
+#define B64_ERROR_2  "Zm$vymFy"
+
+// Too many '=' characters
+#define B64_ERROR_3 "Z==="
+
+// Poorly placed '='
+#define B64_ERROR_4 "Zm=vYmFy"
+
+#define MAX_TEST_STRING_SIZE (200)
+
+// ------------------------------------------------ Input----------Output-----------Result-------Free--Expected Output Size
+static BASIC_TEST_CONTEXT    mBasicEncodeTest1  = {BIN_TEST_1,     B64_TEST_1,      EFI_SUCCESS, NULL, sizeof(B64_TEST_1)};
+static BASIC_TEST_CONTEXT    mBasicEncodeTest2  = {BIN_TEST_2,     B64_TEST_2,      EFI_SUCCESS, NULL, sizeof(B64_TEST_2)};
+static BASIC_TEST_CONTEXT    mBasicEncodeTest3  = {BIN_TEST_3,     B64_TEST_3,      EFI_SUCCESS, NULL, sizeof(B64_TEST_3)};
+static BASIC_TEST_CONTEXT    mBasicEncodeTest4  = {BIN_TEST_4,     B64_TEST_4,      EFI_SUCCESS, NULL, sizeof(B64_TEST_4)};
+static BASIC_TEST_CONTEXT    mBasicEncodeTest5  = {BIN_TEST_5,     B64_TEST_5,      EFI_SUCCESS, NULL, sizeof(B64_TEST_5)};
+static BASIC_TEST_CONTEXT    mBasicEncodeTest6  = {BIN_TEST_6,     B64_TEST_6,      EFI_SUCCESS, NULL, sizeof(B64_TEST_6)};
+static BASIC_TEST_CONTEXT    mBasicEncodeTest7  = {BIN_TEST_7,     B64_TEST_7,      EFI_SUCCESS, NULL, sizeof(B64_TEST_7)};
+static BASIC_TEST_CONTEXT    mBasicEncodeError1 = {BIN_TEST_7,     B64_TEST_1,      EFI_BUFFER_TOO_SMALL, NULL, sizeof(B64_TEST_7)};
+
+static BASIC_TEST_CONTEXT    mBasicDecodeTest1  = {B64_TEST_1,     BIN_TEST_1,      EFI_SUCCESS, NULL, sizeof(BIN_TEST_1)-1};
+static BASIC_TEST_CONTEXT    mBasicDecodeTest2  = {B64_TEST_2,     BIN_TEST_2,      EFI_SUCCESS, NULL, sizeof(BIN_TEST_2)-1};
+static BASIC_TEST_CONTEXT    mBasicDecodeTest3  = {B64_TEST_3,     BIN_TEST_3,      EFI_SUCCESS, NULL, sizeof(BIN_TEST_3)-1};
+static BASIC_TEST_CONTEXT    mBasicDecodeTest4  = {B64_TEST_4,     BIN_TEST_4,      EFI_SUCCESS, NULL, sizeof(BIN_TEST_4)-1};
+static BASIC_TEST_CONTEXT    mBasicDecodeTest5  = {B64_TEST_5,     BIN_TEST_5,      EFI_SUCCESS, NULL, sizeof(BIN_TEST_5)-1};
+static BASIC_TEST_CONTEXT    mBasicDecodeTest6  = {B64_TEST_6,     BIN_TEST_6,      EFI_SUCCESS, NULL, sizeof(BIN_TEST_6)-1};
+static BASIC_TEST_CONTEXT    mBasicDecodeTest7  = {B64_TEST_7,     BIN_TEST_7,      EFI_SUCCESS, NULL, sizeof(BIN_TEST_7)-1};
+static BASIC_TEST_CONTEXT    mBasicDecodeTest8  = {B64_TEST_8_IN,  BIN_TEST_8,      EFI_SUCCESS, NULL, sizeof(BIN_TEST_8)-1};
+
+static BASIC_TEST_CONTEXT    mBasicDecodeError1 = {B64_ERROR_1,    B64_ERROR_1,     EFI_INVALID_PARAMETER, NULL, 0};
+static BASIC_TEST_CONTEXT    mBasicDecodeError2 = {B64_ERROR_2,    B64_ERROR_2,     EFI_INVALID_PARAMETER, NULL, 0};
+static BASIC_TEST_CONTEXT    mBasicDecodeError3 = {B64_ERROR_3,    B64_ERROR_3,     EFI_INVALID_PARAMETER, NULL, 0};
+static BASIC_TEST_CONTEXT    mBasicDecodeError4 = {B64_ERROR_4,    B64_ERROR_4,     EFI_INVALID_PARAMETER, NULL, 0};
+static BASIC_TEST_CONTEXT    mBasicDecodeError5 = {B64_TEST_7,     BIN_TEST_1,      EFI_BUFFER_TOO_SMALL,  NULL, sizeof(BIN_TEST_7)-1};
+
+/**
+  Simple clean up method to make sure tests clean up even if interrupted and fail
+  in the middle.
+**/
+STATIC
+VOID
+EFIAPI
+CleanUpB64TestContext (
+  IN UNIT_TEST_CONTEXT  Context
+  )
+{
+  BASIC_TEST_CONTEXT  *Btc;
+
+  Btc = (BASIC_TEST_CONTEXT *)Context;
+  if (Btc != NULL) {
+    //free string if set
+    if (Btc->BufferToFree != NULL) {
+      FreePool (Btc->BufferToFree);
+      Btc->BufferToFree = NULL;
+    }
+  }
+}
+
+/**
+  Unit test for Base64 encode APIs of BaseLib.
+
+  @param[in]  Context    [Optional] An optional parameter that enables:
+                         1) test-case reuse with varied parameters and
+                         2) test-case re-entry for Target tests that need a
+                         reboot.  This parameter is a VOID* and it is the
+                         responsibility of the test author to ensure that the
+                         contents are well understood by all test cases that may
+                         consume it.
+
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test
+                                        case was successful.
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.
+**/
+STATIC
+UNIT_TEST_STATUS
+EFIAPI
+RfcEncodeTest (
+  IN UNIT_TEST_CONTEXT  Context
+  )
+{
+  BASIC_TEST_CONTEXT  *Btc;
+  CHAR8               *b64String;
+  CHAR8               *binString;
+  UINTN               b64StringSize;
+  EFI_STATUS          Status;
+  UINT8               *BinData;
+  UINTN               BinSize;
+  CHAR8               *b64WorkString;
+  UINTN               ReturnSize;
+  INTN                CompareStatus;
+  UINTN               indx;
+
+  Btc = (BASIC_TEST_CONTEXT *) Context;
+  binString = Btc->TestInput;
+  b64String = Btc->TestOutput;
+
+  //
+  // Only testing the the translate functionality, so preallocate the proper
+  // string buffer.
+  //
+
+  b64StringSize = AsciiStrnSizeS(b64String, MAX_TEST_STRING_SIZE);
+  BinSize = AsciiStrnLenS(binString, MAX_TEST_STRING_SIZE);
+  BinData = (UINT8 *)  binString;
+
+  b64WorkString = (CHAR8 *) AllocatePool(b64StringSize);
+  UT_ASSERT_NOT_NULL(b64WorkString);
+
+  Btc->BufferToFree = b64WorkString;
+  ReturnSize = b64StringSize;
+
+  Status = Base64Encode(BinData, BinSize, b64WorkString, &ReturnSize);
+
+  UT_ASSERT_STATUS_EQUAL(Status, Btc->ExpectedStatus);
+
+  UT_ASSERT_EQUAL(ReturnSize, Btc->ExpectedSize);
+
+  if (!EFI_ERROR (Btc->ExpectedStatus)) {
+    if (ReturnSize != 0) {
+      CompareStatus = AsciiStrnCmp (b64String, b64WorkString, ReturnSize);
+      if (CompareStatus != 0) {
+        UT_LOG_ERROR ("b64 string compare error - size=%d\n", ReturnSize);
+        for (indx = 0; indx < ReturnSize; indx++) {
+          UT_LOG_ERROR (" %2.2x", 0xff & b64String[indx]);
+        }
+        UT_LOG_ERROR ("\n b64 work string:\n");
+        for (indx = 0; indx < ReturnSize; indx++) {
+          UT_LOG_ERROR (" %2.2x", 0xff & b64WorkString[indx]);
+        }
+        UT_LOG_ERROR ("\n");
+      }
+      UT_ASSERT_EQUAL (CompareStatus, 0);
+    }
+  }
+
+  Btc->BufferToFree = NULL;
+  FreePool (b64WorkString);
+  return UNIT_TEST_PASSED;
+}
+
+/**
+  Unit test for Base64 decode APIs of BaseLib.
+
+  @param[in]  Context    [Optional] An optional parameter that enables:
+                         1) test-case reuse with varied parameters and
+                         2) test-case re-entry for Target tests that need a
+                         reboot.  This parameter is a VOID* and it is the
+                         responsibility of the test author to ensure that the
+                         contents are well understood by all test cases that may
+                         consume it.
+
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test
+                                        case was successful.
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.
+**/
+STATIC
+UNIT_TEST_STATUS
+EFIAPI
+RfcDecodeTest(
+  IN UNIT_TEST_CONTEXT  Context
+  )
+{
+  BASIC_TEST_CONTEXT *Btc;
+  CHAR8              *b64String;
+  CHAR8              *binString;
+  EFI_STATUS          Status;
+  UINTN               b64StringLen;
+  UINTN               ReturnSize;
+  UINT8              *BinData;
+  UINTN               BinSize;
+  INTN                CompareStatus;
+  UINTN               indx;
+
+  Btc = (BASIC_TEST_CONTEXT *)Context;
+  b64String = Btc->TestInput;
+  binString = Btc->TestOutput;
+
+  //
+  //  Only testing the the translate functionality
+  //
+
+  b64StringLen = AsciiStrnLenS (b64String, MAX_TEST_STRING_SIZE);
+  BinSize = AsciiStrnLenS (binString, MAX_TEST_STRING_SIZE);
+
+  BinData = AllocatePool (BinSize);
+  UT_ASSERT_NOT_NULL(BinData);
+
+  Btc->BufferToFree = BinData;
+  ReturnSize = BinSize;
+
+  Status = Base64Decode (b64String, b64StringLen, BinData, &ReturnSize);
+
+  UT_ASSERT_STATUS_EQUAL (Status, Btc->ExpectedStatus);
+
+  // If an error is not expected, check the results
+  if (EFI_ERROR (Btc->ExpectedStatus)) {
+    if (Btc->ExpectedStatus == EFI_BUFFER_TOO_SMALL) {
+      UT_ASSERT_EQUAL (ReturnSize, Btc->ExpectedSize);
+    }
+  } else {
+    UT_ASSERT_EQUAL (ReturnSize, Btc->ExpectedSize);
+    if (ReturnSize != 0) {
+      CompareStatus = CompareMem (binString, BinData, ReturnSize);
+      if (CompareStatus != 0) {
+        UT_LOG_ERROR ("bin string compare error - size=%d\n", ReturnSize);
+        for (indx = 0; indx < ReturnSize; indx++) {
+          UT_LOG_ERROR (" %2.2x", 0xff & binString[indx]);
+        }
+        UT_LOG_ERROR ("\nBinData:\n");
+        for (indx = 0; indx < ReturnSize; indx++) {
+          UT_LOG_ERROR (" %2.2x", 0xff & BinData[indx]);
+        }
+        UT_LOG_ERROR ("\n");
+      }
+      UT_ASSERT_EQUAL (CompareStatus, 0);
+    }
+  }
+
+  Btc->BufferToFree = NULL;
+  FreePool (BinData);
+  return UNIT_TEST_PASSED;
+}
+
+#define SOURCE_STRING  L"Hello"
+
+STATIC
+UNIT_TEST_STATUS
+EFIAPI
+SafeStringContraintCheckTest (
+  IN UNIT_TEST_CONTEXT  Context
+  )
+{
+  RETURN_STATUS  Status;
+  CHAR16         Destination[20];
+  CHAR16         AllZero[20];
+
+  //
+  // Zero buffer used to verify Destination is not modified
+  //
+  ZeroMem (AllZero, sizeof (AllZero));
+
+  //
+  // Positive test case copy source unicode string to destination
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), SOURCE_STRING);
+  UT_ASSERT_NOT_EFI_ERROR (Status);
+  UT_ASSERT_MEM_EQUAL (Destination, SOURCE_STRING, sizeof (SOURCE_STRING));
+
+  //
+  // Positive test case with DestMax the same as Source size
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (Destination, sizeof (SOURCE_STRING) / sizeof (CHAR16), SOURCE_STRING);
+  UT_ASSERT_NOT_EFI_ERROR (Status);
+  UT_ASSERT_MEM_EQUAL (Destination, SOURCE_STRING, sizeof (SOURCE_STRING));
+
+  //
+  // Negative test case with Destination NULL
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (NULL, sizeof (Destination) / sizeof (CHAR16), SOURCE_STRING);
+  UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+  UT_ASSERT_MEM_EQUAL (Destination, AllZero, sizeof (AllZero));
+
+  //
+  // Negative test case with Source NULL
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), NULL);
+  UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+  UT_ASSERT_MEM_EQUAL (Destination, AllZero, sizeof (AllZero));
+
+  //
+  // Negative test case with DestMax too big
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (Destination, MAX_UINTN, SOURCE_STRING);
+  UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+  UT_ASSERT_MEM_EQUAL (Destination, AllZero, sizeof (AllZero));
+
+  //
+  // Negative test case with DestMax 0
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (Destination, 0, SOURCE_STRING);
+  UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+  UT_ASSERT_MEM_EQUAL (Destination, AllZero, sizeof (AllZero));
+
+  //
+  // Negative test case with DestMax smaller than Source size
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (Destination, 1, SOURCE_STRING);
+  UT_ASSERT_STATUS_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);
+  UT_ASSERT_MEM_EQUAL (Destination, AllZero, sizeof (AllZero));
+
+  //
+  // Negative test case with DestMax smaller than Source size by one character
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (Destination, sizeof (SOURCE_STRING) / sizeof (CHAR16) - 1, SOURCE_STRING);
+  UT_ASSERT_STATUS_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);
+  UT_ASSERT_MEM_EQUAL (Destination, AllZero, sizeof (AllZero));
+
+  //
+  // Negative test case with overlapping Destination and Source
+  //
+  ZeroMem (Destination, sizeof (Destination));
+  Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), Destination);
+  UT_ASSERT_STATUS_EQUAL (Status, RETURN_ACCESS_DENIED);
+  UT_ASSERT_MEM_EQUAL (Destination, AllZero, sizeof (AllZero));
+
+  return UNIT_TEST_PASSED;
+}
+
+/**
+  Initialze the unit test framework, suite, and unit tests for the
+  Base64 conversion APIs of BaseLib and run the unit tests.
+
+  @retval  EFI_SUCCESS           All test cases were dispatched.
+  @retval  EFI_OUT_OF_RESOURCES  There are not enough resources available to
+                                 initialize the unit tests.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+UnitTestingEntry (
+  VOID
+  )
+{
+  EFI_STATUS                  Status;
+  UNIT_TEST_FRAMEWORK_HANDLE  Fw;
+  UNIT_TEST_SUITE_HANDLE      b64EncodeTests;
+  UNIT_TEST_SUITE_HANDLE      b64DecodeTests;
+  UNIT_TEST_SUITE_HANDLE      SafeStringTests;
+
+  Fw = NULL;
+
+  DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
+
+  //
+  // Start setting up the test framework for running the tests.
+  //
+  Status = InitUnitTestFramework (&Fw, UNIT_TEST_APP_NAME, gEfiCallerBaseName, UNIT_TEST_APP_VERSION);
+  if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
+      goto EXIT;
+  }
+
+  //
+  // Populate the B64 Encode Unit Test Suite.
+  //
+  Status = CreateUnitTestSuite (&b64EncodeTests, Fw, "b64 Encode binary to Ascii string", "BaseLib.b64Encode", NULL, NULL);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for b64EncodeTests\n"));
+    Status = EFI_OUT_OF_RESOURCES;
+    goto EXIT;
+  }
+
+  // --------------Suite-----------Description--------------Class Name----------Function--------Pre---Post-------------------Context-----------
+  AddTestCase (b64EncodeTests, "RFC 4686 Test Vector - Empty", "Test1", RfcEncodeTest, NULL, CleanUpB64TestContext, &mBasicEncodeTest1);
+  AddTestCase (b64EncodeTests, "RFC 4686 Test Vector - f", "Test2", RfcEncodeTest, NULL, CleanUpB64TestContext, &mBasicEncodeTest2);
+  AddTestCase (b64EncodeTests, "RFC 4686 Test Vector - fo", "Test3", RfcEncodeTest, NULL, CleanUpB64TestContext, &mBasicEncodeTest3);
+  AddTestCase (b64EncodeTests, "RFC 4686 Test Vector - foo", "Test4", RfcEncodeTest, NULL, CleanUpB64TestContext, &mBasicEncodeTest4);
+  AddTestCase (b64EncodeTests, "RFC 4686 Test Vector - foob", "Test5", RfcEncodeTest, NULL, CleanUpB64TestContext, &mBasicEncodeTest5);
+  AddTestCase (b64EncodeTests, "RFC 4686 Test Vector - fooba", "Test6", RfcEncodeTest, NULL, CleanUpB64TestContext, &mBasicEncodeTest6);
+  AddTestCase (b64EncodeTests, "RFC 4686 Test Vector - foobar", "Test7", RfcEncodeTest, NULL, CleanUpB64TestContext, &mBasicEncodeTest7);
+  AddTestCase (b64EncodeTests, "Too small of output buffer", "Error1", RfcEncodeTest, NULL, CleanUpB64TestContext, &mBasicEncodeError1);
+  //
+  // Populate the B64 Decode Unit Test Suite.
+  //
+  Status = CreateUnitTestSuite (&b64DecodeTests, Fw, "b64 Decode Ascii string to binary", "BaseLib.b64Decode", NULL, NULL);
+  if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for b64Decode Tests\n"));
+      Status = EFI_OUT_OF_RESOURCES;
+      goto EXIT;
+  }
+
+  AddTestCase (b64DecodeTests, "RFC 4686 Test Vector - Empty", "Test1",  RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeTest1);
+  AddTestCase (b64DecodeTests, "RFC 4686 Test Vector - f", "Test2",  RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeTest2);
+  AddTestCase (b64DecodeTests, "RFC 4686 Test Vector - fo", "Test3",  RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeTest3);
+  AddTestCase (b64DecodeTests, "RFC 4686 Test Vector - foo", "Test4",  RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeTest4);
+  AddTestCase (b64DecodeTests, "RFC 4686 Test Vector - foob", "Test5",  RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeTest5);
+  AddTestCase (b64DecodeTests, "RFC 4686 Test Vector - fooba", "Test6",  RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeTest6);
+  AddTestCase (b64DecodeTests, "RFC 4686 Test Vector - foobar", "Test7",  RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeTest7);
+  AddTestCase (b64DecodeTests, "Ignore Whitespace test", "Test8",  RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeTest8);
+
+  AddTestCase (b64DecodeTests, "Not a quantum multiple of 4", "Error1", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError1);
+  AddTestCase (b64DecodeTests, "Invalid characters in the string", "Error2", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError2);
+  AddTestCase (b64DecodeTests, "Too many padding characters", "Error3", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError3);
+  AddTestCase (b64DecodeTests, "Incorrectly placed padding character", "Error4", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError4);
+  AddTestCase (b64DecodeTests, "Too small of output buffer", "Error5", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError5);
+
+  //
+  // Populate the safe string Unit Test Suite.
+  //
+  Status = CreateUnitTestSuite (&SafeStringTests, Fw, "Safe String", "BaseLib.SafeString", NULL, NULL);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SafeStringTests\n"));
+    Status = EFI_OUT_OF_RESOURCES;
+    goto EXIT;
+  }
+
+  // --------------Suite-----------Description--------------Class Name----------Function--------Pre---Post-------------------Context-----------
+  AddTestCase (SafeStringTests, "SAFE_STRING_CONSTRAINT_CHECK", "SafeStringContraintCheckTest", SafeStringContraintCheckTest, NULL, NULL, NULL);
+
+  //
+  // Execute the tests.
+  //
+  Status = RunAllTestSuites (Fw);
+
+EXIT:
+  if (Fw) {
+    FreeUnitTestFramework (Fw);
+  }
+
+  return Status;
+}
+
+/**
+  Standard UEFI entry point for target based unit test execution from UEFI Shell.
+**/
+EFI_STATUS
+EFIAPI
+BaseLibUnitTestAppEntry (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  return UnitTestingEntry ();
+}
+
+/**
+  Standard POSIX C entry point for host based unit test execution.
+**/
+int
+main (
+  int argc,
+  char *argv[]
+  )
+{
+  return UnitTestingEntry ();
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsHost.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsHost.inf	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsHost.inf	(revision 85718)
@@ -0,0 +1,32 @@
+## @file
+# Unit tests of Base64 conversion APIs in BaseLib that are run from host
+# environment.
+#
+# Copyright (C) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010006
+  BASE_NAME                      = BaseLibUnitTestsHost
+  FILE_GUID                      = 1d005f4c-4dfa-41b5-ab0c-be91fe121459
+  MODULE_TYPE                    = HOST_APPLICATION
+  VERSION_STRING                 = 1.0
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  Base64UnitTest.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  UnitTestLib
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsUefi.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsUefi.inf	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsUefi.inf	(revision 85718)
@@ -0,0 +1,33 @@
+## @file
+# Unit tests of Base64 conversion APIs in BaseLib that are run from UEFI Shell.
+#
+# Copyright (C) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010006
+  BASE_NAME                      = BaseLibUnitTestsUefi
+  FILE_GUID                      = df5a6fed-8786-4a9d-9d02-eab39497b4a1
+  MODULE_TYPE                    = UEFI_APPLICATION
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = BaseLibUnitTestAppEntry
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  Base64UnitTest.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  UefiApplicationEntryPoint
+  DebugLib
+  UnitTestLib
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests32.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests32.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests32.c	(revision 85718)
@@ -0,0 +1,540 @@
+/** @file
+  IA32-specific functions for unit-testing INTN and UINTN functions in
+  SafeIntLib.
+
+  Copyright (c) Microsoft Corporation.<BR>
+  Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "TestBaseSafeIntLib.h"
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  UINTN       Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeInt32ToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-1537977259);
+  Status = SafeInt32ToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToIntn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Operand;
+  INTN        Result;
+
+  //
+  // If Operand is <= MAX_INTN, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeUint32ToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status = SafeUint32ToIntn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToInt32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  INT32       Result;
+
+  //
+  // INTN is same as INT32 in IA32, so this is just a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeIntnToInt32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  UINT32      Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeIntnToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-1537977259);
+  Status = SafeIntnToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  UINT32      Result;
+
+  //
+  // UINTN is same as UINT32 in IA32, so this is just a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeUintnToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToIntn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  INTN        Result;
+
+  //
+  // If Operand is <= MAX_INTN, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeUintnToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status = SafeUintnToIntn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToInt64 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  INT64       Result;
+
+  //
+  // UINTN is same as UINT32 in IA32, and UINT32 is a subset of
+  // INT64, so this is just a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeUintnToInt64(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToIntn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  INTN        Result;
+
+  //
+  // If Operand is between MIN_INTN and  MAX_INTN2 inclusive, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeInt64ToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  Operand = (-1537977259);
+  Status = SafeInt64ToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-1537977259), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToIntn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToIntn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  UINTN       Result;
+
+  //
+  // If Operand is between 0 and  MAX_UINTN inclusive, then it's a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeInt64ToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToIntn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  INTN        Result;
+
+  //
+  // If Operand is <= MAX_INTN, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeUint64ToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToIntn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  UINTN       Result;
+
+  //
+  // If Operand is <= MAX_UINTN, then it's a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeUint64ToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnAdd (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Augend;
+  UINTN       Addend;
+  UINTN       Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_UINTN, then it's addition
+  //
+  Augend = 0x3a3a3a3a;
+  Addend = 0x3a3a3a3a;
+  Result = 0;
+  Status = SafeUintnAdd(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x74747474, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0xabababab;
+  Addend = 0xbcbcbcbc;
+  Status = SafeUintnAdd(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnAdd (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Augend;
+  INTN        Addend;
+  INTN        Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_INTN
+  // and doesn't underflow MIN_INTN, then it's addition
+  //
+  Augend = 0x3a3a3a3a;
+  Addend = 0x3a3a3a3a;
+  Result = 0;
+  Status = SafeIntnAdd(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x74747474, Result);
+
+  Augend = (-976894522);
+  Addend = (-976894522);
+  Status = SafeIntnAdd(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-1953789044), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0x5a5a5a5a;
+  Addend = 0x5a5a5a5a;
+  Status = SafeIntnAdd(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Augend = (-1515870810);
+  Addend = (-1515870810);
+  Status = SafeIntnAdd(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnSub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Minuend;
+  UINTN       Subtrahend;
+  UINTN       Result;
+
+  //
+  // If Minuend >= Subtrahend, then it's subtraction
+  //
+  Minuend = 0x5a5a5a5a;
+  Subtrahend = 0x3b3b3b3b;
+  Result = 0;
+  Status = SafeUintnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x1f1f1f1f, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = 0x5a5a5a5a;
+  Subtrahend = 0x6d6d6d6d;
+  Status = SafeUintnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnSub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Minuend;
+  INTN        Subtrahend;
+  INTN        Result;
+
+  //
+  // If the result of subtractions doesn't overflow MAX_INTN or
+  // underflow MIN_INTN, then it's subtraction
+  //
+  Minuend = 0x5a5a5a5a;
+  Subtrahend = 0x3a3a3a3a;
+  Result = 0;
+  Status = SafeIntnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x20202020, Result);
+
+  Minuend = 0x3a3a3a3a;
+  Subtrahend = 0x5a5a5a5a;
+  Status = SafeIntnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-538976288), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = (-2054847098);
+  Subtrahend = 2054847098;
+  Status = SafeIntnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Minuend = (2054847098);
+  Subtrahend = (-2054847098);
+  Status = SafeIntnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnMult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Multiplicand;
+  UINTN       Multiplier;
+  UINTN       Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_UINTN, it will succeed
+  //
+  Multiplicand = 0xa122a;
+  Multiplier = 0xd23;
+  Result = 0;
+  Status = SafeUintnMult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x844c9dbe, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0xa122a;
+  Multiplier = 0xed23;
+  Status = SafeUintnMult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnMult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Multiplicand;
+  INTN        Multiplier;
+  INTN        Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_INTN and doesn't
+  // underflow MIN_UINTN, it will succeed
+  //
+  Multiplicand = 0x123456;
+  Multiplier = 0x678;
+  Result = 0;
+  Status = SafeIntnMult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x75c28c50, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x123456;
+  Multiplier = 0xabc;
+  Status = SafeIntnMult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests64.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests64.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests64.c	(revision 85718)
@@ -0,0 +1,544 @@
+/** @file
+  x64-specific functions for unit-testing INTN and UINTN functions in
+  SafeIntLib.
+
+  Copyright (c) Microsoft Corporation.<BR>
+  Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "TestBaseSafeIntLib.h"
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  UINTN       Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeInt32ToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-1537977259);
+  Status = SafeInt32ToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToIntn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Operand;
+  INTN        Result;
+
+  //
+  // For x64, INTN is same as INT64 which is a superset of INT32
+  // This is just a cast then, and it'll never fail
+  //
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeUint32ToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToInt32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  INT32       Result;
+
+  //
+  // If Operand is between MIN_INT32 and  MAX_INT32 inclusive, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeIntnToInt32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  Operand = (-1537977259);
+  Status = SafeIntnToInt32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-1537977259), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeIntnToInt32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeIntnToInt32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  UINT32      Result;
+
+  //
+  // If Operand is between 0 and  MAX_UINT32 inclusive, then it's a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeIntnToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeIntnToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeIntnToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  UINT32      Result;
+
+  //
+  // If Operand is <= MAX_UINT32, then it's a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeUintnToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUintnToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToIntn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  INTN        Result;
+
+  //
+  // If Operand is <= MAX_INTN (0x7fff_ffff_ffff_ffff), then it's a cast
+  //
+  Operand = 0x5babababefefefef;
+  Result = 0;
+  Status = SafeUintnToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5babababefefefef, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUintnToIntn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToInt64 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  INT64       Result;
+
+  //
+  // If Operand is <= MAX_INT64, then it's a cast
+  //
+  Operand = 0x5babababefefefef;
+  Result = 0;
+  Status = SafeUintnToInt64(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5babababefefefef, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUintnToInt64(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToIntn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  INTN        Result;
+
+  //
+  // INTN is same as INT64 in x64, so this is just a cast
+  //
+  Operand = 0x5babababefefefef;
+  Result = 0;
+  Status = SafeInt64ToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5babababefefefef, Result);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  UINTN       Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5babababefefefef;
+  Result = 0;
+  Status = SafeInt64ToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5babababefefefef, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToIntn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  INTN        Result;
+
+  //
+  // If Operand is <= MAX_INTN (0x7fff_ffff_ffff_ffff), then it's a cast
+  //
+  Operand = 0x5babababefefefef;
+  Result = 0;
+  Status = SafeUint64ToIntn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5babababefefefef, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToIntn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  UINTN       Result;
+
+  //
+  // UINTN is same as UINT64 in x64, so this is just a cast
+  //
+  Operand = 0xababababefefefef;
+  Result = 0;
+  Status = SafeUint64ToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xababababefefefef, Result);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnAdd (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Augend;
+  UINTN       Addend;
+  UINTN       Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_UINTN, then it's addition
+  //
+  Augend = 0x3a3a3a3a12121212;
+  Addend = 0x3a3a3a3a12121212;
+  Result = 0;
+  Status = SafeUintnAdd(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x7474747424242424, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0xababababefefefef;
+  Addend = 0xbcbcbcbcdededede;
+  Status = SafeUintnAdd(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnAdd (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Augend;
+  INTN        Addend;
+  INTN        Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_INTN
+  // and doesn't underflow MIN_INTN, then it's addition
+  //
+  Augend = 0x3a3a3a3a3a3a3a3a;
+  Addend = 0x3a3a3a3a3a3a3a3a;
+  Result = 0;
+  Status = SafeIntnAdd(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x7474747474747474, Result);
+
+  Augend = (-4195730024608447034);
+  Addend = (-4195730024608447034);
+  Status = SafeIntnAdd(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-8391460049216894068), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0x5a5a5a5a5a5a5a5a;
+  Addend = 0x5a5a5a5a5a5a5a5a;
+  Status = SafeIntnAdd(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Augend = (-6510615555426900570);
+  Addend = (-6510615555426900570);
+  Status = SafeIntnAdd(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnSub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Minuend;
+  UINTN       Subtrahend;
+  UINTN       Result;
+
+  //
+  // If Minuend >= Subtrahend, then it's subtraction
+  //
+  Minuend = 0x5a5a5a5a5a5a5a5a;
+  Subtrahend = 0x3b3b3b3b3b3b3b3b;
+  Result = 0;
+  Status = SafeUintnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x1f1f1f1f1f1f1f1f, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = 0x5a5a5a5a5a5a5a5a;
+  Subtrahend = 0x6d6d6d6d6d6d6d6d;
+  Status = SafeUintnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnSub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Minuend;
+  INTN        Subtrahend;
+  INTN        Result;
+
+  //
+  // If the result of subtractions doesn't overflow MAX_INTN or
+  // underflow MIN_INTN, then it's subtraction
+  //
+  Minuend = 0x5a5a5a5a5a5a5a5a;
+  Subtrahend = 0x3a3a3a3a3a3a3a3a;
+  Result = 0;
+  Status = SafeIntnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x2020202020202020, Result);
+
+  Minuend = 0x3a3a3a3a3a3a3a3a;
+  Subtrahend = 0x5a5a5a5a5a5a5a5a;
+  Status = SafeIntnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-2314885530818453536), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = (-8825501086245354106);
+  Subtrahend = 8825501086245354106;
+  Status = SafeIntnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Minuend = (8825501086245354106);
+  Subtrahend = (-8825501086245354106);
+  Status = SafeIntnSub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnMult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Multiplicand;
+  UINTN       Multiplier;
+  UINTN       Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_UINTN, it will succeed
+  //
+  Multiplicand = 0x123456789a;
+  Multiplier = 0x1234567;
+  Result = 0;
+  Status = SafeUintnMult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x14b66db9745a07f6, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x123456789a;
+  Multiplier = 0x12345678;
+  Status = SafeUintnMult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnMult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Multiplicand;
+  INTN        Multiplier;
+  INTN        Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_INTN and doesn't
+  // underflow MIN_UINTN, it will succeed
+  //
+  Multiplicand = 0x123456789;
+  Multiplier = 0x6789abcd;
+  Result = 0;
+  Status = SafeIntnMult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x75cd9045220d6bb5, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x123456789;
+  Multiplier = 0xa789abcd;
+  Status = SafeIntnMult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c	(revision 85718)
@@ -0,0 +1,3064 @@
+/** @file
+  UEFI OS based application for unit testing the SafeIntLib.
+
+  Copyright (c) Microsoft Corporation.<BR>
+  Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "TestBaseSafeIntLib.h"
+
+#define UNIT_TEST_NAME        "Int Safe Lib Unit Test Application"
+#define UNIT_TEST_VERSION     "0.1"
+
+//
+// Conversion function tests:
+//
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt8ToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT8        Operand;
+  UINT8       Result;
+
+  //
+  // Positive UINT8 should result in just a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt8ToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Negative number should result in an error status
+  //
+  Operand = (-56);
+  Status = SafeInt8ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt8ToUint16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT8        Operand;
+  UINT16      Result;
+
+  //
+  // Positive UINT8 should result in just a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt8ToUint16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Negative number should result in an error status
+  //
+  Operand = (-56);
+  Status = SafeInt8ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt8ToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT8        Operand;
+  UINT32      Result;
+
+  //
+  // Positive UINT8 should result in just a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt8ToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Negative number should result in an error status
+  //
+  Operand = (-56);
+  Status = SafeInt8ToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt8ToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT8        Operand;
+  UINTN       Result;
+
+  //
+  // Positive UINT8 should result in just a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt8ToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Negative number should result in an error status
+  //
+  Operand = (-56);
+  Status = SafeInt8ToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt8ToUint64 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT8        Operand;
+  UINT64      Result;
+
+  //
+  // Positive UINT8 should result in just a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt8ToUint64(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Negative number should result in an error status
+  //
+  Operand = (-56);
+  Status = SafeInt8ToUint64(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint8ToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       Operand;
+  INT8        Result;
+
+  //
+  // Operand <= 0x7F (MAX_INT8) should result in a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUint8ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Operand larger than 0x7f should result in an error status
+  //
+  Operand = 0xaf;
+  Status = SafeUint8ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint8ToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       Operand;
+  CHAR8       Result;
+
+  //
+  // CHAR8 is typedefed as char, which by default is signed, thus
+  // CHAR8 is same as INT8, so same tests as above:
+  //
+
+  //
+  // Operand <= 0x7F (MAX_INT8) should result in a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUint8ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Operand larger than 0x7f should result in an error status
+  //
+  Operand = 0xaf;
+  Status = SafeUint8ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16ToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Operand;
+  INT8        Result;
+
+  //
+  // If Operand is between MIN_INT8 and MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt16ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  Operand = (-35);
+  Status = SafeInt16ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-35), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = 0x1234;
+  Status = SafeInt16ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-17835);
+  Status = SafeInt16ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16ToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Operand;
+  CHAR8       Result;
+
+  //
+  // CHAR8 is typedefed as char, which may be signed or unsigned based
+  // on the compiler. Thus, for compatibility CHAR8 should be between 0 and MAX_INT8.
+  //
+
+  //
+  // If Operand is between 0 and MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt16ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  Operand = 0;
+  Result = 0;
+  Status = SafeInt16ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0, Result);
+
+  Operand = MAX_INT8;
+  Result = 0;
+  Status = SafeInt16ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(MAX_INT8, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-35);
+  Status = SafeInt16ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = 0x1234;
+  Status = SafeInt16ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-17835);
+  Status = SafeInt16ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16ToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Operand;
+  UINT8       Result;
+
+  //
+  // If Operand is between 0 and MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt16ToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = 0x1234;
+  Status = SafeInt16ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-17835);
+  Status = SafeInt16ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16ToUint16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16 Operand = 0x5b5b;
+  UINT16 Result = 0;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Status = SafeInt16ToUint16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-17835);
+  Status = SafeInt16ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16ToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Operand;
+  UINT32      Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5b5b;
+  Result = 0;
+  Status = SafeInt16ToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-17835);
+  Status = SafeInt16ToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16ToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Operand;
+  UINTN       Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5b5b;
+  Result = 0;
+  Status = SafeInt16ToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-17835);
+  Status = SafeInt16ToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16ToUint64 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Operand;
+  UINT64      Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5b5b;
+  Result = 0;
+  Status = SafeInt16ToUint64(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-17835);
+  Status = SafeInt16ToUint64(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint16ToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT16      Operand;
+  INT8        Result;
+
+  //
+  // If Operand is <= MAX_INT8, it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUint16ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5b5b);
+  Status = SafeUint16ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint16ToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT16      Operand;
+  CHAR8       Result;
+
+  // CHAR8 is typedefed as char, which by default is signed, thus
+  // CHAR8 is same as INT8, so same tests as above:
+
+  //
+  // If Operand is <= MAX_INT8, it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUint16ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5b5b);
+  Status = SafeUint16ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint16ToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT16      Operand;
+  UINT8       Result;
+
+  //
+  // If Operand is <= MAX_UINT8 (0xff), it's a cast
+  //
+  Operand = 0xab;
+  Result = 0;
+  Status = SafeUint16ToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5b5b);
+  Status = SafeUint16ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint16ToInt16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT16      Operand;
+  INT16       Result;
+
+  //
+  // If Operand is <= MAX_INT16 (0x7fff), it's a cast
+  //
+  Operand = 0x5b5b;
+  Result = 0;
+  Status = SafeUint16ToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabab);
+  Status = SafeUint16ToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  INT8        Result;
+
+  //
+  // If Operand is between MIN_INT8 and MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt32ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  Operand = (-57);
+  Status = SafeInt32ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-57), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5bababab);
+  Status = SafeInt32ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeInt32ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  CHAR8       Result;
+
+  //
+  // CHAR8 is typedefed as char, which may be signed or unsigned based
+  // on the compiler. Thus, for compatibility CHAR8 should be between 0 and MAX_INT8.
+  //
+
+  //
+  // If Operand is between 0 and MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt32ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  Operand = 0;
+  Result = 0;
+  Status = SafeInt32ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0, Result);
+
+  Operand = MAX_INT8;
+  Result = 0;
+  Status = SafeInt32ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(MAX_INT8, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-57);
+  Status = SafeInt32ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (0x5bababab);
+  Status = SafeInt32ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeInt32ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  UINT8       Result;
+
+  //
+  // If Operand is between 0 and MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt32ToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-57);
+  Status = SafeInt32ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (0x5bababab);
+  Status = SafeInt32ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeInt32ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToInt16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  INT16       Result;
+
+  //
+  // If Operand is between MIN_INT16 and MAX_INT16 inclusive, then it's a cast
+  //
+  Operand = 0x5b5b;
+  Result = 0;
+  Status = SafeInt32ToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b5b, Result);
+
+  Operand = (-17857);
+  Status = SafeInt32ToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-17857), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5bababab);
+  Status = SafeInt32ToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeInt32ToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToUint16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  UINT16      Result;
+
+  //
+  // If Operand is between 0 and MAX_UINT16 inclusive, then it's a cast
+  //
+  Operand = 0xabab;
+  Result = 0;
+  Status = SafeInt32ToUint16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-17857);
+  Status = SafeInt32ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (0x5bababab);
+  Status = SafeInt32ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeInt32ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  UINT32      Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeInt32ToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-1537977259);
+  Status = SafeInt32ToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToUint64 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Operand;
+  UINT64      Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeInt32ToUint64(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-1537977259);
+  Status = SafeInt32ToUint64(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Operand;
+  INT8        Result;
+
+  //
+  // If Operand is <= MAX_INT8, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUint32ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5bababab);
+  Status = SafeUint32ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Operand;
+  CHAR8       Result;
+
+  // CHAR8 is typedefed as char, which by default is signed, thus
+  // CHAR8 is same as INT8, so same tests as above:
+
+  //
+  // If Operand is <= MAX_INT8, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUint32ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5bababab);
+  Status = SafeUint32ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Operand;
+  UINT8       Result;
+
+  //
+  // If Operand is <= MAX_UINT8, then it's a cast
+  //
+  Operand = 0xab;
+  Result = 0;
+  Status = SafeUint32ToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status = SafeUint32ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToInt16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Operand;
+  INT16       Result;
+
+  //
+  // If Operand is <= MAX_INT16, then it's a cast
+  //
+  Operand = 0x5bab;
+  Result = 0;
+  Status = SafeUint32ToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status = SafeUint32ToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToUint16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Operand;
+  UINT16      Result;
+
+  //
+  // If Operand is <= MAX_UINT16, then it's a cast
+  //
+  Operand = 0xabab;
+  Result = 0;
+  Status = SafeUint32ToUint16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status = SafeUint32ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToInt32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Operand;
+  INT32       Result;
+
+  //
+  // If Operand is <= MAX_INT32, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeUint32ToInt32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status = SafeUint32ToInt32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  INT8        Result;
+
+  //
+  // If Operand is between MIN_INT8 and MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeIntnToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  Operand = (-53);
+  Status = SafeIntnToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-53), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5bababab);
+  Status = SafeIntnToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeIntnToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  CHAR8       Result;
+
+  //
+  // CHAR8 is typedefed as char, which may be signed or unsigned based
+  // on the compiler. Thus, for compatibility CHAR8 should be between 0 and MAX_INT8.
+  //
+
+  //
+  // If Operand is between MIN_INT8 and MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeIntnToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  Operand = 0;
+  Result = 0;
+  Status = SafeIntnToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0, Result);
+
+  Operand = MAX_INT8;
+  Result = 0;
+  Status = SafeIntnToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(MAX_INT8, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-53);
+  Status = SafeIntnToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (0x5bababab);
+  Status = SafeIntnToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeIntnToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  UINT8       Result;
+
+  //
+  // If Operand is between 0 and MAX_UINT8 inclusive, then it's a cast
+  //
+  Operand = 0xab;
+  Result = 0;
+  Status = SafeIntnToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5bababab);
+  Status = SafeIntnToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeIntnToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToInt16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  INT16       Result;
+
+  //
+  // If Operand is between MIN_INT16 and MAX_INT16 inclusive, then it's a cast
+  //
+  Operand = 0x5bab;
+  Result = 0;
+  Status = SafeIntnToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bab, Result);
+
+  Operand = (-23467);
+  Status = SafeIntnToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-23467), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5bababab);
+  Status = SafeIntnToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeIntnToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToUint16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  UINT16      Result;
+
+  //
+  // If Operand is between 0 and MAX_UINT16 inclusive, then it's a cast
+  //
+  Operand = 0xabab;
+  Result = 0;
+  Status = SafeIntnToUint16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5bababab);
+  Status = SafeIntnToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (-1537977259);
+  Status = SafeIntnToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToUintn (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  UINTN       Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeIntnToUintn(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-1537977259);
+  Status = SafeIntnToUintn(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToUint64 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INTN        Operand;
+  UINT64      Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeIntnToUint64(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-1537977259);
+  Status = SafeIntnToUint64(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  INT8        Result;
+
+  //
+  // If Operand is <= MAX_INT8, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUintnToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabab);
+  Status = SafeUintnToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  CHAR8       Result;
+
+  // CHAR8 is typedefed as char, which by default is signed, thus
+  // CHAR8 is same as INT8, so same tests as above:
+
+  //
+  // If Operand is <= MAX_INT8, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUintnToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabab);
+  Status = SafeUintnToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  UINT8       Result;
+
+  //
+  // If Operand is <= MAX_UINT8, then it's a cast
+  //
+  Operand = 0xab;
+  Result = 0;
+  Status = SafeUintnToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabab);
+  Status = SafeUintnToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToInt16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  INT16       Result;
+
+  //
+  // If Operand is <= MAX_INT16, then it's a cast
+  //
+  Operand = 0x5bab;
+  Result = 0;
+  Status = SafeUintnToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabab);
+  Status = SafeUintnToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToUint16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  UINT16      Result;
+
+  //
+  // If Operand is <= MAX_UINT16, then it's a cast
+  //
+  Operand = 0xabab;
+  Result = 0;
+  Status = SafeUintnToUint16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status = SafeUintnToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToInt32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINTN       Operand;
+  INT32       Result;
+
+  //
+  // If Operand is <= MAX_INT32, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeUintnToInt32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status = SafeUintnToInt32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  INT8        Result;
+
+  //
+  // If Operand is between MIN_INT8 and  MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt64ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  Operand = (-37);
+  Status = SafeInt64ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-37), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  CHAR8       Result;
+
+  //
+  // CHAR8 is typedefed as char, which may be signed or unsigned based
+  // on the compiler. Thus, for compatibility CHAR8 should be between 0 and MAX_INT8.
+  //
+
+  //
+  // If Operand is between MIN_INT8 and  MAX_INT8 inclusive, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeInt64ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  Operand = 0;
+  Result = 0;
+  Status = SafeInt64ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0, Result);
+
+  Operand = MAX_INT8;
+  Result = 0;
+  Status = SafeInt64ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(MAX_INT8, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-37);
+  Status = SafeInt64ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  UINT8       Result;
+
+  //
+  // If Operand is between 0 and  MAX_UINT8 inclusive, then it's a cast
+  //
+  Operand = 0xab;
+  Result = 0;
+  Status = SafeInt64ToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToInt16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  INT16       Result;
+
+  //
+  // If Operand is between MIN_INT16 and  MAX_INT16 inclusive, then it's a cast
+  //
+  Operand = 0x5bab;
+  Result = 0;
+  Status = SafeInt64ToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bab, Result);
+
+  Operand = (-23467);
+  Status = SafeInt64ToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-23467), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToUint16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  UINT16      Result;
+
+  //
+  // If Operand is between 0 and  MAX_UINT16 inclusive, then it's a cast
+  //
+  Operand = 0xabab;
+  Result = 0;
+  Status = SafeInt64ToUint16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToInt32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  INT32       Result;
+
+  //
+  // If Operand is between MIN_INT32 and  MAX_INT32 inclusive, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeInt64ToInt32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  Operand = (-1537977259);
+  Status = SafeInt64ToInt32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-1537977259), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToInt32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToInt32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  UINT32      Result;
+
+  //
+  // If Operand is between 0 and  MAX_UINT32 inclusive, then it's a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeInt64ToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0x5babababefefefef);
+  Status = SafeInt64ToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToUint64 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Operand;
+  UINT64      Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5babababefefefef;
+  Result = 0;
+  Status = SafeInt64ToUint64(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5babababefefefef, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand =  (-6605562033422200815);
+  Status = SafeInt64ToUint64(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToInt8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  INT8        Result;
+
+  //
+  // If Operand is <= MAX_INT8, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUint64ToInt8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToInt8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToChar8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  CHAR8       Result;
+
+  // CHAR8 is typedefed as char, which by default is signed, thus
+  // CHAR8 is same as INT8, so same tests as above:
+
+  //
+  // If Operand is <= MAX_INT8, then it's a cast
+  //
+  Operand = 0x5b;
+  Result = 0;
+  Status = SafeUint64ToChar8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5b, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToChar8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToUint8 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  UINT8       Result;
+
+  //
+  // If Operand is <= MAX_UINT8, then it's a cast
+  //
+  Operand = 0xab;
+  Result = 0;
+  Status = SafeUint64ToUint8(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToUint8(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToInt16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  INT16       Result;
+
+  //
+  // If Operand is <= MAX_INT16, then it's a cast
+  //
+  Operand = 0x5bab;
+  Result = 0;
+  Status = SafeUint64ToInt16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToInt16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToUint16 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  UINT16      Result;
+
+  //
+  // If Operand is <= MAX_UINT16, then it's a cast
+  //
+  Operand = 0xabab;
+  Result = 0;
+  Status = SafeUint64ToUint16(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToUint16(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToInt32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  INT32       Result;
+
+  //
+  // If Operand is <= MAX_INT32, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result = 0;
+  Status = SafeUint64ToInt32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToInt32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToUint32 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  UINT32      Result;
+
+  //
+  // If Operand is <= MAX_UINT32, then it's a cast
+  //
+  Operand = 0xabababab;
+  Result = 0;
+  Status = SafeUint64ToUint32(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xabababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToUint32(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToInt64 (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Operand;
+  INT64       Result;
+
+  //
+  // If Operand is <= MAX_INT64, then it's a cast
+  //
+  Operand = 0x5babababefefefef;
+  Result = 0;
+  Status = SafeUint64ToInt64(Operand, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x5babababefefefef, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xababababefefefef);
+  Status = SafeUint64ToInt64(Operand, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+//
+// Addition function tests:
+//
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint8Add (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       Augend;
+  UINT8       Addend;
+  UINT8       Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_UINT8, then it's addition
+  //
+  Augend = 0x3a;
+  Addend = 0x3a;
+  Result = 0;
+  Status = SafeUint8Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x74, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0xab;
+  Addend = 0xbc;
+  Status = SafeUint8Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint16Add (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT16 Augend = 0x3a3a;
+  UINT16 Addend = 0x3a3a;
+  UINT16 Result = 0;
+
+  //
+  // If the result of addition doesn't overflow MAX_UINT16, then it's addition
+  //
+  Status = SafeUint16Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x7474, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0xabab;
+  Addend = 0xbcbc;
+  Status = SafeUint16Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32Add (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Augend;
+  UINT32      Addend;
+  UINT32      Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_UINT32, then it's addition
+  //
+  Augend = 0x3a3a3a3a;
+  Addend = 0x3a3a3a3a;
+  Result = 0;
+  Status = SafeUint32Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x74747474, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0xabababab;
+  Addend = 0xbcbcbcbc;
+  Status = SafeUint32Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64Add (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Augend;
+  UINT64      Addend;
+  UINT64      Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_UINT64, then it's addition
+  //
+  Augend = 0x3a3a3a3a12121212;
+  Addend = 0x3a3a3a3a12121212;
+  Result = 0;
+  Status = SafeUint64Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x7474747424242424, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0xababababefefefef;
+  Addend = 0xbcbcbcbcdededede;
+  Status = SafeUint64Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt8Add (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT8        Augend;
+  INT8        Addend;
+  INT8        Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_INT8
+  // and doesn't underflow MIN_INT8, then it's addition
+  //
+  Augend = 0x3a;
+  Addend = 0x3a;
+  Result = 0;
+  Status = SafeInt8Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x74, Result);
+
+  Augend = (-58);
+  Addend = (-58);
+  Status = SafeInt8Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-116), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0x5a;
+  Addend = 0x5a;
+  Status = SafeInt8Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Augend = (-90);
+  Addend = (-90);
+  Status = SafeInt8Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16Add (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Augend;
+  INT16       Addend;
+  INT16       Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_INT16
+  // and doesn't underflow MIN_INT16, then it's addition
+  //
+  Augend = 0x3a3a;
+  Addend = 0x3a3a;
+  Result = 0;
+  Status = SafeInt16Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x7474, Result);
+
+  Augend = (-14906);
+  Addend = (-14906);
+  Status = SafeInt16Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-29812), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0x5a5a;
+  Addend = 0x5a5a;
+  Status = SafeInt16Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Augend = (-23130);
+  Addend = (-23130);
+  Status = SafeInt16Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32Add (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Augend;
+  INT32       Addend;
+  INT32       Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_INT32
+  // and doesn't underflow MIN_INT32, then it's addition
+  //
+  Augend = 0x3a3a3a3a;
+  Addend = 0x3a3a3a3a;
+  Result = 0;
+  Status = SafeInt32Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x74747474, Result);
+
+  Augend = (-976894522);
+  Addend = (-976894522);
+  Status = SafeInt32Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-1953789044), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0x5a5a5a5a;
+  Addend = 0x5a5a5a5a;
+  Status = SafeInt32Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Augend = (-1515870810);
+  Addend = (-1515870810);
+  Status = SafeInt32Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64Add (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Augend;
+  INT64       Addend;
+  INT64       Result;
+
+  //
+  // If the result of addition doesn't overflow MAX_INT64
+  // and doesn't underflow MIN_INT64, then it's addition
+  //
+  Augend = 0x3a3a3a3a3a3a3a3a;
+  Addend = 0x3a3a3a3a3a3a3a3a;
+  Result = 0;
+  Status = SafeInt64Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x7474747474747474, Result);
+
+  Augend = (-4195730024608447034);
+  Addend = (-4195730024608447034);
+  Status = SafeInt64Add(Augend, Addend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-8391460049216894068), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Augend = 0x5a5a5a5a5a5a5a5a;
+  Addend = 0x5a5a5a5a5a5a5a5a;
+  Status = SafeInt64Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Augend = (-6510615555426900570);
+  Addend = (-6510615555426900570);
+  Status = SafeInt64Add(Augend, Addend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+//
+// Subtraction function tests:
+//
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint8Sub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       Minuend;
+  UINT8       Subtrahend;
+  UINT8       Result;
+
+  //
+  // If Minuend >= Subtrahend, then it's subtraction
+  //
+  Minuend = 0x5a;
+  Subtrahend = 0x3b;
+  Result = 0;
+  Status = SafeUint8Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x1f, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = 0x5a;
+  Subtrahend = 0x6d;
+  Status = SafeUint8Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint16Sub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT16      Minuend;
+  UINT16      Subtrahend;
+  UINT16      Result;
+
+  //
+  // If Minuend >= Subtrahend, then it's subtraction
+  //
+  Minuend = 0x5a5a;
+  Subtrahend = 0x3b3b;
+  Result = 0;
+  Status = SafeUint16Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x1f1f, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = 0x5a5a;
+  Subtrahend = 0x6d6d;
+  Status = SafeUint16Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32Sub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Minuend;
+  UINT32      Subtrahend;
+  UINT32      Result;
+
+  //
+  // If Minuend >= Subtrahend, then it's subtraction
+  //
+  Minuend = 0x5a5a5a5a;
+  Subtrahend = 0x3b3b3b3b;
+  Result = 0;
+  Status = SafeUint32Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x1f1f1f1f, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = 0x5a5a5a5a;
+  Subtrahend = 0x6d6d6d6d;
+  Status = SafeUint32Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64Sub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Minuend;
+  UINT64      Subtrahend;
+  UINT64      Result;
+
+  //
+  // If Minuend >= Subtrahend, then it's subtraction
+  //
+  Minuend = 0x5a5a5a5a5a5a5a5a;
+  Subtrahend = 0x3b3b3b3b3b3b3b3b;
+  Result = 0;
+  Status = SafeUint64Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x1f1f1f1f1f1f1f1f, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = 0x5a5a5a5a5a5a5a5a;
+  Subtrahend = 0x6d6d6d6d6d6d6d6d;
+  Status = SafeUint64Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt8Sub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT8        Minuend;
+  INT8        Subtrahend;
+  INT8        Result;
+
+  //
+  // If the result of subtractions doesn't overflow MAX_INT8 or
+  // underflow MIN_INT8, then it's subtraction
+  //
+  Minuend = 0x5a;
+  Subtrahend = 0x3a;
+  Result = 0;
+  Status = SafeInt8Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x20, Result);
+
+  Minuend = 58;
+  Subtrahend = 78;
+  Status = SafeInt8Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-20), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = (-80);
+  Subtrahend = 80;
+  Status = SafeInt8Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Minuend = (80);
+  Subtrahend = (-80);
+  Status = SafeInt8Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16Sub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Minuend;
+  INT16       Subtrahend;
+  INT16       Result;
+
+  //
+  // If the result of subtractions doesn't overflow MAX_INT16 or
+  // underflow MIN_INT16, then it's subtraction
+  //
+  Minuend = 0x5a5a;
+  Subtrahend = 0x3a3a;
+  Result = 0;
+  Status = SafeInt16Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x2020, Result);
+
+  Minuend = 0x3a3a;
+  Subtrahend = 0x5a5a;
+  Status = SafeInt16Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-8224), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = (-31354);
+  Subtrahend = 31354;
+  Status = SafeInt16Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Minuend = (31354);
+  Subtrahend = (-31354);
+  Status = SafeInt16Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32Sub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Minuend;
+  INT32       Subtrahend;
+  INT32       Result;
+
+  //
+  // If the result of subtractions doesn't overflow MAX_INT32 or
+  // underflow MIN_INT32, then it's subtraction
+  //
+  Minuend = 0x5a5a5a5a;
+  Subtrahend = 0x3a3a3a3a;
+  Result = 0;
+  Status = SafeInt32Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x20202020, Result);
+
+  Minuend = 0x3a3a3a3a;
+  Subtrahend = 0x5a5a5a5a;
+  Status = SafeInt32Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-538976288), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = (-2054847098);
+  Subtrahend = 2054847098;
+  Status = SafeInt32Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Minuend = (2054847098);
+  Subtrahend = (-2054847098);
+  Status = SafeInt32Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64Sub (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Minuend;
+  INT64       Subtrahend;
+  INT64       Result;
+
+  //
+  // If the result of subtractions doesn't overflow MAX_INT64 or
+  // underflow MIN_INT64, then it's subtraction
+  //
+  Minuend = 0x5a5a5a5a5a5a5a5a;
+  Subtrahend = 0x3a3a3a3a3a3a3a3a;
+  Result = 0;
+  Status = SafeInt64Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x2020202020202020, Result);
+
+  Minuend = 0x3a3a3a3a3a3a3a3a;
+  Subtrahend = 0x5a5a5a5a5a5a5a5a;
+  Status = SafeInt64Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL((-2314885530818453536), Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Minuend = (-8825501086245354106);
+  Subtrahend = 8825501086245354106;
+  Status = SafeInt64Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  Minuend = (8825501086245354106);
+  Subtrahend = (-8825501086245354106);
+  Status = SafeInt64Sub(Minuend, Subtrahend, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+//
+// Multiplication function tests:
+//
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint8Mult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT8       Multiplicand;
+  UINT8       Multiplier;
+  UINT8       Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_UINT8, it will succeed
+  //
+  Multiplicand = 0x12;
+  Multiplier = 0xa;
+  Result = 0;
+  Status = SafeUint8Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xb4, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x12;
+  Multiplier = 0x23;
+  Status = SafeUint8Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint16Mult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT16      Multiplicand;
+  UINT16      Multiplier;
+  UINT16      Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_UINT16, it will succeed
+  //
+  Multiplicand = 0x212;
+  Multiplier = 0x7a;
+  Result = 0;
+  Status = SafeUint16Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0xfc94, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x1234;
+  Multiplier = 0x213;
+  Status = SafeUint16Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32Mult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT32      Multiplicand;
+  UINT32      Multiplier;
+  UINT32      Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_UINT32, it will succeed
+  //
+  Multiplicand = 0xa122a;
+  Multiplier = 0xd23;
+  Result = 0;
+  Status = SafeUint32Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x844c9dbe, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0xa122a;
+  Multiplier = 0xed23;
+  Status = SafeUint32Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64Mult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  UINT64      Multiplicand;
+  UINT64      Multiplier;
+  UINT64      Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_UINT64, it will succeed
+  //
+  Multiplicand = 0x123456789a;
+  Multiplier = 0x1234567;
+  Result = 0;
+  Status = SafeUint64Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x14b66db9745a07f6, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x123456789a;
+  Multiplier = 0x12345678;
+  Status = SafeUint64Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt8Mult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT8        Multiplicand;
+  INT8        Multiplier;
+  INT8        Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_INT8 and doesn't
+  // underflow MIN_UINT8, it will succeed
+  //
+  Multiplicand = 0x12;
+  Multiplier = 0x7;
+  Result = 0;
+  Status = SafeInt8Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x7e, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x12;
+  Multiplier = 0xa;
+  Status = SafeInt8Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt16Mult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT16       Multiplicand;
+  INT16       Multiplier;
+  INT16       Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_INT16 and doesn't
+  // underflow MIN_UINT16, it will succeed
+  //
+  Multiplicand = 0x123;
+  Multiplier = 0x67;
+  Result = 0;
+  Status = SafeInt16Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x7515, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x123;
+  Multiplier = 0xab;
+  Status = SafeInt16Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32Mult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT32       Multiplicand;
+  INT32       Multiplier;
+  INT32       Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_INT32 and doesn't
+  // underflow MIN_UINT32, it will succeed
+  //
+  Multiplicand = 0x123456;
+  Multiplier = 0x678;
+  Result = 0;
+  Status = SafeInt32Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x75c28c50, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x123456;
+  Multiplier = 0xabc;
+  Status = SafeInt32Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64Mult (
+  IN UNIT_TEST_CONTEXT           Context
+  )
+{
+  EFI_STATUS  Status;
+  INT64       Multiplicand;
+  INT64       Multiplier;
+  INT64       Result;
+
+  //
+  // If the result of multiplication doesn't overflow MAX_INT64 and doesn't
+  // underflow MIN_UINT64, it will succeed
+  //
+  Multiplicand = 0x123456789;
+  Multiplier = 0x6789abcd;
+  Result = 0;
+  Status = SafeInt64Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_NOT_EFI_ERROR(Status);
+  UT_ASSERT_EQUAL(0x75cd9045220d6bb5, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Multiplicand = 0x123456789;
+  Multiplier = 0xa789abcd;
+  Status = SafeInt64Mult(Multiplicand, Multiplier, &Result);
+  UT_ASSERT_EQUAL(RETURN_BUFFER_TOO_SMALL, Status);
+
+  return UNIT_TEST_PASSED;
+}
+
+/**
+
+  Main fuction sets up the unit test environment
+
+**/
+EFI_STATUS
+EFIAPI
+UefiTestMain (
+  VOID
+  )
+{
+  EFI_STATUS                  Status;
+  UNIT_TEST_FRAMEWORK_HANDLE  Framework;
+  UNIT_TEST_SUITE_HANDLE      ConversionTestSuite;
+  UNIT_TEST_SUITE_HANDLE      AdditionSubtractionTestSuite;
+  UNIT_TEST_SUITE_HANDLE      MultiplicationTestSuite;
+
+  Framework = NULL;
+  ConversionTestSuite = NULL;
+  AdditionSubtractionTestSuite = NULL;
+  MultiplicationTestSuite = NULL;
+
+  DEBUG((DEBUG_INFO, "%a v%a\n", UNIT_TEST_NAME, UNIT_TEST_VERSION));
+
+  //
+  // Start setting up the test framework for running the tests.
+  //
+  Status = InitUnitTestFramework (&Framework, UNIT_TEST_NAME, gEfiCallerBaseName, UNIT_TEST_VERSION);
+  if (EFI_ERROR(Status)) {
+    DEBUG((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
+    goto EXIT;
+  }
+
+  ///
+  // Test the conversion functions
+  //
+  Status = CreateUnitTestSuite (&ConversionTestSuite, Framework, "Int Safe Conversions Test Suite", "Common.SafeInt.Convert", NULL, NULL);
+  if (EFI_ERROR(Status)) {
+    DEBUG((DEBUG_ERROR, "Failed in CreateUnitTestSuite for Conversions Test Suite\n"));
+    Status = EFI_OUT_OF_RESOURCES;
+    goto EXIT;
+  }
+  AddTestCase(ConversionTestSuite, "Test SafeInt8ToUint8",    "TestSafeInt8ToUint8",    TestSafeInt8ToUint8,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt8ToUint16",   "TestSafeInt8ToUint16",   TestSafeInt8ToUint16,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt8ToUint32",   "TestSafeInt8ToUint32",   TestSafeInt8ToUint32,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt8ToUintn",    "TestSafeInt8ToUintn",    TestSafeInt8ToUintn,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt8ToUint64",   "TestSafeInt8ToUint64",   TestSafeInt8ToUint64,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint8ToInt8",    "TestSafeUint8ToInt8",    TestSafeUint8ToInt8,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint8ToChar8",   "TestSafeUint8ToChar8",   TestSafeUint8ToChar8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt16ToInt8",    "TestSafeInt16ToInt8",    TestSafeInt16ToInt8,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt16ToChar8",   "TestSafeInt16ToChar8",   TestSafeInt16ToChar8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt16ToUint8",   "TestSafeInt16ToUint8",   TestSafeInt16ToUint8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt16ToUint16",  "TestSafeInt16ToUint16",  TestSafeInt16ToUint16,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt16ToUint32",  "TestSafeInt16ToUint32",  TestSafeInt16ToUint32,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt16ToUintn",   "TestSafeInt16ToUintn",   TestSafeInt16ToUintn,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt16ToUint64",  "TestSafeInt16ToUint64",  TestSafeInt16ToUint64,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint16ToInt8",   "TestSafeUint16ToInt8",   TestSafeUint16ToInt8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint16ToChar8",  "TestSafeUint16ToChar8",  TestSafeUint16ToChar8,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint16ToUint8",  "TestSafeUint16ToUint8",  TestSafeUint16ToUint8,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint16ToInt16",  "TestSafeUint16ToInt16",  TestSafeUint16ToInt16,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt32ToInt8",    "TestSafeInt32ToInt8",    TestSafeInt32ToInt8,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt32ToChar8",   "TestSafeInt32ToChar8",   TestSafeInt32ToChar8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt32ToUint8",   "TestSafeInt32ToUint8",   TestSafeInt32ToUint8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt32ToInt16",   "TestSafeInt32ToInt16",   TestSafeInt32ToInt16,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt32ToUint16",  "TestSafeInt32ToUint16",  TestSafeInt32ToUint16,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt32ToUint32",  "TestSafeInt32ToUint32",  TestSafeInt32ToUint32,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt32ToUintn",   "TestSafeInt32ToUintn",   TestSafeInt32ToUintn,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt32ToUint64",  "TestSafeInt32ToUint64",  TestSafeInt32ToUint64,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint32ToInt8",   "TestSafeUint32ToInt8",   TestSafeUint32ToInt8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint32ToChar8",  "TestSafeUint32ToChar8",  TestSafeUint32ToChar8,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint32ToUint8",  "TestSafeUint32ToUint8",  TestSafeUint32ToUint8,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint32ToInt16",  "TestSafeUint32ToInt16",  TestSafeUint32ToInt16,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint32ToUint16", "TestSafeUint32ToUint16", TestSafeUint32ToUint16, NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint32ToInt32",  "TestSafeUint32ToInt32",  TestSafeUint32ToInt32,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint32ToIntn",   "TestSafeUint32ToIntn",   TestSafeUint32ToIntn,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToInt8",     "TestSafeIntnToInt8",     TestSafeIntnToInt8,     NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToChar8",    "TestSafeIntnToChar8",    TestSafeIntnToChar8,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToUint8",    "TestSafeIntnToUint8",    TestSafeIntnToUint8,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToInt16",    "TestSafeIntnToInt16",    TestSafeIntnToInt16,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToUint16",   "TestSafeIntnToUint16",   TestSafeIntnToUint16,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToInt32",    "TestSafeIntnToInt32",    TestSafeIntnToInt32,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToUint32",   "TestSafeIntnToUint32",   TestSafeIntnToUint32,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToUintn",    "TestSafeIntnToUintn",    TestSafeIntnToUintn,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeIntnToUint64",   "TestSafeIntnToUint64",   TestSafeIntnToUint64,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToInt8",    "TestSafeUintnToInt8",    TestSafeUintnToInt8,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToChar8",   "TestSafeUintnToChar8",   TestSafeUintnToChar8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToUint8",   "TestSafeUintnToUint8",   TestSafeUintnToUint8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToInt16",   "TestSafeUintnToInt16",   TestSafeUintnToInt16,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToUint16",  "TestSafeUintnToUint16",  TestSafeUintnToUint16,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToInt32",   "TestSafeUintnToInt32",   TestSafeUintnToInt32,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToUint32",  "TestSafeUintnToUint32",  TestSafeUintnToUint32,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToIntn",    "TestSafeUintnToIntn",    TestSafeUintnToIntn,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUintnToInt64",   "TestSafeUintnToInt64",   TestSafeUintnToInt64,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToInt8",    "TestSafeInt64ToInt8",    TestSafeInt64ToInt8,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToChar8",   "TestSafeInt64ToChar8",   TestSafeInt64ToChar8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToUint8",   "TestSafeInt64ToUint8",   TestSafeInt64ToUint8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToInt16",   "TestSafeInt64ToInt16",   TestSafeInt64ToInt16,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToUint16",  "TestSafeInt64ToUint16",  TestSafeInt64ToUint16,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToInt32",   "TestSafeInt64ToInt32",   TestSafeInt64ToInt32,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToUint32",  "TestSafeInt64ToUint32",  TestSafeInt64ToUint32,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToIntn",    "TestSafeInt64ToIntn",    TestSafeInt64ToIntn,    NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToUintn",   "TestSafeInt64ToUintn",   TestSafeInt64ToUintn,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeInt64ToUint64",  "TestSafeInt64ToUint64",  TestSafeInt64ToUint64,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToInt8",   "TestSafeUint64ToInt8",   TestSafeUint64ToInt8,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToChar8",  "TestSafeUint64ToChar8",  TestSafeUint64ToChar8,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToUint8",  "TestSafeUint64ToUint8",  TestSafeUint64ToUint8,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToInt16",  "TestSafeUint64ToInt16",  TestSafeUint64ToInt16,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToUint16", "TestSafeUint64ToUint16", TestSafeUint64ToUint16, NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToInt32",  "TestSafeUint64ToInt32",  TestSafeUint64ToInt32,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToUint32", "TestSafeUint64ToUint32", TestSafeUint64ToUint32, NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToIntn",   "TestSafeUint64ToIntn",   TestSafeUint64ToIntn,   NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToUintn",  "TestSafeUint64ToUintn",  TestSafeUint64ToUintn,  NULL, NULL, NULL);
+  AddTestCase(ConversionTestSuite, "Test SafeUint64ToInt64",  "TestSafeUint64ToInt64",  TestSafeUint64ToInt64,  NULL, NULL, NULL);
+
+  //
+  // Test the addition and subtraction functions
+  //
+  Status = CreateUnitTestSuite(&AdditionSubtractionTestSuite, Framework, "Int Safe Add/Subtract Test Suite", "Common.SafeInt.AddSubtract", NULL, NULL);
+  if (EFI_ERROR(Status)) {
+    DEBUG((DEBUG_ERROR, "Failed in CreateUnitTestSuite for Int Safe Add/Subtract Test Suite\n"));
+    Status = EFI_OUT_OF_RESOURCES;
+    goto EXIT;
+  }
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUint8Add",  "TestSafeUint8Add",  TestSafeUint8Add,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUint16Add", "TestSafeUint16Add", TestSafeUint16Add, NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUint32Add", "TestSafeUint32Add", TestSafeUint32Add, NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUintnAdd",  "TestSafeUintnAdd",  TestSafeUintnAdd,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUint64Add", "TestSafeUint64Add", TestSafeUint64Add, NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeInt8Add",   "TestSafeInt8Add",   TestSafeInt8Add,   NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeInt16Add",  "TestSafeInt16Add",  TestSafeInt16Add,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeInt32Add",  "TestSafeInt32Add",  TestSafeInt32Add,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeIntnAdd",   "TestSafeIntnAdd",   TestSafeIntnAdd,   NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeInt64Add",  "TestSafeInt64Add",  TestSafeInt64Add,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUint8Sub",  "TestSafeUint8Sub",  TestSafeUint8Sub,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUint16Sub", "TestSafeUint16Sub", TestSafeUint16Sub, NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUint32Sub", "TestSafeUint32Sub", TestSafeUint32Sub, NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUintnSub",  "TestSafeUintnSub",  TestSafeUintnSub,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeUint64Sub", "TestSafeUint64Sub", TestSafeUint64Sub, NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeInt8Sub",   "TestSafeInt8Sub",   TestSafeInt8Sub,   NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeInt16Sub",  "TestSafeInt16Sub",  TestSafeInt16Sub,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeInt32Sub",  "TestSafeInt32Sub",  TestSafeInt32Sub,  NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeIntnSub",   "TestSafeIntnSub",   TestSafeIntnSub,   NULL, NULL, NULL);
+  AddTestCase(AdditionSubtractionTestSuite, "Test SafeInt64Sub",  "TestSafeInt64Sub",  TestSafeInt64Sub,  NULL, NULL, NULL);
+
+  //
+  // Test the multiplication functions
+  //
+  Status = CreateUnitTestSuite(&MultiplicationTestSuite, Framework, "Int Safe Multiply Test Suite", "Common.SafeInt.Multiply", NULL, NULL);
+  if (EFI_ERROR(Status)) {
+    DEBUG((DEBUG_ERROR, "Failed in CreateUnitTestSuite for Int Safe Multiply Test Suite\n"));
+    Status = EFI_OUT_OF_RESOURCES;
+    goto EXIT;
+  }
+  AddTestCase(MultiplicationTestSuite, "Test SafeUint8Mult",  "TestSafeUint8Mult",  TestSafeUint8Mult,  NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeUint16Mult", "TestSafeUint16Mult", TestSafeUint16Mult, NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeUint32Mult", "TestSafeUint32Mult", TestSafeUint32Mult, NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeUintnMult",  "TestSafeUintnMult",  TestSafeUintnMult,  NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeUint64Mult", "TestSafeUint64Mult", TestSafeUint64Mult, NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeInt8Mult",   "TestSafeInt8Mult",   TestSafeInt8Mult,   NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeInt16Mult",  "TestSafeInt16Mult",  TestSafeInt16Mult,  NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeInt32Mult",  "TestSafeInt32Mult",  TestSafeInt32Mult,  NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeIntnMult",   "TestSafeIntnMult",   TestSafeIntnMult,   NULL, NULL, NULL);
+  AddTestCase(MultiplicationTestSuite, "Test SafeInt64Mult",  "TestSafeInt64Mult",  TestSafeInt64Mult,  NULL, NULL, NULL);
+
+  //
+  // Execute the tests.
+  //
+  Status = RunAllTestSuites(Framework);
+
+EXIT:
+  if (Framework != NULL) {
+    FreeUnitTestFramework(Framework);
+  }
+
+  return Status;
+}
+
+EFI_STATUS
+EFIAPI
+PeiEntryPoint (
+  IN EFI_PEI_FILE_HANDLE       FileHandle,
+  IN CONST EFI_PEI_SERVICES    **PeiServices
+  )
+{
+  return UefiTestMain ();
+}
+
+EFI_STATUS
+EFIAPI
+DxeEntryPoint (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  return UefiTestMain ();
+}
+
+int
+main (
+  int argc,
+  char *argv[]
+  )
+{
+  return UefiTestMain ();
+}
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.h
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.h	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.h	(revision 85718)
@@ -0,0 +1,123 @@
+/** @file
+  UEFI OS based application for unit testing the SafeIntLib.
+
+  Copyright (c) Microsoft Corporation.<BR>
+  Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _TEST_BASE_SAFE_INT_LIB_H_
+#define _TEST_BASE_SAFE_INT_LIB_H_
+
+#include <PiPei.h>
+#include <Uefi.h>
+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UnitTestLib.h>
+#include <Library/SafeIntLib.h>
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt32ToUintn(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint32ToIntn(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToInt32(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnToUint32(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToUint32(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToIntn(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnToInt64(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToIntn(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeInt64ToUintn(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToIntn(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUint64ToUintn(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnAdd(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnAdd(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnSub(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnSub(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeUintnMult(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+UNIT_TEST_STATUS
+EFIAPI
+TestSafeIntnMult(
+  IN UNIT_TEST_CONTEXT           Context
+  );
+
+#endif
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.uni
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.uni	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.uni	(revision 85718)
@@ -0,0 +1,13 @@
+// /** @file
+// Application that Unit Tests the SafeIntLib
+//
+// Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+#string STR_MODULE_ABSTRACT             #language en-US "Application that Unit Tests the SafeIntLib"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "Application that Unit Tests the SafeIntLib."
+
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibDxe.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibDxe.inf	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibDxe.inf	(revision 85718)
@@ -0,0 +1,45 @@
+## @file
+# DXE Driver that Unit Tests the SafeIntLib
+#
+# Copyright (c) Microsoft Corporation.<BR>
+# Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = TestBaseSafeIntLibDxe
+  MODULE_UNI_FILE = TestBaseSafeIntLib.uni
+  FILE_GUID       = 9729DB60-FB9D-4625-9EE1-93B21EC246B8
+  MODULE_TYPE     = DXE_DRIVER
+  VERSION_STRING  = 1.0
+  ENTRY_POINT     = DxeEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  TestBaseSafeIntLib.c
+  TestBaseSafeIntLib.h
+
+[Sources.Ia32, Sources.ARM]
+  SafeIntLibUintnIntnUnitTests32.c
+
+[Sources.X64, Sources.AARCH64]
+  SafeIntLibUintnIntnUnitTests64.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  UefiDriverEntryPoint
+  BaseLib
+  DebugLib
+  SafeIntLib
+  UnitTestLib
+
+[Depex]
+  TRUE
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibHost.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibHost.inf	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibHost.inf	(revision 85718)
@@ -0,0 +1,40 @@
+## @file
+# Host OS based Application that Unit Tests the SafeIntLib
+#
+# Copyright (c) Microsoft Corporation.<BR>
+# Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = TestBaseSafeIntLibHost
+  MODULE_UNI_FILE = TestBaseSafeIntLib.uni
+  FILE_GUID       = 95487689-9E30-41AD-B773-3650C94BCBE2
+  MODULE_TYPE     = HOST_APPLICATION
+  VERSION_STRING  = 1.0
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  TestBaseSafeIntLib.c
+  TestBaseSafeIntLib.h
+
+[Sources.Ia32, Sources.ARM]
+  SafeIntLibUintnIntnUnitTests32.c
+
+[Sources.X64, Sources.AARCH64]
+  SafeIntLibUintnIntnUnitTests64.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  SafeIntLib
+  UnitTestLib
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibPei.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibPei.inf	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibPei.inf	(revision 85718)
@@ -0,0 +1,45 @@
+## @file
+# PEIM that Unit Tests the SafeIntLib
+#
+# Copyright (c) Microsoft Corporation.<BR>
+# Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = TestBaseSafeIntLibPei
+  MODULE_UNI_FILE = TestBaseSafeIntLib.uni
+  FILE_GUID       = 7D910602-ED53-45E6-826E-8266705B9734
+  MODULE_TYPE     = PEIM
+  VERSION_STRING  = 1.0
+  ENTRY_POINT     = PeiEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  TestBaseSafeIntLib.c
+  TestBaseSafeIntLib.h
+
+[Sources.Ia32, Sources.ARM]
+  SafeIntLibUintnIntnUnitTests32.c
+
+[Sources.X64, Sources.AARCH64]
+  SafeIntLibUintnIntnUnitTests64.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  PeimEntryPoint
+  BaseLib
+  DebugLib
+  SafeIntLib
+  UnitTestLib
+
+[Depex]
+  TRUE
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibSmm.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibSmm.inf	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibSmm.inf	(revision 85718)
@@ -0,0 +1,45 @@
+## @file
+# SMM Driver that Unit Tests the SafeIntLib
+#
+# Copyright (c) Microsoft Corporation.<BR>
+# Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = TestBaseSafeIntLibSmm
+  MODULE_UNI_FILE = TestBaseSafeIntLib.uni
+  FILE_GUID       = 2F2A1907-B1B4-4E33-8B83-62A60AB4F0D4
+  MODULE_TYPE     = DXE_SMM_DRIVER
+  VERSION_STRING  = 1.0
+  ENTRY_POINT     = DxeEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  TestBaseSafeIntLib.c
+  TestBaseSafeIntLib.h
+
+[Sources.Ia32, Sources.ARM]
+  SafeIntLibUintnIntnUnitTests32.c
+
+[Sources.X64, Sources.AARCH64]
+  SafeIntLibUintnIntnUnitTests64.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  UefiDriverEntryPoint
+  BaseLib
+  DebugLib
+  SafeIntLib
+  UnitTestLib
+
+[Depex]
+  TRUE
Index: trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibUefiShell.inf
===================================================================
--- trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibUefiShell.inf	(revision 85718)
+++ trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibUefiShell.inf	(revision 85718)
@@ -0,0 +1,42 @@
+## @file
+# UEFI Shell based Application that Unit Tests the SafeIntLib
+#
+# Copyright (c) Microsoft Corporation.<BR>
+# Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION     = 0x00010005
+  BASE_NAME       = TestBaseSafeIntLibUefiShell
+  MODULE_UNI_FILE = TestBaseSafeIntLib.uni
+  FILE_GUID       = 1F91B73E-5B6A-4317-80E8-E7C36A3C7AF4
+  MODULE_TYPE     = UEFI_APPLICATION
+  VERSION_STRING  = 1.0
+  ENTRY_POINT     = DxeEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  TestBaseSafeIntLib.c
+  TestBaseSafeIntLib.h
+
+[Sources.Ia32, Sources.ARM]
+  SafeIntLibUintnIntnUnitTests32.c
+
+[Sources.X64, Sources.AARCH64]
+  SafeIntLibUintnIntnUnitTests64.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  UefiApplicationEntryPoint
+  BaseLib
+  DebugLib
+  SafeIntLib
+  UnitTestLib
