CP/M pages
Home -> CP/M -> DPH

CP/M Disc Parameter Header

In CP/M, the DPH is a BIOS structure containing information about a disc drive. The actual format of the DPH is version-dependent.

Individual BIOSes may add extra fields to a DPH, before the start or after the end.

CP/M 2 DPH

This is the format of the DPH in CP/M 2 and CP/M-86 v1.x. The DPH in CP/M-8000 and CP/M-68K is similar but all the addresses are 32 bits wide.

0000	DW	xlt	;Address of sector translation table
0002	DW	0,0,0	;Used as workspace by CP/M
0008	DW	dirbuf	;Address of a 128-byte sector buffer; this is 
			;the same for all DPHs in the system.
000A	DW	dpb	;Address of the DPB 
			;giving the format of this drive.
000C	DW	csv	;Address of the directory checksum vector
			;for this drive.
000E	DW	alv	;Address of the allocation vector
			;for this drive.

CP/M 3 DPH

This is the format of the DPH in 8-bit CP/M 3:

0000	DW	xlt	;Address of sector translation table
0002	DW	0,0,0,0	;Used as workspace by CP/M
	DB	0	
000B	DB	mf	;Media flag. If the BIOS has an interrupt-driven
			;'disc changed' system, then changing a disc in this
			;drive should set this flag (and the 'media changed'
			;flag in the SCB) to 0FFh.
000C	DW	dpb	;Address of the DPB 
			;giving the format of this drive.
000E	DW	csv	;Address of the directory checksum vector
			;for this drive (in bank 0).
0010	DW	alv	;Address of the allocation vector
			;for this drive (in bank 0).
0012	DW	dirbcb	;Address of the directory buffer chain.
0014	DW	dtabcb	;Address of the data buffer chain.
0016	DW	hash	;Address of the hash buffer for this drive.
0018	DB	hbank	;Bank number of the hash buffer.

CP/M-86 Plus DPH

This is the format of the DPH in the documentation for CP/M-86 Plus; the same format is used by Personal CP/M-86 and DOS Plus.

0000	DW	xlt	;Address of sector translation table
0002	DB	0,0,0	;Used as workspace by CP/M
0005	DB	dopen	;Driver door opened. If the BIOS has an 
			;interrupt-driven 'disc changed' system, then 
			;changing a disc in this drive should set this flag 
			;(and the 'media changed' flag in the XIOS header).
0006	DW	0	;Workspace
0008	DW	dpb	;Address of the DPB 
			;giving the format of this drive.
000A	DW	csv	;Address of the directory checksum vector
			;for this drive (in bank 0).
000C	DW	alv	;Address of the allocation vector
			;for this drive (in bank 0).
000E	DW	dirbcb	;Address of the directory buffer chain.
0010	DW	dtabcb	;Address of the data buffer chain.
0012	DW	hash	;Segment of the hash buffer for this drive.
0014	DW	init	;Offset of drive INIT  routine in XIOS code segment.
			;Entered with BX pointing at the DPH.
0016	DW	login	;Offset of drive LOGIN routine in XIOS code segment.
			;Entered with BX pointing at the DPH.
0018	DW	read	;Offset of drive READ  routine in XIOS code segment.
			;Entered with BX pointing at the DPH and BP pointing
			;to an I/O parameter block.
001A	DW	write	;Offset of drive WRITE routine in XIOS code segment.
			;Entered with BX pointing at the DPH and BP pointing
			;to an I/O parameter block.
001C	DB	unit	;The number of this drive as the controller sees it.
001D	DB	chnnl	;The number of the controller on which this drive is.
001E	DB	nflags	;The number of system flags used by this drive. If 
			;several drives share a controller, the DPH of the 
			;first drive should have this value set and the 
			;others should leave it as 0.

Checksum Vector

This is a buffer which CP/M will use to hold the checksum of each 128-byte record in the directory. If the checksum of a sector changes unexpectedly, the disc is assumed to have been changed.

If the disc is not removable, then there will be no such buffer, and its address in the DPH is 0.

Allocation Vector

This is a bitmap of used/free blocks on the drive. Under CP/M 2, there is one bit per block. Under CP/M 3, there may be one bit per block, or two.

Buffer Chains

In a non-banked CP/M 3, each BCB pointer (DIRBCB/DTABCB) points straight at a single Buffer Control Block. In a banked system, they each point at a word, which in turn points to the first BCB in a linked list.

The two BCB pointers can only be the same if this is a nonbanked version of CP/M 3 and the drive is a fixed disk.

The format of a BCB in 8-bit CP/M is:

0000	DB	drive	;The drive using this buffer, 0FFh if empty.
0001	DB	rec#	;Sector number using this buffer (24-bit).
0004	DB	wflg	;Nonzero if buffer is dirty and must be written back.
0005	DB	0	;Scratch byte.
0006	DW	track	;Track the buffer comes from.
0008	DW	sector	;Sector the buffer comes from.
000A	DW	buffer	;Address of the buffered data.
000C	DB	bank	;Bank of the buffered data (banked CP/M only).
			;BCBs in the directory chain must be in bank 0.
			;Data BCBs can be in any bank that the XMOVE/MOVE
			;BIOS calls support.
000D	DW	link	;Address of next BCB in chain, 0 for none.
			;(banked CP/M only).

In CP/M-86 Plus, Personal CP/M-86 and DOS Plus, it's similar:

0000	DB	drive	;The drive using this buffer, 0FFh if empty.
0001	DB	rec#	;Sector number using this buffer (24-bit).
0004	DB	wflg	;Nonzero if buffer is dirty and must be written back.
0005	DB	0	;Scratch byte.
0006	DW	track	;Track the buffer comes from.
0008	DW	sector	;Sector the buffer comes from.
000A	DW	buffer	;Address of the buffered data in the CP/M-86 data 
			;segment.
000C	DW	link	;Address of next BCB in chain, 0 for none.
000E	DW	rsvd	;Documented as "reserved". Holds the segment of a
			;process table entry.

Hash Buffer

This is an optional hash table with 4 bytes per directory entry, used to speed up file access. If it is 0FFFFh there is no hash table.

I/O Parameter Block

The I/O Parameter Block is passed to the READ and WRITE routines in CP/M-86 Plus, Personal CP/M-86 and DOS Plus. It is formed:

bp+6	DD	address	;Transfer address to read/write
bp+10	DW	sector	;First sector to read/write
bp+12	DW	track	;First track to read/write
bp+14	DB	drive	;Drive number
bp+15	DB	count	;Number of sectors to read/write.

Return to archive listing