1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
//*************************************************************************
//*************************************************************************
//** **
//** (C)Copyright 1985-2011, American Megatrends, Inc. **
//** **
//** All Rights Reserved. **
//** **
//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
//** **
//** Phone: (770)-246-8600 **
//** **
//*************************************************************************
//*************************************************************************
//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/TCG2/Common/TpmClearOnRollback/TpmClearOnRollback.c 1 4/21/14 2:18p Fredericko $
//
// $Revision: 1 $
//
// $Date: 4/21/14 2:18p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/TCG2/Common/TpmClearOnRollback/TpmClearOnRollback.c $
//
// 1 4/21/14 2:18p Fredericko
//
// 1 10/08/13 12:06p Fredericko
// Initial Check-In for Tpm-Next module
//
// 1 7/10/13 5:57p Fredericko
// [TAG] EIP120969
// [Category] New Feature
// [Description] TCG (TPM20)
//**********************************************************************
//<AMI_FHDR_START>
//---------------------------------------------------------------------------
// Name: TpmClearOnRollback
//
//
//
//---------------------------------------------------------------------------
//<AMI_FHDR_END>
#include "TpmClearOnRollback.h"
#include <Protocol/AmiPostMgr.h>
#include <PPI/FwVersion.h>
#include <Hob.h>
#include <Token.h>
#include <AmiHobs.h>
VOID DrawMessageBox(
IN CHAR16 *Caption,
IN CHAR16 *Message
);
//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure: RecoveryClearTpmBeforeFlash
//
// Description:
// Process TPM clear on Rollback policy
//
// Input:
// VOID
//
// Output:
// VOID
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID RecoveryClearTpmBeforeFlash (VOID){
UINT8 ClearResults;
AMI_POST_MANAGER_PROTOCOL *TpmClearAmiPostMgr = NULL;
FW_VERSION Fid;
EFI_EVENT MyEvent;
FW_VERSION RecoveryFid;
EFI_HOB_HANDOFF_INFO_TABLE *TpmpHit;
EFI_GUID myGuidHob = HOB_LIST_GUID;
EFI_GUID TpmRecoveryHobGuid = AMI_RECOVERY_IMAGE_HOB_GUID;
UINT32 ProjectVersion, NewProjectVersion;
EFI_GUID gAmiPostManagerProtocolGuid = \
AMI_POST_MANAGER_PROTOCOL_GUID;
EFI_STATUS Status;
TpmpHit = GetEfiConfigurationTable(pST, &myGuidHob);
if(TpmpHit != NULL && !EFI_ERROR(FindNextHobByGuid(&TpmRecoveryHobGuid, &TpmpHit))) {
TpmGetFidFromBuffer(&RecoveryFid, (VOID *)(UINTN)((RECOVERY_IMAGE_HOB*)TpmpHit)->Address);
}
TpmRecoveryGetFidFromFv(&Fid);
ProjectVersion = Fid.ProjectMajorVersion[0] + Fid.ProjectMajorVersion[1] + Fid.ProjectMajorVersion[2];
ProjectVersion <<= 16;
ProjectVersion += Fid.ProjectMinorVersion[0] + Fid.ProjectMinorVersion[1] + Fid.ProjectMinorVersion[2];
NewProjectVersion = RecoveryFid.ProjectMajorVersion[0] + RecoveryFid.ProjectMajorVersion[1] + RecoveryFid.ProjectMajorVersion[2];
NewProjectVersion <<= 16;
NewProjectVersion += RecoveryFid.ProjectMinorVersion[0] + RecoveryFid.ProjectMinorVersion[1] + RecoveryFid.ProjectMinorVersion[2];
if(NewProjectVersion < ProjectVersion){
ClearResults = ClearTpmBeforeFlash();
if(ClearResults == TPM_CLEAR_RESET_REQUIRED)
{
Status = pBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL, &TpmClearAmiPostMgr);
if(EFI_ERROR(Status))return;
if(TpmClearAmiPostMgr != NULL) {
Status = TpmClearAmiPostMgr->DisplayInfoBox(L"TPM CLEAR",\
L"Caution: A Reset is required to Clear the TPM for Flash Update. Enable Recovery after reset",20, &MyEvent);
FixedDelay(1000000); //10seconds delay
}
pRS->ResetSystem( EfiResetCold, 0, 0, NULL );
}
}
}
//*************************************************************************
//*************************************************************************
//** **
//** (C)Copyright 1985-2010, American Megatrends, Inc. **
//** **
//** All Rights Reserved. **
//** **
//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
//** **
//** Phone: (770)-246-8600 **
//** **
//*************************************************************************
//*************************************************************************
|