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