1 /* 2 * tpm_tis.h - QEMU's TPM TIS interface emulator 3 * 4 * Copyright (C) 2006, 2010-2013 IBM Corporation 5 * 6 * Authors: 7 * Stefan Berger <stefanb@us.ibm.com> 8 * David Safford <safford@us.ibm.com> 9 * 10 * This work is licensed under the terms of the GNU GPL, version 2 or later. 11 * See the COPYING file in the top-level directory. 12 * 13 * Implementation of the TIS interface according to specs found at 14 * http://www.trustedcomputinggroup.org 15 * 16 */ 17 #ifndef TPM_TPM_TIS_H 18 #define TPM_TPM_TIS_H 19 20 #include "hw/isa/isa.h" 21 #include "hw/acpi/tpm.h" 22 #include "qemu-common.h" 23 24 #define TPM_TIS_NUM_LOCALITIES 5 /* per spec */ 25 #define TPM_TIS_LOCALITY_SHIFT 12 26 #define TPM_TIS_NO_LOCALITY 0xff 27 28 #define TPM_TIS_IS_VALID_LOCTY(x) ((x) < TPM_TIS_NUM_LOCALITIES) 29 30 #define TPM_TIS_BUFFER_MAX 4096 31 32 typedef enum { 33 TPM_TIS_STATE_IDLE = 0, 34 TPM_TIS_STATE_READY, 35 TPM_TIS_STATE_COMPLETION, 36 TPM_TIS_STATE_EXECUTION, 37 TPM_TIS_STATE_RECEPTION, 38 } TPMTISState; 39 40 /* locality data -- all fields are persisted */ 41 typedef struct TPMLocality { 42 TPMTISState state; 43 uint8_t access; 44 uint32_t sts; 45 uint32_t inte; 46 uint32_t ints; 47 48 uint16_t w_offset; 49 uint16_t r_offset; 50 TPMSizedBuffer w_buffer; 51 TPMSizedBuffer r_buffer; 52 } TPMLocality; 53 54 typedef struct TPMTISEmuState { 55 QEMUBH *bh; 56 uint32_t offset; 57 uint8_t buf[TPM_TIS_BUFFER_MAX]; 58 59 uint8_t active_locty; 60 uint8_t aborting_locty; 61 uint8_t next_locty; 62 63 TPMLocality loc[TPM_TIS_NUM_LOCALITIES]; 64 65 qemu_irq irq; 66 uint32_t irq_num; 67 } TPMTISEmuState; 68 69 #endif /* TPM_TPM_TIS_H */ 70