xyvar.h revision 1.2
11.2Spk/*	$NetBSD: xyvar.h,v 1.2 1997/12/01 23:25:37 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.1Spk
471.1Spkstruct xy_iorq {
481.1Spk  struct xy_iopb *iopb;             /* address of matching iopb */
491.1Spk  struct xyc_softc *xyc;            /* who we are working with */
501.1Spk  struct xy_softc *xy;              /* which disk */
511.1Spk  int ttl;                          /* time to live */
521.1Spk  int mode;                         /* current mode (state+other data) */
531.1Spk  int tries;                        /* number of times we have tried it */
541.1Spk  int errno;                        /* error number if we fail */
551.1Spk  int lasterror;		    /* last error we got */
561.1Spk  int blockno;                      /* starting block no for this xfer */
571.1Spk  int sectcnt;                      /* number of sectors in xfer */
581.1Spk  char *dbuf;                       /* KVA of data buffer (advances) */
591.1Spk  struct buf *buf;                  /* for NORM */
601.2Spk  bus_dmamap_t dmamap;		    /* DMA I/O handle */
611.1Spk};
621.1Spk
631.1Spk/*
641.1Spk * state
651.1Spk */
661.1Spk
671.1Spk#define XY_SUB_MASK 0xf0            /* mask bits for state */
681.1Spk#define XY_SUB_FREE 0x00            /* free */
691.1Spk#define XY_SUB_NORM 0x10            /* normal I/O request */
701.1Spk#define XY_SUB_WAIT 0x20            /* normal I/O request in the
711.1Spk                                             context of a process */
721.1Spk#define XY_SUB_POLL 0x30            /* polled mode */
731.1Spk#define XY_SUB_DONE 0x40            /* not active, but can't be free'd yet */
741.1Spk#define XY_SUB_NOQ  0x50            /* don't queue, just submit (internal) */
751.1Spk
761.1Spk#define XY_STATE(X) ((X) & XY_SUB_MASK) /* extract state from mode */
771.1Spk#define XY_NEWSTATE(OLD, NEW) (((OLD) & ~XY_SUB_MASK) |(NEW)) /* new state */
781.1Spk
791.1Spk
801.1Spk/*
811.1Spk * other mode data
821.1Spk */
831.1Spk
841.1Spk#define XY_MODE_VERBO 0x08          /* print error messages */
851.1Spk#define XY_MODE_B144  0x04          /* handling a bad144 sector */
861.1Spk
871.1Spk
881.1Spk/*
891.1Spk * software timers and flags
901.1Spk */
911.1Spk
921.1Spk#define XYC_SUBWAITLIM 4   /* max number of "done" IOPBs there can be
931.1Spk				where we still allow a SUB_WAIT command */
941.1Spk#define XYC_TICKCNT (5*hz) /* call xyc_tick on this interval (5 sec) */
951.1Spk#define XYC_MAXTTL     2   /* max number of xy ticks to live */
961.1Spk#define XYC_NOUNIT (-1)    /* for xycmd: no unit number */
971.1Spk
981.1Spk/*
991.1Spk * a "xy_softc" structure contains per-disk state info.
1001.1Spk */
1011.1Spk
1021.1Spkstruct xy_softc {
1031.1Spk  struct device sc_dev;            /* device struct, reqd by autoconf */
1041.1Spk  struct disk sc_dk;               /* generic disk info */
1051.1Spk  struct xyc_softc *parent;        /* parent */
1061.1Spk  u_short flags;                   /* flags */
1071.1Spk  u_short state;                   /* device state */
1081.1Spk  int xy_drive;                    /* unit number */
1091.1Spk  int drive_type;		   /* drive type (as per disk) */
1101.1Spk  /* geometry */
1111.1Spk  u_short ncyl, acyl, pcyl;        /* number of cyl's */
1121.1Spk  u_short sectpercyl;              /* nhead*nsect */
1131.1Spk  u_char nhead;                    /* number of heads */
1141.1Spk  u_char nsect;                    /* number of sectors per track */
1151.1Spk  u_char hw_spt;                   /* as above, but includes spare sectors */
1161.1Spk  struct xy_iorq *xyrq;		   /* this disk's ioreq structure */
1171.1Spk  struct buf xyq;		   /* queue'd I/O requests */
1181.1Spk  struct dkbad dkb;                /* bad144 sectors */
1191.1Spk};
1201.1Spk
1211.1Spk/*
1221.1Spk * flags
1231.1Spk */
1241.1Spk
1251.1Spk#define XY_WLABEL 0x0001           /* write label */
1261.1Spk/*
1271.1Spk * state
1281.1Spk */
1291.1Spk
1301.1Spk#define XY_DRIVE_UNKNOWN 0         /* never talked to it */
1311.1Spk#define XY_DRIVE_ATTACHING 1       /* attach in progress */
1321.1Spk#define XY_DRIVE_NOLABEL 2         /* drive on-line, no label */
1331.1Spk#define XY_DRIVE_ONLINE  3         /* drive is on-line */
1341.1Spk
1351.1Spk/*
1361.1Spk * a "xyc_softc" structure contains per-disk-controller state info,
1371.1Spk * including a list of active controllers.
1381.1Spk */
1391.1Spk
1401.1Spkstruct xyc_softc {
1411.2Spk	struct device sc_dev;            /* device struct, reqd by autoconf */
1421.2Spk	struct intrhand sc_ih;           /* interrupt info */
1431.2Spk	struct evcnt sc_intrcnt;         /* event counter (for vmstat -i) */
1441.2Spk
1451.2Spk	struct xyc *xyc;                 /* vaddr of vme registers */
1461.2Spk
1471.2Spk	struct xy_softc *sc_drives[XYC_MAXDEV]; /* drives on this controller */
1481.2Spk	int ipl;                         /* interrupt level */
1491.2Spk	int vector;                      /* interrupt vector */
1501.2Spk	bus_dma_tag_t dmatag;	 	 /* Bus DMA tag */
1511.2Spk
1521.2Spk	struct xy_iorq *reqs;            /* i/o requests */
1531.2Spk	struct xy_iopb *iopbase;         /* iopb base addr (maps iopb->iorq) */
1541.2Spk	struct xy_iopb *dvmaiopb;        /* iopb base in DVMA space, not kvm */
1551.1Spk
1561.2Spk	struct xy_iorq *ciorq;		 /* controller's iorq */
1571.2Spk	struct xy_iopb *ciopb;		 /* controller's iopb */
1581.1Spk
1591.2Spk	int xy_hand;			 /* hand */
1601.2Spk	struct xy_iorq *xy_chain[XYC_MAXIOPB];
1611.1Spk				   /* current chain */
1621.2Spk	int no_ols;		   /* disable overlap seek for stupid 450s */
1631.1Spk};
1641.1Spk
1651.1Spk/*
1661.1Spk * reset blast modes
1671.1Spk */
1681.1Spk
1691.1Spk#define XY_RSET_NONE (struct xy_iorq *)(-1)   /* restart all requests */
1701.1Spk#define XY_RSET_ALL  (struct xy_iorq *)(-2)   /* don't restart anything */
171