Subject: Re: Device driver implementation question
To: None <,>
From: Chris Torek <torek@BSDI.COM>
List: tech-kern
Date: 01/18/1997 05:22:26
>For instance, the current isa code does something like:

>	for (each device) {
>		rv = device's match result
>		if (!rv)
>			continue;
>		attach device
>	}

>There's no reason that that couldn't be changed to do something like:

>	for (each device) {
>		rv = device's match result
>		if (!rv)
>			continue
>		if (some other (perhaps failure?) condition)
>			continue
>		attach device
>	}

I am no ISA expert, but this is indeed the general idea -- for
instance, on the VAX-780 Unibus, one checks some kind of magic
error registers as the `failure' condition.  (I am not sure what
that code was for, but know it was there originally, so the design
allowed for it.)

>There are drivers in the tree (__BROKEN_INDIRECT_CONFIG or not) which
>currently violate these rules. ...

As an aside, it is okay to violate the rules as long as you know
just how you are violating the rules. :-)

In particular, it is wrong to leak storage, but if you do it, the
system is probably going to work anyway.  Best to mark it XXX and
comment as to what is wrong there, though, lest someone else copy
it and make things worse.  There are also some really horrible gross
bootstrap cases (like console serial ports) where you may decide to
do static allocation of certain structures instead of the `clean' (?)
solution of having a software layer to make the hardware look like
it was designed sanely in the first place, but again this is really
just a case of expediency.