From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=55911 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBLtT-0006P2-Hd for qemu-devel@nongnu.org; Thu, 28 Oct 2010 02:23:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PBLtS-0005Jb-Ae for qemu-devel@nongnu.org; Thu, 28 Oct 2010 02:23:23 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:41676) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PBLtR-0005JE-QS for qemu-devel@nongnu.org; Thu, 28 Oct 2010 02:23:22 -0400 Date: Thu, 28 Oct 2010 15:23:19 +0900 From: Isaku Yamahata Message-ID: <20101028062319.GA5851@valinux.co.jp> References: <20101028055641.GH5599@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101028055641.GH5599@redhat.com> Subject: [Qemu-devel] Re: [PATCH v2 1/2] pci: introduce pci_region to manage pci io/memory/prefmemory regions. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: cam@cs.ualberta.ca, seabios@seabios.org, adnan@khaleel.us, qemu-devel@nongnu.org On Thu, Oct 28, 2010 at 07:56:41AM +0200, Michael S. Tsirkin wrote: > > diff --git a/src/util.h b/src/util.h > > index 5cc9f17..17eedd0 100644 > > --- a/src/util.h > > +++ b/src/util.h > > @@ -344,6 +344,34 @@ void qemu_prep_reset(void); > > void smm_save_and_copy(void); > > void smm_relocate_and_restore(void); > > > > +// pci_region.c > > +// region allocator. pci region allocates the requested region > > +// sequentially with overflow check. > > +struct pci_region { > > + // The region is [start, region). > > [start end)? Yes. Will fix. > > + u32 start; > > + u32 end; > > + > > + // The next allocation is start from this. > > + // i.e. [start, cur_end) is allocated. > > + // Right after initialization cur_end == start. > > + u32 cur_end; > > What is the value for a region at 0xfffff000 and size 0x1000? > > > Maybe first, last is better to detect this? You mean [first, last] instead of [start, end). Maybe Makes sense. Anyway the area right below 4G can't be used for PCI because it's used for LAPIC and so on. > > > +}; > > +// initialize the pci_region of [start, end) > > +void pci_region_init(struct pci_region *r, u32 start, u32 end); > > +// allocate the region of size > > +u32 pci_region_alloc(struct pci_region *r, u32 size); > > +// make the next allocation aligned to align > > +u32 pci_region_align(struct pci_region *r, u32 align); > > +// revert the allocation to addr. > > +void pci_region_revert(struct pci_region *r, u32 addr); > > +// make the allocation fail. > > +u32 pci_region_disable(struct pci_region *r); > > +// returns the current allocation point. > > +u32 pci_region_addr(const struct pci_region *r); > > +// returns the region size. > > +u32 pci_region_size(const struct pci_region *r); > > + > > // pciinit.c > > extern const u8 pci_irqs[4]; > > void pci_bios_allocate_regions(u16 bdf, void *arg); > > -- > > 1.7.1.1 > -- yamahata