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"
20 int tpm_config_parse(QemuOptsList
*opts_list
, const char *optstr
);
22 void tpm_cleanup(void);
24 typedef enum TPMVersion
{
25 TPM_VERSION_UNSPEC
= 0,
30 #define TYPE_TPM_IF "tpm-if"
31 typedef struct TPMIfClass TPMIfClass
;
32 DECLARE_CLASS_CHECKERS(TPMIfClass
, TPM_IF
,
35 INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
37 typedef struct TPMIf TPMIf
;
40 InterfaceClass parent_class
;
43 void (*request_completed
)(TPMIf
*obj
, int ret
);
44 enum TPMVersion (*get_version
)(TPMIf
*obj
);
47 #define TYPE_TPM_TIS_ISA "tpm-tis"
48 #define TYPE_TPM_TIS_SYSBUS "tpm-tis-device"
49 #define TYPE_TPM_CRB "tpm-crb"
50 #define TYPE_TPM_SPAPR "tpm-spapr"
51 #define TYPE_TPM_TIS_I2C "tpm-tis-i2c"
53 #define TPM_IS_TIS_ISA(chr) \
54 object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS_ISA)
55 #define TPM_IS_TIS_SYSBUS(chr) \
56 object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS_SYSBUS)
57 #define TPM_IS_CRB(chr) \
58 object_dynamic_cast(OBJECT(chr), TYPE_TPM_CRB)
59 #define TPM_IS_SPAPR(chr) \
60 object_dynamic_cast(OBJECT(chr), TYPE_TPM_SPAPR)
61 #define TPM_IS_TIS_I2C(chr) \
62 object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS_I2C)
64 /* returns NULL unless there is exactly one TPM device */
65 static inline TPMIf
*tpm_find(void)
67 Object
*obj
= object_resolve_path_type("", TYPE_TPM_IF
, NULL
);
72 static inline TPMVersion
tpm_get_version(TPMIf
*ti
)
75 return TPM_VERSION_UNSPEC
;
78 return TPM_IF_GET_CLASS(ti
)->get_version(ti
);
81 #else /* CONFIG_TPM */
83 #define tpm_init() (0)
86 /* needed for an alignment check in non-tpm code */
87 static inline Object
*TPM_IS_CRB(Object
*obj
)
92 #endif /* CONFIG_TPM */
94 #endif /* QEMU_TPM_H */