Page 1 of 1

confuse about sectors

Posted: Tue Sep 09, 2008 5:52 pm
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

Re: confuse about sectors

Posted: Tue Sep 09, 2008 7:56 pm
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

Re: confuse about sectors

Posted: Tue Sep 09, 2008 9:04 pm
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 ;)

Re: confuse about sectors

Posted: Tue Sep 09, 2008 11:02 pm
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

Re: confuse about sectors

Posted: Tue Sep 09, 2008 11:26 pm
by xyjamepa
Hi,
this may help.