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