FATX - Technical Design - Boot Sector - BIOS Parameter Block

BIOS Parameter Block

Common structure of the first 25 bytes of the BIOS Parameter Block (BPB) used by FAT versions since DOS 2.0 (bytes at sector offset 0x00B to 0x017 are stored since DOS 2.0, but not always used before DOS 3.2, values at 0x018 to 0x01B are used since DOS 3.0):

Sector Offset BPB Offset Length (bytes) Description
0x00B 0x00 2 Bytes per logical sector in powers of two; the most common value is 512. Some operating systems don't support other sector sizes. For simplicity and maximum performance, the logical sector size is often identical to a disk's physical sector size, but can be larger or smaller in some scenarios.

The minimum allowed value for non-bootable FAT12/FAT16 volumes with up to 65535 logical sectors is 32 bytes, or 64 bytes for more than 65535 logical sectors. The minimum practical value is 128. Some pre-DOS 3.31 OEM versions of DOS used logical sector sizes up to 8192 bytes for logical sectored FATs. Atari ST GEMDOS supports logical sector sizes between 512 and 4096. DR-DOS supports booting off FAT12/FAT16 volumes with logical sector sizes up to 32 KB and INT 13h implementations supporting physical sectors up to 1024 bytes/sector. The minimum logical sector size for standard FAT32 volumes is 512 bytes, which can be reduced downto 128 bytes without support for the FS Information Sector.

Floppy drives and controllers use physical sector sizes of 128, 256, 512 and 1024 bytes (f.e. PC/AX). The Atari Portfolio supports a sector size of 512 for volumes larger than 64 KB, 256 bytes for volumes larger 32 KB and 128 bytes for smaller volumes. Magneto-optical drives used sector sizes of 512, 1024 and 2048 bytes. In 2005 some Seagate custom hard disks used sector sizes of 1024 bytes instead of the default 512 bytes. Advanced Format hard disks use 4096 bytes per sector (4Kn) since 2010, but will also be able to emulate 512 byte sectors (512e) for a transitional period.

0x00D 0x02 1 Logical sectors per cluster. Allowed values are powers of two from 1 to 128. Some MS-DOS 3.x versions supported a maximum cluster size of 4 KB only, whereas modern MS-DOS/PC DOS and Windows 95 support a maximum cluster size of 32 KB. Windows 98/SE/ME partially support a cluster size of 64 KB as well, but some FCB services are not available on such disks and various applications fail to work. The Windows NT family and some alternative DOS versions such as PTS-DOS fully support 64 KB clusters. For DOS-based operating systems, the maximum cluster size remains at 32 KB or 64 KB even for sector sizes larger than 512 bytes. MS-DOS/PC DOS will hang on startup if this value is erroneously specified as 0.
0x00E 0x03 2 Count of reserved logical sectors. The number of logical sectors before the first FAT in the file system image. At least 1 for this sector, usually 32 for FAT32 (to hold the extended boot sector, FS info sector and backup boot sectors).

Since DR-DOS 7.0x FAT32 formatted volumes use a single-sector boot sector, FS info sector and backup sector, some volumes formatted under DR-DOS use a value of 4 here.

0x010 0x05 1 Number of File Allocation Tables. Almost always 2; RAM disks might use 1. Most versions of MS-DOS/PC DOS do not support more than 2 FATs. Some DOS operating systems support only two FATs in their built-in disk driver, but support other FAT counts for block device drivers loaded later on.

Volumes declaring 2 FATs in this entry will never be treated as TFAT volumes. If the value differs from 2, some Microsoft operating systems may attempt to mount the volume as a TFAT volume and use the second cluster (cluster 1) of the first FAT to determine the TFAT status.

0x011 0x06 2 Maximum number of FAT12 or FAT16 root directory entries. 0 for FAT32, where the root directory is stored in ordinary data clusters; see offset 0x02C in FAT32 EBPBs.

This value must be adjusted so that directory entries always consume full logical sectors, whereby each directory entry takes up 32 bytes. MS-DOS/PC DOS require this value to be a multiple of 16. The maximum value supported on floppy disks is 240, the maximum value supported by MS-DOS/PC DOS on hard disks is 512. DR-DOS supports booting off FAT12/FAT16 volumes, if the boot file is located in the first 2048 root directory entries.

0x013 0x08 2 Total logical sectors (if zero, use 4 byte value at offset 0x020)
0x015 0x0A 1 Media descriptor:
0xE5
  • 8-inch (200 mm) Single sided, 77 tracks per side, 26 sectors per track, 128 bytes per sector (243 KB) (DR-DOS only)
0xED
  • 5.25-inch (130 mm) Double sided, 80 tracks per side, 9 sector, 720 KB (Tandy 2000 only)
