The company I work for has created a baseboard for a Computer On Module. On the baseboard is a little microprocessor that talks to the COM via a RS232 port. On the COM module I run a 2.6 kernel with a home grown root file system and some applications I developed. The little micro (an ATTiny2313) controls, amongst other things, an on/off switch.

At the moment when the user flicks the switch the micro sends a messages over the serial line to the module. My application program has opened a standard serial device and receives this message. Upon receipt of this message my application program makes preparations for the system to power down.

My problem is this: If my application is not running or is frozen in some way, the device does not shutdown properly. I therefore thought it better, and more stream lined, that a kernel driver should communicate with the micro. The driver would then be able to tell the kernel to go through proper shutdown procedures regardless what else is going on in userland.

As the micro is doing some other things, the driver should also expose an interface to userland, maybe application code could connect via a "socket device".

Reading through various device driver books and articals I now have difficulty figuring out where to start. I wonder what kind of driver could be build on top of (or using) the standard serial driver. So far everything I read talks about drivers that sit between the hardware and userland, but what about a driver that sits between the standard serial driver and userland with some provisions to call kernel functionality.

If someone could tell me what kind of driver would fit here and point me to some relevant documentation, I would be gratefull.

Thanks in advance