112618416ec7a468bc7e47d9739cf973a0bb418fceric_tian/** @file 2d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu The header file of IScsiConfig.c. 36a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 4b0c975b61a47b1b3c7e2e91b9e6aa9321d702a79Gao, LimingCopyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR> 5e5eed7d3641d71d7ea539e5379ea9c6a5cd97004hhtianThis program and the accompanying materials 67a444476b4ffb405006ee36d0f2cec80c2d4b348eric_tianare licensed and made available under the terms and conditions of the BSD License 77a444476b4ffb405006ee36d0f2cec80c2d4b348eric_tianwhich accompanies this distribution. The full text of the license may be found at 87a444476b4ffb405006ee36d0f2cec80c2d4b348eric_tianhttp://opensource.org/licenses/bsd-license.php 97a444476b4ffb405006ee36d0f2cec80c2d4b348eric_tian 107a444476b4ffb405006ee36d0f2cec80c2d4b348eric_tianTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 117a444476b4ffb405006ee36d0f2cec80c2d4b348eric_tianWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 126a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 1312618416ec7a468bc7e47d9739cf973a0bb418fceric_tian**/ 146a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 156a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#ifndef _ISCSI_CONFIG_H_ 166a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#define _ISCSI_CONFIG_H_ 176a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 187e3bcccb0eed449e95c18b01ae8cbace1a759d01lgao#include <Guid/MdeModuleHii.h> 19b99828832108937c999f72f6a0b78cd791df5cc9lgao#include <Protocol/HiiConfigRouting.h> 2093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang#include <Library/HiiLib.h> 21f6f910dd125144707e3516bbb517b8ec7a388c06rsun#include <Library/DevicePathLib.h> 226a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#include <Library/DebugLib.h> 236a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#include <Library/BaseLib.h> 246a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#include <Library/NetLib.h> 256a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 266a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tianextern UINT8 IScsiConfigDxeBin[]; 276924dbdf399fdb807e019932fb83b91fd4170dc3Gao, Limingextern UINT8 IScsi4DxeStrings[]; 286a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 296a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#define ISCSI_INITATOR_NAME_VAR_NAME L"I_NAME" 306a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 316a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#define ISCSI_CONFIG_VAR_ATTR (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE) 326a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 33f3f2e05db8c89628498ec4efdb16184747824c63qhuang#define ISCSI_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'f', 'c', 'i') 346a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 35963dbb30018c6420a9b27778e05e5eed74b23173ywu 36963dbb30018c6420a9b27778e05e5eed74b23173ywu 37963dbb30018c6420a9b27778e05e5eed74b23173ywu/** 38963dbb30018c6420a9b27778e05e5eed74b23173ywu If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear, 39963dbb30018c6420a9b27778e05e5eed74b23173ywu then this macro return a pointer to a data structure ISCSI_FORM_CALLBACK_INFO. 40963dbb30018c6420a9b27778e05e5eed74b23173ywu 41963dbb30018c6420a9b27778e05e5eed74b23173ywu If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set, 42963dbb30018c6420a9b27778e05e5eed74b23173ywu The Signature field of the data structure ISCSI_FORM_CALLBACK_INFO 43963dbb30018c6420a9b27778e05e5eed74b23173ywu is compared to TestSignature. If the signatures match, then a pointer 44963dbb30018c6420a9b27778e05e5eed74b23173ywu to the pointer to a data structure ISCSI_FORM_CALLBACK_INFO is returned. 45963dbb30018c6420a9b27778e05e5eed74b23173ywu If the signatures do not match, then DebugAssert() is called with a description 46963dbb30018c6420a9b27778e05e5eed74b23173ywu of "CR has a bad signature" and Callback is returned. 47963dbb30018c6420a9b27778e05e5eed74b23173ywu 48963dbb30018c6420a9b27778e05e5eed74b23173ywu If the data type ISCSI_FORM_CALLBACK_INFO_SIGNATURE does not contain the field 49963dbb30018c6420a9b27778e05e5eed74b23173ywu specified by Callback, then the module will not compile. 50963dbb30018c6420a9b27778e05e5eed74b23173ywu 51963dbb30018c6420a9b27778e05e5eed74b23173ywu If ISCSI_FORM_CALLBACK_INFO_SIGNATURE does not contain a field called Signature, 52963dbb30018c6420a9b27778e05e5eed74b23173ywu then the module will not compile. 53963dbb30018c6420a9b27778e05e5eed74b23173ywu 5455a64ae0f40421a26dee619dbc3f1e8096081a97ywu @param Callback Pointer to the specified field within the data 55963dbb30018c6420a9b27778e05e5eed74b23173ywu structure ISCSI_FORM_CALLBACK_INFO. 5655a64ae0f40421a26dee619dbc3f1e8096081a97ywu @return A pointer to the pointer to a data structure ISCSI_FORM_CALLBACK_INFO. 5755a64ae0f40421a26dee619dbc3f1e8096081a97ywu @retval Others Some unexpected error happened. 58963dbb30018c6420a9b27778e05e5eed74b23173ywu**/ 59963dbb30018c6420a9b27778e05e5eed74b23173ywu 606a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#define ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \ 616a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian CR ( \ 626a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian Callback, \ 636a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ISCSI_FORM_CALLBACK_INFO, \ 6493e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ConfigAccess, \ 656a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ISCSI_FORM_CALLBACK_INFO_SIGNATURE \ 666a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ) 676a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 686a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#pragma pack(1) 696a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 706a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tiantypedef struct _ISCSI_MAC_INFO { 716a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian EFI_MAC_ADDRESS Mac; 726a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian UINT8 Len; 73779ae3579848a36319d67a6ba012b4b9aa88aa6bxdu UINT16 VlanId; 746a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian} ISCSI_MAC_INFO; 756a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 766a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tiantypedef struct _ISCSI_DEVICE_LIST { 776a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian UINT8 NumDevice; 786a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ISCSI_MAC_INFO MacInfo[1]; 796a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian} ISCSI_DEVICE_LIST; 806a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 816a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#pragma pack() 826a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 836a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tiantypedef struct _ISCSI_CONFIG_FORM_ENTRY { 84e48e37fce2611df7a52aff271835ff72ee396d9bvanjeff LIST_ENTRY Link; 856a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian EFI_HANDLE Controller; 866a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian CHAR16 MacString[95]; 876c7a807a54b14827a6510baa5edfdbe8b5f1f085qwang EFI_STRING_ID PortTitleToken; 886c7a807a54b14827a6510baa5edfdbe8b5f1f085qwang EFI_STRING_ID PortTitleHelpToken; 896a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 906a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ISCSI_SESSION_CONFIG_NVDATA SessionConfigData; 916a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ISCSI_CHAP_AUTH_CONFIG_NVDATA AuthConfigData; 926a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian} ISCSI_CONFIG_FORM_ENTRY; 936a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 946a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tiantypedef struct _ISCSI_FORM_CALLBACK_INFO { 9593e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINTN Signature; 9693e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HANDLE DriverHandle; 9793e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess; 9893e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_DATABASE_PROTOCOL *HiiDatabase; 9993e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting; 10093e3992d1ea50fb30c48f498d257d4e66252dd9bqwang UINT16 *KeyList; 10193e3992d1ea50fb30c48f498d257d4e66252dd9bqwang VOID *FormBuffer; 10293e3992d1ea50fb30c48f498d257d4e66252dd9bqwang EFI_HII_HANDLE RegisteredHandle; 10393e3992d1ea50fb30c48f498d257d4e66252dd9bqwang ISCSI_CONFIG_FORM_ENTRY *Current; 1046a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian} ISCSI_FORM_CALLBACK_INFO; 1056a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 106f6f910dd125144707e3516bbb517b8ec7a388c06rsun#pragma pack(1) 107f6f910dd125144707e3516bbb517b8ec7a388c06rsun 108f6f910dd125144707e3516bbb517b8ec7a388c06rsun/// 109f6f910dd125144707e3516bbb517b8ec7a388c06rsun/// HII specific Vendor Device Path definition. 110f6f910dd125144707e3516bbb517b8ec7a388c06rsun/// 111f6f910dd125144707e3516bbb517b8ec7a388c06rsuntypedef struct { 112f6f910dd125144707e3516bbb517b8ec7a388c06rsun VENDOR_DEVICE_PATH VendorDevicePath; 113f6f910dd125144707e3516bbb517b8ec7a388c06rsun EFI_DEVICE_PATH_PROTOCOL End; 114f6f910dd125144707e3516bbb517b8ec7a388c06rsun} HII_VENDOR_DEVICE_PATH; 115f6f910dd125144707e3516bbb517b8ec7a388c06rsun 116f6f910dd125144707e3516bbb517b8ec7a388c06rsun#pragma pack() 117f6f910dd125144707e3516bbb517b8ec7a388c06rsun 11812618416ec7a468bc7e47d9739cf973a0bb418fceric_tian/** 11912618416ec7a468bc7e47d9739cf973a0bb418fceric_tian Updates the iSCSI configuration form to add/delete an entry for the iSCSI 12012618416ec7a468bc7e47d9739cf973a0bb418fceric_tian device specified by the Controller. 12112618416ec7a468bc7e47d9739cf973a0bb418fceric_tian 122d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu @param[in] DriverBindingHandle The driverbinding handle. 123d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu @param[in] Controller The controller handle of the iSCSI device. 124d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu @param[in] AddForm Whether to add or delete a form entry. 12512618416ec7a468bc7e47d9739cf973a0bb418fceric_tian 12612618416ec7a468bc7e47d9739cf973a0bb418fceric_tian @retval EFI_SUCCESS The iSCSI configuration form is updated. 12712618416ec7a468bc7e47d9739cf973a0bb418fceric_tian @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 128963dbb30018c6420a9b27778e05e5eed74b23173ywu @retval Others Other errors as indicated. 12912618416ec7a468bc7e47d9739cf973a0bb418fceric_tian**/ 1306a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tianEFI_STATUS 1316a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tianIScsiConfigUpdateForm ( 1326a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian IN EFI_HANDLE DriverBindingHandle, 1336a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian IN EFI_HANDLE Controller, 1346a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian IN BOOLEAN AddForm 1356a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ); 1366a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 13712618416ec7a468bc7e47d9739cf973a0bb418fceric_tian/** 13812618416ec7a468bc7e47d9739cf973a0bb418fceric_tian Initialize the iSCSI configuration form. 13912618416ec7a468bc7e47d9739cf973a0bb418fceric_tian 140d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu @param[in] DriverBindingHandle The iSCSI driverbinding handle. 14112618416ec7a468bc7e47d9739cf973a0bb418fceric_tian 142d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu @retval EFI_SUCCESS The iSCSI configuration form is initialized. 143d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 144963dbb30018c6420a9b27778e05e5eed74b23173ywu @retval Others Other errors as indicated. 14512618416ec7a468bc7e47d9739cf973a0bb418fceric_tian**/ 1466a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tianEFI_STATUS 1476a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tianIScsiConfigFormInit ( 148963dbb30018c6420a9b27778e05e5eed74b23173ywu VOID 1496a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ); 1506a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 15112618416ec7a468bc7e47d9739cf973a0bb418fceric_tian/** 15212618416ec7a468bc7e47d9739cf973a0bb418fceric_tian Unload the iSCSI configuration form, this includes: delete all the iSCSI 15312618416ec7a468bc7e47d9739cf973a0bb418fceric_tian device configuration entries, uninstall the form callback protocol and 15412618416ec7a468bc7e47d9739cf973a0bb418fceric_tian free the resources used. 15512618416ec7a468bc7e47d9739cf973a0bb418fceric_tian 156d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu @param[in] DriverBindingHandle The iSCSI driverbinding handle. 157d272bf7d03ecc02a274cc5c8ae6549c0840dce2bywu 15812618416ec7a468bc7e47d9739cf973a0bb418fceric_tian @retval EFI_SUCCESS The iSCSI configuration form is unloaded. 15912618416ec7a468bc7e47d9739cf973a0bb418fceric_tian @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. 16012618416ec7a468bc7e47d9739cf973a0bb418fceric_tian**/ 1616a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tianEFI_STATUS 1626a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tianIScsiConfigFormUnload ( 1636a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian IN EFI_HANDLE DriverBindingHandle 1646a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian ); 1656a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian 1666a690e23d7fb7fa710f6816ee23c17dadfe617b6eric_tian#endif 167