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