4

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?

  • "are those registers part of the device itself, or are they part of the computer?" What difference do you think it makes? – whatsisname May 30 '17 at 4:23
  • @whatsisname If these registers are part of the computer, then I would know that every device (for example: printer, webcam, keyboard) will have these registers once you plug them to the computer. – John May 30 '17 at 4:54
2

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.

0

They are part of the device.

They are addressed as if they were part of memory. This works because memory and the device are plugged into the same bus. You talk to them the same way.

If you've ever plugged a card into a motherboard you've plugged a device into a bus.

Any device connected to the computer is connected by a plug and socket, and the socket is connected to a device controller. Device controllers use binary and digital codes. Each device controller has a local buffer and a command register. It communicates with the CPU by interrupts. A device's controller plays an important role in the operation of that device; it functions as a bridge between the device and the operating system.

Wikipedia: Device Controller

Why do I think of the controller as part of the device? Because if you unplug the device the controller typically goes with it.

  • Hhm... but most of my devices are plugged on my computer via an usb port (and before usb, via an rs232c or a centrinics interface). And behind this port there's a controller. When i unplug the device, the port and its controller are still there. So the controller is on the computer, no ? Some of these controllers can even be on the motherboard (e.g. en.m.wikipedia.org/wiki/Host_adapter). Wouldn't it therefore make sense to first define what boundaries are considered for "the computer" ? – Christophe May 30 '17 at 6:50
  • Yes, that's why I used the word "typically". – candied_orange May 30 '17 at 7:07
  • @Christophe If we plugged a printer into a parallel port, now we have the printer with its own device controller which is part of the printer itself, and we also have the parallel port with its own device controller. But with an IDE disk, we only have the IDE disk device controller which is part of the disk itself, correct? – John May 30 '17 at 16:12
  • 1
    This is the point ! Except for devices which are plugged directly on the bus (e.g. Pci card), you probably always have a controller on the computer side (that controls the communication with the device) and one external, which belongs to the device. Looking at the question, you just have to clarify where you see the computer's boundaries: the cpu and the memory ? The motherboard ? The motherboard and its extensions ? The box in which all this is hosted ? – Christophe May 30 '17 at 16:50
  • @Christophe The computer's boundary the the box in which all is hosted, but why is it important to say what the computer boundary is? You mean if I say that a parallel port is not a part of the computer, then if I plugged a printer into a parallel port, this means that the parallel port device controller is now a part of the printer itself?! – John May 31 '17 at 0:46
0

There are two implementations. When the controller is located with the "Southbridge" we can say about the architecture of DMA (direct memory access).

In modern architecture, the controller can be located in the device. It's a very simple example for working through interruptions.

In generally, we can consider the controller like part of the device, because modern advances of computer engineering let us locate own "system resources" of devices onboard on it. When a device has not own "system resources", so it will use the system resources of a computer, and of course, in the case, the controller will be located on the computer matherboard.

Here is very clear explanation: https://eleccompengineering.files.wordpress.com/2014/07/structured_computer_organization_5th_edition_801_pages_2007_.pdf Also, the 6th edition is more powerful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.