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