Home | History | Annotate | Line # | Download | only in dev
siopvar.h revision 1.25.78.1
      1  1.25.78.1     yamt /*	$NetBSD: siopvar.h,v 1.25.78.1 2009/06/20 07:20:00 yamt Exp $	*/
      2        1.5      cgd 
      3        1.1       mw /*
      4        1.1       mw  * Copyright (c) 1990 The Regents of the University of California.
      5        1.1       mw  * All rights reserved.
      6        1.1       mw  *
      7        1.1       mw  * This code is derived from software contributed to Berkeley by
      8        1.1       mw  * Van Jacobson of Lawrence Berkeley Laboratory.
      9        1.1       mw  *
     10        1.1       mw  * Redistribution and use in source and binary forms, with or without
     11        1.1       mw  * modification, are permitted provided that the following conditions
     12        1.1       mw  * are met:
     13        1.1       mw  * 1. Redistributions of source code must retain the above copyright
     14        1.1       mw  *    notice, this list of conditions and the following disclaimer.
     15        1.1       mw  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1       mw  *    notice, this list of conditions and the following disclaimer in the
     17        1.1       mw  *    documentation and/or other materials provided with the distribution.
     18       1.23      agc  * 3. Neither the name of the University nor the names of its contributors
     19        1.1       mw  *    may be used to endorse or promote products derived from this software
     20        1.1       mw  *    without specific prior written permission.
     21        1.1       mw  *
     22        1.1       mw  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23        1.1       mw  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24        1.1       mw  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25        1.1       mw  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26        1.1       mw  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27        1.1       mw  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28        1.1       mw  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29        1.1       mw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30        1.1       mw  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31        1.1       mw  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32        1.1       mw  * SUCH DAMAGE.
     33        1.1       mw  *
     34        1.1       mw  *	@(#)siopvar.h	7.1 (Berkeley) 5/8/90
     35        1.1       mw  */
     36        1.3   chopps #ifndef _SIOPVAR_H_
     37        1.3   chopps #define _SIOPVAR_H_
     38        1.1       mw 
     39        1.3   chopps /*
     40        1.3   chopps  * The largest single request will be MAXPHYS bytes which will require
     41       1.22  thorpej  * at most MAXPHYS/PAGE_SIZE+1 chain elements to describe, i.e. if none of
     42       1.22  thorpej  * the buffer pages are physically contiguous (MAXPHYS/PAGE_SIZE) and the
     43        1.3   chopps  * buffer is not page aligned (+1).
     44        1.3   chopps  */
     45       1.22  thorpej #define	DMAMAXIO	(MAXPHYS/PAGE_SIZE+1)
     46        1.3   chopps 
     47       1.11   chopps /*
     48       1.11   chopps  * Data Structure for SCRIPTS program
     49       1.11   chopps  */
     50       1.11   chopps struct siop_ds {
     51       1.12   chopps 	long	scsi_addr;		/* SCSI ID & sync */
     52       1.12   chopps 	long	idlen;			/* Identify message */
     53       1.12   chopps 	char	*idbuf;
     54       1.12   chopps 	long	cmdlen;			/* SCSI command */
     55       1.12   chopps 	char	*cmdbuf;
     56       1.12   chopps 	long	stslen;			/* Status */
     57       1.12   chopps 	char	*stsbuf;
     58       1.12   chopps 	long	msglen;			/* Message */
     59       1.12   chopps 	char	*msgbuf;
     60       1.12   chopps 	long	msginlen;		/* Message in */
     61       1.12   chopps 	char	*msginbuf;
     62       1.12   chopps 	long	extmsglen;		/* Extended message in */
     63       1.12   chopps 	char	*extmsgbuf;
     64       1.12   chopps 	long	synmsglen;		/* Sync transfer request */
     65       1.12   chopps 	char	*synmsgbuf;
     66       1.11   chopps 	struct {
     67       1.12   chopps 		long datalen;
     68       1.12   chopps 		char *databuf;
     69       1.11   chopps 	} chain[DMAMAXIO];
     70        1.3   chopps };
     71        1.3   chopps 
     72       1.11   chopps /*
     73       1.11   chopps  * ACB. Holds additional information for each SCSI command Comments: We
     74       1.11   chopps  * need a separate scsi command block because we may need to overwrite it
     75       1.11   chopps  * with a request sense command.  Basicly, we refrain from fiddling with
     76       1.11   chopps  * the scsi_xfer struct (except do the expected updating of return values).
     77       1.11   chopps  * We'll generally update: xs->{flags,resid,error,sense,status} and
     78       1.11   chopps  * occasionally xs->retries.
     79       1.11   chopps  */
     80       1.11   chopps struct siop_acb {
     81       1.12   chopps 	TAILQ_ENTRY(siop_acb) chain;
     82       1.15   bouyer 	struct scsipi_xfer *xs;	/* SCSI xfer ctrl block from above */
     83       1.12   chopps 	int		flags;	/* Status */
     84       1.11   chopps #define ACB_FREE	0x00
     85       1.11   chopps #define ACB_ACTIVE	0x01
     86       1.11   chopps #define ACB_DONE	0x04
     87       1.24  thorpej 	struct scsipi_generic cmd;  /* SCSI command block */
     88       1.12   chopps 	struct siop_ds ds;
     89       1.12   chopps 	void	*iob_buf;
     90       1.12   chopps 	u_long	iob_curbuf;
     91       1.12   chopps 	u_long	iob_len, iob_curlen;
     92       1.12   chopps 	u_char	msgout[6];
     93       1.12   chopps 	u_char	msg[6];
     94       1.12   chopps 	u_char	stat[1];
     95       1.12   chopps 	u_char	status;
     96       1.12   chopps 	u_char	dummy[2];
     97       1.12   chopps 	int	 clen;
     98       1.12   chopps 	char	*daddr;		/* Saved data pointer */
     99       1.12   chopps 	int	 dleft;		/* Residue */
    100        1.1       mw };
    101        1.1       mw 
    102       1.11   chopps /*
    103       1.11   chopps  * Some info about each (possible) target on the SCSI bus.  This should
    104       1.11   chopps  * probably have been a "per target+lunit" structure, but we'll leave it at
    105       1.11   chopps  * this for now.  Is there a way to reliably hook it up to sc->fordriver??
    106       1.11   chopps  */
    107       1.11   chopps struct siop_tinfo {
    108       1.11   chopps 	int	cmds;		/* #commands processed */
    109       1.11   chopps 	int	dconns;		/* #disconnects */
    110       1.11   chopps 	int	touts;		/* #timeouts */
    111       1.11   chopps 	int	perrs;		/* #parity errors */
    112       1.11   chopps 	ushort	lubusy;		/* What local units/subr. are busy? */
    113       1.11   chopps 	u_char  flags;
    114       1.11   chopps 	u_char  period;		/* Period suggestion */
    115       1.11   chopps 	u_char  offset;		/* Offset suggestion */
    116       1.21     matt };
    117       1.11   chopps 
    118        1.1       mw struct	siop_softc {
    119       1.12   chopps 	struct	device sc_dev;
    120       1.12   chopps 	struct	isr sc_isr;
    121  1.25.78.1     yamt 	void	*sc_siop_si;
    122        1.1       mw 
    123       1.12   chopps 	u_char	sc_istat;
    124       1.12   chopps 	u_char	sc_dstat;
    125       1.17       is #ifndef ARCH_720
    126       1.12   chopps 	u_char	sc_sstat0;
    127       1.17       is #endif
    128       1.12   chopps 	u_char	sc_sstat1;
    129       1.17       is #ifdef ARCH_720
    130       1.17       is 	u_short	sc_sist;
    131       1.17       is #endif
    132       1.12   chopps 	u_long	sc_intcode;
    133       1.16  thorpej 	struct	scsipi_adapter sc_adapter;
    134       1.19   bouyer 	struct	scsipi_channel sc_channel;
    135       1.12   chopps 	u_long	sc_scriptspa;		/* physical address of scripts */
    136       1.12   chopps 	siop_regmap_p	sc_siopp;	/* the SIOP */
    137       1.12   chopps 	u_long	sc_active;		/* number of active I/O's */
    138       1.11   chopps 
    139       1.11   chopps 	/* Lists of command blocks */
    140       1.12   chopps 	TAILQ_HEAD(acb_list, siop_acb) free_list,
    141       1.12   chopps 				       ready_list,
    142       1.12   chopps 				       nexus_list;
    143       1.12   chopps 
    144       1.12   chopps 	struct siop_acb *sc_nexus;	/* current command */
    145       1.17       is #define SIOP_NACB 16
    146       1.13    chuck 	struct siop_acb *sc_acb;	/* the real command blocks */
    147       1.18   mhitch #ifndef ARCH_720
    148       1.12   chopps 	struct siop_tinfo sc_tinfo[8];
    149       1.18   mhitch #else
    150       1.18   mhitch 	struct siop_tinfo sc_tinfo[16];
    151       1.18   mhitch #endif
    152       1.12   chopps 
    153       1.12   chopps 	u_short	sc_clock_freq;
    154       1.12   chopps 	u_char	sc_dcntl;
    155       1.12   chopps 	u_char	sc_ctest7;
    156       1.12   chopps 	u_short	sc_tcp[4];
    157       1.12   chopps 	u_char	sc_flags;
    158       1.12   chopps 	u_char	sc_dien;
    159       1.12   chopps 	u_char	sc_minsync;
    160       1.17       is #ifndef ARCH_720
    161       1.17       is 	u_char	sc_sien;
    162       1.17       is #else
    163       1.17       is 	u_short	sc_sien;
    164       1.17       is #endif
    165        1.1       mw 	/* one for each target */
    166       1.12   chopps 	struct syncpar {
    167       1.12   chopps 		u_char state;
    168       1.12   chopps 		u_char sxfer;
    169       1.18   mhitch #ifndef ARCH_720
    170       1.12   chopps 		u_char sbcl;
    171       1.18   mhitch #else
    172       1.18   mhitch 		u_char scntl3;
    173       1.18   mhitch #endif
    174       1.17       is 	} sc_sync[16];
    175        1.1       mw };
    176        1.1       mw 
    177        1.1       mw /* sc_flags */
    178       1.11   chopps #define	SIOP_INTSOFF	0x80	/* Interrupts turned off */
    179       1.11   chopps #define	SIOP_INTDEFER	0x40	/* Level 6 interrupt has been deferred */
    180        1.1       mw #define	SIOP_ALIVE	0x01	/* controller initialized */
    181        1.1       mw #define SIOP_SELECTED	0x04	/* bus is in selected state. Needed for
    182        1.1       mw 				   correct abort procedure. */
    183        1.1       mw 
    184       1.18   mhitch /* negotiation states */
    185       1.18   mhitch #define NEG_WIDE	0	/* Negotiate wide transfers */
    186       1.18   mhitch #define	NEG_WAITW	1	/* Waiting for wide negotation response */
    187       1.18   mhitch #define NEG_SYNC	2	/* Negotiate synch transfers */
    188       1.18   mhitch #define	NEG_WAITS	3	/* Waiting for synch negoation response */
    189       1.18   mhitch #define NEG_DONE	4	/* Wide and/or sync negotation done */
    190        1.3   chopps 
    191        1.3   chopps #define	MSG_CMD_COMPLETE	0x00
    192        1.3   chopps #define MSG_EXT_MESSAGE		0x01
    193        1.3   chopps #define	MSG_SAVE_DATA_PTR	0x02
    194        1.3   chopps #define	MSG_RESTORE_PTR		0x03
    195        1.3   chopps #define	MSG_DISCONNECT		0x04
    196        1.3   chopps #define	MSG_INIT_DETECT_ERROR	0x05
    197        1.3   chopps #define	MSG_ABORT		0x06
    198        1.3   chopps #define	MSG_REJECT		0x07
    199        1.3   chopps #define	MSG_NOOP		0x08
    200        1.3   chopps #define	MSG_PARITY_ERROR	0x09
    201        1.3   chopps #define	MSG_BUS_DEVICE_RESET	0x0C
    202        1.3   chopps #define	MSG_IDENTIFY		0x80
    203        1.3   chopps #define	MSG_IDENTIFY_DR		0xc0	/* (disconnect/reconnect allowed) */
    204       1.11   chopps #define	MSG_SYNC_REQ		0x01
    205       1.18   mhitch #define	MSG_WIDE_REQ		0x03
    206        1.3   chopps 
    207        1.3   chopps #define	STS_CHECKCOND	0x02	/* Check Condition (ie., read sense) */
    208        1.3   chopps #define	STS_CONDMET	0x04	/* Condition Met (ie., search worked) */
    209        1.3   chopps #define	STS_BUSY	0x08
    210        1.3   chopps #define	STS_INTERMED	0x10	/* Intermediate status sent */
    211        1.3   chopps #define	STS_EXT		0x80	/* Extended status valid */
    212        1.3   chopps 
    213       1.17       is #ifdef ARCH_720
    214       1.20  aymeric void siopng_minphys(struct buf *bp);
    215       1.20  aymeric void siopng_scsipi_request(struct scsipi_channel *,
    216       1.20  aymeric 			scsipi_adapter_req_t, void *);
    217       1.20  aymeric void siopnginitialize(struct siop_softc *);
    218       1.20  aymeric void siopngintr(struct siop_softc *);
    219       1.20  aymeric void siopng_dump_registers(struct siop_softc *);
    220       1.17       is #ifdef DEBUG
    221       1.20  aymeric void siopng_dump(struct siop_softc *);
    222       1.17       is #endif
    223       1.17       is 
    224       1.17       is #else
    225       1.17       is 
    226       1.20  aymeric void siop_minphys(struct buf *bp);
    227       1.20  aymeric void siop_scsipi_request(struct scsipi_channel *,
    228       1.20  aymeric 			scsipi_adapter_req_t, void *);
    229       1.20  aymeric void siopinitialize(struct siop_softc *);
    230       1.20  aymeric void siopintr(struct siop_softc *);
    231       1.20  aymeric void siop_dump_registers(struct siop_softc *);
    232       1.14    veego #ifdef DEBUG
    233       1.20  aymeric void siop_dump(struct siop_softc *);
    234       1.17       is #endif
    235       1.14    veego #endif
    236        1.3   chopps 
    237        1.3   chopps #endif /* _SIOPVAR_H */
    238