Memory mapped IO - how is it done?

paulAl picture paulAl · Mar 11, 2012 · Viewed 21k times · Source

I've read about the difference between port mapped IO and memory mapped IO, but I can't figure out how memory mapped Io is implemented in modern operating systems (windows or linux)

What I know is that a part of the physical memory is reserved to communicate with the hardware and there's a MMIO Unit involved in taking care of the bus communication and other memory-related stuff

How would a driver communicate with underlying hardware? What are the functions that the driver would use? Are the addresses to communicate with a video card fixed or is there some kind of "agreement" before using them?

I'm still rather confused

Answer

Gnurou picture Gnurou · Mar 12, 2012

The following statement in your question is wrong:

What I know is that a part of the physical memory is reserved to communicate with the hardware

A part of the physical memory is not reserved for communication with the hardware. A part of the physical address space, to which the physical memory and memory mapped IO are mapped, is. This memory layout is permanent, but user programs do not see it directly - instead, they run into their own virtual address space to which the kernel can decide to map, wherever it wants, physical memory and IO ranges.

You may want to read the following articles which I believe contain answers to most of your questions: