Date: Mon, 10 Nov 2003 01:09:42 -0800 From: John-Mark Gurney <gurney_j@efn.org> To: Sean McNeil <sean@mcneil.com> Cc: freebsd-hackers@freebsd.org Subject: Re: question about user space addressed, mmap, and getting phys address Message-ID: <20031110090942.GC64793@funkthat.com> In-Reply-To: <1067726450.65578.6.camel@blue.mcneil.com> References: <1067726450.65578.6.camel@blue.mcneil.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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."
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031110090942.GC64793>