xref: /netbsd/sys/dev/vme/xyvar.h (revision c4a72b64)
1 /*	$NetBSD: xyvar.h,v 1.8 2002/07/23 20:49:55 hannken Exp $	*/
2 
3 /*
4  *
5  * Copyright (c) 1995 Charles D. Cranor
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by Charles D. Cranor.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * x y v a r . h
36  *
37  * this file defines the software structure we use to control the
38  * 450/451.
39  *
40  * author: Chuck Cranor <chuck@ccrc.wustl.edu>
41  */
42 
43 #include <sys/callout.h>
44 
45 /*
46  * i/o request: wrapper for hardware's iopb data structure
47  */
48 struct xy_iorq {
49 	struct xy_iopb *iopb;	/* address of matching iopb */
50 	struct xy_iopb *dmaiopb;/* DMA address of above */
51 	struct xyc_softc *xyc;	/* who we are working with */
52 	struct xy_softc *xy;	/* which disk */
53 	int ttl;		/* time to live */
54 	int mode;		/* current mode (state+other data) */
55 	int tries;		/* number of times we have tried it */
56 	int errno;		/* error number if we fail */
57 	int lasterror;		/* last error we got */
58 	int blockno;		/* starting block no for this xfer */
59 	int sectcnt;		/* number of sectors in xfer */
60 	char *dbuf;		/* KVA of data buffer (advances) */
61 	struct buf *buf;	/* for NORM */
62 	bus_dmamap_t dmamap;	/* DMA I/O handle */
63 };
64 
65 /*
66  * state
67  */
68 #define XY_SUB_MASK	0xf0	/* mask bits for state */
69 #define XY_SUB_FREE	0x00	/* free */
70 #define XY_SUB_NORM	0x10	/* normal I/O request */
71 #define XY_SUB_WAIT	0x20	/* normal I/O request in the
72                                    context of a process */
73 #define XY_SUB_POLL	0x30	/* polled mode */
74 #define XY_SUB_DONE	0x40	/* not active, but can't be free'd yet */
75 #define XY_SUB_NOQ	0x50	/* don't queue, just submit (internal) */
76 
77 #define XY_STATE(X) ((X) & XY_SUB_MASK) /* extract state from mode */
78 #define XY_NEWSTATE(OLD, NEW) (((OLD) & ~XY_SUB_MASK) |(NEW)) /* new state */
79 
80 
81 /*
82  * other mode data
83  */
84 #define XY_MODE_VERBO	0x08	/* print error messages */
85 #define XY_MODE_B144	0x04	/* handling a bad144 sector */
86 
87 
88 /*
89  * software timers and flags
90  */
91 #define XYC_SUBWAITLIM	4	/* max number of "done" IOPBs there can be
92 				   where we still allow a SUB_WAIT command */
93 #define XYC_TICKCNT	(5*hz)	/* call xyc_tick on this interval (5 sec) */
94 #define XYC_MAXTTL	2	/* max number of xy ticks to live */
95 #define XYC_NOUNIT	(-1)	/* for xycmd: no unit number */
96 
97 /*
98  * a "xy_softc" structure contains per-disk state info.
99  */
100 struct xy_softc {
101 	struct device sc_dev;	/* device struct, reqd by autoconf */
102 	struct disk sc_dk;	/* generic disk info */
103 	struct xyc_softc *parent;/* parent */
104 	u_short flags;		/* flags */
105 	u_short state;		/* device state */
106 	int xy_drive;		/* unit number */
107 	int drive_type;		/* drive type (as per disk) */
108 
109 	/* geometry */
110 	u_short ncyl, acyl, pcyl;	/* number of cyl's */
111 	u_short sectpercyl;	/* nhead*nsect */
112 	u_char nhead;		/* number of heads */
113 	u_char nsect;		/* number of sectors per track */
114 	u_char hw_spt;		/* as above, but includes spare sectors */
115 	struct xy_iorq *xyrq;	/* this disk's ioreq structure */
116 	struct bufq_state xyq;	/* queued I/O requests */
117 	struct dkbad dkb;	/* bad144 sectors */
118 };
119 
120 /*
121  * flags
122  */
123 
124 #define XY_WLABEL 0x0001           /* write label */
125 /*
126  * state
127  */
128 
129 #define XY_DRIVE_UNKNOWN 0         /* never talked to it */
130 #define XY_DRIVE_ATTACHING 1       /* attach in progress */
131 #define XY_DRIVE_NOLABEL 2         /* drive on-line, no label */
132 #define XY_DRIVE_ONLINE  3         /* drive is on-line */
133 
134 /*
135  * a "xyc_softc" structure contains per-disk-controller state info,
136  * including a list of active controllers.
137  */
138 
139 struct xyc_softc {
140 	struct device sc_dev;		/* device struct, reqd by autoconf */
141 	struct evcnt sc_intrcnt;	/* event counter (for vmstat -i) */
142 
143 	struct callout sc_tick_ch;
144 
145 	struct xyc *xyc;		/* vaddr of vme registers */
146 
147 	struct xy_softc *sc_drives[XYC_MAXDEV]; /* drives on this controller */
148 	int ipl;			/* interrupt level */
149 	int vector;			/* interrupt vector */
150 	bus_dma_tag_t dmatag;		/* Bus DMA tag */
151 
152 	struct xy_iorq *reqs;		/* i/o requests */
153 	struct xy_iopb *iopbase;	/* iopb base addr (maps iopb->iorq) */
154 	struct xy_iopb *dvmaiopb;	/* iopb base in DVMA space, not kvm */
155 	bus_dmamap_t iopmap;		/* IOPB DMA handle */
156 	bus_dmamap_t auxmap;		/* auxiliary DMA handle */
157 
158 	struct xy_iorq *ciorq;		/* controller's iorq */
159 	struct xy_iopb *ciopb;		/* controller's iopb */
160 
161 	int xy_hand;			/* hand */
162 	struct xy_iorq *xy_chain[XYC_MAXIOPB];
163 					/* current chain */
164 	int no_ols;			/* disable overlap seek for stupid 450s */
165 };
166 
167 /*
168  * reset blast modes
169  */
170 
171 #define XY_RSET_NONE (struct xy_iorq *)(-1)   /* restart all requests */
172 #define XY_RSET_ALL  (struct xy_iorq *)(-2)   /* don't restart anything */
173