question about boot sector

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
taxus
Posts: 9
Joined: Mon Dec 13, 2010 9:01 am

question about boot sector

Post 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?
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: question about boot sector

Post by Chandra »

Google.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: question about boot sector

Post 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.
taxus
Posts: 9
Joined: Mon Dec 13, 2010 9:01 am

Re: question about boot sector

Post 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
taxus
Posts: 9
Joined: Mon Dec 13, 2010 9:01 am

Re: question about boot sector

Post 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?
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: question about boot sector

Post 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.
taxus
Posts: 9
Joined: Mon Dec 13, 2010 9:01 am

Re: question about boot sector

Post 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
Post Reply