aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-11-06 19:39:15 +0100
committerStefan Berger <stefanb@linux.vnet.ibm.com>2017-12-14 23:39:14 -0500
commit3dfd5a2a50fc4907728eb83569c84b0d98b56582 (patch)
tree5dcf1dfc3bdba85f8e19686849176e3dddaa8651
parentd36e7db1fbf1a5cff4aa359dfe5c2e5dd97d3e13 (diff)
tpm: lookup the the TPM interface instead of TIS device
This will allow to introduce new devices implementing TPM. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
-rw-r--r--hw/i386/acpi-build.c2
-rw-r--r--include/sysemu/tpm.h25
2 files changed, 16 insertions, 11 deletions
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 73519ab3ac..cdb4aa9835 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -208,7 +208,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
}
info->has_hpet = hpet_find();
- info->tpm_version = tpm_get_version();
+ info->tpm_version = tpm_get_version(tpm_find());
info->pvpanic_port = pvpanic_port();
info->applesmc_io_base = applesmc_port();
}
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index 7b407caf25..2fe0f1e120 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -19,7 +19,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);
int tpm_init(void);
void tpm_cleanup(void);
-typedef enum TPMVersion {
+typedef enum TPMVersion {
TPM_VERSION_UNSPEC = 0,
TPM_VERSION_1_2 = 1,
TPM_VERSION_2_0 = 2,
@@ -44,20 +44,25 @@ typedef struct TPMIfClass {
void (*request_completed)(TPMIf *obj);
} TPMIfClass;
-TPMVersion tpm_tis_get_tpm_version(Object *obj);
-
#define TYPE_TPM_TIS "tpm-tis"
-static inline TPMVersion tpm_get_version(void)
+/* returns NULL unless there is exactly one TPM device */
+static inline TPMIf *tpm_find(void)
{
-#ifdef CONFIG_TPM
- Object *obj = object_resolve_path_type("", TYPE_TPM_TIS, NULL);
+ Object *obj = object_resolve_path_type("", TYPE_TPM_IF, NULL);
+
+ return TPM_IF(obj);
+}
- if (obj) {
- return tpm_tis_get_tpm_version(obj);
+TPMVersion tpm_tis_get_tpm_version(Object *obj);
+
+static inline TPMVersion tpm_get_version(TPMIf *ti)
+{
+ if (!ti) {
+ return TPM_VERSION_UNSPEC;
}
-#endif
- return TPM_VERSION_UNSPEC;
+
+ return tpm_tis_get_tpm_version(OBJECT(ti));
}
#endif /* QEMU_TPM_H */