ccdvar.h revision 1.8 1 /* $NetBSD: ccdvar.h,v 1.8 1995/10/12 21:28:35 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1995 Jason R. Thorpe.
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 for the NetBSD Project
18 * by Jason R. Thorpe.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35 /*
36 * Copyright (c) 1988 University of Utah.
37 * Copyright (c) 1990, 1993
38 * The Regents of the University of California. All rights reserved.
39 *
40 * This code is derived from software contributed to Berkeley by
41 * the Systems Programming Group of the University of Utah Computer
42 * Science Department.
43 *
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
46 * are met:
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
59 *
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 * SUCH DAMAGE.
71 *
72 * from: Utah $Hdr: cdvar.h 1.1 90/07/09$
73 *
74 * @(#)cdvar.h 8.1 (Berkeley) 6/10/93
75 */
76
77 /*
78 * Dynamic configuration and disklabel support by:
79 * Jason R. Thorpe <thorpej (at) nas.nasa.gov>
80 * Numerical Aerodynamic Simulation Facility
81 * Mail Stop 258-6
82 * NASA Ames Research Center
83 * Moffett Field, CA 94035
84 */
85
86 /*
87 * A concatenated disk is described at initialization time by this structure.
88 */
89 struct ccddevice {
90 int ccd_unit; /* logical unit of this ccd */
91 int ccd_interleave; /* interleave (DEV_BSIZE blocks) */
92 int ccd_flags; /* misc. information */
93 int ccd_dk; /* disk number */
94 struct vnode **ccd_vpp; /* array of component vnodes */
95 char **ccd_cpp; /* array of component pathnames */
96 int ccd_ndev; /* number of component devices */
97 };
98
99 /*
100 * This structure is used to configure a ccd via ioctl(2).
101 */
102 struct ccd_ioctl {
103 char **ccio_disks; /* pointer to component paths */
104 int ccio_ndisks; /* number of disks to concatenate */
105 int ccio_ileave; /* interleave (DEV_BSIZE blocks) */
106 int ccio_flags; /* misc. information */
107 int ccio_unit; /* unit number: use varies */
108 size_t ccio_size; /* (returned) size of ccd */
109 };
110
111 /* ccd_flags */
112 #define CCDF_SWAP 0x01 /* interleave should be dmmax */
113 #define CCDF_UNIFORM 0x02 /* use LCCD of sizes for uniform interleave */
114
115 /* Mask of user-settable ccd flags. */
116 #define CCDF_USERMASK (CCDF_SWAP|CCDF_UNIFORM)
117
118 /*
119 * Component info table.
120 * Describes a single component of a concatenated disk.
121 */
122 struct ccdcinfo {
123 struct vnode *ci_vp; /* device's vnode */
124 dev_t ci_dev; /* XXX: device's dev_t */
125 size_t ci_size; /* size */
126 char *ci_path; /* path to component */
127 size_t ci_pathlen; /* length of component path */
128 };
129
130 /*
131 * Interleave description table.
132 * Computed at boot time to speed irregular-interleave lookups.
133 * The idea is that we interleave in "groups". First we interleave
134 * evenly over all component disks up to the size of the smallest
135 * component (the first group), then we interleave evenly over all
136 * remaining disks up to the size of the next-smallest (second group),
137 * and so on.
138 *
139 * Each table entry describes the interleave characteristics of one
140 * of these groups. For example if a concatenated disk consisted of
141 * three components of 5, 3, and 7 DEV_BSIZE blocks interleaved at
142 * DEV_BSIZE (1), the table would have three entries:
143 *
144 * ndisk startblk startoff dev
145 * 3 0 0 0, 1, 2
146 * 2 9 3 0, 2
147 * 1 13 5 2
148 * 0 - - -
149 *
150 * which says that the first nine blocks (0-8) are interleaved over
151 * 3 disks (0, 1, 2) starting at block offset 0 on any component disk,
152 * the next 4 blocks (9-12) are interleaved over 2 disks (0, 2) starting
153 * at component block 3, and the remaining blocks (13-14) are on disk
154 * 2 starting at offset 5.
155 */
156 struct ccdiinfo {
157 int ii_ndisk; /* # of disks range is interleaved over */
158 daddr_t ii_startblk; /* starting scaled block # for range */
159 daddr_t ii_startoff; /* starting component offset (block #) */
160 int *ii_index; /* ordered list of components in range */
161 };
162
163 /*
164 * Concatenated disk pseudo-geometry information.
165 */
166 struct ccdgeom {
167 u_int32_t ccg_secsize; /* # bytes per sector */
168 u_int32_t ccg_nsectors; /* # data sectors per track */
169 u_int32_t ccg_ntracks; /* # tracks per cylinder */
170 u_int32_t ccg_ncylinders; /* # cylinders per unit */
171 };
172
173 /*
174 * A concatenated disk is described after initialization by this structure.
175 */
176 struct ccd_softc {
177 int sc_unit; /* logical unit number */
178 int sc_flags; /* flags */
179 int sc_cflags; /* configuration flags */
180 size_t sc_size; /* size of ccd */
181 int sc_ileave; /* interleave */
182 int sc_nccdisks; /* number of components */
183 struct ccdcinfo *sc_cinfo; /* component info */
184 struct ccdiinfo *sc_itable; /* interleave table */
185 int sc_nactive; /* number of requests active */
186 int sc_dk; /* disk index */
187 struct ccdgeom sc_geom; /* pseudo geometry info */
188 struct dkdevice sc_dkdev; /* generic disk device info */
189 };
190
191 /* sc_flags */
192 #define CCDF_INITED 0x01 /* unit has been initialized */
193 #define CCDF_WLABEL 0x02 /* label area is writable */
194 #define CCDF_LABELLING 0x04 /* unit is currently being labelled */
195 #define CCDF_WANTED 0x40 /* someone is waiting to obtain a lock */
196 #define CCDF_LOCKED 0x80 /* unit is locked */
197
198 /*
199 * Before you can use a unit, it must be configured with CCDIOCSET.
200 * The configuration persists across opens and closes of the device;
201 * a CCDIOCCLR must be used to reset a configuration. An attempt to
202 * CCDIOCSET an already active unit will return EBUSY. Attempts to
203 * CCDIOCCLR an inactive unit will return ENXIO.
204 */
205 #define CCDIOCSET _IOWR('F', 16, struct ccd_ioctl) /* enable ccd */
206 #define CCDIOCCLR _IOW('F', 17, struct ccd_ioctl) /* disable ccd */
207