memory mapped i/o
memory mapped i/o
what does memory mapped i/o mean? when the address is mapped does that mean that the i/o device sends data to a location in RAM dedicated for MMIO and then the cpu reads from that location? Or does it mean that the i/o control register is assigned a physical address so the cpu reads directly from the device?
Re: memory mapped i/o
The latter.
Re: memory mapped i/o
so the cpu basically reads from the i/o control register and sees that its assigned to a specific physical address...then it writes the data to that address?
Re: memory mapped i/o
from what ive been reading...in the case of memory mapped i/o... a certain portion of the processor's address space is mapped to the device, and communications occur by reading and writing directly to/from those memory areas. So basically the device can read/write to memory and the cpu reads/writes those memory locations. So for example, the cpu would write to a memory location and the the device would read from it. That is what it sounds like to me.
You might wonder how the communication might work. Suppose you have a printer, and it has some status bits. These bits may reside at some memory address that the CPU "knows" is for the printer. Thus, to get information from the printer, you read a byte or a word from that address.
That byte might tell you if the printer is printing, or is out of paper, or out of toner, or what kind of paper is being used, etc.
You may also want to direct the printer to print. You can send it what characters to print, or what font, etc. This information can be written to a "memory" address. However, instead of having memory at that address, you have an I/O device. The CPU acts as if its writing to memory, and the I/O device reads this information.
Re: memory mapped i/o
Regarding this I always thought that when we allocate some ranges of physical memory address to I/O, how can we we access the memory which resides in those portions of memory?
Re: memory mapped i/o
The OS has first to determine which memory address the registers of the chip are mapped to. In a modern PC it does this by reading the PCI configuration space. Then it just addresses the registers as if they were RAM.icealys wrote:so the cpu basically reads from the i/o control register and sees that its assigned to a specific physical address...then it writes the data to that address?
It's not quite that straightforward, as some registers may be read only; with others writing a particular value to a register clears it, resets the chip, or some other action. So writing 12345 (random example) to the "memory" location doesn't necessarily mean that a read of that location will return 12345. The documentation for the device will detail this.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: memory mapped i/o
You need to understand the difference between physical memory (RAM) and physical address space (bus).siavoshkc wrote:Regarding this I always thought that when we allocate some ranges of physical memory address to I/O, how can we we access the memory which resides in those portions of memory?
RAM is mapped into the physical address space by the firmware, which initializes the DRAM controller. Before this happens the firmware is usually limited to using the CPU's caches as RAM.
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
Re: memory mapped i/o
If the CPU tries to write to (or read from) a location used by a memory mapped device, the write will be intercepted before it reaches memory. It will be sent to the device instead. The circuitry which does that would once upon a time been in an external chip, but it is nowadays quite likely to reside in the CPU itself.icealys wrote:from what ive been reading...in the case of memory mapped i/o... a certain portion of the processor's address space is mapped to the device, and communications occur by reading and writing directly to/from those memory areas. So basically the device can read/write to memory and the cpu reads/writes those memory locations. So for example, the cpu would write to a memory location and the the device would read from it. That is what it sounds like to me.
The continuous image of a connected set is connected.
Re: memory mapped i/o
Can you point me to a book or a guide about this topic? I am reading Intel manuals maybe I will reach to that too?Brynet-Inc wrote:You need to understand the difference between physical memory (RAM) and physical address space (bus).siavoshkc wrote:Regarding this I always thought that when we allocate some ranges of physical memory address to I/O, how can we we access the memory which resides in those portions of memory?
RAM is mapped into the physical address space by the firmware, which initializes the DRAM controller. Before this happens the firmware is usually limited to using the CPU's caches as RAM.
Re: memory mapped i/o
so what happens to the physical locations in RAM? lets say you are reading from the device...so instead of accessing RAM it will read from the device and write to the physical location its mapped to?If the CPU tries to write to (or read from) a location used by a memory mapped device, the write will be intercepted before it reaches memory. It will be sent to the device instead.
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
Re: memory mapped i/o
You might find it in the Bios Writer's Handbook (if there is such a thing). Because it executes in ROM, it alone can run prior to the RAM chips being initialised, and it alone can initialise them.siavoshkc wrote:Can you point me to a book or a guide about this topic? I am reading Intel manuals maybe I will reach to that too?
The continuous image of a connected set is connected.
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
Re: memory mapped i/o
Nothing happens to the physical locations in RAM. They just don't get used - unless it gets mapped elsewhere. From the firmware's point of view at system startup, memory chips constitute just one more type of device, waiting to be mapped into the processor's address space.icealys wrote:so what happens to the physical locations in RAM? lets say you are reading from the device...so instead of accessing RAM it will read from the device and write to the physical location its mapped to?
The continuous image of a connected set is connected.
Re: memory mapped i/o
More about the definition of Physical Address Space I intend.mathematician wrote:You might find it in the Bios Writer's Handbook (if there is such a thing). Because it executes in ROM, it alone can run prior to the RAM chips being initialised, and it alone can initialise them.siavoshkc wrote:Can you point me to a book or a guide about this topic? I am reading Intel manuals maybe I will reach to that too?
Re: memory mapped i/o
I think you were given a very strange explanation. I don't know what this interception is. If you want to understand memory mapped I/O it is probably best to grab a microprocessor and build a computer which has an external chip on the main bus, e.g., memory, serial port, ADC, etc. What usually happens when the CPU reads or writes from a bus device is:icealys wrote:so what happens to the physical locations in RAM? lets say you are reading from the device...so instead of accessing RAM it will read from the device and write to the physical location its mapped to?If the CPU tries to write to (or read from) a location used by a memory mapped device, the write will be intercepted before it reaches memory. It will be sent to the device instead.
i) the CPU dumps a physical address onto the bus, then
ii) address decode logic maps the address to a chip select which tells a bus device that the CPU is talking to it, then
iii) the selected device does what it needs to do.
From this you see that memory is no different from any other device on the bus. Things aren't intercepted before they reach memory, everything on the bus is reached at the same time, the decode logic selects the device that is being communicated with. Here, I've assumed a processor bus as you asked about memory mapped devices, but other buses like I2C or ethernet are similar, there's always some kind of decode logic somewhere: either centralised with chip selects on a processor bus or localised like I2C or ethernet.
For an example, look at the following spec. sheet for an ADC chip: http://www.ti.com/cn/lit/gpn/adc0804-n. See page 27 (microprocessor interfacing) for memory mapped operation and I/O port operation. Page 2 (typical applications) gives the high-level interfacing details.
Every universe of discourse has its logical structure --- S. K. Langer.
Re: memory mapped i/o
i'm a little confused on something, so for example, an input device sends a signal to the processor and the processor reads from the input device like a mouse or keyboard? OR, does the device send data to the processor?