From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8GXg-00058n-Tg for qemu-devel@nongnu.org; Mon, 26 Sep 2011 15:08:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R8GXf-0004BR-LS for qemu-devel@nongnu.org; Mon, 26 Sep 2011 15:08:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R8GXf-0004BL-BS for qemu-devel@nongnu.org; Mon, 26 Sep 2011 15:08:39 -0400 Date: Mon, 26 Sep 2011 22:09:05 +0300 From: "Michael S. Tsirkin" Message-ID: <20110926190905.GD22278@redhat.com> References: <20110926163509.020984459@linux.vnet.ibm.com> <20110926163729.645611239@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110926163729.645611239@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH V9 2/5] Add TPM (frontend) hardware interface (TPM TIS) to Qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Berger Cc: avi@redhat.com, serge@hallyn.com, qemu-devel@nongnu.org, anbang.ruan@cs.ox.ac.uk, andreas.niederl@iaik.tugraz.at 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? > + 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? > + > + rc = tpm_tis_do_startup_tpm(s); > + if (rc != 0) { > + goto err_exit; > + } > + > + return 0; > + > + err_exit: Missing cleanup? > + return -1; > +} > + > +static const VMStateDescription vmstate_tpm_tis = { > + .name = "tpm", > + .unmigratable = 1, > +}; > + > +static ISADeviceInfo tpm_tis_device_info = { > + .init = tpm_tis_init, > + .qdev.name = "tpm-tis", > + .qdev.size = sizeof(TPMState), > + .qdev.vmsd = &vmstate_tpm_tis, > + .qdev.reset = tpm_tis_reset, > + .qdev.props = (Property[]) { > + DEFINE_PROP_UINT32("irq", TPMState, > + s.tis.irq_num, TPM_TIS_IRQ), > + DEFINE_PROP_STRING("tpmdev", TPMState, backend), > + DEFINE_PROP_END_OF_LIST(), > + }, > +}; > + > +static void tpm_tis_register_device(void) > +{ > + isa_qdev_register(&tpm_tis_device_info); > +} > + > +device_init(tpm_tis_register_device)