hpibvar.h revision 1.12 1 /* $NetBSD: hpibvar.h,v 1.12 1997/07/18 03:38:36 jtk Exp $ */
2
3 /*
4 * Copyright (c) 1996, 1997 Jason R. Thorpe. All rights reserved.
5 * Copyright (c) 1982, 1990, 1993
6 * The Regents of the University of California. 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 the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)hpibvar.h 8.1 (Berkeley) 6/10/93
37 */
38
39 #include <sys/queue.h>
40
41 #define HPIB_IPL(x) ((((x) >> 4) & 0x3) + 3)
42
43 #define HPIBA 32
44 #define HPIBB 1
45 #define HPIBC 8
46 #define HPIBA_BA 21
47 #define HPIBC_BA 30
48 #define HPIBA_IPL 3
49
50 #define CSA_BA 0x1F
51
52 #define IDS_WDMA 0x04
53 #define IDS_WRITE 0x08
54 #define IDS_IR 0x40
55 #define IDS_IE 0x80
56 #define IDS_DMA(x) (1 << (x))
57
58 #define C_SDC 0x04 /* Selected device clear */
59 #define C_SDC_P 0x04 /* with odd parity */
60 #define C_DCL 0x14 /* Universal device clear */
61 #define C_DCL_P 0x94 /* with odd parity */
62 #define C_LAG 0x20 /* Listener address group commands */
63 #define C_UNL 0x3f /* Universal unlisten */
64 #define C_UNL_P 0xbf /* with odd parity */
65 #define C_TAG 0x40 /* Talker address group commands */
66 #define C_UNA 0x5e /* Unaddress (master talk address?) */
67 #define C_UNA_P 0x5e /* with odd parity */
68 #define C_UNT 0x5f /* Universal untalk */
69 #define C_UNT_P 0xdf /* with odd parity */
70 #define C_SCG 0x60 /* Secondary group commands */
71
72 struct hpibbus_softc;
73
74 /*
75 * Each of the HP-IB controller drivers fills in this structure, which
76 * is used by the indirect driver to call controller-specific functions.
77 */
78 struct hpib_controller {
79 void (*hpib_reset) __P((struct hpibbus_softc *));
80 int (*hpib_send) __P((struct hpibbus_softc *,
81 int, int, void *, int));
82 int (*hpib_recv) __P((struct hpibbus_softc *,
83 int, int, void *, int));
84 int (*hpib_ppoll) __P((struct hpibbus_softc *));
85 void (*hpib_ppwatch) __P((void *));
86 void (*hpib_go) __P((struct hpibbus_softc *,
87 int, int, void *, int, int, int));
88 void (*hpib_done) __P((struct hpibbus_softc *));
89 int (*hpib_intr) __P((void *));
90 };
91
92 /*
93 * Attach an HP-IB bus to an HP-IB controller.
94 */
95 struct hpibdev_attach_args {
96 struct hpib_controller *ha_ops; /* controller ops vector */
97 int ha_type; /* XXX */
98 int ha_ba;
99 struct hpibbus_softc **ha_softcpp; /* XXX */
100 };
101
102 /*
103 * Attach an HP-IB device to an HP-IB bus.
104 */
105 struct hpibbus_attach_args {
106 u_int16_t ha_id; /* device id */
107 int ha_slave; /* HP-IB bus slave */
108 int ha_punit; /* physical unit on slave */
109 };
110
111 /* Locator short-hand */
112 #include "locators.h"
113
114 #define hpibbuscf_slave cf_loc[HPIBBUSCF_SLAVE]
115 #define hpibbuscf_punit cf_loc[HPIBBUSCF_PUNIT]
116
117 #define HPIB_NSLAVES 8 /* number of slaves on a bus */
118 #define HPIB_NPUNITS 2 /* number of punits per slave */
119
120 /*
121 * An HP-IB job queue entry. Slave drivers have one of these used
122 * to queue requests with the controller.
123 */
124 struct hpibqueue {
125 TAILQ_ENTRY(hpibqueue) hq_list; /* entry on queue */
126 void *hq_softc; /* slave's softc */
127 int hq_slave; /* slave on bus */
128
129 /*
130 * Callbacks used to start and stop the slave driver.
131 */
132 void (*hq_start) __P((void *));
133 void (*hq_go) __P((void *));
134 void (*hq_intr) __P((void *));
135 };
136
137 struct dmaqueue;
138
139 /*
140 * Software state per HP-IB bus.
141 */
142 struct hpibbus_softc {
143 struct device sc_dev; /* generic device glue */
144 struct hpib_controller *sc_ops; /* controller ops vector */
145 volatile int sc_flags; /* misc flags */
146 struct dmaqueue *sc_dq;
147 TAILQ_HEAD(, hpibqueue) sc_queue;
148 int sc_ba;
149 int sc_type;
150 char *sc_addr;
151 int sc_count;
152 int sc_curcnt;
153
154 /*
155 * HP-IB is an indirect bus; this cheezy resource map
156 * keeps track of slave/punit allocations.
157 */
158 char sc_rmap[HPIB_NSLAVES][HPIB_NPUNITS];
159 };
160
161 /* sc_flags */
162 #define HPIBF_IO 0x1
163 #define HPIBF_DONE 0x2
164 #define HPIBF_PPOLL 0x4
165 #define HPIBF_READ 0x8
166 #define HPIBF_TIMO 0x10
167 #define HPIBF_DMA16 0x8000
168
169 #ifdef _KERNEL
170 extern caddr_t internalhpib;
171 extern int hpibtimeout;
172 extern int hpibdmathresh;
173
174 void hpibreset __P((int));
175 int hpibsend __P((int, int, int, void *, int));
176 int hpibrecv __P((int, int, int, void *, int));
177 int hpibustart __P((int));
178 void hpibstart __P((void *));
179 void hpibgo __P((int, int, int, void *, int, int, int));
180 void hpibdone __P((void *));
181 int hpibpptest __P((int, int));
182 void hpibppclear __P((int));
183 void hpibawait __P((int));
184 int hpibswait __P((int, int));
185 int hpibid __P((int, int));
186
187 int hpibreq __P((struct device *, struct hpibqueue *));
188 void hpibfree __P((struct device *, struct hpibqueue *));
189 int hpibbus_alloc __P((struct hpibbus_softc *, int, int));
190 void hpibbus_free __P((struct hpibbus_softc *, int, int));
191
192 int hpibintr __P((void *));
193 int hpibdevprint __P((void *, const char *));
194 #endif
195