Subject: Re: PR 4094 (really about FreeBSD's approach to one aspect of the DDI/DKI)
To: NetBSD-current Discussion List <>
From: Greg A. Woods <>
List: current-users
Date: 12/10/1998 12:57:44
[ On Thu, November 26, 1998 at 16:35:21 (-0500), Michael C. Richardson wrote: ]
> Subject: Re: PR 4094 
>     Greg> IMO FreeBSD gets a million miles closer to a complete solution and
>     Greg> is really only missing a wee tiny bit of glue (and an as yet
>   Can you tell us a bit more about the FreeBSD solution?

I'm probably not the best person to discuss this (I've only been a user
of the FreeBSD scheme through the development of a couple of small
drivers and porting of another), but since nobody else has contributed
any thoughts, here goes:

FreeBSD has eliminated conf.c (and more specifically the static
initialization of cdevsw and bdevsw, and in fact they've even merged
those two tables into one).

What they have is a runtime initialization of these structures that's
driven by a simple registration macro included in every driver.  That
macro is passed the driver's major number.  They also have a list of
major numbers in sys/i386/conf/majors.i386, but unfortunately they don't
yet have the glue which takes the major number out of that file and uses
it in the registration macro (and in /dev/MAKEDEV when DEVFS isn't being
used).  An example invocation of this macro is:

somewhere near the top of sys/i386/isa/fd.c:

	#define CDEV_MAJOR 9
	#define BDEV_MAJOR 2

right near the bottom of the same file:

	static fd_devsw_installed = 0;
	static void     fd_drvinit(void *notused )
	        if( ! fd_devsw_installed ) {
	                cdevsw_add_generic(BDEV_MAJOR,CDEV_MAJOR, &fd_cdevsw);
	                fd_devsw_installed = 1;   

I don't remember exactly how it all fits together under the hood though,
and it would seem they are changing some of this again since the 3.0
release, perhaps to add that missing bit of glue which would ensure
there's only one place where device numbers are defined.

Note that you can wander through the FreeBSD source tree (and their
copies of the 4.4BSD-Lite, NetBSD [from periodic imports?], and OpenBSD
trees) with their CVS WWW interface:


							Greg A. Woods

+1 416 218-0098      VE3TCP      <>      <robohack!woods>
Planix, Inc. <>; Secrets of the Weird <>