#include <Protocol/HiiConfigRouting.h>\r
#include <Protocol/ComponentName.h>\r
#include <Protocol/ComponentName2.h>\r
+#include <Protocol/HiiConfigAccess.h>\r
\r
#include <Guid/NicIp4ConfigNvData.h>\r
\r
#include <Library/DevicePathLib.h>\r
#include <Library/HiiLib.h>\r
#include <Library/PrintLib.h>\r
+#include <Library/UefiLib.h>\r
\r
#define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE\r
\r
}\r
\r
\r
+/**\r
+ Internal function to get the child handle of the NIC handle.\r
+\r
+ @param[in] Controller NIC controller handle.\r
+ @param[out] ChildHandle Returned child handle.\r
+\r
+ @retval EFI_SUCCESS Successfully to get child handle.\r
+ @retval Others Failed to get child handle.\r
+\r
+**/\r
+EFI_STATUS\r
+NetGetChildHandle (\r
+ IN EFI_HANDLE Controller,\r
+ OUT EFI_HANDLE *ChildHandle\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE *Handles;\r
+ UINTN HandleCount;\r
+ UINTN Index;\r
+ EFI_DEVICE_PATH_PROTOCOL *ChildDeviceDevicePath;\r
+ VENDOR_DEVICE_PATH *VendorDeviceNode;\r
+\r
+ //\r
+ // Locate all EFI Hii Config Access protocols\r
+ //\r
+ Status = gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ &gEfiHiiConfigAccessProtocolGuid,\r
+ NULL,\r
+ &HandleCount,\r
+ &Handles\r
+ );\r
+ if (EFI_ERROR (Status) || (HandleCount == 0)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = EFI_NOT_FOUND;\r
+\r
+ for (Index = 0; Index < HandleCount; Index++) {\r
+\r
+ Status = EfiTestChildHandle (Controller, Handles[Index], &gEfiManagedNetworkServiceBindingProtocolGuid);\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Get device path on the child handle\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ Handles[Index],\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &ChildDeviceDevicePath\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ while (!IsDevicePathEnd (ChildDeviceDevicePath)) {\r
+ ChildDeviceDevicePath = NextDevicePathNode (ChildDeviceDevicePath);\r
+ //\r
+ // Parse one instance\r
+ //\r
+ if (ChildDeviceDevicePath->Type == HARDWARE_DEVICE_PATH &&\r
+ ChildDeviceDevicePath->SubType == HW_VENDOR_DP) {\r
+ VendorDeviceNode = (VENDOR_DEVICE_PATH *) ChildDeviceDevicePath;\r
+ if (CompareMem (&VendorDeviceNode->Guid, &gEfiNicIp4ConfigVariableGuid, sizeof (EFI_GUID)) == 0) {\r
+ //\r
+ // Found item matched gEfiNicIp4ConfigVariableGuid\r
+ //\r
+ *ChildHandle = Handles[Index];\r
+ FreePool (Handles);\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ FreePool (Handles);\r
+ return Status;\r
+}\r
+\r
+\r
/**\r
This is the default unload handle for all the network drivers.\r
\r
EFI_STRING AccessProgress;\r
EFI_STRING AccessResults;\r
EFI_STRING String;\r
+ EFI_HANDLE ChildHandle;\r
\r
ConfigInfo = NULL;\r
ConfigHdr = NULL;\r
return TRUE;\r
}\r
\r
+ Status = NetGetChildHandle (Controller, &ChildHandle);\r
+ if (EFI_ERROR (Status)) {\r
+ return TRUE;\r
+ }\r
+\r
//\r
// Construct config request string header\r
//\r
- ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Controller);\r
+ ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);\r
if (ConfigHdr == NULL) {\r
return TRUE;\r
}\r
goto ON_EXIT;\r
}\r
\r
- ConfigInfo = AllocateZeroPool (sizeof (NIC_ITEM_CONFIG_SIZE));\r
+ ConfigInfo = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
if (ConfigInfo == NULL) {\r
goto ON_EXIT;\r
}\r
// If input string doesn't indicate the prefix length, return 0xff.\r
//\r
Length = 0xFF;\r
- \r
+\r
//\r
// Convert the string to prefix length\r
//\r