1 /** @file
2   Header file for NV data structure definition.
3 
4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef __TCG2_CONFIG_NV_DATA_H__
16 #define __TCG2_CONFIG_NV_DATA_H__
17 
18 #include <Guid/HiiPlatformSetupFormset.h>
19 #include <Guid/Tcg2ConfigHii.h>
20 #include <IndustryStandard/TcgPhysicalPresence.h>
21 
22 //
23 // BUGBUG: In order to pass VfrCompiler, we have to redefine below MACRO, which already in <Protocol/Tcg2Protocol.h>.
24 //
25 #ifndef __TCG2_H__
26 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2       0x00000001
27 #define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2         0x00000002
28 #endif
29 #define EFI_TCG2_EVENT_LOG_FORMAT_ALL           (EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 | EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)
30 
31 #define TCG2_CONFIGURATION_VARSTORE_ID  0x0001
32 #define TCG2_CONFIGURATION_INFO_VARSTORE_ID  0x0002
33 #define TCG2_CONFIGURATION_FORM_ID      0x0001
34 
35 #define KEY_TPM_DEVICE                                 0x2000
36 #define KEY_TPM2_OPERATION                             0x2001
37 #define KEY_TPM2_OPERATION_PARAMETER            0x2002
38 #define KEY_TPM2_PCR_BANKS_REQUEST_0            0x2003
39 #define KEY_TPM2_PCR_BANKS_REQUEST_1            0x2004
40 #define KEY_TPM2_PCR_BANKS_REQUEST_2            0x2005
41 #define KEY_TPM2_PCR_BANKS_REQUEST_3            0x2006
42 #define KEY_TPM2_PCR_BANKS_REQUEST_4            0x2007
43 #define KEY_TPM_DEVICE_INTERFACE                       0x2008
44 
45 #define TPM_DEVICE_NULL           0
46 #define TPM_DEVICE_1_2            1
47 #define TPM_DEVICE_2_0_DTPM       2
48 #define TPM_DEVICE_MIN            TPM_DEVICE_1_2
49 #define TPM_DEVICE_MAX            TPM_DEVICE_2_0_DTPM
50 #define TPM_DEVICE_DEFAULT        TPM_DEVICE_1_2
51 
52 #define TPM_DEVICE_INTERFACE_TIS       0
53 #define TPM_DEVICE_INTERFACE_PTP_FIFO  1
54 #define TPM_DEVICE_INTERFACE_PTP_CRB   2
55 #define TPM_DEVICE_INTERFACE_MAX       TPM_DEVICE_INTERFACE_PTP_FIFO
56 #define TPM_DEVICE_INTERFACE_DEFAULT   TPM_DEVICE_INTERFACE_PTP_CRB
57 
58 #define TCG2_PROTOCOL_VERSION_DEFAULT        0x0001
59 #define EFI_TCG2_EVENT_LOG_FORMAT_DEFAULT    EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2
60 
61 //
62 // Nv Data structure referenced by IFR, TPM device user desired
63 //
64 typedef struct {
65   UINT8   TpmDevice;
66 } TCG2_CONFIGURATION;
67 
68 typedef struct {
69   BOOLEAN  Sha1Supported;
70   BOOLEAN  Sha256Supported;
71   BOOLEAN  Sha384Supported;
72   BOOLEAN  Sha512Supported;
73   BOOLEAN  Sm3Supported;
74   UINT8    TpmDeviceInterfaceAttempt;
75   BOOLEAN  TpmDeviceInterfacePtpFifoSupported;
76   BOOLEAN  TpmDeviceInterfacePtpCrbSupported;
77 } TCG2_CONFIGURATION_INFO;
78 
79 //
80 // Variable saved for S3, TPM detected, only valid in S3 path.
81 // This variable is ReadOnly.
82 //
83 typedef struct {
84   UINT8   TpmDeviceDetected;
85 } TCG2_DEVICE_DETECTION;
86 
87 #define TCG2_STORAGE_NAME           L"TCG2_CONFIGURATION"
88 #define TCG2_STORAGE_INFO_NAME      L"TCG2_CONFIGURATION_INFO"
89 #define TCG2_DEVICE_DETECTION_NAME  L"TCG2_DEVICE_DETECTION"
90 
91 #define TPM_INSTANCE_ID_LIST  { \
92   {TPM_DEVICE_INTERFACE_NONE,           TPM_DEVICE_NULL},      \
93   {TPM_DEVICE_INTERFACE_TPM12,          TPM_DEVICE_1_2},       \
94   {TPM_DEVICE_INTERFACE_TPM20_DTPM,     TPM_DEVICE_2_0_DTPM},  \
95 }
96 
97 //
98 // BUGBUG: In order to pass VfrCompiler, we have to redefine GUID here.
99 //
100 #ifndef __BASE_H__
101 typedef struct {
102   UINT32  Data1;
103   UINT16  Data2;
104   UINT16  Data3;
105   UINT8   Data4[8];
106 } GUID;
107 #endif
108 
109 typedef struct {
110   GUID       TpmInstanceGuid;
111   UINT8      TpmDevice;
112 } TPM_INSTANCE_ID;
113 
114 #endif
115