]> git.proxmox.com Git - mirror_qemu.git/blob - hw/tpm/tpm_util.h
tpm: tpm_passthrough: Read the buffer size from the host device
[mirror_qemu.git] / hw / tpm / tpm_util.h
1 /*
2 * TPM utility functions
3 *
4 * Copyright (c) 2010 - 2015 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 #ifndef TPM_TPM_UTIL_H
23 #define TPM_TPM_UTIL_H
24
25 #include "sysemu/tpm.h"
26 #include "qemu/bswap.h"
27
28 void tpm_util_write_fatal_error_response(uint8_t *out, uint32_t out_len);
29
30 bool tpm_util_is_selftest(const uint8_t *in, uint32_t in_len);
31
32 int tpm_util_test_tpmdev(int tpm_fd, TPMVersion *tpm_version);
33
34 static inline uint32_t tpm_cmd_get_size(const void *b)
35 {
36 return be32_to_cpu(*(const uint32_t *)(b + 2));
37 }
38
39 int tpm_util_get_buffer_size(int tpm_fd, TPMVersion tpm_version,
40 size_t *buffersize);
41
42 #endif /* TPM_TPM_UTIL_H */