next up previous contents
Next: 3. Installing WinDriver Up: 2. Understanding Device Drivers Previous: 2.5 Associating the Hardware   Contents


2.6 Communicating with Drivers

A driver can create an instance, thus enabling an application to open a handle to the driver through which the application can communicate with it.
The applications communicate with the drivers using a file access API (Application Program Interface). Applications open a handle to the driver using CreateFile() call (in Windows), or open() call (in Linux) with the name of the device as the file name. In order to read from and write to the device, the application calls ReadFile() and WriteFile() (in Windows), or read(), write() in Linux.
Sending requests is accomplished using an I/O control call, called DeviceIoControl() (in Windows), and ioctl() in Linux. In this I/O control call, the application specifies:

The IOCTL code is a number that the driver and the requester agree upon for a common task.

The data passed between the driver and the application is encapsulated into a structure. In Windows, this structure is called an I/O Request Packet (IRP), and is encapsulated by the I/O Manager. This structure is passed on to the device driver, which may modify it and pass it down to other device drivers.