blob: a4f1d6422695ec7633b264ca6d27412bdc2ce940 [file] [log] [blame]
Stefan Berger0e6ca952018-02-15 08:53:56 -05001/*
2 * Minimal TPM emulator for TPM test cases
3 *
4 * Copyright (c) 2018 Red Hat, Inc.
5 *
6 * Authors:
7 * Marc-André Lureau <marcandre.lureau@redhat.com>
8 *
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.
11 */
12
13#ifndef TESTS_TPM_EMU_H
14#define TESTS_TPM_EMU_H
15
16#define TPM_RC_FAILURE 0x101
17#define TPM2_ST_NO_SESSIONS 0x8001
18
19struct tpm_hdr {
20 uint16_t tag;
21 uint32_t len;
22 uint32_t code; /*ordinal/error */
23 char buffer[];
24} QEMU_PACKED;
25
26typedef struct TestState {
Daniel P. Berrangée7b3af82018-05-04 15:34:46 +010027 GMutex data_mutex;
28 GCond data_cond;
Stefan Berger2271b752018-09-07 11:47:06 -040029 bool data_cond_signal;
Stefan Berger0e6ca952018-02-15 08:53:56 -050030 SocketAddress *addr;
31 QIOChannel *tpm_ioc;
32 GThread *emu_tpm_thread;
33 struct tpm_hdr *tpm_msg;
34} TestState;
35
36void tpm_emu_test_wait_cond(TestState *s);
37void *tpm_emu_ctrl_thread(void *data);
38
Markus Armbruster6834c3f2019-03-15 15:51:23 +010039#endif /* TESTS_TPM_EMU_H */