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
//\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
- &gEfiSimpleNetworkProtocolGuid,\r
+ &gEfiManagedNetworkServiceBindingProtocolGuid,\r
NULL,\r
- &NumberSimpleNetworkHandles,\r
- &SimpleNetworkHandles\r
+ &NumberNetworkHandles,\r
+ &NetworkHandles\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
- for (Index = 0; Index < NumberSimpleNetworkHandles; Index++) {\r
+ for (Index = 0; Index < NumberNetworkHandles; Index++) {\r
UnicodeSPrint (Buffer, sizeof (Buffer), L"%d", Index);\r
- BdsLibBuildOptionFromHandle (SimpleNetworkHandles[Index], BdsBootOptionList, Buffer);\r
+ BdsLibBuildOptionFromHandle (NetworkHandles[Index], BdsBootOptionList, Buffer);\r
}\r
\r
- if (NumberSimpleNetworkHandles != 0) {\r
- FreePool (SimpleNetworkHandles);\r
+ if (NumberNetworkHandles != 0) {\r
+ FreePool (NetworkHandles);\r
}\r
\r
//\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
//\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
+ 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
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
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
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
- return BDS_EFI_MESSAGE_MISC_BOOT;\r
+ return BootType;\r
+\r
default:\r
break;\r
}\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
- // 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
- &gEfiSimpleNetworkProtocolGuid,\r
+ &gEfiManagedNetworkServiceBindingProtocolGuid,\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
TempDevicePath = DevPath;\r
BdsLibConnectDevicePath (TempDevicePath);\r
Status = gBS->LocateDevicePath (\r
- &gEfiSimpleNetworkProtocolGuid,\r
+ &gEfiManagedNetworkServiceBindingProtocolGuid,\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
- 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
- } else {\r
- return TRUE;\r
}\r
}\r
\r