![]() College of Engineering & CS Wright State University Dayton, Ohio 45435-0001 |
EGR 199: Fundamentals of Engineering Device Drivers |
This article is about software components known as device drivers. This is third in a series of modules on computer hardware related topics for a class on freshman engineering. It assumes that the student is already familiar with the internals of a PC, local area network setup, Web, and HTML authoring.
http://thetech.pcwebopedia.com/TERM/d/driver.html defines a device driver as
"a program that controls a device. Every device, whether it be a printer, disk drive, or keyboard, must have a driver program. Many drivers, such as the keyboard driver, come with the operating system. For other devices, you may need to load a new driver when you connect the device to your computer. In DOS systems, drivers are files with a.SYS extension. In Windows environments, drivers often have a.DRV extension.
A driver acts like a translator between the device and programs that use the device. Each device has its own set of specialized commands that only its driver knows. In contrast, most programs access devices by using generic commands. The driver, therefore, accepts generic commands from a program and then translates them into specialized commands for the device."
But, this is a sloppy definition. It is our goal to explain what a device driver is in a more precise manner. In order to do that, we need to understand the following.
The architecture of a computer system is the combination of the architectures for the hardware and systems software. By hardware we mean the motherboard, the plug in cards, the devices connected to these, etc. By systems software we mean the BIOS, and the operating system; we exclude all applications such as MS Word, and Netscape.

A modern motherboard has several PCI bus slots, one or two ISA bus slots, and one AGP slot. A card plugged into one of these slots is generally a device card. Each device communicates with the CPU on the motherboard via the bus. Some devices can communicate with CPUs in a very speedy manner using Direct Memory Access. Such a communication uses "resources."
![]() |
A resource is defined, in this context, as an IRQ channel,
an I/O port, a memory block, or a DMA channel.
There are 16 IRQ lines used to signal the CPU that a peripheral event has started or terminated. Except for PCI devices, two devices cannot use the same line. However, IRQ 2 is lost because it is used to connect to the second interrupt controller chip making IRQ 9 and IRQ 2 are the same. All the IRQs except for 10, 11, 12 and 15 are pre-assigned. If a second parallel port is not used, IRQ 5 is available. IRQ 9 is also often available as most VGA cards do not require an IRQ. Thus IRQs 5, 9, 10, 11, 12 and 15 are arbitrarily used for scanners, SCSI boards, CD-ROM controllers, sound boards and any other peripheral that can be attached to a PC. |
Direct Memory Access is a specialized circuitry or a dedicated microprocessor
that transfers data from memory to memory without using the CPU. In the PIO
mode, data is first transferred from device to CPU, and then to memory.
Although DMA may periodically steal cycles from the CPU, data is transferred
much faster than using the CPU for every byte of transfer.

