Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Jun 2008 16:09:10 +1000
From:      Benno Rice <benno@jeamland.net>
To:        freebsd-arch@freebsd.org
Subject:   Function to get address within SYS_RES_MEM resource?
Message-ID:  <2DF4DB2C-D2F4-4558-80B8-C92B3A60865C@jeamland.net>

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






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2DF4DB2C-D2F4-4558-80B8-C92B3A60865C>