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