xref: /freebsd-src/sys/contrib/edk2/Include/Library/BaseMemoryLib.h (revision 0d1ba6657e90b1f9b76e1c393b1555d6cf6cf260)
1*0d1ba665SWarner Losh /** @file
2*0d1ba665SWarner Losh   Provides copy memory, fill memory, zero memory, and GUID functions.
3*0d1ba665SWarner Losh 
4*0d1ba665SWarner Losh   The Base Memory Library provides optimized implementations for common memory-based operations.
5*0d1ba665SWarner Losh   These functions should be used in place of coding your own loops to do equivalent common functions.
6*0d1ba665SWarner Losh   This allows optimized library implementations to help increase performance.
7*0d1ba665SWarner Losh 
8*0d1ba665SWarner Losh Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
9*0d1ba665SWarner Losh This program and the accompanying materials are licensed and made available under
10*0d1ba665SWarner Losh the terms and conditions of the BSD License that accompanies this distribution.
11*0d1ba665SWarner Losh The full text of the license may be found at
12*0d1ba665SWarner Losh http://opensource.org/licenses/bsd-license.php.
13*0d1ba665SWarner Losh 
14*0d1ba665SWarner Losh THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15*0d1ba665SWarner Losh WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16*0d1ba665SWarner Losh 
17*0d1ba665SWarner Losh **/
18*0d1ba665SWarner Losh 
19*0d1ba665SWarner Losh #ifndef __BASE_MEMORY_LIB__
20*0d1ba665SWarner Losh #define __BASE_MEMORY_LIB__
21*0d1ba665SWarner Losh 
22*0d1ba665SWarner Losh /**
23*0d1ba665SWarner Losh   Copies a source buffer to a destination buffer, and returns the destination buffer.
24*0d1ba665SWarner Losh 
25*0d1ba665SWarner Losh   This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
26*0d1ba665SWarner Losh   DestinationBuffer.  The implementation must be reentrant, and it must handle the case
27*0d1ba665SWarner Losh   where SourceBuffer overlaps DestinationBuffer.
28*0d1ba665SWarner Losh 
29*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
30*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
31*0d1ba665SWarner Losh 
32*0d1ba665SWarner Losh   @param  DestinationBuffer   The pointer to the destination buffer of the memory copy.
33*0d1ba665SWarner Losh   @param  SourceBuffer        The pointer to the source buffer of the memory copy.
34*0d1ba665SWarner Losh   @param  Length              The number of bytes to copy from SourceBuffer to DestinationBuffer.
35*0d1ba665SWarner Losh 
36*0d1ba665SWarner Losh   @return DestinationBuffer.
37*0d1ba665SWarner Losh 
38*0d1ba665SWarner Losh **/
39*0d1ba665SWarner Losh VOID *
40*0d1ba665SWarner Losh EFIAPI
41*0d1ba665SWarner Losh CopyMem (
42*0d1ba665SWarner Losh   OUT VOID       *DestinationBuffer,
43*0d1ba665SWarner Losh   IN CONST VOID  *SourceBuffer,
44*0d1ba665SWarner Losh   IN UINTN       Length
45*0d1ba665SWarner Losh   );
46*0d1ba665SWarner Losh 
47*0d1ba665SWarner Losh /**
48*0d1ba665SWarner Losh   Fills a target buffer with a byte value, and returns the target buffer.
49*0d1ba665SWarner Losh 
50*0d1ba665SWarner Losh   This function fills Length bytes of Buffer with Value, and returns Buffer.
51*0d1ba665SWarner Losh 
52*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
53*0d1ba665SWarner Losh 
54*0d1ba665SWarner Losh   @param  Buffer    The memory to set.
55*0d1ba665SWarner Losh   @param  Length    The number of bytes to set.
56*0d1ba665SWarner Losh   @param  Value     The value with which to fill Length bytes of Buffer.
57*0d1ba665SWarner Losh 
58*0d1ba665SWarner Losh   @return Buffer.
59*0d1ba665SWarner Losh 
60*0d1ba665SWarner Losh **/
61*0d1ba665SWarner Losh VOID *
62*0d1ba665SWarner Losh EFIAPI
63*0d1ba665SWarner Losh SetMem (
64*0d1ba665SWarner Losh   OUT VOID  *Buffer,
65*0d1ba665SWarner Losh   IN UINTN  Length,
66*0d1ba665SWarner Losh   IN UINT8  Value
67*0d1ba665SWarner Losh   );
68*0d1ba665SWarner Losh 
69*0d1ba665SWarner Losh /**
70*0d1ba665SWarner Losh   Fills a target buffer with a 16-bit value, and returns the target buffer.
71*0d1ba665SWarner Losh 
72*0d1ba665SWarner Losh   This function fills Length bytes of Buffer with the 16-bit value specified by
73*0d1ba665SWarner Losh   Value, and returns Buffer. Value is repeated every 16-bits in for Length
74*0d1ba665SWarner Losh   bytes of Buffer.
75*0d1ba665SWarner Losh 
76*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
77*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
78*0d1ba665SWarner Losh   If Buffer is not aligned on a 16-bit boundary, then ASSERT().
79*0d1ba665SWarner Losh   If Length is not aligned on a 16-bit boundary, then ASSERT().
80*0d1ba665SWarner Losh 
81*0d1ba665SWarner Losh   @param  Buffer  The pointer to the target buffer to fill.
82*0d1ba665SWarner Losh   @param  Length  The number of bytes in Buffer to fill.
83*0d1ba665SWarner Losh   @param  Value   The value with which to fill Length bytes of Buffer.
84*0d1ba665SWarner Losh 
85*0d1ba665SWarner Losh   @return Buffer.
86*0d1ba665SWarner Losh 
87*0d1ba665SWarner Losh **/
88*0d1ba665SWarner Losh VOID *
89*0d1ba665SWarner Losh EFIAPI
90*0d1ba665SWarner Losh SetMem16 (
91*0d1ba665SWarner Losh   OUT VOID   *Buffer,
92*0d1ba665SWarner Losh   IN UINTN   Length,
93*0d1ba665SWarner Losh   IN UINT16  Value
94*0d1ba665SWarner Losh   );
95*0d1ba665SWarner Losh 
96*0d1ba665SWarner Losh /**
97*0d1ba665SWarner Losh   Fills a target buffer with a 32-bit value, and returns the target buffer.
98*0d1ba665SWarner Losh 
99*0d1ba665SWarner Losh   This function fills Length bytes of Buffer with the 32-bit value specified by
100*0d1ba665SWarner Losh   Value, and returns Buffer. Value is repeated every 32-bits in for Length
101*0d1ba665SWarner Losh   bytes of Buffer.
102*0d1ba665SWarner Losh 
103*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
104*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
105*0d1ba665SWarner Losh   If Buffer is not aligned on a 32-bit boundary, then ASSERT().
106*0d1ba665SWarner Losh   If Length is not aligned on a 32-bit boundary, then ASSERT().
107*0d1ba665SWarner Losh 
108*0d1ba665SWarner Losh   @param  Buffer  The pointer to the target buffer to fill.
109*0d1ba665SWarner Losh   @param  Length  The number of bytes in Buffer to fill.
110*0d1ba665SWarner Losh   @param  Value   The value with which to fill Length bytes of Buffer.
111*0d1ba665SWarner Losh 
112*0d1ba665SWarner Losh   @return Buffer.
113*0d1ba665SWarner Losh 
114*0d1ba665SWarner Losh **/
115*0d1ba665SWarner Losh VOID *
116*0d1ba665SWarner Losh EFIAPI
117*0d1ba665SWarner Losh SetMem32 (
118*0d1ba665SWarner Losh   OUT VOID   *Buffer,
119*0d1ba665SWarner Losh   IN UINTN   Length,
120*0d1ba665SWarner Losh   IN UINT32  Value
121*0d1ba665SWarner Losh   );
122*0d1ba665SWarner Losh 
123*0d1ba665SWarner Losh /**
124*0d1ba665SWarner Losh   Fills a target buffer with a 64-bit value, and returns the target buffer.
125*0d1ba665SWarner Losh 
126*0d1ba665SWarner Losh   This function fills Length bytes of Buffer with the 64-bit value specified by
127*0d1ba665SWarner Losh   Value, and returns Buffer. Value is repeated every 64-bits in for Length
128*0d1ba665SWarner Losh   bytes of Buffer.
129*0d1ba665SWarner Losh 
130*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
131*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
132*0d1ba665SWarner Losh   If Buffer is not aligned on a 64-bit boundary, then ASSERT().
133*0d1ba665SWarner Losh   If Length is not aligned on a 64-bit boundary, then ASSERT().
134*0d1ba665SWarner Losh 
135*0d1ba665SWarner Losh   @param  Buffer  The pointer to the target buffer to fill.
136*0d1ba665SWarner Losh   @param  Length  The number of bytes in Buffer to fill.
137*0d1ba665SWarner Losh   @param  Value   The value with which to fill Length bytes of Buffer.
138*0d1ba665SWarner Losh 
139*0d1ba665SWarner Losh   @return Buffer.
140*0d1ba665SWarner Losh 
141*0d1ba665SWarner Losh **/
142*0d1ba665SWarner Losh VOID *
143*0d1ba665SWarner Losh EFIAPI
144*0d1ba665SWarner Losh SetMem64 (
145*0d1ba665SWarner Losh   OUT VOID   *Buffer,
146*0d1ba665SWarner Losh   IN UINTN   Length,
147*0d1ba665SWarner Losh   IN UINT64  Value
148*0d1ba665SWarner Losh   );
149*0d1ba665SWarner Losh 
150*0d1ba665SWarner Losh /**
151*0d1ba665SWarner Losh   Fills a target buffer with a value that is size UINTN, and returns the target buffer.
152*0d1ba665SWarner Losh 
153*0d1ba665SWarner Losh   This function fills Length bytes of Buffer with the UINTN sized value specified by
154*0d1ba665SWarner Losh   Value, and returns Buffer. Value is repeated every sizeof(UINTN) bytes for Length
155*0d1ba665SWarner Losh   bytes of Buffer.
156*0d1ba665SWarner Losh 
157*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
158*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
159*0d1ba665SWarner Losh   If Buffer is not aligned on a UINTN boundary, then ASSERT().
160*0d1ba665SWarner Losh   If Length is not aligned on a UINTN boundary, then ASSERT().
161*0d1ba665SWarner Losh 
162*0d1ba665SWarner Losh   @param  Buffer  The pointer to the target buffer to fill.
163*0d1ba665SWarner Losh   @param  Length  The number of bytes in Buffer to fill.
164*0d1ba665SWarner Losh   @param  Value   The value with which to fill Length bytes of Buffer.
165*0d1ba665SWarner Losh 
166*0d1ba665SWarner Losh   @return Buffer.
167*0d1ba665SWarner Losh 
168*0d1ba665SWarner Losh **/
169*0d1ba665SWarner Losh VOID *
170*0d1ba665SWarner Losh EFIAPI
171*0d1ba665SWarner Losh SetMemN (
172*0d1ba665SWarner Losh   OUT VOID  *Buffer,
173*0d1ba665SWarner Losh   IN UINTN  Length,
174*0d1ba665SWarner Losh   IN UINTN  Value
175*0d1ba665SWarner Losh   );
176*0d1ba665SWarner Losh 
177*0d1ba665SWarner Losh /**
178*0d1ba665SWarner Losh   Fills a target buffer with zeros, and returns the target buffer.
179*0d1ba665SWarner Losh 
180*0d1ba665SWarner Losh   This function fills Length bytes of Buffer with zeros, and returns Buffer.
181*0d1ba665SWarner Losh 
182*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
183*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
184*0d1ba665SWarner Losh 
185*0d1ba665SWarner Losh   @param  Buffer      The pointer to the target buffer to fill with zeros.
186*0d1ba665SWarner Losh   @param  Length      The number of bytes in Buffer to fill with zeros.
187*0d1ba665SWarner Losh 
188*0d1ba665SWarner Losh   @return Buffer.
189*0d1ba665SWarner Losh 
190*0d1ba665SWarner Losh **/
191*0d1ba665SWarner Losh VOID *
192*0d1ba665SWarner Losh EFIAPI
193*0d1ba665SWarner Losh ZeroMem (
194*0d1ba665SWarner Losh   OUT VOID  *Buffer,
195*0d1ba665SWarner Losh   IN UINTN  Length
196*0d1ba665SWarner Losh   );
197*0d1ba665SWarner Losh 
198*0d1ba665SWarner Losh /**
199*0d1ba665SWarner Losh   Compares the contents of two buffers.
200*0d1ba665SWarner Losh 
201*0d1ba665SWarner Losh   This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
202*0d1ba665SWarner Losh   If all Length bytes of the two buffers are identical, then 0 is returned.  Otherwise, the
203*0d1ba665SWarner Losh   value returned is the first mismatched byte in SourceBuffer subtracted from the first
204*0d1ba665SWarner Losh   mismatched byte in DestinationBuffer.
205*0d1ba665SWarner Losh 
206*0d1ba665SWarner Losh   If Length > 0 and DestinationBuffer is NULL, then ASSERT().
207*0d1ba665SWarner Losh   If Length > 0 and SourceBuffer is NULL, then ASSERT().
208*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
209*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
210*0d1ba665SWarner Losh 
211*0d1ba665SWarner Losh   @param  DestinationBuffer The pointer to the destination buffer to compare.
212*0d1ba665SWarner Losh   @param  SourceBuffer      The pointer to the source buffer to compare.
213*0d1ba665SWarner Losh   @param  Length            The number of bytes to compare.
214*0d1ba665SWarner Losh 
215*0d1ba665SWarner Losh   @return 0                 All Length bytes of the two buffers are identical.
216*0d1ba665SWarner Losh   @retval Non-zero          The first mismatched byte in SourceBuffer subtracted from the first
217*0d1ba665SWarner Losh                             mismatched byte in DestinationBuffer.
218*0d1ba665SWarner Losh 
219*0d1ba665SWarner Losh **/
220*0d1ba665SWarner Losh INTN
221*0d1ba665SWarner Losh EFIAPI
222*0d1ba665SWarner Losh CompareMem (
223*0d1ba665SWarner Losh   IN CONST VOID  *DestinationBuffer,
224*0d1ba665SWarner Losh   IN CONST VOID  *SourceBuffer,
225*0d1ba665SWarner Losh   IN UINTN       Length
226*0d1ba665SWarner Losh   );
227*0d1ba665SWarner Losh 
228*0d1ba665SWarner Losh /**
229*0d1ba665SWarner Losh   Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value
230*0d1ba665SWarner Losh   in the target buffer.
231*0d1ba665SWarner Losh 
232*0d1ba665SWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
233*0d1ba665SWarner Losh   address to the highest address for an 8-bit value that matches Value.  If a match is found,
234*0d1ba665SWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
235*0d1ba665SWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
236*0d1ba665SWarner Losh 
237*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
238*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
239*0d1ba665SWarner Losh 
240*0d1ba665SWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
241*0d1ba665SWarner Losh   @param  Length      The number of bytes in Buffer to scan.
242*0d1ba665SWarner Losh   @param  Value       The value to search for in the target buffer.
243*0d1ba665SWarner Losh 
244*0d1ba665SWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
245*0d1ba665SWarner Losh 
246*0d1ba665SWarner Losh **/
247*0d1ba665SWarner Losh VOID *
248*0d1ba665SWarner Losh EFIAPI
249*0d1ba665SWarner Losh ScanMem8 (
250*0d1ba665SWarner Losh   IN CONST VOID  *Buffer,
251*0d1ba665SWarner Losh   IN UINTN       Length,
252*0d1ba665SWarner Losh   IN UINT8       Value
253*0d1ba665SWarner Losh   );
254*0d1ba665SWarner Losh 
255*0d1ba665SWarner Losh /**
256*0d1ba665SWarner Losh   Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value
257*0d1ba665SWarner Losh   in the target buffer.
258*0d1ba665SWarner Losh 
259*0d1ba665SWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
260*0d1ba665SWarner Losh   address to the highest address for a 16-bit value that matches Value.  If a match is found,
261*0d1ba665SWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
262*0d1ba665SWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
263*0d1ba665SWarner Losh 
264*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
265*0d1ba665SWarner Losh   If Buffer is not aligned on a 16-bit boundary, then ASSERT().
266*0d1ba665SWarner Losh   If Length is not aligned on a 16-bit boundary, then ASSERT().
267*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
268*0d1ba665SWarner Losh 
269*0d1ba665SWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
270*0d1ba665SWarner Losh   @param  Length      The number of bytes in Buffer to scan.
271*0d1ba665SWarner Losh   @param  Value       The value to search for in the target buffer.
272*0d1ba665SWarner Losh 
273*0d1ba665SWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
274*0d1ba665SWarner Losh 
275*0d1ba665SWarner Losh **/
276*0d1ba665SWarner Losh VOID *
277*0d1ba665SWarner Losh EFIAPI
278*0d1ba665SWarner Losh ScanMem16 (
279*0d1ba665SWarner Losh   IN CONST VOID  *Buffer,
280*0d1ba665SWarner Losh   IN UINTN       Length,
281*0d1ba665SWarner Losh   IN UINT16      Value
282*0d1ba665SWarner Losh   );
283*0d1ba665SWarner Losh 
284*0d1ba665SWarner Losh /**
285*0d1ba665SWarner Losh   Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value
286*0d1ba665SWarner Losh   in the target buffer.
287*0d1ba665SWarner Losh 
288*0d1ba665SWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
289*0d1ba665SWarner Losh   address to the highest address for a 32-bit value that matches Value.  If a match is found,
290*0d1ba665SWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
291*0d1ba665SWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
292*0d1ba665SWarner Losh 
293*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
294*0d1ba665SWarner Losh   If Buffer is not aligned on a 32-bit boundary, then ASSERT().
295*0d1ba665SWarner Losh   If Length is not aligned on a 32-bit boundary, then ASSERT().
296*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
297*0d1ba665SWarner Losh 
298*0d1ba665SWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
299*0d1ba665SWarner Losh   @param  Length      The number of bytes in Buffer to scan.
300*0d1ba665SWarner Losh   @param  Value       The value to search for in the target buffer.
301*0d1ba665SWarner Losh 
302*0d1ba665SWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
303*0d1ba665SWarner Losh 
304*0d1ba665SWarner Losh **/
305*0d1ba665SWarner Losh VOID *
306*0d1ba665SWarner Losh EFIAPI
307*0d1ba665SWarner Losh ScanMem32 (
308*0d1ba665SWarner Losh   IN CONST VOID  *Buffer,
309*0d1ba665SWarner Losh   IN UINTN       Length,
310*0d1ba665SWarner Losh   IN UINT32      Value
311*0d1ba665SWarner Losh   );
312*0d1ba665SWarner Losh 
313*0d1ba665SWarner Losh /**
314*0d1ba665SWarner Losh   Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
315*0d1ba665SWarner Losh   in the target buffer.
316*0d1ba665SWarner Losh 
317*0d1ba665SWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
318*0d1ba665SWarner Losh   address to the highest address for a 64-bit value that matches Value.  If a match is found,
319*0d1ba665SWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
320*0d1ba665SWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
321*0d1ba665SWarner Losh 
322*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
323*0d1ba665SWarner Losh   If Buffer is not aligned on a 64-bit boundary, then ASSERT().
324*0d1ba665SWarner Losh   If Length is not aligned on a 64-bit boundary, then ASSERT().
325*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
326*0d1ba665SWarner Losh 
327*0d1ba665SWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
328*0d1ba665SWarner Losh   @param  Length      The number of bytes in Buffer to scan.
329*0d1ba665SWarner Losh   @param  Value       The value to search for in the target buffer.
330*0d1ba665SWarner Losh 
331*0d1ba665SWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
332*0d1ba665SWarner Losh 
333*0d1ba665SWarner Losh **/
334*0d1ba665SWarner Losh VOID *
335*0d1ba665SWarner Losh EFIAPI
336*0d1ba665SWarner Losh ScanMem64 (
337*0d1ba665SWarner Losh   IN CONST VOID  *Buffer,
338*0d1ba665SWarner Losh   IN UINTN       Length,
339*0d1ba665SWarner Losh   IN UINT64      Value
340*0d1ba665SWarner Losh   );
341*0d1ba665SWarner Losh 
342*0d1ba665SWarner Losh /**
343*0d1ba665SWarner Losh   Scans a target buffer for a UINTN sized value, and returns a pointer to the matching
344*0d1ba665SWarner Losh   UINTN sized value in the target buffer.
345*0d1ba665SWarner Losh 
346*0d1ba665SWarner Losh   This function searches target the buffer specified by Buffer and Length from the lowest
347*0d1ba665SWarner Losh   address to the highest address for a UINTN sized value that matches Value.  If a match is found,
348*0d1ba665SWarner Losh   then a pointer to the matching byte in the target buffer is returned.  If no match is found,
349*0d1ba665SWarner Losh   then NULL is returned.  If Length is 0, then NULL is returned.
350*0d1ba665SWarner Losh 
351*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
352*0d1ba665SWarner Losh   If Buffer is not aligned on a UINTN boundary, then ASSERT().
353*0d1ba665SWarner Losh   If Length is not aligned on a UINTN boundary, then ASSERT().
354*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
355*0d1ba665SWarner Losh 
356*0d1ba665SWarner Losh   @param  Buffer      The pointer to the target buffer to scan.
357*0d1ba665SWarner Losh   @param  Length      The number of bytes in Buffer to scan.
358*0d1ba665SWarner Losh   @param  Value       The value to search for in the target buffer.
359*0d1ba665SWarner Losh 
360*0d1ba665SWarner Losh   @return A pointer to the matching byte in the target buffer, otherwise NULL.
361*0d1ba665SWarner Losh 
362*0d1ba665SWarner Losh **/
363*0d1ba665SWarner Losh VOID *
364*0d1ba665SWarner Losh EFIAPI
365*0d1ba665SWarner Losh ScanMemN (
366*0d1ba665SWarner Losh   IN CONST VOID  *Buffer,
367*0d1ba665SWarner Losh   IN UINTN       Length,
368*0d1ba665SWarner Losh   IN UINTN       Value
369*0d1ba665SWarner Losh   );
370*0d1ba665SWarner Losh 
371*0d1ba665SWarner Losh /**
372*0d1ba665SWarner Losh   Copies a source GUID to a destination GUID.
373*0d1ba665SWarner Losh 
374*0d1ba665SWarner Losh   This function copies the contents of the 128-bit GUID specified by SourceGuid to
375*0d1ba665SWarner Losh   DestinationGuid, and returns DestinationGuid.
376*0d1ba665SWarner Losh 
377*0d1ba665SWarner Losh   If DestinationGuid is NULL, then ASSERT().
378*0d1ba665SWarner Losh   If SourceGuid is NULL, then ASSERT().
379*0d1ba665SWarner Losh 
380*0d1ba665SWarner Losh   @param  DestinationGuid   The pointer to the destination GUID.
381*0d1ba665SWarner Losh   @param  SourceGuid        The pointer to the source GUID.
382*0d1ba665SWarner Losh 
383*0d1ba665SWarner Losh   @return DestinationGuid.
384*0d1ba665SWarner Losh 
385*0d1ba665SWarner Losh **/
386*0d1ba665SWarner Losh GUID *
387*0d1ba665SWarner Losh EFIAPI
388*0d1ba665SWarner Losh CopyGuid (
389*0d1ba665SWarner Losh   OUT GUID       *DestinationGuid,
390*0d1ba665SWarner Losh   IN CONST GUID  *SourceGuid
391*0d1ba665SWarner Losh   );
392*0d1ba665SWarner Losh 
393*0d1ba665SWarner Losh /**
394*0d1ba665SWarner Losh   Compares two GUIDs.
395*0d1ba665SWarner Losh 
396*0d1ba665SWarner Losh   This function compares Guid1 to Guid2.  If the GUIDs are identical then TRUE is returned.
397*0d1ba665SWarner Losh   If there are any bit differences in the two GUIDs, then FALSE is returned.
398*0d1ba665SWarner Losh 
399*0d1ba665SWarner Losh   If Guid1 is NULL, then ASSERT().
400*0d1ba665SWarner Losh   If Guid2 is NULL, then ASSERT().
401*0d1ba665SWarner Losh 
402*0d1ba665SWarner Losh   @param  Guid1       A pointer to a 128 bit GUID.
403*0d1ba665SWarner Losh   @param  Guid2       A pointer to a 128 bit GUID.
404*0d1ba665SWarner Losh 
405*0d1ba665SWarner Losh   @retval TRUE        Guid1 and Guid2 are identical.
406*0d1ba665SWarner Losh   @retval FALSE       Guid1 and Guid2 are not identical.
407*0d1ba665SWarner Losh 
408*0d1ba665SWarner Losh **/
409*0d1ba665SWarner Losh BOOLEAN
410*0d1ba665SWarner Losh EFIAPI
411*0d1ba665SWarner Losh CompareGuid (
412*0d1ba665SWarner Losh   IN CONST GUID  *Guid1,
413*0d1ba665SWarner Losh   IN CONST GUID  *Guid2
414*0d1ba665SWarner Losh   );
415*0d1ba665SWarner Losh 
416*0d1ba665SWarner Losh /**
417*0d1ba665SWarner Losh   Scans a target buffer for a GUID, and returns a pointer to the matching GUID
418*0d1ba665SWarner Losh   in the target buffer.
419*0d1ba665SWarner Losh 
420*0d1ba665SWarner Losh   This function searches target the buffer specified by Buffer and Length from
421*0d1ba665SWarner Losh   the lowest address to the highest address at 128-bit increments for the 128-bit
422*0d1ba665SWarner Losh   GUID value that matches Guid.  If a match is found, then a pointer to the matching
423*0d1ba665SWarner Losh   GUID in the target buffer is returned.  If no match is found, then NULL is returned.
424*0d1ba665SWarner Losh   If Length is 0, then NULL is returned.
425*0d1ba665SWarner Losh 
426*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
427*0d1ba665SWarner Losh   If Buffer is not aligned on a 32-bit boundary, then ASSERT().
428*0d1ba665SWarner Losh   If Length is not aligned on a 128-bit boundary, then ASSERT().
429*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
430*0d1ba665SWarner Losh 
431*0d1ba665SWarner Losh   @param  Buffer  The pointer to the target buffer to scan.
432*0d1ba665SWarner Losh   @param  Length  The number of bytes in Buffer to scan.
433*0d1ba665SWarner Losh   @param  Guid    The value to search for in the target buffer.
434*0d1ba665SWarner Losh 
435*0d1ba665SWarner Losh   @return A pointer to the matching Guid in the target buffer, otherwise NULL.
436*0d1ba665SWarner Losh 
437*0d1ba665SWarner Losh **/
438*0d1ba665SWarner Losh VOID *
439*0d1ba665SWarner Losh EFIAPI
440*0d1ba665SWarner Losh ScanGuid (
441*0d1ba665SWarner Losh   IN CONST VOID  *Buffer,
442*0d1ba665SWarner Losh   IN UINTN       Length,
443*0d1ba665SWarner Losh   IN CONST GUID  *Guid
444*0d1ba665SWarner Losh   );
445*0d1ba665SWarner Losh 
446*0d1ba665SWarner Losh /**
447*0d1ba665SWarner Losh   Checks if the given GUID is a zero GUID.
448*0d1ba665SWarner Losh 
449*0d1ba665SWarner Losh   This function checks whether the given GUID is a zero GUID. If the GUID is
450*0d1ba665SWarner Losh   identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned.
451*0d1ba665SWarner Losh 
452*0d1ba665SWarner Losh   If Guid is NULL, then ASSERT().
453*0d1ba665SWarner Losh 
454*0d1ba665SWarner Losh   @param  Guid        The pointer to a 128 bit GUID.
455*0d1ba665SWarner Losh 
456*0d1ba665SWarner Losh   @retval TRUE        Guid is a zero GUID.
457*0d1ba665SWarner Losh   @retval FALSE       Guid is not a zero GUID.
458*0d1ba665SWarner Losh 
459*0d1ba665SWarner Losh **/
460*0d1ba665SWarner Losh BOOLEAN
461*0d1ba665SWarner Losh EFIAPI
462*0d1ba665SWarner Losh IsZeroGuid (
463*0d1ba665SWarner Losh   IN CONST GUID  *Guid
464*0d1ba665SWarner Losh   );
465*0d1ba665SWarner Losh 
466*0d1ba665SWarner Losh /**
467*0d1ba665SWarner Losh   Checks if the contents of a buffer are all zeros.
468*0d1ba665SWarner Losh 
469*0d1ba665SWarner Losh   This function checks whether the contents of a buffer are all zeros. If the
470*0d1ba665SWarner Losh   contents are all zeros, return TRUE. Otherwise, return FALSE.
471*0d1ba665SWarner Losh 
472*0d1ba665SWarner Losh   If Length > 0 and Buffer is NULL, then ASSERT().
473*0d1ba665SWarner Losh   If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
474*0d1ba665SWarner Losh 
475*0d1ba665SWarner Losh   @param  Buffer      The pointer to the buffer to be checked.
476*0d1ba665SWarner Losh   @param  Length      The size of the buffer (in bytes) to be checked.
477*0d1ba665SWarner Losh 
478*0d1ba665SWarner Losh   @retval TRUE        Contents of the buffer are all zeros.
479*0d1ba665SWarner Losh   @retval FALSE       Contents of the buffer are not all zeros.
480*0d1ba665SWarner Losh 
481*0d1ba665SWarner Losh **/
482*0d1ba665SWarner Losh BOOLEAN
483*0d1ba665SWarner Losh EFIAPI
484*0d1ba665SWarner Losh IsZeroBuffer (
485*0d1ba665SWarner Losh   IN CONST VOID  *Buffer,
486*0d1ba665SWarner Losh   IN UINTN       Length
487*0d1ba665SWarner Losh   );
488*0d1ba665SWarner Losh 
489*0d1ba665SWarner Losh #endif
490