tpm_ibmvtpm.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) 2012 IBM Corporation
  3. *
  4. * Author: Ashley Lai <ashleydlai@gmail.com>
  5. *
  6. * Maintained by: <tpmdd-devel@lists.sourceforge.net>
  7. *
  8. * Device driver for TCG/TCPA TPM (trusted platform module).
  9. * Specifications at www.trustedcomputinggroup.org
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation, version 2 of the
  14. * License.
  15. *
  16. */
  17. #ifndef __TPM_IBMVTPM_H__
  18. #define __TPM_IBMVTPM_H__
  19. /* vTPM Message Format 1 */
  20. struct ibmvtpm_crq {
  21. u8 valid;
  22. u8 msg;
  23. __be16 len;
  24. __be32 data;
  25. __be64 reserved;
  26. } __attribute__((packed, aligned(8)));
  27. struct ibmvtpm_crq_queue {
  28. struct ibmvtpm_crq *crq_addr;
  29. u32 index;
  30. u32 num_entry;
  31. };
  32. struct ibmvtpm_dev {
  33. struct device *dev;
  34. struct vio_dev *vdev;
  35. struct ibmvtpm_crq_queue crq_queue;
  36. dma_addr_t crq_dma_handle;
  37. u32 rtce_size;
  38. void __iomem *rtce_buf;
  39. dma_addr_t rtce_dma_handle;
  40. spinlock_t rtce_lock;
  41. wait_queue_head_t wq;
  42. u16 res_len;
  43. u32 vtpm_version;
  44. };
  45. #define CRQ_RES_BUF_SIZE PAGE_SIZE
  46. /* Initialize CRQ */
  47. #define INIT_CRQ_CMD 0xC001000000000000LL /* Init cmd */
  48. #define INIT_CRQ_COMP_CMD 0xC002000000000000LL /* Init complete cmd */
  49. #define INIT_CRQ_RES 0x01 /* Init respond */
  50. #define INIT_CRQ_COMP_RES 0x02 /* Init complete respond */
  51. #define VALID_INIT_CRQ 0xC0 /* Valid command for init crq */
  52. /* vTPM CRQ response is the message type | 0x80 */
  53. #define VTPM_MSG_RES 0x80
  54. #define IBMVTPM_VALID_CMD 0x80
  55. /* vTPM CRQ message types */
  56. #define VTPM_GET_VERSION 0x01
  57. #define VTPM_GET_VERSION_RES (0x01 | VTPM_MSG_RES)
  58. #define VTPM_TPM_COMMAND 0x02
  59. #define VTPM_TPM_COMMAND_RES (0x02 | VTPM_MSG_RES)
  60. #define VTPM_GET_RTCE_BUFFER_SIZE 0x03
  61. #define VTPM_GET_RTCE_BUFFER_SIZE_RES (0x03 | VTPM_MSG_RES)
  62. #define VTPM_PREPARE_TO_SUSPEND 0x04
  63. #define VTPM_PREPARE_TO_SUSPEND_RES (0x04 | VTPM_MSG_RES)
  64. #endif