summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/DriverSampleDxe
diff options
context:
space:
mode:
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-14 09:52:25 +0000
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>2012-08-14 09:52:25 +0000
commit33efdf51b0f123259dec0bfcff49af189b46c411 (patch)
treeca64b594e5609249f17a720ab2758342c68cbb89 /MdeModulePkg/Universal/DriverSampleDxe
parentd0bf562330e5309a92e55e44063a8ea37ead4d1d (diff)
downloadedk2-33efdf51b0f123259dec0bfcff49af189b46c411.tar.gz
edk2-33efdf51b0f123259dec0bfcff49af189b46c411.tar.bz2
edk2-33efdf51b0f123259dec0bfcff49af189b46c411.zip
Refine the logic to handle the device path info get from string token.
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@13632 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/DriverSampleDxe')
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
index a76c86791a..854a5a7291 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
@@ -1766,6 +1766,44 @@ 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.
@@ -1802,6 +1840,8 @@ DriverSampleInit (
// Initialize the local variables.
//
ConfigRequestHdr = NULL;
+ NewString = NULL;
+
//
// Initialize screen dimensions for SendForm().
// Remove 3 characters from top and bottom
@@ -1921,11 +1961,15 @@ DriverSampleInit (
//
// Update the device path string.
//
- if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_DEVICE_PATH), (EFI_STRING) &mHiiVendorDevicePath0, NULL) == 0) {
+ NewString = GenerateDevicePathString((EFI_DEVICE_PATH_PROTOCOL*)&mHiiVendorDevicePath0);
+ if (HiiSetString (HiiHandle[0], STRING_TOKEN (STR_DEVICE_PATH), NewString, NULL) == 0) {
DriverSampleUnload (ImageHandle);
return EFI_OUT_OF_RESOURCES;
}
-
+ if (NewString != NULL) {
+ FreePool (NewString);
+ }
+
//
// Very simple example of how one would update a string that is already
// in the HII database