Hi everybody,
I have wrote a simple boot-loader that loads a kernel( < 64kb written completely in ASM) and jumps to it. But I have a problem - I don't know how to load a bigger kernel (i.e. more than 64kb - At the moment I have a kernel of size 74Kb approx that I created using djgpp and nasm).
If I stayed at real mode and loaded it using INT13, how and where will my kernel get loaded ? I believe segments can span only upto 64kb in real mode.
And if I switched to Pmode first using my bootloader, how can I load the kernel from disk( coz I won't have INT13 and I haven't wrote a floppy driver yet).
Help me.
Thanking in advance
modshah
Kernel Loading Dilemma
RE:Kernel Loading Dilemma
my bootsector loads the kernel in starting around 0xac00. it starts off with es=0x0ac0 and bx=0x0 and loads a sector at a time with int 0x13 calls. if bx wraps to 0, i increment es by 0x1000. i think that this will work to load a kernel more than 64k, however my kernel is smaller at the moment so i have not been able to test it.
-HOS
-HOS
RE:Kernel Loading Dilemma
If it works out well for your design, I recommend GRUB.
http://www.mcc.ac.uk/grub/multiboot_toc.html
http://www.mcc.ac.uk/grub/grub_toc.html
http://www.mcc.ac.uk/grub/multiboot_toc.html
http://www.mcc.ac.uk/grub/grub_toc.html
RE:Kernel Loading Dilemma
What I found the easiest thing to do when loading a kernel larger then 64k
from my loader was to have the loader go in and out of PMode. It takes a
little extra work but while in real mode I read the first 64k then switch to
PMode and move that 64k up to the first meg of memory. Then switch back to
real mode and use INT 13 to read the next section, go back to PMode copy the
new section to the end of the last section that was copied. You just keep
repeating until you've read as many 64k sections as needed.
Hope that helps,
-Chase
from my loader was to have the loader go in and out of PMode. It takes a
little extra work but while in real mode I read the first 64k then switch to
PMode and move that 64k up to the first meg of memory. Then switch back to
real mode and use INT 13 to read the next section, go back to PMode copy the
new section to the end of the last section that was copied. You just keep
repeating until you've read as many 64k sections as needed.
Hope that helps,
-Chase
RE:Kernel Loading Dilemma
My method is similar to what HOS wrote: I keep BX at 0x00, load one sector at a time, and increase ES after each sector by (bytes per sector) >> 4. It should work similarly.
The only disadvantage of sectorwise loading is that you have to compute track numbers etc., but this should be no problem.
If your kernel is located at contiguous sectors, you can load portions of 64kb at a time.
The only disadvantage of sectorwise loading is that you have to compute track numbers etc., but this should be no problem.
If your kernel is located at contiguous sectors, you can load portions of 64kb at a time.
RE:Kernel Loading Dilemma
I agree with Chase about loading in chunks and copying to the meg-mark. I actually use 0x4800 byte chunks and unreal mode, but the same basic idea.
RE:Kernel Loading Dilemma
Hi
Thanks for replying. I am feeling free from that dilemma. I will try both approaches 1)HOS & Xenos 2)Chase & Jamethiel. Once I make it work I will let u all know. Thanks once again.
modshah
Thanks for replying. I am feeling free from that dilemma. I will try both approaches 1)HOS & Xenos 2)Chase & Jamethiel. Once I make it work I will let u all know. Thanks once again.
modshah
RE:Kernel Loading Dilemma
I spent some time (2 years actually, sadly enough) writing bootstrappers and accompaning pmode experiments. its a waste of time as you never actually get to start on the kernel.
Here is a suggestion so you can start on your kernel. Make you kernel multiboot compliant and boot it with GRUB (or another mutliboot-compliant bootloader)
This allows you to have a kernel that is ELF or COFF - and thus can be assembled without voodoo with normal development tools. Please look over the multiboot sepcification - that stuff is gold.
----> here <-----
http://www.mcc.ac.uk/grub/multiboot_toc.html
Here is a suggestion so you can start on your kernel. Make you kernel multiboot compliant and boot it with GRUB (or another mutliboot-compliant bootloader)
This allows you to have a kernel that is ELF or COFF - and thus can be assembled without voodoo with normal development tools. Please look over the multiboot sepcification - that stuff is gold.
----> here <-----
http://www.mcc.ac.uk/grub/multiboot_toc.html
RE:Kernel Loading Dilemma
I think I am really spending too much time on my bootloader. Thanks for the suggestion - Now I am going to start real osdev with multiboot spec.
Thanks
modshah
Thanks
modshah