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
|
/* $OpenBSD: vsvar.h,v 1.20 2008/01/05 00:34:07 miod Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* 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 OFF(x) (u_int16_t)(x)
/*
* scatter/gather structures
*/
typedef struct {
union {
unsigned short bytes :16;
#define MAX_SG_BLOCK_SIZE (1<<16)
struct {
unsigned short :8;
unsigned short gather:8;
} scatter;
} count;
u_int16_t addrhi, addrlo; /* split due to alignment */
unsigned short link:1;
unsigned short :3;
unsigned short transfer_type:2;
#define SHORT_TRANSFER 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
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;
struct vs_cb {
struct scsi_xfer *cb_xs;
u_int cb_q;
M328_SG cb_sg;
};
struct vs_channel {
int vc_id; /* host id */
int vc_width; /* number of targets */
int vc_type; /* channel type */
#define VCT_UNKNOWN 0
#define VCT_SE 1
#define VCT_DIFFERENTIAL 2
struct scsi_link vc_link;
};
struct vs_softc {
struct device sc_dev;
int sc_bid; /* board id */
paddr_t sc_paddr;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
struct intrhand sc_ih_e, sc_ih_n;
char sc_intrname_e[16 + 4];
int sc_ipl;
int sc_evec, sc_nvec;
u_int sc_nwq; /* number of work queues */
struct vs_channel sc_channel[2];
struct vs_cb sc_cb[1 + NUM_WQ];
};
/* Access macros */
#define vs_read(w,o) \
bus_space_read_##w (sc->sc_iot, sc->sc_ioh, (o))
#define vs_write(w,o,v) \
bus_space_write_##w (sc->sc_iot, sc->sc_ioh, (o), (v))
#define vs_bzero(o,s) \
bus_space_set_region_2(sc->sc_iot, sc->sc_ioh, (o), 0, (s) / 2)
#define cib_read(w,o) vs_read(w, sh_CIB + (o))
#define cib_write(w,o,v) vs_write(w, sh_CIB + (o), (v))
#define crb_read(w,o) vs_read(w, sh_CRB + (o))
#define crb_write(w,o,v) vs_write(w, sh_CRB + (o), (v))
#define csb_read(w,o) vs_read(w, sh_CSS + (o))
#define mce_read(w,o) vs_read(w, sh_MCE + (o))
#define mce_write(w,o,v) vs_write(w, sh_MCE + (o), (v))
#define mce_iopb_read(w,o) vs_read(w, sh_MCE_IOPB + (o))
#define mce_iopb_write(w,o,v) vs_write(w, sh_MCE_IOPB + (o), (v))
#define mcsb_read(w,o) vs_read(w, sh_MCSB + (o))
#define mcsb_write(w,o,v) vs_write(w, sh_MCSB + (o), (v))
#define CRSW crb_read(2, CRB_CRSW)
#define CRB_CLR_DONE crb_write(2, CRB_CRSW, 0)
#define CRB_CLR_ER crb_write(2, CRB_CRSW, CRSW & ~M_CRSW_ER)
#define THAW_REG mcsb_read(2, MCSB_THAW)
#define THAW(x) \
do { \
mcsb_write(1, MCSB_THAW, (x)); \
mcsb_write(1, MCSB_THAW + 1, M_THAW_TWQE); \
} while (0)
#endif /* _M328VAR_H */
|