Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory mapped IO - how is it done?

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

like image 702
paulAl Avatar asked Mar 11 '12 11:03

paulAl


People also ask

How does memory-mapped file work?

A memory-mapped file contains the contents of a file in virtual memory. This mapping between a file and memory space enables an application, including multiple processes, to modify the file by reading and writing directly to the memory.

What is memory mapped I O technique?

Memory mapped I/O is an interfacing technique in which memory related instructions are used for data transfer and the device is identified by a 16-bit address. In this type, the I/O devices are treated as memory locations. The control signals used are MEMR and MEMW.

What happens in a memory-mapped input output?

This chapter describes the interfaces and classes for embedded memory-mapped input and output (MMIO). Memory mapped I/O is typically used for controlling hardware peripherals by reading from and writing to registers or memory blocks mapped to the hardware's system memory.


2 Answers

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:

  • http://duartes.org/gustavo/blog/post/motherboard-chipsets-memory-map
  • http://duartes.org/gustavo/blog/post/memory-translation-and-segmentation
  • http://duartes.org/gustavo/blog/post/how-the-kernel-manages-your-memory
like image 198
Gnurou Avatar answered Sep 18 '22 19:09

Gnurou


http://en.wikipedia.org/wiki/Memory-mapped_I/O

http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/IO/mapped.html

Essentially it is just a form of accessing the data, as if you are saving / reading from the memory. But the hardware will snoop on the address bus, and when it sees the address targetting for him, it will just receive the data on the data bus.

like image 20
Peter Teoh Avatar answered Sep 20 '22 19:09

Peter Teoh