I am studying about Memory-Mapped I/O from here. I have read the following:
From the CPU's perspective, an I/O device appears as a set of
special-purpose registers, of three general types:
- Status registers provide status information to the CPU about the I/O device. These registers are often read-only, i.e. the CPU can
only read their bits, and cannot change them.- Configuration/control registers are used by the CPU to configure and control the device. Bits in these configuration registers may
be write-only, so the CPU can alter them, but not read them back.
Most bits in control registers can be both read and written.- Data registers are used to read data from or send data to the I/O device.
This image (from the page I linked) shows the registers:
But what I don't understand is, are those registers part of the device itself (for example: are they part of a printer), or are they part of the computer?
Best Answer
Computer, controller, and devices are broad and fuzzy concepts. This explains why you have so many different explanations.
What's a hardware controller?
A controller can mean different things. For example:
So as a rule of thumb, if you have some cables between a computer and a device, you can bet that there's at least one controller on each side of the cable.
Is the controller on the computer?
This depends on the boundaries that you set for the computer:
But the fact that a controller is on the computer side, does not exclude that there's a (hidden) controller on the device's side.
Now to the DMA!
In some cases a controller could be plugged directly on the bus (see our previous example of a raid controller) or the controller is on the motherboard and connected to the bus.
To do I/O via the bus, the processor would need to address the device, byte by byte or word by word and copy it to the memory. This is very inefficient, because this simple copying task would keep the CPU busy.
Therefore you have the DMA: the processor instructs a DMA controller to do the job, and the DMA controller would then address the device and copy the obtained bytes into memory, leaving the CPU free to do more interesting tasks.