summaryrefslogtreecommitdiff
path: root/Board/CPU/TxtPei/AmiTxtPei.c
blob: 5081caa7603f12aff1b0d4be42c8671b25b27c26 (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1987-2013, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************

//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/Haswell/AMI Cpu PKG/AMI TXT PEI/AmiTxtPei.c 5     6/11/15 10:32p Crystallee $
//
// $Revision: 5 $
//
// $Date: 6/11/15 10:32p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/Haswell/AMI Cpu PKG/AMI TXT PEI/AmiTxtPei.c $
// 
// 5     6/11/15 10:32p Crystallee
// [TAG]  		EIP207854
// [Category]  	Bug Fix
// [Severity]  	Important
// [Symptom]  	Txt test fail with TCG2 module
// [RootCause]  	Tokne TCG_SUPPORT was removed.
// [Solution]  	Add TCG2Support token.
// 
// 4     4/10/15 3:17a Crystallee
// 
// 3     9/13/12 4:15a Davidhsieh
// [TAG]  		None
// [Category]  	Bug Fix
// [Severity]  	Important
// [Symptom]  	Disable TCG support causes BIOS buiding error
// [RootCause]  	TCG setup data is used in TxtDxe and the data is not
// exist when TCG disabled.
// [Solution]  	Do not use TCG setup data when TCG disabled.
// 
// 2     8/22/12 3:29a Davidhsieh
// [TAG]  		None
// [Category]  	Improvement
// [Description]  	Install TPM_INITIALIZED_PPI  when TPM device is present
// TPM enabled in setup
// 
// 1     7/18/12 2:09a Davidhsieh
// [TAG]  		None
// [Category]  	Improvement
// [Description]  	AMI TXT PEI module part create
// 
//
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:    AmiTxtPei.c
//
// Description:
//
//<AMI_FHDR_END>
//**********************************************************************
//
#include <PEI.h>
#include <AmiPeiLib.h>
#include <AmiCspLib.h>
#include <ppi\ReadOnlyVariable.h>
#include <Setup.h>
#include <token.h>

#define PEI_TPM_INITIALIZED_PPI_GUID \
  { \
    0xe9db0d58, 0xd48d, 0x47f6, 0x9c, 0x6e, 0x6f, 0x40, 0xe8, 0x6c, 0x7b, 0x41 \
  }

static EFI_GUID gPeiTpmInitializedPpiGuid = PEI_TPM_INITIALIZED_PPI_GUID;
static EFI_GUID gEfiPeiReadOnlyVariablePpiGuid = EFI_PEI_READ_ONLY_VARIABLE_PPI_GUID;
static EFI_GUID gEfiSetupGuid                  = SETUP_GUID;

static EFI_PEI_PPI_DESCRIPTOR Tpm_Initialized[] =
{ 
	{
		EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
		&gPeiTpmInitializedPpiGuid, NULL 
	}
};

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   AmiTxtPeiEntry
//
// Description: PEI Entry Point for Intel TXT Driver.
//
// Input:       EFI_HANDLE          - ImageHandle
//              EFI_SYSTEM_TABLE*   - SystemTable
//
// Output:      None.
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS
AmiTxtPeiEntry (
    IN EFI_FFS_FILE_HEADER  *FfsHeader,
    IN EFI_PEI_SERVICES     **PeiServices
)
{
        
    UINT8       *TpmBaseAddr = (UINT8*)0xfed40000;
    EFI_PEI_READ_ONLY_VARIABLE_PPI  *ReadOnlyVariable;
    EFI_STATUS  Status;
    UINTN       VariableSize;
    
    SETUP_DATA SetupData;

    if (*TpmBaseAddr != 0xff){  //If TPM device is present, check TPM setup data
        Status = (*PeiServices)->LocatePpi(
            PeiServices,
            &gEfiPeiReadOnlyVariablePpiGuid,
            0, 
            NULL,
            &ReadOnlyVariable       
        );                                        
    
        if (EFI_ERROR(Status)) return EFI_SUCCESS;
                                        
        VariableSize = sizeof(SETUP_DATA);
    
        Status = ReadOnlyVariable->GetVariable(
            PeiServices,
            L"Setup", 
            &gEfiSetupGuid,
            NULL,
            &VariableSize,  
            &SetupData
        );

		if ( EFI_ERROR(Status) ) return EFI_SUCCESS;

#if TCG_SUPPORT || TCG2Support
        if (SetupData.TpmSupport)   
            (*PeiServices)->InstallPpi(PeiServices, Tpm_Initialized);    //Install PPI if TPM device detected and enable in setup
#endif            
    }
    
    return EFI_SUCCESS;
}

//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1987-2013, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************