TPM state string update requires HiiHandle which may not be initialized when calling ExtractConfig.
Move this logic to CallBack function.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
if (PrivateData == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
if (PrivateData == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
+ PrivateData->Configuration = AllocatePool (sizeof (TCG_CONFIGURATION));\r
+ if (PrivateData->Configuration == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ErrorExit;\r
+ }\r
+\r
PrivateData->TcgProtocol = TcgProtocol;\r
PrivateData->TcgProtocol = TcgProtocol;\r
//\r
// Install TCG configuration form\r
//\r
//\r
// Install TCG configuration form\r
//\r
/** @file\r
HII Config Access protocol implementation of TCG configuration module.\r
\r
/** @file\r
HII Config Access protocol implementation of TCG configuration module.\r
\r
-Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
This program and the accompanying materials \r
are licensed and made available under the terms and conditions of the BSD License \r
which accompanies this distribution. The full text of the license may be found at \r
)\r
{\r
EFI_STATUS Status;\r
)\r
{\r
EFI_STATUS Status;\r
- UINTN BufferSize;\r
- TCG_CONFIGURATION Configuration;\r
TCG_CONFIG_PRIVATE_DATA *PrivateData;\r
EFI_STRING ConfigRequestHdr;\r
EFI_STRING ConfigRequest;\r
TCG_CONFIG_PRIVATE_DATA *PrivateData;\r
EFI_STRING ConfigRequestHdr;\r
EFI_STRING ConfigRequest;\r
UINTN Size;\r
BOOLEAN TpmEnable;\r
BOOLEAN TpmActivate;\r
UINTN Size;\r
BOOLEAN TpmEnable;\r
BOOLEAN TpmActivate;\r
\r
if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
\r
if (Progress == NULL || Results == NULL) {\r
return EFI_INVALID_PARAMETER;\r
//\r
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
// \r
//\r
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
// \r
- ZeroMem (&Configuration, sizeof (TCG_CONFIGURATION));\r
-\r
- Configuration.TpmOperation = PHYSICAL_PRESENCE_ENABLE;\r
+ PrivateData->Configuration->TpmOperation = PHYSICAL_PRESENCE_ENABLE;\r
- // Display current TPM state.\r
+ // Get current TPM state.\r
//\r
if (PrivateData->TcgProtocol != NULL) {\r
Status = GetTpmState (PrivateData->TcgProtocol, &TpmEnable, &TpmActivate);\r
//\r
if (PrivateData->TcgProtocol != NULL) {\r
Status = GetTpmState (PrivateData->TcgProtocol, &TpmEnable, &TpmActivate);\r
- UnicodeSPrint (\r
- State,\r
- sizeof (State),\r
- L"%s, and %s",\r
- TpmEnable ? L"Enabled" : L"Disabled",\r
- TpmActivate ? L"Activated" : L"Deactivated"\r
- );\r
- Configuration.TpmEnable = TpmEnable;\r
- Configuration.TpmActivate = TpmActivate;\r
-\r
- HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM_STATE_CONTENT), State, NULL);\r
+ PrivateData->Configuration->TpmEnable = TpmEnable;\r
+ PrivateData->Configuration->TpmActivate = TpmActivate;\r
- BufferSize = sizeof (Configuration);\r
ConfigRequest = Request;\r
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
//\r
ConfigRequest = Request;\r
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
//\r
ConfigRequest = AllocateZeroPool (Size);\r
ASSERT (ConfigRequest != NULL);\r
AllocatedRequest = TRUE;\r
ConfigRequest = AllocateZeroPool (Size);\r
ASSERT (ConfigRequest != NULL);\r
AllocatedRequest = TRUE;\r
- UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64) BufferSize);\r
+ UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, sizeof (TCG_CONFIGURATION));\r
FreePool (ConfigRequestHdr);\r
}\r
\r
Status = gHiiConfigRouting->BlockToConfig (\r
gHiiConfigRouting,\r
ConfigRequest,\r
FreePool (ConfigRequestHdr);\r
}\r
\r
Status = gHiiConfigRouting->BlockToConfig (\r
gHiiConfigRouting,\r
ConfigRequest,\r
- (UINT8 *) &Configuration,\r
- BufferSize,\r
+ (UINT8 *) PrivateData->Configuration,\r
+ sizeof (TCG_CONFIGURATION),\r
Results,\r
Progress\r
);\r
Results,\r
Progress\r
);\r
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
)\r
{\r
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
)\r
{\r
+ TCG_CONFIG_PRIVATE_DATA *PrivateData;\r
+ CHAR16 State[32];\r
+\r
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
+ if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {\r
+ if (QuestionId == KEY_TPM_ACTION) {\r
+\r
+ PrivateData = TCG_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r
+ UnicodeSPrint (\r
+ State,\r
+ sizeof (State),\r
+ L"%s, and %s",\r
+ PrivateData->Configuration->TpmEnable ? L"Enabled" : L"Disabled",\r
+ PrivateData->Configuration->TpmActivate ? L"Activated" : L"Deactivated"\r
+ );\r
+ HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM_STATE_CONTENT), State, NULL);\r
+ }\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
if ((Action != EFI_BROWSER_ACTION_CHANGED) || (QuestionId != KEY_TPM_ACTION)) {\r
return EFI_UNSUPPORTED;\r
}\r
if ((Action != EFI_BROWSER_ACTION_CHANGED) || (QuestionId != KEY_TPM_ACTION)) {\r
return EFI_UNSUPPORTED;\r
}\r
);\r
PrivateData->DriverHandle = NULL;\r
}\r
);\r
PrivateData->DriverHandle = NULL;\r
}\r
+\r
+ if (PrivateData->Configuration != NULL) {\r
+ FreePool(PrivateData->Configuration);\r
+ }\r
FreePool (PrivateData);\r
}\r
FreePool (PrivateData);\r
}\r
EFI_HII_HANDLE HiiHandle;\r
EFI_HANDLE DriverHandle; \r
\r
EFI_HII_HANDLE HiiHandle;\r
EFI_HANDLE DriverHandle; \r
\r
+ TCG_CONFIGURATION *Configuration;\r
EFI_TCG_PROTOCOL *TcgProtocol;\r
} TCG_CONFIG_PRIVATE_DATA;\r
\r
EFI_TCG_PROTOCOL *TcgProtocol;\r
} TCG_CONFIG_PRIVATE_DATA;\r
\r