]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c
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 The following BaseMemoryLib instances share the same version of this file:
25 // Include common header file for this module.
27 #include "MemLibInternals.h"
30 Copies a source GUID to a destination GUID.
32 This function copies the contents of the 128-bit GUID specified by SourceGuid to
33 DestinationGuid, and returns DestinationGuid.
34 If DestinationGuid is NULL, then ASSERT().
35 If SourceGuid is NULL, then ASSERT().
37 @param DestinationGuid Pointer to the destination GUID.
38 @param SourceGuid Pointer to the source GUID.
40 @return DestinationGuid.
46 OUT GUID
*DestinationGuid
,
47 IN CONST GUID
*SourceGuid
51 (UINT64
*)DestinationGuid
,
52 ReadUnaligned64 ((CONST UINT64
*)SourceGuid
)
55 (UINT64
*)DestinationGuid
+ 1,
56 ReadUnaligned64 ((CONST UINT64
*)SourceGuid
+ 1)
58 return DestinationGuid
;
64 This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.
65 If there are any bit differences in the two GUIDs, then FALSE is returned.
66 If Guid1 is NULL, then ASSERT().
67 If Guid2 is NULL, then ASSERT().
69 @param Guid1 A pointer to a 128 bit GUID.
70 @param Guid2 A pointer to a 128 bit GUID.
72 @retval TRUE Guid1 and Guid2 are identical.
73 @retval FALSE Guid1 and Guid2 are not identical.
88 Guid1ValueLo
= ReadUnaligned64 ((CONST UINT64
*)Guid1
);
89 Guid2ValueLo
= ReadUnaligned64 ((CONST UINT64
*)Guid2
);
91 Guid1ValueHi
= ReadUnaligned64 ((CONST UINT64
*)Guid1
+ 1);
92 Guid2ValueHi
= ReadUnaligned64 ((CONST UINT64
*)Guid2
+ 1);
96 ((Guid1ValueLo
== Guid2ValueLo
) &&
97 (Guid1ValueHi
== Guid2ValueHi
)
102 Scans a target buffer for a GUID, and returns a pointer to the matching GUID
103 in the target buffer.
105 This function searches target the buffer specified by Buffer and Length from
106 the lowest address to the highest address at 128-bit increments for the 128-bit
107 GUID value that matches Guid. If a match is found, then a pointer to the matching
108 GUID in the target buffer is returned. If no match is found, then NULL is returned.
109 If Length is 0, then NULL is returned.
110 If Length > 0 and Buffer is NULL, then ASSERT().
111 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
112 If Length is not aligned on a 128-bit boundary, then ASSERT().
113 If Length is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
115 @param Buffer Pointer to the target buffer to scan.
116 @param Length Number of bytes in Buffer to scan.
117 @param Guid Value to search for in the target buffer.
119 @return A pointer to the matching Guid in the target buffer or NULL otherwise.
125 IN CONST VOID
*Buffer
,
132 ASSERT (((UINTN
)Buffer
& (sizeof (Guid
->Data1
) - 1)) == 0);
133 ASSERT (Length
<= (MAX_ADDRESS
- (UINTN
)Buffer
+ 1));
134 ASSERT ((Length
& (sizeof (*GuidPtr
) - 1)) == 0);
136 GuidPtr
= (GUID
*)Buffer
;
137 Buffer
= GuidPtr
+ Length
/ sizeof (*GuidPtr
);
138 while (GuidPtr
< (CONST GUID
*)Buffer
) {
139 if (CompareGuid (GuidPtr
, Guid
)) {
140 return (VOID
*)GuidPtr
;