Home | History | Annotate | Line # | Download | only in vme
xdvar.h revision 1.11
      1  1.11  christos /*	$NetBSD: xdvar.h,v 1.11 2006/08/27 19:18:08 christos Exp $	*/
      2   1.1        pk 
      3   1.1        pk /*
      4   1.1        pk  *
      5   1.1        pk  * Copyright (c) 1995 Charles D. Cranor
      6   1.1        pk  * All rights reserved.
      7   1.1        pk  *
      8   1.1        pk  * Redistribution and use in source and binary forms, with or without
      9   1.1        pk  * modification, are permitted provided that the following conditions
     10   1.1        pk  * are met:
     11   1.1        pk  * 1. Redistributions of source code must retain the above copyright
     12   1.1        pk  *    notice, this list of conditions and the following disclaimer.
     13   1.1        pk  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1        pk  *    notice, this list of conditions and the following disclaimer in the
     15   1.1        pk  *    documentation and/or other materials provided with the distribution.
     16   1.1        pk  * 3. All advertising materials mentioning features or use of this software
     17   1.1        pk  *    must display the following acknowledgement:
     18   1.1        pk  *      This product includes software developed by Charles D. Cranor.
     19   1.1        pk  * 4. The name of the author may not be used to endorse or promote products
     20   1.1        pk  *    derived from this software without specific prior written permission.
     21   1.1        pk  *
     22   1.1        pk  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23   1.1        pk  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24   1.1        pk  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25   1.1        pk  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26   1.1        pk  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27   1.1        pk  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28   1.1        pk  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29   1.1        pk  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30   1.1        pk  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31   1.1        pk  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32   1.1        pk  */
     33   1.1        pk 
     34   1.1        pk /*
     35   1.1        pk  * x d v a r . h
     36   1.1        pk  *
     37   1.1        pk  * this file defines the software structure we use to control the
     38   1.1        pk  * 753/7053.
     39   1.1        pk  *
     40   1.1        pk  * author: Chuck Cranor <chuck (at) ccrc.wustl.edu>
     41   1.1        pk  */
     42   1.1        pk 
     43   1.5   thorpej #include <sys/callout.h>
     44   1.5   thorpej 
     45   1.1        pk /*
     46   1.1        pk  * i/o request: wrapper for hardware's iopb data structure
     47   1.1        pk  */
     48   1.1        pk 
     49   1.1        pk struct xd_iorq {
     50   1.1        pk 	struct xd_iopb *iopb;		/* address of matching iopb */
     51   1.3        pk 	struct xd_iopb *dmaiopb;	/* DMA address of above */
     52   1.1        pk 	struct xdc_softc *xdc;		/* who we are working with */
     53   1.1        pk 	struct xd_softc *xd;		/* which disk */
     54   1.1        pk 	int ttl;			/* time to live */
     55   1.1        pk 	int mode;			/* current mode (state+other data) */
     56   1.1        pk 	int tries;			/* number of times we have tried it */
     57  1.11  christos 	int errnum;			/* error number if we fail */
     58   1.1        pk 	int lasterror;			/* last error we got */
     59   1.1        pk 	int blockno;			/* starting block no for this xfer */
     60   1.1        pk 	int sectcnt;			/* number of sectors in xfer */
     61   1.1        pk 	char *dbuf;			/* KVA of data buffer (advances) */
     62   1.1        pk 	struct buf *buf;		/* for NORM */
     63   1.2        pk 	bus_dmamap_t dmamap;		/* DMA I/O handle */
     64   1.1        pk };
     65   1.1        pk 
     66   1.1        pk /*
     67   1.1        pk  * state
     68   1.1        pk  */
     69   1.1        pk 
     70   1.1        pk #define XD_SUB_MASK 0xf0            /* mask bits for state */
     71   1.1        pk #define XD_SUB_FREE 0x00            /* free */
     72   1.1        pk #define XD_SUB_NORM 0x10            /* normal I/O request */
     73   1.1        pk #define XD_SUB_WAIT 0x20            /* normal I/O request in the
     74   1.1        pk                                              context of a process */
     75   1.1        pk #define XD_SUB_POLL 0x30            /* polled mode */
     76   1.1        pk #define XD_SUB_DONE 0x40            /* not active, but can't be free'd yet */
     77   1.1        pk #define XD_SUB_NOQ  0x50            /* don't queue, just submit (internal) */
     78   1.1        pk 
     79   1.1        pk #define XD_STATE(X) ((X) & XD_SUB_MASK) /* extract state from mode */
     80   1.1        pk #define XD_NEWSTATE(OLD, NEW) (((OLD) & ~XD_SUB_MASK) |(NEW)) /* new state */
     81   1.1        pk 
     82   1.1        pk 
     83   1.1        pk /*
     84   1.1        pk  * other mode data
     85   1.1        pk  */
     86   1.1        pk 
     87   1.1        pk #define XD_MODE_VERBO 0x08          /* print error messages */
     88   1.1        pk #define XD_MODE_B144  0x04          /* handling a bad144 sector */
     89   1.1        pk 
     90   1.1        pk 
     91   1.1        pk /*
     92   1.1        pk  * software timers and flags
     93   1.1        pk  */
     94   1.1        pk 
     95   1.1        pk #define XDC_SUBWAITLIM	4	/* max number of "done" IOPBs there can be
     96   1.1        pk 				   where we still allow a SUB_WAIT command */
     97   1.1        pk #define XDC_TICKCNT	(5*hz)	/* call xdc_tick on this interval (5 sec) */
     98   1.1        pk #define XDC_MAXTTL	2	/* max number of xd ticks to live */
     99   1.1        pk #define XDC_NOUNIT	(-1)	/* for xdcmd: no unit number */
    100   1.1        pk 
    101   1.1        pk /*
    102   1.1        pk  * a "xd_softc" structure contains per-disk state info.
    103   1.1        pk  */
    104   1.1        pk 
    105   1.1        pk struct xd_softc {
    106   1.1        pk 	struct device sc_dev;		/* device struct, reqd by autoconf */
    107   1.1        pk 	struct disk sc_dk;		/* generic disk info */
    108   1.1        pk 	struct xdc_softc *parent;	/* parent */
    109   1.1        pk 	u_short flags;			/* flags */
    110   1.1        pk 	u_short state;			/* device state */
    111   1.1        pk 	int xd_drive;			/* unit number */
    112   1.1        pk 	/* geometry */
    113   1.1        pk 	u_short ncyl, acyl, pcyl;	/* number of cyl's */
    114   1.1        pk 	u_short sectpercyl;		/* nhead*nsect */
    115   1.1        pk 	u_char nhead;			/* number of heads */
    116   1.1        pk 	u_char nsect;			/* number of sectors per track */
    117   1.1        pk 	u_char hw_spt;			/* as above, but includes spare sectors */
    118   1.1        pk 	struct dkbad dkb;		/* bad144 sectors */
    119   1.1        pk };
    120   1.1        pk 
    121   1.1        pk /*
    122   1.1        pk  * flags
    123   1.1        pk  */
    124   1.1        pk #define XD_WLABEL 0x0001           /* write label */
    125   1.1        pk 
    126   1.1        pk /*
    127   1.1        pk  * state
    128   1.1        pk  */
    129   1.1        pk #define XD_DRIVE_UNKNOWN 0         /* never talked to it */
    130   1.1        pk #define XD_DRIVE_ATTACHING 1       /* attach in progress */
    131   1.1        pk #define XD_DRIVE_NOLABEL 2         /* drive on-line, no label */
    132   1.1        pk #define XD_DRIVE_ONLINE  3         /* drive is on-line */
    133   1.1        pk 
    134   1.1        pk /*
    135   1.1        pk  * a "xdc_softc" structure contains per-disk-controller state info,
    136   1.1        pk  * including a list of active controllers.
    137   1.1        pk  */
    138   1.1        pk 
    139   1.1        pk struct xdc_softc {
    140   1.1        pk 	struct device sc_dev;		/* device struct, reqd by autoconf */
    141   1.1        pk 	struct evcnt sc_intrcnt;	/* event counter (for vmstat -i) */
    142   1.5   thorpej 
    143   1.5   thorpej 	struct callout sc_tick_ch;
    144   1.1        pk 
    145   1.1        pk 	struct xdc *xdc;		/* vaddr of vme registers */
    146   1.1        pk 
    147   1.1        pk 	struct xd_softc *sc_drives[XDC_MAXDEV]; /* drives on this controller */
    148   1.1        pk 	int ipl;			/* interrupt level */
    149   1.1        pk 	int vector;			/* interrupt vector */
    150   1.2        pk 	bus_dma_tag_t dmatag;		/* Bus DMA tag */
    151   1.1        pk 
    152   1.1        pk 	struct xd_iorq *reqs;		/* i/o requests */
    153   1.1        pk 	struct xd_iopb *iopbase;	/* iopb base addr (maps iopb->iorq) */
    154   1.1        pk 	struct xd_iopb *dvmaiopb;	/* iopb base in DVMA space, not kvm */
    155   1.6        pk 	bus_dmamap_t iopmap;		/* IOPB DMA handle */
    156   1.6        pk 	bus_dmamap_t auxmap;		/* auxiliary DMA handle */
    157   1.9      yamt 	struct bufq_state *sc_wq;	/* queued IOPBs for this controller */
    158   1.1        pk 	char freereq[XDC_MAXIOPB];	/* free list (stack) */
    159   1.1        pk 	char waitq[XDC_MAXIOPB];	/* wait queue */
    160   1.1        pk 	u_char nfree;			/* number of iopbs free */
    161   1.1        pk 	u_char nrun;			/* number running */
    162   1.1        pk 	u_char nwait;			/* number of waiting iopbs */
    163   1.1        pk 	u_char ndone;			/* number of done IORQs */
    164   1.1        pk 	u_char waithead;		/* head of queue */
    165   1.1        pk 	u_char waitend;			/* end of queue */
    166   1.1        pk };
    167   1.1        pk 
    168   1.1        pk /*
    169   1.1        pk  * reset blast modes
    170   1.1        pk  */
    171   1.1        pk 
    172   1.1        pk #define XD_RSET_NONE (-1)          /* restart all requests */
    173   1.1        pk #define XD_RSET_ALL  (-2)          /* don't restart anything */
    174