accel/tcg: Record mmio bytes during translation
[qemu/kevin.git] / tests / qtest / tpm-emu.h
blob712cee9b7a5462e1665591523214554ec3317f84
1 /*
2 * Minimal TPM emulator for TPM test cases
4 * Copyright (c) 2018 Red Hat, Inc.
6 * Authors:
7 * Marc-André Lureau <marcandre.lureau@redhat.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.
13 #ifndef TESTS_TPM_EMU_H
14 #define TESTS_TPM_EMU_H
16 #define TPM_RC_FAILURE 0x101
17 #define TPM2_ST_NO_SESSIONS 0x8001
19 #define TPM_FAIL 9
20 #define TPM_TAG_RSP_COMMAND 0xc4
22 #include "qemu/sockets.h"
23 #include "io/channel.h"
24 #include "sysemu/tpm.h"
25 #include "libqtest.h"
27 struct tpm_hdr {
28 uint16_t tag;
29 uint32_t len;
30 uint32_t code; /*ordinal/error */
31 char buffer[];
32 } QEMU_PACKED;
34 #ifndef CONFIG_TPM
35 enum TPMVersion {
36 TPM_VERSION_1_2 = 1,
37 TPM_VERSION_2_0 = 2,
39 #endif
41 typedef struct TPMTestState {
42 GMutex data_mutex;
43 GCond data_cond;
44 bool data_cond_signal;
45 SocketAddress *addr;
46 QIOChannel *tpm_ioc;
47 GThread *emu_tpm_thread;
48 struct tpm_hdr *tpm_msg;
49 enum TPMVersion tpm_version;
50 } TPMTestState;
52 void tpm_emu_test_wait_cond(TPMTestState *s);
53 void *tpm_emu_ctrl_thread(void *data);
54 bool tpm_model_is_available(const char *args, const char *tpm_if);
56 #endif /* TESTS_TPM_EMU_H */