hpibvar.h revision 1.21.54.1 1 /* $NetBSD: hpibvar.h,v 1.21.54.1 2021/08/01 22:42:08 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
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 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * Copyright (c) 1982, 1990, 1993
34 * The Regents of the University of California. All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)hpibvar.h 8.1 (Berkeley) 6/10/93
61 */
62
63 #define HPIB_IPL(x) ((((x) >> 4) & 0x3) + 3)
64
65 #define HPIBA 32
66 #define HPIBB 1
67 #define HPIBC 8
68 #define HPIBA_BA 21
69 #define HPIBC_BA 30
70 #define HPIBA_IPL 3
71
72 #define CSA_BA 0x1F
73
74 #define IDS_WDMA 0x04
75 #define IDS_WRITE 0x08
76 #define IDS_IR 0x40
77 #define IDS_IE 0x80
78 #define IDS_DMA(x) (1 << (x))
79
80 #define C_SDC 0x04 /* Selected device clear */
81 #define C_SDC_P 0x04 /* with odd parity */
82 #define C_DCL 0x14 /* Universal device clear */
83 #define C_DCL_P 0x94 /* with odd parity */
84 #define C_LAG 0x20 /* Listener address group commands */
85 #define C_UNL 0x3f /* Universal unlisten */
86 #define C_UNL_P 0xbf /* with odd parity */
87 #define C_TAG 0x40 /* Talker address group commands */
88 #define C_UNA 0x5e /* Unaddress (master talk address?) */
89 #define C_UNA_P 0x5e /* with odd parity */
90 #define C_UNT 0x5f /* Universal untalk */
91 #define C_UNT_P 0xdf /* with odd parity */
92 #define C_SCG 0x60 /* Secondary group commands */
93
94 /*
95 * Description structure for CS/80 devices.
96 */
97 struct cs80_describe {
98 u_int d_iuw:16, /* controller: installed unit word */
99 d_cmaxxfr:16, /* controller: max transfer rate (Kb) */
100 d_ctype:8, /* controller: controller type */
101 d_utype:8, /* unit: unit type */
102 d_name:24, /* unit: name (6 BCD digits) */
103 d_sectsize:16, /* unit: # of bytes per block (sector) */
104 d_blkbuf:8, /* unit: # of blocks which can be buffered */
105 d_burstsize:8, /* unit: recommended burst size */
106 d_blocktime:16, /* unit: block time (u-sec) */
107 d_uavexfr:16, /* unit: average transfer rate (Kb) */
108 d_retry:16, /* unit: optimal retry time (1/100-sec) */
109 d_access:16, /* unit: access time param (1/100-sec) */
110 d_maxint:8, /* unit: maximum interleave */
111 d_fvbyte:8, /* unit: fixed volume byte */
112 d_rvbyte:8, /* unit: removable volume byte */
113 d_maxcyl:24, /* volume: maximum cylinder */
114 d_maxhead:8, /* volume: maximum head */
115 d_maxsect:16, /* volume: maximum sector on track */
116 d_maxvsecth:16, /* volume: maximum sector on volume (MSW) */
117 d_maxvsectl:32, /* volume: maximum sector on volume (LSWs) */
118 d_interleave:8; /* volume: current interleave */
119 } __attribute__((__packed__));
120
121 #ifdef _KERNEL
122 #include <sys/queue.h>
123
124 struct hpibbus_softc;
125
126 /*
127 * Each of the HP-IB controller drivers fills in this structure, which
128 * is used by the indirect driver to call controller-specific functions.
129 */
130 struct hpib_controller {
131 void (*hpib_reset)(struct hpibbus_softc *);
132 int (*hpib_send)(struct hpibbus_softc *,
133 int, int, void *, int);
134 int (*hpib_recv)(struct hpibbus_softc *,
135 int, int, void *, int);
136 int (*hpib_ppoll)(struct hpibbus_softc *);
137 void (*hpib_ppwatch)(void *);
138 void (*hpib_go)(struct hpibbus_softc *,
139 int, int, void *, int, int, int);
140 void (*hpib_done)(struct hpibbus_softc *);
141 int (*hpib_intr)(void *);
142 };
143
144 /*
145 * Attach an HP-IB bus to an HP-IB controller.
146 */
147 struct hpibdev_attach_args {
148 struct hpib_controller *ha_ops; /* controller ops vector */
149 int ha_type; /* XXX */
150 int ha_ba;
151 struct hpibbus_softc **ha_softcpp; /* XXX */
152 };
153
154 /*
155 * Attach an HP-IB device to an HP-IB bus.
156 */
157 struct hpibbus_attach_args {
158 uint16_t ha_id; /* device id */
159 int ha_slave; /* HP-IB bus slave */
160 int ha_punit; /* physical unit on slave */
161 };
162
163 /* Locator short-hand */
164 #include "locators.h"
165
166 #define hpibbuscf_slave cf_loc[HPIBBUSCF_SLAVE]
167 #define hpibbuscf_punit cf_loc[HPIBBUSCF_PUNIT]
168
169 #define HPIB_NSLAVES 8 /* number of slaves on a bus */
170 #define HPIB_NPUNITS 15 /* number of punits per slave */
171
172 /*
173 * An HP-IB job queue entry. Slave drivers have one of these used
174 * to queue requests with the controller.
175 */
176 struct hpibqueue {
177 TAILQ_ENTRY(hpibqueue) hq_list; /* entry on queue */
178 void *hq_softc; /* slave's softc */
179 int hq_slave; /* slave on bus */
180
181 /*
182 * Callbacks used to start and stop the slave driver.
183 */
184 void (*hq_start)(void *);
185 void (*hq_go)(void *);
186 void (*hq_intr)(void *);
187 };
188
189 struct dmaqueue;
190
191 /*
192 * Software state per HP-IB bus.
193 */
194 struct hpibbus_softc {
195 device_t sc_dev; /* generic device glue */
196 struct hpib_controller *sc_ops; /* controller ops vector */
197 volatile int sc_flags; /* misc flags */
198 struct dmaqueue *sc_dq;
199 TAILQ_HEAD(, hpibqueue) sc_queue;
200 int sc_ba;
201 int sc_type;
202 char *sc_addr;
203 int sc_count;
204 int sc_curcnt;
205 };
206
207 /* sc_flags */
208 #define HPIBF_IO 0x1
209 #define HPIBF_DONE 0x2
210 #define HPIBF_PPOLL 0x4
211 #define HPIBF_READ 0x8
212 #define HPIBF_TIMO 0x10
213 #define HPIBF_DMA16 0x8000
214
215 extern void *internalhpib;
216 extern int hpibtimeout;
217 extern int hpibdmathresh;
218
219 void hpibreset(int);
220 int hpibsend(int, int, int, void *, int);
221 int hpibrecv(int, int, int, void *, int);
222 int hpibustart(int);
223 void hpibgo(int, int, int, void *, int, int, int);
224 int hpibpptest(int, int);
225 void hpibppclear(int);
226 void hpibawait(int);
227 int hpibswait(int, int);
228 int hpibid(int, int);
229
230 int hpibreq(device_t, struct hpibqueue *);
231 void hpibfree(device_t, struct hpibqueue *);
232
233 int hpibintr(void *);
234 int hpibdevprint(void *, const char *);
235 #endif
236