Scor­pio News

  

July–September 1987 – Volume 1. Issue 3.

Page 11 of 67

Disk Formats and CP/M Disk routines – Part 3

by M.W.T. Waters

Disk Parameter Headers

The CP/M 2.2 DPH

A DPH for CP/M 2.2 is a table of eight 16 bit words broken up as follows:

DPH:XLT; Translate table address
0000; 6 bytes scratchpad for BDOS use
0000
0000
DIRBUF; Address of a buffer used
; for reading directory information
DPB; Disk Parameter Block Address
CSV; Checksum Vector address
ALV; Allocation Vector address

Note that CP/M 1.4 doesn’t use DPH’s and that the DPH’s for CP/M 3 are longer.

The BIOS has a DPH for each drive supported by the system. When a drive is logged in, the BIOS returns the address of the appropriate DPH to the BDOS. The BDOS then uses the DPH to locate any remaining data structure that it requires.

The first entry is the the address of a sector translate table which the BIOS will use to convert from logical to physical sector numbers before accessing the disk. If no sector translation is required, this word will contain zero. Sector translation is discussed in some detail elsewhere so all that will be said at this point is that CP/M 2.2 only allows for translation of 128 byte sectors. If sector translation is required on systems using sector sizes of more than 128 bytes, XLT must be set to zero and the BIOS should do the translation separately. CP/M 3 doesn’t suffer from this limitation as all disk transfers and sector translation are done in terms of physical disk sectors.

The next 6 bytes are reserved for use by the BDOS as workspace. Their initial value is immaterial.

DIRBUF is the address of a buffer used by the BDOS and BIOS when reading directory information. This buffer is one physical sector long (512 bytes for Gemini DDDS, QDDS and QDSS formats, 128 bytes for SDDS format) and may be shared by all drives in the system. CP/M 1.4 is different in that it uses the default buffer at address 80H for this purpose. CP/M 3 buffers the directory records differently end consequently CP/M 3 does do not contain this field.

DPB is the address of a Disk Parameter Block for the drive concerned. A separate DPB is required for each disk format handled. DPH’s for drives using the disk format may all address the same DPB. The DPB is explained in full later.

The Checksum Vector

CSV is the address of a table that CP/M uses to check whether a disk has been changed. The table is used to store a checksum byte that uniquely identifies a directory record (128 bytes containing 4 directory entries). A good definition of a checksum is, in this case, a single byte which is derived from a block of data and whose value is unique to that block. As far as we are concerned, a block is 4 directory entries totalling 128 bytes (i.e. one CP/M record) and the checksum byte is obtained by adding together all of the bytes in the record, ignoring overflow, to produce a total. This total, and the totals for the remaining directory records are stored in a part of the BIOS known as the checksum vector and its address is given as CSV in the DPH. There is a checksum vector for each drive supported by the system. The length of each vector depends upon the number of directory entries. Since the checksum applies

Page 11 of 67