From owner-freebsd-hackers Tue Dec 3 09:45:18 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id JAA01705 for hackers-outgoing; Tue, 3 Dec 1996 09:45:18 -0800 (PST) Received: from bacall.lodgenet.com (bacall.lodgenet.com [205.138.147.242]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id JAA01694 for ; Tue, 3 Dec 1996 09:45:11 -0800 (PST) Received: (from mail@localhost) by bacall.lodgenet.com (8.6.12/8.6.12) id LAA17875; Tue, 3 Dec 1996 11:44:45 -0600 Received: from garbo.lodgenet.com(204.124.123.250) by bacall via smap (V1.3) id sma017844; Tue Dec 3 11:44:22 1996 Received: from jake.lodgenet.com (jake.lodgenet.com [10.0.11.30]) by garbo.lodgenet.com (8.6.12/8.6.9) with ESMTP id LAA04461; Tue, 3 Dec 1996 11:44:28 -0600 Received: from jake.lodgenet.com (localhost [127.0.0.1]) by jake.lodgenet.com (8.8.3/8.6.12) with ESMTP id LAA13076; Tue, 3 Dec 1996 11:44:34 -0600 (CST) Message-Id: <199612031744.LAA13076@jake.lodgenet.com> X-Mailer: exmh version 1.6.9 8/22/96 To: Michael Smith cc: tony@nlanr.net (Tony Sterrett), hackers@freebsd.org Subject: Re: Driver help In-reply-to: Your message of "Tue, 03 Dec 1996 11:27:06 +1030." <199612030057.LAA06521@genesis.atrad.adelaide.edu.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 03 Dec 1996 11:44:34 -0600 From: "Eric L. Hernes" Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Michael Smith writes: > - You should use uiomove because it's wise to the type of the > destination; for destinations in kernel space it will use bcopy() > rather than copyout(), and it understands fragmented destinations > (ie. readv()/writev()). > IMHO, using copyin/out in drivers is bogus in most cases. I agree, but people porting drivers from a sysV derrivative, may want to have a driver that will compile and work on either machine. I've used a set of macros tucked away in the ifdef section like: #ifdef __FreeBSD__ #define uio_in uiomove #define uio_out uiomove #else /* probably SCO */ #define uio_out(base, n, uio) copyout(base, uio.u_base, n); \ uio.u_base+=n; uio.u_offset+=n; uio.u_count-=n #define uio_in(base, n, uio) copyin(uio.u_base, base, n); \ uio.u_base+=n; uio.u_offset+=n; uio.u_count-=n #endif I've also done similar things with the dma kernel support functions. Usually, the driver ends up looking more BSDish than SCOish, but isn't that how God intended? ;-) > >-- >]] Mike Smith, Software Engineer msmith@gsoft.com.au [[ >]] Genesis Software genesis@gsoft.com.au [[ >]] High-speed data acquisition and (GSM mobile) 0411-222-496 [[ >]] realtime instrument control. (ph) +61-8-8267-3493 [[ >]] Unix hardware collector. "Where are your PEZ?" The Tick [[ > eric. -- erich@lodgenet.com http://rrnet.com/~erich erich@rrnet.com