Page 1 of 1

Bootloader Problem

Posted: Fri May 02, 2008 7:47 am
by steward
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?

Posted: Fri May 02, 2008 8:01 am
by crackcell
Maybe you can write a boot sector to load the boot loader.

Posted: Fri May 02, 2008 8:01 am
by JamesM
Not again. Did you not get flamed enough last time?

Posted: Fri May 02, 2008 8:02 am
by AJ
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

Posted: Fri May 02, 2008 8:05 am
by AJ
JamesM wrote:Not again. Did you not get flamed enough last time?
Didn't spot this - in which case I should add that the kernel must be a kernel - not just any application!

Cheers,
Adam

Posted: Fri May 02, 2008 8:23 am
by steward
My source code is assembly code that shows hardware spec by SMBIOS.

if you want i can send it to you that have a look at it and say your suggestion.ok? if ok post your email.

thx

Posted: Fri May 02, 2008 8:56 am
by AJ
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

Posted: Fri May 02, 2008 10:11 am
by crackcell
I think reading some sample code will make some difference.

This one may help you:

http://www.jamesmolloy.co.uk/tutorial_html/index.html

Posted: Fri May 02, 2008 10:23 am
by steward
THx for your attention.can you tell me more about grub?

How should i use it with my kernel?

Posted: Fri May 02, 2008 10:46 am
by JamesM
steward wrote:THx for your attention.can you tell me more about grub?

How should i use it with my kernel?
I really wish I knew if you were trolling or not.

Posted: Fri May 02, 2008 11:02 am
by steward
I really want to know sth.guid please

Posted: Fri May 02, 2008 1:41 pm
by AJ
JamesM wrote:I really wish I knew if you were trolling or not.
I wish I could work that out too.

@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

Posted: Fri May 02, 2008 2:00 pm
by steward
Really thx.ok