From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 10 01:09:45 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ACFE716A4CE for ; Mon, 10 Nov 2003 01:09:45 -0800 (PST) Received: from mail.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9FE0A43FF3 for ; Mon, 10 Nov 2003 01:09:44 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 947 invoked from network); 10 Nov 2003 09:09:44 -0000 Received: from unknown (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 10 Nov 2003 09:09:44 -0000 Received: from hydrogen.funkthat.com (zcdsdy@localhost.funkthat.com [127.0.0.1])hAA99hgP075520; Mon, 10 Nov 2003 01:09:43 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id hAA99gM7075519; Mon, 10 Nov 2003 01:09:42 -0800 (PST) Date: Mon, 10 Nov 2003 01:09:42 -0800 From: John-Mark Gurney To: Sean McNeil Message-ID: <20031110090942.GC64793@funkthat.com> Mail-Followup-To: Sean McNeil , freebsd-hackers@freebsd.org References: <1067726450.65578.6.camel@blue.mcneil.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1067726450.65578.6.camel@blue.mcneil.com> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: freebsd-hackers@freebsd.org Subject: Re: question about user space addressed, mmap, and getting phys address X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Nov 2003 09:09:45 -0000 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."