THE DRIVERS IMPORTANCE WITH EQUIPMENT OPERATION

Popova A., Cherednikova O.
Computer Sciences and Technologies Faculty
Boyko V., Technical Translating Supervisor
Donetsk National Technical University

Programming education cannot teach to be an expert,
as well as the study of brushes and paints cannot turn anyone into an artist.
(Eric S. Raymond – is an American computer programmer)

It all started with an idea to teach the machine count or at leas to sum up multi-digit numbers. As early as 1500 Leonardo da Vinci developed a sketch of the 13-bit summing device. It was the first attempt to solve this problem. The very first machine was constructed by the French physicist and mathematician Blaise Pascal in 1642. Almost 250 years later, the widely used aggregate-adding machine, that performed 4 arithmetic operations appeared. At the beginning of the XIX century the level of development of number of sciences and spheres of practical activity was so high, that they required a lot of computing , beyond human capabilities. Programming in our time is developing actively. New technological necessities appear. As a consequence, new devices that require new software system development are being created. So, system programming concerns with system software creation.

Let’s take to consideration, for example, an ordinary personal computer (PC) which is present in almost every house. As we see, in addition to standard PC devices, such as a monitor, a keyboard and a mouse, a variety of additional devices can be connected as well. Peripheral devices are connected to the computer via external interfaces or with the help of specialized adapters or controllers. The mean of docking of any device and any tire of a computer is an adapter and controller.

An exploded view of a modern personal computer and peripherals:

1–Scanner, 2–CPU (Microprocessor), 3–Primary storage (RAM), 4–Expansion cards (graphics cards, etc.), 5–Power supply, 6–Optical disc drive, 6–Secondary storage (Hard disk), 7–Motherboard, 8–Speakers, 9–Monitor, 10–System software, 11–Application software, 12–Keyboard, 13–Mouse, 14–External hard disk, 15–Printer

To connect all kinds of peripheral devices to a PC and to ensure their coordinated work, system programmers write software modules – drivers.

All modern operating systems turn to peripheral devices through drivers. Operating system always consists of a set of drivers for the standard computer hardware, such as disk devices or VGA video controllers. All other devices, as a rule, must be completed by the drivers created by the developers of these devices. An exchange between drivers and operating system is by means of queries. A query contains all necessary information for the operation of the device : what command to execute, how to turn data and others like that. Also a query is a standardized structure which greatly simplifies the work of the application programs to the device.

The purpose of one of the term papers on speciality “System programming” is to check the operation of the console driver, developed by Robert Ley. A device driver is a program that is built according to certain rules. They are defined in DOS and provide proper work of a driver. A driver consists of sections. Each of these sections contains assembler commands or data. Assembler commands unite in procedures. Variables are determined in memory; data that DOS passes to the driver are kept in them. Other variables are used to store text messages that are displayed. For the preparation of the driver source code a word processor is used. Then a macro assembler processes the text. The result of this process is the object code which passes editing of linkages (arrangement), an executable file turns out whereupon. Finally, it is converted to a file of "image in memory" for the proper execution of the operating system.

When the device driver is developed, it is loaded into memory. For this purpose the driver file is declared in the configuration file CONFIG.SYS, then the restart of DOS is produced. On the phase of initializing DOS reads the file CONFIG.SYS and copies the file of device driver to the memory area. Then DOS initializes device drivers so that they are ready to go.

A driver contains two basic procedures STRATEGY and INTERRUPT. Procedure STRATEGY contains commands that produce preparation of the device driver, and procedure INTERRUPT uses information from the procedure STRATEGY for the required operation execution. We remind that a two-step mechanism of commands transmission to the driver is built in DOS: first, the procedure STRATEGY is called, and then INTERRUPT.

Procedure STRATEGY contains first executable program commands. It is executed, when DOS call a driver. The only task of the procedure STRATEGY is to save the address of the query heading, there by the driver can define which command and data to process. After maintenance of the address the controlling returns in DOS and it can continue processing, calling a device driver again.

Procedure INTERRUPT is a section that determines, what command a device driver will execute, and uses a this command code inside a driver. DOS calls this procedure immediately after procedure STRATEGY. That it executes all the work that DOS requires from console driver.

The first part of the procedure INTERRUPT saves the state of the processor registers in a stack using commands. It is now possible to use any of the stored registers.

At the end of device driver when exiting it is necessary to restore the content of registers. It must be noted that stack DOS is small and allows about twenty inclusions, so you need to watch how many bytes are included in the stack. Usually stack space is enough to store registers.

The second part of procedure INTERRUPT determines, what command from DOS a driver must execute. We remind that a driver is calling from DOS in response to the application program to a request of performing a specific function. A “command” code for this function is passed to the driver in the second a element of query heading. The example of commands is a read-out, record and initializing. Every command requires a driver to perform certain procedures of the program.

The best way to implement the device driver in the form of a conventional assembler program for each command. This approach is called developing a prototype. This method will allow you to check the function of each command to turn into a device driver.

There are some reasons to develop the prototype of a driver. The first reason is that you cannot use the debugger of DEBUG to load the driver to memory and trace it. Recall that drivers are a part of DOS and are loaded into memory before you can perform utility of DEBUG. There is not possibility to load DEBUG before a device driver. Even after DOS will load a driver into memory utility cannot be applied because interacts with drivers. DEBUG uses the same resources of DOS, as the driver, disrupting them. In addition, DEBUG is not designed to debug drivers of devices. Debuggers for drivers have their own procedures for access to the keyboard and screen, and allow the driver to use procedures of BIOS without interference.

To debug device drivers special debuggers that do not use the resources of DOS for console input-output are offered, but provide their own resources. Such debuggers are useful for tracing functions of commands.

Another reason to application the prototype is that you can integrate every command in a driver after debugging it in the regular program. In the typical program to verity the driver command you can use utility DEBUG. This method allows to develop a driver gradually, if we know that it works with the previously added commands.

The main obstacle here is a command of initializing. When this command is executed, DOS calls a driver with the command of initializing immediately after loading a driver into memory. All other commands are started when the program accesses to the device through maintenances of DOS reading, recording or controlling by an input-output, and you can control it.

The command of initializing is intended to prepare drivers for its calls from the programs. You can display a message on a console, to initialize a device to prepare the vectors of breaking and add resident software from this command. If the command of initializing is enormous, it is better to perform the same function through the sequence of control by an input-output.

As a driver is a program, which is started as an executive file, it is possible to verify it by writing the testing programs. These programs must include verification of all functions that a driver executes. Adjusting of device drivers is an extremely challenging problem, in fact it is very difficult to monitor their work, when they are already a part of the operating system. The adjusting program allows a driver to certain functions, which it executes without installing a driver into the system MS-DOS. It emulates MS-DOS appeal to the driver by querying commands, which are explored, and consequent procedure calls, controlling, where it is necessary, the results of the processing this query by a driver.

After writing and debugging a driver can be used on different PCS, that will allow to connect a new device. This facilitates the work of users. Thus the system programming plays a fundamental role in modern technology.

References:

  1. http://ru.wikipedia.org/wiki/Ñèñòåìíîå_ïðîãðàììíîå_îáåñïå÷åíèå
  2. Robert Ley – Development of device drivers for ms-dos