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