]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
Update the code of processing device path info in browser to follow UEFI spec.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Ui.c
index 4e83c8fae50ba1b6654978febbbd76bae8cffc2a..8ff90e144069102bcaf3966517ada72ce827e5e0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Utility functions for User Interface functions.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2013, 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
@@ -1970,55 +1970,6 @@ FormSetGuidToHiiHandle (
   return HiiHandle;\r
 }\r
 \r
-/**\r
-  Transfer the device path string to binary format.\r
-\r
-  @param   StringPtr     The device path string info.\r
-\r
-  @retval  Device path binary info.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-ConvertDevicePathFromText (\r
-  IN CHAR16  *StringPtr\r
-  )\r
-{\r
-  UINTN                           BufferSize;\r
-  EFI_DEVICE_PATH_PROTOCOL        *DevicePath;\r
-  CHAR16                          TemStr[2];\r
-  UINT8                           *DevicePathBuffer;\r
-  UINTN                           Index;\r
-  UINT8                           DigitUint8;\r
-\r
-  ASSERT (StringPtr != NULL);\r
-\r
-  BufferSize = StrLen (StringPtr) / 2;\r
-  DevicePath = AllocatePool (BufferSize);\r
-  ASSERT (DevicePath != NULL);\r
-  \r
-  //\r
-  // Convert from Device Path String to DevicePath Buffer in the reverse order.\r
-  //\r
-  DevicePathBuffer = (UINT8 *) DevicePath;\r
-  for (Index = 0; StringPtr[Index] != L'\0'; Index ++) {\r
-    TemStr[0] = StringPtr[Index];\r
-    DigitUint8 = (UINT8) StrHexToUint64 (TemStr);\r
-    if (DigitUint8 == 0 && TemStr[0] != L'0') {\r
-      //\r
-      // Invalid Hex Char as the tail.\r
-      //\r
-      break;\r
-    }\r
-    if ((Index & 1) == 0) {\r
-      DevicePathBuffer [Index/2] = DigitUint8;\r
-    } else {\r
-      DevicePathBuffer [Index/2] = (UINT8) ((DevicePathBuffer [Index/2] << 4) + DigitUint8);\r
-    }\r
-  }\r
-\r
-  return DevicePath;\r
-}\r
-\r
 /**\r
   Process the goto op code, update the info in the selection structure.\r
 \r
@@ -2064,16 +2015,32 @@ ProcessGotoOpCode (
     if (Selection->Form->ModalForm) {\r
       return Status;\r
     }\r
+\r
     //\r
     // Goto another Hii Package list\r
     //\r
-    Selection->Action = UI_ACTION_REFRESH_FORMSET;\r
-    DevicePath = ConvertDevicePathFromText (StringPtr);\r
-\r
-    Selection->Handle = DevicePathToHiiHandle (DevicePath);\r
-    FreePool (DevicePath);\r
-    FreePool (StringPtr);\r
+    if (mPathFromText != NULL) {\r
+      DevicePath = mPathFromText->ConvertTextToDevicePath(StringPtr);\r
+      if (DevicePath != NULL) {\r
+        Selection->Handle = DevicePathToHiiHandle (DevicePath);\r
+        FreePool (DevicePath);\r
+      }\r
+      FreePool (StringPtr);\r
+    } else {\r
+      //\r
+      // Not found the EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol.\r
+      //\r
+      do {\r
+        CreateDialog (4, TRUE, 0, NULL, &Key, gEmptyString, gProtocolNotFound, gPressEnter, gEmptyString);\r
+      } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
+      if (Repaint != NULL) {\r
+        *Repaint = TRUE;\r
+      }\r
+      FreePool (StringPtr);\r
+      return Status;\r
+    }\r
 \r
+    Selection->Action = UI_ACTION_REFRESH_FORMSET;\r
     if (Selection->Handle == NULL) {\r
       //\r
       // If target Hii Handle not found, exit\r