xyvar.h revision 1.10
11.10Stsutsui/* $NetBSD: xyvar.h,v 1.10 2008/06/28 12:13:38 tsutsui Exp $ */
21.1Sgwr
31.1Sgwr/*
41.1Sgwr *
51.1Sgwr * Copyright (c) 1995 Charles D. Cranor
61.1Sgwr * All rights reserved.
71.1Sgwr *
81.1Sgwr * Redistribution and use in source and binary forms, with or without
91.1Sgwr * modification, are permitted provided that the following conditions
101.1Sgwr * are met:
111.1Sgwr * 1. Redistributions of source code must retain the above copyright
121.1Sgwr *    notice, this list of conditions and the following disclaimer.
131.1Sgwr * 2. Redistributions in binary form must reproduce the above copyright
141.1Sgwr *    notice, this list of conditions and the following disclaimer in the
151.1Sgwr *    documentation and/or other materials provided with the distribution.
161.1Sgwr * 3. All advertising materials mentioning features or use of this software
171.1Sgwr *    must display the following acknowledgement:
181.1Sgwr *      This product includes software developed by Charles D. Cranor.
191.1Sgwr * 4. The name of the author may not be used to endorse or promote products
201.1Sgwr *    derived from this software without specific prior written permission.
211.1Sgwr *
221.1Sgwr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231.1Sgwr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
241.1Sgwr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
251.1Sgwr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261.1Sgwr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
271.1Sgwr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
281.1Sgwr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
291.1Sgwr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
301.1Sgwr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
311.1Sgwr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
321.1Sgwr */
331.1Sgwr
341.1Sgwr/*
351.3Sgwr * x y v a r . h
361.1Sgwr *
371.3Sgwr * this file defines the software structure we use to control the
381.1Sgwr * 450/451.
391.1Sgwr *
401.1Sgwr * author: Chuck Cranor <chuck@ccrc.wustl.edu>
411.1Sgwr */
421.1Sgwr
431.6Sthorpej#include <sys/callout.h>
441.6Sthorpej
451.1Sgwr/*
461.1Sgwr * i/o request: wrapper for hardware's iopb data structure
471.1Sgwr */
481.1Sgwr
491.1Sgwrstruct xy_iorq {
501.10Stsutsui	struct xy_iopb *iopb;		/* address of matching iopb */
511.10Stsutsui	struct xyc_softc *xyc;		/* who we are working with */
521.10Stsutsui	struct xy_softc *xy;		/* which disk */
531.10Stsutsui	int ttl;			/* time to live */
541.10Stsutsui	int mode;			/* current mode (state+other data) */
551.10Stsutsui	int tries;			/* number of times we have tried it */
561.10Stsutsui	int errno;			/* error number if we fail */
571.10Stsutsui	int lasterror;			/* last error we got */
581.10Stsutsui	int blockno;			/* starting block no for this xfer */
591.10Stsutsui	int sectcnt;			/* number of sectors in xfer */
601.10Stsutsui	char *dbuf;			/* KVA of data buffer (advances) */
611.10Stsutsui	char *dbufbase;			/* base of dbuf */
621.10Stsutsui	struct buf *buf;		/* for NORM */
631.1Sgwr};
641.1Sgwr
651.1Sgwr/*
661.1Sgwr * state
671.1Sgwr */
681.1Sgwr
691.10Stsutsui#define XY_SUB_MASK	0xf0	/* mask bits for state */
701.10Stsutsui#define XY_SUB_FREE	0x00	/* free */
711.10Stsutsui#define XY_SUB_NORM	0x10	/* normal I/O request */
721.10Stsutsui#define XY_SUB_WAIT	0x20	/* normal I/O request in the
731.10Stsutsui				   context of a process */
741.10Stsutsui#define XY_SUB_POLL	0x30	/* polled mode */
751.10Stsutsui#define XY_SUB_DONE	0x40	/* not active, but can't be free'd yet */
761.10Stsutsui#define XY_SUB_NOQ	0x50	/* don't queue, just submit (internal) */
771.1Sgwr
781.1Sgwr#define XY_STATE(X) ((X) & XY_SUB_MASK) /* extract state from mode */
791.1Sgwr#define XY_NEWSTATE(OLD, NEW) (((OLD) & ~XY_SUB_MASK) |(NEW)) /* new state */
801.1Sgwr
811.1Sgwr
821.1Sgwr/*
831.1Sgwr * other mode data
841.1Sgwr */
851.1Sgwr
861.10Stsutsui#define XY_MODE_VERBO	0x08	/* print error messages */
871.10Stsutsui#define XY_MODE_B144	0x04	/* handling a bad144 sector */
881.1Sgwr
891.1Sgwr
901.1Sgwr/*
911.1Sgwr * software timers and flags
921.1Sgwr */
931.1Sgwr
941.10Stsutsui#define XYC_SUBWAITLIM	4	/* max number of "done" IOPBs there can be
951.10Stsutsui				   where we still allow a SUB_WAIT command */
961.10Stsutsui#define XYC_TICKCNT	(5*hz)	/* call xyc_tick on this interval (5 sec) */
971.10Stsutsui#define XYC_MAXTTL	2	/* max number of xy ticks to live */
981.10Stsutsui#define XYC_NOUNIT	(-1)	/* for xycmd: no unit number */
991.1Sgwr
1001.1Sgwr/*
1011.1Sgwr * a "xy_softc" structure contains per-disk state info.
1021.1Sgwr */
1031.1Sgwr
1041.1Sgwrstruct xy_softc {
1051.10Stsutsui	device_t sc_dev;		/* device struct, reqd by autoconf */
1061.10Stsutsui	struct disk sc_dk;		/* generic disk info */
1071.10Stsutsui	struct xyc_softc *parent;	/* parent */
1081.10Stsutsui	u_short flags;			/* flags */
1091.10Stsutsui	u_short state;			/* device state */
1101.10Stsutsui	int xy_drive;			/* unit number */
1111.10Stsutsui	int drive_type;			/* drive type (as per disk) */
1121.10Stsutsui	/* geometry */
1131.10Stsutsui	u_short ncyl, acyl, pcyl;	/* number of cyl's */
1141.10Stsutsui	u_short sectpercyl;		/* nhead*nsect */
1151.10Stsutsui	u_char nhead;			/* number of heads */
1161.10Stsutsui	u_char nsect;			/* number of sectors per track */
1171.10Stsutsui	u_char hw_spt;		      /* as above, but includes spare sectors */
1181.10Stsutsui	struct xy_iorq *xyrq;		/* this disk's ioreq structure */
1191.10Stsutsui	struct bufq_state *xyq;		/* queue'd I/O requests */
1201.10Stsutsui	struct dkbad dkb;		/* bad144 sectors */
1211.1Sgwr};
1221.1Sgwr
1231.1Sgwr/*
1241.1Sgwr * flags
1251.1Sgwr */
1261.1Sgwr
1271.10Stsutsui#define XY_WLABEL	0x0001	/* write label */
1281.1Sgwr/*
1291.1Sgwr * state
1301.1Sgwr */
1311.1Sgwr
1321.10Stsutsui#define XY_DRIVE_UNKNOWN	0	/* never talked to it */
1331.10Stsutsui#define XY_DRIVE_ATTACHING	1	/* attach in progress */
1341.10Stsutsui#define XY_DRIVE_NOLABEL	2	/* drive on-line, no label */
1351.10Stsutsui#define XY_DRIVE_ONLINE		3	/* drive is on-line */
1361.1Sgwr
1371.1Sgwr/*
1381.1Sgwr * a "xyc_softc" structure contains per-disk-controller state info,
1391.1Sgwr * including a list of active controllers.
1401.1Sgwr */
1411.1Sgwr
1421.1Sgwrstruct xyc_softc {
1431.10Stsutsui	device_t sc_dev;		/* device struct, reqd by autoconf */
1441.10Stsutsui	struct evcnt sc_intrcnt;	/* event counter (for vmstat -i) */
1451.6Sthorpej
1461.10Stsutsui	struct callout sc_tick_ch;
1471.1Sgwr
1481.10Stsutsui	struct xyc *xyc;		/* vaddr of vme registers */
1491.1Sgwr
1501.10Stsutsui	int bustype;			/* from attach args */
1511.10Stsutsui	int ipl;			/* interrupt level */
1521.10Stsutsui	int vector;			/* interrupt vector */
1531.4Sgwr
1541.10Stsutsui	struct xy_softc *sc_drives[XYC_MAXDEV]; /* drives on this controller */
1551.1Sgwr
1561.10Stsutsui	struct xy_iorq *reqs;		/* i/o requests */
1571.10Stsutsui	struct xy_iopb *iopbase;	/* iopb base addr (maps iopb->iorq) */
1581.10Stsutsui	struct xy_iopb *dvmaiopb;	/* iopb base in DVMA space, not kvm */
1591.1Sgwr
1601.10Stsutsui	struct xy_iorq *ciorq;		/* controller's iorq */
1611.10Stsutsui	struct xy_iopb *ciopb;		/* controller's iopb */
1621.1Sgwr
1631.10Stsutsui	int xy_hand;			/* hand */
1641.10Stsutsui	struct xy_iorq *xy_chain[XYC_MAXIOPB]; /* current chain */
1651.10Stsutsui	int no_ols;		      /* disable overlap seek for stupid 450s */
1661.1Sgwr};
1671.1Sgwr
1681.1Sgwr/*
1691.1Sgwr * reset blast modes
1701.1Sgwr */
1711.1Sgwr
1721.10Stsutsui#define XY_RSET_NONE	(struct xy_iorq *)(-1)	/* restart all requests */
1731.10Stsutsui#define XY_RSET_ALL	(struct xy_iorq *)(-2)	/* don't restart anything */
174