]> git.proxmox.com Git - mirror_edk2.git/commitdiff
StandaloneMmPkg/MemLib: Add Standalone MM instance of memory check library.
authorSupreeth Venkatesh <supreeth.venkatesh@arm.com>
Fri, 13 Jul 2018 15:05:23 +0000 (23:05 +0800)
committerJiewen Yao <jiewen.yao@intel.com>
Fri, 20 Jul 2018 02:55:28 +0000 (10:55 +0800)
MM memory check library library implementation. This library consumes
MM_ACCESS_PROTOCOL to get MMRAM information. In order to use this
library instance, the platform should produce all MMRAM range via
MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core
and MM driver) and/or specific dedicated hardware.

This patch provides services for MM Memory Operation.
The management mode Mem Library provides function for checking if buffer
is outside MMRAM and valid. It also provides functions for copy data
from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,
from non-MMRAM to non-MMRAM, or set data in non-MMRAM.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Reviewed-by: Achin Gupta <achin.gupta@arm.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com>
StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h [new file with mode: 0644]
StandaloneMmPkg/Library/StandaloneMmMemLib/AArch64/StandaloneMmMemLibInternal.c [new file with mode: 0644]
StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c [new file with mode: 0644]
StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf [new file with mode: 0644]

diff --git a/StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h b/StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h
new file mode 100644 (file)
index 0000000..8e3f280
--- /dev/null
@@ -0,0 +1,140 @@
+/** @file\r
+  Provides services for MM Memory Operation.\r
+\r
+  The MM Mem Library provides function for checking if buffer is outside MMRAM and valid.\r
+  It also provides functions for copy data from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,\r
+  from non-MMRAM to non-MMRAM, or set data in non-MMRAM.\r
+\r
+  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _MM_MEM_LIB_H_\r
+#define _MM_MEM_LIB_H_\r
+\r
+/**\r
+  This function check if the buffer is valid per processor architecture and not overlap with MMRAM.\r
+\r
+  @param Buffer  The buffer start address to be checked.\r
+  @param Length  The buffer length to be checked.\r
+\r
+  @retval TRUE  This buffer is valid per processor architecture and not overlap with MMRAM.\r
+  @retval FALSE This buffer is not valid per processor architecture or overlap with MMRAM.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MmIsBufferOutsideMmValid (\r
+  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
+  IN UINT64                Length\r
+  );\r
+\r
+/**\r
+  Copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
+\r
+  This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
+  It checks if source buffer is valid per processor architecture and not overlap with MMRAM.\r
+  If the check passes, it copies memory and returns EFI_SUCCESS.\r
+  If the check fails, it return EFI_SECURITY_VIOLATION.\r
+  The implementation must be reentrant.\r
+\r
+  @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        The pointer to the source buffer of the memory copy.\r
+  @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SUCCESS            Memory is copied.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmCopyMemToMmram (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  );\r
+\r
+/**\r
+  Copies a source buffer (MMRAM) to a destination buffer (NON-MMRAM).\r
+\r
+  This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
+  It checks if destination buffer is valid per processor architecture and not overlap with MMRAM.\r
+  If the check passes, it copies memory and returns EFI_SUCCESS.\r
+  If the check fails, it returns EFI_SECURITY_VIOLATION.\r
+  The implementation must be reentrant.\r
+\r
+  @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        The pointer to the source buffer of the memory copy.\r
+  @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SUCCESS            Memory is copied.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmCopyMemFromMmram (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  );\r
+\r
+/**\r
+  Copies a source buffer (NON-MMRAM) to a destination buffer (NON-MMRAM).\r
+\r
+  This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
+  It checks if source buffer and destination buffer are valid per processor architecture and not overlap with MMRAM.\r
+  If the check passes, it copies memory and returns EFI_SUCCESS.\r
+  If the check fails, it returns EFI_SECURITY_VIOLATION.\r
+  The implementation must be reentrant, and it must handle the case where source buffer overlaps destination buffer.\r
+\r
+  @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        The pointer to the source buffer of the memory copy.\r
+  @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SUCCESS            Memory is copied.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmCopyMem (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  );\r
+\r
+/**\r
+  Fills a target buffer (NON-MMRAM) with a byte value.\r
+\r
+  This function fills a target buffer (non-MMRAM) with a byte value.\r
+  It checks if target buffer is valid per processor architecture and not overlap with MMRAM.\r
+  If the check passes, it fills memory and returns EFI_SUCCESS.\r
+  If the check fails, it returns EFI_SECURITY_VIOLATION.\r
+\r
+  @param  Buffer    The memory to set.\r
+  @param  Length    The number of bytes to set.\r
+  @param  Value     The value with which to fill Length bytes of Buffer.\r
+\r
+  @retval EFI_SECURITY_VIOLATION The Buffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SUCCESS            Memory is set.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmSetMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length,\r
+  IN UINT8  Value\r
+  );\r
+\r
+#endif\r
diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/AArch64/StandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/AArch64/StandaloneMmMemLibInternal.c
new file mode 100644 (file)
index 0000000..b3a5861
--- /dev/null
@@ -0,0 +1,49 @@
+/** @file\r
+  Internal ARCH Specific file of MM memory check library.\r
+\r
+  MM memory check library implementation. This library consumes MM_ACCESS_PROTOCOL\r
+  to get MMRAM information. In order to use this library instance, the platform should produce\r
+  all MMRAM range via MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core\r
+  and MM driver) and/or specific dedicated hardware.\r
+\r
+  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+//\r
+// Maximum support address used to check input buffer\r
+//\r
+extern EFI_PHYSICAL_ADDRESS  mMmMemLibInternalMaximumSupportAddress;\r
+\r
+/**\r
+  Calculate and save the maximum support address.\r
+\r
+**/\r
+VOID\r
+MmMemLibInternalCalculateMaximumSupportAddress (\r
+  VOID\r
+  )\r
+{\r
+  UINT8        PhysicalAddressBits;\r
+\r
+  PhysicalAddressBits = 36;\r
+\r
+  //\r
+  // Save the maximum support address in one global variable\r
+  //\r
+  mMmMemLibInternalMaximumSupportAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1);\r
+  DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress = 0x%lx\n", mMmMemLibInternalMaximumSupportAddress));\r
+}\r
+\r
+\r
diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c
new file mode 100644 (file)
index 0000000..ba1a57d
--- /dev/null
@@ -0,0 +1,269 @@
+/** @file\r
+  Instance of MM memory check library.\r
+\r
+  MM memory check library library implementation. This library consumes MM_ACCESS_PROTOCOL\r
+  to get MMRAM information. In order to use this library instance, the platform should produce\r
+  all MMRAM range via MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core\r
+  and MM driver) and/or specific dedicated hardware.\r
+\r
+  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <PiMm.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges;\r
+UINTN                mMmMemLibInternalMmramCount;\r
+\r
+//\r
+// Maximum support address used to check input buffer\r
+//\r
+EFI_PHYSICAL_ADDRESS  mMmMemLibInternalMaximumSupportAddress = 0;\r
+\r
+/**\r
+  Calculate and save the maximum support address.\r
+\r
+**/\r
+VOID\r
+MmMemLibInternalCalculateMaximumSupportAddress (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This function check if the buffer is valid per processor architecture and not overlap with MMRAM.\r
+\r
+  @param Buffer  The buffer start address to be checked.\r
+  @param Length  The buffer length to be checked.\r
+\r
+  @retval TRUE  This buffer is valid per processor architecture and not overlap with MMRAM.\r
+  @retval FALSE This buffer is not valid per processor architecture or overlap with MMRAM.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+MmIsBufferOutsideMmValid (\r
+  IN EFI_PHYSICAL_ADDRESS  Buffer,\r
+  IN UINT64                Length\r
+  )\r
+{\r
+  UINTN  Index;\r
+\r
+  //\r
+  // Check override.\r
+  // NOTE: (B:0->L:4G) is invalid for IA32, but (B:1->L:4G-1)/(B:4G-1->L:1) is valid.\r
+  //\r
+  if ((Length > mMmMemLibInternalMaximumSupportAddress) ||\r
+      (Buffer > mMmMemLibInternalMaximumSupportAddress) ||\r
+      ((Length != 0) && (Buffer > (mMmMemLibInternalMaximumSupportAddress - (Length - 1)))) ) {\r
+    //\r
+    // Overflow happen\r
+    //\r
+    DEBUG ((\r
+      DEBUG_ERROR,\r
+      "MmIsBufferOutsideMmValid: Overflow: Buffer (0x%lx) - Length (0x%lx), MaximumSupportAddress (0x%lx)\n",\r
+      Buffer,\r
+      Length,\r
+      mMmMemLibInternalMaximumSupportAddress\r
+      ));\r
+    return FALSE;\r
+  }\r
+\r
+  for (Index = 0; Index < mMmMemLibInternalMmramCount; Index ++) {\r
+    if (((Buffer >= mMmMemLibInternalMmramRanges[Index].CpuStart) &&\r
+         (Buffer < mMmMemLibInternalMmramRanges[Index].CpuStart + mMmMemLibInternalMmramRanges[Index].PhysicalSize)) ||\r
+        ((mMmMemLibInternalMmramRanges[Index].CpuStart >= Buffer) &&\r
+         (mMmMemLibInternalMmramRanges[Index].CpuStart < Buffer + Length))) {\r
+      DEBUG ((\r
+        DEBUG_ERROR,\r
+        "MmIsBufferOutsideMmValid: Overlap: Buffer (0x%lx) - Length (0x%lx), ",\r
+        Buffer,\r
+        Length\r
+        ));\r
+      DEBUG ((\r
+        DEBUG_ERROR,\r
+        "CpuStart (0x%lx) - PhysicalSize (0x%lx)\n",\r
+        mMmMemLibInternalMmramRanges[Index].CpuStart,\r
+        mMmMemLibInternalMmramRanges[Index].PhysicalSize\r
+        ));\r
+      return FALSE;\r
+    }\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
+\r
+  This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
+  It checks if source buffer is valid per processor architecture and not overlap with MMRAM.\r
+  If the check passes, it copies memory and returns EFI_SUCCESS.\r
+  If the check fails, it return EFI_SECURITY_VIOLATION.\r
+  The implementation must be reentrant.\r
+\r
+  @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        The pointer to the source buffer of the memory copy.\r
+  @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SUCCESS            Memory is copied.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmCopyMemToMmram (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)SourceBuffer, Length)) {\r
+    DEBUG ((DEBUG_ERROR, "MmCopyMemToMmram: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));\r
+    return EFI_SECURITY_VIOLATION;\r
+  }\r
+  CopyMem (DestinationBuffer, SourceBuffer, Length);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Copies a source buffer (MMRAM) to a destination buffer (NON-MMRAM).\r
+\r
+  This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
+  It checks if destination buffer is valid per processor architecture and not overlap with MMRAM.\r
+  If the check passes, it copies memory and returns EFI_SUCCESS.\r
+  If the check fails, it returns EFI_SECURITY_VIOLATION.\r
+  The implementation must be reentrant.\r
+\r
+  @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        The pointer to the source buffer of the memory copy.\r
+  @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SUCCESS            Memory is copied.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmCopyMemFromMmram (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {\r
+    DEBUG ((DEBUG_ERROR, "MmCopyMemFromMmram: Security Violation: Destination (0x%x), Length (0x%x)\n",\r
+            DestinationBuffer, Length));\r
+    return EFI_SECURITY_VIOLATION;\r
+  }\r
+  CopyMem (DestinationBuffer, SourceBuffer, Length);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Copies a source buffer (NON-MMRAM) to a destination buffer (NON-MMRAM).\r
+\r
+  This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
+  It checks if source buffer and destination buffer are valid per processor architecture and not overlap with MMRAM.\r
+  If the check passes, it copies memory and returns EFI_SUCCESS.\r
+  If the check fails, it returns EFI_SECURITY_VIOLATION.\r
+  The implementation must be reentrant, and it must handle the case where source buffer overlaps destination buffer.\r
+\r
+  @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.\r
+  @param  SourceBuffer        The pointer to the source buffer of the memory copy.\r
+  @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
+\r
+  @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SUCCESS            Memory is copied.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmCopyMem (\r
+  OUT VOID       *DestinationBuffer,\r
+  IN CONST VOID  *SourceBuffer,\r
+  IN UINTN       Length\r
+  )\r
+{\r
+  if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)DestinationBuffer, Length)) {\r
+    DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Destination (0x%x), Length (0x%x)\n",\r
+            DestinationBuffer, Length));\r
+    return EFI_SECURITY_VIOLATION;\r
+  }\r
+  if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)SourceBuffer, Length)) {\r
+    DEBUG ((DEBUG_ERROR, "MmCopyMem: Security Violation: Source (0x%x), Length (0x%x)\n", SourceBuffer, Length));\r
+    return EFI_SECURITY_VIOLATION;\r
+  }\r
+  CopyMem (DestinationBuffer, SourceBuffer, Length);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  Fills a target buffer (NON-MMRAM) with a byte value.\r
+\r
+  This function fills a target buffer (non-MMRAM) with a byte value.\r
+  It checks if target buffer is valid per processor architecture and not overlap with MMRAM.\r
+  If the check passes, it fills memory and returns EFI_SUCCESS.\r
+  If the check fails, it returns EFI_SECURITY_VIOLATION.\r
+\r
+  @param  Buffer    The memory to set.\r
+  @param  Length    The number of bytes to set.\r
+  @param  Value     The value with which to fill Length bytes of Buffer.\r
+\r
+  @retval EFI_SECURITY_VIOLATION The Buffer is invalid per processor architecture or overlap with MMRAM.\r
+  @retval EFI_SUCCESS            Memory is set.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MmSetMem (\r
+  OUT VOID  *Buffer,\r
+  IN UINTN  Length,\r
+  IN UINT8  Value\r
+  )\r
+{\r
+  if (!MmIsBufferOutsideMmValid ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Length)) {\r
+    DEBUG ((DEBUG_ERROR, "MmSetMem: Security Violation: Source (0x%x), Length (0x%x)\n", Buffer, Length));\r
+    return EFI_SECURITY_VIOLATION;\r
+  }\r
+  SetMem (Buffer, Length, Value);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+  The constructor function initializes the Mm Mem library\r
+\r
+  @param  ImageHandle   The firmware allocated handle for the EFI image.\r
+  @param  SystemTable   A pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MemLibConstructor (\r
+  IN EFI_HANDLE             ImageHandle,\r
+  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable\r
+  )\r
+{\r
+\r
+  //\r
+  // Calculate and save maximum support address\r
+  //\r
+  MmMemLibInternalCalculateMaximumSupportAddress ();\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
new file mode 100644 (file)
index 0000000..db1041c
--- /dev/null
@@ -0,0 +1,50 @@
+## @file\r
+#  Instance of MM memory check library.\r
+#\r
+#  MM memory check library library implementation. This library consumes MM_ACCESS_PROTOCOL\r
+#  to get MMRAM information. In order to use this library instance, the platform should produce\r
+#  all MMRAM range via MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core\r
+#  and MM driver) and/or specific dedicated hardware.\r
+#\r
+#  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x0001001A\r
+  BASE_NAME                      = MemLib\r
+  FILE_GUID                      = EA355F14-6409-4716-829F-37B3BC7C7F26\r
+  MODULE_TYPE                    = MM_STANDALONE\r
+  VERSION_STRING                 = 1.0\r
+  PI_SPECIFICATION_VERSION       = 0x00010032\r
+  LIBRARY_CLASS                  = MemLib|MM_STANDALONE MM_CORE_STANDALONE\r
+  CONSTRUCTOR                    = MemLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = AARCH64\r
+#\r
+\r
+[Sources.Common]\r
+  StandaloneMmMemLib.c\r
+\r
+[Sources.AARCH64]\r
+  AArch64/StandaloneMmMemLibInternal.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  StandaloneMmPkg/StandaloneMmPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  DebugLib\r