OSDev.org
https://forum.osdev.org/

Would it be smart to map all physical addresses to virtua...
https://forum.osdev.org/viewtopic.php?f=15&t=31115
Page 1 of 1

Author:  Ycep [ Sat Dec 24, 2016 8:16 am ]
Post subject:  Would it be smart to map all physical addresses to virtua...

...l while boot? If not, why? What would be pros and cons of it?

Author:  BrightLight [ Sat Dec 24, 2016 9:23 am ]
Post subject:  Re: Would it be smart to map all physical addresses to virtu

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.

Author:  Ycep [ Sat Dec 24, 2016 10:53 am ]
Post subject:  Re: Would it be smart to map all physical addresses to virtu

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.

Author:  iansjack [ Sat Dec 24, 2016 12:13 pm ]
Post subject:  Re: Would it be smart to map all physical addresses to virtu

What makes you think anything is wrong with it? Have you checked the generated page table to make sure it is correct?

Author:  Ycep [ Sun Dec 25, 2016 10:12 am ]
Post subject:  Re: Would it be smart to map all physical addresses to virtu

Finally I finished the skeleton of my memory managament. ( I sound nerdy)

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/