]>
Commit | Line | Data |
---|---|---|
7618784b HW |
1 | /** @file\r |
2 | Header file of Miscellaneous Routines for TlsAuthConfigDxe driver.\r | |
3 | \r | |
4 | Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef __TLS_AUTH_CONFIG_IMPL_H__\r | |
17 | #define __TLS_AUTH_CONFIG_IMPL_H__\r | |
18 | \r | |
19 | #include <Uefi.h>\r | |
20 | \r | |
21 | #include <Protocol/HiiConfigAccess.h>\r | |
22 | #include <Protocol/SimpleFileSystem.h>\r | |
23 | \r | |
24 | //\r | |
25 | // Libraries\r | |
26 | //\r | |
27 | #include <Library/UefiBootServicesTableLib.h>\r | |
28 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
29 | #include <Library/MemoryAllocationLib.h>\r | |
30 | #include <Library/BaseMemoryLib.h>\r | |
31 | #include <Library/BaseLib.h>\r | |
32 | #include <Library/UefiLib.h>\r | |
33 | #include <Library/DebugLib.h>\r | |
34 | #include <Library/DevicePathLib.h>\r | |
35 | #include <Library/HiiLib.h>\r | |
36 | #include <Library/UefiHiiServicesLib.h>\r | |
37 | #include <Library/FileExplorerLib.h>\r | |
38 | #include <Library/PrintLib.h>\r | |
39 | \r | |
40 | #include <Guid/MdeModuleHii.h>\r | |
41 | #include <Guid/ImageAuthentication.h>\r | |
42 | #include <Guid/TlsAuthentication.h>\r | |
43 | \r | |
44 | \r | |
45 | //\r | |
46 | // Include files with function prototypes\r | |
47 | //\r | |
48 | #include "TlsAuthConfigNvData.h"\r | |
49 | \r | |
50 | extern UINT8 TlsAuthConfigDxeStrings[];\r | |
51 | extern UINT8 TlsAuthConfigVfrBin[];\r | |
52 | \r | |
53 | #define TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('T', 'A', 'C', 'D')\r | |
54 | #define TLS_AUTH_CONFIG_PRIVATE_FROM_THIS(a) CR (a, TLS_AUTH_CONFIG_PRIVATE_DATA, ConfigAccess, TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE)\r | |
55 | \r | |
56 | #define TLS_AUTH_CONFIG_VAR_BASE_ATTR (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)\r | |
57 | \r | |
58 | typedef struct _TLS_AUTH_CONFIG_PRIVATE_DATA TLS_AUTH_CONFIG_PRIVATE_DATA;\r | |
59 | typedef struct _TLS_AUTH_CONFIG_FILE_CONTEXT TLS_AUTH_CONFIG_FILE_CONTEXT;\r | |
60 | \r | |
61 | ///\r | |
62 | /// HII specific Vendor Device Path definition.\r | |
63 | ///\r | |
64 | typedef struct {\r | |
65 | VENDOR_DEVICE_PATH VendorDevicePath;\r | |
66 | EFI_DEVICE_PATH_PROTOCOL End;\r | |
67 | } HII_VENDOR_DEVICE_PATH;\r | |
68 | \r | |
69 | struct _TLS_AUTH_CONFIG_FILE_CONTEXT {\r | |
70 | EFI_FILE_HANDLE FHandle;\r | |
71 | UINT16 *FileName;\r | |
72 | };\r | |
73 | \r | |
74 | struct _TLS_AUTH_CONFIG_PRIVATE_DATA {\r | |
75 | UINTN Signature;\r | |
76 | \r | |
77 | EFI_HANDLE DriverHandle;\r | |
78 | EFI_HII_HANDLE RegisteredHandle;\r | |
79 | EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;\r | |
80 | TLS_AUTH_CONFIG_IFR_NVDATA TlsAuthConfigNvData;\r | |
81 | \r | |
82 | TLS_AUTH_CONFIG_FILE_CONTEXT *FileContext;\r | |
83 | \r | |
84 | EFI_GUID *CertGuid;\r | |
85 | };\r | |
86 | \r | |
87 | /**\r | |
88 | Unload the configuration form, this includes: delete all the configuration\r | |
89 | entries, uninstall the form callback protocol, and free the resources used.\r | |
90 | The form will only be unload completely when both IP4 and IP6 stack are stopped.\r | |
91 | \r | |
92 | @param[in] Private Pointer to the driver private data.\r | |
93 | \r | |
94 | @retval EFI_SUCCESS The configuration form is unloaded.\r | |
95 | @retval Others Failed to unload the form.\r | |
96 | \r | |
97 | **/\r | |
98 | EFI_STATUS\r | |
99 | TlsAuthConfigFormUnload (\r | |
100 | IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private\r | |
101 | );\r | |
102 | \r | |
103 | /**\r | |
104 | Initialize the configuration form.\r | |
105 | \r | |
106 | @param[in] Private Pointer to the driver private data.\r | |
107 | \r | |
108 | @retval EFI_SUCCESS The configuration form is initialized.\r | |
109 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
110 | \r | |
111 | **/\r | |
112 | EFI_STATUS\r | |
113 | TlsAuthConfigFormInit (\r | |
114 | IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private\r | |
115 | );\r | |
116 | \r | |
117 | /**\r | |
118 | \r | |
119 | This function allows the caller to request the current\r | |
120 | configuration for one or more named elements. The resulting\r | |
121 | string is in <ConfigAltResp> format. Any and all alternative\r | |
122 | configuration strings shall also be appended to the end of the\r | |
123 | current configuration string. If they are, they must appear\r | |
124 | after the current configuration. They must contain the same\r | |
125 | routing (GUID, NAME, PATH) as the current configuration string.\r | |
126 | They must have an additional description indicating the type of\r | |
127 | alternative configuration the string represents,\r | |
128 | "ALTCFG=<StringToken>". That <StringToken> (when\r | |
129 | converted from Hex UNICODE to binary) is a reference to a\r | |
130 | string in the associated string pack.\r | |
131 | \r | |
132 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
133 | \r | |
134 | @param Request A null-terminated Unicode string in\r | |
135 | <ConfigRequest> format. Note that this\r | |
136 | includes the routing information as well as\r | |
137 | the configurable name / value pairs. It is\r | |
138 | invalid for this string to be in\r | |
139 | <MultiConfigRequest> format.\r | |
140 | If a NULL is passed in for the Request field,\r | |
141 | all of the settings being abstracted by this function\r | |
142 | will be returned in the Results field. In addition,\r | |
143 | if a ConfigHdr is passed in with no request elements,\r | |
144 | all of the settings being abstracted for that particular\r | |
145 | ConfigHdr reference will be returned in the Results Field.\r | |
146 | \r | |
147 | @param Progress On return, points to a character in the\r | |
148 | Request string. Points to the string's null\r | |
149 | terminator if request was successful. Points\r | |
150 | to the most recent "&" before the first\r | |
151 | failing name / value pair (or the beginning\r | |
152 | of the string if the failure is in the first\r | |
153 | name / value pair) if the request was not\r | |
154 | successful.\r | |
155 | \r | |
156 | @param Results A null-terminated Unicode string in\r | |
157 | <MultiConfigAltResp> format which has all values\r | |
158 | filled in for the names in the Request string.\r | |
159 | String to be allocated by the called function.\r | |
160 | \r | |
161 | @retval EFI_SUCCESS The Results string is filled with the\r | |
162 | values corresponding to all requested\r | |
163 | names.\r | |
164 | \r | |
165 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the\r | |
166 | parts of the results that must be\r | |
167 | stored awaiting possible future\r | |
168 | protocols.\r | |
169 | \r | |
170 | @retval EFI_NOT_FOUND Routing data doesn't match any\r | |
171 | known driver. Progress set to the\r | |
172 | first character in the routing header.\r | |
173 | Note: There is no requirement that the\r | |
174 | driver validate the routing data. It\r | |
175 | must skip the <ConfigHdr> in order to\r | |
176 | process the names.\r | |
177 | \r | |
178 | @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set\r | |
179 | to most recent "&" before the\r | |
180 | error or the beginning of the\r | |
181 | string.\r | |
182 | \r | |
183 | @retval EFI_INVALID_PARAMETER Unknown name. Progress points\r | |
184 | to the & before the name in\r | |
185 | question.\r | |
186 | \r | |
187 | **/\r | |
188 | EFI_STATUS\r | |
189 | EFIAPI\r | |
190 | TlsAuthConfigAccessExtractConfig (\r | |
191 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
192 | IN CONST EFI_STRING Request,\r | |
193 | OUT EFI_STRING *Progress,\r | |
194 | OUT EFI_STRING *Results\r | |
195 | );\r | |
196 | \r | |
197 | /**\r | |
198 | \r | |
199 | This function applies changes in a driver's configuration.\r | |
200 | Input is a Configuration, which has the routing data for this\r | |
201 | driver followed by name / value configuration pairs. The driver\r | |
202 | must apply those pairs to its configurable storage. If the\r | |
203 | driver's configuration is stored in a linear block of data\r | |
204 | and the driver's name / value pairs are in <BlockConfig>\r | |
205 | format, it may use the ConfigToBlock helper function (above) to\r | |
206 | simplify the job.\r | |
207 | \r | |
208 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
209 | \r | |
210 | @param Configuration A null-terminated Unicode string in\r | |
211 | <ConfigString> format.\r | |
212 | \r | |
213 | @param Progress A pointer to a string filled in with the\r | |
214 | offset of the most recent '&' before the\r | |
215 | first failing name / value pair (or the\r | |
216 | beginn ing of the string if the failure\r | |
217 | is in the first name / value pair) or\r | |
218 | the terminating NULL if all was\r | |
219 | successful.\r | |
220 | \r | |
221 | @retval EFI_SUCCESS The results have been distributed or are\r | |
222 | awaiting distribution.\r | |
223 | \r | |
224 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the\r | |
225 | parts of the results that must be\r | |
226 | stored awaiting possible future\r | |
227 | protocols.\r | |
228 | \r | |
229 | @retval EFI_INVALID_PARAMETERS Passing in a NULL for the\r | |
230 | Results parameter would result\r | |
231 | in this type of error.\r | |
232 | \r | |
233 | @retval EFI_NOT_FOUND Target for the specified routing data\r | |
234 | was not found\r | |
235 | \r | |
236 | **/\r | |
237 | EFI_STATUS\r | |
238 | EFIAPI\r | |
239 | TlsAuthConfigAccessRouteConfig (\r | |
240 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
241 | IN CONST EFI_STRING Configuration,\r | |
242 | OUT EFI_STRING *Progress\r | |
243 | );\r | |
244 | \r | |
245 | /**\r | |
246 | \r | |
247 | This function is called to provide results data to the driver.\r | |
248 | This data consists of a unique key that is used to identify\r | |
249 | which data is either being passed back or being asked for.\r | |
250 | \r | |
251 | @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
252 | @param Action Specifies the type of action taken by the browser.\r | |
253 | @param QuestionId A unique value which is sent to the original\r | |
254 | exporting driver so that it can identify the type\r | |
255 | of data to expect. The format of the data tends to\r | |
256 | vary based on the opcode that generated the callback.\r | |
257 | @param Type The type of value for the question.\r | |
258 | @param Value A pointer to the data being sent to the original\r | |
259 | exporting driver.\r | |
260 | @param ActionRequest On return, points to the action requested by the\r | |
261 | callback function.\r | |
262 | \r | |
263 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
264 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r | |
265 | variable and its data.\r | |
266 | @retval EFI_DEVICE_ERROR The variable could not be saved.\r | |
267 | @retval EFI_UNSUPPORTED The specified Action is not supported by the\r | |
268 | callback.\r | |
269 | **/\r | |
270 | EFI_STATUS\r | |
271 | EFIAPI\r | |
272 | TlsAuthConfigAccessCallback (\r | |
273 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
274 | IN EFI_BROWSER_ACTION Action,\r | |
275 | IN EFI_QUESTION_ID QuestionId,\r | |
276 | IN UINT8 Type,\r | |
277 | IN OUT EFI_IFR_TYPE_VALUE *Value,\r | |
278 | OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r | |
279 | );\r | |
280 | \r | |
281 | #endif\r | |
282 | \r |