tpm_crb.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * tpm_crb.h - QEMU's TPM CRB interface emulator
  3. *
  4. * Copyright (c) 2018 Red Hat, Inc.
  5. *
  6. * Authors:
  7. * Marc-André Lureau <marcandre.lureau@redhat.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. *
  12. * tpm_crb is a device for TPM 2.0 Command Response Buffer (CRB) Interface
  13. * as defined in TCG PC Client Platform TPM Profile (PTP) Specification
  14. * Family “2.0” Level 00 Revision 01.03 v22
  15. */
  16. #ifndef TPM_TPM_CRB_H
  17. #define TPM_TPM_CRB_H
  18. #include "exec/memory.h"
  19. #include "hw/acpi/tpm.h"
  20. #include "system/tpm_backend.h"
  21. #include "tpm_ppi.h"
  22. #define CRB_CTRL_CMD_SIZE (TPM_CRB_ADDR_SIZE - A_CRB_DATA_BUFFER)
  23. typedef struct TPMCRBState {
  24. TPMBackend *tpmbe;
  25. TPMBackendCmd cmd;
  26. MemoryRegion mmio;
  27. size_t be_buffer_size;
  28. bool ppi_enabled;
  29. TPMPPI ppi;
  30. } TPMCRBState;
  31. #define CRB_INTF_TYPE_CRB_ACTIVE 0b1
  32. #define CRB_INTF_VERSION_CRB 0b1
  33. #define CRB_INTF_CAP_LOCALITY_0_ONLY 0b0
  34. #define CRB_INTF_CAP_IDLE_FAST 0b0
  35. #define CRB_INTF_CAP_XFER_SIZE_64 0b11
  36. #define CRB_INTF_CAP_FIFO_NOT_SUPPORTED 0b0
  37. #define CRB_INTF_CAP_CRB_SUPPORTED 0b1
  38. #define CRB_INTF_IF_SELECTOR_CRB 0b1
  39. enum crb_loc_ctrl {
  40. CRB_LOC_CTRL_REQUEST_ACCESS = BIT(0),
  41. CRB_LOC_CTRL_RELINQUISH = BIT(1),
  42. CRB_LOC_CTRL_SEIZE = BIT(2),
  43. CRB_LOC_CTRL_RESET_ESTABLISHMENT_BIT = BIT(3),
  44. };
  45. enum crb_ctrl_req {
  46. CRB_CTRL_REQ_CMD_READY = BIT(0),
  47. CRB_CTRL_REQ_GO_IDLE = BIT(1),
  48. };
  49. enum crb_start {
  50. CRB_START_INVOKE = BIT(0),
  51. };
  52. enum crb_cancel {
  53. CRB_CANCEL_INVOKE = BIT(0),
  54. };
  55. #define TPM_CRB_NO_LOCALITY 0xff
  56. void tpm_crb_request_completed(TPMCRBState *s, int ret);
  57. enum TPMVersion tpm_crb_get_version(TPMCRBState *s);
  58. int tpm_crb_pre_save(TPMCRBState *s);
  59. void tpm_crb_reset(TPMCRBState *s, uint64_t baseaddr);
  60. void tpm_crb_init_memory(Object *obj, TPMCRBState *s, Error **errp);
  61. void tpm_crb_mem_save(TPMCRBState *s, uint32_t *saved_regs, void *saved_cmdmem);
  62. void tpm_crb_mem_load(TPMCRBState *s, const uint32_t *saved_regs,
  63. const void *saved_cmdmem);
  64. void tpm_crb_build_aml(TPMIf *ti, Aml *scope, uint32_t baseaddr, uint32_t size,
  65. bool build_ppi);
  66. #endif /* TPM_TPM_CRB_H */