2 Implementation of GUID functions.
4 Copyright (c) 2006, Intel Corporation<BR>
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: MemLibGuid.c
15 The following BaseMemoryLib instances share the same version of this file:
27 This function copies a source GUID to a destination GUID.
29 This function copies the contents of the 128-bit GUID specified by SourceGuid
30 to DestinationGuid, and returns DestinationGuid.
32 If DestinationGuid is NULL, then ASSERT().
33 If SourceGuid is NULL, then ASSERT().
35 @param DestinationGuid Pointer to the destination GUID.
36 @param SourceGuid Pointer to the source GUID.
38 @return DestinationGuid
44 OUT GUID
*DestinationGuid
,
45 IN CONST GUID
*SourceGuid
49 (UINT64
*)DestinationGuid
,
50 ReadUnaligned64 ((CONST UINT64
*)SourceGuid
)
53 (UINT64
*)DestinationGuid
+ 1,
54 ReadUnaligned64 ((CONST UINT64
*)SourceGuid
+ 1)
56 return DestinationGuid
;
62 This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE
63 is returned. If there are any bit differences in the two GUIDs, then FALSE is
66 If Guid1 is NULL, then ASSERT().
67 If Guid2 is NULL, then ASSERT().
69 @param Guid1 guid to compare
70 @param Guid2 guid to compare
72 @retval TRUE if Guid1 == Guid2
73 @retval FALSE if Guid1 != Guid2
84 ReadUnaligned64 ((CONST UINT64
*)Guid1
)
85 == ReadUnaligned64 ((CONST UINT64
*)Guid2
) &&
86 ReadUnaligned64 ((CONST UINT64
*)Guid1
+ 1)
87 == ReadUnaligned64 ((CONST UINT64
*)Guid2
+ 1)
92 Scans a target buffer for a GUID, and returns a pointer to the matching GUID
95 This function searches target the buffer specified by Buffer and Length from
96 the lowest address to the highest address at 128-bit increments for the
97 128-bit GUID value that matches Guid. If a match is found, then a pointer to
98 the matching GUID in the target buffer is returned. If no match is found,
99 then NULL is returned. If Length is 0, then NULL is returned.
101 If Buffer is NULL, then ASSERT().
102 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
103 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
105 @param Buffer Pointer to the target buffer to scan.
106 @param Length Number of bytes in Buffer to scan.
107 @param Guid Value to search for in the target buffer.
109 @return Pointer to the first occurrence.
110 @retval NULL if Length == 0 or Guid was not found.
115 IN CONST VOID
*Buffer
,
122 GuidPtr
= (GUID
*)Buffer
;
123 Buffer
= GuidPtr
+ Length
/ sizeof (*GuidPtr
);
124 while (GuidPtr
< (CONST GUID
*)Buffer
) {
125 if (CompareGuid (GuidPtr
, Guid
)) {
126 return (VOID
*)GuidPtr
;