xref: /DragonStub/lib/guid.c (revision 530d68ba191850edafc6da22cb2df55bec0c5fa5)
1*530d68baSNigel Croxon /*++
2*530d68baSNigel Croxon 
3*530d68baSNigel Croxon Copyright (c) 1998  Intel Corporation
4*530d68baSNigel Croxon 
5*530d68baSNigel Croxon Module Name:
6*530d68baSNigel Croxon 
7*530d68baSNigel Croxon     misc.c
8*530d68baSNigel Croxon 
9*530d68baSNigel Croxon Abstract:
10*530d68baSNigel Croxon 
11*530d68baSNigel Croxon     Misc EFI support functions
12*530d68baSNigel Croxon 
13*530d68baSNigel Croxon 
14*530d68baSNigel Croxon 
15*530d68baSNigel Croxon Revision History
16*530d68baSNigel Croxon 
17*530d68baSNigel Croxon --*/
18*530d68baSNigel Croxon 
19*530d68baSNigel Croxon #include "lib.h"
20*530d68baSNigel Croxon 
21*530d68baSNigel Croxon 
22*530d68baSNigel Croxon //
23*530d68baSNigel Croxon // Additional Known guids
24*530d68baSNigel Croxon //
25*530d68baSNigel Croxon 
26*530d68baSNigel Croxon #define SHELL_INTERFACE_PROTOCOL \
27*530d68baSNigel Croxon     { 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
28*530d68baSNigel Croxon 
29*530d68baSNigel Croxon #define ENVIRONMENT_VARIABLE_ID  \
30*530d68baSNigel Croxon     { 0x47c7b224, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
31*530d68baSNigel Croxon 
32*530d68baSNigel Croxon #define DEVICE_PATH_MAPPING_ID  \
33*530d68baSNigel Croxon     { 0x47c7b225, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
34*530d68baSNigel Croxon 
35*530d68baSNigel Croxon #define PROTOCOL_ID_ID  \
36*530d68baSNigel Croxon     { 0x47c7b226, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
37*530d68baSNigel Croxon 
38*530d68baSNigel Croxon #define ALIAS_ID  \
39*530d68baSNigel Croxon     { 0x47c7b227, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
40*530d68baSNigel Croxon 
41*530d68baSNigel Croxon static EFI_GUID ShellInterfaceProtocol = SHELL_INTERFACE_PROTOCOL;
42*530d68baSNigel Croxon static EFI_GUID SEnvId                 = ENVIRONMENT_VARIABLE_ID;
43*530d68baSNigel Croxon static EFI_GUID SMapId                 = DEVICE_PATH_MAPPING_ID;
44*530d68baSNigel Croxon static EFI_GUID SProtId                = PROTOCOL_ID_ID;
45*530d68baSNigel Croxon static EFI_GUID SAliasId               = ALIAS_ID;
46*530d68baSNigel Croxon 
47*530d68baSNigel Croxon static struct {
48*530d68baSNigel Croxon     EFI_GUID        *Guid;
49*530d68baSNigel Croxon     WCHAR           *GuidName;
50*530d68baSNigel Croxon } KnownGuids[] = {
51*530d68baSNigel Croxon 	{  &NullGuid,                  L"G0"},
52*530d68baSNigel Croxon 	{  &EfiGlobalVariable,         L"Efi"},
53*530d68baSNigel Croxon 
54*530d68baSNigel Croxon 	{  &VariableStoreProtocol,     L"varstore"},
55*530d68baSNigel Croxon 	{  &DevicePathProtocol,        L"dpath"},
56*530d68baSNigel Croxon 	{  &LoadedImageProtocol,       L"image"},
57*530d68baSNigel Croxon 	{  &TextInProtocol,            L"txtin"},
58*530d68baSNigel Croxon 	{  &TextOutProtocol,           L"txtout"},
59*530d68baSNigel Croxon 	{  &BlockIoProtocol,           L"blkio"},
60*530d68baSNigel Croxon 	{  &DiskIoProtocol,            L"diskio"},
61*530d68baSNigel Croxon 	{  &FileSystemProtocol,        L"fs"},
62*530d68baSNigel Croxon 	{  &LoadFileProtocol,          L"load"},
63*530d68baSNigel Croxon 	{  &DeviceIoProtocol,          L"DevIo"},
64*530d68baSNigel Croxon 
65*530d68baSNigel Croxon 	{  &GenericFileInfo,           L"GenFileInfo"},
66*530d68baSNigel Croxon 	{  &FileSystemInfo,            L"FileSysInfo"},
67*530d68baSNigel Croxon 
68*530d68baSNigel Croxon 	{  &UnicodeCollationProtocol,  L"unicode"},
69*530d68baSNigel Croxon 	{  &LegacyBootProtocol,        L"LegacyBoot"},
70*530d68baSNigel Croxon 	{  &SerialIoProtocol,          L"serialio"},
71*530d68baSNigel Croxon 	{  &VgaClassProtocol,          L"vgaclass"},
72*530d68baSNigel Croxon 	{  &SimpleNetworkProtocol,     L"net"},
73*530d68baSNigel Croxon 	{  &NetworkInterfaceIdentifierProtocol,    L"nii"},
74*530d68baSNigel Croxon 	{  &PxeBaseCodeProtocol,       L"pxebc"},
75*530d68baSNigel Croxon 	{  &PxeCallbackProtocol,       L"pxecb"},
76*530d68baSNigel Croxon 
77*530d68baSNigel Croxon 	{  &VariableStoreProtocol,     L"varstore"},
78*530d68baSNigel Croxon 	{  &LegacyBootProtocol,        L"LegacyBoot"},
79*530d68baSNigel Croxon 	{  &VgaClassProtocol,          L"VgaClass"},
80*530d68baSNigel Croxon 	{  &TextOutSpliterProtocol,    L"TxtOutSplit"},
81*530d68baSNigel Croxon 	{  &ErrorOutSpliterProtocol,   L"ErrOutSplit"},
82*530d68baSNigel Croxon 	{  &TextInSpliterProtocol,     L"TxtInSplit"},
83*530d68baSNigel Croxon 	{  &PcAnsiProtocol,            L"PcAnsi"},
84*530d68baSNigel Croxon 	{  &Vt100Protocol,             L"Vt100"},
85*530d68baSNigel Croxon 	{  &UnknownDevice,             L"Unknown Device"},
86*530d68baSNigel Croxon 
87*530d68baSNigel Croxon 	{  &EfiPartTypeSystemPartitionGuid,    L"ESP"},
88*530d68baSNigel Croxon 	{  &EfiPartTypeLegacyMbrGuid,          L"GPT MBR"},
89*530d68baSNigel Croxon 
90*530d68baSNigel Croxon 	{  &ShellInterfaceProtocol,    L"ShellInt"},
91*530d68baSNigel Croxon 	{  &SEnvId,                    L"SEnv"},
92*530d68baSNigel Croxon 	{  &SProtId,                   L"ShellProtId"},
93*530d68baSNigel Croxon 	{  &SMapId,                    L"ShellDevPathMap"},
94*530d68baSNigel Croxon 	{  &SAliasId,                  L"ShellAlias"},
95*530d68baSNigel Croxon 
96*530d68baSNigel Croxon 	{  NULL }
97*530d68baSNigel Croxon };
98*530d68baSNigel Croxon 
99*530d68baSNigel Croxon //
100*530d68baSNigel Croxon //
101*530d68baSNigel Croxon //
102*530d68baSNigel Croxon 
103*530d68baSNigel Croxon LIST_ENTRY          GuidList;
104*530d68baSNigel Croxon 
105*530d68baSNigel Croxon 
106*530d68baSNigel Croxon VOID
107*530d68baSNigel Croxon InitializeGuid (
108*530d68baSNigel Croxon     VOID
109*530d68baSNigel Croxon     )
110*530d68baSNigel Croxon {
111*530d68baSNigel Croxon }
112*530d68baSNigel Croxon 
113*530d68baSNigel Croxon INTN
114*530d68baSNigel Croxon CompareGuid(
115*530d68baSNigel Croxon     IN EFI_GUID     *Guid1,
116*530d68baSNigel Croxon     IN EFI_GUID     *Guid2
117*530d68baSNigel Croxon     )
118*530d68baSNigel Croxon /*++
119*530d68baSNigel Croxon 
120*530d68baSNigel Croxon Routine Description:
121*530d68baSNigel Croxon 
122*530d68baSNigel Croxon     Compares to GUIDs
123*530d68baSNigel Croxon 
124*530d68baSNigel Croxon Arguments:
125*530d68baSNigel Croxon 
126*530d68baSNigel Croxon     Guid1       - guid to compare
127*530d68baSNigel Croxon     Guid2       - guid to compare
128*530d68baSNigel Croxon 
129*530d68baSNigel Croxon Returns:
130*530d68baSNigel Croxon     = 0     if Guid1 == Guid2
131*530d68baSNigel Croxon 
132*530d68baSNigel Croxon --*/
133*530d68baSNigel Croxon {
134*530d68baSNigel Croxon     return RtCompareGuid (Guid1, Guid2);
135*530d68baSNigel Croxon }
136*530d68baSNigel Croxon 
137*530d68baSNigel Croxon 
138*530d68baSNigel Croxon VOID
139*530d68baSNigel Croxon GuidToString (
140*530d68baSNigel Croxon     OUT CHAR16      *Buffer,
141*530d68baSNigel Croxon     IN EFI_GUID     *Guid
142*530d68baSNigel Croxon     )
143*530d68baSNigel Croxon {
144*530d68baSNigel Croxon 
145*530d68baSNigel Croxon     UINTN           Index;
146*530d68baSNigel Croxon 
147*530d68baSNigel Croxon     //
148*530d68baSNigel Croxon     // Else, (for now) use additional internal function for mapping guids
149*530d68baSNigel Croxon     //
150*530d68baSNigel Croxon 
151*530d68baSNigel Croxon     for (Index=0; KnownGuids[Index].Guid; Index++) {
152*530d68baSNigel Croxon         if (CompareGuid(Guid, KnownGuids[Index].Guid) == 0) {
153*530d68baSNigel Croxon             SPrint (Buffer, 0, KnownGuids[Index].GuidName);
154*530d68baSNigel Croxon             return ;
155*530d68baSNigel Croxon         }
156*530d68baSNigel Croxon     }
157*530d68baSNigel Croxon 
158*530d68baSNigel Croxon     //
159*530d68baSNigel Croxon     // Else dump it
160*530d68baSNigel Croxon     //
161*530d68baSNigel Croxon 
162*530d68baSNigel Croxon     SPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
163*530d68baSNigel Croxon         Guid->Data1,
164*530d68baSNigel Croxon         Guid->Data2,
165*530d68baSNigel Croxon         Guid->Data3,
166*530d68baSNigel Croxon         Guid->Data4[0],
167*530d68baSNigel Croxon         Guid->Data4[1],
168*530d68baSNigel Croxon         Guid->Data4[2],
169*530d68baSNigel Croxon         Guid->Data4[3],
170*530d68baSNigel Croxon         Guid->Data4[4],
171*530d68baSNigel Croxon         Guid->Data4[5],
172*530d68baSNigel Croxon         Guid->Data4[6],
173*530d68baSNigel Croxon         Guid->Data4[7]
174*530d68baSNigel Croxon         );
175*530d68baSNigel Croxon }
176