xref: /titanic_44/usr/src/uts/common/io/tpm/tpm_ddi.h (revision 6ceee06ed8e277b6a91d57cded4717df91ff146e)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_TPM_DDI_H
28 #define	_TPM_DDI_H
29 
30 /* Duration index is SHORT, MEDIUM, LONG, UNDEFINED */
31 #define	TPM_DURATION_MAX_IDX	3
32 
33 /*
34  * IO buffer size: this seems sufficient, but feel free to modify
35  * This should be at minimum 765
36  */
37 #define	TPM_IO_BUF_SIZE		4096
38 
39 #define	TPM_IO_TIMEOUT		10000000
40 
41 /*
42  * Flags to keep track of for the allocated resources
43  * so we know what to deallocate later on
44  */
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 };
57 
58 typedef struct tpm_state tpm_state_t;
59 
60 /* TPM specific data structure */
61 struct tpm_state {
62 	/* TPM specific */
63 	TPM_CAP_VERSION_INFO vers_info;
64 
65 	/* OS specific */
66 	int 		instance;
67 	dev_info_t 	*dip;
68 	ddi_acc_handle_t handle;
69 
70 	kmutex_t	dev_lock;
71 	uint8_t		dev_held;
72 
73 	/*
74 	 * For read/write
75 	 */
76 	uint8_t		*iobuf;
77 	size_t		bufsize;
78 	uint8_t		iobuf_inuse;
79 	kmutex_t	iobuf_lock;
80 	kcondvar_t	iobuf_cv;
81 
82 	/*
83 	 * For supporting the interrupt
84 	 */
85 	uint8_t			intr_enabled;
86 	ddi_intr_handle_t	*h_array;
87 	uint_t			intr_pri;
88 	unsigned int		state;
89 
90 	uint8_t		*addr;		/* where TPM is mapped to */
91 	char		locality;	/* keep track of the locality */
92 
93 	uint32_t flags;		/* flags to keep track of what is allocated */
94 	clock_t duration[4];	/* short,medium,long,undefined */
95 	clock_t timeout_a;
96 	clock_t timeout_b;
97 	clock_t timeout_c;
98 	clock_t timeout_d;
99 	clock_t timeout_poll;
100 
101 	ddi_device_acc_attr_t accattr;
102 
103 	/* For power management. */
104 	kmutex_t	pm_mutex;
105 	kcondvar_t	suspend_cv;
106 	uint32_t	suspended;
107 };
108 
109 #endif	/* _TPM_DDI_H */
110