home *** CD-ROM | disk | FTP | other *** search
- /*
- ** mbb.h
- ** Master Boot Block for DOS type hard disk
- ** The pre-boot code, partition table and signature are found here.
- ** Pre version 2.3 V/AT 286 also stored disk geometry here.
- ** 2.3 and above moved this info to the Partition Boot Block.
- **
- ** $Header: mbb.h,v 1.1 88/04/07 23:11:40 root Alpha $
- */
-
- #ifndef MBB_H
- #define MBB_H
-
- /*
- ** Master Boot Block as it appears on physical block 0 of a hard disk.
- ** Size of this structure must be exactly 512 bytes. At offset 0x1a6
- ** the drive geometry may be stored (in a checksummed atructure). The
- ** partition table starts at offset 0x01BE. There are four entries and
- ** each entry is 16 bytes. The block signature is in last two bytes.
- */
-
- /*
- ** The MBB Drive Geometry table
- **
- ** +--------+-------+
- ** 0x1A6 | Cylinders |
- ** +--------+-------+
- ** 0x1A8 | Heads |
- ** +--------+-------+
- ** 0x1AA | Precomp |
- ** +--------+-------+
- ** 0x1AC | Landing Zone |
- ** +--------+-------+
- ** 0x1AE | CHECKSUM |
- ** +--------+-------+
- */
-
- typedef struct {
- short numcyls,
- numheads,
- precompcyl,
- landingzone,
- checksum;
- } dparm_t;
-
- /*
- ** +--------+-------+
- ** 0x1B0 | |
- ** 0x1B2 | |
- ** 0x1B4 | |
- ** 0x1B6 | filler[ 14 ] |
- ** 0x1B8 | |
- ** 0x1BA | |
- ** 0x1BC | |
- ** +--------+-------+
- */
-
- /*
- ** DOS assumes a 10 bit cylinder number in its ROM bios tables.
- ** this is mapped as follows:
- ** lower 8 bits are stored in the CYL field
- ** upper 2 bits are stored as 2 high order bits in the SEC field
- ** All partitions are allocated in cylinder multiples and begin on
- ** sector 1 head 0. EXCEPTION: The partition that is located at the
- ** beginning of the disk *must* start at sector 2 to leave room for the
- ** disk's Master Boot Record.
- ** The relative sector field is the count of the number of sectors
- ** which preceede this partition on the disk. The starting sector of
- ** this partition is found by using the value CYLINDER as found in the
- ** partition table, and the known geometry of the drive:
- ** relsec = CYL * (HeadsOnDrive * SecsPerHead)
- ** The field is stored with the least significant word first.
- **
- ** e.g., For a 4 head drive with 17 sectors per track, assume that
- ** the second partition starts on cyl 1 (sector 1 and head 1
- ** are implied for all but the first partition)
- ** relsec = 1 * ( 4 * 17 ) (cyl 1, 4 heads, 17 sec/track)
- ** relsec = 68
- ** For the first partition, relsec = 1 ('cuz of master boot block)
- **
- ** The number of sectors allocated in this partition is kept in the
- ** next field. It too is stored with the least significant word first.
-
- ** The partition table:
- ** Offset Description +--------+--------+--------+--------+
- ** P1 0x1BE beginning of partition |boot ind| head | sector |cylinder|
- ** 0x1C2 end of partition |syst ind| head | sector |cylinder|
- ** 0x1C6 reletive sector | low word | high word |
- ** 0x1CA number of sectors | low word | high word |
- ** +--------+--------+--------+--------+
- ** P2 0x1CE beginning of partition |boot ind| head | sector |cylinder|
- ** 0x1D2 end of partition |syst ind| head | sector |cylinder|
- ** 0x1D6 reletive sector | low word | high word |
- ** 0x1DA number of sectors | low word | high word |
- ** +--------+--------+--------+--------+
- ** P3 0x1DE beginning of partition |boot ind| head | sector |cylinder|
- ** 0x1E2 end of partition |syst ind| head | sector |cylinder|
- ** 0x1E6 reletive sector | low word | high word |
- ** 0x1EA number of sectors | low word | high word |
- ** +--------+--------+--------+--------+
- ** P4 0x1EE beginning of partition |boot ind| head | sector |cylinder|
- ** 0x1F2 end of partition |syst ind| head | sector |cylinder|
- ** 0x1F6 reletive sector | low word | high word |
- ** 0x1FA number of sectors | low word | high word |
- ** +--------+--------+--------+--------+
- */
-
- #define NPART 4 /* # of partitions in partition table */
-
- typedef struct {
- unsigned char pt_bootind; /* boot indicator 0x00 | 0x80 */
- unsigned char pt_bhead; /* head, sector, & cyl of */
- unsigned char pt_bsector; /* the boot sector for this */
- unsigned char pt_bcyl; /* partition (load at 0:7C00)*/
- unsigned char pt_sys; /* partition (system) type */
- unsigned char pt_ehead; /* head, sector and cyl of */
- unsigned char pt_esector; /* the end of this */
- unsigned char pt_ecyl; /* partition */
- unsigned long pt_start; /* starting sector */
- unsigned long pt_size; /* size in sectors */
- } partition_t;
-
- /*
- ** The Master Boot Block Signature is the last 2 bytes of the boot record
- ** which have the values 0x55 and 0xAA.
- **
- ** +--------+--------+
- ** 0x1FE Master Boot Signature | 0x55 | 0xAA |
- ** +--------+--------+
- */
-
- #define PT_INFO (0x1a6) /* WN.H */ /* start of driveinfo*/
-
- typedef struct {
- char bootcode[ PT_INFO ]; /* boot code at start of MBB */
- dparm_t geometry; /* cyls, heads, ... */
- char filler[ 14 ];
- partition_t partitiontable[ NPART ];
- unsigned int signature;
- } mbb_t;
-
- #define PT_SIG 0xaa55 /* magic constant */
- #define PT_BOOT 0x80 /* active partition */
- #define PT_NULL 0x00 /* passive partition */
- #define PT_UNUSED 0x00 /* unused system type*/
-
- #define PART(mbb,i) ((mbb)->partition[ (i) ])
- #define CYL_BOOT(ptp) ((ptp)->pt_bcyl | (((ptp)->pt_bsector & 0x00C0)<<2))
- #define HEAD_BOOT(ptp) ((ptp)->pt_bhead)
- #define SEC_BOOT(ptp) ((ptp)->pt_bsector & 0x003F)
- #define CYL_END(ptp) ((ptp)->pt_ecyl | (((ptp)->pt_esector & 0x00C0)<<2))
- #define HEAD_END(ptp) ((ptp)->pt_ehead)
- #define SEC_END(ptp) ((ptp)->pt_esector & 0x003F)
-
- #endif /* MBB_H */
-
-