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