tpm_tis.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * tpm_tis.h - QEMU's TPM TIS common header
  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. * Xen 4 support: Andrease Niederl <andreas.niederl@iaik.tugraz.at>
  11. *
  12. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  13. * See the COPYING file in the top-level directory.
  14. *
  15. * Implementation of the TIS interface according to specs found at
  16. * http://www.trustedcomputinggroup.org. This implementation currently
  17. * supports version 1.3, 21 March 2013
  18. * In the developers menu choose the PC Client section then find the TIS
  19. * specification.
  20. *
  21. * TPM TIS for TPM 2 implementation following TCG PC Client Platform
  22. * TPM Profile (PTP) Specification, Family 2.0, Revision 00.43
  23. */
  24. #ifndef TPM_TPM_TIS_H
  25. #define TPM_TPM_TIS_H
  26. #include "system/tpm_backend.h"
  27. #include "tpm_ppi.h"
  28. #define TPM_TIS_NUM_LOCALITIES 5 /* per spec */
  29. #define TPM_TIS_LOCALITY_SHIFT 12
  30. #define TPM_TIS_NO_LOCALITY 0xff
  31. #define TPM_TIS_IS_VALID_LOCTY(x) ((x) < TPM_TIS_NUM_LOCALITIES)
  32. #define TPM_TIS_BUFFER_MAX 4096
  33. typedef enum {
  34. TPM_TIS_STATE_IDLE = 0,
  35. TPM_TIS_STATE_READY,
  36. TPM_TIS_STATE_COMPLETION,
  37. TPM_TIS_STATE_EXECUTION,
  38. TPM_TIS_STATE_RECEPTION,
  39. } TPMTISState;
  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 iface_id;
  46. uint32_t inte;
  47. uint32_t ints;
  48. } TPMLocality;
  49. typedef struct TPMState {
  50. MemoryRegion mmio;
  51. unsigned char buffer[TPM_TIS_BUFFER_MAX];
  52. uint16_t rw_offset;
  53. uint8_t active_locty;
  54. uint8_t aborting_locty;
  55. uint8_t next_locty;
  56. TPMLocality loc[TPM_TIS_NUM_LOCALITIES];
  57. qemu_irq irq;
  58. uint32_t irq_num;
  59. TPMBackendCmd cmd;
  60. TPMBackend *be_driver;
  61. TPMVersion be_tpm_version;
  62. size_t be_buffer_size;
  63. bool ppi_enabled;
  64. TPMPPI ppi;
  65. } TPMState;
  66. extern const VMStateDescription vmstate_locty;
  67. extern const MemoryRegionOps tpm_tis_memory_ops;
  68. int tpm_tis_pre_save(TPMState *s);
  69. void tpm_tis_reset(TPMState *s);
  70. enum TPMVersion tpm_tis_get_tpm_version(TPMState *s);
  71. void tpm_tis_request_completed(TPMState *s, int ret);
  72. uint32_t tpm_tis_read_data(TPMState *s, hwaddr addr, unsigned size);
  73. void tpm_tis_write_data(TPMState *s, hwaddr addr, uint64_t val, uint32_t size);
  74. uint16_t tpm_tis_get_checksum(TPMState *s);
  75. #endif /* TPM_TPM_TIS_H */