/** @file\r
This code implements the IP4Config and NicIp4Config protocols.\r
\r
-Copyright (c) 2006 - 2009, Intel Corporation.<BR> \r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at<BR>\r
@param NicConfig The buffer to receive the NIC's configure\r
parameter.\r
\r
- @retval EFI_SUCCESS The configure parameter for this NIC was \r
+ @retval EFI_SUCCESS The configure parameter for this NIC was\r
obtained successfully .\r
@retval EFI_INVALID_PARAMETER This or ConfigLen is NULL.\r
@retval EFI_NOT_FOUND There is no configure parameter for the NIC in\r
NVRam.\r
- @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is \r
+ @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is\r
NULL.\r
\r
**/\r
\r
\r
/**\r
- Set the IP configure parameters for this NIC. \r
+ Set the IP configure parameters for this NIC.\r
\r
- If Reconfig is TRUE, the IP driver will be informed to discard current \r
- auto configure parameter and restart the auto configuration process. \r
+ If Reconfig is TRUE, the IP driver will be informed to discard current\r
+ auto configure parameter and restart the auto configuration process.\r
If current there is a pending auto configuration, EFI_ALREADY_STARTED is\r
returned. You can only change the configure setting when either\r
the configure has finished or not started yet. If NicConfig, the\r
NIC's configure parameter is removed from the variable.\r
\r
@param Instance The IP4 CONFIG instance.\r
- @param NicConfig The new NIC IP4 configure parameter\r
+ @param NicConfig The new NIC IP4 configure parameter.\r
@param Reconfig Inform the IP4 driver to restart the auto\r
- configuration\r
- \r
- @retval EFI_SUCCESS The configure parameter for this NIC was \r
- set successfully .\r
+ configuration.\r
+\r
+ @retval EFI_SUCCESS The configure parameter for this NIC was\r
+ set successfully.\r
@retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is\r
invalid.\r
@retval EFI_ALREADY_STARTED There is a pending auto configuration.\r
- @retval EFI_NOT_FOUND No auto configure parameter is found\r
+ @retval EFI_NOT_FOUND No auto configure parameter is found.\r
\r
**/\r
EFI_STATUS\r
\r
/**\r
Starts running the configuration policy for the EFI IPv4 Protocol driver.\r
- \r
- The Start() function is called to determine and to begin the platform \r
- configuration policy by the EFI IPv4 Protocol driver. This determination may \r
- be as simple as returning EFI_UNSUPPORTED if there is no EFI IPv4 Protocol \r
- driver configuration policy. It may be as involved as loading some defaults \r
- from nonvolatile storage, downloading dynamic data from a DHCP server, and \r
+\r
+ The Start() function is called to determine and to begin the platform\r
+ configuration policy by the EFI IPv4 Protocol driver. This determination may\r
+ be as simple as returning EFI_UNSUPPORTED if there is no EFI IPv4 Protocol\r
+ driver configuration policy. It may be as involved as loading some defaults\r
+ from nonvolatile storage, downloading dynamic data from a DHCP server, and\r
checking permissions with a site policy server.\r
- Starting the configuration policy is just the beginning. It may finish almost \r
- instantly or it may take several minutes before it fails to retrieve configuration \r
- information from one or more servers. Once the policy is started, drivers \r
- should use the DoneEvent parameter to determine when the configuration policy \r
- has completed. EFI_IP4_CONFIG_PROTOCOL.GetData() must then be called to \r
+ Starting the configuration policy is just the beginning. It may finish almost\r
+ instantly or it may take several minutes before it fails to retrieve configuration\r
+ information from one or more servers. Once the policy is started, drivers\r
+ should use the DoneEvent parameter to determine when the configuration policy\r
+ has completed. EFI_IP4_CONFIG_PROTOCOL.GetData() must then be called to\r
determine if the configuration succeeded or failed.\r
- Until the configuration completes successfully, EFI IPv4 Protocol driver instances \r
+ Until the configuration completes successfully, EFI IPv4 Protocol driver instances\r
that are attempting to use default configurations must return EFI_NO_MAPPING.\r
- Once the configuration is complete, the EFI IPv4 Configuration Protocol driver \r
- signals DoneEvent. The configuration may need to be updated in the future, \r
- however; in this case, the EFI IPv4 Configuration Protocol driver must signal \r
- ReconfigEvent, and all EFI IPv4 Protocol driver instances that are using default \r
- configurations must return EFI_NO_MAPPING until the configuration policy has \r
+ Once the configuration is complete, the EFI IPv4 Configuration Protocol driver\r
+ signals DoneEvent. The configuration may need to be updated in the future,\r
+ however; in this case, the EFI IPv4 Configuration Protocol driver must signal\r
+ ReconfigEvent, and all EFI IPv4 Protocol driver instances that are using default\r
+ configurations must return EFI_NO_MAPPING until the configuration policy has\r
been rerun.\r
\r
@param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
- @param DoneEvent Event that will be signaled when the EFI IPv4 \r
- Protocol driver configuration policy completes \r
+ @param DoneEvent Event that will be signaled when the EFI IPv4\r
+ Protocol driver configuration policy completes\r
execution. This event must be of type EVT_NOTIFY_SIGNAL.\r
- @param ReconfigEvent Event that will be signaled when the EFI IPv4 \r
- Protocol driver configuration needs to be updated. \r
+ @param ReconfigEvent Event that will be signaled when the EFI IPv4\r
+ Protocol driver configuration needs to be updated.\r
This event must be of type EVT_NOTIFY_SIGNAL.\r
- \r
- @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol \r
+\r
+ @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol\r
driver is now running.\r
@retval EFI_INVALID_PARAMETER One or more of the following parameters is NULL:\r
This\r
DoneEvent\r
ReconfigEvent\r
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
- @retval EFI_ALREADY_STARTED The configuration policy for the EFI IPv4 Protocol \r
+ @retval EFI_ALREADY_STARTED The configuration policy for the EFI IPv4 Protocol\r
driver was already started.\r
@retval EFI_DEVICE_ERROR An unexpected system error or network error occurred.\r
- @retval EFI_UNSUPPORTED This interface does not support the EFI IPv4 Protocol \r
+ @retval EFI_UNSUPPORTED This interface does not support the EFI IPv4 Protocol\r
driver configuration.\r
\r
**/\r
\r
/**\r
Stops running the configuration policy for the EFI IPv4 Protocol driver.\r
- \r
- The Stop() function stops the configuration policy for the EFI IPv4 Protocol driver. \r
+\r
+ The Stop() function stops the configuration policy for the EFI IPv4 Protocol driver.\r
All configuration data will be lost after calling Stop().\r
\r
@param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
\r
- @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol \r
+ @retval EFI_SUCCESS The configuration policy for the EFI IPv4 Protocol\r
driver has been stopped.\r
@retval EFI_INVALID_PARAMETER This is NULL.\r
- @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol \r
+ @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol\r
driver was not started.\r
- \r
+\r
**/\r
EFI_STATUS\r
EFIAPI\r
/**\r
Returns the default configuration data (if any) for the EFI IPv4 Protocol driver.\r
\r
- The GetData() function returns the current configuration data for the EFI IPv4 \r
+ The GetData() function returns the current configuration data for the EFI IPv4\r
Protocol driver after the configuration policy has completed.\r
- \r
+\r
@param This Pointer to the EFI_IP4_CONFIG_PROTOCOL instance.\r
- @param ConfigDataSize On input, the size of the ConfigData buffer. \r
- On output, the count of bytes that were written \r
+ @param ConfigDataSize On input, the size of the ConfigData buffer.\r
+ On output, the count of bytes that were written\r
into the ConfigData buffer.\r
- @param ConfigData Pointer to the EFI IPv4 Configuration Protocol \r
- driver configuration data structure. \r
- Type EFI_IP4_IPCONFIG_DATA is defined in \r
+ @param ConfigData Pointer to the EFI IPv4 Configuration Protocol\r
+ driver configuration data structure.\r
+ Type EFI_IP4_IPCONFIG_DATA is defined in\r
"Related Definitions" below.\r
\r
@retval EFI_SUCCESS The EFI IPv4 Protocol driver configuration has been returned.\r
@retval EFI_INVALID_PARAMETER This is NULL.\r
- @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol \r
+ @retval EFI_NOT_STARTED The configuration policy for the EFI IPv4 Protocol\r
driver is not running.\r
@retval EFI_NOT_READY EFI IPv4 Protocol driver configuration is still running.\r
@retval EFI_ABORTED EFI IPv4 Protocol driver configuration could not complete.\r
Currently not implemented.\r
- @retval EFI_BUFFER_TOO_SMALL *ConfigDataSize is smaller than the configuration \r
+ @retval EFI_BUFFER_TOO_SMALL *ConfigDataSize is smaller than the configuration\r
data buffer or ConfigData is NULL.\r
\r
**/\r
\r
#include "Ip4ConfigNv.h"\r
\r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 Ip4HexString[] = "0123456789ABCDEFabcdef";\r
+EFI_GUID mNicIp4ConfigNvDataGuid = EFI_NIC_IP4_CONFIG_NVDATA_GUID;\r
\r
-UINTN mNumberOfIp4Devices = 0;\r
-\r
-IP4_FORM_CALLBACK_INFO *mCallbackInfo = NULL;\r
-\r
-LIST_ENTRY mIp4ConfigFormList = {\r
- &mIp4ConfigFormList,\r
- &mIp4ConfigFormList\r
-};\r
-\r
-HII_VENDOR_DEVICE_PATH mIp4ConifgHiiVendorDevicePath = {\r
- {\r
- {\r
- HARDWARE_DEVICE_PATH,\r
- HW_VENDOR_DP,\r
- {\r
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
- }\r
- },\r
- //\r
- // {6D3FD906-42B9-4220-9E63-9D8C972D58EE}\r
- //\r
- { 0x6d3fd906, 0x42b9, 0x4220, { 0x9e, 0x63, 0x9d, 0x8c, 0x97, 0x2d, 0x58, 0xee } }\r
- },\r
- {\r
- END_DEVICE_PATH_TYPE,\r
- END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- {\r
- (UINT8) (END_DEVICE_PATH_LENGTH),\r
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
- }\r
- }\r
-};\r
-\r
-/**\r
- Convert the mac address into a hexadecimal encoded "-" seperated string.\r
-\r
- @param[in] Mac The mac address.\r
- @param[in] Len Length in bytes of the mac address.\r
- @param[out] Str The storage to return the mac string.\r
-\r
-**/\r
-VOID\r
-Ip4MacAddrToStr (\r
- IN EFI_MAC_ADDRESS *Mac,\r
- IN UINT32 Len,\r
- OUT CHAR16 *Str\r
- )\r
-{\r
- UINT32 Index;\r
-\r
- for (Index = 0; Index < Len; Index++) {\r
- Str[3 * Index] = (CHAR16) Ip4HexString[(Mac->Addr[Index] >> 4) & 0x0F];\r
- Str[3 * Index + 1] = (CHAR16) Ip4HexString[Mac->Addr[Index] & 0x0F];\r
- Str[3 * Index + 2] = L'-';\r
- }\r
-\r
- Str[3 * Index - 1] = L'\0';\r
-}\r
\r
/**\r
Calculate the prefix length of the IPv4 subnet mask.\r
}\r
\r
/**\r
- Get the IP4 configuration form entry by the index of the goto opcode actived.\r
-\r
- @param[in] Index The 0-based index of the goto opcode actived.\r
-\r
- @return The IP4 configuration form entry found.\r
+ Convert the IFR data into the network configuration data and set the IP\r
+ configure parameters for the NIC.\r
+\r
+ @param[in] IfrFormNvData The IFR nv data.\r
+ @param[in, out] Ip4ConfigInstance The IP4Config instance.\r
+ \r
+ @retval EFI_SUCCESS The configure parameter for this NIC was \r
+ set successfully.\r
+ @retval EFI_ALREADY_STARTED There is a pending auto configuration.\r
+ @retval EFI_NOT_FOUND No auto configure parameter is found.\r
+ \r
**/\r
-IP4CONFIG_FORM_ENTRY *\r
-Ip4GetConfigFormEntryByIndex (\r
- IN UINT32 Index\r
+EFI_STATUS\r
+Ip4ConfigConvertIfrNvDataToDeviceConfigData (\r
+ IN IP4_CONFIG_IFR_NVDATA *IfrFormNvData,\r
+ IN OUT IP4_CONFIG_INSTANCE *Ip4ConfigInstance\r
)\r
{\r
- UINT32 CurrentIndex;\r
- LIST_ENTRY *Entry;\r
- IP4CONFIG_FORM_ENTRY *ConfigFormEntry;\r
+ EFI_IP_ADDRESS HostIp;\r
+ EFI_IP_ADDRESS SubnetMask;\r
+ EFI_IP_ADDRESS Gateway;\r
+ EFI_INPUT_KEY Key;\r
+ NIC_IP4_CONFIG_INFO *NicInfo;\r
+ EFI_IP_ADDRESS Ip;\r
\r
- CurrentIndex = 0;\r
- ConfigFormEntry = NULL;\r
+ NicInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO) + 2 * sizeof (EFI_IP4_ROUTE_TABLE));\r
+ ASSERT (NicInfo != NULL);\r
\r
- NET_LIST_FOR_EACH (Entry, &mIp4ConfigFormList) {\r
- if (CurrentIndex == Index) {\r
- ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, IP4CONFIG_FORM_ENTRY, Link);\r
- break;\r
+ NicInfo->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (NicInfo + 1);\r
+\r
+ if (!Ip4ConfigInstance->Ip4ConfigCallbackInfo.Enabled) {\r
+ CopyMem (&HostIp.v4, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.LocalIp, sizeof (HostIp.v4));\r
+ CopyMem (&SubnetMask.v4, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.SubnetMask, sizeof (SubnetMask.v4));\r
+ CopyMem (&Gateway.v4, &Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway, sizeof (Gateway.v4));\r
+\r
+ if ((Gateway.Addr[0] != 0)) {\r
+ if (SubnetMask.Addr[0] == 0) {\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Gateway address is set but subnet mask is zero.", NULL);\r
+ return EFI_INVALID_PARAMETER;\r
+\r
+ } else if (!IP4_NET_EQUAL (HostIp.Addr[0], Gateway.Addr[0], SubnetMask.Addr[0])) {\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Local IP and Gateway are not in the same subnet.", NULL);\r
+ return EFI_INVALID_PARAMETER; }\r
}\r
\r
- CurrentIndex++;\r
+ NicInfo->Source = IP4_CONFIG_SOURCE_STATIC;\r
+ NicInfo->Ip4Info.RouteTableSize = 2;\r
+\r
+ CopyMem (&NicInfo->Ip4Info.StationAddress, &HostIp.v4, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&NicInfo->Ip4Info.SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));\r
+\r
+ Ip.Addr[0] = HostIp.Addr[0] & SubnetMask.Addr[0];\r
+\r
+ CopyMem (&NicInfo->Ip4Info.RouteTable[0].SubnetAddress, &Ip.v4, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&NicInfo->Ip4Info.RouteTable[0].SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));\r
+ CopyMem (&NicInfo->Ip4Info.RouteTable[1].GatewayAddress, &Gateway.v4, sizeof (EFI_IPv4_ADDRESS));\r
+ } else {\r
+ NicInfo->Source = IP4_CONFIG_SOURCE_DHCP;\r
}\r
\r
- return ConfigFormEntry;\r
+ NicInfo->Perment = TRUE;\r
+ CopyMem (&NicInfo->NicAddr, &Ip4ConfigInstance->NicAddr, sizeof (NIC_ADDR));\r
+\r
+ return EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE);\r
}\r
\r
/**\r
EFI_STATUS Status;\r
UINTN ConfigLen;\r
NIC_IP4_CONFIG_INFO *IfrDeviceNvData;\r
- IP4_FORM_CALLBACK_INFO *Private;\r
- EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
IP4_CONFIG_INSTANCE *Ip4ConfigInstance;\r
+ IP4_CONFIG_IFR_NVDATA *IfrFormNvData;\r
\r
- if (Request == NULL) {\r
+ if (Request == NULL || Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
*Progress = Request;\r
\r
+ Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This);\r
+\r
//\r
// Check Request data in <ConfigHdr>.\r
//\r
- if (!HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
- return EFI_NOT_FOUND;\r
- }\r
+ if (HiiIsConfigHdrMatch (Request, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
+ IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
+ if (IfrDeviceNvData == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
\r
- Private = IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
- Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO (Private);\r
+ ConfigLen = sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2;\r
+ Status = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance, &ConfigLen, IfrDeviceNvData);\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (IfrDeviceNvData);\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ \r
+ //\r
+ // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+ //\r
+ Status = gHiiConfigRouting->BlockToConfig (\r
+ gHiiConfigRouting,\r
+ Request,\r
+ (UINT8 *) IfrDeviceNvData,\r
+ NIC_ITEM_CONFIG_SIZE,\r
+ Results,\r
+ Progress\r
+ );\r
+ \r
+ FreePool (IfrDeviceNvData);\r
\r
- IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
- if (IfrDeviceNvData == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
+ } else if (HiiIsConfigHdrMatch (Request, &mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
\r
- Status = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance, &ConfigLen, IfrDeviceNvData);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (IfrDeviceNvData);\r
+ IfrFormNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
+ if (IfrFormNvData == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ \r
+ Ip4ConfigConvertDeviceConfigDataToIfrNvData (Ip4ConfigInstance, IfrFormNvData);\r
+ \r
+ //\r
+ // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+ //\r
+ Status = gHiiConfigRouting->BlockToConfig (\r
+ gHiiConfigRouting,\r
+ Request,\r
+ (UINT8 *) IfrFormNvData,\r
+ sizeof (IP4_CONFIG_IFR_NVDATA),\r
+ Results,\r
+ Progress\r
+ );\r
+ \r
+ FreePool (IfrFormNvData);\r
+\r
+ } else {\r
return EFI_NOT_FOUND;\r
}\r
\r
- //\r
- // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
- //\r
- HiiConfigRouting = Private->ConfigRouting;\r
- Status = HiiConfigRouting->BlockToConfig (\r
- HiiConfigRouting,\r
- Request,\r
- (UINT8 *) IfrDeviceNvData,\r
- NIC_ITEM_CONFIG_SIZE,\r
- Results,\r
- Progress\r
- );\r
-\r
- FreePool (IfrDeviceNvData);\r
\r
return Status;\r
}\r
EFI_STATUS Status;\r
UINTN BufferSize;\r
NIC_IP4_CONFIG_INFO *IfrDeviceNvData;\r
+ IP4_CONFIG_IFR_NVDATA *IfrFormNvData; \r
NIC_IP4_CONFIG_INFO *NicInfo;\r
- IP4_FORM_CALLBACK_INFO *Private;\r
- EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
IP4_CONFIG_INSTANCE *Ip4ConfigInstance;\r
EFI_MAC_ADDRESS ZeroMac;\r
\r
- if (Configuration == NULL) {\r
+ if (Configuration == NULL || Progress == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
*Progress = Configuration;\r
\r
- //\r
- // Check Routing data in <ConfigHdr>.\r
- //\r
- if (!HiiIsConfigHdrMatch (Configuration, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- Private = IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
- Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO (Private);\r
-\r
- IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
- if (IfrDeviceNvData == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
+ Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This);\r
\r
//\r
- // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+ // Check Routing data in <ConfigHdr>.\r
//\r
- HiiConfigRouting = Private->ConfigRouting;\r
- BufferSize = NIC_ITEM_CONFIG_SIZE;\r
- Status = HiiConfigRouting->ConfigToBlock (\r
- HiiConfigRouting,\r
- Configuration,\r
- (UINT8 *) IfrDeviceNvData,\r
- &BufferSize,\r
- Progress\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- ZeroMem (&ZeroMac, sizeof (EFI_MAC_ADDRESS));\r
- if (CompareMem (&IfrDeviceNvData->NicAddr.MacAddr, &ZeroMac, IfrDeviceNvData->NicAddr.Len) != 0) {\r
- BufferSize = sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * IfrDeviceNvData->Ip4Info.RouteTableSize;\r
- NicInfo = AllocateCopyPool (BufferSize, IfrDeviceNvData); \r
- Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE);\r
- } else {\r
- Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NULL, TRUE);\r
+ if (HiiIsConfigHdrMatch (Configuration, &mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
+ //\r
+ // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
+ //\r
+ IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG_IFR_NVDATA));\r
+ if (IfrFormNvData == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
}\r
- }\r
\r
- FreePool (IfrDeviceNvData);\r
- return Status;\r
-\r
-}\r
-\r
-/**\r
- This function allows the caller to request the current\r
- configuration for one or more named elements. The resulting\r
- string is in <ConfigAltResp> format. Any and all alternative\r
- configuration strings shall also be appended to the end of the\r
- current configuration string. If they are, they must appear\r
- after the current configuration. They must contain the same\r
- routing (GUID, NAME, PATH) as the current configuration string.\r
- They must have an additional description indicating the type of\r
- alternative configuration the string represents,\r
- "ALTCFG=<StringToken>". That <StringToken> (when\r
- converted from Hex UNICODE to binary) is a reference to a\r
- string in the associated string pack.\r
+ BufferSize = NIC_ITEM_CONFIG_SIZE;\r
+ Status = gHiiConfigRouting->ConfigToBlock (\r
+ gHiiConfigRouting,\r
+ Configuration,\r
+ (UINT8 *) IfrFormNvData,\r
+ &BufferSize,\r
+ Progress\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (IfrFormNvData, Ip4ConfigInstance);\r
+ }\r
+ \r
+ FreePool (IfrFormNvData);\r
\r
- @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param[in] Request A null-terminated Unicode string in\r
- <ConfigRequest> format. Note that this\r
- includes the routing information as well as\r
- the configurable name / value pairs. It is\r
- invalid for this string to be in\r
- <MultiConfigRequest> format.\r
- @param[out] Progress On return, points to a character in the\r
- Request string. Points to the string's null\r
- terminator if request was successful. Points\r
- to the most recent "&" before the first\r
- failing name / value pair (or the beginning\r
- of the string if the failure is in the first\r
- name / value pair) if the request was not\r
- successful.\r
- @param[out] Results A null-terminated Unicode string in\r
- <ConfigAltResp> format which has all values\r
- filled in for the names in the Request string.\r
- String to be allocated by the called function.\r
+ } else if (HiiIsConfigHdrMatch (Configuration, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
\r
- @retval EFI_SUCCESS The Results string is filled with the\r
- values corresponding to all requested\r
- names.\r
- @retval EFI_OUT_OF_RESOURCES Not enough memory to store the\r
- parts of the results that must be\r
- stored awaiting possible future\r
- protocols.\r
- @retval EFI_INVALID_PARAMETER For example, passing in a NULL\r
- for the Request parameter\r
- would result in this type of\r
- error. In this case, the\r
- Progress parameter would be\r
- set to NULL.\r
- @retval EFI_NOT_FOUND Routing data doesn't match any\r
- known driver. Progress set to the\r
- first character in the routing header.\r
- Note: There is no requirement that the\r
- driver validate the routing data. It\r
- must skip the <ConfigHdr> in order to\r
- process the names.\r
- @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set\r
- to most recent & before the\r
- error or the beginning of the\r
- string.\r
- @retval EFI_INVALID_PARAMETER Unknown name. Progress points\r
- to the & before the name in\r
- question.Currently not implemented.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ip4FormExtractConfig (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN CONST EFI_STRING Request,\r
- OUT EFI_STRING *Progress,\r
- OUT EFI_STRING *Results\r
- )\r
-{\r
- if (Request == NULL || Progress == NULL || Results == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- *Progress = Request;\r
- return EFI_NOT_FOUND;\r
-}\r
+ IfrDeviceNvData = AllocateZeroPool (NIC_ITEM_CONFIG_SIZE);\r
+ if (IfrDeviceNvData == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
\r
-/**\r
- This function applies changes in a driver's configuration.\r
- Input is a Configuration, which has the routing data for this\r
- driver followed by name / value configuration pairs. The driver\r
- must apply those pairs to its configurable storage. If the\r
- driver's configuration is stored in a linear block of data\r
- and the driver's name / value pairs are in <BlockConfig>\r
- format, it may use the ConfigToBlock helper function (above) to\r
- simplify the job. Currently not implemented.\r
+ BufferSize = NIC_ITEM_CONFIG_SIZE;\r
+ Status = gHiiConfigRouting->ConfigToBlock (\r
+ gHiiConfigRouting,\r
+ Configuration,\r
+ (UINT8 *) IfrDeviceNvData,\r
+ &BufferSize,\r
+ Progress\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ ZeroMem (&ZeroMac, sizeof (EFI_MAC_ADDRESS));\r
+ if (CompareMem (&IfrDeviceNvData->NicAddr.MacAddr, &ZeroMac, IfrDeviceNvData->NicAddr.Len) != 0) {\r
+ BufferSize = sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * IfrDeviceNvData->Ip4Info.RouteTableSize;\r
+ NicInfo = AllocateCopyPool (BufferSize, IfrDeviceNvData); \r
+ Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE);\r
+ } else {\r
+ Status = EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NULL, TRUE);\r
+ }\r
+ }\r
\r
- @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param[in] Configuration A null-terminated Unicode string in\r
- <ConfigString> format.\r
- @param[out] Progress A pointer to a string filled in with the\r
- offset of the most recent '&' before the\r
- first failing name / value pair (or the\r
- beginn ing of the string if the failure\r
- is in the first name / value pair) or\r
- the terminating NULL if all was\r
- successful.\r
+ FreePool (IfrDeviceNvData);\r
\r
- @retval EFI_SUCCESS The results have been distributed or are\r
- awaiting distribution.\r
- @retval EFI_OUT_OF_MEMORY Not enough memory to store the\r
- parts of the results that must be\r
- stored awaiting possible future\r
- protocols.\r
- @retval EFI_INVALID_PARAMETERS Passing in a NULL for the\r
- Results parameter would result\r
- in this type of error.\r
- @retval EFI_NOT_FOUND Target for the specified routing data\r
- was not found.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-Ip4FormRouteConfig (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN CONST EFI_STRING Configuration,\r
- OUT EFI_STRING *Progress\r
- )\r
-{\r
- if (Configuration == NULL || Progress == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ } else {\r
\r
- *Progress = Configuration;\r
- if (!HiiIsConfigHdrMatch (Configuration, &gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE)) {\r
return EFI_NOT_FOUND;\r
}\r
+ \r
+ return Status;\r
\r
- *Progress = Configuration + StrLen (Configuration);\r
- return EFI_SUCCESS;\r
}\r
\r
/**\r
)\r
{\r
IP4_CONFIG_INSTANCE *Ip4ConfigInstance;\r
- IP4_FORM_CALLBACK_INFO *Private;\r
CHAR8 Ip4String[IP4_STR_MAX_SIZE];\r
- CHAR16 PortString[128];\r
- EFI_STRING_ID DeviceFormTitleToken;\r
IP4_CONFIG_IFR_NVDATA *IfrFormNvData;\r
- IP4CONFIG_FORM_ENTRY *ConfigFormEntry;\r
EFI_IP_ADDRESS HostIp;\r
EFI_IP_ADDRESS SubnetMask;\r
EFI_IP_ADDRESS Gateway;\r
EFI_STATUS Status;\r
EFI_INPUT_KEY Key;\r
- NIC_IP4_CONFIG_INFO *NicInfo;\r
- EFI_IP_ADDRESS Ip;\r
-\r
- ConfigFormEntry = NULL;\r
\r
- Private = IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
+ Ip4ConfigInstance = IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS (This);\r
\r
IfrFormNvData = AllocateZeroPool (sizeof (IP4_CONFIG_IFR_NVDATA));\r
if (IfrFormNvData == NULL) {\r
//\r
// Retrive uncommitted data from Browser\r
//\r
- if (!HiiGetBrowserData (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, sizeof (IP4_CONFIG_IFR_NVDATA), (UINT8 *) IfrFormNvData)) {\r
+ if (!HiiGetBrowserData (&mNicIp4ConfigNvDataGuid, EFI_NIC_IP4_CONFIG_VARIABLE, sizeof (IP4_CONFIG_IFR_NVDATA), (UINT8 *) IfrFormNvData)) {\r
FreePool (IfrFormNvData);\r
return EFI_NOT_FOUND;\r
}\r
\r
case KEY_DHCP_ENABLE:\r
if (IfrFormNvData->DhcpEnable == 0) {\r
- Private->Current->SessionConfigData.Enabled = FALSE;\r
+ Ip4ConfigInstance->Ip4ConfigCallbackInfo.Enabled = FALSE;\r
} else {\r
- Private->Current->SessionConfigData.Enabled = TRUE;\r
+ Ip4ConfigInstance->Ip4ConfigCallbackInfo.Enabled = TRUE;\r
}\r
\r
break;\r
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
- CopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));\r
+ CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.LocalIp, &HostIp.v4, sizeof (HostIp.v4));\r
}\r
\r
break;\r
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid SubnetMask!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
- CopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));\r
+ CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));\r
}\r
\r
break;\r
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
- CopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));\r
+ CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway, &Gateway.v4, sizeof (Gateway.v4));\r
}\r
\r
break;\r
\r
case KEY_SAVE_CHANGES:\r
- Ip4ConfigInstance = Private->Current->Ip4ConfigInstance;\r
- NicInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO) + 2 * sizeof (EFI_IP4_ROUTE_TABLE));\r
- ASSERT (NicInfo != NULL);\r
-\r
- NicInfo->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (NicInfo + 1);\r
-\r
- if (!Private->Current->SessionConfigData.Enabled) {\r
- CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.LocalIp, sizeof (HostIp.v4));\r
- CopyMem (&SubnetMask.v4, &Private->Current->SessionConfigData.SubnetMask, sizeof (SubnetMask.v4));\r
- CopyMem (&Gateway.v4, &Private->Current->SessionConfigData.Gateway, sizeof (Gateway.v4));\r
-\r
- if ((Gateway.Addr[0] != 0)) {\r
- if (SubnetMask.Addr[0] == 0) {\r
- CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Gateway address is set but subnet mask is zero.", NULL);\r
- Status = EFI_INVALID_PARAMETER;\r
- break;\r
- } else if (!IP4_NET_EQUAL (HostIp.Addr[0], Gateway.Addr[0], SubnetMask.Addr[0])) {\r
- CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Local IP and Gateway are not in the same subnet.", NULL);\r
- Status = EFI_INVALID_PARAMETER;\r
- break;\r
- }\r
- }\r
-\r
- NicInfo->Source = IP4_CONFIG_SOURCE_STATIC;\r
- NicInfo->Ip4Info.RouteTableSize = 2;\r
-\r
- CopyMem (&NicInfo->Ip4Info.StationAddress, &HostIp.v4, sizeof (EFI_IPv4_ADDRESS));\r
- CopyMem (&NicInfo->Ip4Info.SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));\r
-\r
- Ip.Addr[0] = HostIp.Addr[0] & SubnetMask.Addr[0];\r
-\r
- CopyMem (&NicInfo->Ip4Info.RouteTable[0].SubnetAddress, &Ip.v4, sizeof (EFI_IPv4_ADDRESS));\r
- CopyMem (&NicInfo->Ip4Info.RouteTable[0].SubnetMask, &SubnetMask.v4, sizeof (EFI_IPv4_ADDRESS));\r
- CopyMem (&NicInfo->Ip4Info.RouteTable[1].GatewayAddress, &Gateway.v4, sizeof (EFI_IPv4_ADDRESS));\r
- } else {\r
- NicInfo->Source = IP4_CONFIG_SOURCE_DHCP;\r
- }\r
-\r
- NicInfo->Perment = TRUE;\r
- CopyMem (&NicInfo->NicAddr, &Ip4ConfigInstance->NicAddr, sizeof (NIC_ADDR));\r
-\r
- EfiNicIp4ConfigSetInfo (Ip4ConfigInstance, NicInfo, TRUE);\r
-\r
+ Status = Ip4ConfigConvertIfrNvDataToDeviceConfigData (IfrFormNvData, Ip4ConfigInstance);\r
+ \r
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
+\r
break;\r
\r
default:\r
- if ((QuestionId >= KEY_DEVICE_ENTRY_BASE) && (QuestionId < (mNumberOfIp4Devices + KEY_DEVICE_ENTRY_BASE))) {\r
- //\r
- // In case goto the device configuration form, update the device form title.\r
- //\r
- ConfigFormEntry = Ip4GetConfigFormEntryByIndex ((UINT32) (QuestionId - KEY_DEVICE_ENTRY_BASE));\r
- ASSERT (ConfigFormEntry != NULL);\r
-\r
- Ip4ConfigInstance = ConfigFormEntry->Ip4ConfigInstance;\r
-\r
- UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);\r
- DeviceFormTitleToken = (EFI_STRING_ID) STR_IP4_DEVICE_FORM_TITLE;\r
- HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString, NULL);\r
-\r
- Ip4ConfigConvertDeviceConfigDataToIfrNvData (Ip4ConfigInstance, IfrFormNvData);\r
-\r
- Private->Current = ConfigFormEntry;\r
- }\r
-\r
+ \r
break;\r
}\r
\r
if (!EFI_ERROR (Status)) {\r
-\r
//\r
// Pass changed uncommitted data back to Form Browser\r
//\r
}\r
\r
FreePool (IfrFormNvData);\r
+\r
return Status;\r
}\r
\r
**/\r
EFI_STATUS\r
Ip4ConfigDeviceInit (\r
- IN IP4_CONFIG_INSTANCE *Instance\r
+ IN IP4_CONFIG_INSTANCE *Instance\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r
- IP4_FORM_CALLBACK_INFO *CallbackInfo;\r
-\r
- Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
+ EFI_STATUS Status;\r
+ EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
+ VENDOR_DEVICE_PATH VendorDeviceNode;\r
+ EFI_SERVICE_BINDING_PROTOCOL *MnpSb;\r
+ CHAR16 *MacString;\r
+ CHAR16 MenuString[128];\r
+ CHAR16 PortString[128];\r
+ CHAR16 *OldMenuString;\r
\r
- CallbackInfo = &Instance->Ip4FormCallbackInfo;\r
+ ConfigAccess = &Instance->HiiConfigAccessProtocol;\r
+ ConfigAccess->ExtractConfig = Ip4DeviceExtractConfig;\r
+ ConfigAccess->RouteConfig = Ip4DeviceRouteConfig;\r
+ ConfigAccess->Callback = Ip4FormCallback;\r
\r
- CallbackInfo->Signature = IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE;\r
- CallbackInfo->HiiDatabase = HiiDatabase;\r
+ //\r
+ // Construct device path node for EFI HII Config Access protocol,\r
+ // which consists of controller physical device path and one hardware\r
+ // vendor guid node.\r
+ //\r
+ ZeroMem (&VendorDeviceNode, sizeof (VENDOR_DEVICE_PATH));\r
+ VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH;\r
+ VendorDeviceNode.Header.SubType = HW_VENDOR_DP;\r
\r
- CallbackInfo->ConfigAccess.ExtractConfig = Ip4DeviceExtractConfig;\r
- CallbackInfo->ConfigAccess.RouteConfig = Ip4DeviceRouteConfig;\r
- CallbackInfo->ConfigAccess.Callback = NULL;\r
+ CopyGuid (&VendorDeviceNode.Guid, &gEfiNicIp4ConfigVariableGuid);\r
\r
- Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&CallbackInfo->ConfigRouting);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
+ SetDevicePathNodeLength (&VendorDeviceNode.Header, sizeof (VENDOR_DEVICE_PATH));\r
+ Instance->HiiVendorDevicePath = AppendDevicePathNode (\r
+ Instance->ParentDevicePath,\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &VendorDeviceNode\r
+ );\r
\r
- CallbackInfo->DriverHandle = Instance->Controller;\r
+ Instance->ChildHandle = NULL;\r
//\r
- // Install Device Path Protocol and Config Access protocol to driver handle\r
+ // Install Device Path Protocol and Config Access protocol on new handle\r
//\r
Status = gBS->InstallMultipleProtocolInterfaces (\r
- &CallbackInfo->DriverHandle,\r
+ &Instance->ChildHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ Instance->HiiVendorDevicePath, \r
&gEfiHiiConfigAccessProtocolGuid,\r
- &CallbackInfo->ConfigAccess,\r
+ ConfigAccess,\r
NULL\r
);\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Open the Parent Handle for the child\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Instance->Controller,\r
+ &gEfiManagedNetworkServiceBindingProtocolGuid,\r
+ (VOID **) &MnpSb,\r
+ Instance->Image,\r
+ Instance->ChildHandle, \r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ }\r
+\r
ASSERT_EFI_ERROR (Status);\r
+ \r
+ //\r
+ // Publish our HII data\r
+ //\r
+ Instance->RegisteredHandle = HiiAddPackages (\r
+ &mNicIp4ConfigNvDataGuid,\r
+ Instance->ChildHandle,\r
+ Ip4ConfigDxeStrings,\r
+ Ip4ConfigDxeBin,\r
+ NULL\r
+ );\r
+ if (Instance->RegisteredHandle == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ //\r
+ // Append MAC string in the menu string and tile string\r
+ //\r
+ Status = NetLibGetMacString (Instance->Controller, Instance->Image, &MacString);\r
+ if (!EFI_ERROR (Status)) {\r
+ OldMenuString = HiiGetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_CONFIG_FORM_TITLE), NULL);\r
+ UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);\r
+ HiiSetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_CONFIG_FORM_TITLE), MenuString, NULL);\r
+ \r
+ UnicodeSPrint (PortString, 128, L"MAC:%s", MacString);\r
+ HiiSetString (Instance->RegisteredHandle, STRING_TOKEN (STR_IP4_DEVICE_FORM_TITLE), PortString, NULL);\r
+ FreePool (MacString);\r
+ }\r
\r
return Status;\r
}\r
IN IP4_CONFIG_INSTANCE *Instance\r
)\r
{\r
- IP4_FORM_CALLBACK_INFO *CallbackInfo;\r
-\r
- CallbackInfo = &Instance->Ip4FormCallbackInfo;\r
-\r
- Ip4ConfigUpdateForm (Instance, FALSE);\r
-\r
//\r
- // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL\r
+ // Remove HII package list\r
//\r
- gBS->UninstallMultipleProtocolInterfaces (\r
- CallbackInfo->DriverHandle,\r
- &gEfiHiiConfigAccessProtocolGuid,\r
- &CallbackInfo->ConfigAccess,\r
- NULL\r
- );\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Unload the network configuration form, this includes: delete all the network\r
- device configuration entries, uninstall the form callback protocol and\r
- free the resources used.\r
-\r
- @retval EFI_SUCCESS The network configuration form is unloaded.\r
-**/\r
-EFI_STATUS\r
-Ip4ConfigFormUnload (\r
- VOID\r
- )\r
-{\r
- IP4CONFIG_FORM_ENTRY *ConfigFormEntry;\r
-\r
- while (!IsListEmpty (&mIp4ConfigFormList)) {\r
- //\r
- // Uninstall the device forms as the network driver instance may fail to\r
- // control the controller but still install the device configuration form.\r
- // In such case, upon driver unloading, the driver instance's driverbinding.\r
- // stop () won't be called, so we have to take this chance here to uninstall\r
- // the device form.\r
- //\r
- ConfigFormEntry = NET_LIST_USER_STRUCT (mIp4ConfigFormList.ForwardLink, IP4CONFIG_FORM_ENTRY, Link);\r
- Ip4ConfigUpdateForm (ConfigFormEntry->Ip4ConfigInstance, FALSE);\r
- }\r
+ HiiRemovePackages (Instance->RegisteredHandle);\r
\r
//\r
- // Remove HII package list\r
+ // Close the child handle\r
//\r
- mCallbackInfo->HiiDatabase->RemovePackageList (\r
- mCallbackInfo->HiiDatabase,\r
- mCallbackInfo->RegisteredHandle\r
- );\r
+ gBS->CloseProtocol (\r
+ Instance->Controller,\r
+ &gEfiManagedNetworkServiceBindingProtocolGuid,\r
+ Instance->Image,\r
+ Instance->ChildHandle\r
+ );\r
\r
//\r
// Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL\r
//\r
gBS->UninstallMultipleProtocolInterfaces (\r
- mCallbackInfo->DriverHandle,\r
+ Instance->ChildHandle,\r
&gEfiDevicePathProtocolGuid,\r
- &mIp4ConifgHiiVendorDevicePath,\r
+ Instance->HiiVendorDevicePath, \r
&gEfiHiiConfigAccessProtocolGuid,\r
- &mCallbackInfo->ConfigAccess,\r
+ &Instance->HiiConfigAccessProtocol,\r
NULL\r
);\r
\r
- FreePool (mCallbackInfo);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Updates the network configuration form to add/delete an entry for the network\r
- device specified by the Instance.\r
-\r
- @param[in] Instance The IP4 Config instance.\r
- @param[in] AddForm Whether to add or delete a form entry.\r
-\r
- @retval EFI_SUCCESS The network configuration form is updated.\r
- @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
- @retval Others Other errors as indicated.\r
-**/\r
-EFI_STATUS\r
-Ip4ConfigUpdateForm (\r
- IN IP4_CONFIG_INSTANCE *Instance,\r
- IN BOOLEAN AddForm\r
- )\r
-{\r
- LIST_ENTRY *Entry;\r
- IP4CONFIG_FORM_ENTRY *ConfigFormEntry;\r
- BOOLEAN EntryExisted;\r
- EFI_STATUS Status;\r
- CHAR16 PortString[128];\r
- UINT16 FormIndex;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- ConfigFormEntry = NULL;\r
- EntryExisted = FALSE;\r
-\r
- NET_LIST_FOR_EACH (Entry, &mIp4ConfigFormList) {\r
- ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, IP4CONFIG_FORM_ENTRY, Link);\r
-\r
- if (ConfigFormEntry->Controller == Instance->Controller) {\r
- EntryExisted = TRUE;\r
- break;\r
- }\r
- }\r
-\r
- if (AddForm) {\r
- if (EntryExisted) {\r
- return EFI_SUCCESS;\r
- } else {\r
- //\r
- // Add a new form.\r
- //\r
- ConfigFormEntry = (IP4CONFIG_FORM_ENTRY *) AllocateZeroPool (sizeof (IP4CONFIG_FORM_ENTRY));\r
- if (ConfigFormEntry == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- ConfigFormEntry->Ip4ConfigInstance = Instance;\r
- InitializeListHead (&ConfigFormEntry->Link);\r
- ConfigFormEntry->Controller = Instance->Controller;\r
-\r
- Status = NetLibGetMacString (Instance->Controller, Instance->Image, &ConfigFormEntry->MacString);\r
- ASSERT (Status == EFI_SUCCESS);\r
-\r
- //\r
- // Compose the Port string and create a new EFI_STRING_ID.\r
- //\r
- UnicodeSPrint (PortString, 128, L"%s %s", Instance->NicName, ConfigFormEntry->MacString);\r
- ConfigFormEntry->PortTitleToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);\r
-\r
- //\r
- // Compose the help string of this port and create a new EFI_STRING_ID.\r
- //\r
- UnicodeSPrint (PortString, 128, L"Set the network parameters on eth%d %s", 0, ConfigFormEntry->MacString);\r
- ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);\r
-\r
- InsertTailList (&mIp4ConfigFormList, &ConfigFormEntry->Link);\r
- mNumberOfIp4Devices++;\r
- }\r
- } else {\r
- ASSERT (EntryExisted);\r
-\r
- mNumberOfIp4Devices--;\r
- RemoveEntryList (&ConfigFormEntry->Link);\r
- FreePool (ConfigFormEntry->MacString);\r
- FreePool (ConfigFormEntry);\r
- }\r
-\r
- //\r
- // Init OpCode Handle\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode as the start opcode\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = DEVICE_ENTRY_LABEL;\r
-\r
- //\r
- // Create Hii Extend Label OpCode as the end opcode\r
- //\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- FormIndex = 0;\r
-\r
- FormIndex = 0;\r
- NET_LIST_FOR_EACH (Entry, &mIp4ConfigFormList) {\r
- ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, IP4CONFIG_FORM_ENTRY, Link);\r
-\r
- HiiCreateGotoOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- FORMID_DEVICE_FORM, // Target Form ID\r
- ConfigFormEntry->PortTitleToken, // Prompt text\r
- ConfigFormEntry->PortTitleHelpToken, // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- (UINT16)(KEY_DEVICE_ENTRY_BASE + FormIndex) // Question ID\r
- );\r
-\r
- FormIndex++;\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->RegisteredHandle,\r
- &gEfiNicIp4ConfigVariableGuid,\r
- FORMID_MAIN_FORM,\r
- StartOpCodeHandle, // Label DEVICE_ENTRY_LABEL\r
- EndOpCodeHandle // LABEL_END\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-\r
return EFI_SUCCESS;\r
}\r
-\r
-/**\r
- Initialize the network configuration form, this includes: delete all the network\r
- device configuration entries, install the form callback protocol and\r
- allocate the resources used.\r
-\r
- @retval EFI_SUCCESS The network configuration form is unloaded.\r
- @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-**/\r
-EFI_STATUS\r
-Ip4ConfigFormInit (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r
- IP4_FORM_CALLBACK_INFO *CallbackInfo;\r
-\r
- Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- CallbackInfo = (IP4_FORM_CALLBACK_INFO *) AllocateZeroPool (sizeof (IP4_FORM_CALLBACK_INFO));\r
- if (CallbackInfo == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- CallbackInfo->Signature = IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE;\r
- CallbackInfo->HiiDatabase = HiiDatabase;\r
-\r
- CallbackInfo->ConfigAccess.ExtractConfig = Ip4FormExtractConfig;\r
- CallbackInfo->ConfigAccess.RouteConfig = Ip4FormRouteConfig;\r
- CallbackInfo->ConfigAccess.Callback = Ip4FormCallback;\r
-\r
- Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&CallbackInfo->ConfigRouting);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- CallbackInfo->DriverHandle = NULL;\r
- //\r
- // Install Device Path Protocol and Config Access protocol to driver handle\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &CallbackInfo->DriverHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- &mIp4ConifgHiiVendorDevicePath,\r
- &gEfiHiiConfigAccessProtocolGuid,\r
- &CallbackInfo->ConfigAccess,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Publish our HII data\r
- //\r
- CallbackInfo->RegisteredHandle = HiiAddPackages (\r
- &gEfiNicIp4ConfigVariableGuid,\r
- CallbackInfo->DriverHandle,\r
- Ip4ConfigDxeStrings,\r
- Ip4ConfigDxeBin,\r
- NULL\r
- );\r
- if (CallbackInfo->RegisteredHandle == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- mCallbackInfo = CallbackInfo;\r
-\r
- return Status;\r
-}\r