mbavar.h revision 1.3 1 /* $NetBSD: mbavar.h,v 1.3 1996/02/24 21:23:00 ragge Exp $ */
2 /*
3 * Copyright (c) 1994 Ludd, University of Lule}, Sweden
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed at Ludd, University of Lule}.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/device.h>
33
34 #define MBCR_INIT 1
35 #define MBCR_IE (1<<2)
36 #define MBDS_DPR (1<<8)
37 #define MBSR_NED (1<<18)
38 #define MBDT_MOH (1<<13)
39 #define MBDT_TYPE 511
40 #define MBDT_TAP (1<<14)
41
42 #define CLOSED 0
43 #define WANTOPEN 1
44 #define RDLABEL 2
45 #define OPEN 3
46 #define OPENRAW 4
47
48 #define MAXMBADEV 8 /* Max units per MBA */
49
50 /*
51 * Devices that have different device drivers.
52 */
53 enum mb_devices {
54 MB_RP, /* RM/RP disk */
55 MB_TU, /* TM03 based tape, ex. TU45 or TU77 */
56 MB_MT /* TU78 tape */
57 };
58
59 /*
60 * Current state of the adapter.
61 */
62 enum sc_state {
63 SC_AUTOCONF,
64 SC_ACTIVE,
65 SC_IDLE
66 };
67
68 /*
69 * Return value after a finished data transfer, from device driver.
70 */
71 enum xfer_action {
72 XFER_RESTART,
73 XFER_ERROR,
74 XFER_FINISH
75 };
76
77 /*
78 * Info passed do unit device driver during autoconfig.
79 */
80 struct mba_attach_args {
81 int unit;
82 int type;
83 char *name;
84 enum mb_devices devtyp;
85 };
86
87 /*
88 * Common struct used to communicate between the mba device driver
89 * and the unit device driver.
90 */
91 struct mba_device {
92 struct mba_device *md_back; /* linked list of runnable devices */
93 /* Start routine to be called by mbastart. */
94 void (*md_start) __P((struct mba_device *));
95 /* Routine to be called after attn intr */
96 int (*md_attn)__P((struct mba_device *));
97 /* Call after xfer finish */
98 enum xfer_action (*md_finish) __P((struct mba_device *, int, int *));
99 void *md_softc; /* Backpointer to this units softc. */
100 struct mba_softc *md_mba;
101 struct buf md_q; /* Buffer head for transfers */
102 };
103
104 struct mba_softc {
105 struct device sc_dev;
106 struct ivec_dsp sc_dsp; /* Interrupt catch routine */
107 struct mba_regs *sc_mbareg;
108 struct mba_device *sc_first, *sc_last;
109 enum sc_state sc_state;
110 int sc_physnr; /* Physical number of this mba */
111 struct mba_device *sc_md[MAXMBADEV];
112 };
113
114 struct mbaunit {
115 int nr;
116 char *name;
117 enum mb_devices devtyp;
118 };
119
120