Bootloader Problem

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
steward
Member
Member
Posts: 27
Joined: Wed Apr 02, 2008 8:36 am

Bootloader Problem

Post 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?
User avatar
crackcell
Posts: 7
Joined: Sat Mar 22, 2008 3:41 am
Location: Wuhan University

Post by crackcell »

Maybe you can write a boot sector to load the boot loader.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Not again. Did you not get flamed enough last time?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
steward
Member
Member
Posts: 27
Joined: Wed Apr 02, 2008 8:36 am

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
crackcell
Posts: 7
Joined: Sat Mar 22, 2008 3:41 am
Location: Wuhan University

Post 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
steward
Member
Member
Posts: 27
Joined: Wed Apr 02, 2008 8:36 am

Post by steward »

THx for your attention.can you tell me more about grub?

How should i use it with my kernel?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
steward
Member
Member
Posts: 27
Joined: Wed Apr 02, 2008 8:36 am

Post by steward »

I really want to know sth.guid please
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
steward
Member
Member
Posts: 27
Joined: Wed Apr 02, 2008 8:36 am

Post by steward »

Really thx.ok
Post Reply