/** @file\r
- Helper functions for configuring or getting the parameters relating to ISCSI\r
+ Helper functions for configuring or getting the parameters relating to iSCSI.\r
\r
-Copyright (c) 2004 - 2008, Intel Corporation\r
+Copyright (c) 2004 - 2010, 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\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- IScsiConfig.c\r
-\r
-Abstract:\r
-\r
- Helper functions for configuring or getting the parameters relating to ISCSI\r
-\r
**/\r
\r
#include "IScsiImpl.h"\r
\r
EFI_GUID mVendorGuid = ISCSI_CONFIG_GUID;\r
+CHAR16 mVendorStorageName[] = L"ISCSI_CONFIG_IFR_NVDATA";\r
BOOLEAN mIScsiDeviceListUpdated = FALSE;\r
UINTN mNumberOfIScsiDevices = 0;\r
ISCSI_FORM_CALLBACK_INFO *mCallbackInfo = NULL;\r
&mIScsiConfigFormList\r
};\r
\r
+HII_VENDOR_DEVICE_PATH mIScsiHiiVendorDevicePath = {\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
+ // {49D7B73E-143D-4716-977B-C45F1CB038CC}\r
+ //\r
+ { 0x49d7b73e, 0x143d, 0x4716, { 0x97, 0x7b, 0xc4, 0x5f, 0x1c, 0xb0, 0x38, 0xcc } }\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 IPv4 address into a dotted string.\r
\r
- @param Ip[in] The IPv4 address.\r
-\r
- @param Str[out] The dotted IP string.\r
-\r
- @retval None.\r
-\r
+ @param[in] Ip The IPv4 address.\r
+ @param[out] Str The dotted IP string.\r
**/\r
VOID\r
IScsiIpToStr (\r
UnicodeSPrint ( Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip->Addr[1], Ip->Addr[2], Ip->Addr[3]);\r
}\r
\r
-/**\r
- Pop up an invalid notify which displays the message in Warning.\r
-\r
- @param Warning[in] The warning message.\r
-\r
- @retval None.\r
-\r
-**/\r
-VOID\r
-PopUpInvalidNotify (\r
- IN CHAR16 *Warning\r
- )\r
-{\r
- EFI_INPUT_KEY Key;\r
-\r
- IfrLibCreatePopUp (1, &Key, Warning);\r
-}\r
-\r
/**\r
Update the list of iSCSI devices the iSCSI driver is controlling.\r
\r
- @param None.\r
-\r
- @retval None.\r
-\r
+ @retval EFI_SUCCESS The callback successfully handled the action.\r
+ @retval Others Other errors as indicated. \r
**/\r
EFI_STATUS\r
IScsiUpdateDeviceList (\r
UINTN HandleIndex;\r
UINTN Index;\r
UINTN LastDeviceIndex;\r
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
- EFI_SIMPLE_NETWORK_MODE *Mode;\r
+ EFI_MAC_ADDRESS MacAddress;\r
+ UINTN HwAddressSize;\r
+ UINT16 VlanId;\r
ISCSI_MAC_INFO *CurMacInfo;\r
ISCSI_MAC_INFO TempMacInfo;\r
- CHAR16 MacString[65];\r
+ CHAR16 MacString[70];\r
UINTN DeviceListSize;\r
\r
//\r
- // Dump all the handles the Simple Network Protocol is installed on.\r
+ // Dump all the handles the Managed Network Service Binding Protocol is installed on.\r
//\r
Status = gBS->LocateHandleBuffer (\r
ByProtocol,\r
- &gEfiSimpleNetworkProtocolGuid,\r
+ &gEfiManagedNetworkServiceBindingProtocolGuid,\r
NULL,\r
&NumHandles,\r
&Handles\r
LastDeviceIndex = 0;\r
\r
for (HandleIndex = 0; HandleIndex < NumHandles; HandleIndex++) {\r
- gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
-\r
- Mode = Snp->Mode;\r
+ Status = NetLibGetMacAddress (Handles[HandleIndex], &MacAddress, &HwAddressSize);\r
+ ASSERT (Status == EFI_SUCCESS);\r
+ VlanId = NetLibGetVlanId (Handles[HandleIndex]);\r
\r
for (Index = LastDeviceIndex; Index < DeviceList->NumDevice; Index++) {\r
CurMacInfo = &DeviceList->MacInfo[Index];\r
- if ((CurMacInfo->Len == Mode->HwAddressSize) &&\r
- (NET_MAC_EQUAL (&CurMacInfo->Mac, &Mode->PermanentAddress, Mode->HwAddressSize))\r
+ if ((CurMacInfo->Len == HwAddressSize) &&\r
+ (CurMacInfo->VlanId == VlanId) &&\r
+ (NET_MAC_EQUAL (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize))\r
) {\r
//\r
// The previous configured NIC is still here.\r
// delete the variables\r
//\r
CurMacInfo = &DeviceList->MacInfo[Index];\r
- IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, MacString);\r
+ IScsiMacAddrToStr (&CurMacInfo->Mac, CurMacInfo->Len, CurMacInfo->VlanId, MacString);\r
gRT->SetVariable (MacString, &gEfiIScsiInitiatorNameProtocolGuid, 0, 0, NULL);\r
gRT->SetVariable (MacString, &mIScsiCHAPAuthInfoGuid, 0, 0, NULL);\r
}\r
\r
- gBS->FreePool (DeviceList);\r
+ FreePool (DeviceList);\r
} else if (Status != EFI_NOT_FOUND) {\r
- gBS->FreePool (Handles);\r
+ FreePool (Handles);\r
return Status;\r
}\r
//\r
DeviceList->NumDevice = (UINT8) NumHandles;\r
\r
for (Index = 0; Index < NumHandles; Index++) {\r
- gBS->HandleProtocol (Handles[Index], &gEfiSimpleNetworkProtocolGuid, (VOID **)&Snp);\r
- Mode = Snp->Mode;\r
+ NetLibGetMacAddress (Handles[Index], &MacAddress, &HwAddressSize);\r
\r
CurMacInfo = &DeviceList->MacInfo[Index];\r
- CopyMem (&CurMacInfo->Mac, &Mode->PermanentAddress, Mode->HwAddressSize);\r
- CurMacInfo->Len = (UINT8) Mode->HwAddressSize;\r
+ CopyMem (&CurMacInfo->Mac, MacAddress.Addr, HwAddressSize);\r
+ CurMacInfo->Len = (UINT8) HwAddressSize;\r
+ CurMacInfo->VlanId = NetLibGetVlanId (Handles[Index]);\r
}\r
\r
gRT->SetVariable (\r
DeviceList\r
);\r
\r
- gBS->FreePool (DeviceList);\r
- gBS->FreePool (Handles);\r
+ FreePool (DeviceList);\r
+ FreePool (Handles);\r
\r
return Status;\r
}\r
/**\r
Get the iSCSI configuration form entry by the index of the goto opcode actived.\r
\r
- @param Index[in] The 0-based index of the goto opcode actived.\r
-\r
- @retval The iSCSI configuration form entry found.\r
+ @param[in] Index The 0-based index of the goto opcode actived.\r
\r
+ @return The iSCSI configuration form entry found.\r
**/\r
ISCSI_CONFIG_FORM_ENTRY *\r
IScsiGetConfigFormEntryByIndex (\r
/**\r
Convert the iSCSI configuration data into the IFR data.\r
\r
- @param ConfigFormEntry[in] The iSCSI configuration form entry.\r
-\r
- @param IfrNvData[in] The IFR nv data.\r
-\r
- @retval None.\r
-\r
+ @param[in] ConfigFormEntry The iSCSI configuration form entry.\r
+ @param[out] IfrNvData The IFR nv data.\r
**/\r
VOID\r
IScsiConvertDeviceConfigDataToIfrNvData (\r
- IN ISCSI_CONFIG_FORM_ENTRY *ConfigFormEntry,\r
- IN ISCSI_CONFIG_IFR_NVDATA *IfrNvData\r
+ IN ISCSI_CONFIG_FORM_ENTRY *ConfigFormEntry,\r
+ OUT ISCSI_CONFIG_IFR_NVDATA *IfrNvData\r
)\r
{\r
ISCSI_SESSION_CONFIG_NVDATA *SessionConfigData;\r
}\r
\r
/**\r
- This function allows a caller to extract the current configuration for one\r
- or more named elements from the target driver.\r
-\r
- @param This[in] Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-\r
- @param Request[in] A null-terminated Unicode string in <ConfigRequest> format.\r
-\r
- @param Progress[out] On return, points to a character in the Request string.\r
- Points to the string's null terminator if request was successful.\r
- Points to the most recent '&' before the first failing name/value\r
- pair (or the beginning of the string if the failure is in the\r
- first name/value pair) if the request was not successful.\r
-\r
- @param Results[out] A null-terminated Unicode string in <ConfigAltResp> format which\r
- has all values filled in for the names in the Request string.\r
- String to be allocated by the called function.\r
-\r
- @retval EFI_SUCCESS The Results is filled with the requested values.\r
-\r
- @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
-\r
- @retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.\r
-\r
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\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
+\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
+\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
ISCSI_CONFIG_IFR_NVDATA *IfrNvData;\r
ISCSI_FORM_CALLBACK_INFO *Private;\r
EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
+ EFI_STRING ConfigRequestHdr;\r
+ EFI_STRING ConfigRequest;\r
+ BOOLEAN AllocatedRequest;\r
+ UINTN Size;\r
+\r
+ if (Progress == NULL || Results == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *Progress = Request;\r
+ if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mVendorGuid, mVendorStorageName)) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ ConfigRequestHdr = NULL;\r
+ ConfigRequest = NULL;\r
+ AllocatedRequest = FALSE;\r
+ Size = 0;\r
\r
if (!mIScsiDeviceListUpdated) {\r
//\r
//\r
HiiConfigRouting = Private->ConfigRouting;\r
BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
+ ConfigRequest = Request;\r
+ if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+ //\r
+ // Request has no request element, construct full request string.\r
+ // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+ // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+ //\r
+ ConfigRequestHdr = HiiConstructConfigHdr (&mVendorGuid, mVendorStorageName, Private->DriverHandle);\r
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+ ConfigRequest = AllocateZeroPool (Size);\r
+ ASSERT (ConfigRequest != NULL);\r
+ AllocatedRequest = TRUE;\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+ FreePool (ConfigRequestHdr);\r
+ }\r
Status = HiiConfigRouting->BlockToConfig (\r
HiiConfigRouting,\r
- Request,\r
+ ConfigRequest,\r
(UINT8 *) IfrNvData,\r
BufferSize,\r
Results,\r
Progress\r
);\r
- gBS->FreePool (IfrNvData);\r
+ FreePool (IfrNvData);\r
+ //\r
+ // Free the allocated config request string.\r
+ //\r
+ if (AllocatedRequest) {\r
+ FreePool (ConfigRequest);\r
+ ConfigRequest = NULL;\r
+ }\r
+\r
+ //\r
+ // Set Progress string to the original request string.\r
+ //\r
+ if (Request == NULL) {\r
+ *Progress = NULL;\r
+ } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+ *Progress = Request + StrLen (Request);\r
+ }\r
+\r
return Status;\r
}\r
\r
/**\r
- This function processes the results of changes in configuration.\r
-\r
- @param This[in] Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-\r
- @param Configuration[in] A null-terminated Unicode string in <ConfigResp> format.\r
-\r
- @param Progress[out] A pointer to a string filled in with the offset of the most\r
- recent '&' before the first failing name/value pair (or the\r
- beginning of the string if the failure is in the first\r
- name/value pair) or the terminating NULL if all was successful.\r
-\r
- @retval EFI_SUCCESS The Results is processed successfully.\r
-\r
- @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
-\r
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\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
+\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
+\r
+ @retval EFI_SUCCESS The results have been distributed or are\r
+ awaiting distribution. \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_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
OUT EFI_STRING *Progress\r
)\r
{\r
+ if (Configuration == NULL || Progress == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Check routing data in <ConfigHdr>.\r
+ // Note: if only one Storage is used, then this checking could be skipped.\r
+ //\r
+ if (!HiiIsConfigHdrMatch (Configuration, &mVendorGuid, mVendorStorageName)) {\r
+ *Progress = Configuration;\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
+ *Progress = Configuration + StrLen (Configuration);\r
return EFI_SUCCESS;\r
}\r
\r
/**\r
- This function processes the results of changes in configuration.\r
-\r
- @param This[in] Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
-\r
- @param Action[in] Specifies the type of action taken by the browser.\r
-\r
- @param QuestionId[in] A unique value which is sent to the original exporting driver\r
- so that it can identify the type of data to expect.\r
-\r
- @param Type[in] The type of value for the question.\r
-\r
- @param Value[in] A pointer to the data being sent to the original exporting driver.\r
-\r
- @param ActionRequest[out] On return, points to the action requested by the callback function.\r
-\r
- @retval EFI_SUCCESS The callback successfully handled the action.\r
-\r
- @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
-\r
- @retval EFI_DEVICE_ERROR The variable could not be saved.\r
-\r
- @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.\r
-\r
+ This function is called to provide results data to the driver.\r
+ This data consists of a unique key that is used to identify\r
+ which data is either being passed back or being asked for.\r
+\r
+ @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
+ @param[in] Action Specifies the type of action taken by the browser.\r
+ @param[in] QuestionId A unique value which is sent to the original\r
+ exporting driver so that it can identify the type\r
+ of data to expect. The format of the data tends to \r
+ vary based on the opcode that enerated the callback.\r
+ @param[in] Type The type of value for the question.\r
+ @param[in] Value A pointer to the data being sent to the original\r
+ exporting driver.\r
+ @param[out] ActionRequest On return, points to the action requested by the\r
+ callback function.\r
+\r
+ @retval EFI_SUCCESS The callback successfully handled the action.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r
+ variable and its data.\r
+ @retval EFI_DEVICE_ERROR The variable could not be saved.\r
+ @retval EFI_UNSUPPORTED The specified Action is not supported by the\r
+ callback.Currently not implemented.\r
+ @retval EFI_INVALID_PARAMETERS Passing in wrong parameter. \r
+ @retval Others Other errors as indicated. \r
**/\r
EFI_STATUS\r
EFIAPI\r
IScsiFormCallback (\r
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
IN EFI_BROWSER_ACTION Action,\r
- IN EFI_QUESTION_ID KeyValue,\r
+ IN EFI_QUESTION_ID QuestionId,\r
IN UINT8 Type,\r
IN EFI_IFR_TYPE_VALUE *Value,\r
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
EFI_IP_ADDRESS SubnetMask;\r
EFI_IP_ADDRESS Gateway;\r
EFI_STATUS Status;\r
+ EFI_INPUT_KEY Key;\r
\r
Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);\r
\r
//\r
// Retrive uncommitted data from Browser\r
//\r
- BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
- IfrNvData = AllocateZeroPool (BufferSize);\r
+ IfrNvData = AllocateZeroPool (sizeof (ISCSI_CONFIG_IFR_NVDATA));\r
ASSERT (IfrNvData != NULL);\r
- Status = GetBrowserData (NULL, NULL, &BufferSize, (UINT8 *) IfrNvData);\r
- if (EFI_ERROR (Status)) {\r
- gBS->FreePool (IfrNvData);\r
- return Status;\r
+ if (!HiiGetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData)) {\r
+ FreePool (IfrNvData);\r
+ return EFI_NOT_FOUND;\r
}\r
+ \r
+ Status = EFI_SUCCESS;\r
\r
- switch (KeyValue) {\r
+ switch (QuestionId) {\r
case KEY_INITIATOR_NAME:\r
IScsiUnicodeStrToAsciiStr (IfrNvData->InitiatorName, IScsiName);\r
BufferSize = AsciiStrLen (IScsiName) + 1;\r
\r
Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, IScsiName);\r
if (EFI_ERROR (Status)) {\r
- PopUpInvalidNotify (L"Invalid iSCSI Name!");\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid iSCSI Name!", NULL);\r
}\r
\r
break;\r
case KEY_LOCAL_IP:\r
IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String);\r
Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);\r
- if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
- PopUpInvalidNotify (L"Invalid IP address!");\r
+ if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\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
IScsiUnicodeStrToAsciiStr (IfrNvData->SubnetMask, Ip4String);\r
Status = IScsiAsciiStrToIp (Ip4String, &SubnetMask.v4);\r
if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (IScsiGetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {\r
- PopUpInvalidNotify (L"Invalid Subnet Mask!");\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
} else {\r
CopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));\r
case KEY_GATE_WAY:\r
IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String);\r
Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4);\r
- if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !Ip4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\r
- PopUpInvalidNotify (L"Invalid Gateway!");\r
+ if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {\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
case KEY_TARGET_IP:\r
IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String);\r
Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);\r
- if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
- PopUpInvalidNotify (L"Invalid IP address!");\r
+ if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\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.TargetIp, &HostIp.v4, sizeof (HostIp.v4));\r
IScsiUnicodeStrToAsciiStr (IfrNvData->TargetName, IScsiName);\r
Status = IScsiNormalizeName (IScsiName, AsciiStrLen (IScsiName));\r
if (EFI_ERROR (Status)) {\r
- PopUpInvalidNotify (L"Invalid iSCSI Name!");\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid iSCSI Name!", NULL);\r
} else {\r
AsciiStrCpy (Private->Current->SessionConfigData.TargetName, IScsiName);\r
}\r
IScsiUnicodeStrToAsciiStr (IfrNvData->BootLun, LunString);\r
Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun);\r
if (EFI_ERROR (Status)) {\r
- PopUpInvalidNotify (L"Invalid LUN string!");\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid LUN string!", NULL);\r
} else {\r
CopyMem (Private->Current->SessionConfigData.BootLun, &Lun, sizeof (Lun));\r
}\r
\r
if ((Gateway.Addr[0] != 0)) {\r
if (SubnetMask.Addr[0] == 0) {\r
- PopUpInvalidNotify (L"Gateway address is set but subnet mask is zero.");\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
- PopUpInvalidNotify (L"Local IP and Gateway are not in the same subnet.");\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
if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) {\r
CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4));\r
- if (!Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
- PopUpInvalidNotify (L"Target IP is invalid!");\r
+ if (!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Target IP is invalid!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
break;\r
}\r
\r
if (IfrNvData->CHAPType != ISCSI_CHAP_NONE) {\r
if ((IfrNvData->CHAPName[0] == '\0') || (IfrNvData->CHAPSecret[0] == '\0')) {\r
- PopUpInvalidNotify (L"CHAP Name or CHAP Secret is invalid!");\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"CHAP Name or CHAP Secret is invalid!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
break;\r
}\r
if ((IfrNvData->CHAPType == ISCSI_CHAP_MUTUAL) &&\r
((IfrNvData->ReverseCHAPName[0] == '\0') || (IfrNvData->ReverseCHAPSecret[0] == '\0'))\r
) {\r
- PopUpInvalidNotify (L"Reverse CHAP Name or Reverse CHAP Secret is invalid!");\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Reverse CHAP Name or Reverse CHAP Secret is invalid!", NULL);\r
Status = EFI_INVALID_PARAMETER;\r
break;\r
}\r
break;\r
\r
default:\r
- if ((KeyValue >= KEY_DEVICE_ENTRY_BASE) && (KeyValue < (mNumberOfIScsiDevices + KEY_DEVICE_ENTRY_BASE))) {\r
+ if ((QuestionId >= KEY_DEVICE_ENTRY_BASE) && (QuestionId < (mNumberOfIScsiDevices + KEY_DEVICE_ENTRY_BASE))) {\r
//\r
// In case goto the device configuration form, update the device form title.\r
//\r
- ConfigFormEntry = IScsiGetConfigFormEntryByIndex ((UINT32) (KeyValue - KEY_DEVICE_ENTRY_BASE));\r
+ ConfigFormEntry = IScsiGetConfigFormEntryByIndex ((UINT32) (QuestionId - KEY_DEVICE_ENTRY_BASE));\r
ASSERT (ConfigFormEntry != NULL);\r
\r
UnicodeSPrint (PortString, (UINTN) 128, L"Port %s", ConfigFormEntry->MacString);\r
DeviceFormTitleToken = (EFI_STRING_ID) STR_ISCSI_DEVICE_FORM_TITLE;\r
- HiiLibSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString);\r
+ HiiSetString (Private->RegisteredHandle, DeviceFormTitleToken, PortString, NULL);\r
\r
IScsiConvertDeviceConfigDataToIfrNvData (ConfigFormEntry, IfrNvData);\r
\r
//\r
// Pass changed uncommitted data back to Form Browser\r
//\r
- BufferSize = sizeof (ISCSI_CONFIG_IFR_NVDATA);\r
- Status = SetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData, NULL);\r
+ HiiSetBrowserData (&mVendorGuid, mVendorStorageName, sizeof (ISCSI_CONFIG_IFR_NVDATA), (UINT8 *) IfrNvData, NULL);\r
}\r
\r
- gBS->FreePool (IfrNvData);\r
+ FreePool (IfrNvData);\r
return Status;\r
}\r
\r
Updates the iSCSI configuration form to add/delete an entry for the iSCSI\r
device specified by the Controller.\r
\r
- @param DriverBindingHandle[in] The driverbinding handle.\r
-\r
- @param Controller[in] The controller handle of the iSCSI device.\r
-\r
- @param AddForm[in] Whether to add or delete a form entry.\r
+ @param[in] DriverBindingHandle The driverbinding handle.\r
+ @param[in] Controller The controller handle of the iSCSI device.\r
+ @param[in] AddForm Whether to add or delete a form entry.\r
\r
@retval EFI_SUCCESS The iSCSI configuration form is updated.\r
-\r
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-\r
+ @retval Others Other errors as indicated.\r
**/\r
EFI_STATUS\r
IScsiConfigUpdateForm (\r
ISCSI_CONFIG_FORM_ENTRY *ConfigFormEntry;\r
BOOLEAN EntryExisted;\r
EFI_STATUS Status;\r
- EFI_HII_UPDATE_DATA UpdateData;\r
- EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+ EFI_MAC_ADDRESS MacAddress;\r
+ UINTN HwAddressSize;\r
+ UINT16 VlanId;\r
CHAR16 PortString[128];\r
UINT16 FormIndex;\r
UINTN BufferSize;\r
-\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
ConfigFormEntry->Controller = Controller;\r
\r
//\r
- // Get the simple network protocol and convert the MAC address into\r
- // the formatted string.\r
+ // Get the MAC address and convert it into the formatted string.\r
//\r
- Status = gBS->HandleProtocol (\r
- Controller,\r
- &gEfiSimpleNetworkProtocolGuid,\r
- (VOID **)&Snp\r
- );\r
+ Status = NetLibGetMacAddress (Controller, &MacAddress, &HwAddressSize);\r
ASSERT (Status == EFI_SUCCESS);\r
+ VlanId = NetLibGetVlanId (Controller);\r
\r
- IScsiMacAddrToStr (&Snp->Mode->PermanentAddress, Snp->Mode->HwAddressSize, ConfigFormEntry->MacString);\r
+ IScsiMacAddrToStr (&MacAddress, (UINT32) HwAddressSize, VlanId, ConfigFormEntry->MacString);\r
\r
//\r
// Get the normal session configuration data.\r
// Compose the Port string and create a new EFI_STRING_ID.\r
//\r
UnicodeSPrint (PortString, 128, L"Port %s", ConfigFormEntry->MacString);\r
- HiiLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleToken, PortString);\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 iSCSI parameters on port %s", ConfigFormEntry->MacString);\r
- HiiLibNewString (mCallbackInfo->RegisteredHandle, &ConfigFormEntry->PortTitleHelpToken, PortString);\r
+ ConfigFormEntry->PortTitleHelpToken = HiiSetString (mCallbackInfo->RegisteredHandle, 0, PortString, NULL);\r
\r
InsertTailList (&mIScsiConfigFormList, &ConfigFormEntry->Link);\r
mNumberOfIScsiDevices++;\r
\r
mNumberOfIScsiDevices--;\r
RemoveEntryList (&ConfigFormEntry->Link);\r
- gBS->FreePool (ConfigFormEntry);\r
+ FreePool (ConfigFormEntry);\r
}\r
//\r
// Allocate space for creation of Buffer\r
//\r
- UpdateData.BufferSize = 0x1000;\r
- UpdateData.Data = AllocateZeroPool (0x1000);\r
- UpdateData.Offset = 0;\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
NET_LIST_FOR_EACH (Entry, &mIScsiConfigFormList) {\r
ConfigFormEntry = NET_LIST_USER_STRUCT (Entry, ISCSI_CONFIG_FORM_ENTRY, Link);\r
\r
- CreateGotoOpCode (\r
- FORMID_DEVICE_FORM,\r
- ConfigFormEntry->PortTitleToken,\r
- ConfigFormEntry->PortTitleHelpToken,\r
- EFI_IFR_FLAG_CALLBACK,\r
- (UINT16)(KEY_DEVICE_ENTRY_BASE + FormIndex),\r
- &UpdateData\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
- IfrLibUpdateForm (\r
+ HiiUpdateForm (\r
mCallbackInfo->RegisteredHandle,\r
&mVendorGuid,\r
FORMID_MAIN_FORM,\r
- DEVICE_ENTRY_LABEL,\r
- FALSE,\r
- &UpdateData\r
+ StartOpCodeHandle, // Label DEVICE_ENTRY_LABEL\r
+ EndOpCodeHandle // LABEL_END\r
);\r
\r
- gBS->FreePool (UpdateData.Data);\r
+ HiiFreeOpCodeHandle (StartOpCodeHandle);\r
+ HiiFreeOpCodeHandle (EndOpCodeHandle);\r
\r
return EFI_SUCCESS;\r
}\r
/**\r
Initialize the iSCSI configuration form.\r
\r
- @param DriverBindingHandle[in] The iSCSI driverbinding handle.\r
-\r
- @retval EFI_SUCCESS The iSCSI configuration form is initialized.\r
-\r
- @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+ @param[in] DriverBindingHandle The iSCSI driverbinding handle.\r
\r
+ @retval EFI_SUCCESS The iSCSI configuration form is initialized.\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
+ @retval Others Other errors as indicated.\r
**/\r
EFI_STATUS\r
IScsiConfigFormInit (\r
- IN EFI_HANDLE DriverBindingHandle\r
+ VOID\r
)\r
{\r
EFI_STATUS Status;\r
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r
- EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
ISCSI_FORM_CALLBACK_INFO *CallbackInfo;\r
\r
Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);\r
return Status;\r
}\r
\r
- CallbackInfo = (ISCSI_FORM_CALLBACK_INFO *) AllocatePool (sizeof (ISCSI_FORM_CALLBACK_INFO));\r
+ CallbackInfo = (ISCSI_FORM_CALLBACK_INFO *) AllocateZeroPool (sizeof (ISCSI_FORM_CALLBACK_INFO));\r
if (CallbackInfo == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
}\r
\r
//\r
- // Create driver handle used by HII database\r
- //\r
- Status = HiiLibCreateHiiDriverHandle (&CallbackInfo->DriverHandle);\r
- if (EFI_ERROR (Status)) {\r
- FreePool(CallbackInfo);\r
- return Status;\r
- }\r
- \r
- //\r
- // Install Config Access protocol to driver handle\r
+ // Install Device Path Protocol and Config Access protocol to driver handle\r
//\r
- Status = gBS->InstallProtocolInterface (\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
&CallbackInfo->DriverHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ &mIScsiHiiVendorDevicePath,\r
&gEfiHiiConfigAccessProtocolGuid,\r
- EFI_NATIVE_INTERFACE,\r
- &CallbackInfo->ConfigAccess\r
+ &CallbackInfo->ConfigAccess,\r
+ NULL\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
//\r
// Publish our HII data\r
//\r
- PackageList = HiiLibPreparePackageList (2, &mVendorGuid, IScsiDxeStrings, IScsiConfigDxeBin);\r
- ASSERT (PackageList != NULL);\r
- \r
- Status = HiiDatabase->NewPackageList (\r
- HiiDatabase,\r
- PackageList,\r
- CallbackInfo->DriverHandle,\r
- &CallbackInfo->RegisteredHandle\r
- );\r
- FreePool (PackageList);\r
- if (EFI_ERROR (Status)) {\r
+ CallbackInfo->RegisteredHandle = HiiAddPackages (\r
+ &mVendorGuid,\r
+ CallbackInfo->DriverHandle,\r
+ IScsiDxeStrings,\r
+ IScsiConfigDxeBin,\r
+ NULL\r
+ );\r
+ if (CallbackInfo->RegisteredHandle == NULL) {\r
FreePool(CallbackInfo);\r
- return Status;\r
+ return EFI_OUT_OF_RESOURCES;\r
}\r
\r
mCallbackInfo = CallbackInfo;\r
device configuration entries, uninstall the form callback protocol and\r
free the resources used.\r
\r
- @param DriverBindingHandle[in] The iSCSI driverbinding handle.\r
-\r
+ @param[in] DriverBindingHandle The iSCSI driverbinding handle.\r
+ \r
@retval EFI_SUCCESS The iSCSI configuration form is unloaded.\r
-\r
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
-\r
**/\r
EFI_STATUS\r
IScsiConfigFormUnload (\r
//\r
// Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL\r
//\r
- gBS->UninstallProtocolInterface (\r
- mCallbackInfo->DriverHandle,\r
- &gEfiHiiConfigAccessProtocolGuid,\r
- &mCallbackInfo->ConfigAccess\r
- );\r
- HiiLibDestroyHiiDriverHandle (mCallbackInfo->DriverHandle);\r
-\r
- gBS->FreePool (mCallbackInfo);\r
+ gBS->UninstallMultipleProtocolInterfaces (\r
+ mCallbackInfo->DriverHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ &mIScsiHiiVendorDevicePath,\r
+ &gEfiHiiConfigAccessProtocolGuid,\r
+ &mCallbackInfo->ConfigAccess,\r
+ NULL\r
+ );\r
+ FreePool (mCallbackInfo);\r
\r
return EFI_SUCCESS;\r
}\r