147e946e7SWyllys Ingersoll /* 247e946e7SWyllys Ingersoll * CDDL HEADER START 347e946e7SWyllys Ingersoll * 447e946e7SWyllys Ingersoll * The contents of this file are subject to the terms of the 547e946e7SWyllys Ingersoll * Common Development and Distribution License (the "License"). 647e946e7SWyllys Ingersoll * You may not use this file except in compliance with the License. 747e946e7SWyllys Ingersoll * 847e946e7SWyllys Ingersoll * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 947e946e7SWyllys Ingersoll * or http://www.opensolaris.org/os/licensing. 1047e946e7SWyllys Ingersoll * See the License for the specific language governing permissions 1147e946e7SWyllys Ingersoll * and limitations under the License. 1247e946e7SWyllys Ingersoll * 1347e946e7SWyllys Ingersoll * When distributing Covered Code, include this CDDL HEADER in each 1447e946e7SWyllys Ingersoll * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1547e946e7SWyllys Ingersoll * If applicable, add the following below this CDDL HEADER, with the 1647e946e7SWyllys Ingersoll * fields enclosed by brackets "[]" replaced with your own identifying 1747e946e7SWyllys Ingersoll * information: Portions Copyright [yyyy] [name of copyright owner] 1847e946e7SWyllys Ingersoll * 1947e946e7SWyllys Ingersoll * CDDL HEADER END 2047e946e7SWyllys Ingersoll */ 2147e946e7SWyllys Ingersoll 2247e946e7SWyllys Ingersoll /* 2347e946e7SWyllys Ingersoll * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2447e946e7SWyllys Ingersoll * Use is subject to license terms. 2547e946e7SWyllys Ingersoll */ 2647e946e7SWyllys Ingersoll 2747e946e7SWyllys Ingersoll #ifndef _TPM_DDI_H 2847e946e7SWyllys Ingersoll #define _TPM_DDI_H 2947e946e7SWyllys Ingersoll 3047e946e7SWyllys Ingersoll /* Duration index is SHORT, MEDIUM, LONG, UNDEFINED */ 3147e946e7SWyllys Ingersoll #define TPM_DURATION_MAX_IDX 3 3247e946e7SWyllys Ingersoll 3347e946e7SWyllys Ingersoll /* 3447e946e7SWyllys Ingersoll * IO buffer size: this seems sufficient, but feel free to modify 3547e946e7SWyllys Ingersoll * This should be at minimum 765 3647e946e7SWyllys Ingersoll */ 3747e946e7SWyllys Ingersoll #define TPM_IO_BUF_SIZE 4096 3847e946e7SWyllys Ingersoll 3947e946e7SWyllys Ingersoll #define TPM_IO_TIMEOUT 10000000 4047e946e7SWyllys Ingersoll 4147e946e7SWyllys Ingersoll /* 4247e946e7SWyllys Ingersoll * Flags to keep track of for the allocated resources 4347e946e7SWyllys Ingersoll * so we know what to deallocate later on 4447e946e7SWyllys Ingersoll */ 4547e946e7SWyllys Ingersoll enum tpm_ddi_resources_flags { 4647e946e7SWyllys Ingersoll TPM_OPENED = 0x001, 4747e946e7SWyllys Ingersoll TPM_DIDMINOR = 0x002, 4847e946e7SWyllys Ingersoll TPM_DIDREGSMAP = 0x004, 4947e946e7SWyllys Ingersoll TPM_DIDINTMUTEX = 0x008, 5047e946e7SWyllys Ingersoll TPM_DIDINTCV = 0x010, 5147e946e7SWyllys Ingersoll TPM_DID_IO_ALLOC = 0x100, 5247e946e7SWyllys Ingersoll TPM_DID_IO_MUTEX = 0x200, 5347e946e7SWyllys Ingersoll TPM_DID_IO_CV = 0x400, 5447e946e7SWyllys Ingersoll TPM_DID_MUTEX = 0x800, 55*8d26100cSWyllys Ingersoll TPM_DID_SOFT_STATE = 0x1000, 56*8d26100cSWyllys Ingersoll #ifdef sun4v 57*8d26100cSWyllys Ingersoll TPM_HSVC_REGISTERED = 0x2000 58*8d26100cSWyllys Ingersoll #endif 5947e946e7SWyllys Ingersoll }; 6047e946e7SWyllys Ingersoll 6147e946e7SWyllys Ingersoll typedef struct tpm_state tpm_state_t; 6247e946e7SWyllys Ingersoll 6347e946e7SWyllys Ingersoll /* TPM specific data structure */ 6447e946e7SWyllys Ingersoll struct tpm_state { 6547e946e7SWyllys Ingersoll /* TPM specific */ 6647e946e7SWyllys Ingersoll TPM_CAP_VERSION_INFO vers_info; 6747e946e7SWyllys Ingersoll 6847e946e7SWyllys Ingersoll /* OS specific */ 6947e946e7SWyllys Ingersoll int instance; 7047e946e7SWyllys Ingersoll dev_info_t *dip; 7147e946e7SWyllys Ingersoll ddi_acc_handle_t handle; 7247e946e7SWyllys Ingersoll 7347e946e7SWyllys Ingersoll kmutex_t dev_lock; 7447e946e7SWyllys Ingersoll uint8_t dev_held; 7547e946e7SWyllys Ingersoll 7647e946e7SWyllys Ingersoll /* 7747e946e7SWyllys Ingersoll * For read/write 7847e946e7SWyllys Ingersoll */ 7947e946e7SWyllys Ingersoll uint8_t *iobuf; 8047e946e7SWyllys Ingersoll size_t bufsize; 8147e946e7SWyllys Ingersoll uint8_t iobuf_inuse; 8247e946e7SWyllys Ingersoll kmutex_t iobuf_lock; 8347e946e7SWyllys Ingersoll kcondvar_t iobuf_cv; 8447e946e7SWyllys Ingersoll 8547e946e7SWyllys Ingersoll /* 8647e946e7SWyllys Ingersoll * For supporting the interrupt 8747e946e7SWyllys Ingersoll */ 8847e946e7SWyllys Ingersoll uint8_t intr_enabled; 8947e946e7SWyllys Ingersoll ddi_intr_handle_t *h_array; 9047e946e7SWyllys Ingersoll uint_t intr_pri; 9147e946e7SWyllys Ingersoll unsigned int state; 9247e946e7SWyllys Ingersoll 9347e946e7SWyllys Ingersoll uint8_t *addr; /* where TPM is mapped to */ 9447e946e7SWyllys Ingersoll char locality; /* keep track of the locality */ 9547e946e7SWyllys Ingersoll 9647e946e7SWyllys Ingersoll uint32_t flags; /* flags to keep track of what is allocated */ 9747e946e7SWyllys Ingersoll clock_t duration[4]; /* short,medium,long,undefined */ 9847e946e7SWyllys Ingersoll clock_t timeout_a; 9947e946e7SWyllys Ingersoll clock_t timeout_b; 10047e946e7SWyllys Ingersoll clock_t timeout_c; 10147e946e7SWyllys Ingersoll clock_t timeout_d; 10247e946e7SWyllys Ingersoll clock_t timeout_poll; 10347e946e7SWyllys Ingersoll 10447e946e7SWyllys Ingersoll ddi_device_acc_attr_t accattr; 10547e946e7SWyllys Ingersoll 10647e946e7SWyllys Ingersoll /* For power management. */ 10747e946e7SWyllys Ingersoll kmutex_t pm_mutex; 10847e946e7SWyllys Ingersoll kcondvar_t suspend_cv; 10947e946e7SWyllys Ingersoll uint32_t suspended; 110*8d26100cSWyllys Ingersoll 111*8d26100cSWyllys Ingersoll #ifdef KCF_TPM_RNG_PROVIDER 112*8d26100cSWyllys Ingersoll /* For RNG */ 113*8d26100cSWyllys Ingersoll crypto_kcf_provider_handle_t n_prov; 114*8d26100cSWyllys Ingersoll #endif 11547e946e7SWyllys Ingersoll }; 11647e946e7SWyllys Ingersoll 11747e946e7SWyllys Ingersoll #endif /* _TPM_DDI_H */ 118