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