1/** @file
2  The header file of functions for configuring or getting the parameters
3  relating to iSCSI.
4
5Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
6This program and the accompanying materials
7are licensed and made available under the terms and conditions of the BSD License
8which accompanies this distribution.  The full text of the license may be found at
9http://opensource.org/licenses/bsd-license.php
10
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14**/
15
16#ifndef _ISCSI_CONFIG_H_
17#define _ISCSI_CONFIG_H_
18
19#include "IScsiConfigNVDataStruc.h"
20
21typedef struct _ISCSI_FORM_CALLBACK_INFO ISCSI_FORM_CALLBACK_INFO;
22
23extern UINT8                       IScsiConfigVfrBin[];
24extern UINT8                       IScsiDxeStrings[];
25extern ISCSI_FORM_CALLBACK_INFO    *mCallbackInfo;
26
27
28#define VAR_OFFSET(Field)    \
29  ((UINT16) ((UINTN) &(((ISCSI_CONFIG_IFR_NVDATA *) 0)->Field)))
30
31#define QUESTION_ID(Field)   \
32  ((UINT16) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET))
33
34
35#define DYNAMIC_ONE_OF_VAR_OFFSET           VAR_OFFSET  (Enabled)
36#define DYNAMIC_ORDERED_LIST_QUESTION_ID    QUESTION_ID (DynamicOrderedList)
37#define DYNAMIC_ORDERED_LIST_VAR_OFFSET     VAR_OFFSET  (DynamicOrderedList)
38#define ATTEMPT_DEL_QUESTION_ID             QUESTION_ID (DeleteAttemptList)
39#define ATTEMPT_DEL_VAR_OFFSET              VAR_OFFSET  (DeleteAttemptList)
40
41//
42// sizeof (EFI_MAC_ADDRESS) * 3
43//
44#define ISCSI_MAX_MAC_STRING_LEN            96
45
46#define ISCSI_INITATOR_NAME_VAR_NAME        L"I_NAME"
47
48#define ISCSI_CONFIG_VAR_ATTR               (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE)
49
50#define ISCSI_FORM_CALLBACK_INFO_SIGNATURE  SIGNATURE_32 ('I', 'f', 'c', 'i')
51
52#define ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \
53  CR ( \
54  Callback, \
55  ISCSI_FORM_CALLBACK_INFO, \
56  ConfigAccess, \
57  ISCSI_FORM_CALLBACK_INFO_SIGNATURE \
58  )
59
60#pragma pack(1)
61struct _ISCSI_ATTEMPT_CONFIG_NVDATA {
62  LIST_ENTRY                       Link;
63  UINT8                            NicIndex;
64  UINT8                            AttemptConfigIndex;
65  BOOLEAN                          DhcpSuccess;
66  BOOLEAN                          ValidiBFTPath;
67  BOOLEAN                          ValidPath;
68  UINT8                            AutoConfigureMode;
69  EFI_STRING_ID                    AttemptTitleToken;
70  EFI_STRING_ID                    AttemptTitleHelpToken;
71  CHAR8                            AttemptName[ATTEMPT_NAME_MAX_SIZE];
72  CHAR8                            MacString[ISCSI_MAX_MAC_STRING_LEN];
73  EFI_IP_ADDRESS                   PrimaryDns;
74  EFI_IP_ADDRESS                   SecondaryDns;
75  EFI_IP_ADDRESS                   DhcpServer;
76  ISCSI_SESSION_CONFIG_NVDATA      SessionConfigData;
77  UINT8                            AuthenticationType;
78  union {
79    ISCSI_CHAP_AUTH_CONFIG_NVDATA  CHAP;
80  } AuthConfigData;
81  BOOLEAN                          AutoConfigureSuccess;
82};
83
84///
85/// HII specific Vendor Device Path definition.
86///
87typedef struct {
88  VENDOR_DEVICE_PATH               VendorDevicePath;
89  EFI_DEVICE_PATH_PROTOCOL         End;
90} HII_VENDOR_DEVICE_PATH;
91
92#pragma pack()
93
94struct _ISCSI_FORM_CALLBACK_INFO {
95  UINT32                           Signature;
96  EFI_HANDLE                       DriverHandle;
97  EFI_HII_CONFIG_ACCESS_PROTOCOL   ConfigAccess;
98  UINT16                           *KeyList;
99  VOID                             *FormBuffer;
100  EFI_HII_HANDLE                   RegisteredHandle;
101  ISCSI_ATTEMPT_CONFIG_NVDATA      *Current;
102};
103
104/**
105  Initialize the iSCSI configuration form.
106
107  @param[in]  DriverBindingHandle The iSCSI driverbinding handle.
108
109  @retval EFI_SUCCESS             The iSCSI configuration form is initialized.
110  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
111
112**/
113EFI_STATUS
114IScsiConfigFormInit (
115  IN EFI_HANDLE  DriverBindingHandle
116  );
117
118/**
119  Unload the iSCSI configuration form, this includes: delete all the iSCSI
120  configuration entries, uninstall the form callback protocol, and
121  free the resources used.
122
123  @param[in]  DriverBindingHandle The iSCSI driverbinding handle.
124
125  @retval EFI_SUCCESS             The iSCSI configuration form is unloaded.
126  @retval Others                  Failed to unload the form.
127
128**/
129EFI_STATUS
130IScsiConfigFormUnload (
131  IN EFI_HANDLE  DriverBindingHandle
132  );
133
134/**
135  Update the MAIN form to display the configured attempts.
136
137**/
138VOID
139IScsiConfigUpdateAttempt (
140  VOID
141  );
142
143/**
144  Get the attempt config data from global structure by the ConfigIndex.
145
146  @param[in]  AttemptConfigIndex     The unique index indicates the attempt.
147
148  @return       Pointer to the attempt config data.
149  @retval NULL  The attempt configuration data can not be found.
150
151**/
152ISCSI_ATTEMPT_CONFIG_NVDATA *
153IScsiConfigGetAttemptByConfigIndex (
154  IN UINT8                     AttemptConfigIndex
155  );
156
157#endif
158