Deleted Added
full compact
vpo.c (38061) vpo.c (39134)
1/*-
2 * Copyright (c) 1997, 1998 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1997, 1998 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: vpo.c,v 1.4 1997/09/01 00:51:52 bde Exp $
26 * $Id: vpo.c,v 1.6 1998/08/03 19:14:31 msmith Exp $
27 *
28 */
29
30#ifdef KERNEL
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/malloc.h>
34#include <sys/buf.h>

--- 21 unchanged lines hidden (view full) ---

56
57struct vpo_data {
58 unsigned short vpo_unit;
59
60 int vpo_stat;
61 int vpo_count;
62 int vpo_error;
63
27 *
28 */
29
30#ifdef KERNEL
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/malloc.h>
34#include <sys/buf.h>

--- 21 unchanged lines hidden (view full) ---

56
57struct vpo_data {
58 unsigned short vpo_unit;
59
60 int vpo_stat;
61 int vpo_count;
62 int vpo_error;
63
64 int vpo_isplus;
65
64 struct ppb_status vpo_status;
65 struct vpo_sense vpo_sense;
66
67 unsigned char vpo_buffer[VP0_BUFFER_SIZE];
68
69 struct vpoio_data vpo_io; /* interface to low level functions */
70
71 struct scsi_link sc_link;

--- 85 unchanged lines hidden (view full) ---

157 vpo->vpo_unit = nvpo;
158
159 /* ok, go to next device on next probe */
160 nvpo ++;
161
162 /* low level probe */
163 vpoio_set_unit(&vpo->vpo_io, vpo->vpo_unit);
164
66 struct ppb_status vpo_status;
67 struct vpo_sense vpo_sense;
68
69 unsigned char vpo_buffer[VP0_BUFFER_SIZE];
70
71 struct vpoio_data vpo_io; /* interface to low level functions */
72
73 struct scsi_link sc_link;

--- 85 unchanged lines hidden (view full) ---

159 vpo->vpo_unit = nvpo;
160
161 /* ok, go to next device on next probe */
162 nvpo ++;
163
164 /* low level probe */
165 vpoio_set_unit(&vpo->vpo_io, vpo->vpo_unit);
166
165 if (!(dev = vpoio_probe(ppb, &vpo->vpo_io))) {
167 if ((dev = imm_probe(ppb, &vpo->vpo_io))) {
168 vpo->vpo_isplus = 1;
169
170 } else if (!(dev = vpoio_probe(ppb, &vpo->vpo_io))) {
166 free(vpo, M_DEVBUF);
167 return (NULL);
168 }
169
170 return (dev);
171}
172
173/*

--- 4 unchanged lines hidden (view full) ---

178static int
179vpoattach(struct ppb_device *dev)
180{
181
182 struct scsibus_data *scbus;
183 struct vpo_data *vpo = vpodata[dev->id_unit];
184
185 /* low level attachment */
171 free(vpo, M_DEVBUF);
172 return (NULL);
173 }
174
175 return (dev);
176}
177
178/*

--- 4 unchanged lines hidden (view full) ---

183static int
184vpoattach(struct ppb_device *dev)
185{
186
187 struct scsibus_data *scbus;
188 struct vpo_data *vpo = vpodata[dev->id_unit];
189
190 /* low level attachment */
186 if (!vpoio_attach(&vpo->vpo_io))
187 return (0);
191 if (vpo->vpo_isplus) {
192 if (!imm_attach(&vpo->vpo_io))
193 return (0);
194 } else {
195 if (!vpoio_attach(&vpo->vpo_io))
196 return (0);
197 }
188
189 vpo->sc_link.adapter_unit = vpo->vpo_unit;
190 vpo->sc_link.adapter_targ = VP0_INITIATOR;
191 vpo->sc_link.adapter = &vpo_switch;
192 vpo->sc_link.device = &vpo_dev;
193 vpo->sc_link.opennings = VP0_OPENNINGS;
194
195 /*
196 * Prepare the scsibus_data area for the upperlevel
197 * scsi code.
198 */
199 scbus = scsi_alloc_bus();
200 if(!scbus)
201 return (0);
202 scbus->adapter_link = &vpo->sc_link;
203
204 /* all went ok */
198
199 vpo->sc_link.adapter_unit = vpo->vpo_unit;
200 vpo->sc_link.adapter_targ = VP0_INITIATOR;
201 vpo->sc_link.adapter = &vpo_switch;
202 vpo->sc_link.device = &vpo_dev;
203 vpo->sc_link.opennings = VP0_OPENNINGS;
204
205 /*
206 * Prepare the scsibus_data area for the upperlevel
207 * scsi code.
208 */
209 scbus = scsi_alloc_bus();
210 if(!scbus)
211 return (0);
212 scbus->adapter_link = &vpo->sc_link;
213
214 /* all went ok */
205 printf("vpo%d: <Iomega PPA-3/VPI0 SCSI controller>\n", dev->id_unit);
215 printf("vpo%d: <Iomega PPA-3/VPI0/IMM SCSI controller>\n",
216 dev->id_unit);
206
207 scsi_attachdevs(scbus);
208
209 return (1);
210}
211
212static void
213vpominphys(struct buf *bp)

