]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c
Update all the code to consume the ConvertDevicePathToText, ConvertDevicePathNodeToTe...
[mirror_edk2.git] / OvmfPkg / Library / PlatformBdsLib / QemuBootOrder.c
index d2d60c389f0daeba1e8e4d616faaea585a87ad52..c9b8556fab0f28c8932ce78deaa3ce640b9e8225 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Rewrite the BootOrder NvVar based on QEMU's "bootorder" fw_cfg file.\r
 \r
-  Copyright (C) 2012, Red Hat, Inc.\r
+  Copyright (C) 2012 - 2013, Red Hat, Inc.\r
 \r
   This program and the accompanying materials are licensed and made available\r
   under the terms and conditions of the BSD License which accompanies this\r
@@ -20,7 +20,7 @@
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/PrintLib.h>\r
-#include <Protocol/DevicePathToText.h>\r
+#include <Library/DevicePathLib.h>\r
 #include <Guid/GlobalVariable.h>\r
 \r
 \r
@@ -677,6 +677,35 @@ TranslateOfwNodes (
       TargetLun[0],\r
       TargetLun[1]\r
       );\r
+  } else if (NumNodes >= 3 &&\r
+             SubstringEq (OfwNode[1].DriverName, "ethernet") &&\r
+             SubstringEq (OfwNode[2].DriverName, "ethernet-phy")\r
+             ) {\r
+    //\r
+    // OpenFirmware device path (Ethernet NIC):\r
+    //\r
+    //   /pci@i0cf8/ethernet@3[,2]/ethernet-phy@0\r
+    //        ^              ^                  ^\r
+    //        |              |                  fixed\r
+    //        |              PCI slot[, function] holding Ethernet card\r
+    //        PCI root at system bus port, PIO\r
+    //\r
+    // UEFI device path prefix (dependent on presence of nonzero PCI function):\r
+    //\r
+    //   PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400E15EEF,0x1)\r
+    //   PciRoot(0x0)/Pci(0x3,0x2)/MAC(525400E15EEF,0x1)\r
+    //                                 ^            ^\r
+    //                                 MAC address  IfType (1 == Ethernet)\r
+    //\r
+    // (Some UEFI NIC drivers don't set 0x1 for IfType.)\r
+    //\r
+    Written = UnicodeSPrintAsciiFormat (\r
+      Translated,\r
+      *TranslatedSize * sizeof (*Translated), // BufferSize in bytes\r
+      "PciRoot(0x0)/Pci(0x%x,0x%x)/MAC",\r
+      PciDevFun[0],\r
+      PciDevFun[1]\r
+      );\r
   } else {\r
     return RETURN_UNSUPPORTED;\r
   }\r
@@ -837,18 +866,17 @@ BOOLEAN
 Match (\r
   IN  CONST CHAR16                           *Translated,\r
   IN  UINTN                                  TranslatedLength,\r
-  IN  CONST EFI_DEVICE_PATH_PROTOCOL         *DevicePath,\r
-  IN  CONST EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText\r
+  IN  CONST EFI_DEVICE_PATH_PROTOCOL         *DevicePath\r
   )\r
 {\r
   CHAR16  *Converted;\r
   BOOLEAN Result;\r
 \r
-  Converted = DevPathToText->ConvertDevicePathToText (\r
-                               DevicePath,\r
-                               FALSE, // DisplayOnly\r
-                               FALSE  // AllowShortcuts\r
-                               );\r
+  Converted = ConvertDevicePathToText (\r
+                DevicePath,\r
+                FALSE, // DisplayOnly\r
+                FALSE  // AllowShortcuts\r
+                );\r
   if (Converted == NULL) {\r
     return FALSE;\r
   }\r
@@ -904,9 +932,6 @@ SetBootOrderFromQemu (
   )\r
 {\r
   RETURN_STATUS                    Status;\r
-\r
-  EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;\r
-\r
   FIRMWARE_CONFIG_ITEM             FwCfgItem;\r
   UINTN                            FwCfgSize;\r
   CHAR8                            *FwCfg;\r
@@ -917,15 +942,6 @@ SetBootOrderFromQemu (
   UINTN                            TranslatedSize;\r
   CHAR16                           Translated[TRANSLATION_OUTPUT_SIZE];\r
 \r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiDevicePathToTextProtocolGuid,\r
-                  NULL, // optional registration key\r
-                  (VOID **) &DevPathToText\r
-                  );\r
-  if (Status != EFI_SUCCESS) {\r
-    return Status;\r
-  }\r
-\r
   Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize);\r
   if (Status != RETURN_SUCCESS) {\r
     return Status;\r
@@ -990,8 +1006,7 @@ SetBootOrderFromQemu (
             Match (\r
               Translated,\r
               TranslatedSize, // contains length, not size, in CHAR16's here\r
-              BootOption->DevicePath,\r
-              DevPathToText\r
+              BootOption->DevicePath\r
               )\r
             ) {\r
           //\r