direct-io.hg

changeset 13808:3093bd26ae45

[TPM] TIS dm suspend code fix

This fixes a bug in the TPM TIS device model's state suspend code and
adds some casts to variables to avoid compiler warnings.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kfraser@localhost.localdomain
date Tue Feb 06 22:59:35 2007 +0000 (2007-02-06)
parents 2379569b590d
children e212203d7d34
files tools/ioemu/hw/tpm_tis.c
line diff
     1.1 --- a/tools/ioemu/hw/tpm_tis.c	Tue Feb 06 16:05:29 2007 +0000
     1.2 +++ b/tools/ioemu/hw/tpm_tis.c	Tue Feb 06 22:59:35 2007 +0000
     1.3 @@ -517,7 +517,7 @@ static uint32_t tis_mem_readl(void *opaq
     1.4  
     1.5  #ifdef DEBUG_TPM
     1.6      fprintf(logfile," read(%08x) = %08x\n",
     1.7 -            addr,
     1.8 +            (int)addr,
     1.9              val);
    1.10  #endif
    1.11  
    1.12 @@ -538,7 +538,7 @@ static void tis_mem_writel(void *opaque,
    1.13  
    1.14  #ifdef DEBUG_TPM
    1.15      fprintf(logfile,"write(%08x) = %08x\n",
    1.16 -            addr,
    1.17 +            (int)addr,
    1.18              val);
    1.19  #endif
    1.20  
    1.21 @@ -757,10 +757,11 @@ static CPUWriteMemoryFunc *tis_writefn[3
    1.22  static void tpm_save(QEMUFile* f,void* opaque)
    1.23  {
    1.24      tpmState* s=(tpmState*)opaque;
    1.25 +    uint8_t locty = s->active_loc;
    1.26      int c;
    1.27  
    1.28      /* need to wait for outstanding requests to complete */
    1.29 -    if (IS_COMM_WITH_VTPM(s)) {
    1.30 +    if (s->loc[locty].state == STATE_EXECUTION) {
    1.31          int repeats = 30; /* 30 seconds; really should be infty */
    1.32          while (repeats > 0 &&
    1.33                 !(s->loc[s->active_loc].sts & STS_DATA_AVAILABLE)) {
    1.34 @@ -777,6 +778,10 @@ static void tpm_save(QEMUFile* f,void* o
    1.35          }
    1.36      }
    1.37  
    1.38 +    if (IS_COMM_WITH_VTPM(s)) {
    1.39 +        close_vtpm_channel(s, 1);
    1.40 +    }
    1.41 +
    1.42      qemu_put_be32s(f,&s->offset);
    1.43      qemu_put_buffer(f, s->buffer.buf, TPM_MAX_PKT);
    1.44      qemu_put_8s(f, &s->active_loc);
    1.45 @@ -993,7 +998,7 @@ static int TPM_Receive(tpmState *s, tpmB
    1.46          uint32_t size = tpm_get_size_from_buffer(buffer->buf);
    1.47          if (size + sizeof(buffer->instance) != off) {
    1.48              fprintf(logfile,"TPM: Packet size is bad! %d != %d\n",
    1.49 -                    size + sizeof(buffer->instance),
    1.50 +                    (int)(size + sizeof(buffer->instance)),
    1.51                      off);
    1.52          } else {
    1.53              uint32_t ret;