--- 12 unchanged lines hidden (view full) ---

226vpo_intr(struct vpo_data *vpo, struct scsi_xfer *xs)
227{
228
229 int errno; /* error in errno.h */
230
231 if (xs->datalen && !(xs->flags & SCSI_DATA_IN))
232 bcopy(xs->data, vpo->vpo_buffer, xs->datalen);
233
217
218 scsi_attachdevs(scbus);
219
220 return (1);
221}
222
223static void
224vpominphys(struct buf *bp)

--- 12 unchanged lines hidden (view full) ---

237vpo_intr(struct vpo_data *vpo, struct scsi_xfer *xs)
238{
239
240 int errno; /* error in errno.h */
241
242 if (xs->datalen && !(xs->flags & SCSI_DATA_IN))
243 bcopy(xs->data, vpo->vpo_buffer, xs->datalen);
244
234 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
235 xs->sc_link->target, (char *)xs->cmd, xs->cmdlen,
236 vpo->vpo_buffer, xs->datalen, &vpo->vpo_stat, &vpo->vpo_count,
237 &vpo->vpo_error);
245 if (vpo->vpo_isplus) {
246 errno = imm_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
247 xs->sc_link->target, (char *)xs->cmd, xs->cmdlen,
248 vpo->vpo_buffer, xs->datalen, &vpo->vpo_stat,
249 &vpo->vpo_count, &vpo->vpo_error);
250 } else {
251 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
252 xs->sc_link->target, (char *)xs->cmd, xs->cmdlen,
253 vpo->vpo_buffer, xs->datalen, &vpo->vpo_stat,
254 &vpo->vpo_count, &vpo->vpo_error);
255 }
238
239#ifdef VP0_DEBUG
240 printf("vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
241 errno, vpo->vpo_stat, vpo->vpo_count, vpo->vpo_error);
242#endif
243
244 if (errno) {
245#ifdef VP0_WARNING

--- 18 unchanged lines hidden (view full) ---

264 case NO_SENSE:
265 break;
266
267 case CHECK_CONDITION:
268 vpo->vpo_sense.cmd.op_code = REQUEST_SENSE;
269 vpo->vpo_sense.cmd.length = sizeof(xs->sense);
270 vpo->vpo_sense.cmd.control = 0;
271
256
257#ifdef VP0_DEBUG
258 printf("vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
259 errno, vpo->vpo_stat, vpo->vpo_count, vpo->vpo_error);
260#endif
261
262 if (errno) {
263#ifdef VP0_WARNING

--- 18 unchanged lines hidden (view full) ---

282 case NO_SENSE:
283 break;
284
285 case CHECK_CONDITION:
286 vpo->vpo_sense.cmd.op_code = REQUEST_SENSE;
287 vpo->vpo_sense.cmd.length = sizeof(xs->sense);
288 vpo->vpo_sense.cmd.control = 0;
289
272 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
273 xs->sc_link->target, (char *)&vpo->vpo_sense.cmd,
274 sizeof(vpo->vpo_sense.cmd),
275 (char *)&xs->sense, sizeof(xs->sense),
276 &vpo->vpo_sense.stat, &vpo->vpo_sense.count,
277 &vpo->vpo_error);
290 if (vpo->vpo_isplus) {
291 errno = imm_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
292 xs->sc_link->target,
293 (char *)&vpo->vpo_sense.cmd,
294 sizeof(vpo->vpo_sense.cmd),
295 (char *)&xs->sense, sizeof(xs->sense),
296 &vpo->vpo_sense.stat, &vpo->vpo_sense.count,
297 &vpo->vpo_error);
298 } else {
299 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
300 xs->sc_link->target,
301 (char *)&vpo->vpo_sense.cmd,
302 sizeof(vpo->vpo_sense.cmd),
303 (char *)&xs->sense, sizeof(xs->sense),
304 &vpo->vpo_sense.stat, &vpo->vpo_sense.count,
305 &vpo->vpo_error);
306 }
278
279 if (errno)
280 /* connection to ppbus interrupted */
281 xs->error = XS_DRIVER_STUFFUP;
282 else
283 xs->error = XS_SENSE;
284
285 goto error;

--- 56 unchanged lines hidden ---
307
308 if (errno)
309 /* connection to ppbus interrupted */
310 xs->error = XS_DRIVER_STUFFUP;
311 else
312 xs->error = XS_SENSE;
313
314 goto error;

--- 56 unchanged lines hidden ---