nv.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef EPID_MEMBER_TPM2_NV_H_
  19. #define EPID_MEMBER_TPM2_NV_H_
  20. #include <stddef.h>
  21. #include "epid/common/errors.h"
  22. #include "epid/common/stdtypes.h"
  23. /// \cond
  24. typedef struct Tpm2Ctx Tpm2Ctx;
  25. /// \endcond
  26. /*!
  27. \addtogroup Tpm2Module tpm2
  28. \ingroup EpidMemberModule
  29. @{
  30. */
  31. /// Performs TPM2_NV_DefineSpace TPM command.
  32. /*!
  33. \param[in] ctx
  34. The TPM context.
  35. \param[in] nv_index
  36. Handle of the data area.
  37. \param[in] size
  38. Size of the data area.
  39. \returns ::EpidStatus
  40. \see Tpm2NvRead
  41. \see Tpm2NvWrite
  42. */
  43. EpidStatus Tpm2NvDefineSpace(Tpm2Ctx* ctx, uint32_t nv_index, size_t size);
  44. /// Performs TPM2_NV_UndefineSpace TPM command.
  45. /*!
  46. \param[in] ctx
  47. The TPM context.
  48. \param[in] nv_index
  49. Handle of the data area to undefine.
  50. \returns ::EpidStatus
  51. \see Tpm2NvDefineSpace
  52. */
  53. EpidStatus Tpm2NvUndefineSpace(Tpm2Ctx* ctx, uint32_t nv_index);
  54. /// Performs TPM2_NV_Write TPM command.
  55. /*!
  56. An area in NV memory must be defined prior writing.
  57. \param[in] ctx
  58. The TPM context.
  59. \param[in] nv_index
  60. NV Index to be write.
  61. \param[in] size
  62. Number of bytes to write.
  63. \param[in] offset
  64. Offset into the area.
  65. \param[in] data
  66. Data to write.
  67. \returns ::EpidStatus
  68. \see Tpm2NvDefineSpace
  69. */
  70. EpidStatus Tpm2NvWrite(Tpm2Ctx* ctx, uint32_t nv_index, size_t size,
  71. uint16_t offset, void const* data);
  72. /// Performs TPM2_NV_Read TPM command.
  73. /*!
  74. \param[in] ctx
  75. The TPM context.
  76. \param[in] nv_index
  77. NV Index to be read.
  78. \param[in] size
  79. Number of bytes to read.
  80. \param[in] offset
  81. Offset into the area.
  82. \param[out] data
  83. Data read.
  84. \returns ::EpidStatus
  85. \see Tpm2NvWrite
  86. */
  87. EpidStatus Tpm2NvRead(Tpm2Ctx* ctx, uint32_t nv_index, size_t size,
  88. uint16_t offset, void* data);
  89. /*! @} */
  90. #endif // EPID_MEMBER_TPM2_NV_H_