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