Subject: Re: Writing a simple device?
To: Jukka Marin <>
From: Jeremy Cooper <>
List: tech-kern
Date: 07/22/1997 13:29:57
On Tue, 22 Jul 1997, Jukka Marin wrote:

> [ writing a simple device driver ]
> Where can I look for examples? [...]
> What if the device needs so CPU attention every now and then - can I
> hook it to some clock interrupt to get some minor tasks done?

For an example, I suggest you look at the driver code for /dev/null
(seriously!)  Although it can vary from architecture to architecture, you
will usually find it in the file arch/<arch>/<arch>/mem.c.  You'll notice
that /dev/null, /dev/mem, /dev/kmem and others are actually sub-devices of
the generic 'memory' driver.

The portable interface for scheduled events is the timeout(9)
function.  Every port supports it.  It may be documented in the current
section #9 of the man pages.

Although I'm not an LKM expert, I can tell you that the essential parts of
a driver remain unchanged when it is made into an LKM.  It's the
attachment routine (the part where your driver establishes itself in the
kernel) that is slightly different.