From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8UKp-0003hg-Iq for qemu-devel@nongnu.org; Mon, 25 May 2009 03:10:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8UKk-0003Sj-W5 for qemu-devel@nongnu.org; Mon, 25 May 2009 03:10:59 -0400 Received: from [199.232.76.173] (port=47098 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8UKk-0003SR-Ro for qemu-devel@nongnu.org; Mon, 25 May 2009 03:10:54 -0400 Received: from mx20.gnu.org ([199.232.41.8]:37496) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M8UKk-0007ut-BJ for qemu-devel@nongnu.org; Mon, 25 May 2009 03:10:54 -0400 Received: from mx2.redhat.com ([66.187.237.31]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M8UKj-0001HM-24 for qemu-devel@nongnu.org; Mon, 25 May 2009 03:10:53 -0400 Date: Mon, 25 May 2009 10:09:47 +0300 From: "Michael S. Tsirkin" Message-ID: <20090525070947.GA424@redhat.com> References: <1242786334-32752-1-git-send-email-yamahata@valinux.co.jp> <1242786334-32752-4-git-send-email-yamahata@valinux.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1242786334-32752-4-git-send-email-yamahata@valinux.co.jp> Subject: [Qemu-devel] Re: [PATCH 3/4] pci: pci_default_config_write() clean up. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Isaku Yamahata Cc: mtosatti@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com On Wed, May 20, 2009 at 11:25:33AM +0900, Isaku Yamahata wrote: > diff --git a/hw/pci.h b/hw/pci.h > index 7f7842f..6bb1c5c 100644 > --- a/hw/pci.h > +++ b/hw/pci.h > +struct PCIConfigReg { > + uint8_t wmask; > + uint8_t shift; I am not sure I understand what shift is. Document fields in this structure? > + pci_config_written_t callback; > +}; > > struct PCIDevice { > DeviceState qdev; > /* PCI config space */ > uint8_t config[PCI_CONFIG_SPACE_SIZE]; > - > - /* Used to implement R/W bytes */ > - uint8_t mask[PCI_CONFIG_SPACE_SIZE]; > + struct PCIConfigReg config_regs[PCI_CONFIG_SPACE_SIZE]; I think that life will be much easier if you'll keep separate arrays of masks and an array of callbacks. Then two simple memset calls can initialize a range or registers to a sane default (readonly, no side effects for head, writeable, no side effects for the rest of config space), and you'll only need to set up callbacks and masks for when something special is needed. -- MST