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