0xF0
  • 3.5-inch (90 mm) Double Sided, 80 tracks per side, 18 or 36 sectors per track (1.44 MB or 2.88 MB).
  • Designated for use with custom floppy and superfloppy formats where the geometry is defined in the BPB.
  • Used also for other media types such as tapes.
0xF8
  • Fixed disk (i.e., typically a partition on a hard disk). (since DOS 2.0)
  • Designated to be used for any partitioned fixed or removable media, where the geometry is defined in the BPB.
  • 3.5-inch Single sided, 80 tracks per side, 9 sectors per track (360 KB) (MSX-DOS only)
  • 5.25-inch Double sided, 80 tracks per side, 9 sectors per track (720 KB) (Sanyo 55x DS-DOS 2.11 only)
0xF9
  • 3.5-inch Double sided, 80 tracks per side, 9 sectors per track (720 KB) (since DOS 3.2)
  • 3.5-inch Double sided, 80 tracks per side, 18 sectors per track (1440 KB) (DOS 3.2 only)
  • 5.25-inch Double sided, 80 tracks per side, 15 sectors per track (1.2 MB) (since DOS 3.0)
0xFA
  • 3.5-inch and 5.25-inch Single sided, 80 tracks per side, 8 sectors per track (320 KB)
  • Used also for RAM disks and ROM disks (f.e. on HP 200LX)
  • Hard disk (Tandy MS-DOS only)
0xFB
  • 3.5-inch and 5.25-inch Double sided, 80 tracks per side, 8 sectors per track (640 KB)
0xFC
  • 5.25-inch Single sided, 40 tracks per side, 9 sectors per track (180 KB) (since DOS 2.0)
0xFD
  • 5.25-inch Double sided, 40 tracks per side, 9 sectors per track (360 KB) (since DOS 2.0)
  • 8-inch Double sided, 77 tracks per side, 26 sectors per track, 128 bytes per sector (500.5 KB)
  • (8-inch Double sided, (single and) double density (DOS 1))
0xFE
  • 5.25-inch Single sided, 40 tracks per side, 8 sectors per track (160 KB) (since DOS 1.0)
  • 8-inch Single sided, 77 tracks per side, 26 sectors per track, 128 bytes per sector (250.25 KB)
  • 8-inch Double sided, 77 tracks per side, 8 sectors per track, 1024 bytes per sector (1232 KB)
  • (8-inch Single sided, (single and) double density (DOS 1))
0xFF
  • 5.25-inch Double sided, 40 tracks per side, 8 sectors per track (320 KB) (since DOS 1.1)
  • Hard disk (Sanyo 55x DS-DOS 2.11 only)

This value must reflect the media descriptor stored (in the entry for cluster 0) in the first byte of each copy of the FAT. Certain operating systems before DOS 3.2 (86-DOS, MS-DOS/PC DOS 1.x and MSX-DOS version 1.0) ignore the boot sector parameters altogether and use the media descriptor value from the first byte of the FAT to choose among internally pre-defined parameter templates. Must be greater or equal to 0xF0 since DOS 4.0.

On removable drives, DR-DOS will assume the presence of a BPB if this value is greater or equal to 0xF0, whereas for fixed disks, it must be 0xF8 to assume the presence of a BPB.

Initially, these values were meant to be used as bit flags; for any removable media without a recognized BPB format and a media descriptor of either 0xF8 or 0xFA to 0xFF MS-DOS/PC DOS treats bit 1 as a flag to choose a 9-sectors per track format rather than an 8-sectors format, and bit 0 as a flag to indiciate double-sided media. Values 0x00 to 0xEF and 0xF1 to 0xF7 are reserved and must not be used.

0x016 0x0B 2 Logical sectors per File Allocation Table for FAT12/FAT16, 0 for FAT32 (cf. offset 0x024 below)

DOS 3.0 BPB:

The following extensions were documented since DOS 3.0, however, they were already supported by some issues of DOS 2.13. MS-DOS 3.10 still supported the DOS 2.0 format, but could use the DOS 3.0 format as well.

Sector Offset BPB Offset Length (bytes) Description
0x00B 0x00 13 DOS 2.0 BPB
0x018 0x0D 2 Physical sectors per track for disks with INT 13h CHS geometry, e.g., 15 for a 1.20 MB floppy.

A zero entry indicates that this entry is reserved, but not used.

0x01A 0x0F 2 Number of heads for disks with INT 13h CHS geometry, e.g., 2 for a double sided floppy.

A bug in all versions of MS-DOS/PC DOS up to including 7.10 causes these operating systems to crash for CHS geometries with 256 heads, therefore almost all BIOSes choose a maximum of 255 heads only.

A zero entry indicates that this entry is reserved, but not used.

0x01C 0x11 2 Count of hidden sectors preceding the partition that contains this FAT volume. This field should always be zero on media that are not partitioned. This DOS 3.0 entry is incompatible with a similar entry at offset 0x01C in BPBs since DOS 3.31.

