[comp.sys.ibm.pc] DEVICE DRIVERS

lal@tc.fluke.COM (Larry Lohkamp) (02/06/89)

I find that I have to write a device driver for a custom I/O board. Can someone send me an outline (in turbo C hopefully) that will show me how to handle instalation and interrupt servicing. I am using DOS 3.2.

fargo@pawl.rpi.edu (Ethan M. Young) (02/07/89)

I too am interested in writing device drivers in either Turbo C or Turbo Pascal
I have IBM's DOS Technical Reference Manual for DOS v3.00, but they only give
examples in assembly language.

Thank you and happy hunting!   Internet: fargo@pawl.rpi.edu
    ____    [> SB <]                     fargo@{paraguay|uruguay}.acm.rpi.edu
   /__      -=>??<=-        Bitnet (??): usergac0@rpitsmts.bitnet
  /   ARGO : 3000 years of regression from the year 4990

izumi@violet.berkeley.edu (Izumi Ohzawa) (02/07/89)

In article <509@rpi.edu> fargo@pawl.rpi.edu (Ethan M. Young) writes:
>I too am interested in writing device drivers in either Turbo C or Turbo Pascal
>I have IBM's DOS Technical Reference Manual for DOS v3.00, but they only give
>examples in assembly language.
>

I don't think you can write DOS Installable device drivers
(those you install with DEVICE= ...  line in CONFIG.SYS) using
Turbo C or Turbo Pascal or MSC.  I wouln't say never, but
it sounds awfully difficult.

You could write a TSR driver which does equivalent things, but
you will lose the ability to open the device via standard
library functions like;

     fp = fopen("DEVNAME", "wb");

With a TSR driver, you usually have to do I/O functions via
software interrupt calls.  If you don't need these devices to
work at DOS level, i.e., if you access these devices only from
your application programs (e.g., D/A or A/D converters),
writing the driver as a TSR is the easiest way.  And Turbo C and
Turbo Pascal do allow that.

Izumi Ohzawa

gbs@stratus.UUCP (George B. Smith) (02/08/89)

In article <20044@agate.BERKELEY.EDU> izumi@violet.berkeley.edu (Izumi Ohzawa) writes:
>In article <509@rpi.edu> fargo@pawl.rpi.edu (Ethan M. Young) writes:
>>I too am interested in writing device drivers in either Turbo C...
>I don't think you can write DOS Installable device drivers
>(those you install with DEVICE= ...  line in CONFIG.SYS) using
>Turbo C or Turbo Pascal or MSC.  I wouln't say never, but
>it sounds awfully difficult.
>...
>Izumi Ohzawa

Sorry to counterdict you, Izumi, but the latest issue of "The C Users
Journal", Feb. 1989 has an article by a Robert Allen titled "Writing
Device Drivers With Turbo C."  The first paragraph goes like this:

"I read with interest the article "Writing MS-DOS Device Drivers" by
Phipip J. Erdelsky in the V6/N7 of "The C Users Journal."  In the last
few years I have written three different device drivers for MS-DOS,
each to perform fully buffered serail communications.  The first driver
was written in assembly, the second was attempted in Lattice C v3.0, 
but it became so cumbersome I reverted to assembly.  Finally, on my
third attempt I found a compiler, Borland's Turbo-C, that makes the
writing of device drivers in C very simple."

George B. Smith
Stratus Computer, Inc
gbs@stratus.stratus.com
{amdahl,oliveb,uunet}!stratus!gbs

py@geac.UUCP (Peter Yeung) (02/09/89)

There is an article in "Dr. Jobb's Journal, September 1987" called
"Writing MS-DOS Device Drivers in C". In the article, Aztec C was used as
an example. However, it is very easy to use the same idea in Turbo C (hint:
unarc the startup code 'c0.asm' and rewrite it). I am writing a device driver
in Turbo C and found the article really valuable. The book "Writing MS-DOS
Device Drivers" by Robert Lai (Addison-Wesley Publishing Company) is also a
good reference in writing device drivers.

