]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StandaloneMmPkg/Library/StandaloneMmMemLib/AArch64/StandaloneMmMemLibInternal.c
StandaloneMmPkg/MemLib: Add Standalone MM instance of memory check library.
[mirror_edk2.git] / StandaloneMmPkg / Library / StandaloneMmMemLib / AArch64 / StandaloneMmMemLibInternal.c
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