OSDev.org

The Place to Start for Operating System Developers
It is currently Tue May 23, 2017 9:08 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Would it be smart to map all physical addresses to virtua...
PostPosted: Sat Dec 24, 2016 8:16 am 
Offline
Member
Member
User avatar

Joined: Mon Dec 28, 2015 11:11 am
Posts: 365
Location: Serbia
...l while boot? If not, why? What would be pros and cons of it?

_________________
Nutoak
People are like paintings. It may be difficult for them to change any painting after they already drawn that painting.It means that it may be difficult to everybody to change their own opinion about other people after they already made an opinion.
Image


Top
 Profile  
 
 Post subject: Re: Would it be smart to map all physical addresses to virtu
PostPosted: Sat Dec 24, 2016 9:23 am 
Offline
Member
Member

Joined: Sat Dec 27, 2014 9:11 am
Posts: 777
Location: Maadi, Cairo, Egypt
It makes perfect sense to map all physical addresses to virtual address during booting. It makes some things (e.g. ACPI table access, PCIe configuration, ...) easier to do. For 64-bit systems, it makes sense to leave the lower half of the 48-bit address space for general purpose use, and the upper half to map all physical addresses.

_________________
Byte me; OS site, source code.
Progress: USB.


Top
 Profile  
 
 Post subject: Re: Would it be smart to map all physical addresses to virtu
PostPosted: Sat Dec 24, 2016 10:53 am 
Offline
Member
Member
User avatar

Joined: Mon Dec 28, 2015 11:11 am
Posts: 365
Location: Serbia
What is wrong with this then...
Code:
PageDir* d=(PageDir*)AllocBlock(12288);
memclr(d,sizeof(PageDir));
uint page=0, frame=0;
for(uint j=0;j<SystemBootInfo->memoryLo/4096;j++)
{
   PageTable* t=new PageTable;
   for(uint i=0;i<1024;i++,frame+=4096)
   {
      AddAtrib(&page,pteUser);
      SetFrame(&page,(uint)frame);
      AddAtrib(&page,ptePresent);
      t->entries[pteIndex(frame)]=frame;
   }
   AddAtrib(&d->entries[j], pdeWritable);
   AddAtrib(&d->entries[j], pdePresent);
   SetFrame(&d->entries[j], (uint)t);
}


AddAtrib(), SetFrame() and pteIndex() are checked to be working.

_________________
Nutoak
People are like paintings. It may be difficult for them to change any painting after they already drawn that painting.It means that it may be difficult to everybody to change their own opinion about other people after they already made an opinion.
Image


Top
 Profile  
 
 Post subject: Re: Would it be smart to map all physical addresses to virtu
PostPosted: Sat Dec 24, 2016 12:13 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 2786
Location: Chichester, UK
What makes you think anything is wrong with it? Have you checked the generated page table to make sure it is correct?


Top
 Profile  
 
 Post subject: Re: Would it be smart to map all physical addresses to virtu
PostPosted: Sun Dec 25, 2016 10:12 am 
Offline
Member
Member
User avatar

Joined: Mon Dec 28, 2015 11:11 am
Posts: 365
Location: Serbia
Finally I finished the skeleton of my memory managament. ( I sound nerdy)

_________________
Nutoak
People are like paintings. It may be difficult for them to change any painting after they already drawn that painting.It means that it may be difficult to everybody to change their own opinion about other people after they already made an opinion.
Image


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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