xref: /aosp_15_r20/external/ms-tpm-20-ref/TPMCmd/tpm/include/prototypes/NvReserved_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    _NV_RESERVED_FP_H_
41 #define    _NV_RESERVED_FP_H_
42 
43 //*** NvCheckState()
44 // Function to check the NV state by accessing the platform-specific function
45 // to get the NV state.  The result state is registered in s_NvIsAvailable
46 // that will be reported by NvIsAvailable.
47 //
48 // This function is called at the beginning of ExecuteCommand before any potential
49 // check of g_NvStatus.
50 void
51 NvCheckState(
52     void
53 );
54 
55 //*** NvCommit
56 // This is a wrapper for the platform function to commit pending NV writes.
57 BOOL
58 NvCommit(
59     void
60 );
61 
62 //*** NvPowerOn()
63 //  This function is called at _TPM_Init to initialize the NV environment.
64 //  Return Type: BOOL
65 //      TRUE(1)         all NV was initialized
66 //      FALSE(0)        the NV containing saved state had an error and
67 //                      TPM2_Startup(CLEAR) is required
68 BOOL
69 NvPowerOn(
70     void
71 );
72 
73 //*** NvManufacture()
74 // This function initializes the NV system at pre-install time.
75 //
76 // This function should only be called in a manufacturing environment or in a
77 // simulation.
78 //
79 // The layout of NV memory space is an implementation choice.
80 void
81 NvManufacture(
82     void
83 );
84 
85 //*** NvRead()
86 // This function is used to move reserved data from NV memory to RAM.
87 void
88 NvRead(
89     void            *outBuffer,     // OUT: buffer to receive data
90     UINT32           nvOffset,      // IN: offset in NV of value
91     UINT32           size           // IN: size of the value to read
92 );
93 
94 //*** NvWrite()
95 // This function is used to post reserved data for writing to NV memory. Before
96 // the TPM completes the operation, the value will be written.
97 BOOL
98 NvWrite(
99     UINT32           nvOffset,      // IN: location in NV to receive data
100     UINT32           size,          // IN: size of the data to move
101     void            *inBuffer       // IN: location containing data to write
102 );
103 
104 //*** NvUpdatePersistent()
105 // This function is used to update a value in the PERSISTENT_DATA structure and
106 // commits the value to NV.
107 void
108 NvUpdatePersistent(
109     UINT32           offset,        // IN: location in PERMANENT_DATA to be updated
110     UINT32           size,          // IN: size of the value
111     void            *buffer         // IN: the new data
112 );
113 
114 //*** NvClearPersistent()
115 // This function is used to clear a persistent data entry and commit it to NV
116 void
117 NvClearPersistent(
118     UINT32           offset,        // IN: the offset in the PERMANENT_DATA
119                                     //     structure to be cleared (zeroed)
120     UINT32           size           // IN: number of bytes to clear
121 );
122 
123 //*** NvReadPersistent()
124 // This function reads persistent data to the RAM copy of the 'gp' structure.
125 void
126 NvReadPersistent(
127     void
128 );
129 
130 #endif  // _NV_RESERVED_FP_H_
131