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