]> git.proxmox.com Git - mirror_edk2.git/blame - StandaloneMmPkg/Include/Library/StandaloneMmMemLib.h
StandaloneMmPkg: Replace BSD License with BSD+Patent License
[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
86094561 11 SPDX-License-Identifier: BSD-2-Clause-Patent\r
880086a2
SV
12\r
13**/\r
14\r
15#ifndef _MM_MEM_LIB_H_\r
16#define _MM_MEM_LIB_H_\r
17\r
18/**\r
19 This function check if the buffer is valid per processor architecture and not overlap with MMRAM.\r
20\r
21 @param Buffer The buffer start address to be checked.\r
22 @param Length The buffer length to be checked.\r
23\r
24 @retval TRUE This buffer is valid per processor architecture and not overlap with MMRAM.\r
25 @retval FALSE This buffer is not valid per processor architecture or overlap with MMRAM.\r
26**/\r
27BOOLEAN\r
28EFIAPI\r
29MmIsBufferOutsideMmValid (\r
30 IN EFI_PHYSICAL_ADDRESS Buffer,\r
31 IN UINT64 Length\r
32 );\r
33\r
34/**\r
35 Copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
36\r
37 This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
38 It checks if source buffer is valid per processor architecture and not overlap with MMRAM.\r
39 If the check passes, it copies memory and returns EFI_SUCCESS.\r
40 If the check fails, it return EFI_SECURITY_VIOLATION.\r
41 The implementation must be reentrant.\r
42\r
43 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
44 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
45 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
46\r
47 @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.\r
48 @retval EFI_SUCCESS Memory is copied.\r
49\r
50**/\r
51EFI_STATUS\r
52EFIAPI\r
53MmCopyMemToMmram (\r
54 OUT VOID *DestinationBuffer,\r
55 IN CONST VOID *SourceBuffer,\r
56 IN UINTN Length\r
57 );\r
58\r
59/**\r
60 Copies a source buffer (MMRAM) to a destination buffer (NON-MMRAM).\r
61\r
62 This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
63 It checks if destination buffer is valid per processor architecture and not overlap with MMRAM.\r
64 If the check passes, it copies memory and returns EFI_SUCCESS.\r
65 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
66 The implementation must be reentrant.\r
67\r
68 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
69 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
70 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
71\r
72 @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with MMRAM.\r
73 @retval EFI_SUCCESS Memory is copied.\r
74\r
75**/\r
76EFI_STATUS\r
77EFIAPI\r
78MmCopyMemFromMmram (\r
79 OUT VOID *DestinationBuffer,\r
80 IN CONST VOID *SourceBuffer,\r
81 IN UINTN Length\r
82 );\r
83\r
84/**\r
85 Copies a source buffer (NON-MMRAM) to a destination buffer (NON-MMRAM).\r
86\r
87 This function copies a source buffer (non-MMRAM) to a destination buffer (MMRAM).\r
88 It checks if source buffer and destination buffer are valid per processor architecture and not overlap with MMRAM.\r
89 If the check passes, it copies memory and returns EFI_SUCCESS.\r
90 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
91 The implementation must be reentrant, and it must handle the case where source buffer overlaps destination buffer.\r
92\r
93 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
94 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
95 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
96\r
97 @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with MMRAM.\r
98 @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with MMRAM.\r
99 @retval EFI_SUCCESS Memory is copied.\r
100\r
101**/\r
102EFI_STATUS\r
103EFIAPI\r
104MmCopyMem (\r
105 OUT VOID *DestinationBuffer,\r
106 IN CONST VOID *SourceBuffer,\r
107 IN UINTN Length\r
108 );\r
109\r
110/**\r
111 Fills a target buffer (NON-MMRAM) with a byte value.\r
112\r
113 This function fills a target buffer (non-MMRAM) with a byte value.\r
114 It checks if target buffer is valid per processor architecture and not overlap with MMRAM.\r
115 If the check passes, it fills memory and returns EFI_SUCCESS.\r
116 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
117\r
118 @param Buffer The memory to set.\r
119 @param Length The number of bytes to set.\r
120 @param Value The value with which to fill Length bytes of Buffer.\r
121\r
122 @retval EFI_SECURITY_VIOLATION The Buffer is invalid per processor architecture or overlap with MMRAM.\r
123 @retval EFI_SUCCESS Memory is set.\r
124\r
125**/\r
126EFI_STATUS\r
127EFIAPI\r
128MmSetMem (\r
129 OUT VOID *Buffer,\r
130 IN UINTN Length,\r
131 IN UINT8 Value\r
132 );\r
133\r
134#endif\r