diff options
author | Zhang, Chao B <chao.b.zhang@intel.com> | 2016-02-22 13:51:53 +0800 |
---|---|---|
committer | Zhang, Chao B <chao.b.zhang@intel.com> | 2016-02-22 14:19:04 +0800 |
commit | 1826b5e63d0b77437bb846f6f34bf7bf5cf13f47 (patch) | |
tree | cfe9820fa8f7b4c078dd836ff910fed99fe67de5 | |
parent | 0a38a95a35e30490be5ceab2517da37f8fcbb3fa (diff) | |
download | edk2-1826b5e63d0b77437bb846f6f34bf7bf5cf13f47.tar.gz edk2-1826b5e63d0b77437bb846f6f34bf7bf5cf13f47.tar.bz2 edk2-1826b5e63d0b77437bb846f6f34bf7bf5cf13f47.zip |
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>
-rw-r--r-- | SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c | 10 | ||||
-rw-r--r-- | SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c | 55 | ||||
-rw-r--r-- | SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.h | 1 |
3 files changed, 40 insertions, 26 deletions
diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c index 29ec7b0621..a9d3105456 100644 --- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c +++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDriver.c @@ -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
//
diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c index c2e3b34a25..7fa5611cfd 100644 --- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c +++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c @@ -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);
}
diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.h b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.h index acc6062a9b..a03abaa1dd 100644 --- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.h +++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.h @@ -61,6 +61,7 @@ typedef struct { EFI_HII_HANDLE HiiHandle;
EFI_HANDLE DriverHandle;
+ TCG_CONFIGURATION *Configuration;
EFI_TCG_PROTOCOL *TcgProtocol;
} TCG_CONFIG_PRIVATE_DATA;
|