Loading Large Kernel's

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
oxide54
Posts: 2
Joined: Sun Apr 12, 2009 4:30 pm

Loading Large Kernel's

Post 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.!!!!!!!!!!!!!!!!!!!
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Loading Large Kernel's

Post 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.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: Loading Large Kernel's

Post 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.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Loading Large Kernel's

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Loading Large Kernel's

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Loading Large Kernel's

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
oxide54
Posts: 2
Joined: Sun Apr 12, 2009 4:30 pm

Re: Loading Large Kernel's

Post by oxide54 »

Thanks for all the responses they have been really helpfull.
Post Reply