tpm: Share tpm_write_fatal_error_response
PATCH 2/4 tpm: Share tpm_write_fatal_error_response
Move tpm_write_fatal_error_response to tpm.c where it can be shared by multiple backends, and change the return code from void to the size of the message.
Signed-off-by Corey Bryant <[email protected]>
--- hw/tpm/tpm_passthrough.c | 14 -------------- hw/tpm/tpm_tis.h | 1 + include/sysemu/tpm_backend.h | 2 ++ tpm.c | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 14 deletions(-)
hw/tpm/tpm_passthrough.c +0 -14
@@ -98,20 +98,6 @@ static uint32_t tpm_passthrough_get_size_from_buffer(const uint8_t *buf)return be32_to_cpu (resp->len); } -/* -* Write an error message in the given output buffer. -*/ -static void tpm_write_fatal_error_response (uint8_t *out,uint32_t out_len) -{ -if (out_len >=sizeof (struct tpm_resp_hdr )) { -struct tpm_resp_hdr *resp = (struct tpm_resp_hdr *)out; - - resp->tag =cpu_to_be16 (TPM_TAG_RSP_COMMAND ); - resp->len =cpu_to_be32 (sizeof (struct tpm_resp_hdr )); - resp->errcode =cpu_to_be32 (TPM_FAIL ); - } -} -static int tpm_passthrough_unix_tx_bufs (TPMPassthruState *tpm_pt,const uint8_t *in,uint32_t in_len,uint8_t *out,uint32_t out_len)
hw/tpm/tpm_tis.h +1 -0
@@ -19,6 +19,7 @@#include "hw/isa/isa.h" #include "qemu-common.h" +#include "sysemu/tpm_backend.h" #define TPM_TIS_ADDR_BASE 0xFED40000
include/sysemu/tpm_backend.h +2 -0
@@ -207,4 +207,6 @@ const TPMDriverOps *tpm_get_backend_driver(const char *type);int tpm_register_model (enum TpmModel model);int tpm_register_driver (const TPMDriverOps *tdo); +uint32_t tpm_write_fatal_error_response (uint8_t *out,uint32_t out_len); +#endif
tpm.c +19 -0
@@ -19,6 +19,7 @@#include "sysemu/tpm.h" #include "qemu/config-file.h" #include "qmp-commands.h" +#include "hw/tpm/tpm_int.h" static QLIST_HEAD(, TPMBackend) tpm_backends =QLIST_HEAD_INITIALIZER (tpm_backends);
@@ -61,6 +62,24 @@ static bool tpm_model_is_registered(enum TpmModel model)return false; } +/* +* Write an error message in the given output buffer. +*/ +uint32_t tpm_write_fatal_error_response (uint8_t *out,uint32_t out_len) +{ +if (out_len >=sizeof (struct tpm_resp_hdr )) { +struct tpm_resp_hdr *resp = (struct tpm_resp_hdr *)out; + + resp->tag =cpu_to_be16 (TPM_TAG_RSP_COMMAND ); + resp->len =cpu_to_be32 (sizeof (struct tpm_resp_hdr )); + resp->errcode =cpu_to_be32 (TPM_FAIL ); + +return sizeof (struct tpm_resp_hdr ); + } + +return 0 ; +} +const TPMDriverOps *tpm_get_backend_driver (const char *type) {int i;
Signature · 1 line
1.7.1