^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * tpmif.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * TPM I/O interface for Xen guest OSes, v2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * This file is in the public domain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef __XEN_PUBLIC_IO_TPMIF_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define __XEN_PUBLIC_IO_TPMIF_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Xenbus state machine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Device open:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * 1. Both ends start in XenbusStateInitialising
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * 2. Backend transitions to InitWait (frontend does not wait on this step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * 3. Frontend populates ring-ref, event-channel, feature-protocol-v2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * 4. Frontend transitions to Initialised
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * 5. Backend maps grant and event channel, verifies feature-protocol-v2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * 6. Backend transitions to Connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * 7. Frontend verifies feature-protocol-v2, transitions to Connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * Device close:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * 1. State is changed to XenbusStateClosing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * 2. Frontend transitions to Closed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * 3. Backend unmaps grant and event, changes state to InitWait
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) enum vtpm_shared_page_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) VTPM_STATE_IDLE, /* no contents / vTPM idle / cancel complete */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) VTPM_STATE_SUBMIT, /* request ready / vTPM working */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) VTPM_STATE_FINISH, /* response ready / vTPM idle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) VTPM_STATE_CANCEL, /* cancel requested / vTPM working */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* The backend should only change state to IDLE or FINISH, while the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * frontend should only change to SUBMIT or CANCEL. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct vtpm_shared_page {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) uint32_t length; /* request/response length in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) uint8_t state; /* enum vtpm_shared_page_state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) uint8_t locality; /* for the current request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) uint8_t pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) uint8_t nr_extra_pages; /* extra pages for long packets; may be zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) uint32_t extra_pages[]; /* grant IDs; length in nr_extra_pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #endif