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.
1.) wow that was obivous
2.) no reason
3.) still crashes and cr0 is still crasy (but that might be becouse the crash resets the computer so it is not set???)
void set_paging()
{
int x;
unsigned long physaddr = 0;
for(x = 0; x < 1024; x++) // set a test table with liner addressing
{
page_table[x] = physaddr | read_write | present;
physaddr += 4096;
}
page_directory[0] = (int)page_table | read_write; // set test table to first in directory
for(x = 1; x < 1024; x++) // fill directory with nonpresent pages
{
page_directory[x] = 0 | read_write;
}
write_cr3((int)page_directory); // write pointer to cr3
write_cr0(read_cr0() | 0x80000000); // set paging bit
}
Remember once you enable paging the code you are running must be mapped to the same address it was linked at. And dont for get the data segments and stack.
The way I set it all up was from my boot assembler map the kernel C code (linked for 0xc0000000 and placed at 0x00010000) and data and stack segs. I then enable paging and jump into C world.
thx ;D that fixed it, but now my progs dont work, but that is becuse there pages aren't "present", so heres what i'm trying, all my progs think there are at 0x01000000(and before paging there were), so what ill do is "malloc" a bit of mem to fit the prog, but how do i get:
vurtual(0x01000000) = phys(malloc(size)) ???
Usually the memory management system is layered: Physical Memory Manager > Virtual Memory Manager > Heap/Something.
MapPage is part of the Virtual Memory Manager, it maps the given physical page at the given virtual address (creates the page table if the page directory entry is missing, creates the page table entry).
If you just want to hack it for the time being you can alter your set function to create a second page table at the appropriate offset in the page directory.
well no need to hack it i have nothing else to work on, my old mm i think you showed me (linked-list), but i've mad an experamental page table based mm but it doesn't work hear is the code: