Subject: device driver poll() example
To: None <tech-kern@netbsd.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-kern
Date: 08/19/2004 05:29:05
NetBSD IANZAG 2.0G NetBSD 2.0G (IANZAG) #0: Thu Jul 29 09:08:20 NOVST 2004  
ianzag@IANZAG:/usr/src/sys/arch/i386/compile/IANZAG i386

For our hardware i wrote several custom character device drivers and i would 
like to implement poll() call. Actually, i want to use select() call inside 
my userland program to wait for some event and afaiu poll function in driver 
is responsible for this. I checked existing drivers in /sys/dev/ic and found 
that all of them use upper TTY level and just redirect there poll event. On 
the other hand, our devices and drivers due to its logics arn't ttys and i do 
no attach my character device to tty level.

Where i can find some simple example how to implement poll call in device 
driver independently to tty level ? For example, @user level i'd like to 
issue read select() and be unblocked when device receives interrupt request.

My guess is that i can just sleep() inside poll handler and wakeup() process 
from interrupt handler and this should satisfy userland poll/select calls. Am 
i right in my guess or some more complicated handling required?

// wbr