Home | History | Annotate | Line # | Download | only in scsipi
stvar.h revision 1.1
      1  1.1  bouyer /*	$NetBSD: stvar.h,v 1.1 2001/05/04 07:48:57 bouyer Exp $ */
      2  1.1  bouyer 
      3  1.1  bouyer /*-
      4  1.1  bouyer  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  1.1  bouyer  * All rights reserved.
      6  1.1  bouyer  *
      7  1.1  bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  bouyer  * by Charles M. Hannum.
      9  1.1  bouyer  *
     10  1.1  bouyer  * Redistribution and use in source and binary forms, with or without
     11  1.1  bouyer  * modification, are permitted provided that the following conditions
     12  1.1  bouyer  * are met:
     13  1.1  bouyer  * 1. Redistributions of source code must retain the above copyright
     14  1.1  bouyer  *    notice, this list of conditions and the following disclaimer.
     15  1.1  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  bouyer  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  bouyer  *    documentation and/or other materials provided with the distribution.
     18  1.1  bouyer  * 3. All advertising materials mentioning features or use of this software
     19  1.1  bouyer  *    must display the following acknowledgement:
     20  1.1  bouyer  *        This product includes software developed by the NetBSD
     21  1.1  bouyer  *        Foundation, Inc. and its contributors.
     22  1.1  bouyer  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1  bouyer  *    contributors may be used to endorse or promote products derived
     24  1.1  bouyer  *    from this software without specific prior written permission.
     25  1.1  bouyer  *
     26  1.1  bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1  bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1  bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1  bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1  bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1  bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1  bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1  bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1  bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1  bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1  bouyer  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  bouyer  */
     38  1.1  bouyer 
     39  1.1  bouyer /*
     40  1.1  bouyer  * Originally written by Julian Elischer (julian (at) tfs.com)
     41  1.1  bouyer  * for TRW Financial Systems for use under the MACH(2.5) operating system.
     42  1.1  bouyer  *
     43  1.1  bouyer  * TRW Financial Systems, in accordance with their agreement with Carnegie
     44  1.1  bouyer  * Mellon University, makes this software available to CMU to distribute
     45  1.1  bouyer  * or use in any manner that they see fit as long as this message is kept with
     46  1.1  bouyer  * the software. For this reason TFS also grants any other persons or
     47  1.1  bouyer  * organisations permission to use or modify this software.
     48  1.1  bouyer  *
     49  1.1  bouyer  * TFS supplies this software to be publicly redistributed
     50  1.1  bouyer  * on the understanding that TFS is not responsible for the correct
     51  1.1  bouyer  * functioning of this software in any circumstances.
     52  1.1  bouyer  *
     53  1.1  bouyer  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     54  1.1  bouyer  * major changes by Julian Elischer (julian (at) jules.dialix.oz.au) May 1993
     55  1.1  bouyer  *
     56  1.1  bouyer  * A lot of rewhacking done by mjacob (mjacob (at) nas.nasa.gov).
     57  1.1  bouyer  */
     58  1.1  bouyer 
     59  1.1  bouyer #include "rnd.h"
     60  1.1  bouyer #if NRND > 0
     61  1.1  bouyer #include <sys/rnd.h>
     62  1.1  bouyer #endif
     63  1.1  bouyer 
     64  1.1  bouyer #include <dev/scsipi/scsipi_all.h>
     65  1.1  bouyer #include <dev/scsipi/scsiconf.h>
     66  1.1  bouyer 
     67  1.1  bouyer struct modes {
     68  1.1  bouyer 	u_int quirks;			/* same definitions as in quirkdata */
     69  1.1  bouyer 	int blksize;
     70  1.1  bouyer 	u_int8_t density;
     71  1.1  bouyer };
     72  1.1  bouyer 
     73  1.1  bouyer struct quirkdata {
     74  1.1  bouyer 	u_int quirks;
     75  1.1  bouyer #define	ST_Q_FORCE_BLKSIZE	0x0001
     76  1.1  bouyer #define	ST_Q_SENSE_HELP		0x0002	/* must do READ for good MODE SENSE */
     77  1.1  bouyer #define	ST_Q_IGNORE_LOADS	0x0004
     78  1.1  bouyer #define	ST_Q_BLKSIZE		0x0008	/* variable-block media_blksize > 0 */
     79  1.1  bouyer #define	ST_Q_UNIMODAL		0x0010	/* unimode drive rejects mode select */
     80  1.1  bouyer #define	ST_Q_NOPREVENT		0x0020	/* does not support PREVENT */
     81  1.1  bouyer #define	ST_Q_ERASE_NOIMM	0x0040	/* drive rejects ERASE/w Immed bit */
     82  1.1  bouyer 	u_int page_0_size;
     83  1.1  bouyer #define	MAX_PAGE_0_SIZE	64
     84  1.1  bouyer 	struct modes modes[4];
     85  1.1  bouyer };
     86  1.1  bouyer 
     87  1.1  bouyer struct st_quirk_inquiry_pattern {
     88  1.1  bouyer 	struct scsipi_inquiry_pattern pattern;
     89  1.1  bouyer 	struct quirkdata quirkdata;
     90  1.1  bouyer };
     91  1.1  bouyer 
     92  1.1  bouyer struct st_softc {
     93  1.1  bouyer 	struct device sc_dev;
     94  1.1  bouyer /*--------------------present operating parameters, flags etc.---------------*/
     95  1.1  bouyer 	int flags;		/* see below                         */
     96  1.1  bouyer 	u_int quirks;		/* quirks for the open mode          */
     97  1.1  bouyer 	int blksize;		/* blksize we are using              */
     98  1.1  bouyer 	u_int8_t density;	/* present density                   */
     99  1.1  bouyer 	u_int page_0_size;	/* size of page 0 data		     */
    100  1.1  bouyer 	u_int last_dsty;	/* last density opened               */
    101  1.1  bouyer 	short mt_resid;		/* last (short) resid                */
    102  1.1  bouyer 	short mt_erreg;		/* last error (sense key) seen       */
    103  1.1  bouyer #define	mt_key	mt_erreg
    104  1.1  bouyer 	u_int8_t asc;		/* last asc code seen		     */
    105  1.1  bouyer 	u_int8_t ascq;		/* last asc code seen		     */
    106  1.1  bouyer /*--------------------device/scsi parameters---------------------------------*/
    107  1.1  bouyer 	struct scsipi_periph *sc_periph;/* our link to the adpter etc.       */
    108  1.1  bouyer /*--------------------parameters reported by the device ---------------------*/
    109  1.1  bouyer 	int blkmin;		/* min blk size                       */
    110  1.1  bouyer 	int blkmax;		/* max blk size                       */
    111  1.1  bouyer 	struct quirkdata *quirkdata;	/* if we have a rogue entry          */
    112  1.1  bouyer /*--------------------parameters reported by the device for this media-------*/
    113  1.1  bouyer 	u_long numblks;		/* nominal blocks capacity            */
    114  1.1  bouyer 	int media_blksize;	/* 0 if not ST_FIXEDBLOCKS            */
    115  1.1  bouyer 	u_int8_t media_density;	/* this is what it said when asked    */
    116  1.1  bouyer /*--------------------quirks for the whole drive-----------------------------*/
    117  1.1  bouyer 	u_int drive_quirks;	/* quirks of this drive               */
    118  1.1  bouyer /*--------------------How we should set up when opening each minor device----*/
    119  1.1  bouyer 	struct modes modes[4];	/* plus more for each mode            */
    120  1.1  bouyer 	u_int8_t  modeflags[4];	/* flags for the modes                */
    121  1.1  bouyer #define DENSITY_SET_BY_USER	0x01
    122  1.1  bouyer #define DENSITY_SET_BY_QUIRK	0x02
    123  1.1  bouyer #define BLKSIZE_SET_BY_USER	0x04
    124  1.1  bouyer #define BLKSIZE_SET_BY_QUIRK	0x08
    125  1.1  bouyer /*--------------------storage for sense data returned by the drive-----------*/
    126  1.1  bouyer 	u_char sense_data[MAX_PAGE_0_SIZE];	/*
    127  1.1  bouyer 						 * additional sense data needed
    128  1.1  bouyer 						 * for mode sense/select.
    129  1.1  bouyer 						 */
    130  1.1  bouyer 	struct buf_queue buf_queue;	/* the queue of pending IO */
    131  1.1  bouyer 					/* operations */
    132  1.1  bouyer #if NRND > 0
    133  1.1  bouyer 	rndsource_element_t	rnd_source;
    134  1.1  bouyer #endif
    135  1.1  bouyer };
    136  1.1  bouyer 
    137  1.1  bouyer 
    138  1.1  bouyer void	stattach __P((struct device *, struct device *, void *));
    139  1.1  bouyer 
    140  1.1  bouyer extern struct cfdriver st_cd;
    141