It must not be used if the logical sectors entry at offset 0x013 is zero.

DOS 3.2 BPB:

Officially, MS-DOS 3.20 still used the DOS 3.0 format, but SYS and FORMAT were adapted to support a 6 bytes longer format already (of which not all entries were used).

Sector Offset BPB Offset Length (bytes) Description
0x00B 0x00 19 DOS 3.0 BPB
0x01E 0x13 2 Total logical sectors including hidden sectors. This DOS 3.2 entry is incompatible with a similar entry at offset 0x020 in BPBs since DOS 3.31.

It must not be used if the logical sectors entry at offset 0x013 is zero.

DOS 3.31 BPB:

Officially introduced with DOS 3.31 and not used by DOS 3.2, some DOS 3.2 utilities were designed to be aware of this new format already. Official documentation recommends to trust these values only if the logical sectors entry at offset 0x013 is zero.

Sector Offset BPB Offset Length (bytes) Description
0x00B 0x00 13 DOS 2.0 BPB
0x018 0x0D 2 Physical sectors per track for disks with INT 13h CHS geometry, e.g., 18 for a 1.44 MB floppy. Unused for drives, which don't support CHS access any more. Identical to an entry available since DOS 3.0.

A zero entry indicates that this entry is reserved, but not used. A value of 0 may indicate LBA-only access, but may cause a divide-by-zero exception in some boot loaders, which can be avoided by storing a neutral value of 1 here, if no CHS geometry can be reasonably emulated.

0x01A 0x0F 2 Number of heads for disks with INT 13h CHS geometry, e.g., 2 for a double sided floppy. Unused for drives, which don't support CHS access any more. Identical to an entry available since DOS 3.0.

A bug in all versions of MS-DOS/PC DOS up to including 7.10 causes these operating systems to crash for CHS geometries with 256 heads, therefore almost all BIOSes choose a maximum of 255 heads only.

A zero entry indicates that this entry is reserved, but not used. A value of 0 may indicate LBA-only access, but may cause a divide-by-zero exception in some boot loaders, which can be avoided by storing a neutral value of 1 here, if no CHS geometry can be reasonably emulated.

0x01C 0x11 4 Count of hidden sectors preceding the partition that contains this FAT volume. This field should always be zero on media that are not partitioned. This DOS 3.31 entry is incompatible with a similar entry at offset 0x01C in DOS 3.0-3.3 BPBs. At least, it can be trusted if it holds zero, or if the logical sectors entry at offset 0x013 is zero.

If this belongs to an Advanced Active Partition (AAP) selected at boot time, the BPB entry will be dynamically updated by the enhanced MBR to reflect the "relative sectors" value in the partition table, stored at offset 0x1B6 in the AAP or NEWLDR MBR, so that it becomes possible to boot the operating system from EBRs.

0x020 0x15 4 Total logical sectors (if greater than 65535; otherwise, see offset 0x013). This DOS 3.31 entry is incompatible with a similar entry at offset 0x01E in DOS 3.2-3.3 BPBs. Officially, it must be used only if the logical sectors entry at offset 0x013 is zero, but some operating systems (some old versions of DR DOS) use this entry also for smaller disks.

A simple formula translates a volume's given cluster number CN to a logical sector number LSN:

  1. Determine (once) SSA=RSC+FN×SF+ceil((32×RDE)/SS), where the reserved sector count RSC is stored at offset 0x00E, the FAT number FN at offset 0x010, the sectors per FAT SF at offset 0x016 (FAT12/FAT16) or 0x024 (FAT32), the root directory entries RDE at offset 0x011, the sector size SS at offset 0x00B, and ceil(x) rounds up to a whole number.
  2. Determine LSN=SSA+(CN-2)×SC, where the sectors per cluster SC are stored at offset 0x00D.

On unpartitioned media the volume's number of hidden sectors is zero and therefore LSN and LBA addresses become the same for as long as a volume's logical sector size is identical to the underlying medium's physical sector size. Under these conditions, it is also simple to translate between CHS addresses and LSNs as well:

LSN=SPT×(HN+(NOS×TN))+SN-1, where the sectors per track SPT are stored at offset 0x018, and the number of sides NOS at offset 0x01A. Track number TN, head number HN, and sector number SN correspond to Cylinder-head-sector: the formula gives the known CHS to LBA translation.

Read more about this topic:  FATX, Technical Design, Boot Sector

Famous quotes containing the word block:

    It is, in both cases, that a spiritual life has been imparted to nature; that the solid seeming block of matter has been pervaded and dissolved by a thought; that this feeble human being has penetrated the vast masses of nature with an informing soul, and recognised itself in their harmony, that is, seized their law. In physics, when this is attained, the memory disburthens itself of its cumbrous catalogues of particulars, and carries centuries of observation in a single formula.
    Ralph Waldo Emerson (1803–1882)