]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: QemuBootOrderLib: featurize PCI-like device path translation
authorLaszlo Ersek <lersek@redhat.com>
Fri, 2 Jan 2015 12:08:02 +0000 (12:08 +0000)
committerlersek <lersek@Edk2>
Fri, 2 Jan 2015 12:08:02 +0000 (12:08 +0000)
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

OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
OvmfPkg/OvmfPkg.dec

index 2ff6854430ebef2e99fac333cd25b30042d02563..174fd1f5541191c294f5ac18e2d71003d841adcf 100644 (file)
@@ -35,8 +35,8 @@
 /**\r
   Numbers of nodes in OpenFirmware device paths that are required and examined.\r
 **/\r
-#define REQUIRED_OFW_NODES 2\r
-#define EXAMINED_OFW_NODES 4\r
+#define REQUIRED_PCI_OFW_NODES  2\r
+#define EXAMINED_OFW_NODES      4\r
 \r
 \r
 /**\r
@@ -539,7 +539,7 @@ ParseOfwNode (
 \r
 /**\r
 \r
-  Translate an array of OpenFirmware device nodes to a UEFI device path\r
+  Translate a PCI-like array of OpenFirmware device nodes to a UEFI device path\r
   fragment.\r
 \r
   @param[in]     OfwNode         Array of OpenFirmware device nodes to\r
@@ -571,7 +571,7 @@ ParseOfwNode (
 **/\r
 STATIC\r
 RETURN_STATUS\r
-TranslateOfwNodes (\r
+TranslatePciOfwNodes (\r
   IN      CONST OFW_NODE *OfwNode,\r
   IN      UINTN          NumNodes,\r
   OUT     CHAR16         *Translated,\r
@@ -585,7 +585,7 @@ TranslateOfwNodes (
   //\r
   // Get PCI device and optional PCI function. Assume a single PCI root.\r
   //\r
-  if (NumNodes < REQUIRED_OFW_NODES ||\r
+  if (NumNodes < REQUIRED_PCI_OFW_NODES ||\r
       !SubstringEq (OfwNode[0].DriverName, "pci")\r
       ) {\r
     return RETURN_UNSUPPORTED;\r
@@ -801,6 +801,58 @@ TranslateOfwNodes (
 }\r
 \r
 \r
+/**\r
+\r
+  Translate an array of OpenFirmware device nodes to a UEFI device path\r
+  fragment.\r
+\r
+  @param[in]     OfwNode         Array of OpenFirmware device nodes to\r
+                                 translate, constituting the beginning of an\r
+                                 OpenFirmware device path.\r
+\r
+  @param[in]     NumNodes        Number of elements in OfwNode.\r
+\r
+  @param[out]    Translated      Destination array receiving the UEFI path\r
+                                 fragment, allocated by the caller. If the\r
+                                 return value differs from RETURN_SUCCESS, its\r
+                                 contents is indeterminate.\r
+\r
+  @param[in out] TranslatedSize  On input, the number of CHAR16's in\r
+                                 Translated. On RETURN_SUCCESS this parameter\r
+                                 is assigned the number of non-NUL CHAR16's\r
+                                 written to Translated. In case of other return\r
+                                 values, TranslatedSize is indeterminate.\r
+\r
+\r
+  @retval RETURN_SUCCESS           Translation successful.\r
+\r
+  @retval RETURN_BUFFER_TOO_SMALL  The translation does not fit into the number\r
+                                   of bytes provided.\r
+\r
+  @retval RETURN_UNSUPPORTED       The array of OpenFirmware device nodes can't\r
+                                   be translated in the current implementation.\r
+\r
+**/\r
+STATIC\r
+RETURN_STATUS\r
+TranslateOfwNodes (\r
+  IN      CONST OFW_NODE *OfwNode,\r
+  IN      UINTN          NumNodes,\r
+  OUT     CHAR16         *Translated,\r
+  IN OUT  UINTN          *TranslatedSize\r
+  )\r
+{\r
+  RETURN_STATUS Status;\r
+\r
+  Status = RETURN_UNSUPPORTED;\r
+\r
+  if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) {\r
+    Status = TranslatePciOfwNodes (OfwNode, NumNodes, Translated,\r
+               TranslatedSize);\r
+  }\r
+  return Status;\r
+}\r
+\r
 /**\r
 \r
   Translate an OpenFirmware device path fragment to a UEFI device path\r
@@ -1083,9 +1135,11 @@ BootOrderComplete (
           if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST &&\r
               EISA_ID_TO_NUM (Acpi->HID) == 0x0a03) {\r
             //\r
-            // drop PciRoot()\r
+            // drop PciRoot() if we enabled the user to select PCI-like boot\r
+            // options, by providing translation for such OFW device path\r
+            // fragments\r
             //\r
-            Keep = FALSE;\r
+            Keep = !FeaturePcdGet (PcdQemuBootOrderPciTranslation);\r
           }\r
         }\r
 \r
index 12419cda095387f692cb37feed0aa0778c4467f6..5aa4e6eff05dfe6d24d713ef2f41dd1975079369 100644 (file)
@@ -51,3 +51,6 @@
 \r
 [Guids]\r
   gEfiGlobalVariableGuid\r
+\r
+[FeaturePcd]\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation\r
index e1d2731cab7ebd12994478e96b3c62d8c20b0fd6..011fda604528b18b36b13fa236dc129f4fa6b068 100644 (file)
 \r
 [PcdsFeatureFlag]\r
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c\r