[comp.os.msdos.programmer] Communicating With Resident Programs

gday@digigw.digital.co.jp (Gordon Day) (10/01/90)

Could somebody suggest the best way to communicate with a driver?  I have 
successfully implemented a block device driver, but I am at a loss as to the
best way to communicate with it from a transient program.  I have come up 
with three ideas, both with advantages and disadvantages:

1. Search through available user interrupts (0x61 - 0x67) for a free one and
use that.
	Advantages: easy
	Disadvantages: All may be used, a poor program may override the vector.

2. Use Multiplex Interrupt (0x2f) 
	Advantages: easy, better than #1 for safety
	Disadvantages: ID value may already be used (although smaller odds than #1)

3. Chain through device headers searching for signature
	Advantages: almost 0 chance of interference ~length(signature)^256 odds,
	Disavantages: requires undocumented system call, access to o/s structures.


Any help regarding this matter would be appreciated (I'm swaying between 2 & 3)

Gordon W. Day

ekalenda@cup.portal.com (Edward John Kalenda) (10/02/90)

Gordon W. Day writes:
> Could somebody suggest the best way to communicate with a driver?  I have 
> successfully implemented a block device driver, but I am at a loss as to the
> best way to communicate with it from a transient program.  I have come up 
> with three ideas, both with advantages and disadvantages:

The best way is to use the generic ioctl function. INT 21h, function 44h,
sub-function 0Dh allows your application to send and receive driver
specific messages.  Page 466 of the MS-DOS Encyclodedia talks about it.

Ed
ekalenda@cup.portal.com

phys169@canterbury.ac.nz (10/02/90)

In article <679@digigw.digital.co.jp>, gday@digigw.digital.co.jp (Gordon Day) writes:
> Could somebody suggest the best way to communicate with a driver?  I have 
> successfully implemented a block device driver, but I am at a loss as to the
> best way to communicate with it from a transient program. 

The "correct" method, from DOS 2 onwards, is probably to use the IO Control
facility, i.e. set the IOCTL bit in the attribute word of the header (bit 14),
and provide a method of reading and writing bytes with command codes 3 & 12
(respectively) passed from DOS to the driver when you  use certain DOS function
0x44 calls. If you can't find it in the manual call me and I'll explain it a
little better, perhaps send you/post some code. 

Using "spare" interrupts around $60-$6F might clash with DECnet DOS software
(which uses a great number of them). Using interrupt 0x2f is a little better,
but the IOCTL method is best (though rarely used, goodness knows why).

Mark Aitchison, Physics computologist, University of Canterbury, New Zealand.

snow@runxtsa.runx.oz.au (Ned Snow) (10/03/90)

In article <679@digigw.digital.co.jp> gday@digigw.digital.co.jp (Gordon Day) writes:
>Could somebody suggest the best way to communicate with a driver?  I have 
>successfully implemented a block device driver, but I am at a loss as to the
>best way to communicate with it from a transient program.  I have come up 
>
When I implemented a device driver ( to deal with serial input in a C program)
I used the ioctl functions to communicate with it. To do this, you must set
the ioctl bit in the device header, and provide code for the ioctl input
and output functions ( 3 for input, 12 for output ). The transient program
can then use dos function 44h to send/receive strings to/from the driver.

>Gordon W. Day

Ned