How can RAM contain a “memory map” if RAM is unaware of the overall system

cpuiomemorymotherboard

This question concerns hardware more than software. Basically, citing from this article on memory maps, it says that:

In computer science, a memory map is a structure of data (which usually resides in memory itself) that indicates how memory is laid out.

Source: http://en.wikipedia.org/wiki/Memory_map

There is extreme ambiguity in regards to that very opening sentence. First off, how can RAM know how to lay memory out for the CPU's address space if the purpose of RAM depends on the system?

Second, RAM can be changed. If the data resides in the RAM, all RAM chips are hardwired to have a structure describing memory? That doesn't make sense, because from the scope of the CPU it's vague, and makes even less sense when you look at it from the scope of the RAM(a system can have different memory at any time, different hardware, different addresses, different architecture, etc.).

Third, the article claims that the memory map is passed to the firmware for an OS. That would only make sense if the RAM is hardwired, or the map is synchronous with the CPU's address space.

Basically, I am 100% clueless and lost on this. I do not understand in any way how this makes clear sense.
RAM can not map addresses out for a system if it has no knowledge of the system's structure.

Best Answer

In computer science, a memory map is a structure of data (which usually resides in memory itself) that indicates how memory is laid out.

Source: http://en.wikipedia.org/wiki/Memory_map

There is extreme ambiguity in regards to that very opening sentence. First off, how can RAM know how to lay memory out for the CPU's address space if the purpose of RAM depends on the system?

Normally the memory map itself is saved into some kind of non-volatile memory on the device, which loads the memory map into the processor/MMU when the system boots up. As someone using the device, you can change the memory map yourself, although the layout is less relevant in systems running operating systems, since it then becomes the OS's job to control memory access. The DIY approach is usually only required in embedded systems where you yourself are physically connecting RAM/ROM IC's to an existing circuit.

Moving on to modern-day computer systems...

Second, RAM can be changed. If the data resides in the RAM, all RAM chips are hardwired to have a structure describing memory? That doesn't make sense, because from the scope of the CPU it's vague, and makes even less sense when you look at it from the scope of the RAM(a system can have different memory at any time, different hardware, different addresses, different architecture, etc.).

Third, the article claims that the memory map is passed to the firmware for an OS. That would only make sense if the RAM is hardwired, or the map is synchronous with the CPU's address space.

Exactly - this is why RAM itself provides serial presence detect (SPD) so the BIOS/UEFI can determine what RAM is in your system (and if it has changed since the last time the computer was started!).

Also, x86 memory management units come with virtual-memory support made for use with operating systems. The MMU itself bridges the physica hardwired RAM layout (which is just a large number of data/address lines connected to all the DIMMs on the motherboard), so this is abstracted away from the CPU itself (even if the MMU and CPU are on the same die, they are logically two different "units").

RAM can not map addresses out for a system if it has no knowledge of the system's structure.

You're correct, the RAM itself cannot (which is why they have SPD/XMP profiles) - the CPU/MMU will identify what resources are available in the system each and every time you start your computer. Furthermore, this process is abstracted away from anything under the operating system since most OS'es use virtual memory now, which completely separates the concept of system memory from physical RAM (most people are familiar with this concept through paging, where the OS can place part of a processes' memory on-disk to free up RAM for other applications).