4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_DKLABEL_H
28 #define _SYS_DKLABEL_H
30 #include <sys/isa_defs.h>
31 #include <sys/types32.h>
32 #include <sys/isa_defs.h>
39 * Miscellaneous defines
41 #define DKL_MAGIC 0xDABE /* magic number */
42 #define FKL_MAGIC 0xff /* magic number for DOS floppies */
44 #if defined(_SUNOS_VTOC_16)
45 #define NDKMAP 16 /* # of logical partitions */
46 #define DK_LABEL_LOC 1 /* location of disk label */
47 #elif defined(_SUNOS_VTOC_8)
48 #define NDKMAP 8 /* # of logical partitions */
49 #define DK_LABEL_LOC 0 /* location of disk label */
51 #error "No VTOC format defined."
54 #define LEN_DKL_ASCII 128 /* length of dkl_asciilabel */
55 #define LEN_DKL_VVOL 8 /* length of v_volume */
56 #define DK_LABEL_SIZE 512 /* size of disk label */
57 #define DK_MAX_BLOCKS 0x7fffffff /* max # of blocks handled */
60 * Reserve two cylinders on SCSI disks.
61 * One is for the backup disk label and the other is for the deviceid.
63 * IPI disks only reserve one cylinder, but they will go away soon.
64 * CDROMs do not reserve any cylinders.
69 * Format of a Sun disk label.
70 * Resides in cylinder 0, head 0, sector 0.
72 * sizeof (struct dk_label) should be 512 (the current sector size),
73 * but should the sector size increase, this structure should remain
74 * at the beginning of the sector.
77 #if !defined(BLKADDR_TYPE)
80 typedef unsigned long blkaddr_t
;
81 typedef unsigned int blkaddr32_t
;
83 typedef daddr_t blkaddr_t
;
84 typedef daddr32_t blkaddr32_t
;
89 * partition headers: section 1
90 * Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(7I))
93 blkaddr_t dkl_cylno
; /* starting cylinder */
94 blkaddr_t dkl_nblk
; /* number of blocks; if == 0, */
95 /* partition is undefined */
99 * partition headers: section 1
100 * Fixed size for on-disk dk_label
103 blkaddr32_t dkl_cylno
; /* starting cylinder */
104 blkaddr32_t dkl_nblk
; /* number of blocks; if == 0, */
105 /* partition is undefined */
109 * partition headers: section 2,
110 * brought over from AT&T SVr4 vtoc structure.
113 uint16_t p_tag
; /* ID tag of partition */
114 uint16_t p_flag
; /* permission flag */
117 struct dkl_partition
{
118 uint16_t p_tag
; /* ID tag of partition */
119 uint16_t p_flag
; /* permision flags */
120 blkaddr32_t p_start
; /* start sector no of partition */
121 blkaddr32_t p_size
; /* # of blocks in partition */
126 * VTOC inclusions from AT&T SVr4
127 * Fixed sized types for on-disk VTOC
131 #if defined(_SUNOS_VTOC_16)
132 uint32_t v_bootinfo
[3]; /* info for mboot (unsupported) */
133 uint32_t v_sanity
; /* to verify vtoc sanity */
134 uint32_t v_version
; /* layout version */
135 char v_volume
[LEN_DKL_VVOL
]; /* volume name */
136 uint16_t v_sectorsz
; /* sector size in bytes */
137 uint16_t v_nparts
; /* number of partitions */
138 uint32_t v_reserved
[10]; /* free space */
139 struct dkl_partition v_part
[NDKMAP
]; /* partition headers */
140 time32_t timestamp
[NDKMAP
]; /* partition timestamp (unsupported) */
141 char v_asciilabel
[LEN_DKL_ASCII
]; /* for compatibility */
142 #elif defined(_SUNOS_VTOC_8)
143 uint32_t v_version
; /* layout version */
144 char v_volume
[LEN_DKL_VVOL
]; /* volume name */
145 uint16_t v_nparts
; /* number of partitions */
146 struct dk_map2 v_part
[NDKMAP
]; /* partition hdrs, sec 2 */
147 uint32_t v_bootinfo
[3]; /* info needed by mboot */
148 uint32_t v_sanity
; /* to verify vtoc sanity */
149 uint32_t v_reserved
[10]; /* free space */
150 time32_t v_timestamp
[NDKMAP
]; /* partition timestamp */
152 #error "No VTOC format defined."
157 * define the amount of disk label padding needed to make
158 * the entire structure occupy 512 bytes.
160 #if defined(_SUNOS_VTOC_16)
161 #define LEN_DKL_PAD (DK_LABEL_SIZE - \
162 ((sizeof (struct dk_vtoc) + \
163 (4 * sizeof (uint32_t)) + \
164 (12 * sizeof (uint16_t)) + \
165 (2 * (sizeof (uint16_t))))))
166 #elif defined(_SUNOS_VTOC_8)
167 #define LEN_DKL_PAD (DK_LABEL_SIZE \
168 - ((LEN_DKL_ASCII) + \
169 (sizeof (struct dk_vtoc)) + \
170 (sizeof (struct dk_map32) * NDKMAP) + \
171 (14 * (sizeof (uint16_t))) + \
172 (2 * (sizeof (uint16_t)))))
174 #error "No VTOC format defined."
179 #if defined(_SUNOS_VTOC_16)
180 struct dk_vtoc dkl_vtoc
; /* vtoc inclusions from AT&T SVr4 */
181 uint32_t dkl_pcyl
; /* # of physical cylinders */
182 uint32_t dkl_ncyl
; /* # of data cylinders */
183 uint16_t dkl_acyl
; /* # of alternate cylinders */
184 uint16_t dkl_bcyl
; /* cyl offset (for fixed head area) */
185 uint32_t dkl_nhead
; /* # of heads */
186 uint32_t dkl_nsect
; /* # of data sectors per track */
187 uint16_t dkl_intrlv
; /* interleave factor */
188 uint16_t dkl_skew
; /* skew factor */
189 uint16_t dkl_apc
; /* alternates per cyl (SCSI only) */
190 uint16_t dkl_rpm
; /* revolutions per minute */
191 uint16_t dkl_write_reinstruct
; /* # sectors to skip, writes */
192 uint16_t dkl_read_reinstruct
; /* # sectors to skip, reads */
193 uint16_t dkl_extra
[4]; /* for compatible expansion */
194 char dkl_pad
[LEN_DKL_PAD
]; /* unused part of 512 bytes */
195 #elif defined(_SUNOS_VTOC_8)
196 char dkl_asciilabel
[LEN_DKL_ASCII
]; /* for compatibility */
197 struct dk_vtoc dkl_vtoc
; /* vtoc inclusions from AT&T SVr4 */
198 uint16_t dkl_write_reinstruct
; /* # sectors to skip, writes */
199 uint16_t dkl_read_reinstruct
; /* # sectors to skip, reads */
200 char dkl_pad
[LEN_DKL_PAD
]; /* unused part of 512 bytes */
201 uint16_t dkl_rpm
; /* rotations per minute */
202 uint16_t dkl_pcyl
; /* # physical cylinders */
203 uint16_t dkl_apc
; /* alternates per cylinder */
204 uint16_t dkl_obs1
; /* obsolete */
205 uint16_t dkl_obs2
; /* obsolete */
206 uint16_t dkl_intrlv
; /* interleave factor */
207 uint16_t dkl_ncyl
; /* # of data cylinders */
208 uint16_t dkl_acyl
; /* # of alternate cylinders */
209 uint16_t dkl_nhead
; /* # of heads in this partition */
210 uint16_t dkl_nsect
; /* # of sectors per track */
211 uint16_t dkl_obs3
; /* obsolete */
212 uint16_t dkl_obs4
; /* obsolete */
213 struct dk_map32 dkl_map
[NDKMAP
]; /* logical partition headers */
215 #error "No VTOC format defined."
217 uint16_t dkl_magic
; /* identifies this label format */
218 uint16_t dkl_cksum
; /* xor checksum of sector */
221 #if defined(_SUNOS_VTOC_16)
222 #define dkl_asciilabel dkl_vtoc.v_asciilabel
223 #define v_timestamp timestamp
225 #elif defined(_SUNOS_VTOC_8)
228 * These defines are for historic compatibility with old drivers.
230 #define dkl_gap1 dkl_obs1 /* used to be gap1 */
231 #define dkl_gap2 dkl_obs2 /* used to be gap2 */
232 #define dkl_bhead dkl_obs3 /* used to be label head offset */
233 #define dkl_ppart dkl_obs4 /* used to by physical partition */
235 #error "No VTOC format defined."
238 struct fk_label
{ /* DOS floppy label */
246 * Layout of stored fabricated device id (on-disk)
248 #define DK_DEVID_BLKSIZE (512)
249 #define DK_DEVID_SIZE (DK_DEVID_BLKSIZE - ((sizeof (uchar_t) * 7)))
250 #define DK_DEVID_REV_MSB (0)
251 #define DK_DEVID_REV_LSB (1)
254 uchar_t dkd_rev_hi
; /* revision (MSB) */
255 uchar_t dkd_rev_lo
; /* revision (LSB) */
256 uchar_t dkd_flags
; /* flags (not used yet) */
257 uchar_t dkd_devid
[DK_DEVID_SIZE
]; /* devid stored here */
258 uchar_t dkd_checksum3
; /* checksum (MSB) */
259 uchar_t dkd_checksum2
;
260 uchar_t dkd_checksum1
;
261 uchar_t dkd_checksum0
; /* checksum (LSB) */
264 #define DKD_GETCHKSUM(dkd) ((dkd)->dkd_checksum3 << 24) + \
265 ((dkd)->dkd_checksum2 << 16) + \
266 ((dkd)->dkd_checksum1 << 8) + \
267 ((dkd)->dkd_checksum0)
269 #define DKD_FORMCHKSUM(c, dkd) (dkd)->dkd_checksum3 = hibyte(hiword((c))); \
270 (dkd)->dkd_checksum2 = lobyte(hiword((c))); \
271 (dkd)->dkd_checksum1 = hibyte(loword((c))); \
272 (dkd)->dkd_checksum0 = lobyte(loword((c)));
277 #endif /* _SYS_DKLABEL_H */