Revision: 16571
          http://sourceforge.net/p/edk2/code/16571
Author:   lersek
Date:     2015-01-02 12:08:02 +0000 (Fri, 02 Jan 2015)
Log Message:
-----------
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 <[email protected]>
Acked-by: Jordan Justen <[email protected]>

Modified Paths:
--------------
    trunk/edk2/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
    trunk/edk2/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
    trunk/edk2/OvmfPkg/OvmfPkg.dec

Modified: trunk/edk2/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
===================================================================
--- trunk/edk2/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c      
2015-01-02 12:07:57 UTC (rev 16570)
+++ trunk/edk2/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c      
2015-01-02 12:08:02 UTC (rev 16571)
@@ -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 @@
 
 /**
 
-  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 @@
 **/
 STATIC
 RETURN_STATUS
-TranslateOfwNodes (
+TranslatePciOfwNodes (
   IN      CONST OFW_NODE *OfwNode,
   IN      UINTN          NumNodes,
   OUT     CHAR16         *Translated,
@@ -585,7 +585,7 @@
   //
   // 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 @@
 
 /**
 
+  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 @@
           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);
           }
         }
 

Modified: trunk/edk2/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
===================================================================
--- trunk/edk2/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf    
2015-01-02 12:07:57 UTC (rev 16570)
+++ trunk/edk2/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf    
2015-01-02 12:08:02 UTC (rev 16571)
@@ -51,3 +51,6 @@
 
 [Guids]
   gEfiGlobalVariableGuid
+
+[FeaturePcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation

Modified: trunk/edk2/OvmfPkg/OvmfPkg.dec
===================================================================
--- trunk/edk2/OvmfPkg/OvmfPkg.dec      2015-01-02 12:07:57 UTC (rev 16570)
+++ trunk/edk2/OvmfPkg/OvmfPkg.dec      2015-01-02 12:08:02 UTC (rev 16571)
@@ -103,3 +103,4 @@
 
 [PcdsFeatureFlag]
   gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3
+  gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0x1c


------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to