Page 2 of 2

Re: Paging, yes I read the wiki

Posted: Sun Jun 21, 2009 3:52 am
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.

Re: Paging, yes I read the wiki

Posted: Sun Jun 21, 2009 9:20 am
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).

Re: Paging, yes I read the wiki

Posted: Sun Jun 21, 2009 4:39 pm
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.