1 /*
2 * Copyright (c) 1987, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
30 * $FreeBSD: src/sys/sys/disklabel.h,v 1.49.2.7 2001/05/27 05:58:26 jkh Exp $
31 */
32
33 #ifndef _SYS_DISKLABEL32_H_
34 #define _SYS_DISKLABEL32_H_
35
36 #ifndef _SYS_TYPES_H_
37 #include <sys/types.h>
38 #endif
39 #if defined(_KERNEL) && !defined(_SYS_SYSTM_H_)
40 #include <sys/systm.h>
41 #endif
42 #ifndef _SYS_IOCCOM_H_
43 #include <sys/ioccom.h>
44 #endif
45
46 /*
47 * Each disk has a label which includes information about the hardware
48 * disk geometry, filesystem partitions, and drive specific information.
49 * The label is in block 0 or 1, possibly offset from the beginning
50 * to leave room for a bootstrap, etc.
51 */
52
53 /* XXX these should be defined per controller (or drive) elsewhere, not here! */
54 #if defined(__i386__) /* used in stand/boot */ || defined(__x86_64__)
55 #define LABELSECTOR32 1 /* sector containing label */
56 #define LABELOFFSET32 0 /* offset of label in sector */
57 #endif
58
59 #define DISKMAGIC32 ((u_int32_t)0x82564557) /* The disk magic number */
60 #ifndef MAXPARTITIONS32
61 #define MAXPARTITIONS32 16
62 #endif
63
64 #define LABEL_PART 2 /* partition containing label */
65 #define RAW_PART 2 /* partition containing whole disk */
66 #define SWAP_PART 1 /* partition normally containing swap */
67
68 #ifndef LOCORE
69 struct disklabel32 {
70 u_int32_t d_magic; /* the magic number */
71 u_int16_t d_type; /* drive type */
72 u_int16_t d_subtype; /* controller/d_type specific */
73 char d_typename[16]; /* type name, e.g. "eagle" */
74
75 char d_packname[16]; /* pack identifier */
76
77 /* disk geometry: */
78 u_int32_t d_secsize; /* # of bytes per sector */
79 u_int32_t d_nsectors; /* # of data sectors per track */
80 u_int32_t d_ntracks; /* # of tracks per cylinder */
81 u_int32_t d_ncylinders; /* # of data cylinders per unit */
82 u_int32_t d_secpercyl; /* # of data sectors per cylinder */
83 u_int32_t d_secperunit; /* # of data sectors per unit */
84
85 /*
86 * Spares (bad sector replacements) below are not counted in
87 * d_nsectors or d_secpercyl. Spare sectors are assumed to
88 * be physical sectors which occupy space at the end of each
89 * track and/or cylinder.
90 */
91 u_int16_t d_sparespertrack; /* # of spare sectors per track */
92 u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */
93 /*
94 * Alternate cylinders include maintenance, replacement, configuration
95 * description areas, etc.
96 */
97 u_int32_t d_acylinders; /* # of alt. cylinders per unit */
98
99 /* hardware characteristics: */
100 /*
101 * d_interleave, d_trackskew and d_cylskew describe perturbations
102 * in the media format used to compensate for a slow controller.
103 * Interleave is physical sector interleave, set up by the
104 * formatter or controller when formatting. When interleaving is
105 * in use, logically adjacent sectors are not physically
106 * contiguous, but instead are separated by some number of
107 * sectors. It is specified as the ratio of physical sectors
108 * traversed per logical sector. Thus an interleave of 1:1
109 * implies contiguous layout, while 2:1 implies that logical
110 * sector 0 is separated by one sector from logical sector 1.
111 * d_trackskew is the offset of sector 0 on track N relative to
112 * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
113 * is the offset of sector 0 on cylinder N relative to sector 0
114 * on cylinder N-1.
115 */
116 u_int16_t d_rpm; /* rotational speed */
117 u_int16_t d_interleave; /* hardware sector interleave */
118 u_int16_t d_trackskew; /* sector 0 skew, per track */
119 u_int16_t d_cylskew; /* sector 0 skew, per cylinder */
120 u_int32_t d_headswitch; /* head switch time, usec */
121 u_int32_t d_trkseek; /* track-to-track seek, usec */
122 u_int32_t d_flags; /* generic flags (now unused) */
123 #define NDDATA32 5
124 u_int32_t d_drivedata[NDDATA32];/* drive-type specific information */
125 #define NSPARE32 5
126 u_int32_t d_spare[NSPARE32]; /* reserved for future use */
127 u_int32_t d_magic2; /* the magic number (again) */
128 u_int16_t d_checksum; /* xor of data incl. partitions */
129
130 /* filesystem and partition information: */
131 u_int16_t d_npartitions; /* number of partitions in following */
132 u_int32_t d_bbsize; /* size of boot area at sn0, bytes */
133 u_int32_t d_sbsize; /* max size of fs superblock, bytes */
134 struct partition32 { /* the partition table */
135 u_int32_t p_size; /* number of sectors in partition */
136 u_int32_t p_offset; /* starting sector */
137 u_int32_t p_fsize; /* filesystem basic fragment size */
138 u_int8_t p_fstype; /* filesystem type, see below */
139 u_int8_t p_frag; /* filesystem fragments per block */
140 union {
141 u_int16_t cpg; /* UFS: FS cylinders per group */
142 u_int16_t sgs; /* LFS: FS segment shift */
143 } __partition_u1;
144 #define p_cpg __partition_u1.cpg
145 #define p_sgs __partition_u1.sgs
146 } d_partitions[MAXPARTITIONS32];/* actually may be more */
147 };
148
149 static u_int16_t dkcksum32(struct disklabel32 *lp);
150
151 static __inline u_int16_t
dkcksum32(struct disklabel32 * lp)152 dkcksum32(struct disklabel32 *lp)
153 {
154 u_int16_t *start, *end;
155 u_int16_t sum = 0;
156
157 start = (u_int16_t *)lp;
158 end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions];
159 while (start < end)
160 sum ^= *start++;
161 return (sum);
162 }
163
164 #ifdef _KERNEL
165 extern struct disklabel_ops disklabel32_ops;
166 #endif
167
168 #else /* LOCORE */
169 /*
170 * offsets for asm boot files.
171 */
172 .set d_secsize,40
173 .set d_nsectors,44
174 .set d_ntracks,48
175 .set d_ncylinders,52
176 .set d_secpercyl,56
177 .set d_secperunit,60
178 .set d_end_,276 /* size of disk label */
179 #endif /* !LOCORE */
180
181 #ifndef LOCORE
182
183 /*
184 * Disk-specific ioctls.
185 */
186 #define DIOCGDINFO32 _IOR('d', 101, struct disklabel32) /* get */
187 #define DIOCSDINFO32 _IOW('d', 102, struct disklabel32) /* set */
188 #define DIOCWDINFO32 _IOW('d', 103, struct disklabel32) /* set, update disk */
189 #define DIOCGDVIRGIN32 _IOR('d', 105, struct disklabel32) /* get virgin label */
190
191 #endif /* !LOCORE */
192
193 #endif /* !_SYS_DISKLABEL32_H_ */
194