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.
using Mosa.Kernel.x86;
using Mosa.Runtime;
using System.Runtime.InteropServices;
namespace MOSA1
{
unsafe class PAE
{
[DllImport("PAE.o")]
public static extern void PAE_ASM(uint ptr);
public static void Initialize()
{
ulong* page_dir_ptr_tab = (ulong*)((uint)GC.AllocateObject((sizeof(ulong) * 4) + 0x20) & 0x20);
ulong* page_dir0 = (ulong*)((uint)GC.AllocateObject((sizeof(ulong) * 512) + 0x1000) & 0x1000);
ulong* page_dir1 = (ulong*)((uint)GC.AllocateObject((sizeof(ulong) * 512) + 0x1000) & 0x1000);
ulong* page_dir2 = (ulong*)((uint)GC.AllocateObject((sizeof(ulong) * 512) + 0x1000) & 0x1000);
ulong* page_dir3 = (ulong*)((uint)GC.AllocateObject((sizeof(ulong) * 512) + 0x1000) & 0x1000);
page_dir_ptr_tab[0] = (ulong)page_dir0 | 1; // set the page directory into the PDPT and mark it present
page_dir_ptr_tab[1] = (ulong)page_dir1 | 1; // set the page directory into the PDPT and mark it present
page_dir_ptr_tab[2] = (ulong)page_dir2 | 1; // set the page directory into the PDPT and mark it present
page_dir_ptr_tab[3] = (ulong)page_dir3 | 1; // set the page directory into the PDPT and mark it present
for (ulong i = 1; i < 512; i++)
{
page_dir0[i] = 0b10000011;
//page_dir1[i] = 0b10000011;
//page_dir2[i] = 0b10000011;
//page_dir3[i] = 0b10000011;
}
PAE_ASM((uint)page_dir_ptr_tab);
Console.WriteLine("PAE(Physical Address Extension) Configuration Done");
//Native.SetCR0(Native.GetCR0() | 0x80000000);
}
}
}
for (ulong i = 1; i < 512; i++)
{
page_dir0[i] = 0b10000011;
//page_dir1[i] = 0b10000011;
//page_dir2[i] = 0b10000011;
//page_dir3[i] = 0b10000011;
}
You're only setting the present, read-write, and page size flags for each entry of page_dir0, so only the first 2-MiB of physical memory is being mapped. You also have to set the base address for each 2 MiB page. See the wiki.