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