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