An electronic device in the form of chip or circuit board that controls functioning of the I/O device is called the device controller or I/O Controller or adopter. The operating system directly deals with the device controller.
Some devices are very simple devices. For example, a serial port controller is a simple device controller.
It is a single chip inside the computer, which controls the signals on the wires of a serial port. Some controllers are complicated such as SCSI bus controller. It is a complete circuit board that is plugged into the computer.
Usually, the device controller circuit board has a connector into which a data cable device is plugged.
Some devices have their own built-in controllers. For example, a disk drive has its own circuit board, which is attached to its one side. This circuit board is the disk controller.
Each I/O controller is designed specially to handle a particular kind of device. The CPU communicates with the I/O device through device controller of that device.
The CPU sends signals to device controller to perform a specific I/O operation such as read or write operation. For example, the CPU sends a command to controller to read n byte of information from a serial device or to read a sector of information from a disk. In case of serial device, the controller collects a serial bit stream, converts it into a block of bytes and performs necessary error corrections.
The block of bytes is typically first assembled/ bit by bit, in a buffer inside the controller, and then is copied to main memory. Similarly, the controller for a monitor also works as a bit serial device. It reads bytes (containing the characters or graphics to be displayed) from main memory, and generates the signals used to modulate the CRT beam to display the output on screen in readable form.
The operating system initializes the controller with a few parameters (such as number of characters per line and number of lines per screen to be displayed). The CPU gives the responsibility to the controller by sending commands and becomes busy to perform other tasks. Most of the controllers can handle multiple devices.
There are different kinds of I/O controllers or modules. Each controller has one or more registers that are used for communicating with the CPU. The number of registers in a module (or controller) and their functions depend on the type of module. A module for a simple input device may have two registers. In this case, one register is used for data holding, which is referred to as data buffer registered the other for control information, which is refuted to as control register. The data buffer register is used to store the input value to pass to the CPU, while the control register contains control bits from CPU to command the I/O module.
Some I/O controllers contain more than two registers that are used to control the I/O operations. For example, in disk- I/O operation, additional information is required to identify the location on the disk to perform I/O operation and the amount of data to be transferred.
The CPU communicates with the controller by reading and writing bit patterns in controller's registers. The operating system performs I/O operations by sending commands into the controller's registers. For example, the IBM PC floppy disk controller accepts 15 different commands, such as Read, Write. Seek, Format etc. Many of the commands have parameters, which are also loaded into the controller's registers. When a command is accepted, the CPU gives the control to the controller and go off to do other work. When a command has been completed, the controller causes an interrupt in order to inform the operating system that operation is completed. The operating system again gains control of the CPU to test the results of the operation. It gets the results and checks device status by reading information from the controller registers.