summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2010-07-01 01:30:23 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2010-07-01 01:30:23 +0000
commit1dc1b43fc2a3739a01680a6dd848d0359bdc829d (patch)
tree1b28ac931be24717fa07e1e6fd9dedab58a1dcb1 /MdeModulePkg
parent25400c63fab4fb15988827e2ff33fe9e462c03a9 (diff)
downloadedk2-platforms-1dc1b43fc2a3739a01680a6dd848d0359bdc829d.tar.xz
1. fixed one bug to construct config request string header used child handle instead of NIC controller handle.
2. fixed one bug to calculate buffer size. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10617 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.c94
-rw-r--r--MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf3
2 files changed, 93 insertions, 4 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
//
diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
index bf1c76ce1b..9b11c8211d 100644
--- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
+++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
@@ -49,7 +49,7 @@
HiiLib
PrintLib
-[Guids]
+[Guids]
gEfiNicIp4ConfigVariableGuid
[Protocols]
@@ -59,3 +59,4 @@
gEfiComponentNameProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiComponentName2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiHiiConfigRoutingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiHiiConfigAccessProtocolGuid # PROTOCOL ALWAYS_CONSUMED