Enabling paging outside bootloader?

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
chibicitiberiu
Posts:22
Joined:Sat Jul 17, 2010 7:55 am
Enabling paging outside bootloader?

Post by chibicitiberiu » Fri Aug 19, 2011 7:45 am

I am using Grub instead of my own bootloader, I decided to drop it because it had some bugs on real hardware.

However, in the tutorial paging is enabled from the bootloader, and Grub doesn't enable paging. So my guess is that I have to do that in the loader (the asm code executed just before entering main, which sets up the stack, verifies the bootloader etc). And how can I do the jump to higher space (e.g. 0xC0000000), since the kernel is linked at 0x100000?

If this might help, I'm using Cygwin, I compiled gcc and binutils myself, and output format is i586-elf.

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: Enabling paging outside bootloader?

Post by Andyhhp » Sat Aug 20, 2011 4:30 pm

Cant you edit a flag in your multiboot header to cause grub to initialise paging?

Otherwise, the alternative is to link your kernel to 0xC0000000 and have a short stub at the entry point which sets up identitiy paging, then jumps to main.

~Andrew
Image

chibicitiberiu
Posts:22
Joined:Sat Jul 17, 2010 7:55 am

Re: Enabling paging outside bootloader?

Post by chibicitiberiu » Sun Aug 21, 2011 10:27 am

Andyhhp wrote:Cant you edit a flag in your multiboot header to cause grub to initialise paging?

Otherwise, the alternative is to link your kernel to 0xC0000000 and have a short stub at the entry point which sets up identitiy paging, then jumps to main.

~Andrew
Thank you for your reply.

I'm not sure, I can't find info about flags anywhere. The only info I could find was that bit 0 is for 4k aligning, bit1 is for memory info, and bit 2 is for video info, and bit16 has to do with where the kernel is loaded. Nothing about the rest of the bits.

Could you give some more details about second method? Do I have to create an additional 'stage', to load and execute the kernel? Or how can I do something like that? Or create an additional section in the asm code, which will be linked at 0x100000, and all the other sections will be linked at 0xC000000?

Post Reply