From 638868496cafa80a7212f654559944f34f65598a Mon Sep 17 00:00:00 2001 From: vanjeff Date: Wed, 13 May 2009 09:29:44 +0000 Subject: 1. retired NicIp4ConfigProtocolGuid 2. moved NicIp4ConfigVariableGuid to Include/Guid/NicIp4ConfigNvData.h 3. updated Ip4ConfigDxe module to publish one setup page to Get/Set network parameters. Also, Ip4ConfgiDxe installed EFI HII Config Access protocol for each network devices. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8309 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 105 +++++++++++++++++++++------ MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf | 11 ++- 2 files changed, 91 insertions(+), 25 deletions(-) (limited to 'MdeModulePkg/Library/DxeNetLib') diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index b69bd20a40..59da12ce91 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -15,11 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#include +#include #include #include #include +#include + #include #include #include @@ -28,11 +30,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include +#include EFI_DPC_PROTOCOL *mDpc = NULL; GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mNetLibHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; +#define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2 + // // All the supported IP4 maskes in host byte order. // @@ -1248,43 +1254,98 @@ NetLibDefaultAddressIsStatic ( IN EFI_HANDLE Controller ) { - EFI_STATUS Status; - EFI_NIC_IP4_CONFIG_PROTOCOL *NicIp4; - UINTN Len; - NIC_IP4_CONFIG_INFO *ConfigInfo; - BOOLEAN IsStatic; - - Status = gBS->HandleProtocol ( - Controller, - &gEfiNicIp4ConfigProtocolGuid, - (VOID **) &NicIp4 - ); + EFI_STATUS Status; + EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; + UINTN Len; + NIC_IP4_CONFIG_INFO *ConfigInfo; + BOOLEAN IsStatic; + EFI_STRING ConfigHdr; + EFI_STRING ConfigResp; + EFI_STRING AccessProgress; + EFI_STRING AccessResults; + EFI_STRING String; + + ConfigInfo = NULL; + ConfigHdr = NULL; + ConfigResp = NULL; + AccessProgress = NULL; + AccessResults = NULL; + IsStatic = TRUE; + + Status = gBS->LocateProtocol ( + &gEfiHiiConfigRoutingProtocolGuid, + NULL, + (VOID **) &HiiConfigRouting + ); if (EFI_ERROR (Status)) { return TRUE; } - Len = 0; - Status = NicIp4->GetInfo (NicIp4, &Len, NULL); - if (Status != EFI_BUFFER_TOO_SMALL) { - return TRUE; + // + // Construct config request string header + // + ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Controller); + + Len = StrLen (ConfigHdr); + ConfigResp = AllocateZeroPool (Len + NIC_ITEM_CONFIG_SIZE * 2 + 200); + if (ConfigResp == NULL) { + goto ON_EXIT; + } + StrCpy (ConfigResp, ConfigHdr); + + String = ConfigResp + Len; + UnicodeSPrint ( + String, + (8 + 4 + 7 + 4) * sizeof (CHAR16), + L"&OFFSET=%04X&WIDTH=%04X", + OFFSET_OF (NIC_IP4_CONFIG_INFO, Source), + sizeof (UINT32) + ); + + Status = HiiConfigRouting->ExtractConfig ( + HiiConfigRouting, + ConfigResp, + &AccessProgress, + &AccessResults + ); + if (EFI_ERROR (Status)) { + goto ON_EXIT; } - ConfigInfo = AllocatePool (Len); + ConfigInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO)); if (ConfigInfo == NULL) { - return TRUE; + goto ON_EXIT; } - IsStatic = TRUE; - Status = NicIp4->GetInfo (NicIp4, &Len, ConfigInfo); + ConfigInfo->Source = IP4_CONFIG_SOURCE_STATIC; + Len = NIC_ITEM_CONFIG_SIZE; + Status = HiiConfigRouting->ConfigToBlock ( + HiiConfigRouting, + AccessResults, + (UINT8 *) ConfigInfo, + &Len, + &AccessProgress + ); if (EFI_ERROR (Status)) { goto ON_EXIT; } IsStatic = (BOOLEAN) (ConfigInfo->Source == IP4_CONFIG_SOURCE_STATIC); - + ON_EXIT: - gBS->FreePool (ConfigInfo); + if (AccessResults != NULL) { + FreePool (AccessResults); + } + if (ConfigInfo != NULL) { + FreePool (ConfigInfo); + } + if (ConfigResp != NULL) { + FreePool (ConfigResp); + } + if (ConfigHdr != NULL) { + FreePool (ConfigHdr); + } return IsStatic; } diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf index 4ac01a7ca3..2f2b2d095f 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf @@ -1,7 +1,7 @@ /** @file Instance of DxeNetLib. -Copyright (c) 2006, Intel Corporation.
+Copyright (c) 2006 - 2009, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -48,13 +48,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. UefiLib MemoryAllocationLib DevicePathLib - + HiiLib + PrintLib + +[Guids] + gEfiNicIp4ConfigVariableGuid + [Protocols] gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiNicIp4ConfigProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiDpcProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiComponentNameProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiComponentName2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiHiiConfigRoutingProtocolGuid # PROTOCOL ALWAYS_CONSUMED [Depex] gEfiDpcProtocolGuid -- cgit v1.2.3