SecurityPkg: TcgConfigDxe: Move TPM state string update to CallBack function

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>
This commit is contained in:
Zhang, Chao B 2016-02-22 13:51:53 +08:00
parent 0a38a95a35
commit 1826b5e63d
3 changed files with 40 additions and 26 deletions

View File

@ -73,9 +73,15 @@ TcgConfigDriverEntryPoint (
if (PrivateData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
PrivateData->Configuration = AllocatePool (sizeof (TCG_CONFIGURATION));
if (PrivateData->Configuration == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
PrivateData->TcgProtocol = TcgProtocol;
//
// Install TCG configuration form
//

View File

@ -1,7 +1,7 @@
/** @file
HII Config Access protocol implementation of TCG configuration module.
Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -149,8 +149,6 @@ TcgExtractConfig (
)
{
EFI_STATUS Status;
UINTN BufferSize;
TCG_CONFIGURATION Configuration;
TCG_CONFIG_PRIVATE_DATA *PrivateData;
EFI_STRING ConfigRequestHdr;
EFI_STRING ConfigRequest;
@ -158,7 +156,6 @@ TcgExtractConfig (
UINTN Size;
BOOLEAN TpmEnable;
BOOLEAN TpmActivate;
CHAR16 State[32];
if (Progress == NULL || Results == NULL) {
return EFI_INVALID_PARAMETER;
@ -179,12 +176,10 @@ TcgExtractConfig (
//
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
//
ZeroMem (&Configuration, sizeof (TCG_CONFIGURATION));
Configuration.TpmOperation = PHYSICAL_PRESENCE_ENABLE;
PrivateData->Configuration->TpmOperation = PHYSICAL_PRESENCE_ENABLE;
//
// Display current TPM state.
// Get current TPM state.
//
if (PrivateData->TcgProtocol != NULL) {
Status = GetTpmState (PrivateData->TcgProtocol, &TpmEnable, &TpmActivate);
@ -192,20 +187,10 @@ TcgExtractConfig (
return Status;
}
UnicodeSPrint (
State,
sizeof (State),
L"%s, and %s",
TpmEnable ? L"Enabled" : L"Disabled",
TpmActivate ? L"Activated" : L"Deactivated"
);
Configuration.TpmEnable = TpmEnable;
Configuration.TpmActivate = TpmActivate;
HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM_STATE_CONTENT), State, NULL);
PrivateData->Configuration->TpmEnable = TpmEnable;
PrivateData->Configuration->TpmActivate = TpmActivate;
}
BufferSize = sizeof (Configuration);
ConfigRequest = Request;
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
//
@ -218,15 +203,15 @@ TcgExtractConfig (
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64) BufferSize);
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, sizeof (TCG_CONFIGURATION));
FreePool (ConfigRequestHdr);
}
Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting,
ConfigRequest,
(UINT8 *) &Configuration,
BufferSize,
(UINT8 *) PrivateData->Configuration,
sizeof (TCG_CONFIGURATION),
Results,
Progress
);
@ -386,10 +371,29 @@ TcgCallback (
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
TCG_CONFIG_PRIVATE_DATA *PrivateData;
CHAR16 State[32];
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
}
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
if (QuestionId == KEY_TPM_ACTION) {
PrivateData = TCG_CONFIG_PRIVATE_DATA_FROM_THIS (This);
UnicodeSPrint (
State,
sizeof (State),
L"%s, and %s",
PrivateData->Configuration->TpmEnable ? L"Enabled" : L"Disabled",
PrivateData->Configuration->TpmActivate ? L"Activated" : L"Deactivated"
);
HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM_STATE_CONTENT), State, NULL);
}
return EFI_SUCCESS;
}
if ((Action != EFI_BROWSER_ACTION_CHANGED) || (QuestionId != KEY_TPM_ACTION)) {
return EFI_UNSUPPORTED;
}
@ -497,6 +501,9 @@ UninstallTcgConfigForm (
);
PrivateData->DriverHandle = NULL;
}
if (PrivateData->Configuration != NULL) {
FreePool(PrivateData->Configuration);
}
FreePool (PrivateData);
}

View File

@ -61,6 +61,7 @@ typedef struct {
EFI_HII_HANDLE HiiHandle;
EFI_HANDLE DriverHandle;
TCG_CONFIGURATION *Configuration;
EFI_TCG_PROTOCOL *TcgProtocol;
} TCG_CONFIG_PRIVATE_DATA;