xyvar.h revision 1.3
11.3Spk/* $NetBSD: xyvar.h,v 1.3 1998/08/22 11:47:46 pk Exp $ */ 21.1Spk 31.1Spk/* 41.1Spk * 51.1Spk * Copyright (c) 1995 Charles D. Cranor 61.1Spk * All rights reserved. 71.1Spk * 81.1Spk * Redistribution and use in source and binary forms, with or without 91.1Spk * modification, are permitted provided that the following conditions 101.1Spk * are met: 111.1Spk * 1. Redistributions of source code must retain the above copyright 121.1Spk * notice, this list of conditions and the following disclaimer. 131.1Spk * 2. Redistributions in binary form must reproduce the above copyright 141.1Spk * notice, this list of conditions and the following disclaimer in the 151.1Spk * documentation and/or other materials provided with the distribution. 161.1Spk * 3. All advertising materials mentioning features or use of this software 171.1Spk * must display the following acknowledgement: 181.1Spk * This product includes software developed by Charles D. Cranor. 191.1Spk * 4. The name of the author may not be used to endorse or promote products 201.1Spk * derived from this software without specific prior written permission. 211.1Spk * 221.1Spk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 231.1Spk * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 241.1Spk * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 251.1Spk * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 261.1Spk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 271.1Spk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 281.1Spk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 291.1Spk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 301.1Spk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 311.1Spk * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 321.1Spk */ 331.1Spk 341.1Spk/* 351.1Spk * x y v a r . h 361.1Spk * 371.1Spk * this file defines the software structure we use to control the 381.1Spk * 450/451. 391.1Spk * 401.1Spk * author: Chuck Cranor <chuck@ccrc.wustl.edu> 411.1Spk */ 421.1Spk 431.1Spk/* 441.1Spk * i/o request: wrapper for hardware's iopb data structure 451.1Spk */ 461.1Spkstruct xy_iorq { 471.3Spk struct xy_iopb *iopb; /* address of matching iopb */ 481.3Spk struct xy_iopb *dmaiopb;/* DMA address of above */ 491.3Spk struct xyc_softc *xyc; /* who we are working with */ 501.3Spk struct xy_softc *xy; /* which disk */ 511.3Spk int ttl; /* time to live */ 521.3Spk int mode; /* current mode (state+other data) */ 531.3Spk int tries; /* number of times we have tried it */ 541.3Spk int errno; /* error number if we fail */ 551.3Spk int lasterror; /* last error we got */ 561.3Spk int blockno; /* starting block no for this xfer */ 571.3Spk int sectcnt; /* number of sectors in xfer */ 581.3Spk char *dbuf; /* KVA of data buffer (advances) */ 591.3Spk struct buf *buf; /* for NORM */ 601.3Spk bus_dmamap_t dmamap; /* DMA I/O handle */ 611.1Spk}; 621.1Spk 631.1Spk/* 641.1Spk * state 651.1Spk */ 661.3Spk#define XY_SUB_MASK 0xf0 /* mask bits for state */ 671.3Spk#define XY_SUB_FREE 0x00 /* free */ 681.3Spk#define XY_SUB_NORM 0x10 /* normal I/O request */ 691.3Spk#define XY_SUB_WAIT 0x20 /* normal I/O request in the 701.3Spk context of a process */ 711.3Spk#define XY_SUB_POLL 0x30 /* polled mode */ 721.3Spk#define XY_SUB_DONE 0x40 /* not active, but can't be free'd yet */ 731.3Spk#define XY_SUB_NOQ 0x50 /* don't queue, just submit (internal) */ 741.1Spk 751.1Spk#define XY_STATE(X) ((X) & XY_SUB_MASK) /* extract state from mode */ 761.1Spk#define XY_NEWSTATE(OLD, NEW) (((OLD) & ~XY_SUB_MASK) |(NEW)) /* new state */ 771.1Spk 781.1Spk 791.1Spk/* 801.1Spk * other mode data 811.1Spk */ 821.3Spk#define XY_MODE_VERBO 0x08 /* print error messages */ 831.3Spk#define XY_MODE_B144 0x04 /* handling a bad144 sector */ 841.1Spk 851.1Spk 861.1Spk/* 871.1Spk * software timers and flags 881.1Spk */ 891.3Spk#define XYC_SUBWAITLIM 4 /* max number of "done" IOPBs there can be 901.3Spk where we still allow a SUB_WAIT command */ 911.3Spk#define XYC_TICKCNT (5*hz) /* call xyc_tick on this interval (5 sec) */ 921.3Spk#define XYC_MAXTTL 2 /* max number of xy ticks to live */ 931.3Spk#define XYC_NOUNIT (-1) /* for xycmd: no unit number */ 941.1Spk 951.1Spk/* 961.1Spk * a "xy_softc" structure contains per-disk state info. 971.1Spk */ 981.1Spkstruct xy_softc { 991.3Spk struct device sc_dev; /* device struct, reqd by autoconf */ 1001.3Spk struct disk sc_dk; /* generic disk info */ 1011.3Spk struct xyc_softc *parent;/* parent */ 1021.3Spk u_short flags; /* flags */ 1031.3Spk u_short state; /* device state */ 1041.3Spk int xy_drive; /* unit number */ 1051.3Spk int drive_type; /* drive type (as per disk) */ 1061.3Spk 1071.3Spk /* geometry */ 1081.3Spk u_short ncyl, acyl, pcyl; /* number of cyl's */ 1091.3Spk u_short sectpercyl; /* nhead*nsect */ 1101.3Spk u_char nhead; /* number of heads */ 1111.3Spk u_char nsect; /* number of sectors per track */ 1121.3Spk u_char hw_spt; /* as above, but includes spare sectors */ 1131.3Spk struct xy_iorq *xyrq; /* this disk's ioreq structure */ 1141.3Spk struct buf xyq; /* queue'd I/O requests */ 1151.3Spk struct dkbad dkb; /* bad144 sectors */ 1161.1Spk}; 1171.1Spk 1181.1Spk/* 1191.1Spk * flags 1201.1Spk */ 1211.1Spk 1221.1Spk#define XY_WLABEL 0x0001 /* write label */ 1231.1Spk/* 1241.1Spk * state 1251.1Spk */ 1261.1Spk 1271.1Spk#define XY_DRIVE_UNKNOWN 0 /* never talked to it */ 1281.1Spk#define XY_DRIVE_ATTACHING 1 /* attach in progress */ 1291.1Spk#define XY_DRIVE_NOLABEL 2 /* drive on-line, no label */ 1301.1Spk#define XY_DRIVE_ONLINE 3 /* drive is on-line */ 1311.1Spk 1321.1Spk/* 1331.1Spk * a "xyc_softc" structure contains per-disk-controller state info, 1341.1Spk * including a list of active controllers. 1351.1Spk */ 1361.1Spk 1371.1Spkstruct xyc_softc { 1381.2Spk struct device sc_dev; /* device struct, reqd by autoconf */ 1391.2Spk struct intrhand sc_ih; /* interrupt info */ 1401.2Spk struct evcnt sc_intrcnt; /* event counter (for vmstat -i) */ 1411.2Spk 1421.2Spk struct xyc *xyc; /* vaddr of vme registers */ 1431.2Spk 1441.2Spk struct xy_softc *sc_drives[XYC_MAXDEV]; /* drives on this controller */ 1451.2Spk int ipl; /* interrupt level */ 1461.2Spk int vector; /* interrupt vector */ 1471.2Spk bus_dma_tag_t dmatag; /* Bus DMA tag */ 1481.2Spk 1491.2Spk struct xy_iorq *reqs; /* i/o requests */ 1501.2Spk struct xy_iopb *iopbase; /* iopb base addr (maps iopb->iorq) */ 1511.2Spk struct xy_iopb *dvmaiopb; /* iopb base in DVMA space, not kvm */ 1521.1Spk 1531.2Spk struct xy_iorq *ciorq; /* controller's iorq */ 1541.2Spk struct xy_iopb *ciopb; /* controller's iopb */ 1551.1Spk 1561.2Spk int xy_hand; /* hand */ 1571.2Spk struct xy_iorq *xy_chain[XYC_MAXIOPB]; 1581.1Spk /* current chain */ 1591.2Spk int no_ols; /* disable overlap seek for stupid 450s */ 1601.1Spk}; 1611.1Spk 1621.1Spk/* 1631.1Spk * reset blast modes 1641.1Spk */ 1651.1Spk 1661.1Spk#define XY_RSET_NONE (struct xy_iorq *)(-1) /* restart all requests */ 1671.1Spk#define XY_RSET_ALL (struct xy_iorq *)(-2) /* don't restart anything */ 168