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