Reviewed-by: Liming Gao <liming....@intel.com>

From: Bi, Dandan
Sent: Tuesday, June 16, 2015 9:17 AM
To: 'edk2-devel@lists.sourceforge.net'; Dong, Eric; Gao, Liming
Subject: [patch] MdeModulePkg:System hangs in setup menu when RTC time rollover 
1999 to 2000

Error processing of GetTime function:
If get time fail,the date/time will display ??,
and update help info to let user know get time fail.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com<mailto:dandan...@intel.com>>
---
.../Universal/DisplayEngineDxe/FormDisplay.c       |  23 +++++++++++--
.../Universal/DisplayEngineDxe/FormDisplayStr.uni  | Bin 16664 -> 17032 bytes
.../Universal/DisplayEngineDxe/ProcessOptions.c    |  38 +++++++++++++++++----
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c     |  11 +++++-
4 files changed, 62 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c 
b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
index e198a5e..9f50f83 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
@@ -2543,10 +2543,12 @@ UiDisplayMenu (
   UINTN                           Temp2;
   UINTN                           TopRow;
   UINTN                           BottomRow;
   UINTN                           Index;
   CHAR16                          *StringPtr;
+  CHAR16                          *StringRightPtr;
+  CHAR16                          *StringErrorPtr;
   CHAR16                          *OptionString;
   CHAR16                          *HelpString;
   CHAR16                          *HelpHeaderString;
   CHAR16                          *HelpBottomString;
   BOOLEAN                         NewLine;
@@ -2577,10 +2579,11 @@ UiDisplayMenu (
   UINT16                          HeaderLineWidth;
   UINT16                          BottomLineWidth;
   EFI_STRING_ID                   HelpInfo;
   UI_EVENT_TYPE                   EventType;
   BOOLEAN                         SkipHighLight;
+  EFI_HII_VALUE                   *StatementValue;

   EventType           = UIEventNone;
   Status              = EFI_SUCCESS;
   HelpString          = NULL;
   HelpHeaderString    = NULL;
@@ -2883,14 +2886,30 @@ UiDisplayMenu (
           //
           // Don't print anything if it is a NULL help token
           //
           ASSERT(MenuOption != NULL);
           HelpInfo = ((EFI_IFR_STATEMENT_HEADER *) ((CHAR8 
*)MenuOption->ThisTag->OpCode + sizeof (EFI_IFR_OP_HEADER)))->Help;
+          Statement = MenuOption->ThisTag;
+          StatementValue = &Statement->CurrentValue;
           if (HelpInfo == 0 || !IsSelectable (MenuOption)) {
-            StringPtr = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle);
+            if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP && 
StatementValue->Value.date.Month== 0xff)||(Statement->OpCode->OpCode == 
EFI_IFR_TIME_OP && StatementValue->Value.time.Hour == 0xff)){
+              StringPtr = GetToken (STRING_TOKEN (GET_TIME_FAIL), gHiiHandle);
+            } else {
+              StringPtr = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle);
+            }
           } else {
-            StringPtr = GetToken (HelpInfo, gFormData->HiiHandle);
+            if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP && 
StatementValue->Value.date.Month== 0xff)||(Statement->OpCode->OpCode == 
EFI_IFR_TIME_OP && StatementValue->Value.time.Hour == 0xff)){
+              StringRightPtr = GetToken (HelpInfo, gFormData->HiiHandle);
+              StringErrorPtr = GetToken (STRING_TOKEN (GET_TIME_FAIL), 
gHiiHandle);
+              StringPtr = AllocateZeroPool ((StrLen (StringRightPtr) + StrLen 
(StringErrorPtr)+ 1 ) * sizeof (CHAR16));
+              StrCpyS (StringPtr, StrLen (StringRightPtr) + StrLen 
(StringErrorPtr) + 1, StringRightPtr);
+              StrCatS (StringPtr, StrLen (StringRightPtr) + StrLen 
(StringErrorPtr) + 1, StringErrorPtr);
+              FreePool (StringRightPtr);
+              FreePool (StringErrorPtr);
+            } else {
+              StringPtr = GetToken (HelpInfo, gFormData->HiiHandle);
+            }
           }
         }

         RowCount      = BottomRow - TopRow + 1;
         HelpPageIndex = 0;
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplayStr.uni 
b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplayStr.uni
index 
2a06c3d495b308b7b41767f408b72b62594a4c67..5c6ad48433b2c6f50016dc27a5801da90930e76f
 100644
