summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/DriverSampleDxe
diff options
context:
space:
mode:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2013-01-22 09:51:19 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2013-01-22 09:51:19 +0000
commit947a5a9ae84cba2e20536ead860c5de6e73ebc6a (patch)
treee47067d7b93d1cc29cc4d1902b47870d63b61ccf /MdeModulePkg/Universal/DriverSampleDxe
parent80a047f04a9005c37580532307d8c7c4b337fe4b (diff)
downloadedk2-947a5a9ae84cba2e20536ead860c5de6e73ebc6a.tar.gz
edk2-947a5a9ae84cba2e20536ead860c5de6e73ebc6a.tar.bz2
edk2-947a5a9ae84cba2e20536ead860c5de6e73ebc6a.zip
Refine the sample about how to convert the device path to string.
Signed-off-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14077 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/DriverSampleDxe')
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c51
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h3
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf3
3 files changed, 15 insertions, 42 deletions
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
index 854a5a7291..7c47b5fd39 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
@@ -2,7 +2,7 @@
This is an example of how a driver might export data to the HII protocol to be
later utilized by the Setup Protocol
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -1766,44 +1766,6 @@ DriverCallback (
return Status;
}
-
-/**
- Transfer the binary device path to string.
-
- @param DevicePath The device path info.
-
- @retval Device path string info.
-
-**/
-CHAR16 *
-GenerateDevicePathString (
- EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- CHAR16 *String;
- CHAR16 *TmpBuf;
- UINTN Index;
- UINT8 *Buffer;
- UINTN DevicePathSize;
-
- //
- // Compute the size of the device path in bytes
- //
- DevicePathSize = GetDevicePathSize (DevicePath);
-
- String = AllocateZeroPool ((DevicePathSize * 2 + 1) * sizeof (CHAR16));
- if (String == NULL) {
- return NULL;
- }
-
- TmpBuf = String;
- for (Index = 0, Buffer = (UINT8 *)DevicePath; Index < DevicePathSize; Index++) {
- TmpBuf += UnicodeValueToString (TmpBuf, PREFIX_ZERO | RADIX_HEX, *(Buffer++), 2);
- }
-
- return String;
-}
-
/**
Main entry for this driver.
@@ -1835,12 +1797,14 @@ DriverSampleInit (
MY_EFI_VARSTORE_DATA *VarStoreConfig;
EFI_INPUT_KEY HotKey;
EFI_FORM_BROWSER_EXTENSION_PROTOCOL *FormBrowserEx;
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *pToText;
//
// Initialize the local variables.
//
ConfigRequestHdr = NULL;
NewString = NULL;
+ pToText = NULL;
//
// Initialize screen dimensions for SendForm().
@@ -1957,11 +1921,18 @@ DriverSampleInit (
}
PrivateData->HiiHandle[1] = HiiHandle[1];
+
+ Status = gBS->LocateProtocol (
+ &gEfiDevicePathToTextProtocolGuid,
+ NULL,
+ (VOID **) &pToText
+ );
+ ASSERT_EFI_ERROR (Status);
//
// Update the device path string.
//
- NewString = GenerateDevicePathString((EFI_DEVICE_PATH_PROTOCOL*)&mHiiVendorDevicePath0);
+ NewString = pToText->ConvertDevicePathToText((EFI_DEVICE_PATH_PROTOCOL*)&mHiiVendorDevicePath0, FALSE, FALSE);
if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_DEVICE_PATH), NewString, NULL) == 0) {
DriverSampleUnload (ImageHandle);
return EFI_OUT_OF_RESOURCES;
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
index 07ace64852..cd546bf388 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2013, 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
@@ -32,6 +32,7 @@ Revision History
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiString.h>
#include <Protocol/FormBrowserEx.h>
+#include <Protocol/DevicePathToText.h>
#include <Guid/MdeModuleHii.h>
#include <Library/DebugLib.h>
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
index bcc157442e..36511e66d0 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
@@ -2,7 +2,7 @@
# This is a sample driver which show how HII protocol, VFR and UNI files are used to
# create a driver which can be dipslayed and configured by a UEFI HII Form Browser.
#
-# Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2013, 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
@@ -70,6 +70,7 @@
gEfiHiiDatabaseProtocolGuid ## CONSUMES
gEfiSimpleTextInputExProtocolGuid ## CONSUMES
gEfiFormBrowserExProtocolGuid ## CONSUMES
+ gEfiDevicePathToTextProtocolGuid ## CONSUMES
[Depex]
gEfiSimpleTextOutProtocolGuid AND gEfiHiiDatabaseProtocolGuid AND gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid