]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
fix build error on ICC compile.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / FrontPage.c
index 7513ab6d6bb19170d4a05d153493ec82e8417f6e..be3409457a827a00ee3f7dcee139f6efebaf71c4 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   FrontPage routines to handle the callbacks and browser calls\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -78,7 +78,7 @@ HII_VENDOR_DEVICE_PATH  mFrontPageHiiVendorDevicePath = {
 \r
   @retval  EFI_SUCCESS            The Results is filled with the requested values.\r
   @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.\r
-  @retval  EFI_INVALID_PARAMETER  Request is NULL, illegal syntax, or unknown name.\r
+  @retval  EFI_INVALID_PARAMETER  Request is illegal syntax, or unknown name.\r
   @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.\r
 \r
 **/\r
@@ -91,7 +91,7 @@ FakeExtractConfig (
   OUT EFI_STRING                             *Results\r
   )\r
 {\r
-  if (Request == NULL || Progress == NULL || Results == NULL) {\r
+  if (Progress == NULL || Results == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   *Progress = Request;\r
@@ -173,6 +173,13 @@ FrontPageCallback (
   CHAR8                         *PlatformSupportedLanguages;\r
   CHAR8                         *BestLanguage;\r
 \r
+  if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {\r
+    //\r
+    // Do nothing for UEFI OPEN/CLOSE Action\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
   if ((Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -436,7 +443,7 @@ InitializeFrontPage (
 \r
     if (FirstFlag) {\r
       StringBuffer = HiiGetString (HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, Lang);\r
-      ASSERT_EFI_ERROR (StringBuffer != NULL);\r
+      ASSERT (StringBuffer != NULL);\r
 \r
       //\r
       // Save the string Id for each language\r
@@ -534,7 +541,7 @@ CallFrontPage (
                             &ActionRequest\r
                             );\r
   //\r
-  // Check whether user  change any option setting which needs a reset to be effective\r
+  // Check whether user change any option setting which needs a reset to be effective\r
   //\r
   if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {\r
     EnableResetRequired ();\r
@@ -656,51 +663,31 @@ GetOptionalStringByIndex (
   OUT     CHAR16                  **String\r
   )\r
 {\r
-  UINT8          StrNum;\r
-  UINTN          CurrentStrLen;\r
-  CHAR8*         CharInStr;\r
-  EFI_STATUS     Status;\r
+  UINTN          StrSize;\r
 \r
-  StrNum        = 0;\r
-  Status        = EFI_NOT_FOUND;\r
-  CharInStr     = OptionalStrStart;\r
+  if (Index == 0) {\r
+    *String = AllocateZeroPool (sizeof (CHAR16));\r
+    return EFI_SUCCESS;\r
+  }\r
 \r
-  if (Index != 1) {\r
-    CurrentStrLen = 0;\r
+  StrSize = 0;\r
+  do {\r
+    Index--;\r
+    OptionalStrStart += StrSize;\r
+    StrSize           = AsciiStrSize (OptionalStrStart);\r
+  } while (OptionalStrStart[StrSize] != 0 && Index != 0);\r
+\r
+  if ((Index != 0) || (StrSize == 1)) {\r
     //\r
-    // look for the two consecutive zeros, check the string limit by the way.\r
+    // Meet the end of strings set but Index is non-zero, or\r
+    // Find an empty string\r
     //\r
-    while (*CharInStr != 0 || *(CharInStr+1) != 0) { \r
-      if (*CharInStr == 0) {\r
-        StrNum += 1;\r
-        CharInStr++;\r
-      }\r
-  \r
-      if (StrNum == Index) {\r
-        Status = EFI_SUCCESS;\r
-        break;\r
-      }\r
-  \r
-      CurrentStrLen = AsciiStrLen(CharInStr);\r
-  \r
-      //\r
-      // forward the pointer\r
-      //\r
-      OptionalStrStart = CharInStr;\r
-      CharInStr += CurrentStrLen;\r
-    }\r
-  \r
-    if (EFI_ERROR (Status)) {\r
-      *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
-      return Status;\r
-    }\r
+    *String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));\r
   } else {\r
-    CurrentStrLen = AsciiStrLen(CharInStr);\r
+    *String = AllocatePool (StrSize * sizeof (CHAR16));\r
+    AsciiStrToUnicodeStr (OptionalStrStart, *String);\r
   }\r
 \r
-  *String = AllocatePool((CurrentStrLen + 1)*sizeof(CHAR16));\r
-  AsciiStrToUnicodeStr(OptionalStrStart, *String);\r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -749,7 +736,7 @@ UpdateFrontPageStrings (
     if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {\r
       Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;\r
       StrIndex = Type0Record->BiosVersion;\r
-      GetOptionalStringByIndex ((CHAR8*)(Type0Record+1), StrIndex, &NewString);\r
+      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);\r
       TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);\r
       HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
       FreePool (NewString);\r
@@ -759,7 +746,7 @@ UpdateFrontPageStrings (
     if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {\r
       Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;\r
       StrIndex = Type1Record->ProductName;\r
-      GetOptionalStringByIndex ((CHAR8*)(Type1Record+1), StrIndex, &NewString);\r
+      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);\r
       TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);\r
       HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
       FreePool (NewString);\r
@@ -769,7 +756,7 @@ UpdateFrontPageStrings (
     if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {\r
       Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;\r
       StrIndex = Type4Record->ProcessorVersion;\r
-      GetOptionalStringByIndex ((CHAR8*)(Type4Record+1), StrIndex, &NewString);\r
+      GetOptionalStringByIndex ((CHAR8*)((UINT8*)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);\r
       TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);\r
       HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);\r
       FreePool (NewString);\r
@@ -871,7 +858,7 @@ WaitForSingleEvent (
   @param   TimeoutDefault  The fault time out value before the system continue to boot.\r
 \r
   @retval  EFI_SUCCESS       User pressed some key except "Enter"\r
-  @retval  EFI_TIME_OUT      Timout expired or user press "Enter"\r
+  @retval  EFI_TIME_OUT      Timeout expired or user press "Enter"\r
 \r
 **/\r
 EFI_STATUS\r
@@ -965,7 +952,7 @@ ShowProgress (
   @param TimeoutDefault     The fault time out value before the system\r
                             continue to boot.\r
   @param ConnectAllHappened The indicater to check if the connect all have\r
-                            already happended.\r
+                            already happened.\r
 \r
 **/\r
 VOID\r
@@ -1015,11 +1002,11 @@ PlatformBdsEnterFrontPage (
 \r
     //\r
     // If gCallbackKey is greater than 1 and less or equal to 5,\r
-    // it will lauch configuration utilities.\r
+    // it will launch configuration utilities.\r
     // 2 = set language\r
     // 3 = boot manager\r
     // 4 = device manager\r
-    // 5 = boot maintainenance manager\r
+    // 5 = boot maintenance manager\r
     //\r
     if (gCallbackKey != 0) {\r
       REPORT_STATUS_CODE (\r
@@ -1062,7 +1049,7 @@ PlatformBdsEnterFrontPage (
       // Display the Device Manager\r
       //\r
       do {\r
-        CallDeviceManager();\r
+        CallDeviceManager ();\r
       } while (gCallbackKey == FRONT_PAGE_KEY_DEVICE_MANAGER);\r
       break;\r
 \r