memory mapped hardware

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

memory mapped hardware

Post 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?
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
trinopoty
Member
Member
Posts: 87
Joined: Wed Feb 09, 2011 2:21 am
Location: Raipur, India

Re: memory mapped hardware

Post 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.
Always give a difficult task to a lazy person. He will find an easy way to do it.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: memory mapped hardware

Post 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.
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: memory mapped hardware

Post 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.
linguofreak
Member
Member
Posts: 510
Joined: Wed Mar 09, 2011 3:55 am

Re: memory mapped hardware

Post 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).
User avatar
BMW
Member
Member
Posts: 286
Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand

Re: memory mapped hardware

Post 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?
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: memory mapped hardware

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
kscguru
Member
Member
Posts: 27
Joined: Sat Jan 19, 2008 12:29 pm

Re: memory mapped hardware

Post 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).
Post Reply