OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 2:48 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Direct mapping memory in popular OS?
PostPosted: Mon Mar 09, 2009 2:50 am 
Offline
Member
Member

Joined: Wed Jan 23, 2008 8:55 pm
Posts: 63
Hi,

I am wondering if any other popular OS use the same direct mapping memory as Linux?

In Linux, they can translate virtual address to physical address using the formula:

physical-addr = virtual-addr - 0xC0000000

This is called "direct-mapping" in Linux. Of course to use the above formula, the virtual address must falls with a particular range (like [0xC0000000, 0xC0000000+896MB].

My question is: is there any other OS use the same "direct-mapping" technique?

I am particular interested in the answer for popular OS like *BSD, MacOSX, *nix.

Thanks a lot,
J


Top
 Profile  
 
 Post subject: Re: Direct mapping memory in popular OS?
PostPosted: Mon Mar 09, 2009 3:18 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
As far as I know, most operating system's code is directly mapped like this.

Especially in the very early stages of bootup when your memory manager isn't set up correctly, it's really easy to do a 1:1 mapping of the higher half of memory to the lower half. Virtually every high-half kernel does this on boot up.

But once memory management is initialised and working, as far as I know, the pages are then mapped from all over the physical RAM into the kernel. Otherwise you'd get have limited memory (you'd have to shift physical RAM around when you want to allocate another page to the kernel) and I see no benefit.

But for non-dynamic addresses and the such (that were allocated before the memory manager), then I see how the "phys addr = virt addr - start of kernel" would be a helpful macro to resolve the address. Otherwise, it's not too hard to go resolve an address from a page directory/table manually.

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: Direct mapping memory in popular OS?
PostPosted: Mon Mar 09, 2009 9:18 pm 
Offline
Member
Member

Joined: Wed Jan 23, 2008 8:55 pm
Posts: 63
At least I heard that Windows does not use the direct-mapping technique. I dont know why they dont do that!

Besides *BSD, MacOSX, I am curious about Solaris, too.

I would be appreciated if somebody can shed some lights into this problem.

Thanks


Top
 Profile  
 
 Post subject: Re: Direct mapping memory in popular OS?
PostPosted: Tue Mar 10, 2009 8:54 am 
Offline
Member
Member
User avatar

Joined: Fri Apr 18, 2008 4:40 pm
Posts: 1686
Location: Langley, Vancouver, BC, Canada
junkoi wrote:
MacOSX

You can download the Darwin kernel source for free and I bet you these invisible tokens that you could figure out how their memory map works :D

_________________
Image
Image
Solar wrote:
It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.

I wish I could add more tex


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: DotBot [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group