The Disk Parameter Block (DPB)

The Disk Parameter Block (DPB)

The first CP/M versions used only 8″ disks and their disk management was processed by BDOS. Thus, it wasn’t easy to manipulate any disk format. The disk format was a part of the CP/M’s BDOS and not documented by Digital Research.

Later various mass storage devices appeared also for microcomputers and then CP/M was designed up from versions 2.0 to have all disk parameters available in “easy-to-change” tables of the BIOS ( Basic I/O System). These tables contain information about e.g. storage capacity and storage format for groups of identical configured drives. It also provides a scratch pad area for certain BDOS operations.

There are two parts for these BIOS tables:

  • The Disk Parameter Header ( DPH; one for each drive ) and
  • the Disk Parameter Block ( DPB ) which summarizes the attributes of identical groups of mass storage devices.

Given n disk drives, the DPHs are arranged in an array. The first row of 16 bytes corresponds to drive 0, with the last row corresponding to drive n-1. One array dimension follows:

DPH
offset
Contents Meaning
$00 DPBASE Base address of the DPH table.
$00 XLT Address of the logical-to-physical sector translation table, if used for this particular drive. Otherwise, the value of $0000 if there is no there is no translation table for this drive ( that is, the physical and logical sector numbers are the same ). Disk drives with identical sector translation an share the same translate table.
$02 TRACK BIOS workarea for the current track number Three scratch pad words for use within the BDOS. The initial value is unimportant.
$04 SECTOR BIOS workarea for the current sector number
$06 DIRNUM BIOS workarea for the current directory number
$08 DIRBUF Address of a 128-byte scratch pad area ( directory buffer ) for directory operations within BDOS. All DPHs address the same scratch pad area.
$0A DPB Address of a disk parameter block for this drive. Drives with identical disk characteristics can address the same disk parameter block.
$0C CSV Check Sum Vector
Sharp: Address of a scratch pad area used for software check for changed disks. This address is different for each DPH.
$0E ALV Allocation Vector
Address of a scratch pad area used by the BDOS to keep disk storage allocation information. This address is different for each DPH.
$0F last byte of ALV and the DPH

The address of the DPH depends on the machine used, but it can be determined by a simple BIOS-call ( function 9: SELECT DISK ).

A responsibility of the SELDSK subroutine is to return the base address of the DPH for the selected drive. The following sequence of operations returns the table address, with a $0000 returned if the selected drive does not exit.

SELDSK example:

NDISKS   EQU   4           ;Number of disk drives
....
SELDSK:  ;Select disk given by BC
         LXI   H,$0000     ;Error code
         MOV   A,C         ;drive ok?
         CPI   NDISKS      ;CY IF SO
         RNC               ;RET f error

         ;no error, continue
         MOV   L,C         ;low (disk)
         MOV   H,B         ;high (disk)
         DAD   H           ;*2
         DAD   H           ;*4
         DAD   H           ;*8
         DAD   H           ;*16
         LXI   D,DBASE     ;first DPH
         DAD   D           ;DPH (disk)
         RET

The translation vectors XLT are located elsewhere in the BIOS, and simply correspond one-for-one with the logical sector numbers zero through the sector count 1.

The pointer to the DPB is located in a DPH at offset $0A. Note, that CP/M manages mass storage devices in 128-bytes sectors, regardless how many bytes are in the physical sectors of a disk. Several of such sectors are combined to “Allocation Blocks”. The Allocation Blocks are combined to “Logical Extents” for the representation in the directory.

The 15-bytes DPB describes the attributes of a drive and has this general form:

