xyvar.h revision 1.11
1/* $NetBSD: xyvar.h,v 1.11 2011/02/01 20:19:32 chuck Exp $ */
2
3/*
4 * Copyright (c) 1995 Charles D. Cranor
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28/*
29 * x y v a r . h
30 *
31 * this file defines the software structure we use to control the
32 * 450/451.
33 *
34 * author: Chuck Cranor <chuck@netbsd>
35 */
36
37#include <sys/callout.h>
38
39/*
40 * i/o request: wrapper for hardware's iopb data structure
41 */
42
43struct xy_iorq {
44	struct xy_iopb *iopb;		/* address of matching iopb */
45	struct xyc_softc *xyc;		/* who we are working with */
46	struct xy_softc *xy;		/* which disk */
47	int ttl;			/* time to live */
48	int mode;			/* current mode (state+other data) */
49	int tries;			/* number of times we have tried it */
50	int errno;			/* error number if we fail */
51	int lasterror;			/* last error we got */
52	int blockno;			/* starting block no for this xfer */
53	int sectcnt;			/* number of sectors in xfer */
54	char *dbuf;			/* KVA of data buffer (advances) */
55	char *dbufbase;			/* base of dbuf */
56	struct buf *buf;		/* for NORM */
57};
58
59/*
60 * state
61 */
62
63#define XY_SUB_MASK	0xf0	/* mask bits for state */
64#define XY_SUB_FREE	0x00	/* free */
65#define XY_SUB_NORM	0x10	/* normal I/O request */
66#define XY_SUB_WAIT	0x20	/* normal I/O request in the
67				   context of a process */
68#define XY_SUB_POLL	0x30	/* polled mode */
69#define XY_SUB_DONE	0x40	/* not active, but can't be free'd yet */
70#define XY_SUB_NOQ	0x50	/* don't queue, just submit (internal) */
71
72#define XY_STATE(X) ((X) & XY_SUB_MASK) /* extract state from mode */
73#define XY_NEWSTATE(OLD, NEW) (((OLD) & ~XY_SUB_MASK) |(NEW)) /* new state */
74
75
76/*
77 * other mode data
78 */
79
80#define XY_MODE_VERBO	0x08	/* print error messages */
81#define XY_MODE_B144	0x04	/* handling a bad144 sector */
82
83
84/*
85 * software timers and flags
86 */
87
88#define XYC_SUBWAITLIM	4	/* max number of "done" IOPBs there can be
89				   where we still allow a SUB_WAIT command */
90#define XYC_TICKCNT	(5*hz)	/* call xyc_tick on this interval (5 sec) */
91#define XYC_MAXTTL	2	/* max number of xy ticks to live */
92#define XYC_NOUNIT	(-1)	/* for xycmd: no unit number */
93
94/*
95 * a "xy_softc" structure contains per-disk state info.
96 */
97
98struct xy_softc {
99	device_t sc_dev;		/* device struct, reqd by autoconf */
100	struct disk sc_dk;		/* generic disk info */
101	struct xyc_softc *parent;	/* parent */
102	u_short flags;			/* flags */
103	u_short state;			/* device state */
104	int xy_drive;			/* unit number */
105	int drive_type;			/* drive type (as per disk) */
106	/* geometry */
107	u_short ncyl, acyl, pcyl;	/* number of cyl's */
108	u_short sectpercyl;		/* nhead*nsect */
109	u_char nhead;			/* number of heads */
110	u_char nsect;			/* number of sectors per track */
111	u_char hw_spt;		      /* as above, but includes spare sectors */
112	struct xy_iorq *xyrq;		/* this disk's ioreq structure */
113	struct bufq_state *xyq;		/* queue'd I/O requests */
114	struct dkbad dkb;		/* bad144 sectors */
115};
116
117/*
118 * flags
119 */
120
121#define XY_WLABEL	0x0001	/* write label */
122/*
123 * state
124 */
125
126#define XY_DRIVE_UNKNOWN	0	/* never talked to it */
127#define XY_DRIVE_ATTACHING	1	/* attach in progress */
128#define XY_DRIVE_NOLABEL	2	/* drive on-line, no label */
129#define XY_DRIVE_ONLINE		3	/* drive is on-line */
130
131/*
132 * a "xyc_softc" structure contains per-disk-controller state info,
133 * including a list of active controllers.
134 */
135
136struct xyc_softc {
137	device_t sc_dev;		/* device struct, reqd by autoconf */
138	struct evcnt sc_intrcnt;	/* event counter (for vmstat -i) */
139
140	struct callout sc_tick_ch;
141
142	struct xyc *xyc;		/* vaddr of vme registers */
143
144	int bustype;			/* from attach args */
145	int ipl;			/* interrupt level */
146	int vector;			/* interrupt vector */
147
148	struct xy_softc *sc_drives[XYC_MAXDEV]; /* drives on this controller */
149
150	struct xy_iorq *reqs;		/* i/o requests */
151	struct xy_iopb *iopbase;	/* iopb base addr (maps iopb->iorq) */
152	struct xy_iopb *dvmaiopb;	/* iopb base in DVMA space, not kvm */
153
154	struct xy_iorq *ciorq;		/* controller's iorq */
155	struct xy_iopb *ciopb;		/* controller's iopb */
156
157	int xy_hand;			/* hand */
158	struct xy_iorq *xy_chain[XYC_MAXIOPB]; /* current chain */
159	int no_ols;		      /* disable overlap seek for stupid 450s */
160};
161
162/*
163 * reset blast modes
164 */
165
166#define XY_RSET_NONE	(struct xy_iorq *)(-1)	/* restart all requests */
167#define XY_RSET_ALL	(struct xy_iorq *)(-2)	/* don't restart anything */
168