confuse about sectors

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
rutix
Posts: 8
Joined: Fri Jul 04, 2008 8:24 pm

confuse about sectors

Post by rutix »

i m coding a boot loader and i m confused about floppy sectors...

if the first sector is 0 then the last sector of the first track(track 0) is 17. The first sector of the next track (track 1) is the sector 18 and so on....?

now about head's. because there are 2880 sectors on floppy, from 0 to 1440 belongs to head 0, and above 1440 belongs to head 1...?

what is the starting number of the head? 0 or 1?

is it true this or not?

tnx
posman
Posts: 19
Joined: Fri Sep 05, 2008 12:55 pm

Re: confuse about sectors

Post by posman »

If you use CHS to read sectors, then first sector is 1. And yes, sectors for head 0 are from 1 to 18. But I think sectors from 19 to 36 are on head 1

Head 0 is first
bontanu
Member
Member
Posts: 134
Joined: Thu Aug 18, 2005 11:00 pm
Location: Sol. Earth. Europe. Romania. Bucuresti
Contact:

Re: confuse about sectors

Post by bontanu »

NO, you are wrong.

Each floppy has 80 Tracks. Track 0 is the first track.
Each Track has 2 heads (if the floppy is double sided). Head 0 is the first Head.
Each Head has 18 sectors (if floppy is high density). Sector 1 is teh first sector.

1)You start by reading Track:0 Head:0 Sector:1 and after you read Sector 18 you move to Head:1
2)Next you read Track:0 Head:1 Sector:1 until you read Sector 18 of Head:1 and then you move to Track:1
3)Next you read Track:1 Head:0 Sector:1 ... and continue this way.

Keep doing this until you reach Track:79 and floppy is finished or until your boot loader code ends (hopefully before floppy end)

Keep in mind that this is as simple as it gets and you as an OS developer are supposed to be a "God" in programming and are supposed to be able to understand this by yourself... if you do not or did not then maybe this is not the right development path for you.

Honestly there are many more problems to this floppy reading.

For example: you can not cross a 64K memory address boundary (DMA issues). This is Not a problem if you read one sector at a time (slow but safe) but it will become a problem if you try to read multiple sectors at a time (fast but dangerous).

Then some BIOS do support multiple sectors reading and some do not or do so partly and with limitations.

Then when you read multiple sectors you have to take care because the floppy hardware controller does not support reading from multiple tracks or sometimes multiple heads.

In consequence you will have to also worry about crossing Track/Head boundary.

Make yourself a gift and start simple by reading one sector at a time. Then make a habit from reading the specifications and available documentation 10 times (an I really do mean this)

Things are very easy to do for a boot loader with the help of BIOS but they will get much more complicated in the long run mainly in other device drivers (ATA,PCI,Net, USB,Video) and when you switch to protected or long mode and loose the help of BIOS.

You need to be able to understand in between the lines, errors (yes errors in docs) or even the things that are not spoken and not written down in docs. You will need to have a very good understanding of hardware principles of functioning.

OS development can be helped by tutorials and answers on this forum but honestly it is not the kind of thing that you learn by tutorials or from others only. It requires a lot of understanding on your side.

Otherwise you will meet a lot of frustration down this road.

However I can also assure you that there is also a lot of joy on the very same road ;)
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
rutix
Posts: 8
Joined: Fri Jul 04, 2008 8:24 pm

Re: confuse about sectors

Post by rutix »

first thanks for answering, especially to @bontanu.

second...i didnt find any info about this, so i cant know it...
i was looking at some bootload code and getting the info about the sectors from there. i know that there is 2 heads, 80 tracks, 18 sectors per track but i was confused about the order of the reading....

gritz
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Re: confuse about sectors

Post by xyjamepa »

Hi,
this may help.
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
Post Reply