From owner-freebsd-arch@FreeBSD.ORG Sun Jun 15 16:04:28 2008 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1CF361065670 for ; Sun, 15 Jun 2008 16:04:28 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id A8F978FC14 for ; Sun, 15 Jun 2008 16:04:27 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.3/8.14.3/ALCHEMY.FRANKEN.DE) with ESMTP id m5FFWhas014952; Sun, 15 Jun 2008 17:32:43 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.3/8.14.3/Submit) id m5FFWgX5014951; Sun, 15 Jun 2008 17:32:42 +0200 (CEST) (envelope-from marius) Date: Sun, 15 Jun 2008 17:32:42 +0200 From: Marius Strobl To: Benno Rice Message-ID: <20080615153242.GA14902@alchemy.franken.de> References: <2DF4DB2C-D2F4-4558-80B8-C92B3A60865C@jeamland.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2DF4DB2C-D2F4-4558-80B8-C92B3A60865C@jeamland.net> User-Agent: Mutt/1.4.2.3i Cc: freebsd-arch@freebsd.org Subject: Re: Function to get address within SYS_RES_MEM resource? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jun 2008 16:04:28 -0000 On Fri, Jun 13, 2008 at 04:09:10PM +1000, Benno Rice wrote: > Hi, > > I'm currently working on porting dmover(9) from NetBSD in order to > support the DMA controller on the PXA255. I believe some others are > eyeing dmover off to support other similar components. > > For those that haven't heard of it, dmover is an API for controlling > hardware data movers. NetBSD's man page is here: > > http://netbsd.gw.com/cgi-bin/man-cgi?dmover > > Currently, dmover supports two types of buffers, in-kernel linear > memory ranges and uio buffers. For the task I want to use it for, I > need to add a third, which is a static address and width or possibly a > SYS_RES_MEM resource with an offset and width. The task in question > is copying a packet out of an ethernet controller via PIO. > > Currently I'm doing this using bus_read_multi_2. In the software > dmover backend I could easily implement this using bus_read_multi_* as > well. However once I try to offload it to the hardware, I need to be > able to get at the physical address that this ends up reading from. > > My current idea in this regard is to add a new bus_space function > along the lines of: > > void *bus_space_address(bus_space_tag_t, bus_space_handle_t, > bus_size_t offset); > > This function would return a pointer to the relevant _virtual_ > address, or NULL if such a thing is not possible. Another option > would be: > > int bus_space_address(bus_space_tag_t, bus_space_handle_t, bus_size_t > offset, void **addr); > > which could return an errno value on failure. > > This could be shortened to bus_address(struct resource *, bus_size_t > offset) in the same way as other > bus_space_* functions. > > I could then turn that into a physical address, either via bus_dma or > pmap, and then feed it to the DMAC. > > I'm also quite willing to be told that there's already an obvious way > to do this and I should use that instead. =) > If you can add the offset on your own I think you can use rman_get_virtual(9) for this (which requires f.e. nexus(4) to do a rman_set_virtual(9) though). Marius