DVH(4-SVR4) RISC/os Reference Manual DVH(4-SVR4)
NAME
dvh - format of MIPS disk volume header
SYNTAX
#include <sys/dvh.h>
DESCRIPTION
Disk volumes on MIPS computers systems contain a volume
header that describes the contents of the disk and parame-
ters of the physical disk drive. Volume headers are created
by format(8), and manipulated by dvhtool(1M). The MIPS PROM
MONITOR reads disk volume headers to determine the appropri-
ate file to boot on autobooting.
The volume header is a block located at the beginning of all
disk media. It contains information pertaining to physical
device parameters and logical partition information. The
volume header is manipulated by disk formatters/verifiers,
partition builders (e.g. newfs/mkfs), and device drivers.
A copy of the volume header is located at sector 0 of each
track of cylinder 0. The volume header is constrained to be
less than 512 bytes long. A particular copy is assumed
valid if no drive errors are detected, the magic number is
correct, and the 32 bit 2's complement of the volume header
is correct. The checksum is calculated by initially zeroing
vh_csum, 2's complement summing the entire structure and
then storing the 2's complement of the sum. Thus a resum-
ming a previously checksum'ed header should yield 0 to ver-
ify the volume header.
The error summary table, bad sector replacement table, and
boot blocks are located by searching the volume directory
within the volume header. Tables are sized simply by the
integral number of table records that will fit in the space
indicated by the directory entry. The amount of space allo-
cated to the volume header, replacement blocks, and other
tables is user defined when the device is formatted.
Device parameters are in the volume header to determine map-
ping from logical block numbers to physical device
addresses, allow the driver to properly configure itself and
the controller for the given disk drive, and to allow the
operating system to know various parameters (such as
transfer rate) of the disk system.
The partition table describes logical device partitions
(device drivers examine this to determine mapping from logi-
cal units to cylinder groups, device formatters/verifiers
examine this to determine location of replacement
tracks/sectors, etc). NOTE: the field pt_firstlbn should be
cylinder aligned.
Printed 11/19/92 Page 1
DVH(4-SVR4) RISC/os Reference Manual DVH(4-SVR4)
The error table records media defects, and allows for
"automatic" replacement of bad blocks and more informative
error logging.
The bad sector table is used to map from bad sectors/tracks
to replacement sector/tracks. To identify available
replacement sectors/tracks, allocate replacements in
increasing block number from a replacement partition. When
a new replacement sector/track is needed scan the bad sector
table to determine current highest replacement sector/track
block number and then scan the device from the next block
until a defect free replacement sector/track is found or the
end of replacement partition is reached. If bt_rpltype ==
BSTTYPE_TRKFWD, then bt_badlbn refers to the bad logical
block within the bad track, and bt_rpllbn refers to the
first sector of the replacement track. If bt_rpltype ==
BSTTYPE_SLIPSEC or bt_rpltype == BSTTYPE_SLIPBAD, then
bt_rpllbn has no meaning.
The format of the dvh disk volume header is:
struct device_parameters {
u_char dp_skew; /* spiral addressing skew */
u_char dp_gap1; /* words of 0 before header */
u_char dp_gap2; /* words of 0 between hdr and data */
u_char dp_spare0; /* spare space */
u_short dp_cyls; /* number of cylinders */
u_short dp_shd0; /* starting head vol 0 */
u_short dp_trks0; /* number of tracks vol 0 */
u_short dp_shd1; /* starting head vol 1 */
u_short dp_trks1; /* number of tracks vol 1 */
u_short dp_secs; /* number of sectors/track */
u_short dp_secbytes; /* length of sector in bytes */
u_short dp_interleave; /* sector interleave */
int dp_flags; /* controller characteristics */
int dp_datarate; /* bytes/sec for kernel stats */
int dp_nretries; /* max num retries on data error */
int dp_spare1; /* spare entries */
int dp_spare2;
int dp_spare3;
int dp_spare4;
};
/*
* Device characterization flags
* (dp_flags)
*/
#define DP_SECTSLIP 0x00000001 /* sector slip to spare sector */
#define DP_SECTFWD 0x00000002 /* forward to replacement sector */
#define DP_TRKFWD 0x00000004 /* forward to replacement track */
#define DP_MULTIVOL 0x00000008 /* multiple volumes per spindle */
#define DP_IGNOREERRORS 0x00000010 /* transfer data regardless of errors */
Page 2 Printed 11/19/92
DVH(4-SVR4) RISC/os Reference Manual DVH(4-SVR4)
#define DP_RESEEK 0x00000020 /* recalibrate as last resort */
#define DP_SMD 0x10000000 /* SMD drive */
#define DP_SCSI 0x20000000 /* SCSI drive */
#define DP_ESDI 0x40000000 /* ESDI drive */
#define VDNAMESIZE 8
struct volume_directory {
char vd_name[VDNAMESIZE]; /* name */
int vd_lbn; /* logical block number */
int vd_nbytes; /* file length in bytes */
};
struct partition_table { /* one per logical partition */
int pt_nblks; /* # of logical blks in partition */
int pt_firstlbn; /* first lbn of partition */
int pt_type; /* use of partition */
};
#define PTYPE_VOLHDR 0 /* partition is volume header */
#define PTYPE_TRKREPL 1 /* partition is used for repl trks */
#define PTYPE_SECREPL 2 /* partition is used for repl secs */
#define PTYPE_RAW 3 /* partition is used for data */
#define PTYPE_BSD 4 /* partition is 4.2BSD file system */
#define PTYPE_BSD42 4 /* partition is 4.2BSD file system */
#define PTYPE_SYSV 5 /* partition is SVR3 file system */
#define PTYPE_VOLUME 6 /* partition is entire volume */
#define VHMAGIC 0xbe5a941 /* randomly chosen value */
#define NPARTAB 16 /* 16 unix partitions */
#define NVDIR 15 /* max of 15 directory entries */
#define BFNAMESIZE 16 /* max 16 chars in boot file name */
struct volume_header {
int vh_magic; /* identifies volume header */
short vh_rootpt; /* root partition number */
short vh_swappt; /* swap partition number */
char vh_bootfile[BFNAMESIZE]; /* name of file to boot */
struct device_parameters vh_dp; /* device parameters */
struct volume_directory vh_vd[NVDIR]; /* other vol hdr contents */
struct partition_table vh_pt[NPARTAB]; /* device partition layout */
int vh_csum; /* volume header checksum */
};
#define ERR_SECC 0 /* soft ecc */
#define ERR_HECC 1 /* hard ecc */
#define ERR_HCSUM 2 /* header checksum */
#define ERR_SOTHER 3 /* any other soft errors */
#define ERR_HOTHER 4 /* any other hard errors */
#define NERRTYPES 5 /* Total number of error types */
struct error_table { /* one per defective logical block */
Printed 11/19/92 Page 3
DVH(4-SVR4) RISC/os Reference Manual DVH(4-SVR4)
int et_lbn; /* defective block number */
int et_errcount[NERRTYPES]; /* counts for each error type */
};
struct bst_table {
int bt_badlbn; /* bad logical block */
int bt_rpllbn; /* replacement logical block */
int bt_rpltype; /* replacement method */
};
/*
* replacement types
*/
#define BSTTYPE_EMPTY 0 /* slot unused */
#define BSTTYPE_SLIPSEC 1 /* sector slipped to next sector */
#define BSTTYPE_SECFWD 2 /* sector forwarded to replacement sector */
#define BSTTYPE_TRKFWD 3 /* track forwarded to replacement track */
#define BSTTYPE_SLIPBAD 4 /* sector reserved for slipping has defect */
#define BSTTYPE_NOTREPL 5 /* Bad sector couldn't be replaced */
#define BSTTYPE_RUNTBAD 6 /* Runt sector has defect */
/*
* The following structs are parameters to various driver ioctls
* for disk formatting, etc.
*/
/*
* controller information struct
* returned via DIOCGETCTLR
* mostly to determine appropriate method for bad block handling
*/
#define CITYPESIZE 32
struct ctlr_info {
int ci_flags; /* same as DP_* flags */
char ci_type[CITYPESIZE]; /* controller model and manuf. */
};
/*
* information necessary to perform one of the following actions:
* format a track
* fmi_cyl and fmi_trk identify track to format
* map a track
* fmi_cyl and fmi_trk identify defective track
* fmi_rplcyl and fmi_rpltrk identify replacement track
* map a sector
* fmi_cyl, fmi_trk, and fmi_sec identify defective sector
* fmi_rplcyl, fmi_rpltrk, and fmi_rplsec identify
* replacement sector
* slip a sector
* fmi_cyl, fmi_trk, and fmi_sec identify defective sector
Page 4 Printed 11/19/92
DVH(4-SVR4) RISC/os Reference Manual DVH(4-SVR4)
*/
#define FMI_FORMAT_TRACK 1 /* format a track */
#define FMI_MAP_TRACK 2 /* map a track */
#define FMI_MAP_SECTOR 3 /* map a sector */
#define FMI_SLIP_SECTOR 4 /* slip a sector */
#define FMI_FORMAT_TRACK_WDATA 5 /* format a track with data */
struct fmt_map_info {
int fmi_action; /* action desired, see FMI_ above */
union {
struct{
u_short ocyl; /* cylinder with defect or one with */
/* track to format */
u_char otrk; /* track with defect or one to format */
u_char osec; /* sector with defect */
u_short rcyl; /* replacement cylinder */
u_char rtrk; /* replacement track */
u_char rsec; /* replacement sector */
}nonscsi;
struct{
u_short intrlv; /* interleave factor */
u_short tpz; /* tracks per zone */
u_short aspz; /* alternate sectors per zone */
u_short atpv; /* alternate tracks per volume */
}scsidsk;
}info;
char *fmi_addr;
};
#define fmi_cyl info.nonscsi.ocyl
#define fmi_trk info.nonscsi.otrk
#define fmi_sec info.nonscai.osec
#define fmi_rplcyl info.nonscsi.rcyl
#define fmi_rpltrk info.nonscsi.rtrk
#define fmi_rplsec info.nonscai.rsec
#define fmi_intrlv info.scsidsk.intrlv
#define fmi_tpz info.scsidsk.tpz
#define fmi_aspz info.scsidsk.aspz
#define fmi_atpv info.scsidsk.atpv
SEE ALSO
MIPS System Programmer's Guide
System Programmer's Package Reference
Printed 11/19/92 Page 5