| DMA Used for 0 8-bit transfer 1 8-bit transfer 2 Floppy disk controller 3 8-bit transfer 4 Cascaded from 0-3 5 16-bit transfer 6 16-bit transfer 7 16-bit transfer |
On PCs, there are eight DMA channels commonly used as
follows. Most sound cards are set to use DMA channel 1. There are various modes of data transfer on IDE disk drives. The PIO
(programmed IO) modes use the CPU, and the DMA modes bypass the CPU. |
The operating system (OS) of a computer manages the hardware resources and provides an environment that allows the users' applications to run. The operating system is divided into the routines that make up the kernel and the programs that make up a broad set of utilities. At the center of the operating system is the kernel which performs the following low-level functions:
Programs request operating system services such as input and output by invoking an appropriate system call, for example, a request for action from the kernel, such as 'read n bytes from a file from the current position'. A system call is an entry point directly into the kernel. (The terms "operating system" and "kernel" are sometimes used interchangeably.) The set of entry points into the kernel code that allow programs to make use of facilities such as device access, is known as the system call interface.
Hardware devices are called plug-n-play (PnP) if they meet certain conditions.
A legacy device is a device requiring a certain resource setup to maintain
1980s PC compatibility. Devices like Floppy controllers, Real Time
Clocks, Keyboard Controllers, DMA controllers, Timers, etc. have inherited fixed
sets of resources from the original IBM standards.
Ideally, a modern PC should have a PnP BIOS on the motherboard, no non-PnP devices, and a PnP aware Operating System. A modern BIOS has a setup option called "PnP Aware OS Installed (Yes/No)". When set to Yes, the BIOS only does the bare minimum setting up work to get the OS booted up. All devices not required for the boot process are deliberately left in their unconfigured, inactive state. The OS is expected to 'finish' the job of getting the devices configured into a conflict-free state. Windows 95, 98 and 2000 are capable of this; DOS, Windows NT and Linux are not.
Most PnP BIOS's have an extra CMOS memory - usually between 4k and 16k long. This is referred to as the ESCD and it holds the complete record of how the system was configured the last time it was booted. The ESCD can also contain information about non-PnP devices. This can be inserted by a PnP aware Operating System, or the PnP BIOS can discover these devices manually. The message "Updating ESCD" you see when most modern systems boot is simply the BIOS's way of telling you it's finished sorting out the PnP configuration and is saving it to the ESCD CMOS memory. It takes a second or two simply because of the way the ESCD CMOS is designed.
Dynamic linking provides a mechanism for linking applications to libraries of functions at run time. The libraries reside in their own executable files and are not copied into an application's executable file as with static linking. These libraries are "dynamically linked" because they are linked to an application when it is loaded and executed rather than when it is linked. When an application uses a DLL, the operating system loads the DLL into memory, resolves references to functions in the DLL so that they can be called by the application, and unloads the DLL when it is no longer needed. Dynamic linking can be performed explicitly by applications or implicitly by the operating system.
DLLs are designed to provide resources to applications. Many applications can use the code in a DLL, meaning that only one copy of the code is resident in the system. Also, it is possible to update a DLL without changing applications that use the DLL, as long as the interface to the functions in the DLL does not change.
Software developers can extend the Windows environment by creating a DLL that contains routines for performing operations and then making the DLL available to other Windows-based applications (in addition to internal Windows routines). DLLs most often appear as files with a .DLL filename extension; however, they may also have an .EXE or other filename extension.
[The following is taken verbatim from Microsoft literature.] The operating environment for Windows 95/98 consists of a computer's hardware devices and the following software components:
A device driver is code that an operating system uses to control disk
devices, display adapters, input devices such as a mouse or trackball, modems,
fax machines, printers and other hardware. Windows requires device drivers
for the display, keyboard, and communication ports. Other drivers may also be
required if the user adds optional devices to the system.
It is our goal to explain what a device driver is in a more precise manner than the definition that we started off with.
A device driver is a set of routines statically (i.e., well ahead of need, once and for all) or dynamically (i.e., just when needed) linked into the kernel. These routines are used as part of the mechanism to translate the general "file" (even a keyboard can be thought of as a file) handling system calls into commands that will operate the specific peripheral device. Because the operating system handles general I/O management, the device driver must fulfill a request by manipulating the hardware. The device driver handles interrupts raised by the corresponding device. The device driver is the only place where IO ports are read or written. Separating the responsibilities of the device driver from the rest of operating system results in the ability to add new devices without having to change the operating system.
A Windows device driver is a DLL that Windows uses to interact with a hardware device, such as a display or keyboard. Rather than access devices directly, Windows loads device drivers and calls functions in the drivers to carry out actions on the device. Each device driver exports a set of functions; Windows calls these functions to complete an action, such as drawing a circle or translating a keyboard scan code. The driver functions also contain the device-specific code needed to carry out actions on the device.
Writing device drivers requires three skills.
In this Lab on Device Drivers, we will be only observing various related items. Our lab machines are setup so that students do not have the privilege to change device driver settings. If you have somehow managed to change the settings, and receive an advice from the system to shutdown and restart in order for the changes to take effect, please inform your TA and the professor before continuing further.
The System Properties applet on the PCs in the 141 RC lab have been partially disabled. So, follow the alternate procedure shown below as section 1.1 when you are in the 141 Russ, and follow section 1.2 when you are experimenting with your own PC.
For a device to work properly, its IRQ, IO ports, Memory Range, and DMA setting must match with those that the motherboard has set aside. A mismatch is known as a resource conflict. The Device Manager applet allows us to view and reset these resources.
The program named MSD.EXE (MS Diagnostics) can show details of a PCs internals about as well as the System Properties. But it must be run either in a DOS box within Windows, or more preferably you reboot the PC into MS-DOS and then invoke it.
![]() |
|
Q2: We would like you to explore the details of at least two drivers, and turn in your discoveries as a printed text file. Below our exploration of the display driver on a home PC is shown. A similar exploration is possible using MSD.EXE. Your turned in file should contain the IRQ, IO ports, memory range, and DMA information for each of the devices.
![]() |
|
![]() |
|
![]() |
|
![]() |
Q3: We installed a mouse enhancement package called MouseImp. With this enabled, you can scroll the contents of a window as follows. Right click the mouse, and move the mouse up/down while holding the right button. Try this and the usual scroll bar. After a few trials, write a paragraph describing how well this user interface enhancement works for you.
Q4: We installed a system configuration monitoring tool called X-setup. It is not a device driver. Nevertheless, it interacts with the OS and the registry at level comparable to device drivers, and has a direct correlation to how the computer system behaves. Explore the functionality of this tool. Its Help file is self-explanatory. As you explore what interests you in this tool, keep a journal and turn it in.
This step can take considerable amount of time.
| A few acronyms and their expansions are collected in the
table here. If you are curious about an acronym or term not listed, type
it in the input box below, and then press the button to look it up in the TechEncyclopedia. |
| pmateti@cs.wright.edu |