master
h 60 lines 2.07 KB
Raw
1 /*
2 * QTest TPM utilities
3 *
4 * Copyright (c) 2018 IBM Corporation
5 *
6 * Authors:
7 * Stefan Berger <stefanb@linux.vnet.ibm.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_UTIL_H
14 #define TESTS_TPM_UTIL_H
15
16 #include "io/channel-socket.h"
17
18 extern uint64_t tpm_tis_base_addr;
19
20 #define TIS_REG(LOCTY, REG) \
21 (tpm_tis_base_addr + ((LOCTY) << 12) + REG)
22
23 typedef void (tx_func)(QTestState *s,
24 const unsigned char *req, size_t req_size,
25 unsigned char *rsp, size_t rsp_size);
26
27 void tpm_wait_till_bit_clear(QTestState *s, uint64_t addr, uint32_t mask);
28 void tpm_util_crb_transfer(QTestState *s,
29 const unsigned char *req, size_t req_size,
30 unsigned char *rsp, size_t rsp_size);
31
32 void tpm_util_crb_chunk_transfer(QTestState *s,
33 const unsigned char *req, size_t req_size,
34 unsigned char *rsp, size_t rsp_size);
35
36 void tpm_util_startup(QTestState *s, tx_func *tx);
37 void tpm_util_pcrextend(QTestState *s, tx_func *tx);
38 void tpm_util_pcrread(QTestState *s, tx_func *tx,
39 const unsigned char *exp_resp, size_t exp_resp_size);
40
41 bool tpm_util_swtpm_has_tpm2(void);
42
43 gboolean tpm_util_swtpm_start(const char *path, GPid *pid,
44 SocketAddress **addr, GError **error);
45 void tpm_util_swtpm_kill(GPid pid);
46
47 void tpm_util_migrate(QTestState *who, const char *uri);
48
49 void tpm_util_migration_start_qemu(QTestState **src_qemu,
50 QTestState **dst_qemu,
51 SocketAddress *src_tpm_addr,
52 SocketAddress *dst_tpm_addr,
53 const char *miguri,
54 const char *ifmodel,
55 const char *machine_options);
56
57 void tpm_util_wait_for_migration_complete(QTestState *who);
58 void tpm_util_rmdir(const char *path);
59
60 #endif /* TESTS_TPM_UTIL_H */