xref: /aosp_15_r20/external/ms-tpm-20-ref/TPMCmd/tpm/include/prototypes/Time_fp.h (revision 5c591343844d1f9da7da26467c4bf7efc8a7a413)
1 /* Microsoft Reference Implementation for TPM 2.0
2  *
3  *  The copyright in this software is being made available under the BSD License,
4  *  included below. This software may be subject to other third party and
5  *  contributor rights, including patent rights, and no such rights are granted
6  *  under this license.
7  *
8  *  Copyright (c) Microsoft Corporation
9  *
10  *  All rights reserved.
11  *
12  *  BSD License
13  *
14  *  Redistribution and use in source and binary forms, with or without modification,
15  *  are permitted provided that the following conditions are met:
16  *
17  *  Redistributions of source code must retain the above copyright notice, this list
18  *  of conditions and the following disclaimer.
19  *
20  *  Redistributions in binary form must reproduce the above copyright notice, this
21  *  list of conditions and the following disclaimer in the documentation and/or
22  *  other materials provided with the distribution.
23  *
24  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""
25  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  *  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 /*(Auto-generated)
36  *  Created by TpmPrototypes; Version 3.0 July 18, 2017
37  *  Date: Apr  2, 2019  Time: 04:23:27PM
38  */
39 
40 #ifndef    _TIME_FP_H_
41 #define    _TIME_FP_H_
42 
43 //*** TimePowerOn()
44 // This function initialize time info at _TPM_Init().
45 //
46 // This function is called at _TPM_Init() so that the TPM time can start counting
47 // as soon as the TPM comes out of reset and doesn't have to wait until
48 // TPM2_Startup() in order to begin the new time epoch. This could be significant
49 // for systems that could get powered up but not run any TPM commands for some
50 // period of time.
51 //
52 void
53 TimePowerOn(
54     void
55 );
56 
57 //*** TimeStartup()
58 // This function updates the resetCount and restartCount components of
59 // TPMS_CLOCK_INFO structure at TPM2_Startup().
60 //
61 // This function will deal with the deferred creation of a new epoch.
62 // TimeUpdateToCurrent() will not start a new epoch even if one is due when
63 // TPM_Startup() has not been run. This is because the state of NV is not known
64 // until startup completes. When Startup is done, then it will create the epoch
65 // nonce to complete the initializations by calling this function.
66 BOOL
67 TimeStartup(
68     STARTUP_TYPE     type           // IN: start up type
69 );
70 
71 //*** TimeClockUpdate()
72 // This function updates go.clock. If 'newTime' requires an update of NV, then
73 // NV is checked for availability. If it is not available or is rate limiting, then
74 // go.clock is not updated and the function returns an error. If 'newTime' would
75 // not cause an NV write, then go.clock is updated. If an NV write occurs, then
76 // go.safe is SET.
77 void
78 TimeClockUpdate(
79     UINT64           newTime    // IN: New time value in mS.
80 );
81 
82 //*** TimeUpdate()
83 // This function is used to update the time and clock values. If the TPM
84 // has run TPM2_Startup(), this function is called at the start of each command.
85 // If the TPM has not run TPM2_Startup(), this is called from TPM2_Startup() to
86 // get the clock values initialized. It is not called on command entry because, in
87 // this implementation, the go structure is not read from NV until TPM2_Startup().
88 // The reason for this is that the initialization code (_TPM_Init()) may run before
89 // NV is accessible.
90 void
91 TimeUpdate(
92     void
93 );
94 
95 //*** TimeUpdateToCurrent()
96 // This function updates the 'Time' and 'Clock' in the global
97 // TPMS_TIME_INFO structure.
98 //
99 // In this implementation, 'Time' and 'Clock' are updated at the beginning
100 // of each command and the values are unchanged for the duration of the
101 // command.
102 //
103 // Because 'Clock' updates may require a write to NV memory, 'Time' and 'Clock'
104 // are not allowed to advance if NV is not available. When clock is not advancing,
105 // any function that uses 'Clock' will fail and return TPM_RC_NV_UNAVAILABLE or
106 // TPM_RC_NV_RATE.
107 //
108 // This implementation does not do rate limiting. If the implementation does do
109 // rate limiting, then the 'Clock' update should not be inhibited even when doing
110 // rate limiting.
111 void
112 TimeUpdateToCurrent(
113     void
114 );
115 
116 //*** TimeSetAdjustRate()
117 // This function is used to perform rate adjustment on 'Time' and 'Clock'.
118 void
119 TimeSetAdjustRate(
120     TPM_CLOCK_ADJUST     adjust         // IN: adjust constant
121 );
122 
123 //*** TimeGetMarshaled()
124 // This function is used to access TPMS_TIME_INFO in canonical form.
125 // The function collects the time information and marshals it into 'dataBuffer'
126 // and returns the marshaled size
127 UINT16
128 TimeGetMarshaled(
129     TIME_INFO       *dataBuffer     // OUT: result buffer
130 );
131 
132 //*** TimeFillInfo
133 // This function gathers information to fill in a TPMS_CLOCK_INFO structure.
134 void
135 TimeFillInfo(
136     TPMS_CLOCK_INFO     *clockInfo
137 );
138 
139 #endif  // _TIME_FP_H_
140