Good luck!

Peter Yeung

-- 
Peter K.H. Yeung, Geac Computer Corp.
                  Markham, Ontario
                  Canada.
py@geac    or    {uunet!mnetor,yunexus,utgpu}!geac!py

few@quad1.quad.com (Frank Whaley) (02/09/89)

In article <20044@agate.BERKELEY.EDU> izumi@violet.berkeley.edu (Izumi Ohzawa) writes:
>In article <509@rpi.edu> fargo@pawl.rpi.edu (Ethan M. Young) writes:
>>I am interested in writing device drivers in either Turbo C or Turbo Pascal
>>I have IBM's DOS Technical Reference Manual for DOS v3.00, but they only give
>>examples in assembly language.
>
>I don't think you can write DOS Installable device drivers
>(those you install with DEVICE= ...  line in CONFIG.SYS) using
>Turbo C or Turbo Pascal or MSC.  I wouln't say never, but
>it sounds awfully difficult.

Normally I just respond through the mail, but since this might be of
marginal net interest...

I wrote a package that allows you to develop Installable Device Drivers with
Turbo C (1.5 or 2.0).  It is available (as source) in a 30K 'shar' file
free for the asking.  I'll even add your name to my mailing list for future
updates, should I actually have any.

I used to support Lattice C and MSC, but now I'm a 'Turbo Guy'.  The C
Users Group in Kansas is still shipping the original version, I think.

I used to think this was difficult, but now it's not very impressive.  It
helps to understand the '86 architectures and the way DOS interacts with
Device Drivers.  A sample driver is included in the package (MONO.SYS, which
creates a device named MONO that controls a monochrome video adapter).

-- 
Frank Whaley
Senior Development Engineer
Quadratron Systems Incorporated
few@quad1.quad.com
uunet!ccicpg!quad1!few

Water separates the people of the world;
Wine unites them.

sac90286@uxa.cso.uiuc.edu (02/09/89)

There is a file called TCDEV.ARC which is a device driver skeleton into
which you can put your interface functions. Compiling the result produces
the driver. It's available on LOTS of bulletin boards, so you should have
no trouble finding it.

bass@utkcs2.cs.utk.edu (Vance Bass) (02/09/89)

In article <20044@agate.BERKELEY.EDU> izumi@violet.berkeley.edu (Izumi Ohzawa) writes:
>I don't think you can write DOS Installable device drivers
>(those you install with DEVICE= ...  line in CONFIG.SYS) using
>Turbo C or Turbo Pascal or MSC.  I wouln't say never, but
>it sounds awfully difficult.

It's not too bad, actually.  The following is all from memory, but it's
fundamentally correct and should be recreatable from the usual
information (i.e., the DOS Tech Ref).

Several years ago I got driver source and a small executable from a guy
who had simply figured out how to convert the DOS executable header to
the DOS device driver header.  The device driver header is well-documented,
and I believe the executable header can be found in the Tech Ref, too.
The only trick, as I remember it, was that you had to put the strategy
routine first to simplify getting its address for the driver header.

The memory really starts losing multiple bits here, so I'll leave it at
that and let younger, more agile minds flesh out the details.  SMOP,
right?

-- 

Vance Bass			The opinions expressed here are strictly
IBM M&SG			my own, and do not necessarily
Knoxville, TN			represent IBM's views on the subject.

pilgrimk@lafcol.UUCP ([7m[5mPERVERT[0m) (02/10/89)

Has anyone written/come across a program which installs and removes
device drivers on the 'fly'? i.e. If I wnated to load ANSI.SYS and
replace the already installed SAS.SYS, the program would take care
of this.

*Note: I should NOT have to reboot the system to remove existing
       drivers.

This program should be written for MSDOS.

Any pointers or source code would be appreciated. Please use email.

-Thanks, Kenwyn