1 /* $OpenBSD: xyvar.h,v 1.5 2001/03/24 10:07:22 ho Exp $ */ 2 /* $NetBSD: xyvar.h,v 1.4 1996/03/31 22:39:04 pk Exp $ */ 3 4 /* 5 * 6 * Copyright (c) 1995 Charles D. Cranor 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by Charles D. Cranor. 20 * 4. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 /* 36 * x y v a r . h 37 * 38 * this file defines the software structure we use to control the 39 * 450/451. 40 * 41 * author: Chuck Cranor <chuck@ccrc.wustl.edu> 42 */ 43 44 /* 45 * i/o request: wrapper for hardware's iopb data structure 46 */ 47 48 struct xy_iorq { 49 struct xy_iopb *iopb; /* address of matching iopb */ 50 struct xyc_softc *xyc; /* who we are working with */ 51 struct xy_softc *xy; /* which disk */ 52 int ttl; /* time to live */ 53 int mode; /* current mode (state+other data) */ 54 int tries; /* number of times we have tried it */ 55 int errno; /* error number if we fail */ 56 int lasterror; /* last error we got */ 57 int blockno; /* starting block no for this xfer */ 58 int sectcnt; /* number of sectors in xfer */ 59 char *dbuf; /* KVA of data buffer (advances) */ 60 char *dbufbase; /* base of dbuf */ 61 struct buf *buf; /* for NORM */ 62 }; 63 64 /* 65 * state 66 */ 67 68 #define XY_SUB_MASK 0xf0 /* mask bits for state */ 69 #define XY_SUB_FREE 0x00 /* free */ 70 #define XY_SUB_NORM 0x10 /* normal I/O request */ 71 #define XY_SUB_WAIT 0x20 /* normal I/O request in the 72 context of a process */ 73 #define XY_SUB_POLL 0x30 /* polled mode */ 74 #define XY_SUB_DONE 0x40 /* not active, but can't be free'd yet */ 75 #define XY_SUB_NOQ 0x50 /* don't queue, just submit (internal) */ 76 77 #define XY_STATE(X) ((X) & XY_SUB_MASK) /* extract state from mode */ 78 #define XY_NEWSTATE(OLD, NEW) (((OLD) & ~XY_SUB_MASK) |(NEW)) /* new state */ 79 80 81 /* 82 * other mode data 83 */ 84 85 #define XY_MODE_VERBO 0x08 /* print error messages */ 86 #define XY_MODE_B144 0x04 /* handling a bad144 sector */ 87 88 89 /* 90 * software timers and flags 91 */ 92 93 #define XYC_SUBWAITLIM 4 /* max number of "done" IOPBs there can be 94 where we still allow a SUB_WAIT command */ 95 #define XYC_TICKCNT (5*hz) /* call xyc_tick on this interval (5 sec) */ 96 #define XYC_MAXTTL 2 /* max number of xy ticks to live */ 97 #define XYC_NOUNIT (-1) /* for xycmd: no unit number */ 98 99 /* 100 * a "xy_softc" structure contains per-disk state info. 101 */ 102 103 struct xy_softc { 104 struct device sc_dev; /* device struct, reqd by autoconf */ 105 struct disk sc_dk; /* generic disk info */ 106 struct xyc_softc *parent; /* parent */ 107 u_short flags; /* flags */ 108 u_short state; /* device state */ 109 int xy_drive; /* unit number */ 110 int drive_type; /* drive type (as per disk) */ 111 /* geometry */ 112 u_short ncyl, acyl, pcyl; /* number of cyl's */ 113 u_short sectpercyl; /* nhead*nsect */ 114 u_char nhead; /* number of heads */ 115 u_char nsect; /* number of sectors per track */ 116 u_char hw_spt; /* as above, but includes spare sectors */ 117 struct xy_iorq *xyrq; /* this disk's ioreq structure */ 118 struct buf xyq; /* queue'd I/O requests */ 119 struct dkbad dkb; /* bad144 sectors */ 120 }; 121 122 /* 123 * flags 124 */ 125 126 #define XY_WLABEL 0x0001 /* write label */ 127 /* 128 * state 129 */ 130 131 #define XY_DRIVE_UNKNOWN 0 /* never talked to it */ 132 #define XY_DRIVE_ATTACHING 1 /* attach in progress */ 133 #define XY_DRIVE_NOLABEL 2 /* drive on-line, no label */ 134 #define XY_DRIVE_ONLINE 3 /* drive is on-line */ 135 136 /* 137 * a "xyc_softc" structure contains per-disk-controller state info, 138 * including a list of active controllers. 139 */ 140 141 struct xyc_softc { 142 struct device sc_dev; /* device struct, reqd by autoconf */ 143 struct intrhand sc_ih; /* interrupt info */ 144 struct evcnt sc_intrcnt; /* event counter (for vmstat -i) */ 145 146 struct xyc *xyc; /* vaddr of vme registers */ 147 148 struct xy_softc *sc_drives[XYC_MAXDEV]; /* drives on this controller */ 149 int ipl; /* interrupt level */ 150 int vector; /* interrupt vector */ 151 152 struct xy_iorq *reqs; /* i/o requests */ 153 struct xy_iopb *iopbase; /* iopb base addr (maps iopb->iorq) */ 154 struct xy_iopb *dvmaiopb; /* iopb base in DVMA space, not kvm */ 155 156 struct xy_iorq *ciorq; /* controller's iorq */ 157 struct xy_iopb *ciopb; /* controller's iopb */ 158 159 int xy_hand; /* hand */ 160 struct xy_iorq *xy_chain[XYC_MAXIOPB]; 161 /* current chain */ 162 int no_ols; /* disable overlap seek for stupid 450s */ 163 struct timeout xyc_tick_tmo; /* for xyc_tick() */ 164 }; 165 166 /* 167 * reset blast modes 168 */ 169 170 #define XY_RSET_NONE (struct xy_iorq *)(-1) /* restart all requests */ 171 #define XY_RSET_ALL (struct xy_iorq *)(-2) /* don't restart anything */ 172