VirtualBox

source: vbox/trunk/src/libs/libtpms-0.9.0/src/tpm2/NV.h@ 91612

最後變更 在這個檔案從91612是 91612,由 vboxsync 提交於 3 年 前

src/libs: Export libtpms-0.9.0, bugref:10078

檔案大小: 7.6 KB
 
1/********************************************************************************/
2/* */
3/* */
4/* Written by Ken Goldman */
5/* IBM Thomas J. Watson Research Center */
6/* $Id: NV.h 1490 2019-07-26 21:13:22Z kgoldman $ */
7/* */
8/* Licenses and Notices */
9/* */
10/* 1. Copyright Licenses: */
11/* */
12/* - Trusted Computing Group (TCG) grants to the user of the source code in */
13/* this specification (the "Source Code") a worldwide, irrevocable, */
14/* nonexclusive, royalty free, copyright license to reproduce, create */
15/* derivative works, distribute, display and perform the Source Code and */
16/* derivative works thereof, and to grant others the rights granted herein. */
17/* */
18/* - The TCG grants to the user of the other parts of the specification */
19/* (other than the Source Code) the rights to reproduce, distribute, */
20/* display, and perform the specification solely for the purpose of */
21/* developing products based on such documents. */
22/* */
23/* 2. Source Code Distribution Conditions: */
24/* */
25/* - Redistributions of Source Code must retain the above copyright licenses, */
26/* this list of conditions and the following disclaimers. */
27/* */
28/* - Redistributions in binary form must reproduce the above copyright */
29/* licenses, this list of conditions and the following disclaimers in the */
30/* documentation and/or other materials provided with the distribution. */
31/* */
32/* 3. Disclaimers: */
33/* */
34/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
35/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
36/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
37/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */
38/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */
39/* information on specification licensing rights available through TCG */
40/* membership agreements. */
41/* */
42/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */
43/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */
44/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */
45/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */
46/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */
47/* */
48/* - Without limitation, TCG and its members and licensors disclaim all */
49/* liability, including liability for infringement of any proprietary */
50/* rights, relating to use of information in this specification and to the */
51/* implementation of this specification, and TCG disclaims all liability for */
52/* cost of procurement of substitute goods or services, lost profits, loss */
53/* of use, loss of data or any incidental, consequential, direct, indirect, */
54/* or special damages, whether under contract, tort, warranty or otherwise, */
55/* arising in any way out of use or reliance upon this specification or any */
56/* information herein. */
57/* */
58/* (c) Copyright IBM Corp. and others, 2016 - 2019 */
59/* */
60/********************************************************************************/
61
62#ifndef NV_H
63#define NV_H
64
65/* 5.14.1 Index Type Definitions */
66/* These definitions allow the same code to be used pre and post 1.21. The main action is to
67 redefine the index type values from the bit values. Use TPM_NT_ORDINARY to indicate if the TPM_NT
68 type is defined */
69#ifdef TPM_NT_ORDINARY
70/* If TPM_NT_ORDINARY is defined, then the TPM_NT field is present in a TPMA_NV */
71# define GET_TPM_NT(attributes) GET_ATTRIBUTE(attributes, TPMA_NV, TPM_NT)
72#else
73/* If TPM_NT_ORDINARY is not defined, then need to synthesize it from the attributes */
74# define GetNv_TPM_NV(attributes) \
75 ( IS_ATTRIBUTE(attributes, TPMA_NV, COUNTER) \
76 + (IS_ATTRIBUTE(attributes, TPMA_NV, BITS) << 1) \
77 + (IS_ATTRIBUTE(attributes, TPMA_NV, EXTEND) << 2) \
78 )
79# define TPM_NT_ORDINARY (0)
80# define TPM_NT_COUNTER (1)
81# define TPM_NT_BITS (2)
82# define TPM_NT_EXTEND (4)
83#endif
84/* 5.14.2 Attribute Macros */
85/* These macros are used to isolate the differences in the way that the index type changed in
86 version 1.21 of the specification */
87# define IsNvOrdinaryIndex(attributes) \
88 (GET_TPM_NT(attributes) == TPM_NT_ORDINARY)
89# define IsNvCounterIndex(attributes) \
90 (GET_TPM_NT(attributes) == TPM_NT_COUNTER)
91# define IsNvBitsIndex(attributes) \
92 (GET_TPM_NT(attributes) == TPM_NT_BITS)
93# define IsNvExtendIndex(attributes) \
94 (GET_TPM_NT(attributes) == TPM_NT_EXTEND)
95#ifdef TPM_NT_PIN_PASS
96# define IsNvPinPassIndex(attributes) \
97 (GET_TPM_NT(attributes) == TPM_NT_PIN_PASS)
98#endif
99#ifdef TPM_NT_PIN_FAIL
100# define IsNvPinFailIndex(attributes) \
101 (GET_TPM_NT(attributes) == TPM_NT_PIN_FAIL)
102#endif
103typedef struct {
104 UINT32 size;
105 TPM_HANDLE handle;
106} NV_ENTRY_HEADER;
107#define NV_EVICT_OBJECT_SIZE \
108 (sizeof(UINT32) + sizeof(TPM_HANDLE) + sizeof(OBJECT))
109#define NV_INDEX_COUNTER_SIZE \
110 (sizeof(UINT32) + sizeof(NV_INDEX) + sizeof(UINT64))
111#define NV_RAM_INDEX_COUNTER_SIZE \
112 (sizeof(NV_RAM_HEADER) + sizeof(UINT64))
113typedef struct {
114 UINT32 size;
115 TPM_HANDLE handle;
116 TPMA_NV attributes;
117} NV_RAM_HEADER;
118/* Defines the end-of-list marker for NV. The list terminator is a UINT32 of zero, followed by the
119 current value of s_maxCounter which is a 64-bit value. The structure is defined as an array of 3
120 UINT32 values so that there is no padding between the UINT32 list end marker and the UINT64
121 maxCounter value. */
122typedef UINT32 NV_LIST_TERMINATOR[3];
123/* 5.14.3 Orderly RAM Values */
124/* The following defines are for accessing orderly RAM values. This is the initialize for the RAM
125 reference iterator. */
126#define NV_RAM_REF_INIT 0
127/* This is the starting address of the RAM space used for orderly data */
128#define RAM_ORDERLY_START \
129 (&s_indexOrderlyRam[0])
130/* This is the offset within NV that is used to save the orderly data on an orderly shutdown. */
131#define NV_ORDERLY_START \
132 (NV_INDEX_RAM_DATA)
133/* This is the end of the orderly RAM space. It is actually the first byte after the last byte of
134 orderly RAM data */
135#define RAM_ORDERLY_END \
136 (RAM_ORDERLY_START + sizeof(s_indexOrderlyRam))
137/* This is the end of the orderly space in NV memory. As with RAM_ORDERLY_END, it is actually the
138 offset of the first byte after the end of the NV orderly data. */
139#define NV_ORDERLY_END \
140 (NV_ORDERLY_START + sizeof(s_indexOrderlyRam))
141/* Macro to check that an orderly RAM address is with range. */
142#define ORDERLY_RAM_ADDRESS_OK(start, offset) \
143 ((start >= RAM_ORDERLY_START) && ((start + offset - 1) < RAM_ORDERLY_END))
144#define RETURN_IF_NV_IS_NOT_AVAILABLE \
145 { \
146 if(g_NvStatus != TPM_RC_SUCCESS) \
147 return g_NvStatus; \
148 }
149/* Routinely have to clear the orderly flag and fail if the NV is not available so that it can be
150 cleared. */
151#define RETURN_IF_ORDERLY \
152 { \
153 if(NvClearOrderly() != TPM_RC_SUCCESS) \
154 return g_NvStatus; \
155 }
156#define NV_IS_AVAILABLE (g_NvStatus == TPM_RC_SUCCESS)
157#define IS_ORDERLY(value) (value < SU_DA_USED_VALUE)
158#define NV_IS_ORDERLY (IS_ORDERLY(gp.orderlyState))
159/* Macro to set the NV UPDATE_TYPE. This deals with the fact that the update is possibly a
160 combination of UT_NV and UT_ORDERLY. */
161#define SET_NV_UPDATE(type) g_updateNV |= (type)
162#endif // _NV_H_
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette