Subject: kqemu: driver(9)/filedesc(9) questions
To: None <tech-kern@netbsd.org>
From: Oliver Gould <ogould@olix0r.net>
List: tech-kern
Date: 04/16/2007 20:27:06
--ZPt4rx8FFjLCG7dd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello again-

I'm trying to wrap up my work on KQEMU.  I've ported most of the
interfaces to NetBSD, but I am left with a few questions regarding
driver(9)..=20

 o  Does a CFATTACH_DECL(...) make any sense in an LKM?  If not, how
    does the device attach?  Both net/tap and dev/vnd use
    CFDRIVER_DECL(...); will this be of any use to me?  I haven't found
    sufficient documentation (if it exists, please point me to it).

 o  /dev/kqemu is the external interface to the module.  In order to
    clone the device, I am trying to mimick bpf(4), and e.g. using
    fileops / fdclone(9).  I maintain a LIST (from QUEUE(9)) of
    (locally-defined) kqemu_instance structures.
   =20
    I'd like a sanity-check on some of this, though.

    As it is currently, the only function passed into kqemu_cdevsw is
    for 'open'.  Both fileops and cdevsw have close and ioctl function
    pointers- which should actually be used?  Perhaps I need to
    better-understand how these interfaces differ.  Can anyone describe
    this concisely?

    Also, I can't think of any use for the read or write fileops, are
    they necessary?  There's no (apparent) stub (fnullop_read or
    fnullop_write), but I don't expect a NULL value to work either-
    suggestions?

 o  Also, I'm running into some silly compile errors- particularly,
    conflicts between /usr/include/sys and /usr/include/machine.  I
    would imagine that this is something obvious and avoidable:

    In file included from /usr/include/sys/endian.h:107,
                 from /usr/include/machine/endian.h:3,
                 from /usr/include/sys/types.h:98,
		 [...]
                 from /usr/include/sys/buf.h:79,
                 from kqemu-netbsd.c:9:
    /usr/include/machine/bswap.h:14:1: error: "bswap16" redefined
    In file included from /usr/include/machine/bswap.h:9,
                 from /usr/include/sys/endian.h:107,
                 from /usr/include/machine/endian.h:3,
                 from /usr/include/sys/types.h:98,
		 [...]
                 from /usr/include/sys/buf.h:79,
                 from kqemu-netbsd.c:9:
    /usr/include/sys/bswap.h:70:1: error: this is the location of the
    previous definition
   =20
    Any easy way around this?

Many thanks,
  - Oliver

--ZPt4rx8FFjLCG7dd
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)

iQEVAwUBRiQUWvBcMTqzwkq9AQJcPAf+LXVGvy6RRIXy4dYbvHSpQ5++MiHY0x6r
H9t0hzUhpfT5wZS1HAmGlZcvSDVvb5CL/+nut3zpWGm3NyHdg51Oh5U4skFVcLTe
IaeffTQEi4mvHxMM0/A+zeilmNQaT2U99ZSGUNTBrQbN5iombEinSXJytbH3f4go
wiyB6bHxeJpvXw9cXuwo8g/7WhHrpdYOrtaWNK17RvIk0PgnM2d0Vvhn4faNcnRX
YW8J+UmvRQmBfHGHNTPg1/TXogmHejAtb1fvxh2gwMmgUVZXy9Nr5qj9NryTZjlU
lYhRsI+L7IS37oNQE+eU/TqlILTzPdNmVssrwQymhnPy42XtYQugoA==
=hcLr
-----END PGP SIGNATURE-----

--ZPt4rx8FFjLCG7dd--