From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Stefan Berger <stefanb@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PULL v1 06/10] tpm_tis: merge read and write buffer into single buffer
Date: Fri, 22 Dec 2017 15:16:21 -0500 [thread overview]
Message-ID: <1513973785-14427-7-git-send-email-stefanb@linux.vnet.ibm.com> (raw)
In-Reply-To: <1513973785-14427-1-git-send-email-stefanb@linux.vnet.ibm.com>
Since we can only be in read or write mode, we can merge the buffers
into a single buffer.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
hw/tpm/tpm_tis.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 34bfc86..ad36347 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -70,8 +70,7 @@ typedef struct TPMState {
ISADevice busdev;
MemoryRegion mmio;
- unsigned char w_buffer[TPM_TIS_BUFFER_MAX];
- unsigned char r_buffer[TPM_TIS_BUFFER_MAX];
+ unsigned char buffer[TPM_TIS_BUFFER_MAX];
uint8_t active_locty;
uint8_t aborting_locty;
@@ -257,7 +256,7 @@ static void tpm_tis_tpm_send(TPMState *s, uint8_t locty)
{
TPMLocality *locty_data = &s->loc[locty];
- tpm_tis_show_buffer(s->w_buffer, s->be_buffer_size,
+ tpm_tis_show_buffer(s->buffer, s->be_buffer_size,
"tpm_tis: To TPM");
/*
@@ -268,9 +267,9 @@ static void tpm_tis_tpm_send(TPMState *s, uint8_t locty)
s->cmd = (TPMBackendCmd) {
.locty = locty,
- .in = s->w_buffer,
+ .in = s->buffer,
.in_len = locty_data->w_offset,
- .out = s->r_buffer,
+ .out = s->buffer,
.out_len = s->be_buffer_size,
};
@@ -422,7 +421,7 @@ static void tpm_tis_request_completed(TPMIf *ti)
s->loc[locty].r_offset = 0;
s->loc[locty].w_offset = 0;
- tpm_tis_show_buffer(s->r_buffer, s->be_buffer_size,
+ tpm_tis_show_buffer(s->buffer, s->be_buffer_size,
"tpm_tis: From TPM");
if (TPM_TIS_IS_VALID_LOCTY(s->next_locty)) {
@@ -442,10 +441,10 @@ static uint32_t tpm_tis_data_read(TPMState *s, uint8_t locty)
uint16_t len;
if ((s->loc[locty].sts & TPM_TIS_STS_DATA_AVAILABLE)) {
- len = MIN(tpm_cmd_get_size(&s->r_buffer),
+ len = MIN(tpm_cmd_get_size(&s->buffer),
s->be_buffer_size);
- ret = s->r_buffer[s->loc[locty].r_offset++];
+ ret = s->buffer[s->loc[locty].r_offset++];
if (s->loc[locty].r_offset >= len) {
/* got last byte */
tpm_tis_sts_set(&s->loc[locty], TPM_TIS_STS_VALID);
@@ -491,11 +490,11 @@ static void tpm_tis_dump_state(void *opaque, hwaddr addr)
"tpm_tis: result buffer : ",
s->loc[locty].r_offset);
for (idx = 0;
- idx < MIN(tpm_cmd_get_size(&s->r_buffer), s->be_buffer_size);
+ idx < MIN(tpm_cmd_get_size(&s->buffer), s->be_buffer_size);
idx++) {
DPRINTF("%c%02x%s",
s->loc[locty].r_offset == idx ? '>' : ' ',
- s->r_buffer[idx],
+ s->buffer[idx],
((idx & 0xf) == 0xf) ? "\ntpm_tis: " : "");
}
DPRINTF("\n"
@@ -503,11 +502,11 @@ static void tpm_tis_dump_state(void *opaque, hwaddr addr)
"tpm_tis: request buffer: ",
s->loc[locty].w_offset);
for (idx = 0;
- idx < MIN(tpm_cmd_get_size(s->w_buffer), s->be_buffer_size);
+ idx < MIN(tpm_cmd_get_size(s->buffer), s->be_buffer_size);
idx++) {
DPRINTF("%c%02x%s",
s->loc[locty].w_offset == idx ? '>' : ' ',
- s->w_buffer[idx],
+ s->buffer[idx],
((idx & 0xf) == 0xf) ? "\ntpm_tis: " : "");
}
DPRINTF("\n");
@@ -569,7 +568,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,
if (s->active_locty == locty) {
if ((s->loc[locty].sts & TPM_TIS_STS_DATA_AVAILABLE)) {
val = TPM_TIS_BURST_COUNT(
- MIN(tpm_cmd_get_size(&s->r_buffer),
+ MIN(tpm_cmd_get_size(&s->buffer),
s->be_buffer_size)
- s->loc[locty].r_offset) | s->loc[locty].sts;
} else {
@@ -922,7 +921,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
while ((s->loc[locty].sts & TPM_TIS_STS_EXPECT) && size > 0) {
if (s->loc[locty].w_offset < s->be_buffer_size) {
- s->w_buffer[s->loc[locty].w_offset++] =
+ s->buffer[s->loc[locty].w_offset++] =
(uint8_t)val;
val >>= 8;
size--;
@@ -937,7 +936,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
/* we have a packet length - see if we have all of it */
bool need_irq = !(s->loc[locty].sts & TPM_TIS_STS_VALID);
- len = tpm_cmd_get_size(&s->w_buffer);
+ len = tpm_cmd_get_size(&s->buffer);
if (len > s->loc[locty].w_offset) {
tpm_tis_sts_set(&s->loc[locty],
TPM_TIS_STS_EXPECT | TPM_TIS_STS_VALID);
--
2.5.5
next prev parent reply other threads:[~2017-12-22 20:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 20:16 [Qemu-devel] [PULL v1 00/10] Merge tpm 2017/12/22 Stefan Berger
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 01/10] tpm_emulator: Add a caching layer for the TPM Established flag Stefan Berger
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 02/10] tpm_tis: convert uint32_t to size_t Stefan Berger
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 03/10] tpm_tis: limit size of buffer from backend Stefan Berger
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 04/10] tpm_tis: remove TPMSizeBuffer usage Stefan Berger
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 05/10] tpm_tis: move buffers from localities into common location Stefan Berger
2017-12-22 20:16 ` Stefan Berger [this message]
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 07/10] tpm_tis: move r/w_offsets to TPMState Stefan Berger
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 08/10] tpm_tis: merge r/w_offset into rw_offset Stefan Berger
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 09/10] tpm: Implement tpm_sized_buffer_reset Stefan Berger
2017-12-22 20:16 ` [Qemu-devel] [PULL v1 10/10] acpi: Update TPM2 ACPI table to more recent specs Stefan Berger
2018-01-08 11:39 ` [Qemu-devel] [PULL v1 00/10] Merge tpm 2017/12/22 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1513973785-14427-7-git-send-email-stefanb@linux.vnet.ibm.com \
--to=stefanb@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).