]> git.proxmox.com Git - mirror_edk2.git/blame - StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h
StandaloneMmPkg/MemLib: Add Standalone MM instance of memory check library.
[mirror_edk2.git] / StandaloneMmPkg / Include / Library / StandaloneMmMemLib.h
CommitLineData
880086a2
SV
1/** @file\r
2 Provides services for MM Memory Operation.\r
3\r
4 The MM Mem Library provides function for checking if buffer is outside MMRAM and valid.\r
5 It also provides functions for copy data from MMRAM to non-MMRAM, from non-MMRAM to MMRAM,\r
6 from non-MMRAM to non-MMRAM, or set data in non-MMRAM.\r
7\r
8 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
9 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>\r
10\r
11 This program and the accompanying materials\r
12 are licensed and made available under the terms and conditions of the BSD License\r
13 which accompanies this distribution. The full text of the license may be found at\r
14 http://opensource.org/licenses/bsd-license.php\r
15\r
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
18\r
19**/\r
20\r
21#ifndef _MM_MEM_LIB_H_\r
22#define _MM_MEM_LIB_H_\r
23\r
24/**\r
25 This function check if the buffer is valid per processor architecture and not overlap with MMRAM.\r
26\r
27 @param Buffer The buffer start address to be checked.\r
28 @param Length The buffer length to be checked.\r
29\r
30 @retval TRUE This buffer is valid per processor architecture and not overlap with MMRAM.\r
31 @retval FALSE This buffer is not valid per processor architecture or overlap with MMRAM.\r
32**/\r
33BOOLEAN\r
34EFIAPI\r
35MmIsBufferOutsideMmValid (\r
36 IN EFI_PHYSICAL_ADDRESS Buffer,\r
37 IN UINT64 Length\r
38 );\r
39\r
40/**\r
41 Copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
42\r
43 This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
44 It checks if source buffer is valid per processor architecture and not overlap with MMRAM.\r
45 If the check passes, it copies memory and returns EFI_SUCCESS.\r
46 If the check fails, it return EFI_SECURITY_VIOLATION.\r
47 The implementation must be reentrant.\r
48\r
49 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
50 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
51 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
52\r
53 @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.\r
54 @retval EFI_SUCCESS Memory is copied.\r
55\r
56**/\r
57EFI_STATUS\r
58EFIAPI\r
59MmCopyMemToMmram (\r
60 OUT VOID *DestinationBuffer,\r
61 IN CONST VOID *SourceBuffer,\r
62 IN UINTN Length\r
63 );\r
64\r
65/**\r
66 Copies a source buffer (MMRAM) to a destination buffer (NON-MMRAM).\r
67\r
68 This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
69 It checks if destination buffer is valid per processor architecture and not overlap with MMRAM.\r
70 If the check passes, it copies memory and returns EFI_SUCCESS.\r
71 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
72 The implementation must be reentrant.\r
73\r
74 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
75 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
76 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
77\r
78 @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with MMRAM.\r
79 @retval EFI_SUCCESS Memory is copied.\r
80\r
81**/\r
82EFI_STATUS\r
83EFIAPI\r
84MmCopyMemFromMmram (\r
85 OUT VOID *DestinationBuffer,\r
86 IN CONST VOID *SourceBuffer,\r
87 IN UINTN Length\r
88 );\r
89\r
90/**\r
91 Copies a source buffer (NON-MMRAM) to a destination buffer (NON-MMRAM).\r
92\r
93 This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
94 It checks if source buffer and destination buffer are valid per processor architecture and not overlap with MMRAM.\r
95 If the check passes, it copies memory and returns EFI_SUCCESS.\r
96 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
97 The implementation must be reentrant, and it must handle the case where source buffer overlaps destination buffer.\r
98\r
99 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
100 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
101 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
102\r
103 @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with MMRAM.\r
104 @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.\r
105 @retval EFI_SUCCESS Memory is copied.\r
106\r
107**/\r
108EFI_STATUS\r
109EFIAPI\r
110MmCopyMem (\r
111 OUT VOID *DestinationBuffer,\r
112 IN CONST VOID *SourceBuffer,\r
113 IN UINTN Length\r
114 );\r
115\r
116/**\r
117 Fills a target buffer (NON-MMRAM) with a byte value.\r
118\r
119 This function fills a target buffer (non-MMRAM) with a byte value.\r
120 It checks if target buffer is valid per processor architecture and not overlap with MMRAM.\r
121 If the check passes, it fills memory and returns EFI_SUCCESS.\r
122 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
123\r
124 @param Buffer The memory to set.\r
125 @param Length The number of bytes to set.\r
126 @param Value The value with which to fill Length bytes of Buffer.\r
127\r
128 @retval EFI_SECURITY_VIOLATION The Buffer is invalid per processor architecture or overlap with MMRAM.\r
129 @retval EFI_SUCCESS Memory is set.\r
130\r
131**/\r
132EFI_STATUS\r
133EFIAPI\r
134MmSetMem (\r
135 OUT VOID *Buffer,\r
136 IN UINTN Length,\r
137 IN UINT8 Value\r
138 );\r
139\r
140#endif\r