Deleted Added
sdiff udiff text old ( 184130 ) new ( 185003 )
full compact
1/*-
2 * Copyright (c) 1997, 1998, 1999 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

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

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 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/ppbus/vpo.c 185003 2008-11-16 17:42:02Z jhb $");
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/module.h>
34#include <sys/bus.h>
35#include <sys/lock.h>
36#include <sys/mutex.h>
37#include <sys/malloc.h>

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

173 vpo_cam_rescan(vpo); /* have CAM rescan the bus */
174
175 return (0);
176}
177
178static void
179vpo_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb)
180{
181
182 free(ccb, M_TEMP);
183}
184
185static void
186vpo_cam_rescan(struct vpo_data *vpo)
187{
188 struct cam_path *path;
189 union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO);
190
191 if (xpt_create_path(&path, xpt_periph, cam_sim_path(vpo->sim), 0, 0)
192 != CAM_REQ_CMP) {
193 /* A failure is benign as the user can do a manual rescan */
194 free(ccb, M_TEMP);
195 return;
196 }
197
198 xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/);
199 ccb->ccb_h.func_code = XPT_SCAN_BUS;
200 ccb->ccb_h.cbfcnp = vpo_cam_rescan_callback;
201 ccb->crcn.flags = CAM_FLAG_NONE;
202 xpt_action(ccb);
203
204 /* The scan is in progress now. */
205}
206
207/*
208 * vpo_intr()
209 */
210static void
211vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio)
212{

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

228 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
229 csio->ccb_h.target_id,
230 (char *)&csio->cdb_io.cdb_bytes, csio->cdb_len,
231 (char *)csio->data_ptr, csio->dxfer_len,
232 &vpo->vpo_stat, &vpo->vpo_count, &vpo->vpo_error);
233 }
234
235#ifdef VP0_DEBUG
236 printf("vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
237 errno, vpo->vpo_stat, vpo->vpo_count, vpo->vpo_error);
238
239 /* dump of command */
240 for (i=0; i<csio->cdb_len; i++)
241 printf("%x ", ((char *)&csio->cdb_io.cdb_bytes)[i]);
242
243 printf("\n");
244#endif

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

282 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
283 csio->ccb_h.target_id,
284 (char *)&vpo->vpo_sense.cmd,
285 sizeof(vpo->vpo_sense.cmd),
286 (char *)&csio->sense_data, csio->sense_len,
287 &vpo->vpo_sense.stat, &vpo->vpo_sense.count,
288 &vpo->vpo_error);
289 }
290
291
292#ifdef VP0_DEBUG
293 printf("(sense) vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
294 errno, vpo->vpo_sense.stat, vpo->vpo_sense.count, vpo->vpo_error);
295#endif
296
297 /* check sense return status */
298 if (errno == 0 && vpo->vpo_sense.stat == SCSI_STATUS_OK) {
299 /* sense ok */
300 csio->ccb_h.status = CAM_AUTOSNS_VALID | CAM_SCSI_STATUS_ERROR;
301 csio->sense_resid = csio->sense_len - vpo->vpo_sense.count;

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

309#endif
310
311 } else {
312 /* sense failed */
313 csio->ccb_h.status = CAM_AUTOSENSE_FAIL;
314 }
315 } else {
316 /* no sense */
317 csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
318 }
319
320 goto error;
321 }
322
323 csio->resid = csio->dxfer_len - vpo->vpo_count;
324 csio->ccb_h.status = CAM_REQ_CMP;
325

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

341 struct ccb_scsiio *csio;
342
343 csio = &ccb->csio;
344
345#ifdef VP0_DEBUG
346 device_printf(vpo->vpo_dev, "XPT_SCSI_IO (0x%x) request\n",
347 csio->cdb_io.cdb_bytes[0]);
348#endif
349
350 vpo_intr(vpo, csio);
351
352 xpt_done(ccb);
353
354 break;
355 }
356 case XPT_CALC_GEOMETRY:
357 {

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

400
401 ccb->ccb_h.status = CAM_REQ_CMP;
402 xpt_done(ccb);
403 break;
404 }
405 case XPT_PATH_INQ: /* Path routing inquiry */
406 {
407 struct ccb_pathinq *cpi = &ccb->cpi;
408
409#ifdef VP0_DEBUG
410 device_printf(vpo->vpo_dev, "XPT_PATH_INQ request\n");
411#endif
412 cpi->version_num = 1; /* XXX??? */
413 cpi->hba_inquiry = 0;
414 cpi->target_sprt = 0;
415 cpi->hba_misc = 0;
416 cpi->hba_eng_cnt = 0;

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

434 break;
435 }
436
437 return;
438}
439
440static void
441vpo_poll(struct cam_sim *sim)
442{
443
444 /* The ZIP is actually always polled throw vpo_action(). */
445}
446
447static devclass_t vpo_devclass;
448
449static device_method_t vpo_methods[] = {
450 /* device interface */
451 DEVMETHOD(device_identify, vpo_identify),
452 DEVMETHOD(device_probe, vpo_probe),

--- 13 unchanged lines hidden ---