On Apr 19, 2007, at 3:20 AM, Sridhar Ayengar wrote:
In truth it
is really not all that difficult. The BIOS
interface is very simple and well-defined. Under the tutelage of
an experienced mentor, I was writing BIOS code on my Imsai when I
was about fourteen. It's nothing like the complexity of, say, a
device driver system for an implementation of UNIX.
How does it differ? Aren't all drivers just fundamentally open,
close, read, write and ioctl?
All UNIX-ish drivers are. ;) A CP/M BIOS is much simpler than
that. Assuming CP/M v2.2 (the only version I've worked with) there
are only (IIRC) seventeen routines which must be written, and they're
all very low-level.
There are console I/O routines like CONIN and CONOUT, which just
get/put bytes to/from the console UART in the simplest of
implementations, or they may manage buffers and interrupt service
routines for more "fancy" serial I/O. There's SELDSK, SETTRK and
SETSEC, which set the active disk drive, and track/sector numbers for
the next transfer. Then there's READ and WRITE which, in a simple
polled/non-DMA BIOS, can be less than half a page of assembly
language. To CP/M, every mass storage device looks like a rotating
disk with tracks and sectors.
There are a few others, again seventeen if memory serves...READER
and PUNCH, which are character-by-character reader and punch I/O,
etc. There's LIST (printer output), WBOOT (warm boot), BOOT (cold
boot)...not much else.
So my point is that these routines are lower level and much less
generalized than what we'd think of as a device driver in a modern
UNIX-based OS.
-Dave
--
Dave McGuire
Port Charlotte, FL