1 | /** @file
|
---|
2 | Declaration of internal functions for Base Memory Library.
|
---|
3 |
|
---|
4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef __MEM_LIB_INTERNALS__
|
---|
10 | #define __MEM_LIB_INTERNALS__
|
---|
11 |
|
---|
12 | #include <PiPei.h>
|
---|
13 |
|
---|
14 | #include <Library/BaseMemoryLib.h>
|
---|
15 | #include <Library/PeiServicesTablePointerLib.h>
|
---|
16 | #include <Library/DebugLib.h>
|
---|
17 | #include <Library/BaseLib.h>
|
---|
18 |
|
---|
19 | /**
|
---|
20 | Copies a source buffer to a destination buffer, and returns the destination buffer.
|
---|
21 |
|
---|
22 | This function wraps the (*PeiServices)->CopyMem ().
|
---|
23 |
|
---|
24 | @param DestinationBuffer The pointer to the destination buffer of the memory copy.
|
---|
25 | @param SourceBuffer The pointer to the source buffer of the memory copy.
|
---|
26 | @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer.
|
---|
27 |
|
---|
28 | @return DestinationBuffer.
|
---|
29 |
|
---|
30 | **/
|
---|
31 | VOID *
|
---|
32 | EFIAPI
|
---|
33 | InternalMemCopyMem (
|
---|
34 | OUT VOID *Destination,
|
---|
35 | IN CONST VOID *Source,
|
---|
36 | IN UINTN Length
|
---|
37 | );
|
---|
38 |
|
---|
39 | /**
|
---|
40 | Fills a target buffer with a byte value, and returns the target buffer.
|
---|
41 |
|
---|
42 | This function wraps the (*PeiServices)->SetMem ().
|
---|
43 |
|
---|
44 | @param Buffer The memory to set.
|
---|
45 | @param Size The number of bytes to set.
|
---|
46 | @param Value Value of the set operation.
|
---|
47 |
|
---|
48 | @return Buffer.
|
---|
49 |
|
---|
50 | **/
|
---|
51 | VOID *
|
---|
52 | EFIAPI
|
---|
53 | InternalMemSetMem (
|
---|
54 | OUT VOID *Buffer,
|
---|
55 | IN UINTN Size,
|
---|
56 | IN UINT8 Value
|
---|
57 | );
|
---|
58 |
|
---|
59 | /**
|
---|
60 | Fills a target buffer with a 16-bit value, and returns the target buffer.
|
---|
61 |
|
---|
62 | @param Buffer The pointer to the target buffer to fill.
|
---|
63 | @param Length The count of 16-bit value to fill.
|
---|
64 | @param Value The value with which to fill Length bytes of Buffer.
|
---|
65 |
|
---|
66 | @return Buffer
|
---|
67 |
|
---|
68 | **/
|
---|
69 | VOID *
|
---|
70 | EFIAPI
|
---|
71 | InternalMemSetMem16 (
|
---|
72 | OUT VOID *Buffer,
|
---|
73 | IN UINTN Length,
|
---|
74 | IN UINT16 Value
|
---|
75 | );
|
---|
76 |
|
---|
77 | /**
|
---|
78 | Fills a target buffer with a 32-bit value, and returns the target buffer.
|
---|
79 |
|
---|
80 | @param Buffer The pointer to the target buffer to fill.
|
---|
81 | @param Length The count of 32-bit value to fill.
|
---|
82 | @param Value The value with which to fill Length bytes of Buffer.
|
---|
83 |
|
---|
84 | @return Buffer
|
---|
85 |
|
---|
86 | **/
|
---|
87 | VOID *
|
---|
88 | EFIAPI
|
---|
89 | InternalMemSetMem32 (
|
---|
90 | OUT VOID *Buffer,
|
---|
91 | IN UINTN Length,
|
---|
92 | IN UINT32 Value
|
---|
93 | );
|
---|
94 |
|
---|
95 | /**
|
---|
96 | Fills a target buffer with a 64-bit value, and returns the target buffer.
|
---|
97 |
|
---|
98 | @param Buffer The pointer to the target buffer to fill.
|
---|
99 | @param Length The count of 64-bit value to fill.
|
---|
100 | @param Value The value with which to fill Length bytes of Buffer.
|
---|
101 |
|
---|
102 | @return Buffer
|
---|
103 |
|
---|
104 | **/
|
---|
105 | VOID *
|
---|
106 | EFIAPI
|
---|
107 | InternalMemSetMem64 (
|
---|
108 | OUT VOID *Buffer,
|
---|
109 | IN UINTN Length,
|
---|
110 | IN UINT64 Value
|
---|
111 | );
|
---|
112 |
|
---|
113 | /**
|
---|
114 | Set Buffer to 0 for Size bytes.
|
---|
115 |
|
---|
116 | @param Buffer The memory to set.
|
---|
117 | @param Length The number of bytes to set
|
---|
118 |
|
---|
119 | @return Buffer
|
---|
120 |
|
---|
121 | **/
|
---|
122 | VOID *
|
---|
123 | EFIAPI
|
---|
124 | InternalMemZeroMem (
|
---|
125 | OUT VOID *Buffer,
|
---|
126 | IN UINTN Length
|
---|
127 | );
|
---|
128 |
|
---|
129 | /**
|
---|
130 | Compares two memory buffers of a given length.
|
---|
131 |
|
---|
132 | @param DestinationBuffer The first memory buffer
|
---|
133 | @param SourceBuffer The second memory buffer
|
---|
134 | @param Length The length of DestinationBuffer and SourceBuffer memory
|
---|
135 | regions to compare. Must be non-zero.
|
---|
136 |
|
---|
137 | @return 0 All Length bytes of the two buffers are identical.
|
---|
138 | @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
|
---|
139 | mismatched byte in DestinationBuffer.
|
---|
140 |
|
---|
141 | **/
|
---|
142 | INTN
|
---|
143 | EFIAPI
|
---|
144 | InternalMemCompareMem (
|
---|
145 | IN CONST VOID *DestinationBuffer,
|
---|
146 | IN CONST VOID *SourceBuffer,
|
---|
147 | IN UINTN Length
|
---|
148 | );
|
---|
149 |
|
---|
150 | /**
|
---|
151 | Scans a target buffer for an 8-bit value, and returns a pointer to the
|
---|
152 | matching 8-bit value in the target buffer.
|
---|
153 |
|
---|
154 | @param Buffer The pointer to the target buffer to scan.
|
---|
155 | @param Length The count of 8-bit value to scan. Must be non-zero.
|
---|
156 | @param Value The value to search for in the target buffer.
|
---|
157 |
|
---|
158 | @return The pointer to the first occurrence, or NULL if not found.
|
---|
159 |
|
---|
160 | **/
|
---|
161 | CONST VOID *
|
---|
162 | EFIAPI
|
---|
163 | InternalMemScanMem8 (
|
---|
164 | IN CONST VOID *Buffer,
|
---|
165 | IN UINTN Length,
|
---|
166 | IN UINT8 Value
|
---|
167 | );
|
---|
168 |
|
---|
169 | /**
|
---|
170 | Scans a target buffer for a 16-bit value, and returns a pointer to the
|
---|
171 | matching 16-bit value in the target buffer.
|
---|
172 |
|
---|
173 | @param Buffer The pointer to the target buffer to scan.
|
---|
174 | @param Length The count of 16-bit value to scan. Must be non-zero.
|
---|
175 | @param Value The value to search for in the target buffer.
|
---|
176 |
|
---|
177 | @return The pointer to the first occurrence, or NULL if not found.
|
---|
178 |
|
---|
179 | **/
|
---|
180 | CONST VOID *
|
---|
181 | EFIAPI
|
---|
182 | InternalMemScanMem16 (
|
---|
183 | IN CONST VOID *Buffer,
|
---|
184 | IN UINTN Length,
|
---|
185 | IN UINT16 Value
|
---|
186 | );
|
---|
187 |
|
---|
188 | /**
|
---|
189 | Scans a target buffer for a 32-bit value, and returns a pointer to the
|
---|
190 | matching 32-bit value in the target buffer.
|
---|
191 |
|
---|
192 | @param Buffer The pointer to the target buffer to scan.
|
---|
193 | @param Length The count of 32-bit value to scan. Must be non-zero.
|
---|
194 | @param Value The value to search for in the target buffer.
|
---|
195 |
|
---|
196 | @return The pointer to the first occurrence, or NULL if not found.
|
---|
197 |
|
---|
198 | **/
|
---|
199 | CONST VOID *
|
---|
200 | EFIAPI
|
---|
201 | InternalMemScanMem32 (
|
---|
202 | IN CONST VOID *Buffer,
|
---|
203 | IN UINTN Length,
|
---|
204 | IN UINT32 Value
|
---|
205 | );
|
---|
206 |
|
---|
207 | /**
|
---|
208 | Scans a target buffer for a 64-bit value, and returns a pointer to the
|
---|
209 | matching 64-bit value in the target buffer.
|
---|
210 |
|
---|
211 | @param Buffer The pointer to the target buffer to scan.
|
---|
212 | @param Length The count of 64-bit value to scan. Must be non-zero.
|
---|
213 | @param Value The value to search for in the target buffer.
|
---|
214 |
|
---|
215 | @return The pointer to the first occurrence, or NULL if not found.
|
---|
216 |
|
---|
217 | **/
|
---|
218 | CONST VOID *
|
---|
219 | EFIAPI
|
---|
220 | InternalMemScanMem64 (
|
---|
221 | IN CONST VOID *Buffer,
|
---|
222 | IN UINTN Length,
|
---|
223 | IN UINT64 Value
|
---|
224 | );
|
---|
225 |
|
---|
226 | /**
|
---|
227 | Checks whether the contents of a buffer are all zeros.
|
---|
228 |
|
---|
229 | @param Buffer The pointer to the buffer to be checked.
|
---|
230 | @param Length The size of the buffer (in bytes) to be checked.
|
---|
231 |
|
---|
232 | @retval TRUE Contents of the buffer are all zeros.
|
---|
233 | @retval FALSE Contents of the buffer are not all zeros.
|
---|
234 |
|
---|
235 | **/
|
---|
236 | BOOLEAN
|
---|
237 | EFIAPI
|
---|
238 | InternalMemIsZeroBuffer (
|
---|
239 | IN CONST VOID *Buffer,
|
---|
240 | IN UINTN Length
|
---|
241 | );
|
---|
242 |
|
---|
243 | #endif
|
---|