diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2017-10-10 00:55:55 +0200 |
---|---|---|
committer | Stefan Berger <stefanb@linux.vnet.ibm.com> | 2017-10-19 11:42:28 -0400 |
commit | 0e43b7e61ce677e154584523943c1651779baccf (patch) | |
tree | eeabafb7cfd3f4329350731663ad9ffca20b0c55 /hw/tpm/tpm_emulator.c | |
parent | d1fd6b563d44a1132f8a5758f8f7bafba548502c (diff) |
tpm: add TPMBackendCmd to hold the request state
This simplifies a bit locality handling, and argument passing, and
could pave the way to queuing requests (if that makes sense).
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Diffstat (limited to 'hw/tpm/tpm_emulator.c')
-rw-r--r-- | hw/tpm/tpm_emulator.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index 8fbe9ad74a..0b1a99fcc5 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -172,28 +172,29 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_emu, uint8_t locty_number) return 0; } -static void tpm_emulator_handle_request(TPMBackend *tb) +static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd *cmd) { TPMEmulator *tpm_emu = TPM_EMULATOR(tb); - TPMLocality *locty = NULL; - bool selftest_done = false; Error *err = NULL; DPRINTF("processing TPM command"); - locty = tb->tpm_state->locty_data; - if (tpm_emulator_set_locality(tpm_emu, - tb->tpm_state->locty_number) < 0 || - tpm_emulator_unix_tx_bufs(tpm_emu, locty->w_buffer.buffer, - locty->w_offset, locty->r_buffer.buffer, - locty->r_buffer.size, &selftest_done, - &err) < 0) { - tpm_util_write_fatal_error_response(locty->r_buffer.buffer, - locty->r_buffer.size); - error_report_err(err); + if (tpm_emulator_set_locality(tpm_emu, tb->tpm_state->locty_number) < 0) { + goto error; + } + + if (tpm_emulator_unix_tx_bufs(tpm_emu, cmd->in, cmd->in_len, + cmd->out, cmd->out_len, + &cmd->selftest_done, &err) < 0) { + goto error; } - tb->recv_data_callback(tb->tpm_state, selftest_done); + tb->recv_data_callback(tb->tpm_state); + return; + +error: + tpm_util_write_fatal_error_response(cmd->out, cmd->out_len); + error_report_err(err); } static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu) |