diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-04-02 18:28:41 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2013-04-15 18:19:25 +0200 |
commit | bdee56f5466a724f043e6cfcfcf69866cc48cc94 (patch) | |
tree | 342c4de4d6e553b4116860489f671fdba7fd950c /backends | |
parent | 3b8acc11d3f60792f9f716f2a93c258e729af980 (diff) |
tpm: reorganize headers and split hardware part
The TPM subsystem does not have a full front-end/back-end separation.
The sole available backend, tpm_passthrough, depends on the data
structures of the sole available frontend, tpm_tis.
However, we can at least try to split the user interface (tpm.c) from the
implementation (hw/tpm). The patches makes tpm.c not include tpm_int.h,
which is shared between tpm_tis.c and tpm_passthrough.c; instead it
moves more stuff to tpm_backend.h.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'backends')
-rw-r--r-- | backends/tpm.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/backends/tpm.c b/backends/tpm.c index 28148c23c..0580108c5 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -13,8 +13,10 @@ */ #include "backends/tpm.h" -#include "tpm/tpm_int.h" #include "qapi/qmp/qerror.h" +#include "sysemu/tpm.h" +#include "qemu/thread.h" +#include "sysemu/tpm_backend_int.h" enum TpmType tpm_backend_get_type(TPMBackend *s) { @@ -137,6 +139,40 @@ static void tpm_backend_instance_init(Object *obj) NULL); } +void tpm_backend_thread_deliver_request(TPMBackendThread *tbt) +{ + g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_PROCESS_CMD, NULL); +} + +void tpm_backend_thread_create(TPMBackendThread *tbt, + GFunc func, gpointer user_data) +{ + if (!tbt->pool) { + tbt->pool = g_thread_pool_new(func, user_data, 1, TRUE, NULL); + g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_INIT, NULL); + } +} + +void tpm_backend_thread_end(TPMBackendThread *tbt) +{ + if (tbt->pool) { + g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_END, NULL); + g_thread_pool_free(tbt->pool, FALSE, TRUE); + tbt->pool = NULL; + } +} + +void tpm_backend_thread_tpm_reset(TPMBackendThread *tbt, + GFunc func, gpointer user_data) +{ + if (!tbt->pool) { + tpm_backend_thread_create(tbt, func, user_data); + } else { + g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_TPM_RESET, + NULL); + } +} + static const TypeInfo tpm_backend_info = { .name = TYPE_TPM_BACKEND, .parent = TYPE_OBJECT, |