]> git.proxmox.com Git - qemu.git/blame - tpm/tpm_backend.c
configure: fix TPM logic
[qemu.git] / tpm / tpm_backend.c
CommitLineData
4549a8b7
SB
1/*
2 * common TPM backend driver functions
3 *
4 * Copyright (c) 2012-2013 IBM Corporation
5 * Authors:
6 * Stefan Berger <stefanb@us.ibm.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, see <http://www.gnu.org/licenses/>
20 */
21
22#include "tpm/tpm.h"
23#include "qemu/thread.h"
24#include "tpm_backend.h"
25
26void tpm_backend_thread_deliver_request(TPMBackendThread *tbt)
27{
28 g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_PROCESS_CMD, NULL);
29}
30
31void tpm_backend_thread_create(TPMBackendThread *tbt,
32 GFunc func, gpointer user_data)
33{
34 if (!tbt->pool) {
35 tbt->pool = g_thread_pool_new(func, user_data, 1, TRUE, NULL);
36 g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_INIT, NULL);
37 }
38}
39
40void tpm_backend_thread_end(TPMBackendThread *tbt)
41{
42 if (tbt->pool) {
43 g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_END, NULL);
44 g_thread_pool_free(tbt->pool, FALSE, TRUE);
45 tbt->pool = NULL;
46 }
47}
48
49void tpm_backend_thread_tpm_reset(TPMBackendThread *tbt,
50 GFunc func, gpointer user_data)
51{
52 if (!tbt->pool) {
53 tpm_backend_thread_create(tbt, func, user_data);
54 } else {
55 g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_TPM_RESET,
56 NULL);
57 }
58}