Subject: Opinions: device driver architecture for special case
To: None <tech-kern@netbsd.org>
From: Bruce Martin <brucem@cat.co.za>
List: tech-kern
Date: 10/24/2001 14:05:53
Hi All

Just wanting to get some advice on device driver implementation for a project 
we are doing. We have threee pieces of hardware:
 - an ISA serial port card
 - a PCI I/O card
 - a piggyback serial card (same chipsets as ISA) that plugs onto the PCI I/O 
card above.

So, we have two serial cards. We want to access them identically from user 
space. That is, we want to do an:
 int fd = open("/dev/tty00",XXX);

In one system, will only be one of these two serial cards. We can determine 
in software whether the piggyback serial card is there, and if it is not, we 
know that the ISA card is present.

Does anybody know how we could do this? The problem I see is declaring two 
different things for the "same" device: e.g.
 tty00 at isa? ...
 tty00 at pci? ...
and things like
 attach tty00 at isa...
 attach tty00 at pci...

So, that is my first concern. Any suggestions on having two sets of files 
(only really having the bus space accesses to registers different) for a 
device with the same name, but mounted differently.

The next concern is interrupts. The serial piggyback will use the same 
interrupt line as the I/O card it is on. So, let's say an interrupt occurs, 
the I/O card gets it, and sees that it is not for it, but the serial card. 
Could I just return 0, and would this mean the serial card would check its 
interrupts, if it were sharing the same interrupt?

Last concern, I promise! ;) The accesses to both I/O Card and Piggyback 
Serial are through the same set of Base Address Registers, living on the I/O 
card. Can I map these same BARs for both drivers?

Thanks to anybody who reads through this whole email and responds!

Cheers
 Bruce Martin