]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLibOptDxe/Arm/MemLibGuid.c
MdePkg/BaseMemoryLibOptDxe ARM|AARCH64: implement accelerated GUID functions
[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
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include "MemLibInternals.h"\r
17\r
18BOOLEAN\r
19EFIAPI\r
20InternalMemCompareGuid (\r
21 IN CONST GUID *Guid1,\r
22 IN CONST GUID *Guid2\r
23 );\r
24\r
25/**\r
26 Copies a source GUID to a destination GUID.\r
27\r
28 This function copies the contents of the 128-bit GUID specified by SourceGuid to\r
29 DestinationGuid, and returns DestinationGuid.\r
30\r
31 If DestinationGuid is NULL, then ASSERT().\r
32 If SourceGuid is NULL, then ASSERT().\r
33\r
34 @param DestinationGuid The pointer to the destination GUID.\r
35 @param SourceGuid The pointer to the source GUID.\r
36\r
37 @return DestinationGuid.\r
38\r
39**/\r
40GUID *\r
41EFIAPI\r
42CopyGuid (\r
43 OUT GUID *DestinationGuid,\r
44 IN CONST GUID *SourceGuid\r
45 )\r
46{\r
47 ASSERT (DestinationGuid != NULL);\r
48 ASSERT (SourceGuid != NULL);\r
49\r
50 return InternalMemCopyMem (DestinationGuid, SourceGuid, sizeof (GUID));\r
51}\r
52\r
53/**\r
54 Compares two GUIDs.\r
55\r
56 This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.\r
57 If there are any bit differences in the two GUIDs, then FALSE is returned.\r
58\r
59 If Guid1 is NULL, then ASSERT().\r
60 If Guid2 is NULL, then ASSERT().\r
61\r
62 @param Guid1 A pointer to a 128 bit GUID.\r
63 @param Guid2 A pointer to a 128 bit GUID.\r
64\r
65 @retval TRUE Guid1 and Guid2 are identical.\r
66 @retval FALSE Guid1 and Guid2 are not identical.\r
67\r
68**/\r
69BOOLEAN\r
70EFIAPI\r
71CompareGuid (\r
72 IN CONST GUID *Guid1,\r
73 IN CONST GUID *Guid2\r
74 )\r
75{\r
76 ASSERT (Guid1 != NULL);\r
77 ASSERT (Guid2 != NULL);\r
78\r
79 return InternalMemCompareGuid (Guid1, Guid2);\r
80}\r
81\r
82/**\r
83 Scans a target buffer for a GUID, and returns a pointer to the matching GUID\r
84 in the target buffer.\r
85\r
86 This function searches the target buffer specified by Buffer and Length from\r
87 the lowest address to the highest address at 128-bit increments for the 128-bit\r
88 GUID value that matches Guid. If a match is found, then a pointer to the matching\r
89 GUID in the target buffer is returned. If no match is found, then NULL is returned.\r
90 If Length is 0, then NULL is returned.\r
91\r
92 If Length > 0 and Buffer is NULL, then ASSERT().\r
93 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
94 If Length is not aligned on a 128-bit boundary, then ASSERT().\r
95 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
96\r
97 @param Buffer The pointer to the target buffer to scan.\r
98 @param Length The number of bytes in Buffer to scan.\r
99 @param Guid The value to search for in the target buffer.\r
100\r
101 @return A pointer to the matching Guid in the target buffer or NULL otherwise.\r
102\r
103**/\r
104VOID *\r
105EFIAPI\r
106ScanGuid (\r
107 IN CONST VOID *Buffer,\r
108 IN UINTN Length,\r
109 IN CONST GUID *Guid\r
110 )\r
111{\r
112 CONST GUID *GuidPtr;\r
113\r
114 ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0);\r
115 ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));\r
116 ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0);\r
117\r
118 GuidPtr = (GUID*)Buffer;\r
119 Buffer = GuidPtr + Length / sizeof (*GuidPtr);\r
120 while (GuidPtr < (CONST GUID*)Buffer) {\r
121 if (InternalMemCompareGuid (GuidPtr, Guid)) {\r
122 return (VOID*)GuidPtr;\r
123 }\r
124 GuidPtr++;\r
125 }\r
126 return NULL;\r
127}\r
128\r
129/**\r
130 Checks if the given GUID is a zero GUID.\r
131\r
132 This function checks whether the given GUID is a zero GUID. If the GUID is\r
133 identical to a zero GUID then TRUE is returned. Otherwise, FALSE is returned.\r
134\r
135 If Guid is NULL, then ASSERT().\r
136\r
137 @param Guid The pointer to a 128 bit GUID.\r
138\r
139 @retval TRUE Guid is a zero GUID.\r
140 @retval FALSE Guid is not a zero GUID.\r
141\r
142**/\r
143BOOLEAN\r
144EFIAPI\r
145IsZeroGuid (\r
146 IN CONST GUID *Guid\r
147 )\r
148{\r
149 ASSERT (Guid != NULL);\r
150\r
151 return InternalMemCompareGuid (Guid, NULL);\r
152}\r