home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 1
/
FishNMoreVol1.bin
/
more
/
code_examples
/
device
/
device.arc
/
DOSDEV.DOC
< prev
next >
Wrap
Text File
|
1987-10-23
|
4KB
|
110 lines
DOS device driver example for AZTEC C
By Matthew Dillon ... for all those people out there (including me!)
who have been struggling with DOS devices. Placed in PUBLIC DOMAIN.
Documentation is sorely lacking... even the RKM examples are sorely
lacking. What programmers need is a working example ... as full an
implementation as possible to figure out all the little DOS quirks that
the manuals don't tell you about... Little things like when the driver
stores a string in a structure it must be in BCPL 'length first'
format. There are literally hundreds of these babies!
REQUIREMENTS:
-Aztec C compiler
-A precompiled symbol table of all sub-directory include's (*/*.H). i.e.
one which does NOT include top level stuff like <stdio.h>. Remember to
compile with the +L option when generating the symbol table.
The LARGE data and code model will be used... It makes life *much*
easier. This will NOT effect performance as there are very few global
elements anyway.
*Alternately, no requirements if you just want to look at the source.
MOUNTLIST:
You will want to change this to a more permanent file path, obviously,
though to run the example you might as well leave the driver in RAM:
THE EXAMPLE:
How 'bout a RAM disk? RAM disks use most DOS packet types... Since my
RAM disk is not meant for normal usage, There will be a lot of minor
items I will leave unimplimented:
-Date stamps are not kept up. In fact, they are garbage.
-I don't check out-of-memory conditions (remember! This is ONLY an
example!)
-The driver EXIT's if no files exist and no references exist.
This allows you to FLUSH (make flush), which should remove all
knowlege of the driver allowing you to make source changes,
recompile, and re-reference without changing the name or
rebooting. Normally, disk-like devices are permanent fixtures.
-The ARCHIVE protection bit is not supported
All packet types normally associated with a RAM disk are supported,
Most especially LOCKS, which *many* people have not been able to figure
out in the past.
DEBUGGING:
Since this is an example, FULL Debugging has been implemented. Since
the DOS device driver cannot make DOS library calls itself (confusion
on the message port), CreatProc() is used to create a secondary process
which will do actual printing of the debugger messages. The messages
are then sent to the debug process via a dedicated message port.
Since Debugging causes a huge efficiency decrease, and since you are
going to want to fool around with the device, you can turn off debug
error message output by:
CD test:
type debugoff (will get an error, but debugging will be turned
off)
alternately, 'type debugon' will turn it back on.
The debugging code itself is a good example.
DOS:
Remember that most addresses are passed as BPTR's, and most strings are
passed as BPTR's to a BSTR (length in byte 0, string in bytes 1..N, no
'end' bytes). The exceptions are obvious by looking at the code (at
least of the packet types supported).
DOS PECULARITIES NOT ADDRESSED:
Newcli assumes it can open the file '*' on whatever device you specify
for the control terminal to get a duplicate stream. This is how it
gets around CON-like devices which like to create separate processes
for each invocation.
ACTION_DISK_INFO, when sent to a CONSOLE device, will return the window
associated with the console as follows:
id_VolumeNode = console window
id_InUse = console IO blvock
There are probably many more.
Matthew Dillon
ARPA: dillon@ucbvax.berkeley.edu
UUCP: ..!ihnp4!ucbvax!dillon
SNAIL: Matthew Dillon
891 Regal Rd.
Berkeley, Ca. 94708