Subject: Re: Format of "files" file ?
To: None <davem@eastcoast.co.za>
From: Colin Wood <cwood@ichips.intel.com>
List: tech-kern
Date: 02/15/1999 12:38:47
davem@eastcoast.co.za wrote:
> Hello
> 
> What is the syntax for entries in the sys/conf/files file ?

it varies, depending on what kind of entry you're adding.  you can take a
look at the other entries in that file for more examples, and there are
also examples in each port's machine-dependent files.<port> file (in
sys/arch/<port>/conf/files.<port>.
 
> For e.g. what does "needs-flag" mean. 

from what i've managed to determine (and i'm probably managing to miss
it's real purpose), the "needs-flag" makes sure that you have a file
created by config named <device>.h, where <device>  is the name of the
device which appears before the "needs-flag" qualifier.  this file will
contain a line like:

#define N<DEVICE>	<num>

where <DEVICE> is the name of the device in all caps, and <num> is the
number of devices configured into the kernel.  you can then wrap all of
your device driver files by a sequence like:

#include "<device>.h"
#if N<DEVICE> > 0

	code

#endif

so that it doesn't get unnecessarily added in places where it shouldn't if
it hasn't been explicitly configured into the kernel.


> I need to add entries for my own device driver(s) which I'm also 
> figuring out how to write, but I want to start off writing AND 
> installing AND testing a trivial driver (probably a pseudo-device that 
> returns a string), just so I know how all this fits together, but I can't 
> even figure out the syntax of the sys/conf/files file. Is there some 
> secret source of info for this stuff ?

nope.  this is definitely a UTSL (use the source, luke) kind of situation.
there isn't a whole lot of documentation on this, unfortunately.  the best
sources of info so far are the options(4) manpage and the various section
9 man pages.  in addition, there's a short kernel programming FAQ on
www.netbsd.org.  and as i mentioned above, there's always the source.
 
> Ultimately I need to write a PCI driver for an intelligent ISDN card 
> (i.e. with embedded protocol stacks on the card).
> 
> Any help with device drivers, in particular for NETBSD would be 
> appreciated.

here is a brief list of things i did when i was writing the -current
mac68k keyboard and mouse driver.  we used to have a monolithic ADB 
driver.  now adb.c is the bus driver, while kbd.c and ms.c are the
keyboard and mouse drivers, respectively.  perhaps the outline will help
you some:

1) Add ms.c, msvar.h in mac68k/dev
2) Add kbd.c, kbdvar.h in mac68k/dev
3) Add #includes for ms.h and kbd.h in mac68k/mac68k/conf.c
4) Add cdev_decl()'s for ms and kbd drivers in conf.c
5) Add cdevsw[] entries for ms and kbd drivers in conf.c
6) Add NODEV entries for ms and kbd drivers in chrtoblktab[] in conf.c
7) Add device declarations for ms and kbd drivers in
   mac68k/conf/files.mac68k
8) Add device attachment lines to config file (mac68k/conf/GENERIC)
9) Add adbprint() function to adb.c
10) Add appropriate printing of devices in attach functions
11) Add printing for unsupported devices in adbprint()
12) Add kbd_softc and ms_softc structures
13) Implement preliminary ms{open,close}(), kbd{open,close}()
14) Implement kbd ioctl()'s to get and set LED values and return the
    keyboard type
15) Implement {kbd,ms}{read,poll}(), add necessary state to softc's

later.

colin