summaryrefslogtreecommitdiff
path: root/sys/arch/mvme88k/dev/vsvar.h
blob: 5b597ace99862df7462f9268f742985e0a8509f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*	$OpenBSD: vsvar.h,v 1.8 2003/12/26 10:41:43 miod Exp $ */
/*
 * Copyright (c) 1999 Steve Murphree, Jr.
 * Copyright (c) 1990 The Regents of the University of California.
 * All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Van Jacobson of Lawrence Berkeley Laboratory.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */
#ifndef _VSVAR_H_
#define _VSVAR_H_

/*
 * The largest single request will be MAXPHYS bytes which will require
 * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of
 * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the
 * buffer is not page aligned (+1).
 */
#define	DMAMAXIO	(MAXPHYS/NBPG+1)
#define  LO(x) (u_short)((unsigned long)x & 0x0000FFFF)
#define  HI(x) (u_short)((unsigned long)x >> 16)
#define  OFF(x) (u_short)((long)kvtop((vaddr_t)x) - (long)kvtop((vaddr_t)sc->sc_vsreg))
#define  vs_name(sc)	(sc)->sc_dev.dv_xname

/****************     Scater/Gather Stuff                *******************/

typedef struct {
	union {
		unsigned short bytes :16;
   #define MAX_SG_BLOCK_SIZE	(1<<16)	/* the size *has* to be always *smaller* */
		struct {
			unsigned short :8;
			unsigned short gather :8;
		} scatter;
	} count;
	LONGV           address;
	unsigned short  link :1;
	unsigned short  :3;
	unsigned short  transfer_type :2;
	/* 				0x0 is reserved */
   #define SHORT_TREANSFER 		0x1
   #define LONG_TRANSFER			0x2
   #define SCATTER_GATTER_LIST_IN_SHORT_IO	0x3
	unsigned short  memory_type :2;
   #define NORMAL_TYPE			0x0
   #define BLOCK_MODE			0x1
	/*				0x2 is reserved */
	/*				0x3 is reserved */
	unsigned short  address_modifier :8;
} sg_list_element_t;

typedef sg_list_element_t * scatter_gather_list_t;

#define MAX_SG_ELEMENTS 64

struct m328_sg {
	struct m328_sg  *up;
	int                     elements;
	int                     level;
	struct m328_sg  *down[MAX_SG_ELEMENTS];
	sg_list_element_t list[MAX_SG_ELEMENTS];
};

typedef struct m328_sg *M328_SG;

typedef struct {
   struct scsi_xfer  *xs;
   M328_SG           top_sg_list;
} M328_CMD;

/**************** END Scater/Gather Stuff                *******************/

struct vs_tinfo {
	int	cmds;		/* #commands processed */
	int	dconns;		/* #disconnects */
	int	touts;		/* #timeouts */
	int	perrs;		/* #parity errors */
	int	senses;		/* #request sense commands sent */
	ushort	lubusy;		/* What local units/subr. are busy? */
	u_char	flags;
	u_char	period;		/* Period suggestion */
	u_char	offset;		/* Offset suggestion */
	int	avail;		/* Is there a device there */
} tinfo_t;

struct  vs_softc {
	struct  device sc_dev;
	struct  intrhand sc_ih_e;
	struct  intrhand sc_ih_n;
	struct  evcnt sc_intrcnt_e;
	struct  evcnt sc_intrcnt_n;
	u_short  sc_ipl;
	u_short  sc_evec;
	u_short  sc_nvec;
	struct  scsi_link sc_link;	/* proto for sub devices */
	u_long  sc_chnl;		/* channel 0 or 1 for dual bus cards */
	u_long  sc_qhp;			/* Command queue head pointer */
	struct   vsreg  *sc_vsreg;
#define SSH_NACB 8
	struct vs_tinfo sc_tinfo[SSH_NACB];
	u_char  sc_flags;
	u_char  sc_sien;
	u_char  sc_dien;
	u_char  sc_minsync;
	struct map *hus_map;
	/* one for each target */
	struct syncpar {
		u_char state;
		u_char sxfer;
		u_char sbcl;
	} sc_sync[8];
};

/* sync states */
#define SYNC_START	0	/* no sync handshake started */
#define SYNC_SENT	1	/* we sent sync request, no answer yet */
#define SYNC_DONE	2	/* target accepted our (or inferior) settings,
				   or it rejected the request and we stay async */

#define IOPB_SCSI    0x20
#define IOPB_RESET   0x22
#define IOPB_INIT    0x41
#define IOPB_WQINIT  0x42
#define IOPB_DEV_RESET   0x4D

#define OPT_INTEN    0x0001
#define OPT_INTDIS   0x0000
#define OPT_SG       0x0002
#define OPT_SST      0x0004
#define OPT_SIT      0x0040
#define OPT_READ     0x0000
#define OPT_WRITE    0x0100

#define AM_S32       0x01
#define AM_S16       0x05
#define AM_16        0x0100
#define AM_32        0x0200
#define AM_SHORT     0x0300
#define AM_NORMAL    0x0000
#define AM_BLOCK     0x0400
#define AM_D64BLOCK  0x0C00

#define WQO_AE             0x0001   /* abort enable bit */
#define WQO_FOE            0x0004   /* freeze on error */
#define WQO_PE             0x0008   /* parity enable bit */
#define WQO_ARE            0x0010   /* autosense recovery enable bit */
#define WQO_RFWQ           0x0020   /* report frozen work queue bit */
#define WQO_INIT           0x8000   /* work queue init bit */

#endif /* _M328VAR_H */