DPB
offset
Contents Meaning
$00 SPT “Sectors Per Track”
Total number of 128 bytes sectors per track
$02 BSH Data allocation “Block Shift Factor”
Number of 128 bytes sectors per “Allocation Block” ( determined by the data block allocation size. Stored as 2’s-logarithm. See notes below ).
$03 BLM “Data allocation Block Mask”
To get the sector index of the Allocation Block the sector number is to combine logically by AND with this mask. (( 2^BSH)-1). See notes below.
$04 EXM “Extent Mask”
Number of extents per directory entry ( stored as 2’s logarithm ). Determined by the data block allocation size and the number of disk blocks.
$05 DSM Total storage capacity of the disk drive. Number of the last Allocation Block ( Number of entries per disk -1 )
$07 DRM Number of the last directory entry ( Number of entries per disk -1 ). Total number of directory entries that can be stored on this drive. ( AL0, AL1 determine reserved directory blocks ).
$09 AL0 Starting value of the first two bytes of the allocation table. ( Determined by DRM; bit meaning see below )
$0A AL1
$0B CKS “Check area Size”
Size of the directory check vector. Number of directory entries to check for disk change. Zero for a HDD.
$0D OFF Number of system reserved tracks at the beginning of the ( logical ) disk

The values of BSH and BLM implicitly determine the data allocation size, BLS, which is not an entry in the DPB. Given that the designer has selected a value for BLS, the values of BSH and BLM are shown in the following table:

BLS
BSH BLM
1,024
3
7
2,048
4
15
4,096
5
31
8,192
6
63
16,384
7
127

All values are decimal. The value of EXM depends upon the BLS and whether the DSM value is less than 256 or greater than 255. For DSM less than 256, the value of EXM is given by:

BLS
EXM
1,024
0
2,048
1
4,096
3
8,192
7
16,384
15

For DSM greater than 255, the value of EXM is given by:

BLS
EXM
1,024
N/A
2,048
0
4,096
1
8,192
3
16,384
7

The value of DSM is the maximum data block number measured in BLS units supported by this particular drive. The product BLS * ( DSM + 1 ) is the total number of bytes held by the drive and, of course, must be within the capacity of the physical disk, not counting the reserved operating system tracks.

The DRM entry is one less than the total number of directory entries that can take on a 16-bit value. The values of AL0 and AL1 are determined by DRM. AL0 and AL1 values together can be considered a string of 16-bits, as shown below:

AL0
AL1
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

Position 00 corresponds to the high-order bit of the byte AL0, and position 15 to the low-order bit of the byte AL1. Each bit position reserves a data block for a number of directory entries, thus allowing a total of 16 data blocks to be assigned for directory entries ( bits are assigned starting at 00 and filled to the right through position 15 ). Each directory entry occupies 32 bytes, resulting in the following table:

BLS
Directory Entries
1,024
32 times # bits
2,048
64 times # bits
4,096
128 times # bits
8,192
256 times # bits
16,384
512 times # bits

If DRM = 127 ( 128 directory entries ) and BLS = 1,024, there are 32 directory entries per block, requiring four reserved blocks. In this case, the four high-order bits of AL0 are set, resulting in the values AL0 = $F0 and AL1 = $00.

The CKS value is determined as follows:

  1. If the disk drive media is removable, then CKS = ( DRM + 1 ) / 4, where DRM is the last directory number.
  2. If the media are fixed, then CKS = 0. No directory records are checked in this case.

Finally, the OFF field determines the number of tracks that are skipped at the beginning of the physical disk. This value is automatically added whenever SETTRK is called. It can be used as a mechanism for skipping reserved operating system tracks or for partitioning a large disk into smaller segmented sections.

To complete the discussion of the DPB, several DPHs can address the same DPB if their drive characteristics are identical. Further, the DPB can be dynamically changed when a new drive is addressed. Since the BDOS copies the DPB values to a local area whenever the SELDSK function is called, simply change the pointer in the DPH.

Returning back to the DPH for a particular drive, the two address values, CSV and ALV, reference areas of uninitialized memory in the BIOS data segment. The areas must be unique for each drive, and the size of each area is determined by the values in the DPB.

The size of the data addressed by CSV is CKS bytes, which is sufficient to hold the directory check information for this particular drive. If CKS = ( DRM +1 ) / 4, you must reserve ( DRM + 1 ) / 4 bytes for directory check use. Id CKS = =, no storage is reserved.

The size of the area addressed by ALV is determined by the maximum number of data blocks allowed for this particular disk, and is equal to 2 * ( DSM / 8 + 1 ). Two copies of the allocation map for the disk are kept in this area: the first vector stores temporarily allocated blocks resulting from write operations, the second stores permanently allocated blocks resulting from CLOSE FILE operations.