sbicvar.h revision 1.7
11.7Sthorpej/* $NetBSD: sbicvar.h,v 1.7 2000/03/23 06:41:28 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.7Sthorpej#include <sys/callout.h> 431.1Schuck#include <sys/malloc.h> 441.1Schuck 451.1Schuck 461.1Schuck/* 471.1Schuck * DMA chains are used for Scatter-Gather DMA. 481.1Schuck */ 491.1Schuckstruct dma_chain { 501.1Schuck int dc_count; 511.1Schuck char *dc_addr; 521.1Schuck}; 531.1Schuck 541.1Schuck/* 551.1Schuck * ACB. Holds additional information for each SCSI command Comments: We 561.1Schuck * need a separate scsi command block because we may need to overwrite it 571.1Schuck * with a request sense command. Basicly, we refrain from fiddling with 581.1Schuck * the scsi_xfer struct (except do the expected updating of return values). 591.1Schuck * We'll generally update: xs->{flags,resid,error,sense,status} and 601.1Schuck * occasionally xs->retries. 611.1Schuck */ 621.1Schuckstruct sbic_acb { 631.1Schuck TAILQ_ENTRY(sbic_acb) chain; 641.4Sbouyer struct scsipi_xfer *xs; /* SCSI xfer ctrl block from above */ 651.1Schuck int flags; /* Status */ 661.1Schuck#define ACB_FREE 0x00 671.1Schuck#define ACB_ACTIVE 0x01 681.1Schuck#define ACB_DONE 0x04 691.1Schuck#define ACB_CHKSENSE 0x08 701.1Schuck#define ACB_BBUF 0x10 /* DMA input needs to be copied from bounce */ 711.1Schuck#define ACB_DATAIN 0x20 /* DMA direction flag */ 721.1Schuck 731.1Schuck struct scsi_generic cmd; /* SCSI command block */ 741.1Schuck int clen; 751.1Schuck struct dma_chain sc_kv; /* Virtual address of whole DMA */ 761.1Schuck struct dma_chain sc_pa; /* Physical address of DMA segment */ 771.1Schuck u_long sc_tcnt; /* number of bytes for this DMA */ 781.1Schuck u_short sc_dmacmd; /* Internal data for this DMA */ 791.1Schuck char *pa_addr; /* XXXX initial phys addr */ 801.1Schuck}; 811.1Schuck 821.1Schuck/* 831.1Schuck * Some info about each (possible) target on the SCSI bus. This should 841.1Schuck * probably have been a "per target+lunit" structure, but we'll leave it at 851.1Schuck * this for now. Is there a way to reliably hook it up to sc->fordriver?? 861.1Schuck */ 871.1Schuckstruct sbic_tinfo { 881.1Schuck int cmds; /* #commands processed */ 891.1Schuck int dconns; /* #disconnects */ 901.1Schuck int senses; /* #request sense commands sent */ 911.1Schuck int lubusy; /* What local units/subr. are busy? */ 921.1Schuck} tinfo_t; 931.1Schuck 941.1Schuckstruct sbic_softc { 951.1Schuck struct device sc_dev; 961.1Schuck struct target_sync { 971.1Schuck u_char state; 981.1Schuck u_char period; 991.1Schuck u_char offset; 1001.1Schuck } sc_sync[8]; 1011.1Schuck u_char target; /* Currently active target */ 1021.1Schuck u_char lun; 1031.5Sthorpej struct scsipi_link sc_link; /* proto for sub devices */ 1041.5Sthorpej struct scsipi_adapter sc_adapter; 1051.1Schuck sbic_regmap_p sc_sbicp; /* the SBIC */ 1061.6Sscw void *sc_driver; /* driver specific field */ 1071.1Schuck int sc_ipl; 1081.7Sthorpej 1091.7Sthorpej struct callout sc_timo_ch; 1101.1Schuck 1111.1Schuck /* Lists of command blocks */ 1121.1Schuck TAILQ_HEAD(acb_list, sbic_acb) free_list, 1131.1Schuck ready_list, 1141.1Schuck nexus_list; 1151.1Schuck 1161.1Schuck struct sbic_acb *sc_nexus; /* current command */ 1171.1Schuck struct sbic_acb sc_acb[8]; /* the real command blocks */ 1181.1Schuck struct sbic_tinfo sc_tinfo[8]; 1191.1Schuck 1201.4Sbouyer struct scsipi_xfer *sc_xs; /* transfer from high level code */ 1211.1Schuck u_char sc_flags; 1221.1Schuck u_char sc_stat[2]; 1231.1Schuck u_char sc_msg[7]; 1241.1Schuck u_long sc_clkfreq; 1251.1Schuck u_long sc_tcnt; /* number of bytes transfered */ 1261.1Schuck u_short sc_dmacmd; /* used by dma drivers */ 1271.1Schuck u_long sc_dmamask; /* dma valid mem mask */ 1281.1Schuck#ifdef DEBUG 1291.1Schuck u_short sc_dmatimo; /* dma timeout */ 1301.1Schuck#endif 1311.1Schuck struct dma_chain *sc_cur; 1321.1Schuck struct dma_chain *sc_last; 1331.1Schuck int (*sc_dmago) __P((struct sbic_softc *, char *, int, int)); 1341.1Schuck int (*sc_dmanext) __P((struct sbic_softc *)); 1351.1Schuck void (*sc_enintr) __P((struct sbic_softc *)); 1361.1Schuck void (*sc_dmastop) __P((struct sbic_softc *)); 1371.1Schuck}; 1381.1Schuck 1391.1Schuck/* 1401.1Schuck * sc_flags 1411.1Schuck */ 1421.1Schuck#define SBICF_ALIVE 0x01 /* controller initialized */ 1431.1Schuck#define SBICF_DCFLUSH 0x02 /* need flush for overlap after dma finishes */ 1441.1Schuck#define SBICF_SELECTED 0x04 /* bus is in selected state. */ 1451.1Schuck#define SBICF_ICMD 0x08 /* Immediate command in execution */ 1461.1Schuck#define SBICF_BADDMA 0x10 /* controller can only DMA to ztwobus space */ 1471.1Schuck#define SBICF_INTR 0x40 /* SBICF interrupt expected */ 1481.1Schuck#define SBICF_INDMA 0x80 /* not used yet, DMA I/O in progress */ 1491.1Schuck 1501.1Schuck/* 1511.1Schuck * sync states 1521.1Schuck */ 1531.1Schuck#define SYNC_START 0 /* no sync handshake started */ 1541.1Schuck#define SYNC_SENT 1 /* we sent sync request, no answer yet */ 1551.1Schuck#define SYNC_DONE 2 /* target accepted our (or inferior) settings, 1561.1Schuck or it rejected the request and we stay async */ 1571.1Schuck 1581.1Schuck#define PHASE 0x07 /* mask for psns/pctl phase */ 1591.1Schuck#define DATA_OUT_PHASE 0x00 1601.1Schuck#define DATA_IN_PHASE 0x01 1611.1Schuck#define CMD_PHASE 0x02 1621.1Schuck#define STATUS_PHASE 0x03 1631.1Schuck#define BUS_FREE_PHASE 0x04 1641.1Schuck#define ARB_SEL_PHASE 0x05 /* Fuji chip combines arbitration with sel. */ 1651.1Schuck#define MESG_OUT_PHASE 0x06 1661.1Schuck#define MESG_IN_PHASE 0x07 1671.1Schuck 1681.1Schuck#define MSG_CMD_COMPLETE 0x00 1691.1Schuck#define MSG_EXT_MESSAGE 0x01 1701.1Schuck#define MSG_SAVE_DATA_PTR 0x02 1711.1Schuck#define MSG_RESTORE_PTR 0x03 1721.1Schuck#define MSG_DISCONNECT 0x04 1731.1Schuck#define MSG_INIT_DETECT_ERROR 0x05 1741.1Schuck#define MSG_ABORT 0x06 1751.1Schuck#define MSG_REJECT 0x07 1761.1Schuck#define MSG_NOOP 0x08 1771.1Schuck#define MSG_PARITY_ERROR 0x09 1781.1Schuck#define MSG_BUS_DEVICE_RESET 0x0C 1791.1Schuck#define MSG_IDENTIFY 0x80 1801.1Schuck#define MSG_IDENTIFY_DR 0xc0 /* (disconnect/reconnect allowed) */ 1811.1Schuck#define MSG_SYNC_REQ 0x01 1821.1Schuck 1831.1Schuck#define MSG_ISIDENTIFY(x) ((x) & MSG_IDENTIFY) 1841.1Schuck 1851.1Schuck 1861.1Schuck#define STS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */ 1871.1Schuck#define STS_CONDMET 0x04 /* Condition Met (ie., search worked) */ 1881.1Schuck#define STS_BUSY 0x08 1891.1Schuck#define STS_INTERMED 0x10 /* Intermediate status sent */ 1901.1Schuck#define STS_EXT 0x80 /* Extended status valid */ 1911.1Schuck 1921.1Schuck 1931.1Schuck/* 1941.1Schuck * States returned by our state machine 1951.1Schuck */ 1961.1Schuck 1971.1Schuck#define SBIC_STATE_ERROR -1 1981.1Schuck#define SBIC_STATE_DONE 0 1991.1Schuck#define SBIC_STATE_RUNNING 1 2001.1Schuck#define SBIC_STATE_DISCONNECT 2 2011.1Schuck 2021.1Schuck 2031.1Schuckstruct buf; 2041.4Sbouyerstruct scsipi_xfer; 2051.1Schuck 2061.1Schuckvoid sbic_minphys __P((struct buf *bp)); 2071.4Sbouyerint sbic_scsicmd __P((struct scsipi_xfer *)); 2081.6Sscwvoid sbicinit __P((struct sbic_softc *)); 2091.6Sscwint sbicintr __P((struct sbic_softc *)); 2101.1Schuck 2111.1Schuck#endif /* _SBICVAR_H_ */ 212