Sign in
Explore Mechanical Insights: Guest Blogging Opportunities in Our Journal
Explore Mechanical Insights: Guest Blogging Opportunities in Our Journal
Your Position: Home - Auto Electronics - Why do we need memory mapped IO?
Guest Posts

Why do we need memory mapped IO?

Apr. 29, 2024

Why do we need memory mapped IO?

Every device has some sort of internal registers that software (device drivers) use to control the device's state, ask the device to do things, and determine status.

You will get efficient and thoughtful service from sonnepower.

There are 2 main ways that software (device drivers) can access a device's internal registers - by mapping those registers into the CPUs physical address space (the same way that memory is mapped into the CPUs physical address space); and by providing a dedicated mechanism (e.g. IO ports on 80x86).

To understand the advantages/disadvantages; it's best to think about the nature of communication between CPU/s and memory. This communication needs to be extremely fast because everything depends on it; and (for electronics) "fast" tends to mean simple, with short bus lengths (due to things like capacitance and resistance) and with the least loads (because each load increases the current needed to drive the bus, which means larger transistors to handle the higher current, which means more time taken for transistors to switch). Of course there's also a bunch of tricks to make it even faster, starting with caches (and maybe cache coherency), and prefetching, and speculative execution to keep the CPU busy while it's waiting for data.

By providing a dedicated mechanism (e.g. IO ports on 80x86) it all seems nice; because you'd have separation between the high speed memory bus and all the (much slower) stuff.

What if we slap a honking great mess right in the middle of the most performance critical data path (between CPU and RAM), so that software (device drivers) can access devices' internal registers using memory mapped IO instead? Oh boy...

For more information, please visit io what is.

For a start you'd be looking at some major complications for caches (at a minimum, some way to say "these area/s should be cached, and those area/s shouldn't be cached" with all the logic to figure out which accesses are/aren't cached, and its added latency); plus more major complications for the CPU itself (can/should it try to prefetch? Can/should it speculatively execute past a read/write?); plus slower (longer with more loads) and/or more expensive bus to handle "who knows what device/s might get plugged in", likely with some extra pain (wait states, etc) to deal devices being so much slower than memory. It just sounds like an incredibly bad idea.

However, it turns out that a lot of devices can benefit from being able to access the memory bus directly (using bus mastering/DMA to transfer data between the device and RAM directly; and not for memory mapped IO), so you mostly end up wanting that slower bus anyway, and you mostly end up wanting to deal with all the other complications too.

If you look at the history (at least for 80x86); you'll find a gradual shift from "simple, primarily using IO ports" to "extremely complex, primarily using memory mapped IO".

Why do we need memory mapped IO?

No, it's not a strict necessity (but it's much nicer if you're willing to accept the performance/complexity consequences).

Are you interested in learning more about spd display? Contact us today to secure an expert consultation!

Comments

0 of 2000 characters used

All Comments (0)
Get in Touch

  |   Transportation   |   Toys & Hobbies   |   Tools   |   Timepieces, Jewelry, Eyewear   |   Textiles & Leather Products   |   Telecommunications   |   Sports & Entertainment   |   Shoes & Accessories   |   Service Equipment