2 HII Config Access protocol implementation of TREE configuration module.
3 NOTE: This module is only for reference only, each platform should have its own setup page.
5 Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
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
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.
16 #include "TrEEConfigImpl.h"
17 #include <Library/PcdLib.h>
18 #include <Library/Tpm2CommandLib.h>
19 #include <Guid/TpmInstance.h>
21 TPM_INSTANCE_ID mTpmInstanceId
[TPM_DEVICE_MAX
+ 1] = TPM_INSTANCE_ID_LIST
;
23 TREE_CONFIG_PRIVATE_DATA mTrEEConfigPrivateDateTemplate
= {
24 TREE_CONFIG_PRIVATE_DATA_SIGNATURE
,
32 HII_VENDOR_DEVICE_PATH mTrEEHiiVendorDevicePath
= {
38 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
39 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
42 TREE_CONFIG_FORM_SET_GUID
46 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
48 (UINT8
) (END_DEVICE_PATH_LENGTH
),
49 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
55 This function allows a caller to extract the current configuration for one
56 or more named elements from the target driver.
58 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
59 @param[in] Request A null-terminated Unicode string in
60 <ConfigRequest> format.
61 @param[out] Progress On return, points to a character in the Request
62 string. Points to the string's null terminator if
63 request was successful. Points to the most recent
64 '&' before the first failing name/value pair (or
65 the beginning of the string if the failure is in
66 the first name/value pair) if the request was not
68 @param[out] Results A null-terminated Unicode string in
69 <ConfigAltResp> format which has all values filled
70 in for the names in the Request string. String to
71 be allocated by the called function.
73 @retval EFI_SUCCESS The Results is filled with the requested values.
74 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
75 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
76 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
83 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
84 IN CONST EFI_STRING Request
,
85 OUT EFI_STRING
*Progress
,
86 OUT EFI_STRING
*Results
89 if (Progress
== NULL
|| Results
== NULL
) {
90 return EFI_INVALID_PARAMETER
;
98 Save TPM request to variable space.
100 @param[in] PpRequest Physical Presence request command.
102 @retval EFI_SUCCESS The operation is finished successfully.
103 @retval Others Other errors as indicated.
113 EFI_TREE_PHYSICAL_PRESENCE PpData
;
116 // Save TPM command to variable.
118 DataSize
= sizeof (EFI_TREE_PHYSICAL_PRESENCE
);
119 Status
= gRT
->GetVariable (
120 TREE_PHYSICAL_PRESENCE_VARIABLE
,
121 &gEfiTrEEPhysicalPresenceGuid
,
126 if (EFI_ERROR (Status
)) {
130 PpData
.PPRequest
= PpRequest
;
131 Status
= gRT
->SetVariable (
132 TREE_PHYSICAL_PRESENCE_VARIABLE
,
133 &gEfiTrEEPhysicalPresenceGuid
,
134 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
| EFI_VARIABLE_RUNTIME_ACCESS
,
138 if (EFI_ERROR(Status
)) {
146 This function processes the results of changes in configuration.
148 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
149 @param[in] Configuration A null-terminated Unicode string in <ConfigResp>
151 @param[out] Progress A pointer to a string filled in with the offset of
152 the most recent '&' before the first failing
153 name/value pair (or the beginning of the string if
154 the failure is in the first name/value pair) or
155 the terminating NULL if all was successful.
157 @retval EFI_SUCCESS The Results is processed successfully.
158 @retval EFI_INVALID_PARAMETER Configuration is NULL.
159 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this
166 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
167 IN CONST EFI_STRING Configuration
,
168 OUT EFI_STRING
*Progress
171 if (Configuration
== NULL
|| Progress
== NULL
) {
172 return EFI_INVALID_PARAMETER
;
175 return EFI_NOT_FOUND
;
179 This function processes the results of changes in configuration.
181 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
182 @param[in] Action Specifies the type of action taken by the browser.
183 @param[in] QuestionId A unique value which is sent to the original
184 exporting driver so that it can identify the type
186 @param[in] Type The type of value for the question.
187 @param[in] Value A pointer to the data being sent to the original
189 @param[out] ActionRequest On return, points to the action requested by the
192 @retval EFI_SUCCESS The callback successfully handled the action.
193 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
194 variable and its data.
195 @retval EFI_DEVICE_ERROR The variable could not be saved.
196 @retval EFI_UNSUPPORTED The specified Action is not supported by the
203 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
204 IN EFI_BROWSER_ACTION Action
,
205 IN EFI_QUESTION_ID QuestionId
,
207 IN EFI_IFR_TYPE_VALUE
*Value
,
208 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
211 if ((This
== NULL
) || (Value
== NULL
) || (ActionRequest
== NULL
)) {
212 return EFI_INVALID_PARAMETER
;
215 if (Action
== EFI_BROWSER_ACTION_CHANGED
) {
216 if (QuestionId
== KEY_TPM_DEVICE
) {
219 if (QuestionId
== KEY_TPM2_OPERATION
) {
220 return SaveTrEEPpRequest (Value
->u8
);
224 return EFI_UNSUPPORTED
;
228 This function publish the TREE configuration Form for TPM device.
230 @param[in, out] PrivateData Points to TREE configuration private data.
232 @retval EFI_SUCCESS HII Form is installed for this network device.
233 @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.
234 @retval Others Other errors as indicated.
238 InstallTrEEConfigForm (
239 IN OUT TREE_CONFIG_PRIVATE_DATA
*PrivateData
243 EFI_HII_HANDLE HiiHandle
;
244 EFI_HANDLE DriverHandle
;
245 EFI_HII_CONFIG_ACCESS_PROTOCOL
*ConfigAccess
;
248 ConfigAccess
= &PrivateData
->ConfigAccess
;
249 Status
= gBS
->InstallMultipleProtocolInterfaces (
251 &gEfiDevicePathProtocolGuid
,
252 &mTrEEHiiVendorDevicePath
,
253 &gEfiHiiConfigAccessProtocolGuid
,
257 if (EFI_ERROR (Status
)) {
261 PrivateData
->DriverHandle
= DriverHandle
;
264 // Publish the HII package list
266 HiiHandle
= HiiAddPackages (
267 &gTrEEConfigFormSetGuid
,
269 TrEEConfigDxeStrings
,
273 if (HiiHandle
== NULL
) {
274 gBS
->UninstallMultipleProtocolInterfaces (
276 &gEfiDevicePathProtocolGuid
,
277 &mTrEEHiiVendorDevicePath
,
278 &gEfiHiiConfigAccessProtocolGuid
,
283 return EFI_OUT_OF_RESOURCES
;
286 PrivateData
->HiiHandle
= HiiHandle
;
289 // Update static data
291 switch (PrivateData
->TpmDeviceDetected
) {
292 case TPM_DEVICE_NULL
:
293 HiiSetString (PrivateData
->HiiHandle
, STRING_TOKEN (STR_TREE_DEVICE_STATE_CONTENT
), L
"Not Found", NULL
);
296 HiiSetString (PrivateData
->HiiHandle
, STRING_TOKEN (STR_TREE_DEVICE_STATE_CONTENT
), L
"TPM 1.2", NULL
);
298 case TPM_DEVICE_2_0_DTPM
:
299 HiiSetString (PrivateData
->HiiHandle
, STRING_TOKEN (STR_TREE_DEVICE_STATE_CONTENT
), L
"TPM 2.0 (DTPM)", NULL
);
302 HiiSetString (PrivateData
->HiiHandle
, STRING_TOKEN (STR_TREE_DEVICE_STATE_CONTENT
), L
"Unknown", NULL
);
310 This function removes TREE configuration Form.
312 @param[in, out] PrivateData Points to TREE configuration private data.
316 UninstallTrEEConfigForm (
317 IN OUT TREE_CONFIG_PRIVATE_DATA
*PrivateData
321 // Uninstall HII package list
323 if (PrivateData
->HiiHandle
!= NULL
) {
324 HiiRemovePackages (PrivateData
->HiiHandle
);
325 PrivateData
->HiiHandle
= NULL
;
329 // Uninstall HII Config Access Protocol
331 if (PrivateData
->DriverHandle
!= NULL
) {
332 gBS
->UninstallMultipleProtocolInterfaces (
333 PrivateData
->DriverHandle
,
334 &gEfiDevicePathProtocolGuid
,
335 &mTrEEHiiVendorDevicePath
,
336 &gEfiHiiConfigAccessProtocolGuid
,
337 &PrivateData
->ConfigAccess
,
340 PrivateData
->DriverHandle
= NULL
;
343 FreePool (PrivateData
);