[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MiNT device drivers



Hello Roland,

> I'm trying to write a device driver for my new external keyboard. This is
> a DEC LK201 which outputs key scan codes on a serial interface.
> 
> What the driver basically has to do is:
> 
> 1) read and convert DEC key scans from the serial port and make them ready
> for reading.
> 
> Another thing thats not clear is how I supposed to wake up processes once
> they have been blocked. I understand I need to call wakeselect(), but where
> from? I don't see how the device driver gets any CPU time if only one
> process is using it, and its blocked. BTW I had a quick look at Thierry
> Bousch's modm0dev. There the solution seems to be an interupt routine on
> the 200ms clock. This seems a bit complicated - is it the correct solution?

	The big problem if you write your own driver is that it won't be
called in some emergency situations. If you type ^C or ^\ to kill a
runaway process, this will be ignored if this process does not deign to
read the keyboard :-)

	In fact, the MiNT kernel handles these keyboard "interrupts" in
a very ad hoc way, by directly peeking into the keyboard Iorec buffer at
regular intervals! It will not do it with your driver, obviously, that's
why you would need to fork a daemon process to check for this (or
better, use addroottimeout). If you don't mind writing a few lines of
assembler, I think a simpler solution would consist in adding a hook to
the RS232 receiver interrupt routine, which will pop the incoming
scancodes from the rs232 iorec buffer, convert them, and push them into
the keyboard iorec buffer. This is not very clean, but the problem
really lies in the brain-dead MiNT interface to tty drivers.

Thierry.