1 Index: drivers/drivers.c
2 ===================================================================
3 --- drivers/drivers.c (revision 30)
4 +++ drivers/drivers.c (working copy)
9 + CHAR8 *PlatformLanguage;
10 UINTN DriverImageHandleCount;
11 EFI_HANDLE *DriverImageHandleBuffer;
14 SHELL_VAR_CHECK_PACKAGE ChkPck;
17 + PlatformLanguage = NULL;
18 DriverImageHandleCount = 0;
19 DriverImageHandleBuffer = NULL;
25 - Language = LibGetVariableLang ();
26 + Language = LibGetVariable (L"Lang", &gEfiGlobalVariableGuid);
27 if (Language == NULL) {
28 Language = (CHAR8 *)AllocateZeroPool(strlena(LanguageCodeEnglish) + 1);
29 if (Language == NULL) {
31 strcpya(Language, LanguageCodeEnglish);
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;
40 + strcpya(PlatformLanguage, PlatformLanguageCodeEnglish);
43 Item = LibCheckVarGetFlag (&ChkPck, L"-l");
45 if (Language != NULL) {
47 EFI_OPEN_PROTOCOL_GET_PROTOCOL
50 - ComponentName = NULL;
51 - ComponentName2 = NULL;
52 - Status = LibGetComponentNameProtocol (
53 - DriverImageHandleBuffer[Index],
58 DiagnosticsStatus = BS->OpenProtocol (
59 DriverImageHandleBuffer[Index],
60 &gEfiDriverDiagnostics2ProtocolGuid,
63 PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_ONE_VAR_D), HiiHandle, NumberOfChildren);
66 - Status = EFI_SUCCESS;
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,
79 + EFI_OPEN_PROTOCOL_GET_PROTOCOL
81 + if (!EFI_ERROR (Status)) {
83 + // Driver has Component Name 2 Protocol is available, we get the
84 + // driver name var RFC 3066 language code
86 + Status = ComponentName2->GetDriverName (
91 + if (EFI_ERROR (Status)) {
93 + // Current RFC3066 language code fails, we then extract the supported
94 + // language from Component Name 2 protocol interface.
96 + SupportedLanguage = ExtractSupportedLanguage(ComponentName2->SupportedLanguages, Language);
97 + if (SupportedLanguage != NULL) {
98 + Status = ComponentName2->GetDriverName (
103 + FreePool(SupportedLanguage);
107 + if (EFI_ERROR (Status)) {
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.
113 + Status = BS->OpenProtocol (
114 + DriverImageHandleBuffer[Index],
115 + &gEfiComponentNameProtocolGuid,
116 + (VOID **) &ComponentName,
119 + EFI_OPEN_PROTOCOL_GET_PROTOCOL
121 + if (!EFI_ERROR (Status)) {
122 Status = ComponentName->GetDriverName (
129 - } else if (ComponentName2 != NULL) {
130 - if (ComponentName2->GetDriverName != NULL) {
131 - SupportedLanguage = LibConvertSupportedLanguage (ComponentName2->SupportedLanguages, Language);
132 - Status = ComponentName2->GetDriverName (
139 - if (SupportedLanguage != NULL) {
140 - FreePool (SupportedLanguage);
143 if (EFI_ERROR (Status)) {
145 + // Fails to get driver name from either Component Name 2 & Component Name
146 + // Protocol, we show "<UNKNOWN>" string as driver name.
148 DriverName = L"<UNKNOWN>";
152 for (StringIndex = 0; StringIndex < StrLen (DriverName) && StringIndex < 35; StringIndex++) {
153 FormattedDriverName[StringIndex] = DriverName[StringIndex];
159 + if (PlatformLanguage != NULL) {
160 + FreePool (PlatformLanguage);
163 ShellCloseHandleEnumerator ();
164 LibCheckVarFreeVarList (&ChkPck);
165 LibUnInitializeStrings ();
166 Index: edit/libEditor.c
167 ===================================================================
168 --- edit/libEditor.c (revision 30)
169 +++ edit/libEditor.c (working copy)
174 - EFI_HANDLE *HandleBuffer;
178 // basic initialization
179 @@ -117,38 +115,22 @@
184 + // Find mouse in System Table ConsoleInHandle
186 - HandleBuffer = NULL;
187 - Status = LibLocateHandle (
189 - &gEfiPrimaryConsoleInDeviceGuid,
194 + Status = BS->HandleProtocol (
196 + &gEfiSimplePointerProtocolGuid,
197 + &MainEditor.MouseInterface
200 - if (!EFI_ERROR (Status)) {
201 - if (HandleCount > 0) {
202 - Status = BS->HandleProtocol (
204 - &gEfiSimplePointerProtocolGuid,
205 - &MainEditor.MouseInterface
208 - if (EFI_ERROR (Status)) {
209 - MainEditor.MouseInterface = NULL;
211 - MainEditor.MouseAccumulatorX = 0;
212 - MainEditor.MouseAccumulatorY = 0;
213 - MainEditor.MouseSupported = TRUE;
216 + if (EFI_ERROR (Status)) {
217 + MainEditor.MouseInterface = NULL;
219 + MainEditor.MouseAccumulatorX = 0;
220 + MainEditor.MouseAccumulatorY = 0;
221 + MainEditor.MouseSupported = TRUE;
224 - if (HandleBuffer) {
225 - FreePool (HandleBuffer);
228 // below will call the five components' init function
230 Index: edit/libFileBuffer.c
231 ===================================================================
232 --- edit/libFileBuffer.c (revision 30)
233 +++ edit/libFileBuffer.c (working copy)
237 CHAR16 *UnicodeBuffer;
238 - CHAR8 *AsciiBuffer;
239 + UINT8 *AsciiBuffer;
241 EFI_FILE_HANDLE Handle;
243 @@ -1047,7 +1047,7 @@
247 - if (AsciiBuffer[0] == 0xff && AsciiBuffer[1] == 0xfe) {
248 + if ((FileSize >= 2) && (*((UINT16 *) Buffer) == EFI_UNICODE_BYTE_ORDER_MARK)) {
250 // Unicode file's size should be even
252 Index: hexedit/libEditor.c
253 ===================================================================
254 --- hexedit/libEditor.c (revision 30)
255 +++ hexedit/libEditor.c (working copy)
260 - EFI_HANDLE *HandleBuffer;
264 // basic initialization
265 @@ -129,36 +127,19 @@
266 &(HMainEditor.ScreenSize.Row)
269 - HandleBuffer = NULL;
270 - Status = LibLocateHandle (
272 - &gEfiPrimaryConsoleInDeviceGuid,
278 - if (!EFI_ERROR (Status)) {
280 - if (HandleCount > 0) {
281 - Status = BS->HandleProtocol (
283 - &gEfiSimplePointerProtocolGuid,
284 - &HMainEditor.MouseInterface
286 - if (EFI_ERROR (Status)) {
287 - HMainEditor.MouseInterface = NULL;
289 - HMainEditor.MouseAccumulatorX = 0;
290 - HMainEditor.MouseAccumulatorY = 0;
291 - HMainEditor.MouseSupported = TRUE;
294 + Status = BS->HandleProtocol (
296 + &gEfiSimplePointerProtocolGuid,
297 + &HMainEditor.MouseInterface
299 + if (EFI_ERROR (Status)) {
300 + HMainEditor.MouseInterface = NULL;
302 + HMainEditor.MouseAccumulatorX = 0;
303 + HMainEditor.MouseAccumulatorY = 0;
304 + HMainEditor.MouseSupported = TRUE;
307 - if (HandleBuffer != NULL) {
308 - FreePool (HandleBuffer);
311 // below will call the five components' init function
313 Index: Library/EfiShellLib.h
314 ===================================================================
315 --- Library/EfiShellLib.h (revision 30)
316 +++ Library/EfiShellLib.h (working copy)
317 @@ -174,22 +174,23 @@
319 // Environment variable name constants
321 -#define VarLanguageCodes L"LangCodes"
322 -#define VarLanguage L"Lang"
323 -#define VarTimeout L"Timeout"
324 -#define VarConsoleIn L"ConIn"
325 -#define VarConsoleOut L"ConOut"
326 -#define VarErrorOut L"ErrOut"
327 -#define VarBootOption L"Boot%04x"
328 -#define VarBootOrder L"BootOrder"
329 -#define VarBootNext L"BootNext"
330 -#define VarBootCurrent L"BootCurrent"
331 -#define VarDriverOption L"Driver%04x"
332 -#define VarDriverOrder L"DriverOrder"
333 -#define VarConsoleInpDev L"ConInDev"
334 -#define VarConsoleOutDev L"ConOutDev"
335 -#define VarErrorOutDev L"ErrOutDev"
336 -#define LanguageCodeEnglish "eng"
337 +#define VarLanguageCodes L"LangCodes"
338 +#define VarLanguage L"Lang"
339 +#define VarTimeout L"Timeout"
340 +#define VarConsoleIn L"ConIn"
341 +#define VarConsoleOut L"ConOut"
342 +#define VarErrorOut L"ErrOut"
343 +#define VarBootOption L"Boot%04x"
344 +#define VarBootOrder L"BootOrder"
345 +#define VarBootNext L"BootNext"
346 +#define VarBootCurrent L"BootCurrent"
347 +#define VarDriverOption L"Driver%04x"
348 +#define VarDriverOrder L"DriverOrder"
349 +#define VarConsoleInpDev L"ConInDev"
350 +#define VarConsoleOutDev L"ConOutDev"
351 +#define VarErrorOutDev L"ErrOutDev"
352 +#define LanguageCodeEnglish "eng"
353 +#define PlatformLanguageCodeEnglish "en-US"
355 #define ISO_639_2_ENTRY_SIZE 3
356 #define RFC_3066_ENTRY_SIZE 12
362 +ExtractSupportedLanguage (
363 + IN CONST CHAR8 *SupportedLanguages,
364 + IN CONST CHAR8 *Language
368 Index: Library/Misc.c
369 ===================================================================
370 --- Library/Misc.c (revision 30)
371 +++ Library/Misc.c (working copy)
372 @@ -1905,13 +1905,13 @@
388 @@ -2271,3 +2271,76 @@
394 +ExtractSupportedLanguage (
395 + IN CONST CHAR8 *SupportedLanguages,
396 + IN CONST CHAR8 *Language
400 + Routine Description:
402 + This function matches the major language code (first two characters) in the
403 + SupportedLanguages. The first language code in the SupportedLanguages that
404 + matches first two characters of the input Language is returned. If there is no
405 + such match, then NULL is returned.
409 + SupportedLanguages - A Null-terminated ASCII string that contains one
410 + or more supported language codes.
412 + LangCode - A pointer to a Null-terminated ASCII string
413 + array indicating the RFC 3066 language.
417 + The RFC3066 language code that matches the major language.
421 + CONST CHAR8 *CurrentLanguage;
422 + CHAR8 *SupportedLanguage;
425 + CurrentLanguage = SupportedLanguages;
427 + while (CurrentLanguage != '\0') {
429 + // Search till the end of current language.
432 + while (CurrentLanguage[LanguageLen] != ';' && CurrentLanguage[LanguageLen] != '\0') {
437 + // should use AsciiStrnCmp(CurrentLanguage, Language, 2) == 0
439 + if ((CurrentLanguage[0] == Language[0]) && (CurrentLanguage[1] == Language[1])) {
441 + // Match the major language code, then return a new copy of
442 + // NULL-terminated SupportedLanguage.
444 + SupportedLanguage = AllocatePool (LanguageLen + 1);
445 + CopyMem (SupportedLanguage, (VOID *) CurrentLanguage, LanguageLen);
447 + SupportedLanguage[LanguageLen] = '\0';
449 + return SupportedLanguage;
452 + // Make CurrentLangue point to the next candiate language code.
454 + CurrentLanguage += LanguageLen;
455 + if (*CurrentLanguage == ';') {
465 Index: shellenv/batch.c
466 ===================================================================
467 --- shellenv/batch.c (revision 30)
468 +++ shellenv/batch.c (working copy)
469 @@ -2074,17 +2074,17 @@
473 - // UNICODE byte-order-mark is two bytes
474 + // UNICODE byte-order-mark is 16 bits
482 // Read the first two bytes to check for byte order mark
484 - BufSize = sizeof (Buffer8);
485 - Status = File->Read (File, &BufSize, Buffer8);
486 + BufSize = sizeof (Uint16);
487 + Status = File->Read (File, &BufSize, &Uint16);
488 if (EFI_ERROR (Status)) {
491 @@ -2098,9 +2098,8 @@
492 // otherwise assume it is ASCII. UNICODE byte order mark on
493 // IA little endian is first byte 0xff and second byte 0xfe
495 - if ((Buffer8[0] | (Buffer8[1] << 8)) == EFI_UNICODE_BYTE_ORDER_MARK) {
496 + if ((BufSize == 2) && (Uint16 == EFI_UNICODE_BYTE_ORDER_MARK)) {
502 Index: shellenv/Connect.c
503 ===================================================================
504 --- shellenv/Connect.c (revision 30)
505 +++ shellenv/Connect.c (working copy)
511 + // Close proxy console before disconnect all devices.
513 + SEnvCloseConsoleProxy (
514 + ST->ConsoleInHandle,
516 + ST->ConsoleOutHandle,
520 for (Index = 0; Index < AllHandleCount; Index++) {
522 // Check whether the handle is still in handle database
523 @@ -1004,7 +1014,6 @@
526 CHAR16 *VariableName,
527 - EFI_GUID *PrimaryGuid,
528 EFI_GUID *ConsoleGuid,
529 EFI_HANDLE *ConsoleHandle,
530 VOID **ConsoleInterface
531 @@ -1018,27 +1027,36 @@
532 EFI_HANDLE *AllHandleBuffer;
535 - *ConsoleHandle = NULL;
536 - *ConsoleInterface = NULL;
538 + AllHandleBuffer = NULL;
540 DevicePath = LibGetVariable (VariableName, &gEfiGlobalVariableGuid);
541 - if (DevicePath != NULL) {
542 - SEnvConnectDevicePath (DevicePath);
543 - FreePool (DevicePath);
544 + if (DevicePath == NULL) {
546 + // If no any device defined in EFI variable, do nothing
551 - AllHandleBuffer = NULL;
552 - Status = BS->LocateHandleBuffer (
559 - if (!EFI_ERROR (Status) && AllHandleCount > 0) {
560 - *ConsoleHandle = AllHandleBuffer[0];
561 - } else if (*ConsoleHandle == NULL) {
563 + // Connect all console devices
565 + SEnvConnectDevicePath (DevicePath);
566 + FreePool (DevicePath);
568 + Status = EFI_NOT_FOUND;
570 + // Check ConsoleHandle validation whatever it was updated or not.
572 + if (*ConsoleHandle != NULL) {
573 + Status = BS->HandleProtocol (
580 + if (EFI_ERROR (Status)) {
581 AllHandleBuffer = NULL;
582 Status = BS->LocateHandleBuffer (
584 @@ -1063,16 +1081,16 @@
585 &gEfiDevicePathProtocolGuid,
588 - if (EFI_ERROR (Status)) {
589 + if (!EFI_ERROR (Status)) {
590 ConsoleIndex = Index;
595 + *ConsoleHandle = AllHandleBuffer[ConsoleIndex];
599 - *ConsoleHandle = AllHandleBuffer[ConsoleIndex];
601 if (*ConsoleHandle != NULL) {
604 @@ -1081,7 +1099,7 @@
608 - if (AllHandleBuffer) {
609 + if (AllHandleBuffer != NULL) {
610 FreePool (AllHandleBuffer);
613 @@ -1189,8 +1207,7 @@
617 - // Check current ConIn and ConOut to ensure it is the ConsoleProxy
618 - // Otherwise, the Console should not be close
619 + // Check current ConIn and ConOut to judge it is the ConsoleProxy
621 Status = SEnvCheckConsoleProxy (
623 @@ -1203,23 +1220,21 @@
624 // Indicate the Console is replaced by redirection operation
625 // It is not safe to connect Console here
627 - if (EFI_ERROR (Status)) {
629 + if (!EFI_ERROR (Status)) {
631 + // It is proxy console, to prevent the proxy console form being restored to original console,
632 + // close it temporary before connect all console
634 + SEnvCloseConsoleProxy (
635 + ST->ConsoleInHandle,
637 + ST->ConsoleOutHandle,
642 - // To prevent the proxy console form being restored to original console,
643 - // close it temporary before connect all console
645 - SEnvCloseConsoleProxy (
646 - ST->ConsoleInHandle,
648 - ST->ConsoleOutHandle,
654 - &gEfiPrimaryStandardErrorDeviceGuid,
655 &gEfiSimpleTextOutProtocolGuid,
656 &ST->StandardErrorHandle,
657 (VOID **) &ST->StdErr
658 @@ -1227,7 +1242,6 @@
662 - &gEfiPrimaryConsoleOutDeviceGuid,
663 &gEfiSimpleTextOutProtocolGuid,
664 &ST->ConsoleOutHandle,
665 (VOID **) &ST->ConOut
666 @@ -1235,7 +1249,6 @@
670 - &gEfiPrimaryConsoleInDeviceGuid,
671 &gEfiSimpleTextInProtocolGuid,
672 &ST->ConsoleInHandle,
674 @@ -1254,6 +1267,8 @@
683 Index: SmbiosView/PrintInfo.c
684 ===================================================================
685 --- SmbiosView/PrintInfo.c (revision 30)
686 +++ SmbiosView/PrintInfo.c (working copy)
687 @@ -1779,7 +1779,7 @@
689 // MaxSize is determined by follow formula
691 - MaxSize = 1 << Size;
692 + MaxSize = (UINTN) 1 << Size;
693 PrintToken (STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ONE_VAR_MB), HiiHandle, MaxSize);
695 if (Option >= SHOW_DETAIL) {
696 Index: SmbiosView/Smbios.h
697 ===================================================================
698 --- SmbiosView/Smbios.h (revision 30)
699 +++ SmbiosView/Smbios.h (working copy)
702 extern EFI_HII_HANDLE HiiHandle;
704 -#define EFI_SMBIOS_TABLE_GUID \
706 - 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
709 -extern EFI_GUID gEfiSmbiosTableGuid;