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