qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V9 2/5] Add TPM (frontend) hardware interface (T


From: Stefan Berger
Subject: Re: [Qemu-devel] [PATCH V9 2/5] Add TPM (frontend) hardware interface (TPM TIS) to Qemu
Date: Mon, 26 Sep 2011 21:48:31 -0400
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Thunderbird/3.1.11

On 09/26/2011 03:09 PM, Michael S. Tsirkin wrote:
On Mon, Sep 26, 2011 at 12:35:11PM -0400, Stefan Berger wrote:
+static int tpm_tis_init(ISADevice *dev)
+{
+    TPMState *s = DO_UPCAST(TPMState, busdev, dev);
+    TPMTISState *tis =&s->s.tis;
+    int iomemtype, rc;
+
+    qemu_mutex_init(&s->state_lock);
+    qemu_cond_init(&s->from_tpm_cond);
+    qemu_cond_init(&s->to_tpm_cond);
+
+    s->be_driver = qemu_find_tpm(s->backend);
+    if (!s->be_driver) {
+        fprintf(stderr,
+                "tpm_tis: backend driver with id %s could not be found.n\n",
+                s->backend);
error_report?
Fixed.
+        return -1;
+    }
+
+    if (s->be_driver->ops->init(s->be_driver, s, tpm_tis_receive_cb)) {
+        goto err_exit;
+    }
+
+    isa_init_irq(dev,&tis->irq, tis->irq_num);
+
+    iomemtype = cpu_register_io_memory(tpm_tis_readfn, tpm_tis_writefn, s,
+                                       DEVICE_LITTLE_ENDIAN);
A bit of a strange name for a var - it's not a type, is it?

+    cpu_register_physical_memory(TPM_TIS_ADDR_BASE,
+                                 0x1000 * TPM_TIS_NUM_LOCALITIES,
+                                 iomemtype);
I think memory_region_init_io are supposed to be used for new devices
from now on... Right, Avi?
I fixed that now also to use

memory_region_init_io(&s->mmio, &tpm_tis_memory_ops, s, "tpm-tis-mmio",
                      0x1000 * TPM_TIS_NUM_LOCALITIES);
memory_region_add_subregion(get_system_memory(), TPM_TIS_ADDR_BASE,
&s->mmio);


+
+    rc = tpm_tis_do_startup_tpm(s);
+    if (rc != 0) {
+        goto err_exit;
+    }
+
+    return 0;
+
+ err_exit:
Missing cleanup?

True. Fixed.
I had previously looked around in other devices how they were doing it and had often seen them not cleaning up, either.

   Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]