Home | History | Annotate | Line # | Download | only in include
disklabel.h revision 1.4
      1  1.4  chuck /*	$NetBSD: disklabel.h,v 1.4 1996/05/16 17:52:51 chuck Exp $	*/
      2  1.1  chuck 
      3  1.1  chuck /*
      4  1.2  chuck  * Copyright (c) 1995 Dale Rahn.
      5  1.1  chuck  * All rights reserved.
      6  1.2  chuck  *
      7  1.1  chuck  * Redistribution and use in source and binary forms, with or without
      8  1.1  chuck  * modification, are permitted provided that the following conditions
      9  1.1  chuck  * are met:
     10  1.1  chuck  * 1. Redistributions of source code must retain the above copyright
     11  1.1  chuck  *    notice, this list of conditions and the following disclaimer.
     12  1.1  chuck  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  chuck  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  chuck  *    documentation and/or other materials provided with the distribution.
     15  1.1  chuck  * 3. All advertising materials mentioning features or use of this software
     16  1.1  chuck  *    must display the following acknowledgement:
     17  1.2  chuck  *   This product includes software developed by Dale Rahn.
     18  1.1  chuck  * 4. The name of the author may not be used to endorse or promote products
     19  1.2  chuck  *    derived from this software without specific prior written permission.
     20  1.1  chuck  *
     21  1.1  chuck  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1  chuck  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1  chuck  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1  chuck  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1  chuck  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1  chuck  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1  chuck  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1  chuck  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1  chuck  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1  chuck  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.2  chuck  */
     32  1.1  chuck 
     33  1.1  chuck #ifndef _MACHINE_DISKLABEL_H_
     34  1.1  chuck #define _MACHINE_DISKLABEL_H_
     35  1.1  chuck 
     36  1.2  chuck /* number of boot pieces , ie xxboot bootxx */
     37  1.4  chuck #define NUMBOOT		0
     38  1.2  chuck 
     39  1.4  chuck #define	PARTITIONSHIFT	3 /* could also be 4 if you need 16 partitions */
     40  1.2  chuck 
     41  1.2  chuck #define LABELSECTOR     0                       /* sector containing label */
     42  1.2  chuck #define LABELOFFSET	0			/* offset of label in sector */
     43  1.2  chuck #define MAXPARTITIONS	(1 << PARTITIONSHIFT)	/* number of partitions */
     44  1.2  chuck #define RAW_PART	2			/* raw partition: xx?c */
     45  1.2  chuck 
     46  1.2  chuck /*
     47  1.2  chuck  * used to encode disk minor numbers
     48  1.2  chuck  * this should probably be moved to sys/disklabel.h
     49  1.2  chuck  */
     50  1.2  chuck #define DISKUNIT(dev)	(minor(dev) / MAXPARTITIONS)
     51  1.2  chuck #define DISKPART(dev)	(minor(dev) % MAXPARTITIONS)
     52  1.2  chuck #define MAKEDISKDEV(maj, unit, part) \
     53  1.2  chuck     (makedev((maj), ((unit) * MAXPARTITIONS) + (part)))
     54  1.1  chuck 
     55  1.4  chuck /*
     56  1.4  chuck  * a cpu_disklabel is a disklabel that the bug (prom) can understand
     57  1.4  chuck  * and live with.   the bug works in terms of 256 byte blocks.   in our
     58  1.4  chuck  * case the first two bug blocks make up the cpu_disklabel (which is 512
     59  1.4  chuck  * bytes [i.e. one sector] in length).
     60  1.4  chuck  *
     61  1.4  chuck  * we use a fixed layout the BSD disk structure (in 256 byte blocks):
     62  1.4  chuck  *   block 0  = the volume ID block  (part of cpu_disklabel)
     63  1.4  chuck  *   block 1  = media configuration area (part of cpu_disklabel)
     64  1.4  chuck  *   block 2  = start of first level OS bootstrap (continues ...)
     65  1.4  chuck  *   block 31 = end of OS bootstrap
     66  1.4  chuck  *   block 32 = BSD filesystem superblock
     67  1.4  chuck  *
     68  1.4  chuck  * this gives us 30 blocks (30*256 = 7680 bytes) for the bootstrap's text+data
     69  1.4  chuck  *
     70  1.4  chuck  * disksubr.c translates between cpu_disklabel and BSD disklabel.
     71  1.4  chuck  *
     72  1.4  chuck  */
     73  1.4  chuck 
     74  1.1  chuck struct cpu_disklabel {
     75  1.2  chuck 	/* VID */
     76  1.4  chuck 	u_char  vid_id[4];	/* volume ID */
     77  1.4  chuck #define VID_ID		"NBSD"
     78  1.4  chuck 	u_char  vid_0[16];
     79  1.4  chuck 	u_int   vid_oss;	/* starting block # of bootstrap */
     80  1.4  chuck #define VID_OSS		2
     81  1.4  chuck 	u_short	vid_osl;	/* bootstrap length (30 blocks) */
     82  1.4  chuck #define VID_OSL		30
     83  1.4  chuck 	u_char	vid_1[4];
     84  1.4  chuck 	u_short	vid_osa_u;	/* bootstrap start address (upper) */
     85  1.4  chuck 	u_short	vid_osa_l;	/* bootstrap start address (lower) */
     86  1.4  chuck #define VID_OSA		0x3f0000	/* MUST match bootstrap code */
     87  1.4  chuck #define VID_OSAU	((VID_OSA >> 16) & 0xffff)
     88  1.4  chuck #define VID_OSAL	(VID_OSA & 0xffff)
     89  1.4  chuck 	u_char	vid_2[2];
     90  1.4  chuck 	u_short	partitions;
     91  1.4  chuck 	u_char	vid_vd[16];
     92  1.4  chuck 	u_long	bbsize;
     93  1.4  chuck 	u_long	magic1;		/* 4 */
     94  1.4  chuck 	u_short	type;		/* 2 */
     95  1.4  chuck 	u_short	subtype;	/* 2 */
     96  1.4  chuck 	u_char	packname[16];	/* 16 */
     97  1.4  chuck 	u_long	flags;		/* 4 */
     98  1.4  chuck 	u_long	drivedata[5];	/* 4 */
     99  1.4  chuck 	u_long	spare[5];	/* 4 */
    100  1.4  chuck 	u_short	checksum;	/* 2 */
    101  1.4  chuck 
    102  1.4  chuck 	u_long	secpercyl;	/* 4 */
    103  1.4  chuck 	u_long	secperunit;	/* 4 */
    104  1.4  chuck 	u_long	headswitch;	/* 4 */
    105  1.4  chuck 
    106  1.4  chuck 	u_char	vid_3[4];
    107  1.4  chuck 	u_int	vid_cas;	/* block # of CFG area, hardwired at 1 */
    108  1.4  chuck #define VID_CAS		1
    109  1.4  chuck 	u_char	vid_cal;	/* length of CFG area, in blocks (1) */
    110  1.4  chuck #define VID_CAL		1
    111  1.4  chuck 	u_char	vid_4_0[3];
    112  1.4  chuck 	u_char	vid_4[64];
    113  1.4  chuck 	u_char	vid_4_1[28];
    114  1.4  chuck 	u_long	sbsize;
    115  1.4  chuck 	u_char	vid_mot[8];	/* must contain "MOTOROLA" */
    116  1.4  chuck #define VID_MOT		"MOTOROLA"
    117  1.2  chuck 
    118  1.2  chuck 	/* CFG */
    119  1.4  chuck 	u_char	cfg_0[4];
    120  1.4  chuck 	u_short	cfg_atm;
    121  1.4  chuck 	u_short	cfg_prm;
    122  1.4  chuck 	u_short	cfg_atw;
    123  1.4  chuck 	u_short	cfg_rec;	/* block size (256) */
    124  1.4  chuck #define	CFG_REC		256
    125  1.4  chuck 
    126  1.4  chuck 	u_short	sparespertrack;
    127  1.4  chuck 	u_short	sparespercyl;
    128  1.4  chuck 	u_long	acylinders;
    129  1.4  chuck 	u_short	rpm;
    130  1.4  chuck 	u_short	cylskew;
    131  1.4  chuck 
    132  1.4  chuck 	u_char	cfg_spt;
    133  1.4  chuck 	u_char	cfg_hds;
    134  1.4  chuck 	u_short	cfg_trk;
    135  1.4  chuck 	u_char	cfg_ilv;
    136  1.4  chuck 	u_char	cfg_sof;
    137  1.4  chuck 	u_short	cfg_psm;	/* physical sector size (512) */
    138  1.4  chuck #define CFG_PSM		512
    139  1.4  chuck 	u_short	cfg_shd;
    140  1.4  chuck 	u_char	cfg_2[2];
    141  1.4  chuck 	u_short	cfg_pcom;
    142  1.4  chuck 	u_char	cfg_3;
    143  1.4  chuck 	u_char	cfg_ssr;
    144  1.4  chuck 	u_short	cfg_rwcc;
    145  1.4  chuck 	u_short	cfg_ecc;
    146  1.4  chuck 	u_short	cfg_eatm;
    147  1.4  chuck 	u_short	cfg_eprm;
    148  1.4  chuck 	u_short	cfg_eatw;
    149  1.4  chuck 	u_char	cfg_gpb1;
    150  1.4  chuck 	u_char	cfg_gpb2;
    151  1.4  chuck 	u_char	cfg_gpb3;
    152  1.4  chuck 	u_char	cfg_gpb4;
    153  1.4  chuck 	u_char	cfg_ssc;
    154  1.4  chuck 	u_char	cfg_runit;
    155  1.4  chuck 	u_short	cfg_rsvc1;
    156  1.4  chuck 	u_short	cfg_rsvc2;
    157  1.4  chuck 	u_long	magic2;
    158  1.4  chuck 	u_char	cfg_4[192];
    159  1.1  chuck };
    160  1.2  chuck #endif _MACHINE_DISKLABEL_H_
    161