2

I've been reading about how memory-mapped I/O actually works and I cannot understand how the system assigns an address or address space to a specific device.

Let's say I had two devices that I wanted to use in a memory-mapped scheme, and they were identical devices (hard drives maybe?). If they both monitored the address bus for the same address, then they wouldn't be able to function independently of each other. Does the I/O controller have some kind of on-board process to dynamically allocate that sort of thing, or is that left up to BIOS/UEFI? Or am I really off track?

  • I believe this is an operating system specific thing. UEFI and BIOS are even lower level than that, translating motherboard specific signalling to a standard interface. – Berin Loritsch Dec 20 '17 at 18:10
  • It varies depending on architecture, bus type, age of the device, etc. What kind of system are you asking about? – Jules Dec 20 '17 at 19:31
6

It depends on the bus specification.

For example, PCI uses an enumeration scheme whereby the OS probes for each possible device, and finding a device, asks it how many memory blocks it wants, and how large each should be. The operating system will then tell each device what memory addresses it should consider its own.

More specifically, PCI devices have Base Address Register(s), which are used both to communicate the size of the desired memory block from the device to the OS, and also for the OS to assign a unique address for each device-requested memory block.

The device's BARs themselves are addressed via their specific location in the bus, so have unique addresses just by being plugged in somewhere.

It wasn't always like this: for example, one old scheme required dip switches to be configured on the installed boards, and if they were set wrong by the user/installer, things wouldn't work because of conflicts between two boards.

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.