1 /********************************************************************************/
2 /*										*/
3 /*	     	TPM2 Novoton Proprietary Command Utilities			*/
4 /*			     Written by Ken Goldman				*/
5 /*		       IBM Thomas J. Watson Research Center			*/
6 /*	      $Id: ntc2lib.h 1257 2018-06-27 20:52:08Z kgoldman $		*/
7 /*										*/
8 /* (c) Copyright IBM Corporation 2015, 2017					*/
9 /*										*/
10 /* All rights reserved.								*/
11 /* 										*/
12 /* Redistribution and use in source and binary forms, with or without		*/
13 /* modification, are permitted provided that the following conditions are	*/
14 /* met:										*/
15 /* 										*/
16 /* Redistributions of source code must retain the above copyright notice,	*/
17 /* this list of conditions and the following disclaimer.			*/
18 /* 										*/
19 /* Redistributions in binary form must reproduce the above copyright		*/
20 /* notice, this list of conditions and the following disclaimer in the		*/
21 /* documentation and/or other materials provided with the distribution.		*/
22 /* 										*/
23 /* Neither the names of the IBM Corporation nor the names of its		*/
24 /* contributors may be used to endorse or promote products derived from		*/
25 /* this software without specific prior written permission.			*/
26 /* 										*/
27 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS		*/
28 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT		*/
29 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR	*/
30 /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT		*/
31 /* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,	*/
32 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT		*/
33 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,	*/
34 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY	*/
35 /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT		*/
36 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE	*/
37 /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.		*/
38 /********************************************************************************/
39 
40 #ifndef NTC2LIB_H
41 #define NTC2LIB_H
42 
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <string.h>
46 #include <stdint.h>
47 
48 #include <ibmtss/TPM_Types.h>
49 #include <ibmtss/Unmarshal_fp.h>
50 
51 /* default values for System P8 I2C */
52 
53 #define P8_REQUIRED_i2cLoc1_2  	0xff
54 #define P8_REQUIRED_i2cLoc3_4  	0xff
55 #define P8_REQUIRED_AltCfg	0x03
56 #define P8_REQUIRED_Direction  	0x00
57 #define P8_REQUIRED_PullUp    	0xff
58 #define P8_REQUIRED_PushPull   	0xff
59 #define P8_REQUIRED_CFG_A    	0xfe
60 #define P8_REQUIRED_CFG_B    	0xff
61 #define P8_REQUIRED_CFG_C    	0xff
62 #define P8_REQUIRED_CFG_D    	0xff
63 #define P8_REQUIRED_CFG_E    	0xff
64 #define P8_REQUIRED_CFG_F    	0xff
65 #define P8_REQUIRED_CFG_G    	0xff
66 #define P8_REQUIRED_CFG_H    	0xff
67 #define P8_REQUIRED_CFG_I    	0xff
68 #define P8_REQUIRED_CFG_J    	0xff
69 #define P8_REQUIRED_IsValid    	0xaa
70 #define P8_REQUIRED_IsLocked	0x00;
71 
72 /* default values for System P8 I2C */
73 
74 #define P9_REQUIRED_i2cLoc1_2  	0xa9		/* changed */
75 #define P9_REQUIRED_i2cLoc3_4  	0xa5		/* changed */
76 #define P9_REQUIRED_AltCfg	0x03
77 #define P9_REQUIRED_Direction  	0x00
78 #define P9_REQUIRED_PullUp    	0xff
79 #define P9_REQUIRED_PushPull   	0xff
80 #define P9_REQUIRED_CFG_A    	0xfe
81 #define P9_REQUIRED_CFG_B    	0xff
82 #define P9_REQUIRED_CFG_C    	0xff
83 #define P9_REQUIRED_CFG_D    	0xff
84 #define P9_REQUIRED_CFG_E    	0xff
85 #define P9_REQUIRED_CFG_F    	0xff
86 #define P9_REQUIRED_CFG_G    	0xff
87 #define P9_REQUIRED_CFG_H    	0xf0		/* changed */
88 #define P9_REQUIRED_CFG_I    	0xff
89 #define P9_REQUIRED_CFG_J    	0xff
90 #define P9_REQUIRED_IsValid    	0xaa
91 #define P9_REQUIRED_IsLocked	0x00;
92 
93 /* required values, others not supported */
94 
95 #define FIXED_Direction   	0x00
96 #define FIXED_PullUp    	0xff
97 #define FIXED_PushPull    	0xff
98 #define FIXED_CFG_F    		0xff
99 #define FIXED_CFG_I    		0xff
100 #define FIXED_CFG_J    		0xff
101 #define FIXED_IsValid    	0xaa
102 
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106 
107     TPM_RC
108     verifyConfig(NTC2_CFG_STRUCT *expected, NTC2_CFG_STRUCT *actual, int verifyLocked);
109     void
110     requiredConfig(NTC2_CFG_STRUCT *preConfig, int p9);
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif
117