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