How do I get started writing OS/2 device drivers

By IBM

From: Solution Developer Support

Date: 1996-03-26

One of the most commonly asked questions is "How do I get started writing OS/2 device drivers"? Well, that depends on your background.

Writing OS/2 device drivers is not terribly difficult if you're already an experienced OS/2 programmer. Since device drivers interact with the OS/2 kernel, you should have a good understanding how the basic functions provided by OS/2, such as multi-threading, priorities, memory allocation, and addressing.

A majority of the questions we get involve a misunderstanding of how various types of addresses work. Driver developers must be able to work with virtual, linear, physical and real addresses. Since the device driver interacts with the processor at the machine level, a good understanding of the processor architecture is also invaluable. Failures in a device driver usually hang the system, and tracking them down can be tedious without knowing where to look.

So what tools will you need?

If you're writing your device drivers in C, which is recommended, you'll need a 16-bit C Compiler such as Microsoft C 5.1 or 6.0. You'll also need an assembler such as the Microsoft 6.0 Macro Assembler. Previous versions (5.1) of these tools will also work.

If you're developing Virtual Device Drivers, you'll need a 32-bit C compiler such as IBM C Set/2-C Set++(recommended) or the special 32-bit compiler CL386 which comes with the IBM Developer Connection Device Driver Kit For OS/2 (DEVCON DDK).

The IBM DEVCON DDK is available as a one year subscription with periodic updates. It is only available on CDROM. Call 1-800-633-8266 to order the DEVCON DDK (P/N 83G9641). The DDK includes online versions of the driver reference manuals.

Also included with the DDK is the kernel debugger, which you will need to debug your device drivers. You may also wish to use ASDT32, a debugger included with the DDK, or the Periscope Debugger, available commercially.

Included with the DDK subscription is a subscription to the OS/2 Developer Connection (DEVCON) CDROM. This is a separate CDROM which includes OS/2 development tools and tips. The DEVCON subscription comes with quarterly updates.


 * For documentation, you should get the OS/2 Technical Library, a collection of developer reference books, which include the OS/2 Physical Device Driver Reference, Virtual Device Driver Reference and Presentation Driver Reference (these three are on the DDK). The library is available as part of the OS/2 2.1 Online Book Collection CDROM.  Call 1-800-342-6672 to order it.

A book, "Writing OS/2 2.1 Device Drivers in C", by Steve Mastrianni, is available on CompuServe from Compubooks (GO CBK), from Van Nostrand Reinhold (800-842-3636), or from IBM (800-879-2755, P/N SR28-4392). It's the only tutorial on writing OS/2 2.x device drivers.

Another book, "The Design of OS/2", by H.M. Deitel and M.S. Kogan, provides an insight into the architecture of OS/2, multitasking implementation, memory management, and much more. This book (P/N S325-4005) is also available from IBM, as well as the publisher, Addison-Wesley Publishing Company.

For device driver developers, free support is provided by the Driver Development Support Center (DDSC) team, via their DUDE system, by calling (512) 838-9717. The communication parameters are N81, at 2400-14400 baud. Registration is done on-line. Questions are tracked by number, so you're assured that your question will get answered.

Periodically, the DDSC team archives the questions into a file after removing company and developer names, etc. This file is available for download by registered DUDE users.

Device driver workshops are also available through the DDSC team. For additional information and schedules, see the INFO file area on the DUDE.