Home | History | Annotate | Line # | Download | only in mba
mbavar.h revision 1.13.58.1
      1  1.13.58.1  skrll /*	$NetBSD: mbavar.h,v 1.13.58.1 2017/08/28 17:51:55 skrll Exp $ */
      2        1.1  ragge /*
      3        1.1  ragge  * Copyright (c) 1994 Ludd, University of Lule}, Sweden
      4        1.1  ragge  * All rights reserved.
      5        1.1  ragge  *
      6        1.1  ragge  * Redistribution and use in source and binary forms, with or without
      7        1.1  ragge  * modification, are permitted provided that the following conditions
      8        1.1  ragge  * are met:
      9        1.1  ragge  * 1. Redistributions of source code must retain the above copyright
     10        1.1  ragge  *    notice, this list of conditions and the following disclaimer.
     11        1.1  ragge  * 2. Redistributions in binary form must reproduce the above copyright
     12        1.1  ragge  *    notice, this list of conditions and the following disclaimer in the
     13        1.1  ragge  *    documentation and/or other materials provided with the distribution.
     14        1.1  ragge  *
     15        1.1  ragge  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16        1.1  ragge  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17        1.1  ragge  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18        1.1  ragge  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19        1.1  ragge  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20        1.1  ragge  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21        1.1  ragge  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22        1.1  ragge  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23        1.1  ragge  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24        1.1  ragge  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25        1.1  ragge  */
     26        1.1  ragge 
     27        1.2  ragge #include <sys/device.h>
     28        1.6   matt #include <machine/scb.h>
     29        1.1  ragge 
     30        1.1  ragge #define MBCR_INIT	1
     31        1.1  ragge #define	MBCR_IE		(1<<2)
     32        1.1  ragge #define	MBDS_DPR	(1<<8)
     33        1.1  ragge #define	MBSR_NED	(1<<18)
     34        1.1  ragge #define	MBDT_MOH	(1<<13)
     35        1.1  ragge #define	MBDT_TYPE	511
     36        1.1  ragge #define MBDT_TAP	(1<<14)
     37        1.1  ragge 
     38        1.1  ragge #define	CLOSED		0
     39        1.1  ragge #define	WANTOPEN	1
     40        1.1  ragge #define	RDLABEL		2
     41        1.1  ragge #define	OPEN		3
     42        1.1  ragge #define	OPENRAW		4
     43        1.1  ragge 
     44        1.2  ragge #define	MAXMBADEV	8	/* Max units per MBA */
     45        1.2  ragge 
     46        1.2  ragge /*
     47        1.2  ragge  * Devices that have different device drivers.
     48        1.2  ragge  */
     49        1.2  ragge enum	mb_devices {
     50       1.13   hans 	MB_UK,	/* unknown */
     51        1.2  ragge 	MB_RP,	/* RM/RP disk */
     52        1.2  ragge 	MB_TU,	/* TM03 based tape, ex. TU45 or TU77 */
     53        1.2  ragge 	MB_MT	/* TU78 tape */
     54        1.1  ragge };
     55        1.2  ragge 
     56        1.2  ragge /*
     57        1.2  ragge  * Current state of the adapter.
     58        1.2  ragge  */
     59        1.2  ragge enum    sc_state {
     60        1.2  ragge 	SC_AUTOCONF,
     61        1.2  ragge 	SC_ACTIVE,
     62        1.2  ragge 	SC_IDLE
     63        1.2  ragge };
     64        1.2  ragge 
     65        1.2  ragge /*
     66        1.2  ragge  * Return value after a finished data transfer, from device driver.
     67        1.2  ragge  */
     68        1.2  ragge enum	xfer_action {
     69        1.2  ragge 	XFER_RESTART,
     70        1.2  ragge 	XFER_FINISH
     71        1.2  ragge };
     72        1.2  ragge 
     73        1.2  ragge /*
     74        1.2  ragge  * Info passed do unit device driver during autoconfig.
     75        1.2  ragge  */
     76        1.2  ragge struct	mba_attach_args {
     77        1.7  ragge 	int	ma_unit;
     78        1.7  ragge         int	ma_type;
     79        1.9  ragge 	const char	*ma_name;
     80        1.7  ragge 	enum	mb_devices ma_devtyp;
     81        1.7  ragge 	bus_space_tag_t ma_iot;
     82        1.7  ragge 	bus_space_handle_t ma_ioh;
     83        1.2  ragge };
     84        1.2  ragge 
     85        1.2  ragge /*
     86        1.2  ragge  * Common struct used to communicate between the mba device driver
     87        1.2  ragge  * and the unit device driver.
     88        1.2  ragge  */
     89        1.2  ragge struct	mba_device {
     90       1.12   matt 	STAILQ_ENTRY(mba_device) md_link; /* linked list of runnable devices */
     91       1.12   matt 	void (*md_start)(struct mba_device *);
     92       1.12   matt 				/* Start routine to be called by mbastart. */
     93       1.12   matt 	int (*md_attn)(struct mba_device *);
     94       1.12   matt 				/* Routine to be called after attn intr */
     95       1.12   matt 	enum xfer_action (*md_finish)(struct mba_device *, int, int *);
     96       1.12   matt 				/* Call after xfer finish */
     97       1.12   matt 	void *md_softc;		/* Backpointer to this units softc. */
     98       1.12   matt 	struct mba_softc *md_mba;
     99       1.12   matt 	struct bufq_state *md_q;	/* queue of I/O requests */
    100        1.2  ragge };
    101        1.2  ragge 
    102        1.2  ragge struct	mba_softc {
    103       1.12   matt 	device_t sc_dev;
    104        1.7  ragge 	bus_space_tag_t sc_iot;
    105        1.7  ragge 	bus_space_handle_t sc_ioh;
    106       1.12   matt 	STAILQ_HEAD(,mba_device) sc_xfers;
    107       1.12   matt 	struct evcnt sc_intrcnt;
    108       1.12   matt 	enum sc_state sc_state;
    109       1.12   matt 	struct mba_device *sc_md[MAXMBADEV];
    110        1.2  ragge };
    111        1.2  ragge 
    112        1.2  ragge struct  mbaunit {
    113        1.2  ragge 	int     nr;
    114        1.9  ragge 	const char    *name;
    115        1.2  ragge 	enum	mb_devices devtyp;
    116        1.2  ragge };
    117        1.4  ragge 
    118        1.4  ragge /* Common prototypes */
    119        1.7  ragge void	mbaqueue(struct mba_device *);
    120        1.2  ragge 
    121