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