]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/BaseMemoryLib.h
2 Provides copy memory, fill memory, zero memory, and GUID functions.
4 The Base Memory Library provides optimized implementions for common memory-based operations.
5 These functions should be used in place of coding your own loops to do equivalent common functions.
6 This allows optimized library implementations to help increase performance.
8 Copyright (c) 2006 - 2008, Intel Corporation
9 All rights reserved. This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #ifndef __BASE_MEMORY_LIB__
20 #define __BASE_MEMORY_LIB__
23 Copies a source buffer to a destination buffer, and returns the destination buffer.
25 This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
26 DestinationBuffer. The implementation must be reentrant, and it must handle the case
27 where SourceBuffer overlaps DestinationBuffer.
28 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
29 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
31 @param DestinationBuffer Pointer to the destination buffer of the memory copy.
32 @param SourceBuffer Pointer to the source buffer of the memory copy.
33 @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer.
35 @return DestinationBuffer.
41 OUT VOID
*DestinationBuffer
,
42 IN CONST VOID
*SourceBuffer
,
47 Fills a target buffer with a byte value, and returns the target buffer.
49 This function fills Length bytes of Buffer with Value, and returns Buffer.
50 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
52 @param Buffer Memory to set.
53 @param Length Number of bytes to set.
54 @param Value Value with which to fill Length bytes of Buffer.
68 Fills a target buffer with a 16-bit value, and returns the target buffer.
70 This function fills Length bytes of Buffer with the 16-bit value specified by
71 Value, and returns Buffer. Value is repeated every 16-bits in for Length
74 If Length > 0 and Buffer is NULL, then ASSERT().
75 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
76 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
77 If Length is not aligned on a 16-bit boundary, then ASSERT().
79 @param Buffer Pointer to the target buffer to fill.
80 @param Length Number of bytes in Buffer to fill.
81 @param Value Value with which to fill Length bytes of Buffer.
95 Fills a target buffer with a 32-bit value, and returns the target buffer.
97 This function fills Length bytes of Buffer with the 32-bit value specified by
98 Value, and returns Buffer. Value is repeated every 32-bits in for Length
101 If Length > 0 and Buffer is NULL, then ASSERT().
102 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
103 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
104 If Length is not aligned on a 32-bit boundary, then ASSERT().
106 @param Buffer Pointer to the target buffer to fill.
107 @param Length Number of bytes in Buffer to fill.
108 @param Value Value with which to fill Length bytes of Buffer.
122 Fills a target buffer with a 64-bit value, and returns the target buffer.
124 This function fills Length bytes of Buffer with the 64-bit value specified by
125 Value, and returns Buffer. Value is repeated every 64-bits in for Length
128 If Length > 0 and Buffer is NULL, then ASSERT().
129 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
130 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
131 If Length is not aligned on a 64-bit boundary, then ASSERT().
133 @param Buffer Pointer to the target buffer to fill.
134 @param Length Number of bytes in Buffer to fill.
135 @param Value Value with which to fill Length bytes of Buffer.
149 Fills a target buffer with zeros, and returns the target buffer.
151 This function fills Length bytes of Buffer with zeros, and returns Buffer.
152 If Length > 0 and Buffer is NULL, then ASSERT().
153 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
155 @param Buffer Pointer to the target buffer to fill with zeros.
156 @param Length Number of bytes in Buffer to fill with zeros.
169 Compares the contents of two buffers.
171 This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
172 If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the
173 value returned is the first mismatched byte in SourceBuffer subtracted from the first
174 mismatched byte in DestinationBuffer.
175 If Length > 0 and DestinationBuffer is NULL, then ASSERT().
176 If Length > 0 and SourceBuffer is NULL, then ASSERT().
177 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
178 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
180 @param DestinationBuffer Pointer to the destination buffer to compare.
181 @param SourceBuffer Pointer to the source buffer to compare.
182 @param Length Number of bytes to compare.
184 @return 0 All Length bytes of the two buffers are identical.
185 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
186 mismatched byte in DestinationBuffer.
192 IN CONST VOID
*DestinationBuffer
,
193 IN CONST VOID
*SourceBuffer
,
198 Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value
199 in the target buffer.
201 This function searches target the buffer specified by Buffer and Length from the lowest
202 address to the highest address for an 8-bit value that matches Value. If a match is found,
203 then a pointer to the matching byte in the target buffer is returned. If no match is found,
204 then NULL is returned. If Length is 0, then NULL is returned.
205 If Length > 0 and Buffer is NULL, then ASSERT().
206 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
208 @param Buffer Pointer to the target buffer to scan.
209 @param Length Number of bytes in Buffer to scan.
210 @param Value Value to search for in the target buffer.
212 @return A pointer to the matching byte in the target buffer or NULL otherwise.
218 IN CONST VOID
*Buffer
,
224 Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value
225 in the target buffer.
227 This function searches target the buffer specified by Buffer and Length from the lowest
228 address to the highest address for a 16-bit value that matches Value. If a match is found,
229 then a pointer to the matching byte in the target buffer is returned. If no match is found,
230 then NULL is returned. If Length is 0, then NULL is returned.
231 If Length > 0 and Buffer is NULL, then ASSERT().
232 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
233 If Length is not aligned on a 16-bit boundary, then ASSERT().
234 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
236 @param Buffer Pointer to the target buffer to scan.
237 @param Length Number of bytes in Buffer to scan.
238 @param Value Value to search for in the target buffer.
240 @return A pointer to the matching byte in the target buffer or NULL otherwise.
246 IN CONST VOID
*Buffer
,
252 Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value
253 in the target buffer.
255 This function searches target the buffer specified by Buffer and Length from the lowest
256 address to the highest address for a 32-bit value that matches Value. If a match is found,
257 then a pointer to the matching byte in the target buffer is returned. If no match is found,
258 then NULL is returned. If Length is 0, then NULL is returned.
259 If Length > 0 and Buffer is NULL, then ASSERT().
260 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
261 If Length is not aligned on a 32-bit boundary, then ASSERT().
262 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
264 @param Buffer Pointer to the target buffer to scan.
265 @param Length Number of bytes in Buffer to scan.
266 @param Value Value to search for in the target buffer.
268 @return A pointer to the matching byte in the target buffer or NULL otherwise.
274 IN CONST VOID
*Buffer
,
280 Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
281 in the target buffer.
283 This function searches target the buffer specified by Buffer and Length from the lowest
284 address to the highest address for a 64-bit value that matches Value. If a match is found,
285 then a pointer to the matching byte in the target buffer is returned. If no match is found,
286 then NULL is returned. If Length is 0, then NULL is returned.
287 If Length > 0 and Buffer is NULL, then ASSERT().
288 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
289 If Length is not aligned on a 64-bit boundary, then ASSERT().
290 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
292 @param Buffer Pointer to the target buffer to scan.
293 @param Length Number of bytes in Buffer to scan.
294 @param Value Value to search for in the target buffer.
296 @return A pointer to the matching byte in the target buffer or NULL otherwise.
302 IN CONST VOID
*Buffer
,
308 Copies a source GUID to a destination GUID.
310 This function copies the contents of the 128-bit GUID specified by SourceGuid to
311 DestinationGuid, and returns DestinationGuid.
312 If DestinationGuid is NULL, then ASSERT().
313 If SourceGuid is NULL, then ASSERT().
315 @param DestinationGuid Pointer to the destination GUID.
316 @param SourceGuid Pointer to the source GUID.
318 @return DestinationGuid.
324 OUT GUID
*DestinationGuid
,
325 IN CONST GUID
*SourceGuid
331 This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.
332 If there are any bit differences in the two GUIDs, then FALSE is returned.
333 If Guid1 is NULL, then ASSERT().
334 If Guid2 is NULL, then ASSERT().
336 @param Guid1 A pointer to a 128 bit GUID.
337 @param Guid2 A pointer to a 128 bit GUID.
339 @retval TRUE Guid1 and Guid2 are identical.
340 @retval FALSE Guid1 and Guid2 are not identical.
346 IN CONST GUID
*Guid1
,
351 Scans a target buffer for a GUID, and returns a pointer to the matching GUID
352 in the target buffer.
354 This function searches target the buffer specified by Buffer and Length from
355 the lowest address to the highest address at 128-bit increments for the 128-bit
356 GUID value that matches Guid. If a match is found, then a pointer to the matching
357 GUID in the target buffer is returned. If no match is found, then NULL is returned.
358 If Length is 0, then NULL is returned.
359 If Length > 0 and Buffer is NULL, then ASSERT().
360 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
361 If Length is not aligned on a 128-bit boundary, then ASSERT().
362 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
364 @param Buffer Pointer to the target buffer to scan.
365 @param Length Number of bytes in Buffer to scan.
366 @param Guid Value to search for in the target buffer.
368 @return A pointer to the matching Guid in the target buffer or NULL otherwise.
374 IN CONST VOID
*Buffer
,