Home | History | Annotate | Line # | Download | only in ic
mb89352var.h revision 1.10.70.2
      1  1.10.70.1       mjf /*	$NetBSD: mb89352var.h,v 1.10.70.2 2008/06/02 13:23:24 mjf Exp $	*/
      2        1.1   minoura /*	NecBSD: mb89352var.h,v 1.4 1998/03/14 07:31:22 kmatsuda Exp 	*/
      3        1.1   minoura 
      4        1.1   minoura /*-
      5  1.10.70.2       mjf  * Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
      6        1.1   minoura  * All rights reserved.
      7        1.1   minoura  *
      8        1.1   minoura  * This code is derived from software contributed to The NetBSD Foundation
      9        1.1   minoura  * by Charles M. Hannum, Masaru Oki and Kouichi Matsuda.
     10        1.1   minoura  *
     11        1.1   minoura  * Redistribution and use in source and binary forms, with or without
     12        1.1   minoura  * modification, are permitted provided that the following conditions
     13        1.1   minoura  * are met:
     14        1.1   minoura  * 1. Redistributions of source code must retain the above copyright
     15        1.1   minoura  *    notice, this list of conditions and the following disclaimer.
     16        1.1   minoura  * 2. Redistributions in binary form must reproduce the above copyright
     17        1.1   minoura  *    notice, this list of conditions and the following disclaimer in the
     18        1.1   minoura  *    documentation and/or other materials provided with the distribution.
     19  1.10.70.2       mjf  *
     20  1.10.70.2       mjf  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  1.10.70.2       mjf  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  1.10.70.2       mjf  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  1.10.70.2       mjf  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  1.10.70.2       mjf  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  1.10.70.2       mjf  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  1.10.70.2       mjf  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  1.10.70.2       mjf  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  1.10.70.2       mjf  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  1.10.70.2       mjf  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  1.10.70.2       mjf  * POSSIBILITY OF SUCH DAMAGE.
     31        1.1   minoura  *
     32        1.1   minoura  * Copyright (c) 1994 Jarle Greipsland
     33        1.1   minoura  * All rights reserved.
     34        1.1   minoura  *
     35        1.1   minoura  * Redistribution and use in source and binary forms, with or without
     36        1.1   minoura  * modification, are permitted provided that the following conditions
     37        1.1   minoura  * are met:
     38        1.1   minoura  * 1. Redistributions of source code must retain the above copyright
     39        1.1   minoura  *    notice, this list of conditions and the following disclaimer.
     40        1.1   minoura  * 2. Redistributions in binary form must reproduce the above copyright
     41        1.1   minoura  *    notice, this list of conditions and the following disclaimer in the
     42        1.1   minoura  *    documentation and/or other materials provided with the distribution.
     43        1.1   minoura  * 3. The name of the author may not be used to endorse or promote products
     44        1.1   minoura  *    derived from this software without specific prior written permission.
     45        1.1   minoura  *
     46        1.1   minoura  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     47        1.1   minoura  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     48        1.1   minoura  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     49        1.1   minoura  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     50        1.1   minoura  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     51        1.1   minoura  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     52        1.1   minoura  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     53        1.1   minoura  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     54        1.1   minoura  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     55        1.1   minoura  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     56        1.1   minoura  * POSSIBILITY OF SUCH DAMAGE.
     57        1.1   minoura  */
     58        1.1   minoura /*
     59        1.1   minoura  * [NetBSD for NEC PC-98 series]
     60        1.1   minoura  *  Copyright (c) 1996, 1997, 1998
     61        1.1   minoura  *	NetBSD/pc98 porting staff. All rights reserved.
     62        1.1   minoura  *  Copyright (c) 1996, 1997, 1998
     63        1.1   minoura  *	Kouich Matsuda. All rights reserved.
     64        1.1   minoura  */
     65        1.1   minoura 
     66        1.1   minoura #ifndef	_MB89352VAR_H_
     67        1.1   minoura #define	_MB89352VAR_H_
     68        1.1   minoura /*
     69        1.1   minoura  * ACB. Holds additional information for each SCSI command Comments: We
     70        1.1   minoura  * need a separate scsi command block because we may need to overwrite it
     71        1.1   minoura  * with a request sense command.  Basicly, we refrain from fiddling with
     72        1.1   minoura  * the scsi_xfer struct (except do the expected updating of return values).
     73        1.1   minoura  * We'll generally update: xs->{flags,resid,error,sense,status} and
     74        1.1   minoura  * occasionally xs->retries.
     75        1.1   minoura  */
     76        1.1   minoura struct spc_acb {
     77        1.9   thorpej 	struct scsipi_generic scsipi_cmd;
     78        1.1   minoura 	int scsipi_cmd_length;
     79  1.10.70.1       mjf 	uint8_t *data_addr;		/* Saved data pointer */
     80        1.1   minoura 	int data_length;		/* Residue */
     81        1.1   minoura 
     82  1.10.70.1       mjf 	uint8_t target_stat;		/* SCSI status byte */
     83        1.1   minoura 
     84        1.1   minoura #ifdef notdef
     85        1.1   minoura 	struct spc_dma_seg dma[SPC_NSEG]; /* Physical addresses+len */
     86        1.1   minoura #endif
     87        1.1   minoura 
     88        1.1   minoura 	TAILQ_ENTRY(spc_acb) chain;
     89        1.1   minoura 	struct scsipi_xfer *xs;	/* SCSI xfer ctrl block from above */
     90  1.10.70.1       mjf 	u_int flags;
     91        1.1   minoura #define ACB_ALLOC	0x01
     92        1.6   tsutsui #define ACB_NEXUS	0x02
     93        1.1   minoura #define ACB_SENSE	0x04
     94        1.6   tsutsui #define ACB_ABORT	0x40
     95        1.6   tsutsui #define ACB_RESET	0x80
     96        1.1   minoura 	int timeout;
     97        1.1   minoura };
     98        1.1   minoura 
     99        1.1   minoura /*
    100        1.1   minoura  * Some info about each (possible) target on the SCSI bus.  This should
    101        1.1   minoura  * probably have been a "per target+lunit" structure, but we'll leave it at
    102        1.1   minoura  * this for now.
    103        1.1   minoura  */
    104        1.1   minoura struct spc_tinfo {
    105        1.1   minoura 	int	cmds;		/* #commands processed */
    106        1.1   minoura 	int	dconns;		/* #disconnects */
    107        1.1   minoura 	int	touts;		/* #timeouts */
    108        1.1   minoura 	int	perrs;		/* #parity errors */
    109        1.1   minoura 	int	senses;		/* #request sense commands sent */
    110        1.1   minoura 	ushort	lubusy;		/* What local units/subr. are busy? */
    111        1.1   minoura 	u_char  flags;
    112        1.1   minoura #define DO_SYNC		0x01	/* (Re)Negotiate synchronous options */
    113        1.6   tsutsui #define DO_WIDE		0x02	/* (Re)Negotiate wide options */
    114  1.10.70.1       mjf 	uint8_t period;		/* Period suggestion */
    115  1.10.70.1       mjf 	uint8_t offset;		/* Offset suggestion */
    116  1.10.70.1       mjf 	uint8_t width;		/* Width suggestion */
    117        1.2  nisimura };
    118        1.1   minoura 
    119        1.1   minoura struct spc_softc {
    120  1.10.70.1       mjf 	device_t sc_dev;
    121        1.1   minoura 
    122        1.1   minoura 	bus_space_tag_t sc_iot;
    123        1.1   minoura 	bus_space_handle_t sc_ioh;
    124        1.1   minoura 
    125        1.3    bouyer 	struct scsipi_channel sc_channel; /* prototype for subdevs */
    126        1.1   minoura 	struct scsipi_adapter sc_adapter;
    127        1.1   minoura 
    128        1.1   minoura 	TAILQ_HEAD(, spc_acb) free_list, ready_list, nexus_list;
    129        1.1   minoura 	struct spc_acb *sc_nexus;	/* current command */
    130        1.1   minoura 	struct spc_acb sc_acb[8];
    131        1.1   minoura 	struct spc_tinfo sc_tinfo[8];
    132        1.1   minoura 
    133        1.1   minoura 	/* Data about the current nexus (updated for every cmd switch) */
    134  1.10.70.1       mjf 	uint8_t	*sc_dp;		/* Current data pointer */
    135        1.1   minoura 	size_t	sc_dleft;	/* Data bytes left to transfer */
    136  1.10.70.1       mjf 	uint8_t	*sc_cp;		/* Current command pointer */
    137        1.1   minoura 	size_t	sc_cleft;	/* Command bytes left to transfer */
    138        1.1   minoura 
    139        1.1   minoura 	/* Adapter state */
    140  1.10.70.1       mjf 	uint8_t	 sc_phase;	/* Current bus phase */
    141  1.10.70.1       mjf 	uint8_t	 sc_prevphase;	/* Previous bus phase */
    142  1.10.70.1       mjf 	uint8_t	 sc_state;	/* State applicable to the adapter */
    143        1.6   tsutsui #define SPC_INIT	0
    144        1.1   minoura #define SPC_IDLE	1
    145        1.1   minoura #define SPC_SELECTING	2	/* SCSI command is arbiting  */
    146        1.1   minoura #define SPC_RESELECTED	3	/* Has been reselected */
    147        1.1   minoura #define SPC_CONNECTED	4	/* Actively using the SCSI bus */
    148        1.6   tsutsui #define SPC_DISCONNECT	5	/* MSG_DISCONNECT received */
    149        1.6   tsutsui #define SPC_CMDCOMPLETE	6	/* MSG_CMDCOMPLETE received */
    150        1.1   minoura #define SPC_CLEANING	7
    151  1.10.70.1       mjf 	uint8_t	 sc_flags;
    152        1.1   minoura #define SPC_DROP_MSGIN	0x01	/* Discard all msgs (parity err detected) */
    153        1.6   tsutsui #define SPC_ABORTING	0x02	/* Bailing out */
    154        1.5   tsutsui #define SPC_DOINGDMA	0x04	/* doing DMA */
    155        1.1   minoura #define SPC_INACTIVE	0x80	/* The FIFO data path is active! */
    156  1.10.70.1       mjf 	uint8_t	sc_selid;	/* Reselection ID */
    157        1.7   mycroft 	struct device *sc_child;/* Our child */
    158        1.1   minoura 
    159        1.1   minoura 	/* Message stuff */
    160  1.10.70.1       mjf 	uint8_t	sc_msgpriq;	/* Messages we want to send */
    161  1.10.70.1       mjf 	uint8_t	sc_msgoutq;	/* Messages sent during last MESSAGE OUT */
    162  1.10.70.1       mjf 	uint8_t	sc_lastmsg;	/* Message last transmitted */
    163  1.10.70.1       mjf 	uint8_t	sc_currmsg;	/* Message currently ready to transmit */
    164        1.1   minoura #define SEND_DEV_RESET		0x01
    165        1.1   minoura #define SEND_PARITY_ERROR	0x02
    166        1.1   minoura #define SEND_INIT_DET_ERR	0x04
    167        1.1   minoura #define SEND_REJECT		0x08
    168        1.1   minoura #define SEND_IDENTIFY		0x10
    169        1.1   minoura #define SEND_ABORT		0x20
    170        1.1   minoura #define SEND_SDTR		0x40
    171        1.6   tsutsui #define SEND_WDTR		0x80
    172        1.1   minoura #define SPC_MAX_MSG_LEN 8
    173  1.10.70.1       mjf 	uint8_t	sc_omess[SPC_MAX_MSG_LEN];
    174  1.10.70.1       mjf 	uint8_t	*sc_omp;		/* Outgoing message pointer */
    175  1.10.70.1       mjf 	uint8_t	sc_imess[SPC_MAX_MSG_LEN];
    176  1.10.70.1       mjf 	uint8_t	*sc_imp;		/* Incoming message pointer */
    177        1.1   minoura 
    178        1.1   minoura 	/* Hardware stuff */
    179        1.1   minoura 	int	sc_initiator;		/* Our scsi id */
    180        1.1   minoura 	int	sc_freq;		/* Clock frequency in MHz */
    181        1.1   minoura 	int	sc_minsync;		/* Minimum sync period / 4 */
    182        1.1   minoura 	int	sc_maxsync;		/* Maximum sync period / 4 */
    183        1.5   tsutsui 
    184        1.5   tsutsui 	/* DMA function set from MD code */
    185        1.5   tsutsui 	void (*sc_dma_start)(struct spc_softc *, void *, size_t, int);
    186        1.5   tsutsui 	void (*sc_dma_done)(struct spc_softc *);
    187        1.1   minoura };
    188        1.1   minoura 
    189        1.1   minoura #if SPC_DEBUG
    190        1.1   minoura #define SPC_SHOWACBS	0x01
    191        1.1   minoura #define SPC_SHOWINTS	0x02
    192        1.1   minoura #define SPC_SHOWCMDS	0x04
    193        1.1   minoura #define SPC_SHOWMISC	0x08
    194        1.1   minoura #define SPC_SHOWTRACE	0x10
    195        1.1   minoura #define SPC_SHOWSTART	0x20
    196        1.1   minoura #define SPC_DOBREAK	0x40
    197        1.1   minoura extern int spc_debug; /* SPC_SHOWSTART|SPC_SHOWMISC|SPC_SHOWTRACE; */
    198  1.10.70.1       mjf #define SPC_PRINT(b, s)							\
    199  1.10.70.1       mjf 	do {								\
    200  1.10.70.1       mjf 		if ((spc_debug & (b)) != 0)				\
    201  1.10.70.1       mjf 			printf s;					\
    202  1.10.70.1       mjf 	} while (/* CONSTCOND */ 0)
    203  1.10.70.1       mjf #define SPC_BREAK()							\
    204  1.10.70.1       mjf 	do {								\
    205  1.10.70.1       mjf 		if ((spc_debug & SPC_DOBREAK) != 0)			\
    206  1.10.70.1       mjf 			Debugger();					\
    207  1.10.70.1       mjf 	} while (/* CONSTCOND */ 0)
    208  1.10.70.1       mjf #define SPC_ASSERT(x)							\
    209  1.10.70.1       mjf 	do {								\
    210  1.10.70.1       mjf 		if (x) {						\
    211  1.10.70.1       mjf 			;						\
    212  1.10.70.1       mjf 		} else {						\
    213  1.10.70.1       mjf 			printf("%s at line %d: assertion failed\n",	\
    214  1.10.70.1       mjf 			    device_xname(sc->sc_dev), __LINE__);	\
    215  1.10.70.1       mjf 			Debugger();					\
    216  1.10.70.1       mjf 		}							\
    217  1.10.70.1       mjf 	} while (/* CONSTCOND */ 0)
    218        1.1   minoura #else
    219        1.6   tsutsui #define SPC_PRINT(b, s)
    220        1.6   tsutsui #define SPC_BREAK()
    221        1.6   tsutsui #define SPC_ASSERT(x)
    222        1.1   minoura #endif
    223        1.1   minoura 
    224        1.1   minoura #define SPC_ACBS(s)	SPC_PRINT(SPC_SHOWACBS, s)
    225        1.1   minoura #define SPC_INTS(s)	SPC_PRINT(SPC_SHOWINTS, s)
    226        1.1   minoura #define SPC_CMDS(s)	SPC_PRINT(SPC_SHOWCMDS, s)
    227        1.1   minoura #define SPC_MISC(s)	SPC_PRINT(SPC_SHOWMISC, s)
    228        1.1   minoura #define SPC_TRACE(s)	SPC_PRINT(SPC_SHOWTRACE, s)
    229        1.1   minoura #define SPC_START(s)	SPC_PRINT(SPC_SHOWSTART, s)
    230        1.1   minoura 
    231        1.8   tsutsui void	spc_attach(struct spc_softc *);
    232  1.10.70.1       mjf int	spc_activate(device_t, enum devact);
    233  1.10.70.1       mjf int	spc_detach(device_t, int);
    234        1.8   tsutsui int	spc_intr(void *);
    235        1.8   tsutsui int	spc_find(bus_space_tag_t, bus_space_handle_t, int);
    236        1.8   tsutsui void	spc_init(struct spc_softc *, int);
    237        1.8   tsutsui void	spc_sched(struct spc_softc *);
    238        1.1   minoura #endif	/* _MB89352VAR_H_ */
    239