Page 1 of 1

question about boot sector

Posted: Sat May 28, 2011 4:16 am
by taxus
Hello everyone,now I'm trying to write a boot sector
I had read some documents
What bother me is whether the boot sector must have a function to locate where is the loader.bin
I don't know where to find a good tutorial about boot sector,thanks for give me some advise

PS.Is the boot sector always means dos boot sector?

Re: question about boot sector

Posted: Sat May 28, 2011 8:32 am
by Chandra
Google.

Re: question about boot sector

Posted: Sat May 28, 2011 8:36 am
by bluemoon
taxus wrote:Hello everyone,now I'm trying to write a boot sector
To program a boot sector, check the wiki resources below.
To write a boot sector using dd

Code: Select all

dd if=boot0.bin of=(partition) bs=1 skip=0 seek=0 count=512 conv=notrunc
taxus wrote:I had read some documents. What bother me is whether the boot sector must have a function to locate where is the loader.bin
No it's not a must, a boot sector may load code from anywhere, or execute random instructions, or just hang.
taxus wrote:I don't know where to find a good tutorial about boot sector,thanks for give me some advise
PS.Is the boot sector always means dos boot sector?
Did you check the wiki? 3 hits on the same site. PS. boot sector always means boot sector.

Re: question about boot sector

Posted: Sat May 28, 2011 9:47 am
by taxus
bluemoon wrote:
taxus wrote:Hello everyone,now I'm trying to write a boot sector
To program a boot sector, check the wiki resources below.
To write a boot sector using dd

Code: Select all

dd if=boot0.bin of=(partition) bs=1 skip=0 seek=0 count=512 conv=notrunc
taxus wrote:I had read some documents. What bother me is whether the boot sector must have a function to locate where is the loader.bin
No it's not a must, a boot sector may load code from anywhere, or execute random instructions, or just hang.
taxus wrote:I don't know where to find a good tutorial about boot sector,thanks for give me some advise
PS.Is the boot sector always means dos boot sector?
Did you check the wiki? 3 hits on the same site. PS. boot sector always means boot sector.

Wow,quite thanks for that ,your answer give me a lot of help,thanks

Re: question about boot sector

Posted: Sat May 28, 2011 10:02 am
by taxus
berkus wrote:Have you tried reading before writing?

What problems did you encounter with writing? There are no specifics. All I can advise is go read some more documentation.
yea,I had read three or four documents,but I just don't know whether the boot sector must find the loader.bin
that means,can the loader.bin in a static address that the boot sector don't need a function to find where it is?
and also the loader don't need a function to find where is the kernel,does it possible?

Re: question about boot sector

Posted: Sat May 28, 2011 10:29 am
by bluemoon
It's up to your design where to place your 2nd stage loader
Some common examples:
  • * in a file in boot partition (which you need to understand the file system and code in limited space, less than 512 bytes)
  • * pre-defined sectors. If you have your own FS, you may put things starting right after the boot sector
  • * For FAT, the reserved area is safe to abuse, and is configurable for different size
  • * Fetch from TFTP. Ok this is not so common. :lol:
However, I would strongly advice to put kernel image(s) into file as it can someday grow to megabytes.
It will be ugly to place it on special sectors, or have the user to reformat the disk just to upgrade a bigger kernel.
also the loader don't need a function to find where is the kernel,does it possible?
Yes, if you pre-calculate the sector number of 2nd stage loader (and kernel images) and put that information into the loader.

Re: question about boot sector

Posted: Tue Jun 07, 2011 7:59 am
by taxus
I'm so appreciate for your help
It works now,I used a function to find the loader
maybe later I will try to calculate the address before that