EmbeddedRelated.com
Forums

MMU question

Started by sg83 July 3, 2008
Hi everyone,

I am very new to Embedded Linux. I know that the MMU handles all of the
address translations from Virtual to Physical. My question is that how does
the MMU know which physical addresses actually have RAM?

Is this information provided by the CPU? Kernel? Bootloader?

For example, if I have a board with the first bank of 64MB DRAM mapped to
0xa0000000 and second bank of 64MB DRAM mapped to 0xb0000000, where does
the MMU get this map from?

Thanks for the help!


sg83 wrote:

> For example, if I have a board with the first bank of 64MB DRAM mapped to > 0xa0000000 and second bank of 64MB DRAM mapped to 0xb0000000, where does > the MMU get this map from?
Take a look at the Wikipedia entry: http://en.wikipedia.org/wiki/Memory_management_unit If you have plenty of time, you can read the documenation of chips like Pentium for the details :-) -- Frank Buss, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
On Thu, 03 Jul 2008 14:57:39 -0500, sg83 wrote:

> Hi everyone, > > I am very new to Embedded Linux. I know that the MMU handles all of the > address translations from Virtual to Physical. My question is that how > does the MMU know which physical addresses actually have RAM? > > Is this information provided by the CPU? Kernel? Bootloader? > > For example, if I have a board with the first bank of 64MB DRAM mapped > to 0xa0000000 and second bank of 64MB DRAM mapped to 0xb0000000, where > does the MMU get this map from? > > Thanks for the help!
The MMU doesn't 'know' what's RAM and what's not. The MMU just knows how virtual memory should be mapped to what physical memory. This mapping is specified by the CPU running in some protected mode (like ring 0 on a x86) that lets it talk to the MMU. You seem to be confused about what the CPU is in relation to the kernel and bootloader. The CPU is the hardware which executes the bootloader code as well as the kernel code. So asking if the information is provided by the CPU _or_ the kernel is a near-meaningless question. -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Actually in linux, the MMU makes the conversion from logical to virtual/linear 
to physical adresses.  But, even on systems that use segmentation, Linux 
pretty-much ignores it, so logical = virtual.  Linux uses whats called demand 
paging.  While you at wikipedia look-up paging and demand paging.  The book 
"Understanding the Linux Kernel" is also a good reference.


---Matthew Hicks


> Hi everyone, > > I am very new to Embedded Linux. I know that the MMU handles all of > the address translations from Virtual to Physical. My question is that > how does the MMU know which physical addresses actually have RAM? > > Is this information provided by the CPU? Kernel? Bootloader? > > For example, if I have a board with the first bank of 64MB DRAM mapped > to 0xa0000000 and second bank of 64MB DRAM mapped to 0xb0000000, where > does the MMU get this map from? > > Thanks for the help! >
Thank you for the help everyone. 

The main reason I ask this question is because I have a kernel running on
a dev. board right now. However, I want to port my code over to the final
product which is going to have less memory and the memory is going to be
located at a different physical address. 

I've ensured that the lower memory amount is enough to run my kernel and
apps, but I wanted to prepare for any issues I might have due to the actual
location of the memory. 

I will surely look into your suggestions.
sg83 wrote:
> > The main reason I ask this question is because I have a kernel > running on a dev. board right now. However, I want to port my code > over to the final product which is going to have less memory and > the memory is going to be located at a different physical address.
What question? If you want to post a followup via groups.google.com or similar, ensure you quote enough for the article to make sense. Google is only an interface to Usenet; it's not Usenet itself. Don't assume your readers can, or ever will, see any previous articles. More details at: <http://cfaj.freeshell.org/google/> -- [mail]: Chuck F (cbfalconer at maineline dot net) [page]: <http://cbfalconer.home.att.net> Try the download section.
>On Thu, 03 Jul 2008 14:57:39 -0500, sg83 wrote: > >> Hi everyone, >> >> I am very new to Embedded Linux. I know that the MMU handles all of
the
>> address translations from Virtual to Physical. My question is that how >> does the MMU know which physical addresses actually have RAM? >> >> Is this information provided by the CPU? Kernel? Bootloader? >> >> For example, if I have a board with the first bank of 64MB DRAM mapped >> to 0xa0000000 and second bank of 64MB DRAM mapped to 0xb0000000, where >> does the MMU get this map from? >> >> Thanks for the help! > >The MMU doesn't 'know' what's RAM and what's not. The MMU just knows how
>virtual memory should be mapped to what physical memory. This mapping is
>specified by the CPU running in some protected mode (like ring 0 on a >x86) that lets it talk to the MMU. > >You seem to be confused about what the CPU is in relation to the kernel >and bootloader. The CPU is the hardware which executes the bootloader >code as well as the kernel code. So asking if the information is >provided by the CPU _or_ the kernel is a near-meaningless question. > >-- >Tim Wescott >Control systems and communications consulting >http://www.wescottdesign.com > >Need to learn how to apply control theory in your embedded system? >"Applied Control Theory for Embedded Systems" by Tim Wescott >Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html >
Thanks for the help. The main reason I ask this question is because I have a kernel running on a dev. board right now. However, I want to port my code over to the final product which is going to have less memory and the memory is going to be located at a different physical address. I've ensured that the lower memory amount is enough to run my kernel and apps, but I wanted to prepare for any issues I might have due to the actual location of the memory.
sg83 wrote:
> My question is that how does > the MMU know which physical addresses actually have RAM?
It doesn't. Depending on how the system is designed, an attempt to access a virtual address that maps to a physical address not corresponding to any memory may lead to a bus fault.