Bootloader Problem
Bootloader Problem
Hi to all,
I have a bootloader and sourcecode in assembly.iwant to use the source code as a kernel after bootloader in a floppy.But my problem is that the binary of kernel is more than 512 byte and is almoste 40k.
what can i do?is there any way?
Other question is that : is there any way to use an .EXE file as a kernel after bootloader?
I have a bootloader and sourcecode in assembly.iwant to use the source code as a kernel after bootloader in a floppy.But my problem is that the binary of kernel is more than 512 byte and is almoste 40k.
what can i do?is there any way?
Other question is that : is there any way to use an .EXE file as a kernel after bootloader?
Hi,
You have three options. Either:
a) Copy the kernel directly to the floppy disk after the boot loader. You will need to appropriately adjust the 'Reserved Sectors' field of the BPB. With this method, you will need to know statically what the size of the kernel is.
b) Use a boot loader which can read a formatted disk. I do this for my FAT12 boot loader - have a look -> here <- where you can download a sample FAT12 boot loader. This method will load any size kernel, but it is in real mode, so will only load to the 640k point.
c) Use GRUB - self explanatory.
As for the EXE format - you can certainly do this. GRUB will load ELF, binary (with preamble) and (I believe) AOUT. For COFF, I think you will either need to write your own loader or there is a pre-written version available for download (I think it was written by Alexi someone but can't remember the url).
My Boot Loader:
- Loads sectors 1-3 immediately after itself (from 0x7E00 onwards).
- Loads the second stage boot loader (ELF) in to memory without relocation at 0x10000 from a FAT12 disk.
- Gets a system memory map and enables A20.
- Switches to PMode.
- Relocates the ELF second stage boot loader above 1MiB as per the ELF format.
This is done in about 4 sectors, hence the first step loading sectors 1-3 to complete the executable image. The second stage boot loader is then written in C++ and does more stuff, like providing a debug console and scanning hardware. You needn't do this if your kernel starts with an assembly stub.
Cheers,
Adam
You have three options. Either:
a) Copy the kernel directly to the floppy disk after the boot loader. You will need to appropriately adjust the 'Reserved Sectors' field of the BPB. With this method, you will need to know statically what the size of the kernel is.
b) Use a boot loader which can read a formatted disk. I do this for my FAT12 boot loader - have a look -> here <- where you can download a sample FAT12 boot loader. This method will load any size kernel, but it is in real mode, so will only load to the 640k point.
c) Use GRUB - self explanatory.
As for the EXE format - you can certainly do this. GRUB will load ELF, binary (with preamble) and (I believe) AOUT. For COFF, I think you will either need to write your own loader or there is a pre-written version available for download (I think it was written by Alexi someone but can't remember the url).
My Boot Loader:
- Loads sectors 1-3 immediately after itself (from 0x7E00 onwards).
- Loads the second stage boot loader (ELF) in to memory without relocation at 0x10000 from a FAT12 disk.
- Gets a system memory map and enables A20.
- Switches to PMode.
- Relocates the ELF second stage boot loader above 1MiB as per the ELF format.
This is done in about 4 sectors, hence the first step loading sectors 1-3 to complete the executable image. The second stage boot loader is then written in C++ and does more stuff, like providing a debug console and scanning hardware. You needn't do this if your kernel starts with an assembly stub.
Cheers,
Adam
Erm...no. You have my answer above which should enable you to make the appropriate design decision. My suggestion to you is to take option c) and use GRUB with an ELF executable initially.
Looking at your assembly code should make absolutely no difference to this recommendation. Even if you are in Real Mode, you can switch back from GRUB. If that doesn't fit in with your design, try one of the other options.
Cheers,
Adam
Looking at your assembly code should make absolutely no difference to this recommendation. Even if you are in Real Mode, you can switch back from GRUB. If that doesn't fit in with your design, try one of the other options.
Cheers,
Adam
I think reading some sample code will make some difference.
This one may help you:
http://www.jamesmolloy.co.uk/tutorial_html/index.html
This one may help you:
http://www.jamesmolloy.co.uk/tutorial_html/index.html
I wish I could work that out too.JamesM wrote:I really wish I knew if you were trolling or not.
@Steward: Before continuing this thread, please do some background reading. There is plenty of info around on GRUB and writing your own boot loaders. Try using the wiki (link above), http://www.osdever.net and Google (probably in that order). There is a huge wealth of information available.
If you then get stuck on a specific point of design or implementation, please feel free to come back and ask.
Cheers,
Adam