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