Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jun 2008 17:32:42 +0200
From:      Marius Strobl <marius@alchemy.franken.de>
To:        Benno Rice <benno@jeamland.net>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: Function to get address within SYS_RES_MEM resource?
Message-ID:  <20080615153242.GA14902@alchemy.franken.de>
In-Reply-To: <2DF4DB2C-D2F4-4558-80B8-C92B3A60865C@jeamland.net>
References:  <2DF4DB2C-D2F4-4558-80B8-C92B3A60865C@jeamland.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080615153242.GA14902>