1997-08-14 13:57:45 +00:00
|
|
|
/*-
|
1998-08-03 19:14:33 +00:00
|
|
|
* Copyright (c) 1997, 1998 Nicolas Souchu
|
1997-08-14 13:57:45 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*
|
1999-05-06 21:12:58 +00:00
|
|
|
* $Id: vpo.c,v 1.12 1999/05/06 20:16:27 ken Exp $
|
1997-08-14 13:57:45 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef KERNEL
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
|
|
|
|
#include <machine/clock.h>
|
|
|
|
|
|
|
|
#endif /* KERNEL */
|
1998-09-20 14:41:54 +00:00
|
|
|
|
|
|
|
#include <cam/cam.h>
|
|
|
|
#include <cam/cam_ccb.h>
|
|
|
|
#include <cam/cam_sim.h>
|
|
|
|
#include <cam/cam_xpt_sim.h>
|
|
|
|
#include <cam/cam_debug.h>
|
|
|
|
|
|
|
|
#include <cam/scsi/scsi_all.h>
|
|
|
|
#include <cam/scsi/scsi_message.h>
|
|
|
|
#include <cam/scsi/scsi_da.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
#ifdef KERNEL
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#endif /*KERNEL */
|
|
|
|
|
1999-01-10 12:04:56 +00:00
|
|
|
#include "opt_vpo.h"
|
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
#include <dev/ppbus/ppbconf.h>
|
1998-08-03 19:14:33 +00:00
|
|
|
#include <dev/ppbus/vpoio.h>
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
struct vpo_sense {
|
|
|
|
struct scsi_sense cmd;
|
|
|
|
unsigned int stat;
|
|
|
|
unsigned int count;
|
|
|
|
};
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
struct vpo_data {
|
|
|
|
unsigned short vpo_unit;
|
|
|
|
|
|
|
|
int vpo_stat;
|
|
|
|
int vpo_count;
|
|
|
|
int vpo_error;
|
|
|
|
|
1998-09-13 18:26:26 +00:00
|
|
|
int vpo_isplus;
|
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
struct cam_sim *sim;
|
|
|
|
struct cam_path *path;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
struct vpo_sense vpo_sense;
|
1998-08-03 19:14:33 +00:00
|
|
|
|
|
|
|
struct vpoio_data vpo_io; /* interface to low level functions */
|
|
|
|
};
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* cam related functions */
|
|
|
|
static void vpo_action(struct cam_sim *sim, union ccb *ccb);
|
|
|
|
static void vpo_poll(struct cam_sim *sim);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
static int nvpo = 0;
|
|
|
|
#define MAXVP0 8 /* XXX not much better! */
|
|
|
|
static struct vpo_data *vpodata[MAXVP0];
|
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef KERNEL
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make ourselves visible as a ppbus driver
|
|
|
|
*/
|
|
|
|
static struct ppb_device *vpoprobe(struct ppb_data *ppb);
|
|
|
|
static int vpoattach(struct ppb_device *dev);
|
|
|
|
|
|
|
|
static struct ppb_driver vpodriver = {
|
|
|
|
vpoprobe, vpoattach, "vpo"
|
|
|
|
};
|
|
|
|
DATA_SET(ppbdriver_set, vpodriver);
|
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#endif /* KERNEL */
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* vpoprobe()
|
|
|
|
*
|
|
|
|
* Called by ppb_attachdevs().
|
|
|
|
*/
|
|
|
|
static struct ppb_device *
|
|
|
|
vpoprobe(struct ppb_data *ppb)
|
|
|
|
{
|
|
|
|
struct vpo_data *vpo;
|
1998-08-03 19:14:33 +00:00
|
|
|
struct ppb_device *dev;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
if (nvpo >= MAXVP0) {
|
|
|
|
printf("vpo: Too many devices (max %d)\n", MAXVP0);
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
vpo = (struct vpo_data *)malloc(sizeof(struct vpo_data),
|
|
|
|
M_DEVBUF, M_NOWAIT);
|
|
|
|
if (!vpo) {
|
|
|
|
printf("vpo: cannot malloc!\n");
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
bzero(vpo, sizeof(struct vpo_data));
|
|
|
|
|
|
|
|
vpodata[nvpo] = vpo;
|
|
|
|
|
|
|
|
/* vpo dependent initialisation */
|
|
|
|
vpo->vpo_unit = nvpo;
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/* ok, go to next device on next probe */
|
|
|
|
nvpo ++;
|
|
|
|
|
|
|
|
/* low level probe */
|
|
|
|
vpoio_set_unit(&vpo->vpo_io, vpo->vpo_unit);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* check ZIP before ZIP+ or imm_probe() will send controls to
|
|
|
|
* the printer or whatelse connected to the port */
|
|
|
|
if ((dev = vpoio_probe(ppb, &vpo->vpo_io))) {
|
|
|
|
vpo->vpo_isplus = 0;
|
|
|
|
} else if ((dev = imm_probe(ppb, &vpo->vpo_io))) {
|
1998-09-13 18:26:26 +00:00
|
|
|
vpo->vpo_isplus = 1;
|
1998-09-20 14:41:54 +00:00
|
|
|
} else {
|
1997-08-14 13:57:45 +00:00
|
|
|
free(vpo, M_DEVBUF);
|
1997-08-16 14:05:38 +00:00
|
|
|
return (NULL);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
return (dev);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vpoattach()
|
|
|
|
*
|
|
|
|
* Called by ppb_attachdevs().
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
vpoattach(struct ppb_device *dev)
|
|
|
|
{
|
|
|
|
struct vpo_data *vpo = vpodata[dev->id_unit];
|
1998-09-20 14:41:54 +00:00
|
|
|
struct cam_devq *devq;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-08-03 19:14:33 +00:00
|
|
|
/* low level attachment */
|
1998-09-13 18:26:26 +00:00
|
|
|
if (vpo->vpo_isplus) {
|
|
|
|
if (!imm_attach(&vpo->vpo_io))
|
|
|
|
return (0);
|
|
|
|
} else {
|
|
|
|
if (!vpoio_attach(&vpo->vpo_io))
|
|
|
|
return (0);
|
|
|
|
}
|
1998-08-03 19:14:33 +00:00
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
/*
|
1998-09-20 14:41:54 +00:00
|
|
|
** Now tell the generic SCSI layer
|
|
|
|
** about our bus.
|
|
|
|
*/
|
|
|
|
devq = cam_simq_alloc(/*maxopenings*/1);
|
|
|
|
/* XXX What about low-level detach on error? */
|
|
|
|
if (devq == NULL)
|
1997-08-14 13:57:45 +00:00
|
|
|
return (0);
|
1998-08-03 19:14:33 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
vpo->sim = cam_sim_alloc(vpo_action, vpo_poll, "vpo", vpo, dev->id_unit,
|
|
|
|
/*untagged*/1, /*tagged*/0, devq);
|
|
|
|
if (vpo->sim == NULL) {
|
|
|
|
cam_simq_free(devq);
|
|
|
|
return (0);
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
if (xpt_bus_register(vpo->sim, /*bus*/0) != CAM_SUCCESS) {
|
|
|
|
cam_sim_free(vpo->sim, /*free_devq*/TRUE);
|
|
|
|
return (0);
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
if (xpt_create_path(&vpo->path, /*periph*/NULL,
|
|
|
|
cam_sim_path(vpo->sim), CAM_TARGET_WILDCARD,
|
|
|
|
CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
|
|
|
|
xpt_bus_deregister(cam_sim_path(vpo->sim));
|
|
|
|
cam_sim_free(vpo->sim, /*free_devq*/TRUE);
|
|
|
|
return (0);
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* all went ok */
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
return (1);
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1998-08-03 19:14:33 +00:00
|
|
|
* vpo_intr()
|
1997-08-14 13:57:45 +00:00
|
|
|
*/
|
1998-08-03 19:14:33 +00:00
|
|
|
static void
|
1998-09-20 14:41:54 +00:00
|
|
|
vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
1998-12-07 21:58:50 +00:00
|
|
|
int errno; /* error in errno.h */
|
1998-09-20 14:41:54 +00:00
|
|
|
int s;
|
1998-12-07 21:58:50 +00:00
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
int i;
|
|
|
|
#endif
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
s = splcam();
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-13 18:26:26 +00:00
|
|
|
if (vpo->vpo_isplus) {
|
|
|
|
errno = imm_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.target_id,
|
|
|
|
(char *)&csio->cdb_io.cdb_bytes, csio->cdb_len,
|
|
|
|
(char *)csio->data_ptr, csio->dxfer_len,
|
|
|
|
&vpo->vpo_stat, &vpo->vpo_count, &vpo->vpo_error);
|
1998-09-13 18:26:26 +00:00
|
|
|
} else {
|
|
|
|
errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.target_id,
|
|
|
|
(char *)&csio->cdb_io.cdb_bytes, csio->cdb_len,
|
|
|
|
(char *)csio->data_ptr, csio->dxfer_len,
|
|
|
|
&vpo->vpo_stat, &vpo->vpo_count, &vpo->vpo_error);
|
1998-09-13 18:26:26 +00:00
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
printf("vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
|
|
|
|
errno, vpo->vpo_stat, vpo->vpo_count, vpo->vpo_error);
|
1998-09-20 14:41:54 +00:00
|
|
|
|
|
|
|
/* dump of command */
|
|
|
|
for (i=0; i<csio->cdb_len; i++)
|
|
|
|
printf("%x ", ((char *)&csio->cdb_io.cdb_bytes)[i]);
|
|
|
|
|
|
|
|
printf("\n");
|
1997-08-16 14:05:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (errno) {
|
|
|
|
/* connection to ppbus interrupted */
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.status = CAM_CMD_TIMEOUT;
|
1997-08-16 14:05:38 +00:00
|
|
|
goto error;
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
/* if a timeout occured, no sense */
|
|
|
|
if (vpo->vpo_error) {
|
1998-09-20 14:41:54 +00:00
|
|
|
if (vpo->vpo_error != VP0_ESELECT_TIMEOUT)
|
|
|
|
printf("vpo%d: VP0 error/timeout (%d)\n",
|
|
|
|
vpo->vpo_unit, vpo->vpo_error);
|
|
|
|
|
|
|
|
csio->ccb_h.status = CAM_CMD_TIMEOUT;
|
1997-08-16 14:05:38 +00:00
|
|
|
goto error;
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* check scsi status */
|
|
|
|
if (vpo->vpo_stat != SCSI_STATUS_OK) {
|
|
|
|
csio->scsi_status = vpo->vpo_stat;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* check if we have to sense the drive */
|
|
|
|
if ((vpo->vpo_stat & SCSI_STATUS_CHECK_COND) != 0) {
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
vpo->vpo_sense.cmd.opcode = REQUEST_SENSE;
|
|
|
|
vpo->vpo_sense.cmd.length = csio->sense_len;
|
1997-08-14 13:57:45 +00:00
|
|
|
vpo->vpo_sense.cmd.control = 0;
|
|
|
|
|
1998-09-13 18:26:26 +00:00
|
|
|
if (vpo->vpo_isplus) {
|
|
|
|
errno = imm_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.target_id,
|
1998-09-13 18:26:26 +00:00
|
|
|
(char *)&vpo->vpo_sense.cmd,
|
|
|
|
sizeof(vpo->vpo_sense.cmd),
|
1998-09-20 14:41:54 +00:00
|
|
|
(char *)&csio->sense_data, csio->sense_len,
|
1998-09-13 18:26:26 +00:00
|
|
|
&vpo->vpo_sense.stat, &vpo->vpo_sense.count,
|
|
|
|
&vpo->vpo_error);
|
|
|
|
} else {
|
|
|
|
errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR,
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->ccb_h.target_id,
|
1998-09-13 18:26:26 +00:00
|
|
|
(char *)&vpo->vpo_sense.cmd,
|
|
|
|
sizeof(vpo->vpo_sense.cmd),
|
1998-09-20 14:41:54 +00:00
|
|
|
(char *)&csio->sense_data, csio->sense_len,
|
1998-09-13 18:26:26 +00:00
|
|
|
&vpo->vpo_sense.stat, &vpo->vpo_sense.count,
|
|
|
|
&vpo->vpo_error);
|
|
|
|
}
|
1998-09-20 14:41:54 +00:00
|
|
|
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
printf("(sense) vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n",
|
|
|
|
errno, vpo->vpo_sense.stat, vpo->vpo_sense.count, vpo->vpo_error);
|
|
|
|
#endif
|
1997-08-16 14:05:38 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
/* check sense return status */
|
|
|
|
if (errno == 0 && vpo->vpo_sense.stat == SCSI_STATUS_OK) {
|
|
|
|
/* sense ok */
|
|
|
|
csio->ccb_h.status = CAM_AUTOSNS_VALID | CAM_SCSI_STATUS_ERROR;
|
|
|
|
csio->sense_resid = csio->sense_len - vpo->vpo_sense.count;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
/* dump of sense info */
|
|
|
|
printf("(sense) ");
|
|
|
|
for (i=0; i<vpo->vpo_sense.count; i++)
|
|
|
|
printf("%x ", ((char *)&csio->sense_data)[i]);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
} else {
|
|
|
|
/* sense failed */
|
|
|
|
csio->ccb_h.status = CAM_AUTOSENSE_FAIL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* no sense */
|
|
|
|
csio->ccb_h.status = CAM_SCSI_STATUS_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
goto error;
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
csio->resid = csio->dxfer_len - vpo->vpo_count;
|
|
|
|
csio->ccb_h.status = CAM_REQ_CMP;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
error:
|
1998-09-20 14:41:54 +00:00
|
|
|
splx(s);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
static void
|
|
|
|
vpo_action(struct cam_sim *sim, union ccb *ccb)
|
1997-08-14 13:57:45 +00:00
|
|
|
{
|
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
struct vpo_data *vpo = (struct vpo_data *)sim->softc;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
switch (ccb->ccb_h.func_code) {
|
|
|
|
case XPT_SCSI_IO:
|
|
|
|
{
|
|
|
|
struct ccb_scsiio *csio;
|
|
|
|
|
|
|
|
csio = &ccb->csio;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
printf("vpo%d: XPT_SCSI_IO (0x%x) request\n",
|
|
|
|
vpo->vpo_unit, csio->cdb_io.cdb_bytes[0]);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
vpo_intr(vpo, csio);
|
|
|
|
|
|
|
|
xpt_done(ccb);
|
|
|
|
|
|
|
|
break;
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
1998-09-20 14:41:54 +00:00
|
|
|
case XPT_CALC_GEOMETRY:
|
|
|
|
{
|
|
|
|
struct ccb_calc_geometry *ccg;
|
|
|
|
u_int32_t size_mb;
|
|
|
|
u_int32_t secs_per_cylinder;
|
|
|
|
|
|
|
|
ccg = &ccb->ccg;
|
|
|
|
size_mb = ccg->volume_size
|
|
|
|
/ ((1024L * 1024L) / ccg->block_size);
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1997-08-16 14:05:38 +00:00
|
|
|
#ifdef VP0_DEBUG
|
1998-09-20 14:41:54 +00:00
|
|
|
printf("vpo%d: XPT_CALC_GEOMETRY (%d, %d) request\n",
|
|
|
|
vpo->vpo_unit, ccg->volume_size, ccg->block_size);
|
1997-08-14 13:57:45 +00:00
|
|
|
#endif
|
1998-09-20 14:41:54 +00:00
|
|
|
|
|
|
|
ccg->heads = 64;
|
|
|
|
ccg->secs_per_track = 32;
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
secs_per_cylinder = ccg->heads * ccg->secs_per_track;
|
|
|
|
ccg->cylinders = ccg->volume_size / secs_per_cylinder;
|
|
|
|
|
|
|
|
ccb->ccb_h.status = CAM_REQ_CMP;
|
|
|
|
xpt_done(ccb);
|
|
|
|
break;
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|
1998-09-20 14:41:54 +00:00
|
|
|
case XPT_RESET_BUS: /* Reset the specified SCSI bus */
|
|
|
|
{
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
printf("vpo%d: XPT_RESET_BUS request\n", vpo->vpo_unit);
|
|
|
|
#endif
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
if (vpo->vpo_isplus) {
|
|
|
|
if (imm_reset_bus(&vpo->vpo_io)) {
|
|
|
|
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
|
|
|
|
xpt_done(ccb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (vpoio_reset_bus(&vpo->vpo_io)) {
|
|
|
|
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
|
|
|
|
xpt_done(ccb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1997-08-14 13:57:45 +00:00
|
|
|
|
1998-09-20 14:41:54 +00:00
|
|
|
ccb->ccb_h.status = CAM_REQ_CMP;
|
|
|
|
xpt_done(ccb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case XPT_PATH_INQ: /* Path routing inquiry */
|
|
|
|
{
|
|
|
|
struct ccb_pathinq *cpi = &ccb->cpi;
|
|
|
|
|
|
|
|
#ifdef VP0_DEBUG
|
|
|
|
printf("vpo%d: XPT_PATH_INQ request\n", vpo->vpo_unit);
|
|
|
|
#endif
|
|
|
|
cpi->version_num = 1; /* XXX??? */
|
1999-01-09 18:05:46 +00:00
|
|
|
cpi->hba_inquiry = 0;
|
|
|
|
cpi->target_sprt = 0;
|
|
|
|
cpi->hba_misc = 0;
|
|
|
|
cpi->hba_eng_cnt = 0;
|
1998-09-20 14:41:54 +00:00
|
|
|
cpi->max_target = 7;
|
|
|
|
cpi->max_lun = 0;
|
|
|
|
cpi->initiator_id = VP0_INITIATOR;
|
|
|
|
cpi->bus_id = sim->bus_id;
|
Add a number of interrelated CAM feature enhancements and bug fixes.
NOTE: These changes will require recompilation of any userland
applications, like cdrecord, xmcd, etc., that use the CAM passthrough
interface. A make world is recommended.
camcontrol.[c8]:
- We now support two new commands, "tags" and "negotiate".
- The tags commands allows users to view the number of tagged
openings for a device as well as a number of other related
parameters, and it allows users to set tagged openings for
a device.
- The negotiate command allows users to enable and disable
disconnection and tagged queueing, set sync rates, offsets
and bus width. Note that not all of those features are
available for all controllers. Only the adv, ahc, and ncr
drivers fully support all of the features at this point.
Some cards do not allow the setting of sync rates, offsets and
the like, and some of the drivers don't have any facilities to
do so. Some drivers, like the adw driver, only support enabling
or disabling sync negotiation, but do not support setting sync
rates.
- new description in the camcontrol man page of how to format a disk
- cleanup of the camcontrol inquiry command
- add support in the 'devlist' command for skipping unconfigured devices if
-v was not specified on the command line.
- make use of the new base_transfer_speed in the path inquiry CCB.
- fix CCB bzero cases
cam_xpt.c, cam_sim.[ch], cam_ccb.h:
- new flags on many CCB function codes to designate whether they're
non-immediate, use a user-supplied CCB, and can only be passed from
userland programs via the xpt device. Use these flags in the transport
layer and pass driver to categorize CCBs.
- new flag in the transport layer device matching code for device nodes
that indicates whether a device is unconfigured
- bump the CAM version from 0x10 to 0x11
- Change the CAM ioctls to use the version as their group code, so we can
force users to recompile code even when the CCB size doesn't change.
- add + fill in a new value in the path inquiry CCB, base_transfer_speed.
Remove a corresponding field from the cam_sim structure, and add code to
every SIM to set this field to the proper value.
- Fix the set transfer settings code in the transport layer.
scsi_cd.c:
- make some variables volatile instead of just casting them in various
places
- fix a race condition in the changer code
- attach unless we get a "logical unit not supported" error. This should
fix all of the cases where people have devices that return weird errors
when they don't have media in the drive.
scsi_da.c:
- attach unless we get a "logical unit not supported" error
scsi_pass.c:
- for immediate CCBs, just malloc a CCB to send the user request in. This
gets rid of the 'held' count problem in camcontrol tags.
scsi_pass.h:
- change the CAM ioctls to use the CAM version as their group code.
adv driver:
- Allow changing the sync rate and offset separately.
adw driver
- Allow changing the sync rate and offset separately.
aha driver:
- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.
ahc driver:
- Allow setting offset and sync rate separately
bt driver:
- Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.
NCR driver:
- Fix the ultra/ultra 2 negotiation bug
- allow setting both the sync rate and offset separately
Other HBA drivers:
- Put code in to set the base_transfer_speed field for
XPT_GET_TRAN_SETTINGS CCBs.
Reviewed by: gibbs, mjacob (isp), imp (aha)
1999-05-06 20:16:39 +00:00
|
|
|
cpi->base_transfer_speed = 3300;
|
1998-09-20 14:41:54 +00:00
|
|
|
strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
|
|
|
|
strncpy(cpi->hba_vid, "Iomega", HBA_IDLEN);
|
|
|
|
strncpy(cpi->dev_name, sim->sim_name, DEV_IDLEN);
|
|
|
|
cpi->unit_number = sim->unit_number;
|
|
|
|
|
|
|
|
cpi->ccb_h.status = CAM_REQ_CMP;
|
|
|
|
xpt_done(ccb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
ccb->ccb_h.status = CAM_REQ_INVALID;
|
|
|
|
xpt_done(ccb);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vpo_poll(struct cam_sim *sim)
|
|
|
|
{
|
|
|
|
/* The ZIP is actually always polled throw vpo_action() */
|
|
|
|
return;
|
1997-08-14 13:57:45 +00:00
|
|
|
}
|