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