Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L7YPf-000535-C0 for qemu-devel@nongnu.org; Tue, 02 Dec 2008 11:47:51 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L7YPd-000528-Ei for qemu-devel@nongnu.org; Tue, 02 Dec 2008 11:47:50 -0500 Received: from [199.232.76.173] (port=56475 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7YPd-000522-96 for qemu-devel@nongnu.org; Tue, 02 Dec 2008 11:47:49 -0500 Received: from smtp11.dti.ne.jp ([202.216.231.186]:41825) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L7YPc-0001xZ-Ef for qemu-devel@nongnu.org; Tue, 02 Dec 2008 11:47:49 -0500 Date: Wed, 3 Dec 2008 01:47:39 +0900 (JST) Message-Id: <200812021647.mB2Gldoe003402@smtp11.dti.ne.jp> From: takasi-y@ops.dti.ne.jp Subject: Re: [Qemu-devel] MMIO address changes In-Reply-To: <200812011859.35859.paul@codesourcery.com> References: <200812011859.35859.paul@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paul Brook Hi, > I've just committed a patch that changes the MMIO callback interface for > devices. Instead of being passed an absolute address these are now passed an > offset from the start[1] of the memory region that was registered. Good! It is just what I wanted. > I've tried to be fairly thorough with the changes, and tested what I can. > However it's possible I missed or broke something, so please test your > favourite targets. Mmmmm, sh/r2d is broken. I'll post a fix later. But, before that, could you please tell me if this modification below is good and acceptable ? diff --git a/exec.c b/exec.c --- a/exec.c +++ b/exec.c @@ -2295,6 +2295,7 @@ void cpu_register_physical_memory_offset(target_phys_addr_ t start_addr, p->region_offset = 0; } else { p->phys_offset = phys_offset; + p->region_offset = region_offset; if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM || (phys_offset & IO_MEM_ROMD)) phys_offset += TARGET_PAGE_SIZE; You can see the difference when you register a region overriding other(perhaps bigger) region. hw/sh7750.c hits this by registering 0xfc000000 .. 0xffffffff for CPU control registers, then 0xffe00000 .. 0xffe00028 0xffe80000 .. 0xffe80028 0xffd00000 .. 0xffd01000 0xffd80000 .. 0xffd81000 ... for peripheral modules. I can divide the first region to some pieces to avoid overlapping. That is one solution, and is not bad to do (even without this issue), though. Ah, in addition, I'd like to know if registering overlapping region is valid or no. > [1] It's actually the offset from the start of the first page of that region. > In practice this difference doesn't matter, and makes the implementation a > lot simpler. Simpler is better. But, I'd like to have a guide to write a code when it does matter. Now, at least hw/sm501.c has been already broken by this case. It registers palette register array at base + MMIO_BASE_OFFSET + SM501_DC + SM501_DC_PANEL_PALETTE, = 0x10000000 + 0x3e00000 + 0x080000 + 0x400 so, palette index offsets 0x400. Of cource I can fix it by addr -= (MMIO_BASE_OFFSET + SM501_DC + SM501_DC_PANEL_PALETTE)&~TARGET_PAGE_MASK; before accessing the register. Looks not so smart... Are there any idea? Cheers, /yoshii