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