Are “Control register” and “Status register” and “Data register” part of the device itself

computer-architecturehardwareio

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:

enter image description here

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:

  • it can be a dedicated chip (or a more complex chipset) on the motherboard, specialized in controlling communication that passes over an interface port. Typical examples are a USB host controller or integrated controllers, or on older machines a UART controller or a keyboard controller. These controllers are either connected to a bus, or to an external connector.
  • it can be a more complex board connected to a PCI slot, for example a network card or a RAID disk controller. Some people see such complex things as a device on its own (because of its complexity), while some just see this as another controller connected to the internal bus.
  • it can be a microcontroller (i.e. a kind of simplified CPU) that can be integrated in a device to perform some processing tasks and organize the communication with what is on the other side of the cable. Most people explaining controllers from the computer point of view just omit this from their explanation, because that's irrelevant device internals. However a device need its own brain: even for simple things like an older PC keyboard, how can the controller on the motherboard know about the 102 keys' state, when there are only 5 to 6 pins/wires that connects it to the remote keyboard? Well, there's a simple controller inside the keyboard as well.

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:

  • do you mean the core or your computer (i.e. CPU, memory, and clock)? In this case the answer will be no.
  • do you mean the motherboard? In this case, as you saw the answer could be yes or no, depending on the kind of controller you're thinking of.
  • do you mean the box, i.e. the physical boundaries with the outside world? Then yes: whenever a connector on the box, then there's a controller in the box as well.

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.

Related Topic