Build BPB (Device-Driver Function 02h)

BUILDBPBREQUEST STRUC

bbrLength db ? ;length of record, in bytes

bbrUnit db ? ;unit number

bbrFunction db 02h ;function number

bbrStatus dw ? ;status

bbrReserved db 8 dup(?) ;reserved

bbrMediaID db ? ;INPUT: media descriptor

bbrFATSector dd ? ;INPUT: buffer with first FAT sector

bbrBPBAddress dd ? ;OUTPUT: BPB address

BUILDBPBREQUEST ENDS

Build BPB (Device-Driver Function 02h) returns a BPB structure for the medium in the specified drive. MS-DOS calls this function whenever Media Check (Device-Driver Function 01h) specifies that the medium has changed or that it might have been changed and no disk-write operations are pending.

This function is required for block-device drivers.

Fields

bbrLength

Specifies the length, in bytes, of the BUILDBPBREQUEST structure.

bbrUnit

Specifies the unit for which to return the BPB structure.

bbrFunction

Specifies the Build BPB function: 02h.

bbrStatus

Specifies the status of the completed function. If the function is successful, the driver must set the done bit (bit 8). Otherwise, the driver must set both the error and done bits (bits 15 and 8) and copy an error value to the low-order byte.

bbrReserved

Reserved; do not use.

bbrMediaID

Specifies the media descriptor for the medium MS-DOS assumes is in the drive. Following are the most commonly used media descriptors and their corresponding media:

Value Type of medium

0F0h 3.5-inch, 2 sides, 18 sectors/track (1.44 MB); 3.5-inch, 2 sides, 36 sectors/track (2.88 MB); 5.25-inch, 2 sides, 15 sectors/track (1.2 MB). This value is also used to describe other media types.
0F8h Hard disk, any capacity.
0F9h 3.5-inch, 2 sides, 9 sectors/track, 80 tracks/side (720K); 5.25-inch, 2 sides, 15 sectors/track, 40 tracks/side (1.2 MB).
0FAh 5.25-inch, 1 side, 8 sectors/track, (320K).
0FBh 3.5-inch, 2 sides, 8 sectors/track (640K).
0FCh 5.25-inch, 1 side, 9 sectors/track, 40 tracks/side (180K).
0FDh 5.25-inch, 2 sides, 9 sectors/track, 40 tracks/side (360K). This value is also used for 8-inch disks.
0FEh 5.25-inch, 1 side, 8 sectors/track, 40 tracks/side (160K). This value is also used for 8-inch disks.
0FFh 5.25-inch, 2 sides, 8 sectors/track, 40 tracks/side (320K).

For more information about media descriptors, see Chapter 3, “File System.”

bbrFATSector

Contains the 32-bit address (segment:offset) of a buffer. The contents of the buffer depend on bit 13 in the dhAttributes field in the driver's DEVICEHEADER structure. If bit 13 is zero, the buffer contains the first sector of the first FAT on the disk; the driver uses the first byte in this buffer to determine the disk's media descriptor. In this case, the driver must not alter this buffer. If bit 13 is set, the contents of the buffer are meaningless and the driver may use the buffer as scratch space.

bbrBPBAddress

Receives the 32-bit address (segment:offset) of the BPB structure for the medium in the drive. The BPB structure has the following form:

BPB STRUC

bpbBytesPerSec dw ? ;bytes per sector

bpbSecPerClust db ? ;sectors per cluster

bpbResSectors dw ? ;number of reserved sectors

bpbFATs db ? ;number of file allocation tables

bpbRootDirEnts dw ? ;number of root-directory entries

bpbSectors dw ? ;total number of sectors

bpbMedia db ? ;media descriptor

bpbFATsecs dw ? ;number of sectors per FAT

bpbSecPerTrack dw ? ;sectors per track

bpbHeads dw ? ;number of heads

bpbHiddenSecs dd ? ;number of hidden sectors

bpbHugeSectors dd ? ;number of sectors if bpbSectors = 0

BPB ENDS

For a full description of the DEVICEHEADER and BPB structures, see Section 9.9, “Structures.”

Comments

If the driver supports removable media, Build BPB should read the volume label from the disk and save it.

See Also

Device-Driver Function 01h Media Check
Interrupt 21h Function 440Dh Minor Code 40h Set Device Parameters
Interrupt 21h Function 440Dh Minor Code 60h Get Device Parameters