]> Git Repo - qemu.git/blob - tpm/tpm_int.h
QOM-ify the TPM support
[qemu.git] / tpm / tpm_int.h
1 /*
2  * TPM configuration
3  *
4  * Copyright (C) 2011-2013 IBM Corporation
5  *
6  * Authors:
7  *  Stefan Berger    <[email protected]>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2 or later.
10  * See the COPYING file in the top-level directory.
11  */
12 #ifndef TPM_TPM_INT_H
13 #define TPM_TPM_INT_H
14
15 #include "exec/memory.h"
16 #include "tpm/tpm_tis.h"
17
18 struct TPMDriverOps;
19 typedef struct TPMDriverOps TPMDriverOps;
20
21 /* overall state of the TPM interface */
22 typedef struct TPMState {
23     ISADevice busdev;
24     MemoryRegion mmio;
25
26     union {
27         TPMTISEmuState tis;
28     } s;
29
30     uint8_t     locty_number;
31     TPMLocality *locty_data;
32
33     char *backend;
34     TPMBackend *be_driver;
35 } TPMState;
36
37 #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
38
39 typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty);
40
41 struct TPMDriverOps {
42     enum TpmType type;
43     /* get a descriptive text of the backend to display to the user */
44     const char *(*desc)(void);
45
46     TPMBackend *(*create)(QemuOpts *opts, const char *id);
47     void (*destroy)(TPMBackend *t);
48
49     /* initialize the backend */
50     int (*init)(TPMBackend *t, TPMState *s, TPMRecvDataCB *datacb);
51     /* start up the TPM on the backend */
52     int (*startup_tpm)(TPMBackend *t);
53     /* returns true if nothing will ever answer TPM requests */
54     bool (*had_startup_error)(TPMBackend *t);
55
56     size_t (*realloc_buffer)(TPMSizedBuffer *sb);
57
58     void (*deliver_request)(TPMBackend *t);
59
60     void (*reset)(TPMBackend *t);
61
62     void (*cancel_cmd)(TPMBackend *t);
63
64     bool (*get_tpm_established_flag)(TPMBackend *t);
65 };
66
67 struct tpm_req_hdr {
68     uint16_t tag;
69     uint32_t len;
70     uint32_t ordinal;
71 } QEMU_PACKED;
72
73 struct tpm_resp_hdr {
74     uint16_t tag;
75     uint32_t len;
76     uint32_t errcode;
77 } QEMU_PACKED;
78
79 #define TPM_TAG_RQU_COMMAND       0xc1
80 #define TPM_TAG_RQU_AUTH1_COMMAND 0xc2
81 #define TPM_TAG_RQU_AUTH2_COMMAND 0xc3
82
83 #define TPM_TAG_RSP_COMMAND       0xc4
84 #define TPM_TAG_RSP_AUTH1_COMMAND 0xc5
85 #define TPM_TAG_RSP_AUTH2_COMMAND 0xc6
86
87 #define TPM_FAIL                  9
88
89 #define TPM_ORD_GetTicks          0xf1
90
91 TPMBackend *qemu_find_tpm(const char *id);
92 int tpm_register_model(enum TpmModel model);
93 int tpm_register_driver(const TPMDriverOps *tdo);
94 void tpm_display_backend_drivers(void);
95 const TPMDriverOps *tpm_get_backend_driver(const char *type);
96 void tpm_write_fatal_error_response(uint8_t *out, uint32_t out_len);
97
98 extern const TPMDriverOps tpm_passthrough_driver;
99
100 #endif /* TPM_TPM_INT_H */
This page took 0.030701 seconds and 4 git commands to generate.