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