• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*############################################################################
2 # Copyright 2017 Intel Corporation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 ############################################################################*/
16 /// SDK TPM non volatile memory API.
17 /*! \file */
18 
19 #ifndef EPID_MEMBER_TPM2_NV_H_
20 #define EPID_MEMBER_TPM2_NV_H_
21 
22 #include <stddef.h>
23 
24 #include "epid/common/errors.h"
25 #include "epid/common/stdtypes.h"
26 
27 /// \cond
28 typedef struct Tpm2Ctx Tpm2Ctx;
29 /// \endcond
30 
31 /*!
32  \addtogroup Tpm2Module tpm2
33  \ingroup EpidMemberModule
34  @{
35 */
36 
37 /// Performs TPM2_NV_DefineSpace TPM command.
38 /*!
39  \param[in] ctx
40  The TPM context.
41  \param[in] nv_index
42  Handle of the data area.
43  \param[in] size
44  Size of the data area.
45 
46  \returns ::EpidStatus
47 
48  \see Tpm2NvRead
49  \see Tpm2NvWrite
50 */
51 EpidStatus Tpm2NvDefineSpace(Tpm2Ctx* ctx, uint32_t nv_index, size_t size);
52 
53 /// Performs TPM2_NV_UndefineSpace TPM command.
54 /*!
55  \param[in] ctx
56  The TPM context.
57  \param[in] nv_index
58  Handle of the data area to undefine.
59 
60  \returns ::EpidStatus
61 
62  \see Tpm2NvDefineSpace
63 */
64 EpidStatus Tpm2NvUndefineSpace(Tpm2Ctx* ctx, uint32_t nv_index);
65 
66 /// Performs TPM2_NV_Write TPM command.
67 /*!
68  An area in NV memory must be defined prior writing.
69 
70  \param[in] ctx
71  The TPM context.
72  \param[in] nv_index
73  NV Index to be write.
74  \param[in] size
75  Number of bytes to write.
76  \param[in] offset
77  Offset into the area.
78  \param[in] data
79  Data to write.
80 
81  \returns ::EpidStatus
82 
83  \see Tpm2NvDefineSpace
84 */
85 EpidStatus Tpm2NvWrite(Tpm2Ctx* ctx, uint32_t nv_index, size_t size,
86                        uint16_t offset, void const* data);
87 
88 /// Performs TPM2_NV_Read TPM command.
89 /*!
90  \param[in] ctx
91  The TPM context.
92  \param[in] nv_index
93  NV Index to be read.
94  \param[in] size
95  Number of bytes to read.
96  \param[in] offset
97  Offset into the area.
98  \param[out] data
99  Data read.
100 
101  \returns ::EpidStatus
102 
103  \see Tpm2NvWrite
104 */
105 EpidStatus Tpm2NvRead(Tpm2Ctx* ctx, uint32_t nv_index, size_t size,
106                       uint16_t offset, void* data);
107 
108 /*! @} */
109 
110 #endif  // EPID_MEMBER_TPM2_NV_H_
111