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