flat assembler
Message board for the users of flat assembler.

Index > OS Construction > bytes per sector

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
I wonder if there could be a device (HDD, floppy, other drive) with physical BytesPerSector not equal to 512? If I use, for example, 1024 bytes per sector for FAT and I want to read 4 sectors, then I should read 8 physical sectors. Am I right?
Post 13 May 2005, 22:27
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu
FLoppy disks are capable of:
128,256,512,1024,2048,8192 and some even 16384 of bytes per sector. Althoug aparently it should be usefull, it doesent make them any good.

HDD only use 512bytes per sector. That is good for standardization.

Internaly HDDs might and do use a diferent sector size/track layout but they all expose the same fixed 512bytes sector to the external world.
Post 14 May 2005, 04:25
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Bogdan, is this also true for SCSI disks?
Post 14 May 2005, 14:00
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Quote:
HDD only use 512bytes per sector. That is good for standardization.


Not true! I've encountered more than one SCSI hard drive using 520 byte sectors. Others have mentioned a range of 512 - 528 bytes per sector on various SCSI drives.
Post 14 May 2005, 19:22
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
SCSI is a differnet animal in itself as are older HDD. You used to be able to low level format HDD which was recommended for aligning the heads to the tracks and sectors, especially if you were encountering bad tracks. Back then and for SCSI (depends on your interface too) you could specify secotor sizes based on multiples of 128 bytes. As you can imagine, 128 bytes is very inefficient because there is an additional 64 (not all are the same, some have more some have less) bytes per sector on the disk that identifies low level specifics of the sector which would be 1/3 data description 2/3 data. Which leads into the specifics of the physical layout and sector sizes. Most HD companies do not adhere to a 2^n format for bytes per sector. Some will say that 1MB is 1,000,000 bytes and not 1024^2. This is the difference between RAM and magnetic media, as RAM has address lines. Each address line is either a one or zero (high or low) and therefore each address line is more important in consideration than specific bytes. But with magnetic media it is laid out in a circular pattern and is far easier to work in decimal than in binary.

But this is all moot when you put most OS file formats on a disc. The file systems tend to format into specific buffer sizes to make things easier to manipulate.

Also, most IDE drives these days will not allow you to do low level formating any longer and abstract a layer which makes it appear the disc is giving you a quasi standard of 512 bytes.

So, to get back on topic and to answer the initial question. Floppies can be, as well as FAT 12 can be, 1024 bytes per sector. If you are to read those sectors they are physical sectors, thus you would read only those four sectors. However, a caveat, your boot sector, regardless of all the rest, has to be 512 bytes to be compatible with FAT 12 (16/32).
Post 14 May 2005, 22:22
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
And what should I do if I have, for example, 2048 (or greater) BytesPerSector, but I need to read only 1024 (or 512, etc.) of them (with INT 13h) and I do not have a buffer to store the whole sector, only 1024 (or 512) bytes that I need? Or if I use 1024 (or 2048) BytesPerSector then I need at least 1024 (or 2048) and not less bytes of RAM to read this sector?
Post 15 May 2005, 09:24
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu
fodder:

Nope the SCSI and the ATAPI counterparts use an aproximatively 2048 bytes per sector standard.

But yes smiddy is right... the real sector stored on the physical media is greater that the usefull data payload and a lot of bytes are wasted with 128bytes sectors. Sector sizes of 2048 bytes or higher are faster and have more usefull data payload but do waste space with multiple very small size files. So the 512 bytes is the middle compromise that is always used by IDE HDDs.

zhak:
For the floppy I do not think that the BIOS supports non 512 bytes per sector. The FDC controller does but you would have to write your own drivers and talk directly to the floppy chip for this.

HDD do not support this and honestly the floppy is no speed champion and I see no purpose into tweaking it...
Post 15 May 2005, 10:35
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
@zhak:

The BIOS, as bogdanontanu says requires your boot sector to be 512 bytes. Also a signature at the end of the 512 byte sector is needed:

Code:
dw 0AA55h
    


My saying it was because of FAT 12 (16/32) was incorrect (whoops; its been a while).

To answer your questions is a bit difficult because it means you have to do specific arbitration for potential situations. You would need to figure out the number of combinations and the number of permutations and all possible outcomes and code it accordingly for each case, that is if you wanted to do an intelligent design. You can always say that anything not of your design standard is not supported, which is what most OSes do. You can not predict or use all combinations and permutations as there are too many to deal with, especially within the boot sector requirement of 512 bytes of code.
Post 15 May 2005, 11:54
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
So, smiddy, you suggest not to make boot-time support for non-standart disk formats and use only default 512 BytesPerSector? Maybe you're right, but it could make the solution more universal, I thought...
Post 15 May 2005, 15:58
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
I did some experiments with different BytesPerSector. You can specify say 1024 when you format, however, at bytes 511 and 512 of that sector you will need a 55 AAh in each byte if you want to boot from it. There are a couple of FAT12 compatible formats, XDF and 2M. Here a link with more information: http://www.csa.iisc.ernet.in/resources/documentation/hypertext/fdutils/fdutils_7.html#SEC47

So, to answer your question more specifically, yes, use the default of 512 bytes, at least until you have a handle on your own file system. FAT12 discs are easily attained and help you during your debug process. Once you have developed your own file system for the floppy you can arrange it however you wish, except for the booting floppy as described above.
Post 16 May 2005, 00:29
View user's profile Send private message Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius
Don't bother. 512 is just fine. Besides, most BIOS's that I know of will load a 512-byte bootsector regardless, so that won't be helpful in that area.
Post 17 Jun 2005, 04:32
View user's profile Send private message AIM Address Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.