📜 ⬆️ ⬇️

Device driver and what it eats

What is a "driver"




As a respected user, you probably know that a “device driver” is a computer program that controls a specific type of device connected to or included in any desktop or laptop computer.

The main task of any driver is to provide a soft interface for controlling the device, through which the operating system and other computer programs gain access to the functions of this device, “not knowing” how it is specifically used and working.
')
Usually the driver communicates with the device via the bus or communication subsystem to which the direct device is connected. When the program calls the procedure (sequence of operations) driver - it sends commands to the device itself. As soon as the device has completed the procedure (“routine”), the data is sent back to the driver and from there to the OS.

Any driver is device dependent and specific to each operating system. Typically, drivers provide an interrupt scheme for handling asynchronous procedures in an interface dependent on the time it is executed.

Any operating system has a "device map" (which we see in the device manager), each of which requires a specific driver. The only exceptions are the central processor and RAM, which is controlled directly by the OS. For everything else, you need a driver that translates the commands of the operating system into a sequence of interrupts - the notorious “binary code”.

How does the driver work and what is it for?


The main purpose of the driver is to simplify the programming process of working with the device.

It serves as a “translator” between the hard (iron) interface and the applications or operating systems that use them. Developers can write, using drivers, high-level applications and programs without going into details of the low-level functionality of each of the necessary devices separately.

As already mentioned, the driver is specific to each device. He "understands" all the operations that the device can perform, as well as the protocol through which the interaction between the soft and iron parts takes place. And, of course, it is controlled by the operating system, in which it performs a specific application or a separate function of the OS itself (“printing using a printer”).

If you want to format a hard disk, then, simply, this process looks like this and has a certain sequence: (1) first, the OS sends a command to the device driver using a command that both the driver and the operating system understand. (2) After that, the driver of a specific device translates the command into a format that only the device already understands. (3) The hard disk formats itself, returns the result to the driver, which already subsequently translates this command into the “language” of the operating system and returns the result to its user (4).

How to create a device driver




Each device has its own strict order of command execution, called “instruction”. Without knowing the instruction to the device, it is impossible to write a driver for it, since the low-level machine instructions are binary codes (interrupts) that send the output to the driver to the result obtained during the execution of this instruction.

When creating a driver for Linux, you need to know not only the type of bus and its address, but also the schematics of the device itself, as well as the entire set of electrical interrupts, during the execution of which the device gives the result to the driver.

Writing any driver begins with its "skeleton" - that is, the most basic commands like "on / off" and ending with parameters specific to this device.

And what the driver is not


Often, a device driver is compared with other programs that perform the role of a “middleman” between software and / or hardware. In order to dot the “i”, we specify:



Well, as advertising - you always know where to download the latest drivers for any device under Windows.

Source: https://habr.com/ru/post/252927/


All Articles