]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
Refine code to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / DriverSampleDxe / DriverSample.c
index 854a5a729156812e6f311c0546fa8a879009e1ea..3ae55de2b0dd36adbd6efddc384d25fad7c71e15 100644 (file)
@@ -2,7 +2,7 @@
 This is an example of how a driver might export data to the HII protocol to be\r
 later utilized by the Setup Protocol\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
@@ -1766,44 +1766,6 @@ DriverCallback (
   return Status;\r
 }\r
 \r
-\r
-/**\r
-  Transfer the binary device path to string.\r
-\r
-  @param   DevicePath     The device path info.\r
-\r
-  @retval  Device path string info.\r
-\r
-**/\r
-CHAR16  *\r
-GenerateDevicePathString (\r
-  EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
-  )\r
-{\r
-  CHAR16                    *String;\r
-  CHAR16                    *TmpBuf;\r
-  UINTN                     Index;\r
-  UINT8                     *Buffer;\r
-  UINTN                     DevicePathSize;\r
-\r
-  //\r
-  // Compute the size of the device path in bytes\r
-  //\r
-  DevicePathSize = GetDevicePathSize (DevicePath);\r
-  \r
-  String = AllocateZeroPool ((DevicePathSize * 2 + 1) * sizeof (CHAR16));\r
-  if (String == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  TmpBuf = String;\r
-  for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) {\r
-    TmpBuf += UnicodeValueToString (TmpBuf, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2);\r
-  }\r
-\r
-  return String;\r
-}\r
-\r
 /**\r
   Main entry for this driver.\r
 \r
@@ -1835,12 +1797,14 @@ DriverSampleInit (
   MY_EFI_VARSTORE_DATA            *VarStoreConfig;\r
   EFI_INPUT_KEY                   HotKey;\r
   EFI_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx;\r
+  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *PathToText;\r
 \r
   //\r
   // Initialize the local variables.\r
   //\r
   ConfigRequestHdr = NULL;\r
   NewString        = NULL;\r
+  PathToText       = NULL;\r
 \r
   //\r
   // Initialize screen dimensions for SendForm().\r
@@ -1957,11 +1921,18 @@ DriverSampleInit (
   }\r
 \r
   PrivateData->HiiHandle[1] = HiiHandle[1];\r
\r
+  Status = gBS->LocateProtocol (\r
+                  &gEfiDevicePathToTextProtocolGuid,\r
+                  NULL,\r
+                  (VOID **) &PathToText\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
   // Update the device path string.\r
   //\r
-  NewString = GenerateDevicePathString((EFI_DEVICE_PATH_PROTOCOL*)&mHiiVendorDevicePath0);\r
+  NewString = PathToText->ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL*)&mHiiVendorDevicePath0, FALSE, FALSE);\r
   if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_DEVICE_PATH), NewString, NULL) == 0) {\r
     DriverSampleUnload (ImageHandle);\r
     return EFI_OUT_OF_RESOURCES;\r