Subject: Re: Machine-independent device drivers
To: None <, tech-kern@NetBSD.ORG>
From: Wolfgang Solfrank <>
List: tech-kern
Date: 04/13/1995 14:50:19
> * Different machines map device registers and memory differently.
> * In some cases, multiple mappings are possible on the same machine.
> * In some weirder cases, you might even have one device mapped in I/O
> space, and another one of the same type mapped in memory space, on the
> same machine.

While I see the point in the latter, I don't think that we will want to
pay too much penalty for flexibility (which is a range, and not a black-white

Some of you might already know that I'm running a portable wd.c driver on
my PC for quite a while now. Unfortunately I'm too busy right now, so I
hadn't have the time to really prove its machine independence by using it on
another machine (I'm working on this in whatever little spare time I can get).

My current version works by using macros for port access, and a typedef for
the port address. These are separated in a <machine/isa.h> include file
(file name is probably subject to change). For the PC it looks similar to:

typedef	int	isa_port;
#define	isa_readb(base, port)		(inb((base) + (port)))
#define	isa_writew(base, port, data)	(outw((base) + (port), (data)))

As far as I can tell, the generated code is the same as with the current
machine dependent code.

To support machines with more than one type of ISA (or IDE) attachment, I'm
willing to accept an additional argument to the macro with the softc
structure of the driver (or the isa bus?), but I'd be very unhappy if I
couldn't generate code like the above with proper definition of the macros.

ws@TooLs.DE     (Wolfgang Solfrank, TooLs GmbH) 	+49-228-985800