loading kernel to location other than 1MB?

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.
Post Reply
mrnoob
Member
Member
Posts: 26
Joined: Thu Sep 18, 2008 11:45 am

loading kernel to location other than 1MB?

Post by mrnoob »

Hi,

ive just completed a fat16 bootloader, but im trying to consider how to proceed. As the first few lines of the kernel are still in real mode (the fat16 bootloader lives entirely in the MBR and so has no space to switch to protected) i cannot place the kernel at 1MB, the standard location. Is there any problem with me loading it at somewhere earlier, e.g. the 1KB boundary, apart from having to jump around the EBDA and other annoyances? Or is there a workaround for this?

Thanks in advance
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: loading kernel to location other than 1MB?

Post by Combuster »

There is no real issue with having a kernel below 1MB, other than having a limited amount of space for your kernel to fit in (some 500k), and your bootloader being in the middle (just below the 32k mark)

What most people do is use unreal mode, or a two-stage bootloader to make loading at 1M a lot easier. And some are able to fit it all in 512 bytes.
"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 ]
mrnoob
Member
Member
Posts: 26
Joined: Thu Sep 18, 2008 11:45 am

Re: loading kernel to location other than 1MB?

Post by mrnoob »

surely if i jmp instead of call to the kernel i can overwrite the bootloader in memory? seen as i wont be returning there.
[edit] never mind, i just realised that if the kernel overran the bootloader the jmp to the kernel would be overwritten and the kernel would begin execution halfway through.
LoseThos
Member
Member
Posts: 112
Joined: Tue Oct 30, 2007 6:41 pm
Location: Las Vegas, NV USA
Contact:

Re: loading kernel to location other than 1MB?

Post by LoseThos »

My boot loader relocates itself to the 90000h area. It loads a 2nd stage loader, though, which doubles as half the kernel. The 2nd stage module loads in the range 40000h-70000h. When it runs, I loads the remainder above 1 Meg.
mrnoob
Member
Member
Posts: 26
Joined: Thu Sep 18, 2008 11:45 am

Re: loading kernel to location other than 1MB?

Post by mrnoob »

hmm im starting to get an idea of what ill do. as ive chosen a heavily abstracted microkernel as my design, i might load it to 0x10000/64kb and simply have the kernel parse the filesystem and load a bunch of drivers and such in over the 1MB boundary, then set them to work. Basically a mix of second stage bootloader and kernel.

Thanks for the advice :)
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: loading kernel to location other than 1MB?

Post by Combuster »

LoseThos wrote:My boot loader relocates itself to the 90000h area.
Which may very well be inside the EBDA :roll:
"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 ]
Post Reply