From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43394 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7iXT-0007U0-L0 for qemu-devel@nongnu.org; Mon, 18 Oct 2010 01:45:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P7iXS-0008CT-3k for qemu-devel@nongnu.org; Mon, 18 Oct 2010 01:45:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P7iXR-0008CO-To for qemu-devel@nongnu.org; Mon, 18 Oct 2010 01:45:38 -0400 Date: Mon, 18 Oct 2010 07:38:53 +0200 From: "Michael S. Tsirkin" Message-ID: <20101018053853.GC18366@redhat.com> References: <7d5d92f508899391d060809e9a419c7556905379.1287371107.git.yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7d5d92f508899391d060809e9a419c7556905379.1287371107.git.yamahata@valinux.co.jp> Subject: [Qemu-devel] Re: [PATCH v4 04/15] pci: record which is written into pci configuration space List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: skandasa@cisco.com, adnan@khaleel.us, etmartin@cisco.com, qemu-devel@nongnu.org, wexu2@cisco.com On Mon, Oct 18, 2010 at 12:17:45PM +0900, Isaku Yamahata wrote: > record which is written into pci configuration space. > introduce helper function to zero PCIDevice::written. > They will be used later. > > Signed-off-by: Isaku Yamahata This really exposes an internal variable. I really dislike this, and I don't think it's needed at all: just make the bit writeable. Commented on appropriate patches. > --- > hw/pci.c | 10 ++++++++++ > hw/pci.h | 5 +++++ > 2 files changed, 15 insertions(+), 0 deletions(-) > > diff --git a/hw/pci.c b/hw/pci.c > index 5954476..eca9324 100644 > --- a/hw/pci.c > +++ b/hw/pci.c > @@ -627,6 +627,7 @@ static void pci_config_alloc(PCIDevice *pci_dev) > pci_dev->cmask = qemu_mallocz(config_size); > pci_dev->wmask = qemu_mallocz(config_size); > pci_dev->w1cmask = qemu_mallocz(config_size); > + pci_dev->written = qemu_mallocz(config_size); > pci_dev->used = qemu_mallocz(config_size); > } > > @@ -636,6 +637,7 @@ static void pci_config_free(PCIDevice *pci_dev) > qemu_free(pci_dev->cmask); > qemu_free(pci_dev->wmask); > qemu_free(pci_dev->w1cmask); > + qemu_free(pci_dev->written); > qemu_free(pci_dev->used); > } > > @@ -1002,6 +1004,8 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) > assert(!(wmask & w1cmask)); > d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask); > d->config[addr + i] &= ~(val & w1cmask); /* W1C: Write 1 to Clear */ > + d->written[addr + i] = val; /* record what is written for driver > + specific code */ > } > if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) || > ranges_overlap(addr, l, PCI_ROM_ADDRESS, 4) || > @@ -1013,6 +1017,12 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) > pci_update_irq_disabled(d, was_irq_disabled); > } > > +void pci_clear_written_write_config(PCIDevice *d, > + uint32_t addr, uint32_t val, int l) > +{ > + memset(d->written + addr, 0, l); > +} > + > /***********************************************************/ > /* generic PCI irq support */ > > diff --git a/hw/pci.h b/hw/pci.h > index eafa9f3..7097817 100644 > --- a/hw/pci.h > +++ b/hw/pci.h > @@ -132,6 +132,9 @@ struct PCIDevice { > /* Used to implement RW1C(Write 1 to Clear) bytes */ > uint8_t *w1cmask; > > + /* Used to record what value is written */ > + uint8_t *written; > + > /* Used to allocate config space for capabilities. */ > uint8_t *used; > > @@ -200,6 +203,8 @@ uint32_t pci_default_read_config(PCIDevice *d, > uint32_t address, int len); > void pci_default_write_config(PCIDevice *d, > uint32_t address, uint32_t val, int len); > +void pci_clear_written_write_config(PCIDevice *d, > + uint32_t addr, uint32_t val, int l); > void pci_device_save(PCIDevice *s, QEMUFile *f); > int pci_device_load(PCIDevice *s, QEMUFile *f); > > -- > 1.7.1.1