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