Home | History | Annotate | Line # | Download | only in scsipi
sdvar.h revision 1.16.8.1
      1  1.16.8.1   gehenna /*	$NetBSD: sdvar.h,v 1.16.8.1 2002/07/20 11:35:10 gehenna Exp $	*/
      2       1.1       cgd 
      3       1.7   mycroft /*-
      4       1.7   mycroft  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5       1.7   mycroft  * All rights reserved.
      6       1.7   mycroft  *
      7       1.7   mycroft  * This code is derived from software contributed to The NetBSD Foundation
      8       1.7   mycroft  * by Charles M. Hannum.
      9       1.1       cgd  *
     10       1.1       cgd  * Redistribution and use in source and binary forms, with or without
     11       1.1       cgd  * modification, are permitted provided that the following conditions
     12       1.1       cgd  * are met:
     13       1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     14       1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     15       1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     17       1.1       cgd  *    documentation and/or other materials provided with the distribution.
     18       1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     19       1.1       cgd  *    must display the following acknowledgement:
     20       1.7   mycroft  *        This product includes software developed by the NetBSD
     21       1.7   mycroft  *        Foundation, Inc. and its contributors.
     22       1.7   mycroft  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.7   mycroft  *    contributors may be used to endorse or promote products derived
     24       1.7   mycroft  *    from this software without specific prior written permission.
     25       1.1       cgd  *
     26       1.7   mycroft  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.7   mycroft  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.7   mycroft  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.7   mycroft  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.7   mycroft  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.7   mycroft  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.7   mycroft  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.7   mycroft  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.7   mycroft  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.7   mycroft  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.7   mycroft  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1       cgd  */
     38       1.1       cgd 
     39       1.1       cgd /*
     40       1.1       cgd  * Originally written by Julian Elischer (julian (at) dialix.oz.au)
     41       1.1       cgd  * for TRW Financial Systems for use under the MACH(2.5) operating system.
     42       1.1       cgd  *
     43       1.1       cgd  * TRW Financial Systems, in accordance with their agreement with Carnegie
     44       1.1       cgd  * Mellon University, makes this software available to CMU to distribute
     45       1.1       cgd  * or use in any manner that they see fit as long as this message is kept with
     46       1.1       cgd  * the software. For this reason TFS also grants any other persons or
     47       1.1       cgd  * organisations permission to use or modify this software.
     48       1.1       cgd  *
     49       1.1       cgd  * TFS supplies this software to be publicly redistributed
     50       1.1       cgd  * on the understanding that TFS is not responsible for the correct
     51       1.1       cgd  * functioning of this software in any circumstances.
     52       1.1       cgd  *
     53       1.1       cgd  * Ported to run under 386BSD by Julian Elischer (julian (at) dialix.oz.au) Sept 1992
     54       1.1       cgd  */
     55      1.11  drochner 
     56      1.14    mjacob #include "opt_scsi.h"
     57      1.11  drochner #include "rnd.h"
     58      1.11  drochner #if NRND > 0
     59      1.11  drochner #include <sys/rnd.h>
     60      1.11  drochner #endif
     61       1.1       cgd 
     62      1.14    mjacob #ifndef	SDRETRIES
     63       1.1       cgd #define	SDRETRIES	4
     64      1.14    mjacob #endif
     65      1.14    mjacob 
     66      1.14    mjacob #ifndef	SD_IO_TIMEOUT
     67      1.15       chs #define	SD_IO_TIMEOUT	(60 * 1000)
     68      1.14    mjacob #endif
     69       1.1       cgd 
     70       1.1       cgd struct sd_ops;
     71       1.1       cgd 
     72       1.1       cgd struct sd_softc {
     73       1.1       cgd 	struct device sc_dev;
     74       1.1       cgd 	struct disk sc_dk;
     75       1.1       cgd 
     76       1.1       cgd 	int flags;
     77       1.1       cgd #define	SDF_LOCKED	0x01
     78       1.1       cgd #define	SDF_WANTED	0x02
     79       1.1       cgd #define	SDF_WLABEL	0x04		/* label is writable */
     80       1.1       cgd #define	SDF_LABELLING	0x08		/* writing label */
     81       1.1       cgd #define	SDF_ANCIENT	0x10		/* disk is ancient; for minphys */
     82       1.6   thorpej #define	SDF_DIRTY	0x20		/* disk is dirty; needs cache flush */
     83       1.6   thorpej #define	SDF_FLUSHING	0x40		/* flushing, for sddone() */
     84      1.13    bouyer 
     85      1.13    bouyer 	struct scsipi_periph *sc_periph;/* contains our targ, lun, etc. */
     86      1.13    bouyer 
     87       1.1       cgd 	struct disk_parms {
     88       1.1       cgd 		u_long	heads;		/* number of heads */
     89       1.1       cgd 		u_long	cyls;		/* number of cylinders */
     90       1.1       cgd 		u_long	sectors;	/* number of sectors/track */
     91       1.1       cgd 		u_long	blksize;	/* number of bytes/sector */
     92       1.1       cgd 		u_long	disksize;	/* total number sectors */
     93       1.1       cgd 		u_long	rot_rate;	/* rotational rate, in RPM */
     94       1.1       cgd 	} params;
     95      1.13    bouyer 
     96  1.16.8.1   gehenna 	struct bufq_state buf_queue;
     97       1.1       cgd 	u_int8_t type;
     98       1.5  drochner 	char name[16]; /* product name, for default disklabel */
     99       1.1       cgd 	const struct sd_ops *sc_ops;	/* our bus-dependent ops vector */
    100       1.4   thorpej 
    101       1.4   thorpej 	void *sc_sdhook;		/* our shutdown hook */
    102       1.1       cgd 
    103       1.1       cgd #if NRND > 0
    104       1.1       cgd 	rndsource_element_t rnd_source;
    105       1.1       cgd #endif
    106       1.1       cgd };
    107       1.1       cgd 
    108       1.1       cgd struct sd_ops {
    109       1.1       cgd 	int	(*sdo_get_parms) __P((struct sd_softc *, struct disk_parms *,
    110       1.1       cgd 		    int));
    111       1.8   hannken 	int	(*sdo_flush) __P((struct sd_softc *, int));
    112      1.16   thorpej 	int	(*sdo_getcache) __P((struct sd_softc *, int *));
    113      1.16   thorpej 	int	(*sdo_setcache) __P((struct sd_softc *, int));
    114       1.1       cgd };
    115       1.1       cgd #define	SDGP_RESULT_OK		0	/* paramters obtained */
    116       1.1       cgd #define	SDGP_RESULT_OFFLINE	1	/* no media, or otherwise losing */
    117       1.1       cgd #define	SDGP_RESULT_UNFORMATTED	2	/* unformatted media (max params) */
    118       1.1       cgd 
    119      1.13    bouyer void sdattach __P((struct device *, struct sd_softc *, struct scsipi_periph *,
    120       1.1       cgd     const struct sd_ops *));
    121       1.9   thorpej int sdactivate __P((struct device *, enum devact));
    122       1.9   thorpej int sddetach __P((struct device *, int));
    123