stvar.h revision 1.1 1 /* $NetBSD: stvar.h,v 1.1 2001/05/04 07:48:57 bouyer Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Charles M. Hannum.
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 * Originally written by Julian Elischer (julian (at) tfs.com)
41 * for TRW Financial Systems for use under the MACH(2.5) operating system.
42 *
43 * TRW Financial Systems, in accordance with their agreement with Carnegie
44 * Mellon University, makes this software available to CMU to distribute
45 * or use in any manner that they see fit as long as this message is kept with
46 * the software. For this reason TFS also grants any other persons or
47 * organisations permission to use or modify this software.
48 *
49 * TFS supplies this software to be publicly redistributed
50 * on the understanding that TFS is not responsible for the correct
51 * functioning of this software in any circumstances.
52 *
53 * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
54 * major changes by Julian Elischer (julian (at) jules.dialix.oz.au) May 1993
55 *
56 * A lot of rewhacking done by mjacob (mjacob (at) nas.nasa.gov).
57 */
58
59 #include "rnd.h"
60 #if NRND > 0
61 #include <sys/rnd.h>
62 #endif
63
64 #include <dev/scsipi/scsipi_all.h>
65 #include <dev/scsipi/scsiconf.h>
66
67 struct modes {
68 u_int quirks; /* same definitions as in quirkdata */
69 int blksize;
70 u_int8_t density;
71 };
72
73 struct quirkdata {
74 u_int quirks;
75 #define ST_Q_FORCE_BLKSIZE 0x0001
76 #define ST_Q_SENSE_HELP 0x0002 /* must do READ for good MODE SENSE */
77 #define ST_Q_IGNORE_LOADS 0x0004
78 #define ST_Q_BLKSIZE 0x0008 /* variable-block media_blksize > 0 */
79 #define ST_Q_UNIMODAL 0x0010 /* unimode drive rejects mode select */
80 #define ST_Q_NOPREVENT 0x0020 /* does not support PREVENT */
81 #define ST_Q_ERASE_NOIMM 0x0040 /* drive rejects ERASE/w Immed bit */
82 u_int page_0_size;
83 #define MAX_PAGE_0_SIZE 64
84 struct modes modes[4];
85 };
86
87 struct st_quirk_inquiry_pattern {
88 struct scsipi_inquiry_pattern pattern;
89 struct quirkdata quirkdata;
90 };
91
92 struct st_softc {
93 struct device sc_dev;
94 /*--------------------present operating parameters, flags etc.---------------*/
95 int flags; /* see below */
96 u_int quirks; /* quirks for the open mode */
97 int blksize; /* blksize we are using */
98 u_int8_t density; /* present density */
99 u_int page_0_size; /* size of page 0 data */
100 u_int last_dsty; /* last density opened */
101 short mt_resid; /* last (short) resid */
102 short mt_erreg; /* last error (sense key) seen */
103 #define mt_key mt_erreg
104 u_int8_t asc; /* last asc code seen */
105 u_int8_t ascq; /* last asc code seen */
106 /*--------------------device/scsi parameters---------------------------------*/
107 struct scsipi_periph *sc_periph;/* our link to the adpter etc. */
108 /*--------------------parameters reported by the device ---------------------*/
109 int blkmin; /* min blk size */
110 int blkmax; /* max blk size */
111 struct quirkdata *quirkdata; /* if we have a rogue entry */
112 /*--------------------parameters reported by the device for this media-------*/
113 u_long numblks; /* nominal blocks capacity */
114 int media_blksize; /* 0 if not ST_FIXEDBLOCKS */
115 u_int8_t media_density; /* this is what it said when asked */
116 /*--------------------quirks for the whole drive-----------------------------*/
117 u_int drive_quirks; /* quirks of this drive */
118 /*--------------------How we should set up when opening each minor device----*/
119 struct modes modes[4]; /* plus more for each mode */
120 u_int8_t modeflags[4]; /* flags for the modes */
121 #define DENSITY_SET_BY_USER 0x01
122 #define DENSITY_SET_BY_QUIRK 0x02
123 #define BLKSIZE_SET_BY_USER 0x04
124 #define BLKSIZE_SET_BY_QUIRK 0x08
125 /*--------------------storage for sense data returned by the drive-----------*/
126 u_char sense_data[MAX_PAGE_0_SIZE]; /*
127 * additional sense data needed
128 * for mode sense/select.
129 */
130 struct buf_queue buf_queue; /* the queue of pending IO */
131 /* operations */
132 #if NRND > 0
133 rndsource_element_t rnd_source;
134 #endif
135 };
136
137
138 void stattach __P((struct device *, struct device *, void *));
139
140 extern struct cfdriver st_cd;
141