]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update GenericBdsLib to support BootOption for VLAN device.
authorxdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 30 Dec 2009 13:52:19 +0000 (13:52 +0000)
committerxdu2 <xdu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 30 Dec 2009 13:52:19 +0000 (13:52 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9650 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c
IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
IntelFrameworkModulePkg/Library/GenericBdsLib/InternalBdsLib.h

index c022c15ee015b0bc18533bb3e96a743666a2bb49..309bc60758270b6872f84698ae66d890e11a5e8d 100644 (file)
@@ -986,8 +986,8 @@ BdsLibEnumerateAllBootOption (
   EFI_HANDLE                    *BlockIoHandles;\r
   EFI_BLOCK_IO_PROTOCOL         *BlkIo;\r
   UINTN                         Index;\r
   EFI_HANDLE                    *BlockIoHandles;\r
   EFI_BLOCK_IO_PROTOCOL         *BlkIo;\r
   UINTN                         Index;\r
-  UINTN                         NumberSimpleNetworkHandles;\r
-  EFI_HANDLE                    *SimpleNetworkHandles;\r
+  UINTN                         NumberNetworkHandles;\r
+  EFI_HANDLE                    *NetworkHandles;\r
   UINTN                         FvHandleCount;\r
   EFI_HANDLE                    *FvHandleBuffer;\r
   EFI_FV_FILETYPE               Type;\r
   UINTN                         FvHandleCount;\r
   EFI_HANDLE                    *FvHandleBuffer;\r
   EFI_FV_FILETYPE               Type;\r
@@ -1166,21 +1166,37 @@ BdsLibEnumerateAllBootOption (
   //\r
   // Parse Network Boot Device\r
   //\r
   //\r
   // Parse Network Boot Device\r
   //\r
+  NumberNetworkHandles = 0;\r
+  //\r
+  // Search MNP Service Binding protocol for UEFI network stack\r
+  //\r
   gBS->LocateHandleBuffer (\r
         ByProtocol,\r
   gBS->LocateHandleBuffer (\r
         ByProtocol,\r
-        &gEfiSimpleNetworkProtocolGuid,\r
+        &gEfiManagedNetworkServiceBindingProtocolGuid,\r
         NULL,\r
         NULL,\r
-        &NumberSimpleNetworkHandles,\r
-        &SimpleNetworkHandles\r
+        &NumberNetworkHandles,\r
+        &NetworkHandles\r
         );\r
         );\r
+  if (NumberNetworkHandles == 0) {\r
+    //\r
+    // MNP Service Binding protocol not found, search SNP for EFI network stack\r
+    //\r
+    gBS->LocateHandleBuffer (\r
+          ByProtocol,\r
+          &gEfiSimpleNetworkProtocolGuid,\r
+          NULL,\r
+          &NumberNetworkHandles,\r
+          &NetworkHandles\r
+          );\r
+  }\r
 \r
 \r
-  for (Index = 0; Index < NumberSimpleNetworkHandles; Index++) {\r
+  for (Index = 0; Index < NumberNetworkHandles; Index++) {\r
     UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", Index);\r
     UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", Index);\r
-    BdsLibBuildOptionFromHandle (SimpleNetworkHandles[Index], BdsBootOptionList, Buffer);\r
+    BdsLibBuildOptionFromHandle (NetworkHandles[Index], BdsBootOptionList, Buffer);\r
   }\r
 \r
   }\r
 \r
-  if (NumberSimpleNetworkHandles != 0) {\r
-    FreePool (SimpleNetworkHandles);\r
+  if (NumberNetworkHandles != 0) {\r
+    FreePool (NetworkHandles);\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r
@@ -1534,7 +1550,17 @@ BdsLibNetworkBootWithMediaPresent (
   MediaPresent = FALSE;\r
 \r
   UpdatedDevicePath = DevicePath;\r
   MediaPresent = FALSE;\r
 \r
   UpdatedDevicePath = DevicePath;\r
-  Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &UpdatedDevicePath, &Handle);\r
+  //\r
+  // Locate MNP Service Binding protocol for UEFI network stack first\r
+  //\r
+  Status = gBS->LocateDevicePath (&gEfiManagedNetworkServiceBindingProtocolGuid, &UpdatedDevicePath, &Handle);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // MNP Service Binding protocol not found, search SNP for EFI network stack\r
+    //\r
+    UpdatedDevicePath = DevicePath;\r
+    Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &UpdatedDevicePath, &Handle);\r
+  }\r
   if (EFI_ERROR (Status)) {\r
     //\r
     // Device not present so see if we need to connect it\r
   if (EFI_ERROR (Status)) {\r
     //\r
     // Device not present so see if we need to connect it\r
@@ -1544,12 +1570,32 @@ BdsLibNetworkBootWithMediaPresent (
       //\r
       // This one should work after we did the connect\r
       //\r
       //\r
       // This one should work after we did the connect\r
       //\r
-      Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &UpdatedDevicePath, &Handle);\r
+      Status = gBS->LocateDevicePath (&gEfiManagedNetworkServiceBindingProtocolGuid, &UpdatedDevicePath, &Handle);\r
+      if (EFI_ERROR (Status)) {\r
+        UpdatedDevicePath = DevicePath;\r
+        Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &UpdatedDevicePath, &Handle);\r
+      }\r
     }\r
   }\r
 \r
   if (!EFI_ERROR (Status)) {\r
     Status = gBS->HandleProtocol (Handle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
     }\r
   }\r
 \r
   if (!EFI_ERROR (Status)) {\r
     Status = gBS->HandleProtocol (Handle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
+    if (EFI_ERROR (Status)) {\r
+      //\r
+      // Failed to open SNP from this handle, try to get SNP from parent handle\r
+      //\r
+      UpdatedDevicePath = DevicePathFromHandle (Handle);\r
+      if (UpdatedDevicePath != NULL) {\r
+        Status = gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &UpdatedDevicePath, &Handle);\r
+        if (!EFI_ERROR (Status)) {\r
+          //\r
+          // SNP handle found, get SNP from it\r
+          //\r
+          Status = gBS->HandleProtocol (Handle, &gEfiSimpleNetworkProtocolGuid, (VOID **) &Snp);\r
+        }\r
+      }\r
+    }\r
+\r
     if (!EFI_ERROR (Status)) {\r
       if (Snp->Mode->MediaPresentSupported) {\r
         if (Snp->Mode->State == EfiSimpleNetworkInitialized) {\r
     if (!EFI_ERROR (Status)) {\r
       if (Snp->Mode->MediaPresentSupported) {\r
         if (Snp->Mode->State == EfiSimpleNetworkInitialized) {\r
@@ -1613,7 +1659,7 @@ BdsGetBootTypeFromDevicePath (
   ACPI_HID_DEVICE_PATH          *Acpi;\r
   EFI_DEVICE_PATH_PROTOCOL      *TempDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL      *LastDeviceNode;\r
   ACPI_HID_DEVICE_PATH          *Acpi;\r
   EFI_DEVICE_PATH_PROTOCOL      *TempDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL      *LastDeviceNode;\r
-\r
+  UINT32                        BootType;\r
 \r
   if (NULL == DevicePath) {\r
     return BDS_EFI_UNSUPPORT;\r
 \r
   if (NULL == DevicePath) {\r
     return BDS_EFI_UNSUPPORT;\r
@@ -1646,7 +1692,7 @@ BdsGetBootTypeFromDevicePath (
         if (DevicePathSubType(LastDeviceNode) == MSG_DEVICE_LOGICAL_UNIT_DP) {\r
           //\r
           // if the next node type is Device Logical Unit, which specify the Logical Unit Number (LUN),\r
         if (DevicePathSubType(LastDeviceNode) == MSG_DEVICE_LOGICAL_UNIT_DP) {\r
           //\r
           // if the next node type is Device Logical Unit, which specify the Logical Unit Number (LUN),\r
-          // skit it\r
+          // skip it\r
           //\r
           LastDeviceNode = NextDevicePathNode (LastDeviceNode);\r
         }\r
           //\r
           LastDeviceNode = NextDevicePathNode (LastDeviceNode);\r
         }\r
@@ -1657,18 +1703,34 @@ BdsGetBootTypeFromDevicePath (
           break;\r
         }\r
 \r
           break;\r
         }\r
 \r
-        if (DevicePathSubType(TempDevicePath) == MSG_ATAPI_DP) {\r
-          return BDS_EFI_MESSAGE_ATAPI_BOOT;\r
-        } else if (DevicePathSubType(TempDevicePath) == MSG_USB_DP) {\r
-          return BDS_EFI_MESSAGE_USB_DEVICE_BOOT;\r
-        } else if (DevicePathSubType(TempDevicePath) == MSG_SCSI_DP) {\r
-          return BDS_EFI_MESSAGE_SCSI_BOOT;\r
-        } else if (DevicePathSubType(TempDevicePath) == MSG_SATA_DP) {\r
-          return BDS_EFI_MESSAGE_SATA_BOOT;\r
-        } else if (DevicePathSubType(TempDevicePath) == MSG_MAC_ADDR_DP) {\r
-          return BDS_EFI_MESSAGE_MAC_BOOT;\r
+        switch (DevicePathSubType (TempDevicePath)) {\r
+        case MSG_ATAPI_DP:\r
+          BootType = BDS_EFI_MESSAGE_ATAPI_BOOT;\r
+          break;\r
+\r
+        case MSG_USB_DP:\r
+          BootType = BDS_EFI_MESSAGE_USB_DEVICE_BOOT;\r
+          break;\r
+\r
+        case MSG_SCSI_DP:\r
+          BootType = BDS_EFI_MESSAGE_SCSI_BOOT;\r
+          break;\r
+\r
+        case MSG_SATA_DP:\r
+          BootType = BDS_EFI_MESSAGE_SATA_BOOT;\r
+          break;\r
+\r
+        case MSG_MAC_ADDR_DP:\r
+        case MSG_VLAN_DP:\r
+          BootType = BDS_EFI_MESSAGE_MAC_BOOT;\r
+          break;\r
+\r
+        default:\r
+          BootType = BDS_EFI_MESSAGE_MISC_BOOT;\r
+          break;\r
         }\r
         }\r
-        return BDS_EFI_MESSAGE_MISC_BOOT;\r
+        return BootType;\r
+\r
       default:\r
         break;\r
     }\r
       default:\r
         break;\r
     }\r
@@ -1727,20 +1789,29 @@ BdsLibIsValidEFIBootOptDevicePathExt (
   EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL  *LastDeviceNode;\r
   EFI_BLOCK_IO_PROTOCOL     *BlockIo;\r
   EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL  *LastDeviceNode;\r
   EFI_BLOCK_IO_PROTOCOL     *BlockIo;\r
+  EFI_LOAD_FILE_PROTOCOL    *LoadFile;\r
 \r
   TempDevicePath = DevPath;\r
   LastDeviceNode = DevPath;\r
 \r
   //\r
   // Check if it's a valid boot option for network boot device\r
 \r
   TempDevicePath = DevPath;\r
   LastDeviceNode = DevPath;\r
 \r
   //\r
   // Check if it's a valid boot option for network boot device\r
-  // Only check if there is SimpleNetworkProtocol installed. If yes, that means\r
-  // there is the network card there.\r
+  // Check if there is MNP Service Binding Protocol or SimpleNetworkProtocol\r
+  // installed. If yes, that means there is the network card there.\r
   //\r
   Status = gBS->LocateDevicePath (\r
   //\r
   Status = gBS->LocateDevicePath (\r
-                  &gEfiSimpleNetworkProtocolGuid,\r
+                  &gEfiManagedNetworkServiceBindingProtocolGuid,\r
                   &TempDevicePath,\r
                   &Handle\r
                   );\r
                   &TempDevicePath,\r
                   &Handle\r
                   );\r
+  if (EFI_ERROR (Status)) {\r
+    TempDevicePath = DevPath;\r
+    Status = gBS->LocateDevicePath (\r
+                    &gEfiSimpleNetworkProtocolGuid,\r
+                    &TempDevicePath,\r
+                    &Handle\r
+                    );\r
+  }\r
   if (EFI_ERROR (Status)) {\r
     //\r
     // Device not present so see if we need to connect it\r
   if (EFI_ERROR (Status)) {\r
     //\r
     // Device not present so see if we need to connect it\r
@@ -1748,22 +1819,43 @@ BdsLibIsValidEFIBootOptDevicePathExt (
     TempDevicePath = DevPath;\r
     BdsLibConnectDevicePath (TempDevicePath);\r
     Status = gBS->LocateDevicePath (\r
     TempDevicePath = DevPath;\r
     BdsLibConnectDevicePath (TempDevicePath);\r
     Status = gBS->LocateDevicePath (\r
-                    &gEfiSimpleNetworkProtocolGuid,\r
+                    &gEfiManagedNetworkServiceBindingProtocolGuid,\r
                     &TempDevicePath,\r
                     &Handle\r
                     );\r
                     &TempDevicePath,\r
                     &Handle\r
                     );\r
+    if (EFI_ERROR (Status)) {\r
+      TempDevicePath = DevPath;\r
+      Status = gBS->LocateDevicePath (\r
+                      &gEfiSimpleNetworkProtocolGuid,\r
+                      &TempDevicePath,\r
+                      &Handle\r
+                      );\r
+    }\r
   }\r
 \r
   if (!EFI_ERROR (Status)) {\r
   }\r
 \r
   if (!EFI_ERROR (Status)) {\r
-    if (CheckMedia) {\r
-      //\r
-      // Test if it is ready to boot now\r
-      //\r
-      if (BdsLibNetworkBootWithMediaPresent(DevPath)) {\r
+    //\r
+    // Check whether LoadFile protocol is installed\r
+    //\r
+    Status = gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID **)&LoadFile);\r
+    if (!EFI_ERROR (Status)) {\r
+      if (!IsDevicePathEnd (TempDevicePath)) {\r
+        //\r
+        // LoadFile protocol is not installed on handle with exactly the same DevPath\r
+        //\r
+        return FALSE;\r
+      }\r
+\r
+      if (CheckMedia) {\r
+        //\r
+        // Test if it is ready to boot now\r
+        //\r
+        if (BdsLibNetworkBootWithMediaPresent(DevPath)) {\r
+          return TRUE;\r
+        }\r
+      } else {\r
         return TRUE;\r
       }\r
         return TRUE;\r
       }\r
-    } else {\r
-      return TRUE;\r
     }\r
   }\r
 \r
     }\r
   }\r
 \r
index 2f6ba4b8e688deeb40ba2dfed929db4b633a21aa..4aa9f124ddd620e4d74ead3cf78c00a83eebf0d1 100644 (file)
@@ -90,6 +90,8 @@
 \r
 [Protocols]\r
   gEfiSimpleFileSystemProtocolGuid              # PROTOCOL CONSUMES\r
 \r
 [Protocols]\r
   gEfiSimpleFileSystemProtocolGuid              # PROTOCOL CONSUMES\r
+  gEfiManagedNetworkServiceBindingProtocolGuid  # PROTOCOL CONSUMES\r
+  gEfiLoadFileProtocolGuid                      # PROTOCOL CONSUMES\r
   gEfiSimpleTextOutProtocolGuid                 # PROTOCOL CONSUMES\r
   gEfiPciIoProtocolGuid                         # PROTOCOL CONSUMES\r
   gEfiLoadedImageProtocolGuid                   # PROTOCOL CONSUMES\r
   gEfiSimpleTextOutProtocolGuid                 # PROTOCOL CONSUMES\r
   gEfiPciIoProtocolGuid                         # PROTOCOL CONSUMES\r
   gEfiLoadedImageProtocolGuid                   # PROTOCOL CONSUMES\r
index f269e44eff45f811fec28dfa0aa5c159879749bc..c119523edd68171530f1048c8366322463f1e86c 100644 (file)
@@ -24,6 +24,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/LoadedImage.h>\r
 #include <Protocol/Cpu.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
 #include <Protocol/LoadedImage.h>\r
 #include <Protocol/Cpu.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/ManagedNetwork.h>\r
+#include <Protocol/LoadFile.h>\r
 #include <Protocol/DebugPort.h>\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/SimpleTextIn.h>\r
 #include <Protocol/DebugPort.h>\r
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/SimpleTextIn.h>\r