sbicvar.h revision 1.3
11.3Sthorpej/* $NetBSD: sbicvar.h,v 1.3 1996/05/08 05:55:09 thorpej Exp $ */ 21.3Sthorpej 31.1Schuck/* 41.1Schuck * Copyright (c) 1990 The Regents of the University of California. 51.1Schuck * All rights reserved. 61.1Schuck * 71.1Schuck * This code is derived from software contributed to Berkeley by 81.1Schuck * Van Jacobson of Lawrence Berkeley Laboratory. 91.1Schuck * 101.1Schuck * Redistribution and use in source and binary forms, with or without 111.1Schuck * modification, are permitted provided that the following conditions 121.1Schuck * are met: 131.1Schuck * 1. Redistributions of source code must retain the above copyright 141.1Schuck * notice, this list of conditions and the following disclaimer. 151.1Schuck * 2. Redistributions in binary form must reproduce the above copyright 161.1Schuck * notice, this list of conditions and the following disclaimer in the 171.1Schuck * documentation and/or other materials provided with the distribution. 181.1Schuck * 3. All advertising materials mentioning features or use of this software 191.1Schuck * must display the following acknowledgement: 201.1Schuck * This product includes software developed by the University of 211.1Schuck * California, Berkeley and its contributors. 221.1Schuck * 4. Neither the name of the University nor the names of its contributors 231.1Schuck * may be used to endorse or promote products derived from this software 241.1Schuck * without specific prior written permission. 251.1Schuck * 261.1Schuck * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271.1Schuck * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281.1Schuck * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291.1Schuck * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 301.1Schuck * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311.1Schuck * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321.1Schuck * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 331.1Schuck * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 341.1Schuck * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351.1Schuck * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 361.1Schuck * SUCH DAMAGE. 371.1Schuck * 381.1Schuck * @(#)scsivar.h 7.1 (Berkeley) 5/8/90 391.1Schuck */ 401.1Schuck#ifndef _SBICVAR_H_ 411.1Schuck#define _SBICVAR_H_ 421.1Schuck#include <sys/malloc.h> 431.1Schuck 441.1Schuck 451.1Schuck/* 461.1Schuck * DMA chains are used for Scatter-Gather DMA. 471.1Schuck */ 481.1Schuckstruct dma_chain { 491.1Schuck int dc_count; 501.1Schuck char *dc_addr; 511.1Schuck}; 521.1Schuck 531.1Schuck/* 541.1Schuck * ACB. Holds additional information for each SCSI command Comments: We 551.1Schuck * need a separate scsi command block because we may need to overwrite it 561.1Schuck * with a request sense command. Basicly, we refrain from fiddling with 571.1Schuck * the scsi_xfer struct (except do the expected updating of return values). 581.1Schuck * We'll generally update: xs->{flags,resid,error,sense,status} and 591.1Schuck * occasionally xs->retries. 601.1Schuck */ 611.1Schuckstruct sbic_acb { 621.1Schuck TAILQ_ENTRY(sbic_acb) chain; 631.1Schuck struct scsi_xfer *xs; /* SCSI xfer ctrl block from above */ 641.1Schuck int flags; /* Status */ 651.1Schuck#define ACB_FREE 0x00 661.1Schuck#define ACB_ACTIVE 0x01 671.1Schuck#define ACB_DONE 0x04 681.1Schuck#define ACB_CHKSENSE 0x08 691.1Schuck#define ACB_BBUF 0x10 /* DMA input needs to be copied from bounce */ 701.1Schuck#define ACB_DATAIN 0x20 /* DMA direction flag */ 711.1Schuck 721.1Schuck struct scsi_generic cmd; /* SCSI command block */ 731.1Schuck int clen; 741.1Schuck struct dma_chain sc_kv; /* Virtual address of whole DMA */ 751.1Schuck struct dma_chain sc_pa; /* Physical address of DMA segment */ 761.1Schuck u_long sc_tcnt; /* number of bytes for this DMA */ 771.1Schuck u_short sc_dmacmd; /* Internal data for this DMA */ 781.1Schuck char *pa_addr; /* XXXX initial phys addr */ 791.1Schuck}; 801.1Schuck 811.1Schuck/* 821.1Schuck * Some info about each (possible) target on the SCSI bus. This should 831.1Schuck * probably have been a "per target+lunit" structure, but we'll leave it at 841.1Schuck * this for now. Is there a way to reliably hook it up to sc->fordriver?? 851.1Schuck */ 861.1Schuckstruct sbic_tinfo { 871.1Schuck int cmds; /* #commands processed */ 881.1Schuck int dconns; /* #disconnects */ 891.1Schuck int senses; /* #request sense commands sent */ 901.1Schuck int lubusy; /* What local units/subr. are busy? */ 911.1Schuck} tinfo_t; 921.1Schuck 931.1Schuckstruct sbic_softc { 941.1Schuck struct device sc_dev; 951.1Schuck struct target_sync { 961.1Schuck u_char state; 971.1Schuck u_char period; 981.1Schuck u_char offset; 991.1Schuck } sc_sync[8]; 1001.1Schuck u_char target; /* Currently active target */ 1011.1Schuck u_char lun; 1021.1Schuck struct scsi_link sc_link; /* proto for sub devices */ 1031.1Schuck sbic_regmap_p sc_sbicp; /* the SBIC */ 1041.1Schuck volatile void *sc_cregs; /* driver specific regs */ 1051.1Schuck int sc_ipl; 1061.1Schuck 1071.1Schuck /* Lists of command blocks */ 1081.1Schuck TAILQ_HEAD(acb_list, sbic_acb) free_list, 1091.1Schuck ready_list, 1101.1Schuck nexus_list; 1111.1Schuck 1121.1Schuck struct sbic_acb *sc_nexus; /* current command */ 1131.1Schuck struct sbic_acb sc_acb[8]; /* the real command blocks */ 1141.1Schuck struct sbic_tinfo sc_tinfo[8]; 1151.1Schuck 1161.1Schuck struct scsi_xfer *sc_xs; /* transfer from high level code */ 1171.1Schuck u_char sc_flags; 1181.1Schuck u_char sc_stat[2]; 1191.1Schuck u_char sc_msg[7]; 1201.1Schuck u_long sc_clkfreq; 1211.1Schuck u_long sc_tcnt; /* number of bytes transfered */ 1221.1Schuck u_short sc_dmacmd; /* used by dma drivers */ 1231.1Schuck u_long sc_dmamask; /* dma valid mem mask */ 1241.1Schuck#ifdef DEBUG 1251.1Schuck u_short sc_dmatimo; /* dma timeout */ 1261.1Schuck#endif 1271.1Schuck struct dma_chain *sc_cur; 1281.1Schuck struct dma_chain *sc_last; 1291.1Schuck int (*sc_dmago) __P((struct sbic_softc *, char *, int, int)); 1301.1Schuck int (*sc_dmanext) __P((struct sbic_softc *)); 1311.1Schuck void (*sc_enintr) __P((struct sbic_softc *)); 1321.1Schuck void (*sc_dmastop) __P((struct sbic_softc *)); 1331.1Schuck}; 1341.1Schuck 1351.1Schuck/* 1361.1Schuck * sc_flags 1371.1Schuck */ 1381.1Schuck#define SBICF_ALIVE 0x01 /* controller initialized */ 1391.1Schuck#define SBICF_DCFLUSH 0x02 /* need flush for overlap after dma finishes */ 1401.1Schuck#define SBICF_SELECTED 0x04 /* bus is in selected state. */ 1411.1Schuck#define SBICF_ICMD 0x08 /* Immediate command in execution */ 1421.1Schuck#define SBICF_BADDMA 0x10 /* controller can only DMA to ztwobus space */ 1431.1Schuck#define SBICF_INTR 0x40 /* SBICF interrupt expected */ 1441.1Schuck#define SBICF_INDMA 0x80 /* not used yet, DMA I/O in progress */ 1451.1Schuck 1461.1Schuck/* 1471.1Schuck * sync states 1481.1Schuck */ 1491.1Schuck#define SYNC_START 0 /* no sync handshake started */ 1501.1Schuck#define SYNC_SENT 1 /* we sent sync request, no answer yet */ 1511.1Schuck#define SYNC_DONE 2 /* target accepted our (or inferior) settings, 1521.1Schuck or it rejected the request and we stay async */ 1531.1Schuck 1541.1Schuck#define PHASE 0x07 /* mask for psns/pctl phase */ 1551.1Schuck#define DATA_OUT_PHASE 0x00 1561.1Schuck#define DATA_IN_PHASE 0x01 1571.1Schuck#define CMD_PHASE 0x02 1581.1Schuck#define STATUS_PHASE 0x03 1591.1Schuck#define BUS_FREE_PHASE 0x04 1601.1Schuck#define ARB_SEL_PHASE 0x05 /* Fuji chip combines arbitration with sel. */ 1611.1Schuck#define MESG_OUT_PHASE 0x06 1621.1Schuck#define MESG_IN_PHASE 0x07 1631.1Schuck 1641.1Schuck#define MSG_CMD_COMPLETE 0x00 1651.1Schuck#define MSG_EXT_MESSAGE 0x01 1661.1Schuck#define MSG_SAVE_DATA_PTR 0x02 1671.1Schuck#define MSG_RESTORE_PTR 0x03 1681.1Schuck#define MSG_DISCONNECT 0x04 1691.1Schuck#define MSG_INIT_DETECT_ERROR 0x05 1701.1Schuck#define MSG_ABORT 0x06 1711.1Schuck#define MSG_REJECT 0x07 1721.1Schuck#define MSG_NOOP 0x08 1731.1Schuck#define MSG_PARITY_ERROR 0x09 1741.1Schuck#define MSG_BUS_DEVICE_RESET 0x0C 1751.1Schuck#define MSG_IDENTIFY 0x80 1761.1Schuck#define MSG_IDENTIFY_DR 0xc0 /* (disconnect/reconnect allowed) */ 1771.1Schuck#define MSG_SYNC_REQ 0x01 1781.1Schuck 1791.1Schuck#define MSG_ISIDENTIFY(x) ((x) & MSG_IDENTIFY) 1801.1Schuck 1811.1Schuck 1821.1Schuck#define STS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */ 1831.1Schuck#define STS_CONDMET 0x04 /* Condition Met (ie., search worked) */ 1841.1Schuck#define STS_BUSY 0x08 1851.1Schuck#define STS_INTERMED 0x10 /* Intermediate status sent */ 1861.1Schuck#define STS_EXT 0x80 /* Extended status valid */ 1871.1Schuck 1881.1Schuck 1891.1Schuck/* 1901.1Schuck * States returned by our state machine 1911.1Schuck */ 1921.1Schuck 1931.1Schuck#define SBIC_STATE_ERROR -1 1941.1Schuck#define SBIC_STATE_DONE 0 1951.1Schuck#define SBIC_STATE_RUNNING 1 1961.1Schuck#define SBIC_STATE_DISCONNECT 2 1971.1Schuck 1981.1Schuck 1991.1Schuckstruct buf; 2001.1Schuckstruct scsi_xfer; 2011.1Schuck 2021.1Schuckvoid sbic_minphys __P((struct buf *bp)); 2031.1Schuckint sbic_scsicmd __P((struct scsi_xfer *)); 2041.1Schuck 2051.1Schuck#endif /* _SBICVAR_H_ */ 206