Date: Tue, 03 Dec 1996 11:44:34 -0600 From: "Eric L. Hernes" <erich@lodgenet.com> To: Michael Smith <msmith@atrad.adelaide.edu.au> Cc: tony@nlanr.net (Tony Sterrett), hackers@freebsd.org Subject: Re: Driver help Message-ID: <199612031744.LAA13076@jake.lodgenet.com> In-Reply-To: Your message of "Tue, 03 Dec 1996 11:27:06 %2B1030." <199612030057.LAA06521@genesis.atrad.adelaide.edu.au>
index | next in thread | previous in thread | raw e-mail
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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612031744.LAA13076>
