]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptDxe/Arm/MemLibGuid.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLibOptDxe / Arm / MemLibGuid.c
CommitLineData
217b3ac0
AB
1/** @file\r
2 Implementation of GUID functions for ARM and AARCH64\r
3\r
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
5 Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
9344f092 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
217b3ac0
AB
7\r
8**/\r
9\r
10#include "MemLibInternals.h"\r
11\r
8e947c07
LG
12/**\r
13 Internal function to compare two GUIDs.\r
14\r
15 This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.\r
16 If there are any bit differences in the two GUIDs, then FALSE is returned.\r
17\r
18 @param Guid1 A pointer to a 128 bit GUID.\r
19 @param Guid2 A pointer to a 128 bit GUID.\r
20\r
21 @retval TRUE Guid1 and Guid2 are identical.\r
22 @retval FALSE Guid1 and Guid2 are not identical.\r
23\r
24**/\r
217b3ac0
AB
25BOOLEAN\r
26EFIAPI\r
27InternalMemCompareGuid (\r
28 IN CONST GUID *Guid1,\r
29 IN CONST GUID *Guid2\r
30 );\r
31\r
32/**\r
33 Copies a source GUID to a destination GUID.\r
34\r
35 This function copies the contents of the 128-bit GUID specified by SourceGuid to\r
36 DestinationGuid, and returns DestinationGuid.\r
37\r
38 If DestinationGuid is NULL, then ASSERT().\r
39 If SourceGuid is NULL, then ASSERT().\r
40\r
41 @param DestinationGuid The pointer to the destination GUID.\r
42 @param SourceGuid The pointer to the source GUID.\r
43\r
44 @return DestinationGuid.\r
45\r
46**/\r
47GUID *\r
48EFIAPI\r
49CopyGuid (\r
50 OUT GUID *DestinationGuid,\r
51 IN CONST GUID *SourceGuid\r
52 )\r
53{\r
54 ASSERT (DestinationGuid != NULL);\r
55 ASSERT (SourceGuid != NULL);\r
56\r
57 return InternalMemCopyMem (DestinationGuid, SourceGuid, sizeof (GUID));\r
58}\r
59\r
60/**\r
61 Compares two GUIDs.\r
62\r
63 This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.\r
64 If there are any bit differences in the two GUIDs, then FALSE is returned.\r
65\r
66 If Guid1 is NULL, then ASSERT().\r
67 If Guid2 is NULL, then ASSERT().\r
68\r
69 @param Guid1 A pointer to a 128 bit GUID.\r
70 @param Guid2 A pointer to a 128 bit GUID.\r
71\r
72 @retval TRUE Guid1 and Guid2 are identical.\r
73 @retval FALSE Guid1 and Guid2 are not identical.\r
74\r
75**/\r
76BOOLEAN\r
77EFIAPI\r
78CompareGuid (\r
79 IN CONST GUID *Guid1,\r
80 IN CONST GUID *Guid2\r
81 )\r
82{\r
83 ASSERT (Guid1 != NULL);\r
84 ASSERT (Guid2 != NULL);\r
85\r
86 return InternalMemCompareGuid (Guid1, Guid2);\r
87}\r
88\r
89/**\r
90 Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r
91 in the target buffer.\r
92\r
93 This function searches the target buffer specified by Buffer and Length from\r
94 the lowest address to the highest address at 128-bit increments for the 128-bit\r
95 GUID value that matches Guid. If a match is found, then a pointer to the matching\r
96 GUID in the target buffer is returned. If no match is found, then NULL is returned.\r
97 If Length is 0, then NULL is returned.\r
98\r
99 If Length > 0 and Buffer is NULL, then ASSERT().\r
100 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
101 If Length is not aligned on a 128-bit boundary, then ASSERT().\r
102 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
103\r
104 @param Buffer The pointer to the target buffer to scan.\r
105 @param Length The number of bytes in Buffer to scan.\r
106 @param Guid The value to search for in the target buffer.\r
107\r
108 @return A pointer to the matching Guid in the target buffer or NULL otherwise.\r
109\r
110**/\r
111VOID *\r
112EFIAPI\r
113ScanGuid (\r
114 IN CONST VOID *Buffer,\r
115 IN UINTN Length,\r
116 IN CONST GUID *Guid\r
117 )\r
118{\r
2f88bd3a 119 CONST GUID *GuidPtr;\r
217b3ac0
AB
120\r
121 ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0);\r
122 ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
123 ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0);\r
124\r
2f88bd3a 125 GuidPtr = (GUID *)Buffer;\r
217b3ac0 126 Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
2f88bd3a 127 while (GuidPtr < (CONST GUID *)Buffer) {\r
217b3ac0 128 if (InternalMemCompareGuid (GuidPtr, Guid)) {\r
2f88bd3a 129 return (VOID *)GuidPtr;\r
217b3ac0 130 }\r
2f88bd3a 131\r
217b3ac0
AB
132 GuidPtr++;\r
133 }\r
2f88bd3a 134\r
217b3ac0
AB
135 return NULL;\r
136}\r
137\r
138/**\r
139 Checks if the given GUID is a zero GUID.\r
140\r
141 This function checks whether the given GUID is a zero GUID. If the GUID is\r
142 identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned.\r
143\r
144 If Guid is NULL, then ASSERT().\r
145\r
146 @param Guid The pointer to a 128 bit GUID.\r
147\r
148 @retval TRUE Guid is a zero GUID.\r
149 @retval FALSE Guid is not a zero GUID.\r
150\r
151**/\r
152BOOLEAN\r
153EFIAPI\r
154IsZeroGuid (\r
155 IN CONST GUID *Guid\r
156 )\r
157{\r
158 ASSERT (Guid != NULL);\r
159\r
160 return InternalMemCompareGuid (Guid, NULL);\r
161}\r