Fix vfr compiler build error for checkbox check.
[mirror_edk2.git] / EdkShellPkg / ShellHotFix.patch
CommitLineData
0fe4decf 1Index: drivers/drivers.c\r
2===================================================================\r
3--- drivers/drivers.c (revision 30)\r
4+++ drivers/drivers.c (working copy)\r
5@@ -130,6 +130,7 @@\r
6 UINTN StringIndex;
7 UINTN Index;
8 CHAR8 *Language;
9+ CHAR8 *PlatformLanguage;
10 UINTN DriverImageHandleCount;
11 EFI_HANDLE *DriverImageHandleBuffer;
12 UINTN HandleIndex;
13@@ -152,6 +153,7 @@\r
14 SHELL_VAR_CHECK_PACKAGE ChkPck;
15
16 Language = NULL;
17+ PlatformLanguage = NULL;
18 DriverImageHandleCount = 0;
19 DriverImageHandleBuffer = NULL;
20 IsHelp = FALSE;
21@@ -241,7 +243,7 @@\r
22 goto Done;
23 }
24
25- Language = LibGetVariableLang ();
26+ Language = LibGetVariable (L"Lang", &gEfiGlobalVariableGuid);
27 if (Language == NULL) {
28 Language = (CHAR8 *)AllocateZeroPool(strlena(LanguageCodeEnglish) + 1);
29 if (Language == NULL) {
30@@ -250,6 +252,15 @@\r
31 strcpya(Language, LanguageCodeEnglish);
32 }
33
34+ PlatformLanguage = LibGetVariable (L"PlatformLang", &gEfiGlobalVariableGuid);
35+ if (PlatformLanguage == NULL) {
36+ PlatformLanguage = (CHAR8 *)AllocateZeroPool(strlena(PlatformLanguageCodeEnglish) + 1);
37+ if (PlatformLanguage == NULL) {
38+ return EFI_OUT_OF_RESOURCES;
39+ }
40+ strcpya(PlatformLanguage, PlatformLanguageCodeEnglish);
41+ }
42+
43 Item = LibCheckVarGetFlag (&ChkPck, L"-l");
44 if (Item) {
45 if (Language != NULL) {
46@@ -314,14 +325,6 @@\r
47 EFI_OPEN_PROTOCOL_GET_PROTOCOL
48 );
49
50- ComponentName = NULL;
51- ComponentName2 = NULL;
52- Status = LibGetComponentNameProtocol (
53- DriverImageHandleBuffer[Index],
54- &ComponentName,
55- &ComponentName2
56- );
57-
58 DiagnosticsStatus = BS->OpenProtocol (
59 DriverImageHandleBuffer[Index],
60 &gEfiDriverDiagnostics2ProtocolGuid,
61@@ -418,37 +421,73 @@\r
62 } else {
63 PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_ONE_VAR_D), HiiHandle, NumberOfChildren);
64 }
65-
66- Status = EFI_SUCCESS;
67+
68 DriverName = L"<UNKNOWN>";
69- SupportedLanguage = NULL;
70- if (ComponentName != NULL) {
71- if (ComponentName->GetDriverName != NULL) {
72- SupportedLanguage = LibConvertSupportedLanguage (ComponentName->SupportedLanguages, Language);
73+ Status = BS->OpenProtocol (
74+ DriverImageHandleBuffer[Index],
75+ &gEfiComponentName2ProtocolGuid,
76+ (VOID **) &ComponentName2,
77+ NULL,
78+ NULL,
79+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
80+ );
81+ if (!EFI_ERROR (Status)) {
82+ //
83+ // Driver has Component Name 2 Protocol is available, we get the
84+ // driver name var RFC 3066 language code
85+ //
86+ Status = ComponentName2->GetDriverName (
87+ ComponentName2,
88+ PlatformLanguage,
89+ &DriverName
90+ );
91+ if (EFI_ERROR (Status)) {
92+ //
93+ // Current RFC3066 language code fails, we then extract the supported
94+ // language from Component Name 2 protocol interface.
95+ //
96+ SupportedLanguage = ExtractSupportedLanguage(ComponentName2->SupportedLanguages, Language);
97+ if (SupportedLanguage != NULL) {
98+ Status = ComponentName2->GetDriverName (
99+ ComponentName2,
100+ SupportedLanguage,
101+ &DriverName
102+ );
103+ FreePool(SupportedLanguage);
104+ }
105+ }
106+ }
107+ if (EFI_ERROR (Status)) {
108+ //
109+ // In case Component Name 2 protocol is not available or some error occurs
110+ // when getting driver name from Component Name 2 protocol, we get driver
111+ // name from Component Name protocol.
112+ //
113+ Status = BS->OpenProtocol (
114+ DriverImageHandleBuffer[Index],
115+ &gEfiComponentNameProtocolGuid,
116+ (VOID **) &ComponentName,
117+ NULL,
118+ NULL,
119+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
120+ );
121+ if (!EFI_ERROR (Status)) {
122 Status = ComponentName->GetDriverName (
123 ComponentName,
124- SupportedLanguage,
125+ Language,
126 &DriverName
127 );
128 }
129- } else if (ComponentName2 != NULL) {
130- if (ComponentName2->GetDriverName != NULL) {
131- SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
132- Status = ComponentName2->GetDriverName (
133- ComponentName2,
134- SupportedLanguage,
135- &DriverName
136- );
137- }
138 }
139- if (SupportedLanguage != NULL) {
140- FreePool (SupportedLanguage);
141- }
142-
143 if (EFI_ERROR (Status)) {
144+ //
145+ // Fails to get driver name from either Component Name 2 & Component Name
146+ // Protocol, we show "<UNKNOWN>" string as driver name.
147+ //
148 DriverName = L"<UNKNOWN>";
149 }
150
151+
152 for (StringIndex = 0; StringIndex < StrLen (DriverName) && StringIndex < 35; StringIndex++) {
153 FormattedDriverName[StringIndex] = DriverName[StringIndex];
154 }
155@@ -491,6 +530,10 @@\r
156 FreePool (Language);
157 }
158
159+ if (PlatformLanguage != NULL) {
160+ FreePool (PlatformLanguage);
161+ }
162+
163 ShellCloseHandleEnumerator ();
164 LibCheckVarFreeVarList (&ChkPck);
165 LibUnInitializeStrings ();
166Index: Library/EfiShellLib.h\r
167===================================================================\r
168--- Library/EfiShellLib.h (revision 30)\r
169+++ Library/EfiShellLib.h (working copy)\r
170@@ -174,22 +174,23 @@\r
171 //
172 // Environment variable name constants
173 //
174-#define VarLanguageCodes L"LangCodes"
175-#define VarLanguage L"Lang"
176-#define VarTimeout L"Timeout"
177-#define VarConsoleIn L"ConIn"
178-#define VarConsoleOut L"ConOut"
179-#define VarErrorOut L"ErrOut"
180-#define VarBootOption L"Boot%04x"
181-#define VarBootOrder L"BootOrder"
182-#define VarBootNext L"BootNext"
183-#define VarBootCurrent L"BootCurrent"
184-#define VarDriverOption L"Driver%04x"
185-#define VarDriverOrder L"DriverOrder"
186-#define VarConsoleInpDev L"ConInDev"
187-#define VarConsoleOutDev L"ConOutDev"
188-#define VarErrorOutDev L"ErrOutDev"
189-#define LanguageCodeEnglish "eng"
190+#define VarLanguageCodes L"LangCodes"
191+#define VarLanguage L"Lang"
192+#define VarTimeout L"Timeout"
193+#define VarConsoleIn L"ConIn"
194+#define VarConsoleOut L"ConOut"
195+#define VarErrorOut L"ErrOut"
196+#define VarBootOption L"Boot%04x"
197+#define VarBootOrder L"BootOrder"
198+#define VarBootNext L"BootNext"
199+#define VarBootCurrent L"BootCurrent"
200+#define VarDriverOption L"Driver%04x"
201+#define VarDriverOrder L"DriverOrder"
202+#define VarConsoleInpDev L"ConInDev"
203+#define VarConsoleOutDev L"ConOutDev"
204+#define VarErrorOutDev L"ErrOutDev"
205+#define LanguageCodeEnglish "eng"
206+#define PlatformLanguageCodeEnglish "en-US"
207
208 #define ISO_639_2_ENTRY_SIZE 3
209 #define RFC_3066_ENTRY_SIZE 12
210@@ -333,4 +334,10 @@\r
211 IN CHAR8 *LangCode
212 );
213
214+CHAR8 *
215+ExtractSupportedLanguage (
216+ IN CONST CHAR8 *SupportedLanguages,
217+ IN CONST CHAR8 *Language
218+ );
219+
220 #endif
221Index: Library/Misc.c\r
222===================================================================\r
223--- Library/Misc.c (revision 30)\r
224+++ Library/Misc.c (working copy)\r
225@@ -1905,13 +1905,13 @@\r
226 IN VOID *UserData
227 )
228 {
229- CHAR8 *Data;
230+ UINT8 *Data;
231
232 CHAR8 Val[50];
233
234 CHAR8 Str[20];
235
236- CHAR8 c;
237+ UINT8 c;
238 UINTN Size;
239 UINTN Index;
240
241@@ -2271,3 +2271,76 @@\r
242 }
243 return Lang;
244 }
245+
246+CHAR8 *
247+ExtractSupportedLanguage (
248+ IN CONST CHAR8 *SupportedLanguages,
249+ IN CONST CHAR8 *Language
250+ )
251+/*++
252+
253+ Routine Description:
254+
255+ This function matches the major language code (first two characters) in the
256+ SupportedLanguages. The first language code in the SupportedLanguages that
257+ matches first two characters of the input Language is returned. If there is no
258+ such match, then NULL is returned.
259+
260+ Arguments:
261+
262+ SupportedLanguages - A Null-terminated ASCII string that contains one
263+ or more supported language codes.
264+
265+ LangCode - A pointer to a Null-terminated ASCII string
266+ array indicating the RFC 3066 language.
267+
268+ Returns:
269+
270+ The RFC3066 language code that matches the major language.
271+
272+--*/
273+{
274+ CONST CHAR8 *CurrentLanguage;
275+ CHAR8 *SupportedLanguage;
276+ UINTN LanguageLen;
277+
278+ CurrentLanguage = SupportedLanguages;
279+
280+ while (CurrentLanguage != '\0') {
281+ //
282+ // Search till the end of current language.
283+ //
284+ LanguageLen = 0;
285+ while (CurrentLanguage[LanguageLen] != ';' && CurrentLanguage[LanguageLen] != '\0') {
286+ LanguageLen++;
287+ }
288+
289+ //
290+ // should use AsciiStrnCmp(CurrentLanguage, Language, 2) == 0
291+ //
292+ if ((CurrentLanguage[0] == Language[0]) && (CurrentLanguage[1] == Language[1])) {
293+ //
294+ // Match the major language code, then return a new copy of
295+ // NULL-terminated SupportedLanguage.
296+ //
297+ SupportedLanguage = AllocatePool (LanguageLen + 1);
298+ CopyMem (SupportedLanguage, (VOID *) CurrentLanguage, LanguageLen);
299+
300+ SupportedLanguage[LanguageLen] = '\0';
301+
302+ return SupportedLanguage;
303+ }
304+ //
305+ // Make CurrentLangue point to the next candiate language code.
306+ //
307+ CurrentLanguage += LanguageLen;
308+ if (*CurrentLanguage == ';') {
309+ CurrentLanguage++;
310+ }
311+ }
312+
313+ return NULL;
314+}
315+
316+
317+
318Index: SmbiosView/PrintInfo.c\r
319===================================================================\r
320--- SmbiosView/PrintInfo.c (revision 30)\r
321+++ SmbiosView/PrintInfo.c (working copy)\r
322@@ -1779,7 +1779,7 @@\r
323 //
324 // MaxSize is determined by follow formula
325 //
326- MaxSize = 1 << Size;
327+ MaxSize = (UINTN) 1 << Size;
328 PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_MB), HiiHandle, MaxSize);
329
330 if (Option >= SHOW_DETAIL) {
331Index: SmbiosView/Smbios.h\r
332===================================================================\r
333--- SmbiosView/Smbios.h (revision 30)\r
334+++ SmbiosView/Smbios.h (working copy)\r
335@@ -34,11 +34,6 @@\r
336
337 extern EFI_HII_HANDLE HiiHandle;
338
339-#define EFI_SMBIOS_TABLE_GUID \
340- { \
341- 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
342- }
343
344-extern EFI_GUID gEfiSmbiosTableGuid;
345
346 #endif