Paging, yes I read the wiki

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.
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: Paging, yes I read the wiki

Post by ru2aqare »

brodeur235 wrote:VBox is aborting when I try to actually enable paging by setting cr3 with the address of the page dir and turning on the last bit of cr0. The following asm is in my kernel's main:

Code: Select all

	;this part works fine
	mov eax,0x000B8000
	add eax,(80*25*2)           ;where to begin page directory (right after vid-mem)
I think the problem lies there. Paging structures are required to be aligned on page boundaries as far as I know (check the Intel manuals to be sure), and the sum of 0xB8000+(80*25*2) is not divisible by 4096. Therefore the address will be off by a page and some reserved bits may be set. Probably this is what makes your emulator refuse the code.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Paging, yes I read the wiki

Post by Combuster »

That and emulators are known to shoot you in the foot when you put data in video memory (or any other form of memory mapped I/O) - which is a Bad Idea(tm).
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
OrOS
Member
Member
Posts: 143
Joined: Sat Sep 08, 2007 11:26 pm
Location: Canada

Re: Paging, yes I read the wiki

Post by OrOS »

A. You're assuming the video memory is 80*25*2. Believe it or not, your monitor can do more then show a default console.
B. If you're using grub, you should be reading the memory map, not blindly assigning data structures to memory
C. System structures should always be page aligned (even if they don't need to be.) It takes two runs to access an un-aligned memory address, 1 for aligned.
Post Reply