Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / ic / mb89352var.h
blob55d1c9c1108db7983ea71acc467a9611ac5e2303
1 /* $NetBSD: mb89352var.h,v 1.14 2009/11/12 20:14:04 dyoung Exp $ */
2 /* NecBSD: mb89352var.h,v 1.4 1998/03/14 07:31:22 kmatsuda Exp */
4 /*-
5 * Copyright (c) 1996-1999 The NetBSD Foundation, Inc.
6 * All rights reserved.
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Charles M. Hannum, Masaru Oki and Kouichi Matsuda.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
32 * Copyright (c) 1994 Jarle Greipsland
33 * All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
37 * are met:
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. The name of the author may not be used to endorse or promote products
44 * derived from this software without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
47 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
48 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
50 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
51 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
52 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
54 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
55 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
56 * POSSIBILITY OF SUCH DAMAGE.
59 * [NetBSD for NEC PC-98 series]
60 * Copyright (c) 1996, 1997, 1998
61 * NetBSD/pc98 porting staff. All rights reserved.
62 * Copyright (c) 1996, 1997, 1998
63 * Kouich Matsuda. All rights reserved.
66 #ifndef _MB89352VAR_H_
67 #define _MB89352VAR_H_
69 * ACB. Holds additional information for each SCSI command Comments: We
70 * need a separate scsi command block because we may need to overwrite it
71 * with a request sense command. Basicly, we refrain from fiddling with
72 * the scsi_xfer struct (except do the expected updating of return values).
73 * We'll generally update: xs->{flags,resid,error,sense,status} and
74 * occasionally xs->retries.
76 struct spc_acb {
77 struct scsipi_generic scsipi_cmd;
78 int scsipi_cmd_length;
79 uint8_t *data_addr; /* Saved data pointer */
80 int data_length; /* Residue */
82 uint8_t target_stat; /* SCSI status byte */
84 #ifdef notdef
85 struct spc_dma_seg dma[SPC_NSEG]; /* Physical addresses+len */
86 #endif
88 TAILQ_ENTRY(spc_acb) chain;
89 struct scsipi_xfer *xs; /* SCSI xfer ctrl block from above */
90 u_int flags;
91 #define ACB_ALLOC 0x01
92 #define ACB_NEXUS 0x02
93 #define ACB_SENSE 0x04
94 #define ACB_ABORT 0x40
95 #define ACB_RESET 0x80
96 int timeout;
100 * Some info about each (possible) target on the SCSI bus. This should
101 * probably have been a "per target+lunit" structure, but we'll leave it at
102 * this for now.
104 struct spc_tinfo {
105 int cmds; /* #commands processed */
106 int dconns; /* #disconnects */
107 int touts; /* #timeouts */
108 int perrs; /* #parity errors */
109 int senses; /* #request sense commands sent */
110 ushort lubusy; /* What local units/subr. are busy? */
111 u_char flags;
112 #define DO_SYNC 0x01 /* (Re)Negotiate synchronous options */
113 #define DO_WIDE 0x02 /* (Re)Negotiate wide options */
114 uint8_t period; /* Period suggestion */
115 uint8_t offset; /* Offset suggestion */
116 uint8_t width; /* Width suggestion */
119 struct spc_softc {
120 device_t sc_dev;
122 bus_space_tag_t sc_iot;
123 bus_space_handle_t sc_ioh;
125 struct scsipi_channel sc_channel; /* prototype for subdevs */
126 struct scsipi_adapter sc_adapter;
128 TAILQ_HEAD(, spc_acb) free_list, ready_list, nexus_list;
129 struct spc_acb *sc_nexus; /* current command */
130 struct spc_acb sc_acb[8];
131 struct spc_tinfo sc_tinfo[8];
133 /* Data about the current nexus (updated for every cmd switch) */
134 uint8_t *sc_dp; /* Current data pointer */
135 size_t sc_dleft; /* Data bytes left to transfer */
136 uint8_t *sc_cp; /* Current command pointer */
137 size_t sc_cleft; /* Command bytes left to transfer */
139 /* Adapter state */
140 uint8_t sc_phase; /* Current bus phase */
141 uint8_t sc_prevphase; /* Previous bus phase */
142 uint8_t sc_state; /* State applicable to the adapter */
143 #define SPC_INIT 0
144 #define SPC_IDLE 1
145 #define SPC_SELECTING 2 /* SCSI command is arbiting */
146 #define SPC_RESELECTED 3 /* Has been reselected */
147 #define SPC_CONNECTED 4 /* Actively using the SCSI bus */
148 #define SPC_DISCONNECT 5 /* MSG_DISCONNECT received */
149 #define SPC_CMDCOMPLETE 6 /* MSG_CMDCOMPLETE received */
150 #define SPC_CLEANING 7
151 uint8_t sc_flags;
152 #define SPC_DROP_MSGIN 0x01 /* Discard all msgs (parity err detected) */
153 #define SPC_ABORTING 0x02 /* Bailing out */
154 #define SPC_DOINGDMA 0x04 /* doing DMA */
155 #define SPC_INACTIVE 0x80 /* The FIFO data path is active! */
156 uint8_t sc_selid; /* Reselection ID */
157 device_t sc_child;/* Our child */
159 /* Message stuff */
160 uint8_t sc_msgpriq; /* Messages we want to send */
161 uint8_t sc_msgoutq; /* Messages sent during last MESSAGE OUT */
162 uint8_t sc_lastmsg; /* Message last transmitted */
163 uint8_t sc_currmsg; /* Message currently ready to transmit */
164 #define SEND_DEV_RESET 0x01
165 #define SEND_PARITY_ERROR 0x02
166 #define SEND_INIT_DET_ERR 0x04
167 #define SEND_REJECT 0x08
168 #define SEND_IDENTIFY 0x10
169 #define SEND_ABORT 0x20
170 #define SEND_SDTR 0x40
171 #define SEND_WDTR 0x80
172 #define SPC_MAX_MSG_LEN 8
173 uint8_t sc_omess[SPC_MAX_MSG_LEN];
174 uint8_t *sc_omp; /* Outgoing message pointer */
175 uint8_t sc_imess[SPC_MAX_MSG_LEN];
176 uint8_t *sc_imp; /* Incoming message pointer */
178 /* Hardware stuff */
179 int sc_initiator; /* Our scsi id */
180 int sc_freq; /* Clock frequency in MHz */
181 int sc_minsync; /* Minimum sync period / 4 */
182 int sc_maxsync; /* Maximum sync period / 4 */
184 /* DMA function set from MD code */
185 void (*sc_dma_start)(struct spc_softc *, void *, size_t, int);
186 void (*sc_dma_done)(struct spc_softc *);
189 #if SPC_DEBUG
190 #define SPC_SHOWACBS 0x01
191 #define SPC_SHOWINTS 0x02
192 #define SPC_SHOWCMDS 0x04
193 #define SPC_SHOWMISC 0x08
194 #define SPC_SHOWTRACE 0x10
195 #define SPC_SHOWSTART 0x20
196 #define SPC_DOBREAK 0x40
197 extern int spc_debug; /* SPC_SHOWSTART|SPC_SHOWMISC|SPC_SHOWTRACE; */
198 #define SPC_PRINT(b, s) \
199 do { \
200 if ((spc_debug & (b)) != 0) \
201 printf s; \
202 } while (/* CONSTCOND */ 0)
203 #define SPC_BREAK() \
204 do { \
205 if ((spc_debug & SPC_DOBREAK) != 0) \
206 Debugger(); \
207 } while (/* CONSTCOND */ 0)
208 #define SPC_ASSERT(x) \
209 do { \
210 if (x) { \
212 } else { \
213 printf("%s at line %d: assertion failed\n", \
214 device_xname(sc->sc_dev), __LINE__); \
215 Debugger(); \
217 } while (/* CONSTCOND */ 0)
218 #else
219 #define SPC_PRINT(b, s)
220 #define SPC_BREAK()
221 #define SPC_ASSERT(x)
222 #endif
224 #define SPC_ACBS(s) SPC_PRINT(SPC_SHOWACBS, s)
225 #define SPC_INTS(s) SPC_PRINT(SPC_SHOWINTS, s)
226 #define SPC_CMDS(s) SPC_PRINT(SPC_SHOWCMDS, s)
227 #define SPC_MISC(s) SPC_PRINT(SPC_SHOWMISC, s)
228 #define SPC_TRACE(s) SPC_PRINT(SPC_SHOWTRACE, s)
229 #define SPC_START(s) SPC_PRINT(SPC_SHOWSTART, s)
231 void spc_attach(struct spc_softc *);
232 void spc_childdet(device_t, device_t);
233 int spc_detach(device_t, int);
234 int spc_intr(void *);
235 int spc_find(bus_space_tag_t, bus_space_handle_t, int);
236 void spc_init(struct spc_softc *, int);
237 void spc_sched(struct spc_softc *);
238 #endif /* _MB89352VAR_H_ */