GIT binary patch
delta 178
zcmbQy#MsfwxIw~kvVfh4q&tHvLkL4W5PLHC0@?8lZVZk<w$J23F;9C126u*3h7tw^
zh7^WGAf3vf4<s`ga)B%bhBTm9CPNN`4p=^up_rin$V+6X1oG{HP;WA$K&2D98HuEs
I!Jxzd05(V<l>h($

delta 9
QcmeBZWt`E(xIw}Z01=-9GXMYp

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c 
b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
index 84ae03e..52dc5f2 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c
@@ -1,10 +1,10 @@
/** @file
Implementation for handling the User Interface option processing.


-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD 
License
which accompanies this distribution.  The full text of the license may be found 
at
http://opensource.org/licenses/bsd-license.php

@@ -1276,23 +1276,35 @@ ProcessOptions (
       ASSERT (*OptionString);

       switch (MenuOption->Sequence) {
       case 0:
         *OptionString[0] = LEFT_NUMERIC_DELIMITER;
-        UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.date.Month);
+        if (QuestionValue->Value.date.Month == 0xff){
+          UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"??");
+        } else {
+          UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.date.Month);
+        }
         *(OptionString[0] + 3) = DATE_SEPARATOR;
         break;

       case 1:
         SetUnicodeMem (OptionString[0], 4, L' ');
-        UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.date.Day);
+        if (QuestionValue->Value.date.Day == 0xff){
+          UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"??");
+        } else {
+          UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.date.Day);
+        }
         *(OptionString[0] + 6) = DATE_SEPARATOR;
         break;

       case 2:
         SetUnicodeMem (OptionString[0], 7, L' ');
-        UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%04d", 
QuestionValue->Value.date.Year);
+        if (QuestionValue->Value.date.Year == 0xff){
+          UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"????");
+        } else {
+          UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%04d", 
QuestionValue->Value.date.Year);
+        }
         *(OptionString[0] + 11) = RIGHT_NUMERIC_DELIMITER;
         break;
       }
     }
     break;
@@ -1308,23 +1320,35 @@ ProcessOptions (
       ASSERT (*OptionString);

       switch (MenuOption->Sequence) {
       case 0:
         *OptionString[0] = LEFT_NUMERIC_DELIMITER;
-        UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.time.Hour);
+        if (QuestionValue->Value.time.Hour == 0xff){
+          UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"??");
+        } else {
+          UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.time.Hour);
+        }
         *(OptionString[0] + 3) = TIME_SEPARATOR;
         break;

       case 1:
         SetUnicodeMem (OptionString[0], 4, L' ');
-        UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.time.Minute);
+        if (QuestionValue->Value.time.Minute == 0xff){
+          UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"??");
+        } else {
+          UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.time.Minute);
+        }
         *(OptionString[0] + 6) = TIME_SEPARATOR;
         break;

       case 2:
         SetUnicodeMem (OptionString[0], 7, L' ');
-        UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.time.Second);
+        if (QuestionValue->Value.time.Second == 0xff){
+          UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"??");
+        } else {
+          UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%02d", 
QuestionValue->Value.time.Second);
+        }
         *(OptionString[0] + 9) = RIGHT_NUMERIC_DELIMITER;
         break;
       }
     }
     break;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c 
b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
index 4d28617..b153dd4 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
@@ -1593,11 +1593,20 @@ GetQuestionValue (
         //
         return EFI_SUCCESS;
       }

       if (EFI_ERROR (Status)) {
-        return Status;
+        if (Question->Operand == EFI_IFR_DATE_OP){
+          QuestionValue->date.Year  = 0xff;
+          QuestionValue->date.Month = 0xff;
+          QuestionValue->date.Day   = 0xff;
+        } else {
+          QuestionValue->time.Hour   = 0xff;
+          QuestionValue->time.Minute = 0xff;
+          QuestionValue->time.Second = 0xff;
+        }
+        return EFI_SUCCESS;
       }

       if (Question->Operand == EFI_IFR_DATE_OP) {
         QuestionValue->date.Year  = EfiTime.Year;
         QuestionValue->date.Month = EfiTime.Month;
--
1.9.5.msysgit.1
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to