summaryrefslogtreecommitdiff
path: root/Core/EM/TCG2/Common/TcgLegacy.h
blob: 51e3fad091baa9900194042d713152c266c07cc0 (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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************
//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/TCG2/Common/TcgLegacy/TcgLegacy.h 1     4/21/14 2:17p Fredericko $
//
// $Revision: 1 $
//
// $Date: 4/21/14 2:17p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/TCG2/Common/TcgLegacy/TcgLegacy.h $
// 
// 1     4/21/14 2:17p Fredericko
// 
// 1     10/08/13 12:04p Fredericko
// Initial Check-In for Tpm-Next module
// 
// 2     10/03/13 3:08p Fredericko
// 
// 1     7/10/13 5:56p Fredericko
// [TAG]  		EIP120969
// [Category]  	New Feature
// [Description]  	TCG (TPM20)
// 
// 2     5/20/10 8:57a Fredericko
// Included File Header
// Code Beautification
// EIP 37653
//
// 1     3/23/10 7:57p Fredericko
//
// 11    12/31/09 2:42p Fredericko
// modfied the legacy16 and tpm32 structure.
//
// 10    4/30/09 6:16p Fredericko
// Updated Header Date
//
// 9     4/30/09 5:33p Fredericko
// AMI company Header Address changed
//
// 8     3/05/09 3:17p Fredericko
// Changes for CoreSources dependency
//
// 7     2/27/08 5:53p Fredericko
// Change in tpm32Header
//
// 6     6/13/07 5:24p Fredericko
// Function header for GetPCIOptionROM added
//
// 5     11/30/06 5:00p Fasihm
// More organized and formatted.
//
// 4     8/25/06 4:10p Andriyn
// Changed LEGX16HEADER with fields to track version information
//
// 3     8/22/06 1:30p Andriyn
// MOR related changes
//
// 2     8/15/06 9:28a Andriyn
//
// 1     6/20/06 5:58p Andriyn
//**********************************************************************
//*************************************************************************
//<AMI_FHDR_START>
//
// Name:  TcgLegacy.h
//
// Description:
// Header file for TCG Legacy subcomponent
//
//<AMI_FHDR_END>
//*************************************************************************
#include <EFI.h>

#pragma pack (push, 1)

EFI_FORWARD_DECLARATION( EFI_LEGACY_TCG_PROTOCOL );

typedef struct _TCG_LEGX16_HEADER TCG_LEGX16_HEADER;
struct _TCG_LEGX16_HEADER
{
    UINT16 wHeaderSize;
    UINT16 wLeg16Ver;
    UINT32 wTpm32hdr;
    UINT16 wTpm32entryPtr;
    UINT16 int1a_dispatch;
    UINT16 int19Ev;
    UINT16 intLoaderEv;
    UINT16 BevBcvEv;
    UINT16 InitCode;
    UINT16 Reserved;
    UINT16 regMOR; //8-15: byte offset; 0-7: bit position
};

typedef struct _TpmBinaryStruct TpmBinaryStruct;
struct _TpmBinaryStruct
{
    UINT16 wLegX16Seg;
    UINT16 int1a_dispatch;
    UINT16 int19Ev;
    UINT16 intLoaderEv;
    UINT16 BevBcvEv;
};

typedef struct _TPMBIOSDriverHeader TPMBIOSDriverHeader;
struct _TPMBIOSDriverHeader
{
    UINT16 TPMSignature;       // 55AAh
    UINT32 TPMCodeOffset;       // Offset to Entry Point
    UINT16 TPMCodeSize;
    UINT32 TPMBaseAddr;       // Base Adress of CMD register
    UINT32 TPMBaseAddrOpt;
    UINT8  TPMIRQ;
    UINT8  TPMDMA;
    UINT8  TPMCheckSum;
    UINT8  TPMReserve1;       // 00h
    UINT32 TPMPCIPFA;
    UINT32 TPMUSB;
    UINT32 TPMReserve2;       // 00000000h
    UINT16 TPMOEM0;
    UINT16 TPMOEM1;
};

typedef struct _MEM_OBJECT MEM_OBJECT;
struct _MEM_OBJECT
{
    UINT32 memptr; //void* memptr;
    UINT32 dwSize;
    UINT32 reserved1;
};

typedef struct _TPM32HEADER TPM32HEADER;
struct _TPM32HEADER
{
    UINT32 Signature;         //Signature of TPM32 module
    UINT32 entryPoint;        //offset to the dispatch code relative to the
                              //start of the TPM32 module
    UINT32     MP_HDR;            //TPMBIOSDriverHeader* MP_HDR;//offset to the start of the MP driver in MP_xSEG
    MEM_OBJECT scratch;

    //errType is one of { TCPA_ERRGRP_TPM,TCPA_ERRGRP_TCPA,or TCPA_ERRGRP_OTHER}
    //see tcpatpm.inc
    UINT32 errType;
    UINT8  TPMAcDeact;
    //meaning of errCode depends on errType: TPM err code, TCPA err code
    //or own error code
    UINT32 errCode;

    UINT32 ptrOnTPMFailue;

    MEM_OBJECT log;
    UINT32     freelog;
    UINT32     last;
    UINT32     nextevent;
    UINT32     lastEventShadow; // UINT8**
    UINT8      Tpm20Enabled;
    UINT64     efi_log_event_ptr;
};

typedef struct _SHA1_TCG_PCR_EVENT {
  UINT32                            PCRIndex;  // PCRIndex event extended to
  UINT32                            EventType; // TCG EFI event type
  UINT8                             Digest[20];    // Value extended into PCRIndex
  UINT32                            EventSize; // Size of the event data
  UINT8                             Event[1];  // The event data
} SHA1_PCR_EVENT;

#pragma pack (pop)
//
// TcgLegacy imports
//
EFI_STATUS GetRawImage (
    IN EFI_GUID  *NameGuid,
    IN OUT VOID  **Buffer,
    IN OUT UINTN *Size );

EFI_STATUS GetPCIOPROMImage (
    IN EFI_HANDLE PciHandle,
    OUT VOID      *RomImage,
    OUT UINTN     *Romsize,
    OUT UINTN     *Flags );
#ifdef EFI_DEBUG
  #define EFI_VERIFY( x ) ASSERT( !EFI_ERROR( x ))
#else
  #define EFI_VERIFY( x )            x
#endif
#define TPM32_SCRATCHMEM_SIZE    0x400
#define TPM32_LOG_SIZE            0x1000
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************