Annotation of sys/arch/vax/mscp/mscpvar.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: mscpvar.h,v 1.6 2003/06/02 23:27:57 millert Exp $ */
2: /* $NetBSD: mscpvar.h,v 1.7 1999/06/06 19:16:18 ragge Exp $ */
3: /*
4: * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
5: * Copyright (c) 1988 Regents of the University of California.
6: * All rights reserved.
7: *
8: * This code is derived from software contributed to Berkeley by
9: * Chris Torek.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: * 2. Redistributions in binary form must reproduce the above copyright
17: * notice, this list of conditions and the following disclaimer in the
18: * documentation and/or other materials provided with the distribution.
19: * 3. Neither the name of the University nor the names of its contributors
20: * may be used to endorse or promote products derived from this software
21: * without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33: * SUCH DAMAGE.
34: *
35: * @(#)mscpvar.h 7.3 (Berkeley) 6/28/90
36: */
37:
38: /*
39: * MSCP generic driver configuration
40: */
41:
42: /*
43: * Enabling MSCP_PARANOIA makes the response code perform various checks
44: * on the hardware. (Right now it verifies only the buffer pointer in
45: * mscp_cmdref.)
46: *
47: * Enabling AVOID_EMULEX_BUG selects an alternative method of identifying
48: * transfers in progress, which gets around a rather peculiar bug in the
49: * SC41/MS. Enabling MSCP_PARANOIA instead should work, but will cause
50: * `extra' Unibus resets.
51: *
52: * Either of these flags can simply be included as an `options' line in
53: * your configuration file.
54: */
55:
56: /* #define MSCP_PARANOIA */
57: /* #define AVOID_EMULEX_BUG */
58:
59: /*
60: * Ring information, per ring (one each for commands and responses).
61: */
62: struct mscp_ri {
63: int mri_size; /* ring size */
64: int mri_next; /* next (expected|free) */
65: long *mri_desc; /* base address of descriptors */
66: struct mscp *mri_ring; /* base address of packets */
67: };
68:
69: /*
70: * Transfer info, one per command packet.
71: */
72: struct mscp_xi {
73: bus_dmamap_t mxi_dmam; /* Allocated DMA map for this entry */
74: struct buf * mxi_bp; /* Buffer used in this command */
75: struct mscp * mxi_mp; /* Packet used in this command */
76: int mxi_inuse;
77: };
78:
79: struct mscp_ctlr {
80: /* controller operation complete */
81: void (*mc_ctlrdone)(struct device *);
82: /* device-specific start routine */
83: void (*mc_go)(struct device *, struct mscp_xi *);
84: /* ctlr error handling */
85: void (*mc_saerror)(struct device *, int);
86: };
87:
88: struct mscp_softc;
89:
90: struct mscp_device {
91: /* error datagram */
92: void (*me_dgram)(struct device *, struct mscp *, struct mscp_softc *);
93: /* normal I/O is done */
94: void (*me_iodone)(struct device *, struct buf *);
95: /* drive on line */
96: int (*me_online)(struct device *, struct mscp *);
97: /* got unit status */
98: int (*me_gotstatus)(struct device *, struct mscp *);
99: /* replace done */
100: void (*me_replace)(struct device *, struct mscp *);
101: /* read or write failed */
102: int (*me_ioerr)(struct device *, struct mscp *, struct buf *);
103: /* B_BAD io done */
104: void (*me_bb)(struct device *, struct mscp *, struct buf *);
105: /* Fill in mscp info for this drive */
106: void (*me_fillin)(struct buf *,struct mscp *);
107: /* Non-data transfer operation is done */
108: void (*me_cmddone)(struct device *, struct mscp *);
109: };
110:
111: /*
112: * This struct is used when attaching a mscpbus.
113: */
114: struct mscp_attach_args {
115: struct mscp_ctlr *ma_mc; /* Pointer to ctlr's mscp_ctlr */
116: int ma_type; /* disk/tape bus type */
117: struct mscp_pack *ma_uda; /* comm area virtual */
118: struct mscp_softc **ma_softc; /* backpointer to bus softc */
119: bus_dmamap_t ma_dmam; /* This comm area dma info */
120: bus_dma_tag_t ma_dmat;
121: bus_space_tag_t ma_iot;
122: bus_space_handle_t ma_iph; /* initialisation and polling */
123: bus_space_handle_t ma_sah; /* status & address (read part) */
124: bus_space_handle_t ma_swh; /* status & address (write part) */
125: short ma_ivec; /* Interrupt vector to use */
126: char ma_ctlrnr; /* Phys ctlr nr */
127: char ma_adapnr; /* Phys adapter nr */
128: };
129: #define MSCPBUS_DISK 001 /* Bus is used for disk mounts */
130: #define MSCPBUS_TAPE 002 /* Bus is used for tape mounts */
131: #define MSCPBUS_UDA 004 /* ctlr is disk on unibus/qbus */
132: #define MSCPBUS_KDB 010 /* ctlr is disk on BI */
133: #define MSCPBUS_KLE 020 /* ctlr is tape on unibus/qbus */
134:
135: /*
136: * Used when going for child devices.
137: */
138: struct drive_attach_args {
139: struct mscp *da_mp; /* this devices response struct */
140: int da_typ; /* Parent of type */
141: };
142:
143: /*
144: * Return values from functions.
145: * MSCP_RESTARTED is peculiar to I/O errors.
146: */
147: #define MSCP_DONE 0 /* all ok */
148: #define MSCP_FAILED 1 /* no go */
149: #define MSCP_RESTARTED 2 /* transfer restarted */
150:
151: /*
152: * Per device information.
153: *
154: * mi_ip is a pointer to the inverting pointers (things that get `ui's
155: * given unit numbers) FOR THIS CONTROLLER (NOT the whole set!).
156: *
157: * b_actf holds a queue of those transfers that were started but have
158: * not yet finished. Other Unibus drivers do not need this as they hand
159: * out requests one at a time. MSCP devices, however, take a slew of
160: * requests and pick their own order to execute them. This means that
161: * we have to have a place to move transfers that were given to the
162: * controller, so we can tell those apart from those that have not yet
163: * been handed out; b_actf is that place.
164: */
165: struct mscp_softc {
166: struct device mi_dev; /* Autoconf stuff */
167: struct mscp_ri mi_cmd; /* MSCP command ring info */
168: struct mscp_ri mi_rsp; /* MSCP response ring info */
169: bus_dma_tag_t mi_dmat;
170: bus_dmamap_t mi_dmam;
171: struct mscp_xi mi_xi[NCMD];
172: int mi_mxiuse; /* Bitfield of inuse mxi packets */
173: short mi_credits; /* transfer credits */
174: char mi_wantcmd; /* waiting for command packet */
175: char mi_wantcredits; /* waiting for transfer credits */
176: struct mscp_ctlr *mi_mc; /* Pointer to parent's mscp_ctlr */
177: struct mscp_device *mi_me; /* Pointer to child's mscp_device */
178: struct device **mi_dp; /* array of backpointers */
179: int mi_driveno; /* Max physical drive number found */
180: char mi_ctlrnr; /* Phys ctlr nr */
181: char mi_adapnr; /* Phys adapter nr */
182: int mi_flags;
183: struct mscp_pack *mi_uda; /* virtual address */
184: int mi_type;
185: short mi_ivec; /* Interrupt vector to use */
186: short mi_ierr; /* Init err counter */
187: bus_space_tag_t mi_iot;
188: bus_space_handle_t mi_iph; /* initialisation and polling */
189: bus_space_handle_t mi_sah; /* status & address (read part) */
190: bus_space_handle_t mi_swh; /* status & address (write part) */
191: SIMPLEQ_HEAD(, buf) mi_resq; /* While waiting for packets */
192: };
193:
194: /* mi_flags */
195: #define MSC_STARTPOLL 1
196: #define MSC_INSTART 2
197: #define MSC_IGNOREINTR 4
198: #define MSC_READY 8
199:
200: /*
201: * We have run out of credits when mi_credits is <= MSCP_MINCREDITS.
202: * It is still possible to issue one command in this case, but it must
203: * not be a data transfer. E.g., `get command status' or `abort command'
204: * is legal, while `read' is not.
205: */
206: #define MSCP_MINCREDITS 1
207:
208: /*
209: * Flags for mscp_getcp().
210: */
211: #define MSCP_WAIT 1
212: #define MSCP_DONTWAIT 0
213:
214: /* get a command packet */
215:
216: /*
217: * Unit flags
218: */
219: #define UNIT_ONLINE 0x01 /* drive is on line */
220: #define UNIT_HAVESTATUS 0x02 /* got unit status */
221: #define UNIT_REQUEUE 0x04 /* requeue after response */
222:
223: /*
224: * Handle a command ring transition: wake up sleepers for command packets.
225: * This is too simple to bother with a function call.
226: */
227: #define MSCP_DOCMD(mi) { \
228: if ((mi)->mi_wantcmd) { \
229: (mi)->mi_wantcmd = 0; \
230: wakeup((caddr_t) &(mi)->mi_wantcmd); \
231: } \
232: }
233:
234: /* Prototypes */
235: struct mscp *mscp_getcp(struct mscp_softc *, int);
236: void mscp_printevent(struct mscp *);
237: void mscp_go(struct mscp_softc *, struct mscp *, int);
238: void mscp_requeue(struct mscp_softc *);
239: void mscp_dorsp(struct mscp_softc *);
240: int mscp_decodeerror(char *, struct mscp *, struct mscp_softc *);
241: int mscp_print(void *, const char *);
242: void mscp_hexdump(struct mscp *);
243: void mscp_strategy(struct buf *, struct device *);
244: void mscp_printtype(int, int);
245: int mscp_waitstep(struct mscp_softc *, int, int);
246: void mscp_dgo(struct mscp_softc *, struct mscp_xi *);
247: void mscp_intr(struct mscp_softc *);
CVSweb