19126SWyllys.Ingersoll@Sun.COM /* 29126SWyllys.Ingersoll@Sun.COM * CDDL HEADER START 39126SWyllys.Ingersoll@Sun.COM * 49126SWyllys.Ingersoll@Sun.COM * The contents of this file are subject to the terms of the 59126SWyllys.Ingersoll@Sun.COM * Common Development and Distribution License (the "License"). 69126SWyllys.Ingersoll@Sun.COM * You may not use this file except in compliance with the License. 79126SWyllys.Ingersoll@Sun.COM * 89126SWyllys.Ingersoll@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99126SWyllys.Ingersoll@Sun.COM * or http://www.opensolaris.org/os/licensing. 109126SWyllys.Ingersoll@Sun.COM * See the License for the specific language governing permissions 119126SWyllys.Ingersoll@Sun.COM * and limitations under the License. 129126SWyllys.Ingersoll@Sun.COM * 139126SWyllys.Ingersoll@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 149126SWyllys.Ingersoll@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159126SWyllys.Ingersoll@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 169126SWyllys.Ingersoll@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 179126SWyllys.Ingersoll@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 189126SWyllys.Ingersoll@Sun.COM * 199126SWyllys.Ingersoll@Sun.COM * CDDL HEADER END 209126SWyllys.Ingersoll@Sun.COM */ 219126SWyllys.Ingersoll@Sun.COM 229126SWyllys.Ingersoll@Sun.COM /* 239126SWyllys.Ingersoll@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 249126SWyllys.Ingersoll@Sun.COM * Use is subject to license terms. 259126SWyllys.Ingersoll@Sun.COM */ 269126SWyllys.Ingersoll@Sun.COM 279126SWyllys.Ingersoll@Sun.COM #ifndef _TPM_DDI_H 289126SWyllys.Ingersoll@Sun.COM #define _TPM_DDI_H 299126SWyllys.Ingersoll@Sun.COM 309126SWyllys.Ingersoll@Sun.COM /* Duration index is SHORT, MEDIUM, LONG, UNDEFINED */ 319126SWyllys.Ingersoll@Sun.COM #define TPM_DURATION_MAX_IDX 3 329126SWyllys.Ingersoll@Sun.COM 339126SWyllys.Ingersoll@Sun.COM /* 349126SWyllys.Ingersoll@Sun.COM * IO buffer size: this seems sufficient, but feel free to modify 359126SWyllys.Ingersoll@Sun.COM * This should be at minimum 765 369126SWyllys.Ingersoll@Sun.COM */ 379126SWyllys.Ingersoll@Sun.COM #define TPM_IO_BUF_SIZE 4096 389126SWyllys.Ingersoll@Sun.COM 399126SWyllys.Ingersoll@Sun.COM #define TPM_IO_TIMEOUT 10000000 409126SWyllys.Ingersoll@Sun.COM 419126SWyllys.Ingersoll@Sun.COM /* 429126SWyllys.Ingersoll@Sun.COM * Flags to keep track of for the allocated resources 439126SWyllys.Ingersoll@Sun.COM * so we know what to deallocate later on 449126SWyllys.Ingersoll@Sun.COM */ 459126SWyllys.Ingersoll@Sun.COM enum tpm_ddi_resources_flags { 469126SWyllys.Ingersoll@Sun.COM TPM_OPENED = 0x001, 479126SWyllys.Ingersoll@Sun.COM TPM_DIDMINOR = 0x002, 489126SWyllys.Ingersoll@Sun.COM TPM_DIDREGSMAP = 0x004, 499126SWyllys.Ingersoll@Sun.COM TPM_DIDINTMUTEX = 0x008, 509126SWyllys.Ingersoll@Sun.COM TPM_DIDINTCV = 0x010, 519126SWyllys.Ingersoll@Sun.COM TPM_DID_IO_ALLOC = 0x100, 529126SWyllys.Ingersoll@Sun.COM TPM_DID_IO_MUTEX = 0x200, 539126SWyllys.Ingersoll@Sun.COM TPM_DID_IO_CV = 0x400, 549126SWyllys.Ingersoll@Sun.COM TPM_DID_MUTEX = 0x800, 55*10346Swyllys.ingersoll@sun.com TPM_DID_SOFT_STATE = 0x1000, 56*10346Swyllys.ingersoll@sun.com #ifdef sun4v 57*10346Swyllys.ingersoll@sun.com TPM_HSVC_REGISTERED = 0x2000 58*10346Swyllys.ingersoll@sun.com #endif 599126SWyllys.Ingersoll@Sun.COM }; 609126SWyllys.Ingersoll@Sun.COM 619126SWyllys.Ingersoll@Sun.COM typedef struct tpm_state tpm_state_t; 629126SWyllys.Ingersoll@Sun.COM 639126SWyllys.Ingersoll@Sun.COM /* TPM specific data structure */ 649126SWyllys.Ingersoll@Sun.COM struct tpm_state { 659126SWyllys.Ingersoll@Sun.COM /* TPM specific */ 669126SWyllys.Ingersoll@Sun.COM TPM_CAP_VERSION_INFO vers_info; 679126SWyllys.Ingersoll@Sun.COM 689126SWyllys.Ingersoll@Sun.COM /* OS specific */ 699126SWyllys.Ingersoll@Sun.COM int instance; 709126SWyllys.Ingersoll@Sun.COM dev_info_t *dip; 719126SWyllys.Ingersoll@Sun.COM ddi_acc_handle_t handle; 729126SWyllys.Ingersoll@Sun.COM 739126SWyllys.Ingersoll@Sun.COM kmutex_t dev_lock; 749126SWyllys.Ingersoll@Sun.COM uint8_t dev_held; 759126SWyllys.Ingersoll@Sun.COM 769126SWyllys.Ingersoll@Sun.COM /* 779126SWyllys.Ingersoll@Sun.COM * For read/write 789126SWyllys.Ingersoll@Sun.COM */ 799126SWyllys.Ingersoll@Sun.COM uint8_t *iobuf; 809126SWyllys.Ingersoll@Sun.COM size_t bufsize; 819126SWyllys.Ingersoll@Sun.COM uint8_t iobuf_inuse; 829126SWyllys.Ingersoll@Sun.COM kmutex_t iobuf_lock; 839126SWyllys.Ingersoll@Sun.COM kcondvar_t iobuf_cv; 849126SWyllys.Ingersoll@Sun.COM 859126SWyllys.Ingersoll@Sun.COM /* 869126SWyllys.Ingersoll@Sun.COM * For supporting the interrupt 879126SWyllys.Ingersoll@Sun.COM */ 889126SWyllys.Ingersoll@Sun.COM uint8_t intr_enabled; 899126SWyllys.Ingersoll@Sun.COM ddi_intr_handle_t *h_array; 909126SWyllys.Ingersoll@Sun.COM uint_t intr_pri; 919126SWyllys.Ingersoll@Sun.COM unsigned int state; 929126SWyllys.Ingersoll@Sun.COM 939126SWyllys.Ingersoll@Sun.COM uint8_t *addr; /* where TPM is mapped to */ 949126SWyllys.Ingersoll@Sun.COM char locality; /* keep track of the locality */ 959126SWyllys.Ingersoll@Sun.COM 969126SWyllys.Ingersoll@Sun.COM uint32_t flags; /* flags to keep track of what is allocated */ 979126SWyllys.Ingersoll@Sun.COM clock_t duration[4]; /* short,medium,long,undefined */ 989126SWyllys.Ingersoll@Sun.COM clock_t timeout_a; 999126SWyllys.Ingersoll@Sun.COM clock_t timeout_b; 1009126SWyllys.Ingersoll@Sun.COM clock_t timeout_c; 1019126SWyllys.Ingersoll@Sun.COM clock_t timeout_d; 1029126SWyllys.Ingersoll@Sun.COM clock_t timeout_poll; 1039126SWyllys.Ingersoll@Sun.COM 1049126SWyllys.Ingersoll@Sun.COM ddi_device_acc_attr_t accattr; 1059126SWyllys.Ingersoll@Sun.COM 1069126SWyllys.Ingersoll@Sun.COM /* For power management. */ 1079126SWyllys.Ingersoll@Sun.COM kmutex_t pm_mutex; 1089126SWyllys.Ingersoll@Sun.COM kcondvar_t suspend_cv; 1099126SWyllys.Ingersoll@Sun.COM uint32_t suspended; 110*10346Swyllys.ingersoll@sun.com 111*10346Swyllys.ingersoll@sun.com #ifdef KCF_TPM_RNG_PROVIDER 112*10346Swyllys.ingersoll@sun.com /* For RNG */ 113*10346Swyllys.ingersoll@sun.com crypto_kcf_provider_handle_t n_prov; 114*10346Swyllys.ingersoll@sun.com #endif 1159126SWyllys.Ingersoll@Sun.COM }; 1169126SWyllys.Ingersoll@Sun.COM 1179126SWyllys.Ingersoll@Sun.COM #endif /* _TPM_DDI_H */ 118