18c2ecf20Sopenharmony_ci/****************************************************************************** 28c2ecf20Sopenharmony_ci * tpmif.h 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * TPM I/O interface for Xen guest OSes, v2 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This file is in the public domain. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __XEN_PUBLIC_IO_TPMIF_H__ 118c2ecf20Sopenharmony_ci#define __XEN_PUBLIC_IO_TPMIF_H__ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Xenbus state machine 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * Device open: 178c2ecf20Sopenharmony_ci * 1. Both ends start in XenbusStateInitialising 188c2ecf20Sopenharmony_ci * 2. Backend transitions to InitWait (frontend does not wait on this step) 198c2ecf20Sopenharmony_ci * 3. Frontend populates ring-ref, event-channel, feature-protocol-v2 208c2ecf20Sopenharmony_ci * 4. Frontend transitions to Initialised 218c2ecf20Sopenharmony_ci * 5. Backend maps grant and event channel, verifies feature-protocol-v2 228c2ecf20Sopenharmony_ci * 6. Backend transitions to Connected 238c2ecf20Sopenharmony_ci * 7. Frontend verifies feature-protocol-v2, transitions to Connected 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * Device close: 268c2ecf20Sopenharmony_ci * 1. State is changed to XenbusStateClosing 278c2ecf20Sopenharmony_ci * 2. Frontend transitions to Closed 288c2ecf20Sopenharmony_ci * 3. Backend unmaps grant and event, changes state to InitWait 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cienum vtpm_shared_page_state { 328c2ecf20Sopenharmony_ci VTPM_STATE_IDLE, /* no contents / vTPM idle / cancel complete */ 338c2ecf20Sopenharmony_ci VTPM_STATE_SUBMIT, /* request ready / vTPM working */ 348c2ecf20Sopenharmony_ci VTPM_STATE_FINISH, /* response ready / vTPM idle */ 358c2ecf20Sopenharmony_ci VTPM_STATE_CANCEL, /* cancel requested / vTPM working */ 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci/* The backend should only change state to IDLE or FINISH, while the 388c2ecf20Sopenharmony_ci * frontend should only change to SUBMIT or CANCEL. */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistruct vtpm_shared_page { 428c2ecf20Sopenharmony_ci uint32_t length; /* request/response length in bytes */ 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci uint8_t state; /* enum vtpm_shared_page_state */ 458c2ecf20Sopenharmony_ci uint8_t locality; /* for the current request */ 468c2ecf20Sopenharmony_ci uint8_t pad; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci uint8_t nr_extra_pages; /* extra pages for long packets; may be zero */ 498c2ecf20Sopenharmony_ci uint32_t extra_pages[]; /* grant IDs; length in nr_extra_pages */ 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#endif 53