xyvar.h revision 1.10
11.10Syamt/*	$NetBSD: xyvar.h,v 1.10 2005/10/15 17:29:26 yamt 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.6Sthorpej#include <sys/callout.h>
441.6Sthorpej
451.1Spk/*
461.1Spk * i/o request: wrapper for hardware's iopb data structure
471.1Spk */
481.1Spkstruct xy_iorq {
491.3Spk	struct xy_iopb *iopb;	/* address of matching iopb */
501.3Spk	struct xy_iopb *dmaiopb;/* DMA address of above */
511.3Spk	struct xyc_softc *xyc;	/* who we are working with */
521.3Spk	struct xy_softc *xy;	/* which disk */
531.3Spk	int ttl;		/* time to live */
541.3Spk	int mode;		/* current mode (state+other data) */
551.3Spk	int tries;		/* number of times we have tried it */
561.3Spk	int errno;		/* error number if we fail */
571.3Spk	int lasterror;		/* last error we got */
581.3Spk	int blockno;		/* starting block no for this xfer */
591.3Spk	int sectcnt;		/* number of sectors in xfer */
601.3Spk	char *dbuf;		/* KVA of data buffer (advances) */
611.3Spk	struct buf *buf;	/* for NORM */
621.3Spk	bus_dmamap_t dmamap;	/* DMA I/O handle */
631.1Spk};
641.1Spk
651.1Spk/*
661.1Spk * state
671.1Spk */
681.3Spk#define XY_SUB_MASK	0xf0	/* mask bits for state */
691.3Spk#define XY_SUB_FREE	0x00	/* free */
701.3Spk#define XY_SUB_NORM	0x10	/* normal I/O request */
711.3Spk#define XY_SUB_WAIT	0x20	/* normal I/O request in the
721.3Spk                                   context of a process */
731.3Spk#define XY_SUB_POLL	0x30	/* polled mode */
741.3Spk#define XY_SUB_DONE	0x40	/* not active, but can't be free'd yet */
751.3Spk#define XY_SUB_NOQ	0x50	/* don't queue, just submit (internal) */
761.1Spk
771.1Spk#define XY_STATE(X) ((X) & XY_SUB_MASK) /* extract state from mode */
781.1Spk#define XY_NEWSTATE(OLD, NEW) (((OLD) & ~XY_SUB_MASK) |(NEW)) /* new state */
791.1Spk
801.1Spk
811.1Spk/*
821.1Spk * other mode data
831.1Spk */
841.3Spk#define XY_MODE_VERBO	0x08	/* print error messages */
851.3Spk#define XY_MODE_B144	0x04	/* handling a bad144 sector */
861.1Spk
871.1Spk
881.1Spk/*
891.1Spk * software timers and flags
901.1Spk */
911.3Spk#define XYC_SUBWAITLIM	4	/* max number of "done" IOPBs there can be
921.3Spk				   where we still allow a SUB_WAIT command */
931.3Spk#define XYC_TICKCNT	(5*hz)	/* call xyc_tick on this interval (5 sec) */
941.3Spk#define XYC_MAXTTL	2	/* max number of xy ticks to live */
951.3Spk#define XYC_NOUNIT	(-1)	/* for xycmd: no unit number */
961.1Spk
971.1Spk/*
981.1Spk * a "xy_softc" structure contains per-disk state info.
991.1Spk */
1001.1Spkstruct xy_softc {
1011.3Spk	struct device sc_dev;	/* device struct, reqd by autoconf */
1021.3Spk	struct disk sc_dk;	/* generic disk info */
1031.3Spk	struct xyc_softc *parent;/* parent */
1041.3Spk	u_short flags;		/* flags */
1051.3Spk	u_short state;		/* device state */
1061.3Spk	int xy_drive;		/* unit number */
1071.3Spk	int drive_type;		/* drive type (as per disk) */
1081.3Spk
1091.3Spk	/* geometry */
1101.3Spk	u_short ncyl, acyl, pcyl;	/* number of cyl's */
1111.3Spk	u_short sectpercyl;	/* nhead*nsect */
1121.3Spk	u_char nhead;		/* number of heads */
1131.3Spk	u_char nsect;		/* number of sectors per track */
1141.3Spk	u_char hw_spt;		/* as above, but includes spare sectors */
1151.3Spk	struct xy_iorq *xyrq;	/* this disk's ioreq structure */
1161.10Syamt	struct bufq_state *xyq;	/* queued I/O requests */
1171.3Spk	struct dkbad dkb;	/* bad144 sectors */
1181.1Spk};
1191.1Spk
1201.1Spk/*
1211.1Spk * flags
1221.1Spk */
1231.1Spk
1241.1Spk#define XY_WLABEL 0x0001           /* write label */
1251.1Spk/*
1261.1Spk * state
1271.1Spk */
1281.1Spk
1291.1Spk#define XY_DRIVE_UNKNOWN 0         /* never talked to it */
1301.1Spk#define XY_DRIVE_ATTACHING 1       /* attach in progress */
1311.1Spk#define XY_DRIVE_NOLABEL 2         /* drive on-line, no label */
1321.1Spk#define XY_DRIVE_ONLINE  3         /* drive is on-line */
1331.1Spk
1341.1Spk/*
1351.1Spk * a "xyc_softc" structure contains per-disk-controller state info,
1361.1Spk * including a list of active controllers.
1371.1Spk */
1381.1Spk
1391.1Spkstruct xyc_softc {
1401.7Spk	struct device sc_dev;		/* device struct, reqd by autoconf */
1411.7Spk	struct evcnt sc_intrcnt;	/* event counter (for vmstat -i) */
1421.6Sthorpej
1431.6Sthorpej	struct callout sc_tick_ch;
1441.2Spk
1451.7Spk	struct xyc *xyc;		/* vaddr of vme registers */
1461.2Spk
1471.2Spk	struct xy_softc *sc_drives[XYC_MAXDEV]; /* drives on this controller */
1481.7Spk	int ipl;			/* interrupt level */
1491.7Spk	int vector;			/* interrupt vector */
1501.7Spk	bus_dma_tag_t dmatag;		/* Bus DMA tag */
1511.7Spk
1521.7Spk	struct xy_iorq *reqs;		/* i/o requests */
1531.7Spk	struct xy_iopb *iopbase;	/* iopb base addr (maps iopb->iorq) */
1541.7Spk	struct xy_iopb *dvmaiopb;	/* iopb base in DVMA space, not kvm */
1551.7Spk	bus_dmamap_t iopmap;		/* IOPB DMA handle */
1561.7Spk	bus_dmamap_t auxmap;		/* auxiliary DMA handle */
1571.1Spk
1581.7Spk	struct xy_iorq *ciorq;		/* controller's iorq */
1591.7Spk	struct xy_iopb *ciopb;		/* controller's iopb */
1601.1Spk
1611.7Spk	int xy_hand;			/* hand */
1621.2Spk	struct xy_iorq *xy_chain[XYC_MAXIOPB];
1631.7Spk					/* current chain */
1641.7Spk	int no_ols;			/* disable overlap seek for stupid 450s */
1651.1Spk};
1661.1Spk
1671.1Spk/*
1681.1Spk * reset blast modes
1691.1Spk */
1701.1Spk
1711.1Spk#define XY_RSET_NONE (struct xy_iorq *)(-1)   /* restart all requests */
1721.1Spk#define XY_RSET_ALL  (struct xy_iorq *)(-2)   /* don't restart anything */
173