aboutsummaryrefslogtreecommitdiff
path: root/gnu-efi/gnu-efi-3.0/lib/guid.c
blob: 92622b4903167315b0d58b77498bdc68e1180ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*++

Copyright (c) 1998  Intel Corporation

Module Name:

    misc.c

Abstract:

    Misc EFI support functions



Revision History

--*/

#include "lib.h"


//
// Additional Known guids
//

#define SHELL_INTERFACE_PROTOCOL \
    { 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }

#define ENVIRONMENT_VARIABLE_ID  \
    { 0x47c7b224, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }

#define DEVICE_PATH_MAPPING_ID  \
    { 0x47c7b225, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }

#define PROTOCOL_ID_ID  \
    { 0x47c7b226, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }

#define ALIAS_ID  \
    { 0x47c7b227, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }

static EFI_GUID ShellInterfaceProtocol = SHELL_INTERFACE_PROTOCOL;
static EFI_GUID SEnvId                 = ENVIRONMENT_VARIABLE_ID;
static EFI_GUID SMapId                 = DEVICE_PATH_MAPPING_ID;
static EFI_GUID SProtId                = PROTOCOL_ID_ID;
static EFI_GUID SAliasId               = ALIAS_ID;

static struct {
    EFI_GUID        *Guid;
    WCHAR           *GuidName;
} KnownGuids[] = {
	{  &NullGuid,                  L"G0"},
	{  &EfiGlobalVariable,         L"Efi"},

	{  &VariableStoreProtocol,     L"varstore"},
	{  &DevicePathProtocol,        L"dpath"},
	{  &LoadedImageProtocol,       L"image"},
	{  &TextInProtocol,            L"txtin"},
	{  &TextOutProtocol,           L"txtout"},
	{  &BlockIoProtocol,           L"blkio"},
	{  &DiskIoProtocol,            L"diskio"},
	{  &FileSystemProtocol,        L"fs"},
	{  &LoadFileProtocol,          L"load"},
	{  &DeviceIoProtocol,          L"DevIo"},

	{  &GenericFileInfo,           L"GenFileInfo"},
	{  &FileSystemInfo,            L"FileSysInfo"},

	{  &UnicodeCollationProtocol,  L"unicode"},
	{  &LegacyBootProtocol,        L"LegacyBoot"},
	{  &SerialIoProtocol,          L"serialio"},
	{  &VgaClassProtocol,          L"vgaclass"},
	{  &SimpleNetworkProtocol,     L"net"},
	{  &NetworkInterfaceIdentifierProtocol,    L"nii"},
	{  &PxeBaseCodeProtocol,       L"pxebc"},
	{  &PxeCallbackProtocol,       L"pxecb"},

	{  &VariableStoreProtocol,     L"varstore"},
	{  &LegacyBootProtocol,        L"LegacyBoot"},
	{  &VgaClassProtocol,          L"VgaClass"},
	{  &TextOutSpliterProtocol,    L"TxtOutSplit"},
	{  &ErrorOutSpliterProtocol,   L"ErrOutSplit"},
	{  &TextInSpliterProtocol,     L"TxtInSplit"},
	{  &PcAnsiProtocol,            L"PcAnsi"},
	{  &Vt100Protocol,             L"Vt100"},
	{  &UnknownDevice,             L"Unknown Device"},

	{  &EfiPartTypeSystemPartitionGuid,    L"ESP"},
	{  &EfiPartTypeLegacyMbrGuid,          L"GPT MBR"},

	{  &ShellInterfaceProtocol,    L"ShellInt"},
	{  &SEnvId,                    L"SEnv"},
	{  &SProtId,                   L"ShellProtId"},
	{  &SMapId,                    L"ShellDevPathMap"},
	{  &SAliasId,                  L"ShellAlias"},

	{  NULL }
};

//
//
//

LIST_ENTRY          GuidList;


VOID
InitializeGuid (
    VOID
    )
{
}

INTN
CompareGuid(
    IN EFI_GUID     *Guid1,
    IN EFI_GUID     *Guid2
    )
/*++

Routine Description:

    Compares to GUIDs

Arguments:

    Guid1       - guid to compare
    Guid2       - guid to compare

Returns:
    = 0     if Guid1 == Guid2

--*/
{
    return RtCompareGuid (Guid1, Guid2);
}


VOID
GuidToString (
    OUT CHAR16      *Buffer,
    IN EFI_GUID     *Guid
    )
{

    UINTN           Index;

    //
    // Else, (for now) use additional internal function for mapping guids
    //

    for (Index=0; KnownGuids[Index].Guid; Index++) {
        if (CompareGuid(Guid, KnownGuids[Index].Guid) == 0) {
            SPrint (Buffer, 0, KnownGuids[Index].GuidName);
            return ;
        }
    }

    //
    // Else dump it
    //

    SPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
        Guid->Data1,                    
        Guid->Data2,
        Guid->Data3,
        Guid->Data4[0],
        Guid->Data4[1],
        Guid->Data4[2],
        Guid->Data4[3],
        Guid->Data4[4],
        Guid->Data4[5],
        Guid->Data4[6],
        Guid->Data4[7]
        );
}