From owner-freebsd-arch@FreeBSD.ORG Fri Jun 13 06:24:35 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 DA5AE1065674 for ; Fri, 13 Jun 2008 06:24:35 +0000 (UTC) (envelope-from benno@jeamland.net) Received: from mail.jeamland.net (rafe.jeamland.net [203.20.99.33]) by mx1.freebsd.org (Postfix) with ESMTP id 917788FC1D for ; Fri, 13 Jun 2008 06:24:35 +0000 (UTC) (envelope-from benno@jeamland.net) Received: from mail.jeamland.net (localhost [127.0.0.1]) by mail.jeamland.net (Postfix) with ESMTP id 3CEB51CC85 for ; Fri, 13 Jun 2008 16:09:19 +1000 (EST) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on rafe.jeamland.net X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.4 Received: from urtzweil.jeamland.net (ppp154-45.static.internode.on.net [150.101.154.45]) by mail.jeamland.net (Postfix) with ESMTPSA id BA8F51CC07 for ; Fri, 13 Jun 2008 16:09:18 +1000 (EST) Message-Id: <2DF4DB2C-D2F4-4558-80B8-C92B3A60865C@jeamland.net> From: Benno Rice To: freebsd-arch@freebsd.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Date: Fri, 13 Jun 2008 16:09:10 +1000 X-Mailer: Apple Mail (2.919.2) X-Virus-Scanned: ClamAV using ClamSMTP at rafe.jeamland.net Subject: 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: Fri, 13 Jun 2008 06:24:36 -0000 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. =) -- Benno Rice benno@jeamland.net