Maybe something wrong with the BonaFide paging tutorial

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
bkilgore

Re:Maybe something wrong with the BonaFide paging tutorial

Post by bkilgore »

Compile a debug version of your code (-g) and make sure objdump -S shows all of the source along with the disassembly, and then post a link to it. Then maybe we'll be able to see what's going wrong. I didn't notice anything wrong with that code at a glance.
OSMAN

Re:Maybe something wrong with the BonaFide paging tutorial

Post by OSMAN »

The thing is I don't have a server. So, this is the only way I could make it fit as an attachment: binary kernel in .zip. Sorry. Maybe you can make something out of it. ::) (... with objdump)
bkilgore

Re:Maybe something wrong with the BonaFide paging tutorial

Post by bkilgore »

You're kernel is loaded above 0x1000000, which is above 16MB. The first page table (and all of the pages in it) only cover 0-4MB, since each table holds 1024 pages, and each page is 4KB. In order to identity map your kernel, you need to be identity mapping all the way up through 16MB, which involves at least 5 page tables (page_directory[00] through page_directory[4]).

Well, if you just want your kernel to run, and dont need to access any of the other low memory, you can probably just map from 16-20MB for now.

Try changing your code to:

Code: Select all

   unsigned long address=0; // holds the physical address of where a page is
and

Code: Select all

  // fill the first entry of the page directory
   page_directory[4] = page_table; // attribute set to: supervisor level, read/write, present(011 in binary)
   page_directory[4] = page_directory[4] | 3;
   
   // For all the yet unused page tables
   for(i=0; i<1024; i++)
   {
      if (i != 4)
         page_directory[i] = 0 | 3; // attribute set to: supervisor level, read/write, present(011 in binary)
   };
OSMAN

Re:Maybe something wrong with the BonaFide paging tutorial

Post by OSMAN »

Thank you so much! It truly was just an issue of that 16 Mb location whose meaning I don't even remember. Now I set it to 1 Mb, and the kernel and the paging work! :D
bkilgore

Re:Maybe something wrong with the BonaFide paging tutorial

Post by bkilgore »

Isn't it great when things start working? :)
Post Reply