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