diff options
Diffstat (limited to 'MdeModulePkg/Library/DxeNetLib/DxeNetLib.c')
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 94 |
1 files changed, 91 insertions, 3 deletions
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index 9d7af66f33..c055db2b77 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Protocol/HiiConfigRouting.h>
#include <Protocol/ComponentName.h>
#include <Protocol/ComponentName2.h>
+#include <Protocol/HiiConfigAccess.h>
#include <Guid/NicIp4ConfigNvData.h>
@@ -33,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/DevicePathLib.h>
#include <Library/HiiLib.h>
#include <Library/PrintLib.h>
+#include <Library/UefiLib.h>
#define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE
@@ -1571,6 +1573,86 @@ NetMapIterate ( /**
+ Internal function to get the child handle of the NIC handle.
+
+ @param[in] Controller NIC controller handle.
+ @param[out] ChildHandle Returned child handle.
+
+ @retval EFI_SUCCESS Successfully to get child handle.
+ @retval Others Failed to get child handle.
+
+**/
+EFI_STATUS
+NetGetChildHandle (
+ IN EFI_HANDLE Controller,
+ OUT EFI_HANDLE *ChildHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *ChildDeviceDevicePath;
+ VENDOR_DEVICE_PATH *VendorDeviceNode;
+
+ //
+ // Locate all EFI Hii Config Access protocols
+ //
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiHiiConfigAccessProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status) || (HandleCount == 0)) {
+ return Status;
+ }
+
+ Status = EFI_NOT_FOUND;
+
+ for (Index = 0; Index < HandleCount; Index++) {
+
+ Status = EfiTestChildHandle (Controller, Handles[Index], &gEfiManagedNetworkServiceBindingProtocolGuid);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Get device path on the child handle
+ //
+ Status = gBS->HandleProtocol (
+ Handles[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID **) &ChildDeviceDevicePath
+ );
+
+ if (!EFI_ERROR (Status)) {
+ while (!IsDevicePathEnd (ChildDeviceDevicePath)) {
+ ChildDeviceDevicePath = NextDevicePathNode (ChildDeviceDevicePath);
+ //
+ // Parse one instance
+ //
+ if (ChildDeviceDevicePath->Type == HARDWARE_DEVICE_PATH &&
+ ChildDeviceDevicePath->SubType == HW_VENDOR_DP) {
+ VendorDeviceNode = (VENDOR_DEVICE_PATH *) ChildDeviceDevicePath;
+ if (CompareMem (&VendorDeviceNode->Guid, &gEfiNicIp4ConfigVariableGuid, sizeof (EFI_GUID)) == 0) {
+ //
+ // Found item matched gEfiNicIp4ConfigVariableGuid
+ //
+ *ChildHandle = Handles[Index];
+ FreePool (Handles);
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ FreePool (Handles);
+ return Status;
+}
+
+
+/**
This is the default unload handle for all the network drivers.
Disconnect the driver specified by ImageHandle from all the devices in the handle database.
@@ -2391,6 +2473,7 @@ NetLibDefaultAddressIsStatic ( EFI_STRING AccessProgress;
EFI_STRING AccessResults;
EFI_STRING String;
+ EFI_HANDLE ChildHandle;
ConfigInfo = NULL;
ConfigHdr = NULL;
@@ -2408,10 +2491,15 @@ NetLibDefaultAddressIsStatic ( return TRUE;
}
+ Status = NetGetChildHandle (Controller, &ChildHandle);
+ if (EFI_ERROR (Status)) {
+ return TRUE;
+ }
+
//
// Construct config request string header
//
- ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Controller);
+ ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, ChildHandle);
if (ConfigHdr == NULL) {
return TRUE;
}
@@ -2442,7 +2530,7 @@ NetLibDefaultAddressIsStatic ( goto ON_EXIT;
}
- ConfigInfo = AllocateZeroPool (sizeof (NIC_ITEM_CONFIG_SIZE));
+ ConfigInfo = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);
if (ConfigInfo == NULL) {
goto ON_EXIT;
}
@@ -2983,7 +3071,7 @@ NetLibStrToIp6andPrefix ( // If input string doesn't indicate the prefix length, return 0xff.
//
Length = 0xFF;
-
+
//
// Convert the string to prefix length
//
|