xyvar.h revision 1.3
11.3Sgwr/* $NetBSD: xyvar.h,v 1.3 1997/10/17 03:48:02 gwr Exp $ */ 21.1Sgwr 31.1Sgwr/* 41.1Sgwr * 51.1Sgwr * Copyright (c) 1995 Charles D. Cranor 61.1Sgwr * All rights reserved. 71.1Sgwr * 81.1Sgwr * Redistribution and use in source and binary forms, with or without 91.1Sgwr * modification, are permitted provided that the following conditions 101.1Sgwr * are met: 111.1Sgwr * 1. Redistributions of source code must retain the above copyright 121.1Sgwr * notice, this list of conditions and the following disclaimer. 131.1Sgwr * 2. Redistributions in binary form must reproduce the above copyright 141.1Sgwr * notice, this list of conditions and the following disclaimer in the 151.1Sgwr * documentation and/or other materials provided with the distribution. 161.1Sgwr * 3. All advertising materials mentioning features or use of this software 171.1Sgwr * must display the following acknowledgement: 181.1Sgwr * This product includes software developed by Charles D. Cranor. 191.1Sgwr * 4. The name of the author may not be used to endorse or promote products 201.1Sgwr * derived from this software without specific prior written permission. 211.1Sgwr * 221.1Sgwr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 231.1Sgwr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 241.1Sgwr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 251.1Sgwr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 261.1Sgwr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 271.1Sgwr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 281.1Sgwr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 291.1Sgwr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 301.1Sgwr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 311.1Sgwr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 321.1Sgwr */ 331.1Sgwr 341.1Sgwr/* 351.3Sgwr * x y v a r . h 361.1Sgwr * 371.3Sgwr * this file defines the software structure we use to control the 381.1Sgwr * 450/451. 391.1Sgwr * 401.1Sgwr * author: Chuck Cranor <chuck@ccrc.wustl.edu> 411.1Sgwr */ 421.1Sgwr 431.1Sgwr/* 441.1Sgwr * i/o request: wrapper for hardware's iopb data structure 451.1Sgwr */ 461.1Sgwr 471.1Sgwrstruct xy_iorq { 481.1Sgwr struct xy_iopb *iopb; /* address of matching iopb */ 491.1Sgwr struct xyc_softc *xyc; /* who we are working with */ 501.1Sgwr struct xy_softc *xy; /* which disk */ 511.1Sgwr int ttl; /* time to live */ 521.1Sgwr int mode; /* current mode (state+other data) */ 531.1Sgwr int tries; /* number of times we have tried it */ 541.1Sgwr int errno; /* error number if we fail */ 551.1Sgwr int lasterror; /* last error we got */ 561.1Sgwr int blockno; /* starting block no for this xfer */ 571.1Sgwr int sectcnt; /* number of sectors in xfer */ 581.1Sgwr char *dbuf; /* KVA of data buffer (advances) */ 591.1Sgwr char *dbufbase; /* base of dbuf */ 601.1Sgwr struct buf *buf; /* for NORM */ 611.1Sgwr}; 621.1Sgwr 631.1Sgwr/* 641.1Sgwr * state 651.1Sgwr */ 661.1Sgwr 671.1Sgwr#define XY_SUB_MASK 0xf0 /* mask bits for state */ 681.1Sgwr#define XY_SUB_FREE 0x00 /* free */ 691.1Sgwr#define XY_SUB_NORM 0x10 /* normal I/O request */ 701.3Sgwr#define XY_SUB_WAIT 0x20 /* normal I/O request in the 711.1Sgwr context of a process */ 721.1Sgwr#define XY_SUB_POLL 0x30 /* polled mode */ 731.1Sgwr#define XY_SUB_DONE 0x40 /* not active, but can't be free'd yet */ 741.1Sgwr#define XY_SUB_NOQ 0x50 /* don't queue, just submit (internal) */ 751.1Sgwr 761.1Sgwr#define XY_STATE(X) ((X) & XY_SUB_MASK) /* extract state from mode */ 771.1Sgwr#define XY_NEWSTATE(OLD, NEW) (((OLD) & ~XY_SUB_MASK) |(NEW)) /* new state */ 781.1Sgwr 791.1Sgwr 801.1Sgwr/* 811.1Sgwr * other mode data 821.1Sgwr */ 831.1Sgwr 841.1Sgwr#define XY_MODE_VERBO 0x08 /* print error messages */ 851.1Sgwr#define XY_MODE_B144 0x04 /* handling a bad144 sector */ 861.1Sgwr 871.1Sgwr 881.1Sgwr/* 891.1Sgwr * software timers and flags 901.1Sgwr */ 911.1Sgwr 921.1Sgwr#define XYC_SUBWAITLIM 4 /* max number of "done" IOPBs there can be 931.1Sgwr where we still allow a SUB_WAIT command */ 941.1Sgwr#define XYC_TICKCNT (5*hz) /* call xyc_tick on this interval (5 sec) */ 951.1Sgwr#define XYC_MAXTTL 2 /* max number of xy ticks to live */ 961.1Sgwr#define XYC_NOUNIT (-1) /* for xycmd: no unit number */ 971.1Sgwr 981.1Sgwr/* 991.1Sgwr * a "xy_softc" structure contains per-disk state info. 1001.1Sgwr */ 1011.1Sgwr 1021.1Sgwrstruct xy_softc { 1031.1Sgwr struct device sc_dev; /* device struct, reqd by autoconf */ 1041.2Sthorpej struct disk sc_dk; /* generic disk info */ 1051.1Sgwr struct xyc_softc *parent; /* parent */ 1061.1Sgwr u_short flags; /* flags */ 1071.1Sgwr u_short state; /* device state */ 1081.1Sgwr int xy_drive; /* unit number */ 1091.1Sgwr int drive_type; /* drive type (as per disk) */ 1101.1Sgwr /* geometry */ 1111.1Sgwr u_short ncyl, acyl, pcyl; /* number of cyl's */ 1121.1Sgwr u_short sectpercyl; /* nhead*nsect */ 1131.1Sgwr u_char nhead; /* number of heads */ 1141.1Sgwr u_char nsect; /* number of sectors per track */ 1151.1Sgwr u_char hw_spt; /* as above, but includes spare sectors */ 1161.1Sgwr struct xy_iorq *xyrq; /* this disk's ioreq structure */ 1171.1Sgwr struct buf xyq; /* queue'd I/O requests */ 1181.1Sgwr struct dkbad dkb; /* bad144 sectors */ 1191.1Sgwr}; 1201.1Sgwr 1211.1Sgwr/* 1221.1Sgwr * flags 1231.1Sgwr */ 1241.1Sgwr 1251.1Sgwr#define XY_WLABEL 0x0001 /* write label */ 1261.1Sgwr/* 1271.1Sgwr * state 1281.1Sgwr */ 1291.1Sgwr 1301.1Sgwr#define XY_DRIVE_UNKNOWN 0 /* never talked to it */ 1311.1Sgwr#define XY_DRIVE_ATTACHING 1 /* attach in progress */ 1321.1Sgwr#define XY_DRIVE_NOLABEL 2 /* drive on-line, no label */ 1331.1Sgwr#define XY_DRIVE_ONLINE 3 /* drive is on-line */ 1341.1Sgwr 1351.1Sgwr/* 1361.1Sgwr * a "xyc_softc" structure contains per-disk-controller state info, 1371.1Sgwr * including a list of active controllers. 1381.1Sgwr */ 1391.1Sgwr 1401.1Sgwrstruct xyc_softc { 1411.1Sgwr struct device sc_dev; /* device struct, reqd by autoconf */ 1421.1Sgwr struct evcnt sc_intrcnt; /* event counter (for vmstat -i) */ 1431.1Sgwr 1441.1Sgwr struct xyc *xyc; /* vaddr of vme registers */ 1451.1Sgwr 1461.1Sgwr struct xy_softc *sc_drives[XYC_MAXDEV]; /* drives on this controller */ 1471.1Sgwr int ipl; /* interrupt level */ 1481.1Sgwr int vector; /* interrupt vector */ 1491.1Sgwr 1501.1Sgwr struct xy_iorq *reqs; /* i/o requests */ 1511.1Sgwr struct xy_iopb *iopbase; /* iopb base addr (maps iopb->iorq) */ 1521.1Sgwr struct xy_iopb *dvmaiopb; /* iopb base in DVMA space, not kvm */ 1531.1Sgwr 1541.1Sgwr struct xy_iorq *ciorq; /* controller's iorq */ 1551.1Sgwr struct xy_iopb *ciopb; /* controller's iopb */ 1561.1Sgwr 1571.1Sgwr int xy_hand; /* hand */ 1581.1Sgwr struct xy_iorq *xy_chain[XYC_MAXIOPB]; 1591.1Sgwr /* current chain */ 1601.1Sgwr int no_ols; /* disable overlap seek for stupid 450s */ 1611.1Sgwr}; 1621.1Sgwr 1631.1Sgwr/* 1641.1Sgwr * reset blast modes 1651.1Sgwr */ 1661.1Sgwr 1671.1Sgwr#define XY_RSET_NONE (struct xy_iorq *)(-1) /* restart all requests */ 1681.1Sgwr#define XY_RSET_ALL (struct xy_iorq *)(-2) /* don't restart anything */ 169