Function to get address within SYS_RES_MEM resource?
Marius Strobl
marius at alchemy.franken.de
Sun Jun 15 16:04:28 UTC 2008
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
More information about the freebsd-arch
mailing list