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