Devices communicate with the computer through a port, e.g. a serial port
Devices that share wires are on a connection called a bus (PCIe bus is the common system bus - connects processor/memory to fast devices, while an expansion bus connects slow devices like keyboards, usb ports, etc.)
PCIe buses are split into multiple lanes which allow for full-duplex (bidirectional) data transfer between the two ends
A device controller is the electronics that can operate the device. The driver speaks with the controller.
e.g. a serial controller is a single chip controlling the electrical signals to and from the serial port
The communication goes OS->driver->device controller->electrical signals sent to actual device
Device controllers have a set of registers for data and controller signals. The driver reads and writes data to and from these registers to communicate with the controller
e.g. status, data in, data out, control
Devices that support memory mapping (mmap) map their registers into the processor’s address space so the processor can read and write to their mapped location in physically memory (e.g. an innterupt controller devices can be mmapped to hex address 0x021-0x021)
Today, most I/O is performed by device controllers with memory mapped I/O
The controller will set a busy bit when it is working. When free, and if there is a command from the processor available, it will read the data and send it to the device
When the device becomes available it will send an interrupt
There are thousands of interrupts being processed per second
For larger transfers, instead of continually writing to the data register and waiting for the controller to service it, a Direct Memory Access (DMA) controller is used
You pass in a pointer to the start of the source data, a pointer to the destination buffer, and the number of bytes to transfer and it takes care of it for you without the processor needed to continue to do work on the transfer
The DMA controller is a processor that operates the device controller independently (without the processor). The device controller still sends the actual signals to the device