nuke pkcs11_tpm and tpmadm(1m)
[unleashed.git] / usr / src / uts / common / io / tpm / tpm_ddi.h
blobf2cea655f418f3dcb71947093f54d4f5ab0245f1
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _TPM_DDI_H
28 #define _TPM_DDI_H
30 /* Duration index is SHORT, MEDIUM, LONG, UNDEFINED */
31 #define TPM_DURATION_MAX_IDX 3
34 * IO buffer size: this seems sufficient, but feel free to modify
35 * This should be at minimum 765
37 #define TPM_IO_BUF_SIZE 4096
39 #define TPM_IO_TIMEOUT 10000000
42 * Flags to keep track of for the allocated resources
43 * so we know what to deallocate later on
45 enum tpm_ddi_resources_flags {
46 TPM_OPENED = 0x001,
47 TPM_DIDMINOR = 0x002,
48 TPM_DIDREGSMAP = 0x004,
49 TPM_DIDINTMUTEX = 0x008,
50 TPM_DIDINTCV = 0x010,
51 TPM_DID_IO_ALLOC = 0x100,
52 TPM_DID_IO_MUTEX = 0x200,
53 TPM_DID_IO_CV = 0x400,
54 TPM_DID_MUTEX = 0x800,
55 TPM_DID_SOFT_STATE = 0x1000,
56 #ifdef sun4v
57 TPM_HSVC_REGISTERED = 0x2000
58 #endif
61 typedef struct tpm_state tpm_state_t;
63 /* TPM specific data structure */
64 struct tpm_state {
65 /* TPM specific */
66 TPM_CAP_VERSION_INFO vers_info;
68 /* OS specific */
69 int instance;
70 dev_info_t *dip;
71 ddi_acc_handle_t handle;
73 kmutex_t dev_lock;
74 uint8_t dev_held;
77 * For read/write
79 uint8_t *iobuf;
80 size_t bufsize;
81 uint8_t iobuf_inuse;
82 kmutex_t iobuf_lock;
83 kcondvar_t iobuf_cv;
86 * For supporting the interrupt
88 uint8_t intr_enabled;
89 ddi_intr_handle_t *h_array;
90 uint_t intr_pri;
91 unsigned int state;
93 uint8_t *addr; /* where TPM is mapped to */
94 char locality; /* keep track of the locality */
96 uint32_t flags; /* flags to keep track of what is allocated */
97 clock_t duration[4]; /* short,medium,long,undefined */
98 clock_t timeout_a;
99 clock_t timeout_b;
100 clock_t timeout_c;
101 clock_t timeout_d;
102 clock_t timeout_poll;
104 ddi_device_acc_attr_t accattr;
106 /* For power management. */
107 kmutex_t pm_mutex;
108 kcondvar_t suspend_cv;
109 uint32_t suspended;
111 #ifdef KCF_TPM_RNG_PROVIDER
112 /* For RNG */
113 crypto_kcf_provider_handle_t n_prov;
114 #endif
117 #endif /* _TPM_DDI_H */