question about user space addressed, mmap, and getting phys
address
John-Mark Gurney
gurney_j at efn.org
Mon Nov 10 01:09:45 PST 2003
Sean McNeil wrote this message on Sat, Nov 01, 2003 at 14:40 -0800:
> Sorry I am not on the list, but I was hoping someone here might be able
> to help me. I have a design that I cannot change that does the
> following:
>
> 1) Calls mmap on a chunk of memory that the device driver uses to DMA to
> a video decoder.
>
> 2) This chunk of memory is treated as several DMA buffers. There is an
> ioctl setup to indicate when a section of that memory is being used and
> when it is freed (usage count).
>
> I need to take the address from the mmap, add an offset, send it through
> an ioctl, and then relate it back to the physical address that it was
> originally mapped from.
>
> Unfortunately, the address I get from the ioctl is a user-space address
> and when I use vtophys I get back 0. Is there some other mechanism to
> convert a user-space address to a physical address?
>
> Any and all help will be greatly appreciated.
I wrote a fucntion for a video encoder card that does this. I think
passing in physical address is a bad thing, (and svgalib is nice and
mmap's the video frame buffer for you) so I made my driver require
you to pass the address via ioctl pointing to it's local buffer.
The function is a bit long, but look at
http://people.FreeBSD.org/~jmg/zoran-0.5.tar.gz
in the file zoran-0.5/dev/zr/zr_os.c the function verify_contig.
I've stolen that code from other parts of the kernel that do something
similar, but I forget where now.
--
John-Mark Gurney Voice: +1 415 225 5579
"All that I will do, has been done, All that I have, has not."
More information about the freebsd-hackers
mailing list