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