Page 1 of 1

memory mapped hardware

Posted: Mon Jan 21, 2013 11:43 pm
by BMW
Sorry this is probably the noobest question yet, but I can't find a decent explanation elsewhere.

Memory mapped hardware doesn't actually store data in the memory location it is mapped to (well some do such as the video memory but most dont), so why can't we use that memory?

Re: memory mapped hardware

Posted: Mon Jan 21, 2013 11:56 pm
by trinopoty
Memory mapped hardware basically means that the memory location decodes to a hardware. Technically speaking, RAM and ROM are also memory mapped hardware. We can/cannot store data at memory mapped hardware depending on the hardware. Technically speaking, we are storing data whenever we are writing to any memory location, be it RAM or other hardware. Whether the hardware allows us to read back the data is another thing.

Re: memory mapped hardware

Posted: Tue Jan 22, 2013 1:15 am
by Yoda
This misunderstanding happens because of somewhat incorrect common term. This should be "address space mapped hardware", rather than "memory mapped". In this case both RAM and hardware are "address space mapped". If the hardware is mapped to the definite location, there is no common RAM here.

Re: memory mapped hardware

Posted: Tue Jan 22, 2013 2:27 am
by bluemoon
Or "physical address mapped IO"

Both memory module (ie RAM) and "physical address mapped IO" are mapped by the memory controller that divert the physical address access made by the CPU/cache fetch.

address space is generally assumed to meant logical address space for kernel developers.

Re: memory mapped hardware

Posted: Tue Jan 22, 2013 12:25 pm
by linguofreak
One way of looking at it is that the memory mapped hardware *is* the memory at the location it's mapped to. When the CPU reads that location, the hardware will send something to the CPU. When the CPU writes that location, the hardware accepts the write.

But unlike normal memory, a read might not return what had previously been written to a given location, and a write might very well cause the hardware to do something (for example, memory mapped video displays a character or a pixel on the screen when it receives a write). These two factors generally make memory mapped hardware unusable as general memory.

Now, as long as your memory mapped does something when written to but always returns what was previously written to a location when read (I think memory mapped video generally behaves this way, but I can't guarantee it), you *can* use it as general memory *if* any action it might take when written to is acceptable (for example, if you're OK with your monitor displaying a psychedelic screensaver and not displaying anything useful, you can use your video memory as general memory).

Re: memory mapped hardware

Posted: Tue Jan 22, 2013 9:13 pm
by BMW
Ok, so physical memory is not being wasted with physical address mapped hardware, only part of the address space is being wasted (well not wasted, used).

So say at 0x100 is a mapped keyboard, would the memory controller map the physical memory address 0x100 to a different memory address to save that memory? Or would the physical memory at 0x100 be wasted?

Re: memory mapped hardware

Posted: Wed Jan 23, 2013 2:00 am
by Brendan
Hi,
BMW wrote:Ok, so physical memory is not being wasted with physical address mapped hardware, only part of the address space is being wasted (well not wasted, used).

So say at 0x100 is a mapped keyboard, would the memory controller map the physical memory address 0x100 to a different memory address to save that memory? Or would the physical memory at 0x100 be wasted?
In general; the 128 KiB of RAM from 0x000A0000 to 0x000BFFFF (the legacy VGA area) is either wasted or used for SMM; and the (512 MiB to 1.5 GiB) of RAM from the start of the "PCI device hole" to 0xFFFFFFFF either doesn't exist (computers that have less than 3 GiB of RAM), or is remapped to the end of RAM (most chipsets/motherboards) or is wasted (cheaper chipsets/motherboards).

Also note that for the area from 0x000C0000 to 0x000FFFFF (the legacy ROM area) modern motherboards copy the ROM/s into RAM and then set the RAM to "read only". This is done because RAM is faster than ROM, and means that the RAM in this area is actually being used and is not wasted.

There are no other areas that are used for memory mapped IO on modern "PC compatible" 80x86 systems.


Cheers,

Brendan

Re: memory mapped hardware

Posted: Fri Jan 25, 2013 12:03 pm
by kscguru
BMW wrote:Ok, so physical memory is not being wasted with physical address mapped hardware, only part of the address space is being wasted (well not wasted, used).

So say at 0x100 is a mapped keyboard, would the memory controller map the physical memory address 0x100 to a different memory address to save that memory? Or would the physical memory at 0x100 be wasted?
In addition to what Brendan said - most memory-mapped hardware is SMALL. Kilobytes for "simple" devices (like keyboards or VGA), maybe a megabyte or two for more sophisticated devices (NICs or SCSI/SATA controllers). When the amount of memory is that small, it's simply not cost-effective to remap it elsewhere - remapping the inaccessible 0.01% of memory isn't justifiable compared to the price of buying more RAM. That's probably why the PCI hole exists - it's cheaper to just do one giant linear remapping than a few dozen noncontiguous cherry-picked remappings for the PCI devices that do exist. (Cheaper in electronics cost, writing code, ACPI data structure size, etc.)

There are a few other (less common) memory holes on PC hardware too: the ISA memory hole (15MB-16MB, but ISA is uncommon today), the HyperTransport hole on AMD (1023GB-1024GB, but that much RAM costs US$200,000+ so only major OS vendors even see such hardware).