Revision: 14665
http://sourceforge.net/p/edk2/code/14665
Author: jljusten
Date: 2013-09-13 08:14:36 +0000 (Fri, 13 Sep 2013)
Log Message:
-----------
OvmfPkg: QemuBootOrder: expand relative device paths in UEFI boot options
The prefix matching logic in Match()
[OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c] expects UEFI boot options
to specify full (absolute) device paths. However, partial (relative)
device paths starting with a HD() node are valid for booting. By not
recognizing them, QemuBootOrder.c misses (and deletes) valid boot options
that would otherwise match the user's preference.
Just like BdsLibBootViaBootOption() expands such paths with the
BdsExpandPartitionPartialDevicePathToFull() function for booting, do the
same in QemuBootOrder.c for prefix matching.
This moves the very first call to
BdsExpandPartitionPartialDevicePathToFull() to an earlier point. The
following call tree explains it:
BdsEntry()
[IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c]
PlatformBdsPolicyBehavior()
[OvmfPkg/Library/PlatformBdsLib/BdsPlatform.c]
SetBootOrderFromQemu()
[OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c]
Match()
[OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c]
BdsExpandPartitionPartialDevicePathToFull()
[IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c]
BdsBootDeviceSelect()
[IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c]
BdsLibBootViaBootOption()
[IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c]
BdsExpandPartitionPartialDevicePathToFull()
[IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c]
This should be fine, for two reasons:
- the new, earlier call is still under BdsEntry(),
- BdsExpandPartitionPartialDevicePathToFull() expects to be called
repeatedly, even with the same set of HD() device paths. This function
implements its own caching for device paths, likely for performance
reasons.
That fits this patch well because whatever device paths we expand under
PlatformBdsPolicyBehavior() can be quickly looked up in
BdsBootDeviceSelect(), so no work (ie.
BdsLibConnectAllDriversToAllControllers()) should be wasted.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
Tested-by: Michael Chang <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Modified Paths:
--------------
trunk/edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
Modified: trunk/edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
===================================================================
--- trunk/edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c 2013-09-13
00:46:19 UTC (rev 14664)
+++ trunk/edk2/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c 2013-09-13
08:14:36 UTC (rev 14665)
@@ -882,6 +882,34 @@
}
//
+ // Attempt to expand any relative UEFI device path starting with HD() to an
+ // absolute device path first. The logic imitates BdsLibBootViaBootOption().
+ // We don't have to free the absolute device path,
+ // BdsExpandPartitionPartialDevicePathToFull() has internal caching.
+ //
+ Result = FALSE;
+ if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (DevicePath) == MEDIA_HARDDRIVE_DP) {
+ EFI_DEVICE_PATH_PROTOCOL *AbsDevicePath;
+ CHAR16 *AbsConverted;
+
+ AbsDevicePath = BdsExpandPartitionPartialDevicePathToFull (
+ (HARDDRIVE_DEVICE_PATH *) DevicePath);
+ if (AbsDevicePath == NULL) {
+ goto Exit;
+ }
+ AbsConverted = ConvertDevicePathToText (AbsDevicePath, FALSE, FALSE);
+ if (AbsConverted == NULL) {
+ goto Exit;
+ }
+ DEBUG ((DEBUG_VERBOSE,
+ "%a: expanded relative device path \"%s\" for prefix matching\n",
+ __FUNCTION__, Converted));
+ FreePool (Converted);
+ Converted = AbsConverted;
+ }
+
+ //
// Is Translated a prefix of Converted?
//
Result = (BOOLEAN)(StrnCmp (Converted, Translated, TranslatedLength) == 0);
@@ -892,6 +920,7 @@
Converted,
Result ? "match" : "no match"
));
+Exit:
FreePool (Converted);
return Result;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. Consolidate legacy IT systems to a single system of record for IT
2. Standardize and globalize service processes across IT
3. Implement zero-touch automation to replace manual, redundant tasks
http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits