4 * Copyright (C) 2011-2013 IBM Corporation
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.
15 #include "qapi/qapi-types-tpm.h"
16 #include "qom/object.h"
18 int tpm_config_parse(QemuOptsList
*opts_list
, const char *optarg
);
20 void tpm_cleanup(void);
22 typedef enum TPMVersion
{
23 TPM_VERSION_UNSPEC
= 0,
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)
34 INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
36 typedef struct TPMIf
{
40 typedef struct TPMIfClass
{
41 InterfaceClass parent_class
;
44 void (*request_completed
)(TPMIf
*obj
, int ret
);
45 enum TPMVersion (*get_version
)(TPMIf
*obj
);
48 #define TYPE_TPM_TIS "tpm-tis"
49 #define TYPE_TPM_CRB "tpm-crb"
51 #define TPM_IS_TIS(chr) \
52 object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS)
53 #define TPM_IS_CRB(chr) \
54 object_dynamic_cast(OBJECT(chr), TYPE_TPM_CRB)
56 /* returns NULL unless there is exactly one TPM device */
57 static inline TPMIf
*tpm_find(void)
59 Object
*obj
= object_resolve_path_type("", TYPE_TPM_IF
, NULL
);
64 static inline TPMVersion
tpm_get_version(TPMIf
*ti
)
67 return TPM_VERSION_UNSPEC
;
70 return TPM_IF_GET_CLASS(ti
)->get_version(ti
);
73 #endif /* QEMU_TPM_H */