\r
#include <Protocol/ServiceBinding.h>\r
#include <Protocol/SimpleNetwork.h>\r
-#include <Protocol/NicIp4Config.h>\r
+#include <Protocol/HiiConfigRouting.h>\r
#include <Protocol/ComponentName.h>\r
#include <Protocol/ComponentName2.h>\r
#include <Protocol/Dpc.h>\r
\r
+#include <Guid/NicIp4ConfigNvData.h>\r
+\r
#include <Library/NetLib.h>\r
#include <Library/BaseLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/UefiRuntimeServicesTableLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/DevicePathLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/PrintLib.h>\r
\r
EFI_DPC_PROTOCOL *mDpc = NULL;\r
\r
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mNetLibHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};\r
\r
+#define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2\r
+\r
//\r
// All the supported IP4 maskes in host byte order.\r
//\r
Initializes the count of the <Key, Value> pairs in the netmap to zero.\r
\r
If Map is NULL, then ASSERT().\r
- If the address of Map->Used is NULl, then ASSERT().\r
+ If the address of Map->Used is NULL, then ASSERT().\r
If the address of Map->Recycled is NULl, then ASSERT().\r
\r
@param[in, out] Map The netmap to initialize.\r
@param[in] Controller The controller which has the service installed.\r
@param[in] Image The image handle used to open service.\r
@param[in] ServiceBindingGuid The service's Guid.\r
- @param[in, out] ChildHandle The handle to receive the create child\r
+ @param[in, out] ChildHandle The handle to receive the create child.\r
\r
@retval EFI_SUCCESS The child is successfully created.\r
@retval Others Failed to create the child.\r
@param[in] Controller The controller which has the service installed.\r
@param[in] Image The image handle used to open service.\r
@param[in] ServiceBindingGuid The service's Guid.\r
- @param[in] ChildHandle The child to destory\r
+ @param[in] ChildHandle The child to destory.\r
\r
@retval EFI_SUCCESS The child is successfully destoried.\r
@retval Others Failed to destory the child.\r
IN EFI_HANDLE Controller\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_NIC_IP4_CONFIG_PROTOCOL *NicIp4;\r
- UINTN Len;\r
- NIC_IP4_CONFIG_INFO *ConfigInfo;\r
- BOOLEAN IsStatic;\r
-\r
- Status = gBS->HandleProtocol (\r
- Controller,\r
- &gEfiNicIp4ConfigProtocolGuid,\r
- (VOID **) &NicIp4\r
- );\r
+ EFI_STATUS Status;\r
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
+ UINTN Len;\r
+ NIC_IP4_CONFIG_INFO *ConfigInfo;\r
+ BOOLEAN IsStatic;\r
+ EFI_STRING ConfigHdr;\r
+ EFI_STRING ConfigResp;\r
+ EFI_STRING AccessProgress;\r
+ EFI_STRING AccessResults;\r
+ EFI_STRING String;\r
+\r
+ ConfigInfo = NULL;\r
+ ConfigHdr = NULL;\r
+ ConfigResp = NULL;\r
+ AccessProgress = NULL;\r
+ AccessResults = NULL;\r
+ IsStatic = TRUE;\r
+\r
+ Status = gBS->LocateProtocol (\r
+ &gEfiHiiConfigRoutingProtocolGuid,\r
+ NULL,\r
+ (VOID **) &HiiConfigRouting\r
+ );\r
if (EFI_ERROR (Status)) {\r
return TRUE;\r
}\r
\r
- Len = 0;\r
- Status = NicIp4->GetInfo (NicIp4, &Len, NULL);\r
- if (Status != EFI_BUFFER_TOO_SMALL) {\r
- return TRUE;\r
+ //\r
+ // Construct config request string header\r
+ //\r
+ ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Controller);\r
+ \r
+ Len = StrLen (ConfigHdr);\r
+ ConfigResp = AllocateZeroPool (Len + NIC_ITEM_CONFIG_SIZE * 2 + 200);\r
+ if (ConfigResp == NULL) {\r
+ goto ON_EXIT;\r
+ }\r
+ StrCpy (ConfigResp, ConfigHdr);\r
+\r
+ String = ConfigResp + Len;\r
+ UnicodeSPrint (\r
+ String, \r
+ (8 + 4 + 7 + 4) * sizeof (CHAR16), \r
+ L"&OFFSET=%04X&WIDTH=%04X", \r
+ OFFSET_OF (NIC_IP4_CONFIG_INFO, Source), \r
+ sizeof (UINT32)\r
+ );\r
+\r
+ Status = HiiConfigRouting->ExtractConfig (\r
+ HiiConfigRouting,\r
+ ConfigResp,\r
+ &AccessProgress,\r
+ &AccessResults\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto ON_EXIT;\r
}\r
\r
- ConfigInfo = AllocatePool (Len);\r
+ ConfigInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO));\r
if (ConfigInfo == NULL) {\r
- return TRUE;\r
+ goto ON_EXIT;\r
}\r
\r
- IsStatic = TRUE;\r
- Status = NicIp4->GetInfo (NicIp4, &Len, ConfigInfo);\r
+ ConfigInfo->Source = IP4_CONFIG_SOURCE_STATIC;\r
+ Len = NIC_ITEM_CONFIG_SIZE;\r
+ Status = HiiConfigRouting->ConfigToBlock (\r
+ HiiConfigRouting,\r
+ AccessResults,\r
+ (UINT8 *) ConfigInfo,\r
+ &Len,\r
+ &AccessProgress\r
+ );\r
if (EFI_ERROR (Status)) {\r
goto ON_EXIT;\r
}\r
\r
IsStatic = (BOOLEAN) (ConfigInfo->Source == IP4_CONFIG_SOURCE_STATIC);\r
-\r
+ \r
ON_EXIT:\r
\r
- gBS->FreePool (ConfigInfo);\r
+ if (AccessResults != NULL) {\r
+ FreePool (AccessResults);\r
+ }\r
+ if (ConfigInfo != NULL) {\r
+ FreePool (ConfigInfo);\r
+ }\r
+ if (ConfigResp != NULL) {\r
+ FreePool (ConfigResp);\r
+ }\r
+ if (ConfigHdr != NULL) {\r
+ FreePool (ConfigHdr);\r
+ }\r
\r
return IsStatic;\r
}\r