]>
Commit | Line | Data |
---|---|---|
d1a0cf73 SB |
1 | /* |
2 | * Public TPM functions | |
3 | * | |
4 | * Copyright (C) 2011-2013 IBM Corporation | |
5 | * | |
6 | * Authors: | |
7 | * Stefan Berger <stefanb@us.ibm.com> | |
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 QEMU_TPM_H | |
13 | #define QEMU_TPM_H | |
14 | ||
9af23989 | 15 | #include "qapi/qapi-types-tpm.h" |
6b287efe | 16 | #include "qom/object.h" |
d1a0cf73 SB |
17 | |
18 | int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); | |
d64072c0 | 19 | int tpm_init(void); |
d1a0cf73 SB |
20 | void tpm_cleanup(void); |
21 | ||
3dfd5a2a | 22 | typedef enum TPMVersion { |
116694c3 SB |
23 | TPM_VERSION_UNSPEC = 0, |
24 | TPM_VERSION_1_2 = 1, | |
25 | TPM_VERSION_2_0 = 2, | |
26 | } TPMVersion; | |
27 | ||
67af320c MAL |
28 | #define TYPE_TPM_IF "tpm-if" |
29 | #define TPM_IF_CLASS(klass) \ | |
30 | OBJECT_CLASS_CHECK(TPMIfClass, (klass), TYPE_TPM_IF) | |
31 | #define TPM_IF_GET_CLASS(obj) \ | |
32 | OBJECT_GET_CLASS(TPMIfClass, (obj), TYPE_TPM_IF) | |
33 | #define TPM_IF(obj) \ | |
34 | INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF) | |
35 | ||
aa1b35b9 | 36 | typedef struct TPMIf TPMIf; |
67af320c MAL |
37 | |
38 | typedef struct TPMIfClass { | |
39 | InterfaceClass parent_class; | |
40 | ||
191adc94 | 41 | enum TpmModel model; |
6a8a2354 | 42 | void (*request_completed)(TPMIf *obj, int ret); |
9af7a721 | 43 | enum TPMVersion (*get_version)(TPMIf *obj); |
67af320c MAL |
44 | } TPMIfClass; |
45 | ||
43bc7f84 | 46 | #define TYPE_TPM_TIS_ISA "tpm-tis" |
229de57a | 47 | #define TYPE_TPM_TIS_SYSBUS "tpm-tis-device" |
4ab6cb4c | 48 | #define TYPE_TPM_CRB "tpm-crb" |
3676bc69 | 49 | #define TYPE_TPM_SPAPR "tpm-spapr" |
711b20b4 | 50 | |
43bc7f84 EA |
51 | #define TPM_IS_TIS_ISA(chr) \ |
52 | object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS_ISA) | |
80bde693 EA |
53 | #define TPM_IS_TIS_SYSBUS(chr) \ |
54 | object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS_SYSBUS) | |
4ab6cb4c MAL |
55 | #define TPM_IS_CRB(chr) \ |
56 | object_dynamic_cast(OBJECT(chr), TYPE_TPM_CRB) | |
3676bc69 SB |
57 | #define TPM_IS_SPAPR(chr) \ |
58 | object_dynamic_cast(OBJECT(chr), TYPE_TPM_SPAPR) | |
ff5ce21e | 59 | |
3dfd5a2a MAL |
60 | /* returns NULL unless there is exactly one TPM device */ |
61 | static inline TPMIf *tpm_find(void) | |
711b20b4 | 62 | { |
3dfd5a2a MAL |
63 | Object *obj = object_resolve_path_type("", TYPE_TPM_IF, NULL); |
64 | ||
65 | return TPM_IF(obj); | |
66 | } | |
5cb18b3d | 67 | |
3dfd5a2a MAL |
68 | static inline TPMVersion tpm_get_version(TPMIf *ti) |
69 | { | |
70 | if (!ti) { | |
71 | return TPM_VERSION_UNSPEC; | |
5cb18b3d | 72 | } |
3dfd5a2a | 73 | |
9af7a721 | 74 | return TPM_IF_GET_CLASS(ti)->get_version(ti); |
711b20b4 SB |
75 | } |
76 | ||
d1a0cf73 | 77 | #endif /* QEMU_TPM_H */ |