[SOLVED] enabling paging on real processor
Posted: Sun Nov 14, 2010 3:15 pm
After adding multitasking to my kernel and getting everything working again wanted to try something fun and run the kernel on actual hardware (instead of bochs).
However, after a lot of debugging figured out that on my processor (some AMD 64 bit dual core: "AMD Turion(tm) 64 X2 Mobile Technology TL-58" according to linux /proc/cpuinfo) something went awry on turning on paging (or so I believe). For this i am using the following code:
main_map is the address of the pagedirectory anded with 0xFFFFF000 and ored with 0x8.
(figured this out by removing my identity mapping frrom pagedir, which caused pagefault (as expected) in bochs but did nothing on the real deal)
Has anyone seen something like this before or has an explanation.
For reference, on bochs i use grub 0.97 to boot (grub legacy), on the real hardware grub 1.96beta4 (the default for ubuntu 9.10).
However, after a lot of debugging figured out that on my processor (some AMD 64 bit dual core: "AMD Turion(tm) 64 X2 Mobile Technology TL-58" according to linux /proc/cpuinfo) something went awry on turning on paging (or so I believe). For this i am using the following code:
Code: Select all
asm("mov %0, %%cr3\n" : : "r" (main_map));
asm("mov %%cr0, %%eax\n"
"or 0x80000000, %%eax\n"
"mov %%eax, %%cr0" : : : "eax");
(figured this out by removing my identity mapping frrom pagedir, which caused pagefault (as expected) in bochs but did nothing on the real deal)
Has anyone seen something like this before or has an explanation.
For reference, on bochs i use grub 0.97 to boot (grub legacy), on the real hardware grub 1.96beta4 (the default for ubuntu 9.10).