From: tanith@csd4.csd.uwm.edu (Michael D Kretzer)
Subject: Re: Writing Device Drivers for OS/2 2.0
Originator: tanith@csd4.csd.uwm.edu
Reply-To: tanith@csd4.csd.uwm.edu
Organization: University of Wisconsin - Milwaukee
Date: Fri, 21 Aug 1992 17:42:05 GMT

From article <1992Aug21.151852.8673@natinst.com>, by ramdas@natinst.com (Malathi Ramdas):
> 
>     I am in the process of writing an instrument control character based devcie
> driver for OS/2 2.0. The device driver architecture under OS/2 2.0 is still
> 16-bit. Does that mean that I need to generate 16-bit device driver code. (ie:
> generate code using a 16-bit compiler and 16-bit linker). Also, what would
> be the address format of the data address in an IOCTL request packet passed by
> the kernel on behalf of an application making a DosDevIOCtl API call to my
> device driver? Would it be in a 16:16 (selector:offset) form or a 0:32 
> address form (flat address)? Would it depend on whether the application is 
> 16-bit or 32-bit? From what I read all 16-bit processes  get tiled
> into a flat virtual address space. I hope to hear that all virtual addresses
> that gets passed to my driver is in a 0:32 bit form.

Right now, PDDs (Physical Device Drivers) are 16-bit.  However, object
files must be linked with the new LX linker (i.e. link386) if they are
OS/2 2.0 device drivers and not OS/2 1.x device drivers (although most
1.x device drivers work just fine under OS/2 2.0).

Request packets are passed to the device driver from the operating system
in 16:16 form, regardless of the type of program that made the IOCTL
request.  The request is sent to the operating system first, not the device
driver, and it creates a request packet for the device driver in 16:16 form.

Be aware that VDDs (Virtual Device Drivers) which are used for DOS are
32-bit (just to confuse the issue).

>    Is there a 32-bit assembler that goes out with OS/2 2.0. I still have the
> masm assembler that is 16-bit. I have not received anything along with toolkit

MASM 6.0 is a 32-bit assembler (when used in conjunction with LINK386).
One of the updates from MASM 5.1 was to include support for the FLAT model.
OS/2 2.0 programming considerations are even mentioned in the manual
explicitly.  (MASM 6.0 will also produce 16-bit executables, of course).
In conjunction with the Toolkit, MASM 6.0 is a full 32-bit/16-bit OS/2 2.0
assembler.

I have written several OS/2 2.0 device drivers personally, and have
used MASM 6.0 for all of them.  I typically use a C compiler to write
the bulk of the driver code (Microsoft C 6.0 and IBM CSet/2),however,
and Assembler for time-critical routines and a few miscellaneous other things.

I urge you to check out the book 'Writing OS/2 2.0 Device Drivers in C'
by Steven J. Mastrianni.  He shows how a good portion of an OS/2 2.0
device driver can be written in C, thus saving a great deal of time
in the development cycle of your driver.  Also, Mastrianni's book includes
a good number of device driver source code listings that are quite scarce
in other Device Driver books.  None of these books replace IBM's
Physical Device Driver Reference from the Technical Library, though...this
is required reading for anyone considering writing a device driver (it's
just very short on giving practical source code examples).

Xref: sparky comp.os.os2.programmer:4386 comp.os.os2.apps:5473