xref: /DragonStub/lib/guid.c (revision f412fd2a1a248b546b7085648dece8d908077fab)
1 /*++
2 
3 Copyright (c) 1998  Intel Corporation
4 
5 Module Name:
6 
7     misc.c
8 
9 Abstract:
10 
11     Misc EFI support functions
12 
13 
14 
15 Revision History
16 
17 --*/
18 
19 #include "lib.h"
20 
21 
22 //
23 // Additional Known guids
24 //
25 
26 #define SHELL_INTERFACE_PROTOCOL \
27     { 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
28 
29 #define ENVIRONMENT_VARIABLE_ID  \
30     { 0x47c7b224, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
31 
32 #define DEVICE_PATH_MAPPING_ID  \
33     { 0x47c7b225, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
34 
35 #define PROTOCOL_ID_ID  \
36     { 0x47c7b226, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
37 
38 #define ALIAS_ID  \
39     { 0x47c7b227, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
40 
41 static EFI_GUID ShellInterfaceProtocol = SHELL_INTERFACE_PROTOCOL;
42 static EFI_GUID SEnvId                 = ENVIRONMENT_VARIABLE_ID;
43 static EFI_GUID SMapId                 = DEVICE_PATH_MAPPING_ID;
44 static EFI_GUID SProtId                = PROTOCOL_ID_ID;
45 static EFI_GUID SAliasId               = ALIAS_ID;
46 
47 static struct {
48     EFI_GUID        *Guid;
49     WCHAR           *GuidName;
50 } KnownGuids[] = {
51 	{  &NullGuid,                                       L"G0" },
52 	{  &gEfiGlobalVariableGuid,                         L"EfiVar" },
53 
54 	{  &VariableStoreProtocol,                          L"VarStore" },
55 	{  &gEfiDevicePathProtocolGuid,                     L"DevPath" },
56 	{  &gEfiLoadedImageProtocolGuid,                    L"LdImg" },
57 	{  &gEfiSimpleTextInProtocolGuid,                   L"TxtIn" },
58 	{  &gEfiSimpleTextOutProtocolGuid,                  L"TxtOut" },
59 	{  &gEfiBlockIoProtocolGuid,                        L"BlkIo" },
60 	{  &gEfiBlockIo2ProtocolGuid,                       L"BlkIo2" },
61 	{  &gEfiDiskIoProtocolGuid,                         L"DskIo" },
62 	{  &gEfiDiskIo2ProtocolGuid,                        L"DskIo2" },
63 	{  &gEfiSimpleFileSystemProtocolGuid,               L"Fs" },
64 	{  &gEfiLoadFileProtocolGuid,                       L"LdFile" },
65 	{  &gEfiDeviceIoProtocolGuid,                       L"DevIo" },
66 	{  &gEfiComponentNameProtocolGuid,                  L"CName" },
67 	{  &gEfiComponentName2ProtocolGuid,                 L"CName2" },
68 
69 	{  &gEfiFileInfoGuid,                               L"FileInfo" },
70 	{  &gEfiFileSystemInfoGuid,                         L"FsInfo" },
71 	{  &gEfiFileSystemVolumeLabelInfoIdGuid,            L"FsVolInfo" },
72 
73 	{  &gEfiUnicodeCollationProtocolGuid,               L"Unicode" },
74 	{  &LegacyBootProtocol,                             L"LegacyBoot" },
75 	{  &gEfiSerialIoProtocolGuid,                       L"SerIo" },
76 	{  &VgaClassProtocol,                               L"VgaClass"},
77 	{  &gEfiSimpleNetworkProtocolGuid,                  L"Net" },
78 	{  &gEfiNetworkInterfaceIdentifierProtocolGuid,     L"Nii" },
79 	{  &gEfiPxeBaseCodeProtocolGuid,                    L"Pxe" },
80 	{  &gEfiPxeBaseCodeCallbackProtocolGuid,            L"PxeCb" },
81 
82 	{  &TextOutSpliterProtocol,                         L"TxtOutSplit" },
83 	{  &ErrorOutSpliterProtocol,                        L"ErrOutSplit" },
84 	{  &TextInSpliterProtocol,                          L"TxtInSplit" },
85 	{  &gEfiPcAnsiGuid,                                 L"PcAnsi" },
86 	{  &gEfiVT100Guid,                                  L"Vt100" },
87 	{  &gEfiVT100PlusGuid,                              L"Vt100Plus" },
88 	{  &gEfiVTUTF8Guid,                                 L"VtUtf8" },
89 	{  &UnknownDevice,                                  L"UnknownDev" },
90 
91 	{  &EfiPartTypeSystemPartitionGuid,                 L"ESP" },
92 	{  &EfiPartTypeLegacyMbrGuid,                       L"GPT MBR" },
93 
94 	{  &ShellInterfaceProtocol,                         L"ShellInt" },
95 	{  &SEnvId,                                         L"SEnv" },
96 	{  &SProtId,                                        L"ShellProtId" },
97 	{  &SMapId,                                         L"ShellDevPathMap" },
98 	{  &SAliasId,                                       L"ShellAlias" },
99 
100 	{  NULL, L"" }
101 };
102 
103 //
104 //
105 //
106 
107 LIST_ENTRY          GuidList;
108 
109 
110 VOID
111 InitializeGuid (
112     VOID
113     )
114 {
115 }
116 
117 INTN
118 CompareGuid(
119     IN EFI_GUID     *Guid1,
120     IN EFI_GUID     *Guid2
121     )
122 /*++
123 
124 Routine Description:
125 
126     Compares to GUIDs
127 
128 Arguments:
129 
130     Guid1       - guid to compare
131     Guid2       - guid to compare
132 
133 Returns:
134     = 0     if Guid1 == Guid2
135 
136 --*/
137 {
138     return RtCompareGuid (Guid1, Guid2);
139 }
140 
141 
142 VOID
143 GuidToString (
144     OUT CHAR16      *Buffer,
145     IN EFI_GUID     *Guid
146     )
147 {
148 
149     UINTN           Index;
150 
151     //
152     // Else, (for now) use additional internal function for mapping guids
153     //
154 
155     for (Index=0; KnownGuids[Index].Guid; Index++) {
156         if (CompareGuid(Guid, KnownGuids[Index].Guid) == 0) {
157             UnicodeSPrint (Buffer, 0, KnownGuids[Index].GuidName);
158             return ;
159         }
160     }
161 
162     //
163     // Else dump it
164     //
165 
166     UnicodeSPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
167         Guid->Data1,
168         Guid->Data2,
169         Guid->Data3,
170         Guid->Data4[0],
171         Guid->Data4[1],
172         Guid->Data4[2],
173         Guid->Data4[3],
174         Guid->Data4[4],
175         Guid->Data4[5],
176         Guid->Data4[6],
177         Guid->Data4[7]
178         );
179 }
180