]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Memory-only library functions with no library constructor/destructor\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | Module Name: BaseMemoryLib.h\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef __BASE_MEMORY_LIB__\r | |
18 | #define __BASE_MEMORY_LIB__\r | |
19 | \r | |
20 | /**\r | |
21 | Copy Length bytes from Source to Destination.\r | |
22 | \r | |
23 | This function copies Length bytes from SourceBuffer to DestinationBuffer, and\r | |
24 | returns DestinationBuffer. The implementation must be reentrant, and it must\r | |
25 | handle the case where SourceBuffer overlaps DestinationBuffer.\r | |
26 | \r | |
27 | If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then\r | |
28 | ASSERT().\r | |
29 | If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r | |
30 | \r | |
31 | @param Destination Target of copy\r | |
32 | @param Source Place to copy from\r | |
33 | @param Length Number of bytes to copy\r | |
34 | \r | |
35 | @return Destination\r | |
36 | \r | |
37 | **/\r | |
38 | VOID *\r | |
39 | EFIAPI\r | |
40 | CopyMem (\r | |
41 | OUT VOID *DestinationBuffer,\r | |
42 | IN CONST VOID *SourceBuffer,\r | |
43 | IN UINTN Length\r | |
44 | );\r | |
45 | \r | |
46 | /**\r | |
47 | Set Buffer to Value for Size bytes.\r | |
48 | \r | |
49 | This function fills Length bytes of Buffer with Value, and returns Buffer.\r | |
50 | \r | |
51 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
52 | \r | |
53 | @param Buffer Memory to set.\r | |
54 | @param Size Number of bytes to set\r | |
55 | @param Value Value of the set operation.\r | |
56 | \r | |
57 | @return Buffer\r | |
58 | \r | |
59 | **/\r | |
60 | VOID *\r | |
61 | EFIAPI\r | |
62 | SetMem (\r | |
63 | OUT VOID *Buffer,\r | |
64 | IN UINTN Length,\r | |
65 | IN UINT8 Value\r | |
66 | );\r | |
67 | \r | |
68 | /**\r | |
69 | Fills a target buffer with a 16-bit value, and returns the target buffer.\r | |
70 | \r | |
71 | This function fills Length bytes of Buffer with the 16-bit value specified by\r | |
72 | Value, and returns Buffer. Value is repeated every 16-bits in for Length\r | |
73 | bytes of Buffer.\r | |
74 | \r | |
75 | If Buffer is NULL and Length > 0, then ASSERT().\r | |
76 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
77 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
78 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
79 | \r | |
80 | @param Buffer Pointer to the target buffer to fill.\r | |
81 | @param Length Number of bytes in Buffer to fill.\r | |
82 | @param Value Value with which to fill Length bytes of Buffer.\r | |
83 | \r | |
84 | @return Buffer\r | |
85 | \r | |
86 | **/\r | |
87 | VOID *\r | |
88 | EFIAPI\r | |
89 | SetMem16 (\r | |
90 | OUT VOID *Buffer,\r | |
91 | IN UINTN Length,\r | |
92 | IN UINT16 Value\r | |
93 | );\r | |
94 | \r | |
95 | /**\r | |
96 | Fills a target buffer with a 32-bit value, and returns the target buffer.\r | |
97 | \r | |
98 | This function fills Length bytes of Buffer with the 32-bit value specified by\r | |
99 | Value, and returns Buffer. Value is repeated every 32-bits in for Length\r | |
100 | bytes of Buffer.\r | |
101 | \r | |
102 | If Buffer is NULL and Length > 0, then ASSERT().\r | |
103 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
104 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
105 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
106 | \r | |
107 | @param Buffer Pointer to the target buffer to fill.\r | |
108 | @param Length Number of bytes in Buffer to fill.\r | |
109 | @param Value Value with which to fill Length bytes of Buffer.\r | |
110 | \r | |
111 | @return Buffer\r | |
112 | \r | |
113 | **/\r | |
114 | VOID *\r | |
115 | EFIAPI\r | |
116 | SetMem32 (\r | |
117 | OUT VOID *Buffer,\r | |
118 | IN UINTN Length,\r | |
119 | IN UINT32 Value\r | |
120 | );\r | |
121 | \r | |
122 | /**\r | |
123 | Fills a target buffer with a 64-bit value, and returns the target buffer.\r | |
124 | \r | |
125 | This function fills Length bytes of Buffer with the 64-bit value specified by\r | |
126 | Value, and returns Buffer. Value is repeated every 64-bits in for Length\r | |
127 | bytes of Buffer.\r | |
128 | \r | |
129 | If Buffer is NULL and Length > 0, then ASSERT().\r | |
130 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
131 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
132 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
133 | \r | |
134 | @param Buffer Pointer to the target buffer to fill.\r | |
135 | @param Length Number of bytes in Buffer to fill.\r | |
136 | @param Value Value with which to fill Length bytes of Buffer.\r | |
137 | \r | |
138 | @return Buffer\r | |
139 | \r | |
140 | **/\r | |
141 | VOID *\r | |
142 | EFIAPI\r | |
143 | SetMem64 (\r | |
144 | OUT VOID *Buffer,\r | |
145 | IN UINTN Length,\r | |
146 | IN UINT64 Value\r | |
147 | );\r | |
148 | \r | |
149 | /**\r | |
150 | Set Buffer to 0 for Size bytes.\r | |
151 | \r | |
152 | This function fills Length bytes of Buffer with zeros, and returns Buffer.\r | |
153 | \r | |
154 | If Buffer is NULL and Length > 0, then ASSERT().\r | |
155 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
156 | \r | |
157 | @param Buffer Memory to set.\r | |
158 | @param Size Number of bytes to set\r | |
159 | \r | |
160 | @return Buffer\r | |
161 | \r | |
162 | **/\r | |
163 | VOID *\r | |
164 | EFIAPI\r | |
165 | ZeroMem (\r | |
166 | OUT VOID *Buffer,\r | |
167 | IN UINTN Length\r | |
168 | );\r | |
169 | \r | |
170 | /**\r | |
171 | Compares two memory buffers of a given length.\r | |
172 | \r | |
173 | This function compares Length bytes of SourceBuffer to Length bytes of\r | |
174 | DestinationBuffer. If all Length bytes of the two buffers are identical, then\r | |
175 | 0 is returned. Otherwise, the value returned is the first mismatched byte in\r | |
176 | SourceBuffer subtracted from the first mismatched byte in DestinationBuffer.\r | |
177 | \r | |
178 | If DestinationBuffer is NULL and Length > 0, then ASSERT().\r | |
179 | If SourceBuffer is NULL and Length > 0, then ASSERT().\r | |
180 | If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then\r | |
181 | ASSERT().\r | |
182 | If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r | |
183 | \r | |
184 | @param DestinationBuffer First memory buffer\r | |
185 | @param SourceBuffer Second memory buffer\r | |
186 | @param Length Length of DestinationBuffer and SourceBuffer memory\r | |
187 | regions to compare\r | |
188 | \r | |
189 | @retval 0 if DestinationBuffer == SourceBuffer\r | |
190 | @retval Non-zero if DestinationBuffer != SourceBuffer\r | |
191 | \r | |
192 | **/\r | |
193 | INTN\r | |
194 | EFIAPI\r | |
195 | CompareMem (\r | |
196 | IN CONST VOID *DestinationBuffer,\r | |
197 | IN CONST VOID *SourceBuffer,\r | |
198 | IN UINTN Length\r | |
199 | );\r | |
200 | \r | |
201 | /**\r | |
202 | Scans a target buffer for an 8-bit value, and returns a pointer to the\r | |
203 | matching 8-bit value in the target buffer.\r | |
204 | \r | |
205 | This function searches target the buffer specified by Buffer and Length from\r | |
206 | the lowest address to the highest address for an 8-bit value that matches\r | |
207 | Value. If a match is found, then a pointer to the matching byte in the target\r | |
208 | buffer is returned. If no match is found, then NULL is returned. If Length is\r | |
209 | 0, then NULL is returned.\r | |
210 | \r | |
211 | If Buffer is NULL, then ASSERT().\r | |
212 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
213 | \r | |
214 | @param Buffer Pointer to the target buffer to scan.\r | |
215 | @param Length Number of bytes in Buffer to scan.\r | |
216 | @param Value Value to search for in the target buffer.\r | |
217 | \r | |
218 | @return Pointer to the first occurrence or NULL if not found.\r | |
219 | @retval NULL if Length == 0 or Value was not found.\r | |
220 | \r | |
221 | **/\r | |
222 | VOID *\r | |
223 | EFIAPI\r | |
224 | ScanMem8 (\r | |
225 | IN CONST VOID *Buffer,\r | |
226 | IN UINTN Length,\r | |
227 | IN UINT8 Value\r | |
228 | );\r | |
229 | \r | |
230 | /**\r | |
231 | Scans a target buffer for a 16-bit value, and returns a pointer to the\r | |
232 | matching 16-bit value in the target buffer.\r | |
233 | \r | |
234 | This function searches target the buffer specified by Buffer and Length from\r | |
235 | the lowest address to the highest address at 16-bit increments for a 16-bit\r | |
236 | value that matches Value. If a match is found, then a pointer to the matching\r | |
237 | value in the target buffer is returned. If no match is found, then NULL is\r | |
238 | returned. If Length is 0, then NULL is returned.\r | |
239 | \r | |
240 | If Buffer is NULL, then ASSERT().\r | |
241 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
242 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
243 | \r | |
244 | @param Buffer Pointer to the target buffer to scan.\r | |
245 | @param Length Number of bytes in Buffer to scan.\r | |
246 | @param Value Value to search for in the target buffer.\r | |
247 | \r | |
248 | @return Pointer to the first occurrence.\r | |
249 | @retval NULL if Length == 0 or Value was not found.\r | |
250 | \r | |
251 | **/\r | |
252 | VOID *\r | |
253 | EFIAPI\r | |
254 | ScanMem16 (\r | |
255 | IN CONST VOID *Buffer,\r | |
256 | IN UINTN Length,\r | |
257 | IN UINT16 Value\r | |
258 | );\r | |
259 | \r | |
260 | /**\r | |
261 | Scans a target buffer for a 32-bit value, and returns a pointer to the\r | |
262 | matching 32-bit value in the target buffer.\r | |
263 | \r | |
264 | This function searches target the buffer specified by Buffer and Length from\r | |
265 | the lowest address to the highest address at 32-bit increments for a 32-bit\r | |
266 | value that matches Value. If a match is found, then a pointer to the matching\r | |
267 | value in the target buffer is returned. If no match is found, then NULL is\r | |
268 | returned. If Length is 0, then NULL is returned.\r | |
269 | \r | |
270 | If Buffer is NULL, then ASSERT().\r | |
271 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
272 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
273 | \r | |
274 | @param Buffer Pointer to the target buffer to scan.\r | |
275 | @param Length Number of bytes in Buffer to scan.\r | |
276 | @param Value Value to search for in the target buffer.\r | |
277 | \r | |
278 | @return Pointer to the first occurrence or NULL if not found.\r | |
279 | @retval NULL if Length == 0 or Value was not found.\r | |
280 | \r | |
281 | **/\r | |
282 | VOID *\r | |
283 | EFIAPI\r | |
284 | ScanMem32 (\r | |
285 | IN CONST VOID *Buffer,\r | |
286 | IN UINTN Length,\r | |
287 | IN UINT32 Value\r | |
288 | );\r | |
289 | \r | |
290 | /**\r | |
291 | Scans a target buffer for a 64-bit value, and returns a pointer to the\r | |
292 | matching 64-bit value in the target buffer.\r | |
293 | \r | |
294 | This function searches target the buffer specified by Buffer and Length from\r | |
295 | the lowest address to the highest address at 64-bit increments for a 64-bit\r | |
296 | value that matches Value. If a match is found, then a pointer to the matching\r | |
297 | value in the target buffer is returned. If no match is found, then NULL is\r | |
298 | returned. If Length is 0, then NULL is returned.\r | |
299 | \r | |
300 | If Buffer is NULL, then ASSERT().\r | |
301 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
302 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
303 | \r | |
304 | @param Buffer Pointer to the target buffer to scan.\r | |
305 | @param Length Number of bytes in Buffer to scan.\r | |
306 | @param Value Value to search for in the target buffer.\r | |
307 | \r | |
308 | @return Pointer to the first occurrence or NULL if not found.\r | |
309 | @retval NULL if Length == 0 or Value was not found.\r | |
310 | \r | |
311 | **/\r | |
312 | VOID *\r | |
313 | EFIAPI\r | |
314 | ScanMem64 (\r | |
315 | IN CONST VOID *Buffer,\r | |
316 | IN UINTN Length,\r | |
317 | IN UINT64 Value\r | |
318 | );\r | |
319 | \r | |
320 | /**\r | |
321 | This function copies a source GUID to a destination GUID.\r | |
322 | \r | |
323 | This function copies the contents of the 128-bit GUID specified by SourceGuid\r | |
324 | to DestinationGuid, and returns DestinationGuid.\r | |
325 | \r | |
326 | If DestinationGuid is NULL, then ASSERT().\r | |
327 | If SourceGuid is NULL, then ASSERT().\r | |
328 | \r | |
329 | @param DestinationGuid Pointer to the destination GUID.\r | |
330 | @param SourceGuid Pointer to the source GUID.\r | |
331 | \r | |
332 | @return DestinationGuid\r | |
333 | \r | |
334 | **/\r | |
335 | GUID *\r | |
336 | EFIAPI\r | |
337 | CopyGuid (\r | |
338 | OUT GUID *DestinationGuid,\r | |
339 | IN CONST GUID *SourceGuid\r | |
340 | );\r | |
341 | \r | |
342 | /**\r | |
343 | Compares two GUIDs\r | |
344 | \r | |
345 | This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE\r | |
346 | is returned. If there are any bit differences in the two GUIDs, then FALSE is\r | |
347 | returned.\r | |
348 | \r | |
349 | If Guid1 is NULL, then ASSERT().\r | |
350 | If Guid2 is NULL, then ASSERT().\r | |
351 | \r | |
352 | @param Guid1 guid to compare\r | |
353 | @param Guid2 guid to compare\r | |
354 | \r | |
355 | @retval TRUE if Guid1 == Guid2\r | |
356 | @retval FALSE if Guid1 != Guid2\r | |
357 | \r | |
358 | **/\r | |
359 | BOOLEAN\r | |
360 | EFIAPI\r | |
361 | CompareGuid (\r | |
362 | IN CONST GUID *Guid1,\r | |
363 | IN CONST GUID *Guid2\r | |
364 | );\r | |
365 | \r | |
366 | /**\r | |
367 | Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r | |
368 | in the target buffer.\r | |
369 | \r | |
370 | This function searches target the buffer specified by Buffer and Length from\r | |
371 | the lowest address to the highest address at 128-bit increments for the\r | |
372 | 128-bit GUID value that matches Guid. If a match is found, then a pointer to\r | |
373 | the matching GUID in the target buffer is returned. If no match is found,\r | |
374 | then NULL is returned. If Length is 0, then NULL is returned.\r | |
375 | \r | |
376 | If Buffer is NULL, then ASSERT().\r | |
377 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
378 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
379 | \r | |
380 | @param Buffer Pointer to the target buffer to scan.\r | |
381 | @param Length Number of bytes in Buffer to scan.\r | |
382 | @param Guid Value to search for in the target buffer.\r | |
383 | \r | |
384 | @return Pointer to the first occurrence.\r | |
385 | @retval NULL if Length == 0 or Guid was not found.\r | |
386 | **/\r | |
387 | VOID *\r | |
388 | EFIAPI\r | |
389 | ScanGuid (\r | |
390 | IN CONST VOID *Buffer,\r | |
391 | IN UINTN Length,\r | |
392 | IN CONST GUID *Guid\r | |
393 | );\r | |
394 | \r | |
395 | #endif\r |