qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/5] Add TPM 1.2 device interface


From: Stefan Berger
Subject: Re: [Qemu-devel] [PATCH 1/5] Add TPM 1.2 device interface
Date: Fri, 18 Feb 2011 16:03:04 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.7

On 02/18/2011 10:33 AM, Andreas Niederl wrote:
+
+static const VMStateDescription vmstate_loc = {
+    .name       = "loc",
+    .version_id = 0,
+    .fields     = (VMStateField []) {
+        VMSTATE_UINT32(state, TPMLocality),
+        VMSTATE_UINT32(inte,  TPMLocality),
+        VMSTATE_UINT32(ints,  TPMLocality),
+        VMSTATE_UINT8(access, TPMLocality),
+        VMSTATE_UINT8(sts,    TPMLocality),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_tpm = {
+    .name       = "tpm",
+    .version_id = 0,
+    .minimum_version_id     = 0,
+    .minimum_version_id_old = 0,
+    .pre_save   = tpm_pre_save,
+    .fields     = (VMStateField []) {
+        VMSTATE_UINT32(irq,    TPMState),
+        VMSTATE_UINT32(offset, TPMState),
+        VMSTATE_BUFFER(buf,    TPMState),
+        VMSTATE_UINT8(  active_locty, TPMState),
+        VMSTATE_UINT8(aborting_locty, TPMState),
+        VMSTATE_UINT8(    next_locty, TPMState),
+        VMSTATE_STRUCT_ARRAY(loc, TPMState, NUM_LOCALITIES, 0,
+                             vmstate_loc, TPMLocality),
Here you are pointing to the above vmstate_loc ...
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+/*

+
+    vmstate_register(&dev->qdev, 1,&vmstate_tpm, s);
+    for (i = 0; i<  NUM_LOCALITIES; i++) {
+        vmstate_register(&dev->qdev, 1,&vmstate_loc,&s->loc[i]);
... here you are (again) registering the localities ...
+    }
+
+    isa_init_irq(dev,&s->pic, isairq);
+    s->irq = isairq;
+
+    iomem = cpu_register_io_memory(tis_readfn, tis_writefn, s,
+            DEVICE_LITTLE_ENDIAN);
+    cpu_register_physical_memory(TIS_ADDR_BASE,
+            0x1000 * NUM_LOCALITIES, iomem);
+
+    s->poll_timer = qemu_new_timer(vm_clock, tis_poll_timer, s);
+
+    return 0;
+}
+
+static void qdev_tpm_reset(DeviceState *dev)
+{
+    TPMState *s = DO_UPCAST(TPMState, dev.qdev, dev);
+    tpm_reset(s);
+}
+
+static ISADeviceInfo tpm_info = {
+    .init          = tpm_init,
+    .qdev.name     = "tpm",
+    .qdev.desc     = "TPM TIS Interface",
+    .qdev.size     = sizeof (TPMState),
+    .qdev.vmsd     =&vmstate_tpm,
... and here you're pointing to vmstate_tpm, which was also registered above using

+
+    vmstate_register(&dev->qdev, 1,&vmstate_tpm, s);


Are you sure this is necessary? In my implementation I only have the qdev.vmsd set and need not explicitly use vmstate_register(). Aren't you writing the state two times if you do that?

   Stefan




reply via email to

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