]>
git.proxmox.com Git - mirror_edk2.git/blob - OldMdePkg/Include/Library/BaseMemoryLib.h
2 Memory-only library functions with no library constructor/destructor
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: BaseMemoryLib.h
17 #ifndef __BASE_MEMORY_LIB__
18 #define __BASE_MEMORY_LIB__
21 Copies a source buffer to a destination buffer, and returns the destination buffer.
23 This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
24 DestinationBuffer. The implementation must be reentrant, and it must handle the case
25 where SourceBuffer overlaps DestinationBuffer.
26 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
27 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
29 @param DestinationBuffer Pointer to the destination buffer of the memory copy.
30 @param SourceBuffer Pointer to the source buffer of the memory copy.
31 @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer.
33 @return DestinationBuffer.
39 OUT VOID
*DestinationBuffer
,
40 IN CONST VOID
*SourceBuffer
,
45 Fills a target buffer with a byte value, and returns the target buffer.
47 This function fills Length bytes of Buffer with Value, and returns Buffer.
48 If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
50 @param Buffer Memory to set.
51 @param Length Number of bytes to set.
52 @param Value Value of the set operation.
66 Fills a target buffer with a 16-bit value, and returns the target buffer.
68 This function fills Length bytes of Buffer with the 16-bit value specified by
69 Value, and returns Buffer. Value is repeated every 16-bits in for Length
72 If Length > 0 and Buffer is NULL, then ASSERT().
73 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
74 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
75 If Length is not aligned on a 16-bit boundary, then ASSERT().
77 @param Buffer Pointer to the target buffer to fill.
78 @param Length Number of bytes in Buffer to fill.
79 @param Value Value with which to fill Length bytes of Buffer.
93 Fills a target buffer with a 32-bit value, and returns the target buffer.
95 This function fills Length bytes of Buffer with the 32-bit value specified by
96 Value, and returns Buffer. Value is repeated every 32-bits in for Length
99 If Length > 0 and Buffer is NULL, then ASSERT().
100 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
101 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
102 If Length is not aligned on a 32-bit boundary, then ASSERT().
104 @param Buffer Pointer to the target buffer to fill.
105 @param Length Number of bytes in Buffer to fill.
106 @param Value Value with which to fill Length bytes of Buffer.
120 Fills a target buffer with a 64-bit value, and returns the target buffer.
122 This function fills Length bytes of Buffer with the 64-bit value specified by
123 Value, and returns Buffer. Value is repeated every 64-bits in for Length
126 If Length > 0 and Buffer is NULL, then ASSERT().
127 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
128 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
129 If Length is not aligned on a 64-bit boundary, then ASSERT().
131 @param Buffer Pointer to the target buffer to fill.
132 @param Length Number of bytes in Buffer to fill.
133 @param Value Value with which to fill Length bytes of Buffer.
147 Fills a target buffer with zeros, and returns the target buffer.
149 This function fills Length bytes of Buffer with zeros, and returns Buffer.
150 If Length > 0 and Buffer is NULL, then ASSERT().
151 If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
153 @param Buffer Pointer to the target buffer to fill with zeros.
154 @param Length Number of bytes in Buffer to fill with zeros.
167 Compares the contents of two buffers.
169 This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
170 If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the
171 value returned is the first mismatched byte in SourceBuffer subtracted from the first
172 mismatched byte in DestinationBuffer.
173 If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().
174 If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT().
175 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
176 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
178 @param DestinationBuffer Pointer to the destination buffer to compare.
179 @param SourceBuffer Pointer to the source buffer to compare.
180 @param Length Number of bytes to compare.
182 @return 0 All Length bytes of the two buffers are identical.
183 @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
184 mismatched byte in DestinationBuffer.
190 IN CONST VOID
*DestinationBuffer
,
191 IN CONST VOID
*SourceBuffer
,
196 Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value
197 in the target buffer.
199 This function searches target the buffer specified by Buffer and Length from the lowest
200 address to the highest address for an 8-bit value that matches Value. If a match is found,
201 then a pointer to the matching byte in the target buffer is returned. If no match is found,
202 then NULL is returned. If Length is 0, then NULL is returned.
203 If Length > 0 and Buffer is NULL, then ASSERT().
204 If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
206 @param Buffer Pointer to the target buffer to scan.
207 @param Length Number of bytes in Buffer to scan.
208 @param Value Value to search for in the target buffer.
210 @return A pointer to the matching byte in the target buffer or NULL otherwise.
216 IN CONST VOID
*Buffer
,
222 Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value
223 in the target buffer.
225 This function searches target the buffer specified by Buffer and Length from the lowest
226 address to the highest address for a 16-bit value that matches Value. If a match is found,
227 then a pointer to the matching byte in the target buffer is returned. If no match is found,
228 then NULL is returned. If Length is 0, then NULL is returned.
229 If Length > 0 and Buffer is NULL, then ASSERT().
230 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
231 If Length is not aligned on a 16-bit boundary, then ASSERT().
232 If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
234 @param Buffer Pointer to the target buffer to scan.
235 @param Length Number of bytes in Buffer to scan.
236 @param Value Value to search for in the target buffer.
238 @return A pointer to the matching byte in the target buffer or NULL otherwise.
244 IN CONST VOID
*Buffer
,
250 Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value
251 in the target buffer.
253 This function searches target the buffer specified by Buffer and Length from the lowest
254 address to the highest address for a 32-bit value that matches Value. If a match is found,
255 then a pointer to the matching byte in the target buffer is returned. If no match is found,
256 then NULL is returned. If Length is 0, then NULL is returned.
257 If Length > 0 and Buffer is NULL, then ASSERT().
258 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
259 If Length is not aligned on a 32-bit boundary, then ASSERT().
260 If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
262 @param Buffer Pointer to the target buffer to scan.
263 @param Length Number of bytes in Buffer to scan.
264 @param Value Value to search for in the target buffer.
266 @return A pointer to the matching byte in the target buffer or NULL otherwise.
272 IN CONST VOID
*Buffer
,
278 Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
279 in the target buffer.
281 This function searches target the buffer specified by Buffer and Length from the lowest
282 address to the highest address for a 64-bit value that matches Value. If a match is found,
283 then a pointer to the matching byte in the target buffer is returned. If no match is found,
284 then NULL is returned. If Length is 0, then NULL is returned.
285 If Length > 0 and Buffer is NULL, then ASSERT().
286 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
287 If Length is not aligned on a 64-bit boundary, then ASSERT().
288 If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
290 @param Buffer Pointer to the target buffer to scan.
291 @param Length Number of bytes in Buffer to scan.
292 @param Value Value to search for in the target buffer.
294 @return A pointer to the matching byte in the target buffer or NULL otherwise.
300 IN CONST VOID
*Buffer
,
306 Copies a source GUID to a destination GUID.
308 This function copies the contents of the 128-bit GUID specified by SourceGuid to
309 DestinationGuid, and returns DestinationGuid.
310 If DestinationGuid is NULL, then ASSERT().
311 If SourceGuid is NULL, then ASSERT().
313 @param DestinationGuid Pointer to the destination GUID.
314 @param SourceGuid Pointer to the source GUID.
316 @return DestinationGuid.
322 OUT GUID
*DestinationGuid
,
323 IN CONST GUID
*SourceGuid
329 This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.
330 If there are any bit differences in the two GUIDs, then FALSE is returned.
331 If Guid1 is NULL, then ASSERT().
332 If Guid2 is NULL, then ASSERT().
334 @param Guid1 A pointer to a 128 bit GUID.
335 @param Guid2 A pointer to a 128 bit GUID.
337 @retval TRUE Guid1 and Guid2 are identical.
338 @retval FALSE Guid1 and Guid2 are not identical.
344 IN CONST GUID
*Guid1
,
349 Scans a target buffer for a GUID, and returns a pointer to the matching GUID
350 in the target buffer.
352 This function searches target the buffer specified by Buffer and Length from
353 the lowest address to the highest address at 128-bit increments for the 128-bit
354 GUID value that matches Guid. If a match is found, then a pointer to the matching
355 GUID in the target buffer is returned. If no match is found, then NULL is returned.
356 If Length is 0, then NULL is returned.
357 If Length > 0 and Buffer is NULL, then ASSERT().
358 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
359 If Length is not aligned on a 128-bit boundary, then ASSERT().
360 If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
362 @param Buffer Pointer to the target buffer to scan.
363 @param Length Number of bytes in Buffer to scan.
364 @param Guid Value to search for in the target buffer.
366 @return A pointer to the matching Guid in the target buffer or NULL otherwise.
372 IN CONST VOID
*Buffer
,