spapr, xics, xive: Match signatures for XICS and XIVE KVM connect routines
[qemu/ar7.git] / include / sysemu / tpm.h
blob5b541a71c872b6164cb8605d20626d97d5118925
1 /*
2 * Public TPM functions
4 * Copyright (C) 2011-2013 IBM Corporation
6 * Authors:
7 * Stefan Berger <stefanb@us.ibm.com>
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.
12 #ifndef QEMU_TPM_H
13 #define QEMU_TPM_H
15 #include "qapi/qapi-types-tpm.h"
16 #include "qom/object.h"
18 int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);
19 void tpm_init(void);
20 void tpm_cleanup(void);
22 typedef enum TPMVersion {
23 TPM_VERSION_UNSPEC = 0,
24 TPM_VERSION_1_2 = 1,
25 TPM_VERSION_2_0 = 2,
26 } TPMVersion;
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)
36 typedef struct TPMIf TPMIf;
38 typedef struct TPMIfClass {
39 InterfaceClass parent_class;
41 enum TpmModel model;
42 void (*request_completed)(TPMIf *obj, int ret);
43 enum TPMVersion (*get_version)(TPMIf *obj);
44 } TPMIfClass;
46 #define TYPE_TPM_TIS "tpm-tis"
47 #define TYPE_TPM_CRB "tpm-crb"
49 #define TPM_IS_TIS(chr) \
50 object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS)
51 #define TPM_IS_CRB(chr) \
52 object_dynamic_cast(OBJECT(chr), TYPE_TPM_CRB)
54 /* returns NULL unless there is exactly one TPM device */
55 static inline TPMIf *tpm_find(void)
57 Object *obj = object_resolve_path_type("", TYPE_TPM_IF, NULL);
59 return TPM_IF(obj);
62 static inline TPMVersion tpm_get_version(TPMIf *ti)
64 if (!ti) {
65 return TPM_VERSION_UNSPEC;
68 return TPM_IF_GET_CLASS(ti)->get_version(ti);
71 #endif /* QEMU_TPM_H */