diff options
author | Laszlo Ersek <lersek@redhat.com> | 2015-01-02 12:08:02 +0000 |
---|---|---|
committer | lersek <lersek@Edk2> | 2015-01-02 12:08:02 +0000 |
commit | 2f9c55cc1d00c075c20dc196699eb8f0d6029069 (patch) | |
tree | fe50fa65a427c4dfa6348b1f5325b30855db92f9 /OvmfPkg | |
parent | cca7475bcbb8bfc7c732e106692a6d15e1dae51c (diff) | |
download | edk2-2f9c55cc1d00c075c20dc196699eb8f0d6029069.tar.gz edk2-2f9c55cc1d00c075c20dc196699eb8f0d6029069.tar.bz2 edk2-2f9c55cc1d00c075c20dc196699eb8f0d6029069.zip |
OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation
In preparation for adding OpenFirmware-to-UEFI translation for "MMIO-like"
OFW device path fragments, let's turn the currently exclusive "PCI-like"
translation into "just one" of the possible translations.
- Rename TranslateOfwNodes() to TranslatePciOfwNodes(), because it is
tightly coupled to "PCI-like" translations.
- Rename REQUIRED_OFW_NODES to REQUIRED_PCI_OFW_NODES, because this macro
is specific to TranslatePciOfwNodes().
- Introduce a new wrapper function under the original TranslateOfwNodes()
name. This function is supposed to try translations in some order until
a specific translation returns a status different from
RETURN_UNSUPPORTED.
- Introduce a new Feature PCD that controls whether PCI translation is
attempted at all.
- The boot option "survival policy" in BootOrderComplete() must take into
account if the user was able to select PCI-like boot options. If the
user had no such possibility (because the Feature PCD was off for
PCI-like translation), then we ought to keep any such unselected boot
options.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16571 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg')
-rw-r--r-- | OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c | 68 | ||||
-rw-r--r-- | OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf | 3 | ||||
-rw-r--r-- | OvmfPkg/OvmfPkg.dec | 1 |
3 files changed, 65 insertions, 7 deletions
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c index 2ff6854430..174fd1f554 100644 --- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c +++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c @@ -35,8 +35,8 @@ /**
Numbers of nodes in OpenFirmware device paths that are required and examined.
**/
-#define REQUIRED_OFW_NODES 2
-#define EXAMINED_OFW_NODES 4
+#define REQUIRED_PCI_OFW_NODES 2
+#define EXAMINED_OFW_NODES 4
/**
@@ -539,7 +539,7 @@ ParseOfwNode ( /**
- Translate an array of OpenFirmware device nodes to a UEFI device path
+ Translate a PCI-like array of OpenFirmware device nodes to a UEFI device path
fragment.
@param[in] OfwNode Array of OpenFirmware device nodes to
@@ -571,7 +571,7 @@ ParseOfwNode ( **/
STATIC
RETURN_STATUS
-TranslateOfwNodes (
+TranslatePciOfwNodes (
IN CONST OFW_NODE *OfwNode,
IN UINTN NumNodes,
OUT CHAR16 *Translated,
@@ -585,7 +585,7 @@ TranslateOfwNodes ( //
// Get PCI device and optional PCI function. Assume a single PCI root.
//
- if (NumNodes < REQUIRED_OFW_NODES ||
+ if (NumNodes < REQUIRED_PCI_OFW_NODES ||
!SubstringEq (OfwNode[0].DriverName, "pci")
) {
return RETURN_UNSUPPORTED;
@@ -803,6 +803,58 @@ TranslateOfwNodes ( /**
+ Translate an array of OpenFirmware device nodes to a UEFI device path
+ fragment.
+
+ @param[in] OfwNode Array of OpenFirmware device nodes to
+ translate, constituting the beginning of an
+ OpenFirmware device path.
+
+ @param[in] NumNodes Number of elements in OfwNode.
+
+ @param[out] Translated Destination array receiving the UEFI path
+ fragment, allocated by the caller. If the
+ return value differs from RETURN_SUCCESS, its
+ contents is indeterminate.
+
+ @param[in out] TranslatedSize On input, the number of CHAR16's in
+ Translated. On RETURN_SUCCESS this parameter
+ is assigned the number of non-NUL CHAR16's
+ written to Translated. In case of other return
+ values, TranslatedSize is indeterminate.
+
+
+ @retval RETURN_SUCCESS Translation successful.
+
+ @retval RETURN_BUFFER_TOO_SMALL The translation does not fit into the number
+ of bytes provided.
+
+ @retval RETURN_UNSUPPORTED The array of OpenFirmware device nodes can't
+ be translated in the current implementation.
+
+**/
+STATIC
+RETURN_STATUS
+TranslateOfwNodes (
+ IN CONST OFW_NODE *OfwNode,
+ IN UINTN NumNodes,
+ OUT CHAR16 *Translated,
+ IN OUT UINTN *TranslatedSize
+ )
+{
+ RETURN_STATUS Status;
+
+ Status = RETURN_UNSUPPORTED;
+
+ if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) {
+ Status = TranslatePciOfwNodes (OfwNode, NumNodes, Translated,
+ TranslatedSize);
+ }
+ return Status;
+}
+
+/**
+
Translate an OpenFirmware device path fragment to a UEFI device path
fragment, and advance in the input string.
@@ -1083,9 +1135,11 @@ BootOrderComplete ( if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST &&
EISA_ID_TO_NUM (Acpi->HID) == 0x0a03) {
//
- // drop PciRoot()
+ // drop PciRoot() if we enabled the user to select PCI-like boot
+ // options, by providing translation for such OFW device path
+ // fragments
//
- Keep = FALSE;
+ Keep = !FeaturePcdGet (PcdQemuBootOrderPciTranslation);
}
}
diff --git a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf index 12419cda09..5aa4e6eff0 100644 --- a/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf +++ b/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf @@ -51,3 +51,6 @@ [Guids]
gEfiGlobalVariableGuid
+
+[FeaturePcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index e1d2731cab..011fda6045 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -103,3 +103,4 @@ [PcdsFeatureFlag]
gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3
+ gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c
|