Home | History | Annotate | Line # | Download | only in include
disklabel.h revision 1.5
      1 /*	$NetBSD: disklabel.h,v 1.5 1998/10/30 06:48:51 scottr Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1994 Christopher G. Demetriou
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Christopher G. Demetriou.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 /*-
     33  * Copyright (C) 1993	Allen K. Briggs, Chris P. Caputo,
     34  *			Michael L. Finch, Bradley A. Grantham, and
     35  *			Lawrence A. Kesteloot
     36  * All rights reserved.
     37  *
     38  * Redistribution and use in source and binary forms, with or without
     39  * modification, are permitted provided that the following conditions
     40  * are met:
     41  * 1. Redistributions of source code must retain the above copyright
     42  *    notice, this list of conditions and the following disclaimer.
     43  * 2. Redistributions in binary form must reproduce the above copyright
     44  *    notice, this list of conditions and the following disclaimer in the
     45  *    documentation and/or other materials provided with the distribution.
     46  * 3. All advertising materials mentioning features or use of this software
     47  *    must display the following acknowledgement:
     48  *	This product includes software developed by the Alice Group.
     49  * 4. The names of the Alice Group or any of its members may not be used
     50  *    to endorse or promote products derived from this software without
     51  *    specific prior written permission.
     52  *
     53  * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR
     54  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     55  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     56  * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT,
     57  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     58  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     59  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     60  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     61  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     62  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     63  *
     64  */
     65 
     66 #ifndef _MACHINE_DISKLABEL_H_
     67 #define _MACHINE_DISKLABEL_H_
     68 
     69 #define	LABELSECTOR	0			/* sector containing label */
     70 #define	LABELOFFSET	64			/* offset of label in sector */
     71 #define	MAXPARTITIONS	8			/* number of partitions */
     72 #define	RAW_PART	2			/* raw partition: xx?c */
     73 
     74 /* DOS partition table -- located in boot block */
     75 #define	DOSBBSECTOR	0		/* DOS boot block relative sector # */
     76 #define	DOSPARTOFF	446
     77 #define	NDOSPART	4
     78 
     79 struct dos_partition {
     80 	u_int8_t	dp_flag;	/* bootstrap flags */
     81 	u_int8_t	dp_shd;		/* starting head */
     82 	u_int8_t	dp_ssect;	/* starting sector */
     83 	u_int8_t	dp_scyl;	/* starting cylinder */
     84 	u_int8_t	dp_typ;		/* partition type (see below) */
     85 	u_int8_t	dp_ehd;		/* end head */
     86 	u_int8_t	dp_esect;	/* end sector */
     87 	u_int8_t	dp_ecyl;	/* end cylinder */
     88 	u_int32_t	dp_start;	/* absolute starting sector number */
     89 	u_int32_t	dp_size;	/* partition size in sectors */
     90 };
     91 
     92 /* Known DOS partition types. */
     93 #define DOSPTYP_NETBSD	0xa9		/* NetBSD/i386 partition type (XXX) */
     94 #define	DOSPTYP_386BSD	0xa5		/* 386BSD partition type (XXX) */
     95 #define DOSPTYP_FAT12	0x01		/* 12-bit FAT */
     96 #define DOSPTYP_FAT16S	0x04		/* 16-bit FAT, less than 32M */
     97 #define DOSPTYP_FAT16B	0x06		/* 16-bit FAT, more than 32M */
     98 #define DOSPTYP_FAT32	0x0b		/* 32-bit FAT */
     99 #define DOSPTYP_FAT32L	0x0c		/* 32-bit FAT, LBA-mapped */
    100 #define DOSPTYP_FAT16L	0x0e		/* 16-bit FAT, LBA-mapped */
    101 #define DOSPTYP_LNXEXT2	0x83		/* Linux native */
    102 
    103 /* Just a dummy */
    104 struct cpu_disklabel {
    105 	int	cd_dummy;			/* must have one element. */
    106 };
    107 
    108 /*
    109  * Driver Descriptor Map, from Inside Macintosh: Devices, SCSI Manager
    110  * pp 12-13.  The driver descriptor map always resides on physical block 0.
    111  */
    112 struct drvr_descriptor {
    113 	u_int32_t	descBlock;	/* first block of driver */
    114 	u_int16_t	descSize;	/* driver size in blocks */
    115 	u_int16_t	descType;	/* system type */
    116 };
    117 
    118 /* system types; Apple reserves 0-15 */
    119 #define	DRVR_TYPE_MACINTOSH	1
    120 
    121 struct drvr_map {
    122 #define DRIVER_MAP_MAGIC	0x4552
    123 	u_int16_t	sbSig;		/* map signature */
    124 	u_int16_t	sbBlockSize;	/* block size of device */
    125 	u_int32_t	sbBlkCount;	/* number of blocks on device */
    126 	u_int16_t	sbDevType;	/* (used internally by ROM) */
    127 	u_int16_t	sbDevID;	/* (used internally by ROM) */
    128 	u_int32_t	sbData;		/* (used internally by ROM) */
    129 	u_int16_t	sbDrvrCount;	/* number of driver descriptors */
    130 #define	DRVR_MAX_DESCRIPTORS	61
    131 	struct drvr_descriptor sb_dd[DRVR_MAX_DESCRIPTORS];
    132 	u_int16_t	pad[3];
    133 } __attribute__ ((packed));
    134 
    135 #define	ddBlock(N)	sb_dd[(N)].descBlock
    136 #define	ddSize(N)	sb_dd[(N)].descSize
    137 #define	ddType(N)	sb_dd[(N)].descType
    138 
    139 /*
    140  * Partition map structure from Inside Macintosh: Devices, SCSI Manager
    141  * pp. 13-14.  The partition map always begins on physical block 1.
    142  *
    143  * With the exception of block 0, all blocks on the disk must belong to
    144  * exactly one partition.  The partition map itself belongs to a partition
    145  * of type `APPLE_PARTITION_MAP', and is not limited in size by anything
    146  * other than available disk space.  The partition map is not necessarily
    147  * the first partition listed.
    148  */
    149 struct part_map_entry {
    150 #define PART_ENTRY_MAGIC	0x504d
    151 	u_int16_t	pmSig;		/* partition signature */
    152 	u_int16_t	pmSigPad;	/* (reserved) */
    153 	u_int32_t	pmMapBlkCnt;	/* number of blocks in partition map */
    154 	u_int32_t	pmPyPartStart;	/* first physical block of partition */
    155 	u_int32_t	pmPartBlkCnt;	/* number of blocks in partition */
    156 	char		pmPartName[32];	/* partition name */
    157 	char		pmPartType[32];	/* partition type */
    158 	u_int32_t	pmLgDataStart;	/* first logical block of data area */
    159 	u_int32_t	pmDataCnt;	/* number of blocks in data area */
    160 	u_int32_t	pmPartStatus;	/* partition status information */
    161 	u_int32_t	pmLgBootStart;	/* first logical block of boot code */
    162 	u_int32_t	pmBootSize;	/* size of boot code, in bytes */
    163 	u_int32_t	pmBootLoad;	/* boot code load address */
    164 	u_int32_t	pmBootLoad2;	/* (reserved) */
    165 	u_int32_t	pmBootEntry;	/* boot code entry point */
    166 	u_int32_t	pmBootEntry2;	/* (reserved) */
    167 	u_int32_t	pmBootCksum;	/* boot code checksum */
    168 	char		pmProcessor[16]; /* processor type (e.g. "68020") */
    169 	u_int8_t	pmBootArgs[128]; /* A/UX boot arguments */
    170 	u_int8_t	pad[248];	/* pad to end of block */
    171 };
    172 
    173 #define PART_TYPE_DRIVER	"APPLE_DRIVER"
    174 #define PART_TYPE_DRIVER43	"APPLE_DRIVER43"
    175 #define PART_TYPE_DRIVERATA	"APPLE_DRIVER_ATA"
    176 #define PART_TYPE_FWB_COMPONENT	"FWB DRIVER COMPONENTS"
    177 #define PART_TYPE_MAC		"APPLE_HFS"
    178 #define PART_TYPE_NETBSD	"NETBSD"
    179 #define PART_TYPE_PARTMAP	"APPLE_PARTITION_MAP"
    180 #define PART_TYPE_SCRATCH	"APPLE_SCRATCH"
    181 #define PART_TYPE_UNIX		"APPLE_UNIX_SVR2"
    182 
    183 /*
    184  * "pmBootArgs" for APPLE_UNIX_SVR2 partition.
    185  * NetBSD/mac68k only uses Magic, Cluster, Type, and Flags.
    186  */
    187 struct blockzeroblock {
    188 	u_int32_t       bzbMagic;
    189 	u_int8_t        bzbCluster;
    190 	u_int8_t        bzbType;
    191 	u_int16_t       bzbBadBlockInode;
    192 	u_int16_t       bzbFlags;
    193 	u_int16_t       bzbReserved;
    194 	u_int32_t       bzbCreationTime;
    195 	u_int32_t       bzbMountTime;
    196 	u_int32_t       bzbUMountTime;
    197 };
    198 
    199 #define BZB_MAGIC	0xABADBABE
    200 #define BZB_TYPEFS	1
    201 #define BZB_TYPESWAP	3
    202 #define BZB_ROOTFS	0x8000
    203 #define BZB_USRFS	0x4000
    204 
    205 #endif /* _MACHINE_DISKLABEL_H_ */
    206