mirror of https://github.com/acidanthera/audk.git
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:
parent
0a38a95a35
commit
1826b5e63d
|
@ -74,6 +74,12 @@ TcgConfigDriverEntryPoint (
|
||||||
return EFI_OUT_OF_RESOURCES;
|
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;
|
PrivateData->TcgProtocol = TcgProtocol;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
HII Config Access protocol implementation of TCG configuration module.
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -149,8 +149,6 @@ TcgExtractConfig (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN BufferSize;
|
|
||||||
TCG_CONFIGURATION Configuration;
|
|
||||||
TCG_CONFIG_PRIVATE_DATA *PrivateData;
|
TCG_CONFIG_PRIVATE_DATA *PrivateData;
|
||||||
EFI_STRING ConfigRequestHdr;
|
EFI_STRING ConfigRequestHdr;
|
||||||
EFI_STRING ConfigRequest;
|
EFI_STRING ConfigRequest;
|
||||||
|
@ -158,7 +156,6 @@ TcgExtractConfig (
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
BOOLEAN TpmEnable;
|
BOOLEAN TpmEnable;
|
||||||
BOOLEAN TpmActivate;
|
BOOLEAN TpmActivate;
|
||||||
CHAR16 State[32];
|
|
||||||
|
|
||||||
if (Progress == NULL || Results == NULL) {
|
if (Progress == NULL || Results == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
@ -179,12 +176,10 @@ TcgExtractConfig (
|
||||||
//
|
//
|
||||||
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
|
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
|
||||||
//
|
//
|
||||||
ZeroMem (&Configuration, sizeof (TCG_CONFIGURATION));
|
PrivateData->Configuration->TpmOperation = PHYSICAL_PRESENCE_ENABLE;
|
||||||
|
|
||||||
Configuration.TpmOperation = PHYSICAL_PRESENCE_ENABLE;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Display current TPM state.
|
// Get current TPM state.
|
||||||
//
|
//
|
||||||
if (PrivateData->TcgProtocol != NULL) {
|
if (PrivateData->TcgProtocol != NULL) {
|
||||||
Status = GetTpmState (PrivateData->TcgProtocol, &TpmEnable, &TpmActivate);
|
Status = GetTpmState (PrivateData->TcgProtocol, &TpmEnable, &TpmActivate);
|
||||||
|
@ -192,20 +187,10 @@ TcgExtractConfig (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnicodeSPrint (
|
PrivateData->Configuration->TpmEnable = TpmEnable;
|
||||||
State,
|
PrivateData->Configuration->TpmActivate = TpmActivate;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferSize = sizeof (Configuration);
|
|
||||||
ConfigRequest = Request;
|
ConfigRequest = Request;
|
||||||
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
|
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
|
||||||
//
|
//
|
||||||
|
@ -218,15 +203,15 @@ TcgExtractConfig (
|
||||||
ConfigRequest = AllocateZeroPool (Size);
|
ConfigRequest = AllocateZeroPool (Size);
|
||||||
ASSERT (ConfigRequest != NULL);
|
ASSERT (ConfigRequest != NULL);
|
||||||
AllocatedRequest = TRUE;
|
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);
|
FreePool (ConfigRequestHdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gHiiConfigRouting->BlockToConfig (
|
Status = gHiiConfigRouting->BlockToConfig (
|
||||||
gHiiConfigRouting,
|
gHiiConfigRouting,
|
||||||
ConfigRequest,
|
ConfigRequest,
|
||||||
(UINT8 *) &Configuration,
|
(UINT8 *) PrivateData->Configuration,
|
||||||
BufferSize,
|
sizeof (TCG_CONFIGURATION),
|
||||||
Results,
|
Results,
|
||||||
Progress
|
Progress
|
||||||
);
|
);
|
||||||
|
@ -386,10 +371,29 @@ TcgCallback (
|
||||||
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
TCG_CONFIG_PRIVATE_DATA *PrivateData;
|
||||||
|
CHAR16 State[32];
|
||||||
|
|
||||||
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {
|
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
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)) {
|
if ((Action != EFI_BROWSER_ACTION_CHANGED) || (QuestionId != KEY_TPM_ACTION)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
@ -498,5 +502,8 @@ UninstallTcgConfigForm (
|
||||||
PrivateData->DriverHandle = NULL;
|
PrivateData->DriverHandle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PrivateData->Configuration != NULL) {
|
||||||
|
FreePool(PrivateData->Configuration);
|
||||||
|
}
|
||||||
FreePool (PrivateData);
|
FreePool (PrivateData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ typedef struct {
|
||||||
EFI_HII_HANDLE HiiHandle;
|
EFI_HII_HANDLE HiiHandle;
|
||||||
EFI_HANDLE DriverHandle;
|
EFI_HANDLE DriverHandle;
|
||||||
|
|
||||||
|
TCG_CONFIGURATION *Configuration;
|
||||||
EFI_TCG_PROTOCOL *TcgProtocol;
|
EFI_TCG_PROTOCOL *TcgProtocol;
|
||||||
} TCG_CONFIG_PRIVATE_DATA;
|
} TCG_CONFIG_PRIVATE_DATA;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue