Page 1 of 1
Loading Large Kernel's
Posted: Sun Apr 12, 2009 4:40 pm
by oxide54
Hi,
great forum here.
I've been looking at various kernel examples and bootsectors/stage2's and have started looking at building my kernel. I have some questions.
How do I load a large kernel from the bootloader, presumable I don't have much ram available starting in realmode.
What areas of memory are used for what e.g. bios etc. when the bootsector loads.
Whats the max amount of memory i can use for loading in real mode.
Would I then have to
while ( remaining )
{
RealMode();
loaddata ([out] realmode buffer,[in,out]size);
ProtectedMode();
copydata([in] realmodebuffer, [out] pmodebuffer, [in,out]size)
remaining -= size;
}
I'm not intending on have a massive kernel. But 640kb or 1mb could be quite restrictive. I wouldn't like to end up stuck later down the line.
thanks in advance
oxide54
EDIT : Use unreal mode.!!!!!!!!!!!!!!!!!!!
Re: Loading Large Kernel's
Posted: Sun Apr 12, 2009 9:11 pm
by Dex
Yes some use unrealmode, but i would use (if my kernel32 got to big) going to and from pmode or you could code pmode drivers, which i can also use.
But i have been working on my OS for many many years it got many built in function (fdd,hdd,ATAPI,usb, fat12/16/32, CLI, etc) and still only 60k.
Re: Loading Large Kernel's
Posted: Sun Apr 12, 2009 9:32 pm
by frank
You could use GRUB which loads the kernel at 1mb (or anywhere you tell it practically). That way you would have practically the rest of the address space to use and a proven boot loader. Problems in your boot loader are incredible hard to track down.
Re: Loading Large Kernel's
Posted: Mon Apr 13, 2009 6:01 am
by egos
oxide54 wrote:What areas of memory are used for what e.g. bios etc. when the bootsector loads.
Whats the max amount of memory i can use for loading in real mode.
0-3FFh - IVT
400h-4FFh - BDA
500h-AMT - available for using. You can get AMT value in kilobytes by calling int 12h.
AMT-0A0000h - EBDA
oxide54 wrote:But 640kb or 1mb could be quite restrictive.
I don't think so. If your kernel is modular, then it's more than enough.
Re: Loading Large Kernel's
Posted: Mon Apr 13, 2009 6:21 am
by Love4Boobies
egos wrote:oxide54 wrote:What areas of memory are used for what e.g. bios etc. when the bootsector loads.
Whats the max amount of memory i can use for loading in real mode.
0-3FFh - IVT
400h-4FFh - BDA
500h-AMT - available for using. You can get AMT value in kilobytes by calling int 12h.
AMT-0A0000h - EBDA
oxide54 wrote:But 640kb or 1mb could be quite restrictive.
I don't think so. If your kernel is modular, then it's more than enough.
A couple of quick notes:
- The IVT may not be located at 00H. Think about it for a bit; that is the default position when you first boot. However, people are known to also use chain loading. What if the 1st boot loader moves the IVT (for some unknown reason) to some other place and you rewrite it? It would probably be safest to turn off interrupts until you set your own IVT or until you get to pmode/64-bit mode altogether.
- There might be some empty space between the EBDA and A0000H.
- What's your point with the modular kernel? Modules have to be loaded too. And it's somewhat uncomfortable having to load the VFS, FS driver(s), ATA (or the like) driver and let them do the rest of the job from pmode. I'd go for a more uniform solution.
Re: Loading Large Kernel's
Posted: Mon Apr 13, 2009 7:04 am
by egos
Love4Boobies wrote:
- The IVT may not be located at 00H. Think about it for a bit; that is the default position when you first boot. However, people are known to also use chain loading. What if the 1st boot loader moves the IVT (for some unknown reason) to some other place and you rewrite it? It would probably be safest to turn off interrupts until you set your own IVT or until you get to pmode/64-bit mode altogether.
The good soft for boot management wouldn't to do so. When RM kernel code is starting, it supposes that IVT would have the default position setting by BIOS.
Love4Boobies wrote:
- There might be some empty space between the EBDA and A0000H.
You are right. But I didn't see like this however.
Love4Boobies wrote:
- What's your point with the modular kernel? Modules have to be loaded too. And it's somewhat uncomfortable having to load the VFS, FS driver(s), ATA (or the like) driver and let them do the rest of the job from pmode. I'd go for a more uniform solution.
I load general kernel module and boot device and file system driver when being in RM, but load all other drivers later.
Re: Loading Large Kernel's
Posted: Thu Apr 16, 2009 7:16 pm
by oxide54
Thanks for all the responses they have been really helpfull.