Fix current TPM device string missing. Use efivarstore instead of varstor, remove TPM disable.

Signed-off-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Guo Dong <Guo.Dong@intel.com>
Reviewed-by: Liming Gao <Liming.Gao@intel.com>

Contributed-under: TianoCore Contribution Agreement 1.0


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15360 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Jiewen Yao
2014-03-21 02:51:42 +00:00
committed by jyao1
parent 553e86699d
commit 5437d457b9
8 changed files with 162 additions and 188 deletions

View File

@@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiPei.h>
#include <Ppi/ReadOnlyVariable2.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
@@ -64,25 +65,47 @@ DetectTpmDevice (
{
EFI_STATUS Status;
EFI_BOOT_MODE BootMode;
Status = PeiServicesGetBootMode (&BootMode);
ASSERT_EFI_ERROR (Status);
//
// In S3, we rely on Setup option, because we save to Setup in normal boot.
//
if (BootMode == BOOT_ON_S3_RESUME) {
DEBUG ((EFI_D_ERROR, "DetectTpmDevice: S3 mode\n"));
return SetupTpmDevice;
}
TREE_DEVICE_DETECTION TrEEDeviceDetection;
EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi;
UINTN Size;
if (PcdGetBool (PcdHideTpmSupport) && PcdGetBool (PcdHideTpm)) {
DEBUG ((EFI_D_ERROR, "DetectTpmDevice: Tpm is hide\n"));
return TPM_DEVICE_NULL;
}
Status = PeiServicesGetBootMode (&BootMode);
ASSERT_EFI_ERROR (Status);
//
// In S3, we rely on normal boot Detection, because we save to ReadOnly Variable in normal boot.
//
if (BootMode == BOOT_ON_S3_RESUME) {
DEBUG ((EFI_D_ERROR, "DetectTpmDevice: S3 mode\n"));
Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NULL, (VOID **) &VariablePpi);
ASSERT_EFI_ERROR (Status);
Size = sizeof(TREE_DEVICE_DETECTION);
ZeroMem (&TrEEDeviceDetection, sizeof(TrEEDeviceDetection));
Status = VariablePpi->GetVariable (
VariablePpi,
TREE_DEVICE_DETECTION_NAME,
&gTrEEConfigFormSetGuid,
NULL,
&Size,
&TrEEDeviceDetection
);
if (!EFI_ERROR (Status) &&
(TrEEDeviceDetection.TpmDeviceDetected >= TPM_DEVICE_MIN) &&
(TrEEDeviceDetection.TpmDeviceDetected <= TPM_DEVICE_MAX)) {
DEBUG ((EFI_D_ERROR, "TpmDevice from DeviceDetection: %x\n", TrEEDeviceDetection.TpmDeviceDetected));
return TrEEDeviceDetection.TpmDeviceDetected;
}
}
DEBUG ((EFI_D_ERROR, "DetectTpmDevice:\n"));
if ((!IsDtpmPresent ()) || (SetupTpmDevice == TPM_DEVICE_NULL)) {
if (!IsDtpmPresent ()) {
// dTPM not available
return TPM_DEVICE_NULL;
}
@@ -96,7 +119,11 @@ DetectTpmDevice (
return TPM_DEVICE_2_0_DTPM;
}
Status = Tpm12Startup (TPM_ST_CLEAR);
if (BootMode == BOOT_ON_S3_RESUME) {
Status = Tpm12Startup (TPM_ST_STATE);
} else {
Status = Tpm12Startup (TPM_ST_CLEAR);
}
if (EFI_ERROR (Status)) {
return TPM_DEVICE_2_0_DTPM;
}