]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/SmmMemLib.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Library / SmmMemLib.h
CommitLineData
d425764e
JY
1/** @file\r
2 Provides services for SMM Memory Operation.\r
3\r
4 The SMM Mem Library provides function for checking if buffer is outside SMRAM and valid.\r
5 It also provides functions for copy data from SMRAM to non-SMRAM, from non-SMRAM to SMRAM,\r
6 from non-SMRAM to non-SMRAM, or set data in non-SMRAM.\r
9095d37b
LG
7\r
8 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 9 SPDX-License-Identifier: BSD-2-Clause-Patent\r
d425764e
JY
10\r
11**/\r
12\r
13#ifndef _SMM_MEM_LIB_H_\r
14#define _SMM_MEM_LIB_H_\r
15\r
16/**\r
17 This function check if the buffer is valid per processor architecture and not overlap with SMRAM.\r
18\r
19 @param Buffer The buffer start address to be checked.\r
20 @param Length The buffer length to be checked.\r
21\r
22 @retval TRUE This buffer is valid per processor architecture and not overlap with SMRAM.\r
23 @retval FALSE This buffer is not valid per processor architecture or overlap with SMRAM.\r
24**/\r
25BOOLEAN\r
26EFIAPI\r
27SmmIsBufferOutsideSmmValid (\r
28 IN EFI_PHYSICAL_ADDRESS Buffer,\r
29 IN UINT64 Length\r
30 );\r
31\r
32/**\r
33 Copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).\r
34\r
35 This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).\r
36 It checks if source buffer is valid per processor architecture and not overlap with SMRAM.\r
37 If the check passes, it copies memory and returns EFI_SUCCESS.\r
38 If the check fails, it return EFI_SECURITY_VIOLATION.\r
39 The implementation must be reentrant.\r
40\r
41 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
42 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
43 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
44\r
45 @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with SMRAM.\r
46 @retval EFI_SUCCESS Memory is copied.\r
47\r
48**/\r
49EFI_STATUS\r
50EFIAPI\r
51SmmCopyMemToSmram (\r
52 OUT VOID *DestinationBuffer,\r
53 IN CONST VOID *SourceBuffer,\r
54 IN UINTN Length\r
55 );\r
56\r
57/**\r
58 Copies a source buffer (SMRAM) to a destination buffer (NON-SMRAM).\r
59\r
60 This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).\r
61 It checks if destination buffer is valid per processor architecture and not overlap with SMRAM.\r
62 If the check passes, it copies memory and returns EFI_SUCCESS.\r
63 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
64 The implementation must be reentrant.\r
9095d37b 65\r
d425764e
JY
66 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
67 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
68 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
69\r
70 @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with SMRAM.\r
71 @retval EFI_SUCCESS Memory is copied.\r
72\r
73**/\r
74EFI_STATUS\r
75EFIAPI\r
76SmmCopyMemFromSmram (\r
77 OUT VOID *DestinationBuffer,\r
78 IN CONST VOID *SourceBuffer,\r
79 IN UINTN Length\r
80 );\r
81\r
82/**\r
83 Copies a source buffer (NON-SMRAM) to a destination buffer (NON-SMRAM).\r
84\r
85 This function copies a source buffer (non-SMRAM) to a destination buffer (SMRAM).\r
86 It checks if source buffer and destination buffer are valid per processor architecture and not overlap with SMRAM.\r
87 If the check passes, it copies memory and returns EFI_SUCCESS.\r
88 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
89 The implementation must be reentrant, and it must handle the case where source buffer overlaps destination buffer.\r
9095d37b 90\r
d425764e
JY
91 @param DestinationBuffer The pointer to the destination buffer of the memory copy.\r
92 @param SourceBuffer The pointer to the source buffer of the memory copy.\r
93 @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.\r
94\r
95 @retval EFI_SECURITY_VIOLATION The DesinationBuffer is invalid per processor architecture or overlap with SMRAM.\r
96 @retval EFI_SECURITY_VIOLATION The SourceBuffer is invalid per processor architecture or overlap with SMRAM.\r
97 @retval EFI_SUCCESS Memory is copied.\r
98\r
99**/\r
100EFI_STATUS\r
101EFIAPI\r
102SmmCopyMem (\r
103 OUT VOID *DestinationBuffer,\r
104 IN CONST VOID *SourceBuffer,\r
105 IN UINTN Length\r
106 );\r
107\r
108/**\r
109 Fills a target buffer (NON-SMRAM) with a byte value.\r
110\r
111 This function fills a target buffer (non-SMRAM) with a byte value.\r
112 It checks if target buffer is valid per processor architecture and not overlap with SMRAM.\r
113 If the check passes, it fills memory and returns EFI_SUCCESS.\r
114 If the check fails, it returns EFI_SECURITY_VIOLATION.\r
9095d37b 115\r
d425764e
JY
116 @param Buffer The memory to set.\r
117 @param Length The number of bytes to set.\r
118 @param Value The value with which to fill Length bytes of Buffer.\r
9095d37b 119\r
d425764e
JY
120 @retval EFI_SECURITY_VIOLATION The Buffer is invalid per processor architecture or overlap with SMRAM.\r
121 @retval EFI_SUCCESS Memory is set.\r
122\r
123**/\r
124EFI_STATUS\r
125EFIAPI\r
126SmmSetMem (\r
127 OUT VOID *Buffer,\r
128 IN UINTN Length,\r
129 IN UINT8 Value\r
130 );\r
131\r
9095d37b 132#endif\r