From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 25 15:01:39 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org 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 19C4C16A41F; Mon, 25 Jul 2005 15:01:39 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from server.absolute-media.de (server.absolute-media.de [213.239.231.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id A38C143D5D; Mon, 25 Jul 2005 15:01:36 +0000 (GMT) (envelope-from NKoch@demig.de) Received: from localhost (unknown [127.0.0.1]) by server.absolute-media.de (Postfix) with ESMTP id D13D38C1C1; Mon, 25 Jul 2005 17:01:33 +0200 (CEST) Received: from server.absolute-media.de ([127.0.0.1]) by localhost (server [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 23255-10; Mon, 25 Jul 2005 17:01:29 +0200 (CEST) Received: from firewall.demig (p50839592.dip0.t-ipconnect.de [80.131.149.146]) by server.absolute-media.de (Postfix) with ESMTP id 058DD8B933; Mon, 25 Jul 2005 17:01:28 +0200 (CEST) Received: from ws-ew-3 (ws-ew-3.w2kdemig [192.168.1.72]) by firewall.demig (8.13.4/8.13.1) with SMTP id j6PEwtnY040780; Mon, 25 Jul 2005 16:58:55 +0200 (CEST) (envelope-from NKoch@demig.de) From: "Norbert Koch" To: "Giorgos Keramidas" , "Felix-KM" Date: Mon, 25 Jul 2005 16:58:55 +0200 Message-ID: <000001c59129$6099b560$4801a8c0@ws-ew-3.W2KDEMIG> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 In-reply-to: <20050725142745.GA26647@beatrix.daedalusnetworks.priv> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2120.0 Importance: Normal X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at absolute-media.de Cc: freebsd-hackers@freebsd.org Subject: RE: how to use the function copyout() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2005 15:01:39 -0000 > > > So if I get it right, it's impossible in FreeBSD to gain access to > > 64KB of user's program memory with ioctl? > > > > My situation is this - I have a device driver for Linux. My task is > > port it as it is (1:1) into FreeBSD. > > > > In the Linux driver Ioctl is realized with the macroses _put_user > > _get_user all over it. As I understand in FreeBSD their analogues are > > functions described in store(9), copy(9) and fetch(9). > > > > So the problem is that in my user program an array short unsigned int > > Data[32768] is defined. I need to gain access to the array(to each > > element of it) from device driver with Ioctl handler. > > > > Is it possible to do? If yes, then how it can be done? > > A better alternative that doesn't involve copying huge amounts of data > from userlevel to kernel space and vice versa is probably to pass just > the address of the area with an ioctl() and then map the appropriate > pages from the address space of the user process to an area where the > kernel can access the data directly? I think that could work (only an idea, not tested): struct Region { void * p; size_t s; }; #define IOBIG _IOWR ('b', 123, struct Region) userland: char data[1000]; struct Region r; r.p = data; r.s = sizeof data; int error = ioctl (fd, IOBIG, &r); kernel: int my_ioctl(..., caddr_t data, ...) { ... char data[1000]; ... return copyout(data, ((struct Region *) data)->p, ((struct Region *) data)->s); } Have a try and tell us if it works. Norbert