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