CAM support.
Submitted by: NOKUBI Hirotaka <hnokubi@yyy.or.jp> and Takahashi Yoshihiro <nyan@wyvern.cc.kogakuin.ac.jp>
This commit is contained in:
parent
ea122a9130
commit
790434fad1
@ -39,21 +39,30 @@
|
||||
#include <i386/isa/bs/bsif.h>
|
||||
#endif
|
||||
|
||||
#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>
|
||||
|
||||
/*****************************************************************
|
||||
* Inline phase funcs
|
||||
*****************************************************************/
|
||||
/* static inline declare */
|
||||
static BS_INLINE struct targ_info *bs_reselect __P((struct bs_softc *));
|
||||
static BS_INLINE void bs_sat_continue __P((struct bs_softc *, struct targ_info *, struct ccb *));
|
||||
static BS_INLINE struct targ_info *bs_selected __P((struct bs_softc *, struct targ_info *, struct ccb *));
|
||||
static BS_INLINE void bs_sat_continue __P((struct bs_softc *, struct targ_info *, struct bsccb *));
|
||||
static BS_INLINE struct targ_info *bs_selected __P((struct bs_softc *, struct targ_info *, struct bsccb *));
|
||||
static BS_INLINE u_int8_t bs_read_1byte __P((struct bs_softc *));
|
||||
static BS_INLINE void bs_write_1byte __P((struct bs_softc *, u_int8_t));
|
||||
static BS_INLINE void bs_commandout __P((struct bs_softc *, struct targ_info *, struct ccb *));
|
||||
static BS_INLINE void bs_commandout __P((struct bs_softc *, struct targ_info *, struct bsccb *));
|
||||
static BS_INLINE void bs_status_check __P((struct bs_softc *, struct targ_info *));
|
||||
static BS_INLINE void bs_msgin __P((struct bs_softc *, struct targ_info *));
|
||||
static BS_INLINE void bs_msgout __P((struct bs_softc *, struct targ_info *, struct ccb *));
|
||||
static BS_INLINE void bs_disconnect_phase __P((struct bs_softc *, struct targ_info *, struct ccb *));
|
||||
static void bs_phase_error __P((struct targ_info *, struct ccb *));
|
||||
static BS_INLINE void bs_msgout __P((struct bs_softc *, struct targ_info *, struct bsccb *));
|
||||
static BS_INLINE void bs_disconnect_phase __P((struct bs_softc *, struct targ_info *, struct bsccb *));
|
||||
static void bs_phase_error __P((struct targ_info *, struct bsccb *));
|
||||
static int bs_scsi_cmd_poll_internal __P((struct targ_info *));
|
||||
static int bs_xfer __P((struct bs_softc *, char *, int));
|
||||
static void bs_io_xfer __P((struct targ_info *));
|
||||
@ -64,99 +73,153 @@ static void bs_msg_reject __P((struct targ_info *));
|
||||
static void bshoststart __P((struct bs_softc *, struct targ_info *));
|
||||
|
||||
/*****************************************************************
|
||||
* Julian scsi interface
|
||||
* SIM interface
|
||||
*****************************************************************/
|
||||
XSBS_INT32T
|
||||
bs_scsi_cmd(xs)
|
||||
struct scsi_xfer *xs;
|
||||
void
|
||||
bs_scsi_cmd(struct cam_sim *sim, union ccb *ccb)
|
||||
{
|
||||
struct bs_softc *bsc = (struct bs_softc *) xs->sc_link->adapter_softc;
|
||||
int s, target = (u_int) (xs->sc_link->target);
|
||||
struct bs_softc *bsc = (struct bs_softc *) cam_sim_softc(sim);
|
||||
int s, target = (u_int) (ccb->ccb_h.target_id);
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
u_int flags = xs->flags;
|
||||
struct bsccb *cb;
|
||||
|
||||
switch (ccb->ccb_h.func_code) {
|
||||
case XPT_SCSI_IO: /* Execute the requested I/O operation */
|
||||
ti = bsc->sc_ti[target];
|
||||
if ((cb = bs_get_ccb()) == NULL) {
|
||||
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
|
||||
xpt_done(ccb);
|
||||
return;
|
||||
}
|
||||
|
||||
/* make up ccb! */
|
||||
cb->ccb = ccb;
|
||||
cb->lun = ccb->ccb_h.target_lun;
|
||||
cb->cmd = ccb->csio.cdb_io.cdb_bytes;
|
||||
cb->cmdlen = (int) ccb->csio.cdb_len;
|
||||
cb->data = ccb->csio.data_ptr;
|
||||
cb->datalen = (int) ccb->csio.dxfer_len;
|
||||
cb->rcnt = 0;
|
||||
cb->msgoutlen = 0;
|
||||
cb->bsccb_flags = 0;
|
||||
bs_targ_flags(ti, cb);
|
||||
cb->tcmax = 0;/*(xs->timeout >> 10); default HN2*/
|
||||
if (cb->tcmax < BS_DEFAULT_TIMEOUT_SECOND)
|
||||
cb->tcmax = BS_DEFAULT_TIMEOUT_SECOND;
|
||||
|
||||
if (xs->bp == NULL && (bsc->sc_openf & (1 << target)) == 0)
|
||||
{
|
||||
s = splbio();
|
||||
xs->error = XS_DRIVER_STUFFUP;
|
||||
xs->flags |= XSBS_ITSDONE;
|
||||
scsi_done(xs);
|
||||
splx(s);
|
||||
return COMPLETE;
|
||||
}
|
||||
|
||||
ti = bsc->sc_ti[target];
|
||||
if ((cb = bs_get_ccb(flags & XSBS_SCSI_NOSLEEP)) == NULL)
|
||||
return TRY_AGAIN_LATER;
|
||||
TAILQ_INSERT_TAIL(&ti->ti_ctab, cb, ccb_chain);
|
||||
|
||||
/* make up ccb! */
|
||||
cb->xs = xs;
|
||||
cb->lun = xs->sc_link->lun;
|
||||
cb->cmd = (u_int8_t *) xs->cmd;
|
||||
cb->cmdlen = (int) xs->cmdlen;
|
||||
cb->data = (u_int8_t *) xs->data;
|
||||
cb->datalen = (int) xs->datalen;
|
||||
cb->rcnt = 0;
|
||||
cb->msgoutlen = 0;
|
||||
cb->flags = (flags & XSBS_SCSI_POLL) ? BSFORCEIOPOLL : 0;
|
||||
bs_targ_flags(ti, cb);
|
||||
cb->tcmax = (xs->timeout >> 10);
|
||||
if (cb->tcmax < BS_DEFAULT_TIMEOUT_SECOND)
|
||||
cb->tcmax = BS_DEFAULT_TIMEOUT_SECOND;
|
||||
|
||||
#ifdef BS_ADDRESS_CHECK
|
||||
/* XXX:
|
||||
* Sanity check, however this is critical!
|
||||
* NetBSD 1.0: WRONG
|
||||
* NetBSD 1.1: OK
|
||||
* FreeBSD: WRONG
|
||||
*/
|
||||
if ((caddr_t) cb->data < (caddr_t) KERNBASE)
|
||||
{
|
||||
u_int8_t *altbp;
|
||||
|
||||
altbp = (u_int8_t *) malloc(cb->datalen, M_DEVBUF, M_NOWAIT);
|
||||
if (altbp == NULL)
|
||||
{
|
||||
bs_free_ccb(cb);
|
||||
return TRY_AGAIN_LATER;
|
||||
}
|
||||
|
||||
if (flags & SCSI_DATA_OUT)
|
||||
bcopy(cb->data, altbp, cb->datalen);
|
||||
else
|
||||
bzero(altbp, cb->datalen);
|
||||
|
||||
cb->data = (u_int8_t *) altbp;
|
||||
cb->flags |= BSALTBUF;
|
||||
}
|
||||
#endif /* BS_ADDRESS_CHECK */
|
||||
|
||||
s = splbio();
|
||||
|
||||
TAILQ_INSERT_TAIL(&ti->ti_ctab, cb, ccb_chain);
|
||||
|
||||
if (ti->ti_phase == FREE)
|
||||
{
|
||||
if (ti->ti_state == BS_TARG_START)
|
||||
{
|
||||
if ((flags & XSBS_SCSI_POLL) == 0)
|
||||
if (ti->ti_phase == FREE) {
|
||||
if (ti->ti_state == BS_TARG_START)
|
||||
bs_start_syncmsg(ti, NULL, BS_SYNCMSG_ASSERT);
|
||||
bscmdstart(ti, BSCMDSTART);
|
||||
}
|
||||
bscmdstart(ti, BSCMDSTART);
|
||||
}
|
||||
|
||||
if ((flags & XSBS_SCSI_POLL) == 0)
|
||||
{
|
||||
splx(s);
|
||||
return SUCCESSFULLY_QUEUED;
|
||||
break;
|
||||
case XPT_RESET_DEV: /* Bus Device Reset the specified SCSI device */
|
||||
case XPT_EN_LUN: /* Enable LUN as a target */
|
||||
case XPT_TARGET_IO: /* Execute target I/O request */
|
||||
case XPT_ACCEPT_TARGET_IO: /* Accept Host Target Mode CDB */
|
||||
case XPT_CONT_TARGET_IO: /* Continue Host Target I/O Connection*/
|
||||
case XPT_ABORT: /* Abort the specified CCB */
|
||||
/* XXX Implement */
|
||||
ccb->ccb_h.status = CAM_REQ_INVALID;
|
||||
xpt_done(ccb);
|
||||
break;
|
||||
case XPT_SET_TRAN_SETTINGS:
|
||||
/* XXX Implement */
|
||||
ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
|
||||
xpt_done(ccb);
|
||||
break;
|
||||
case XPT_GET_TRAN_SETTINGS: {
|
||||
struct ccb_trans_settings *cts;
|
||||
struct targ_info *ti;
|
||||
/*int s;*/
|
||||
|
||||
cts = &ccb->cts;
|
||||
ti = bsc->sc_ti[ccb->ccb_h.target_id];
|
||||
/*s = splcam();*/
|
||||
if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) {
|
||||
if (ti->ti_cfgflags & BS_SCSI_DISC)
|
||||
cts->flags = CCB_TRANS_DISC_ENB;
|
||||
else
|
||||
cts->flags = 0;
|
||||
if (ti->ti_cfgflags & BS_SCSI_QTAG)
|
||||
cts->flags |= CCB_TRANS_TAG_ENB;
|
||||
cts->sync_period = ti->ti_syncnow.period;
|
||||
cts->sync_offset = ti->ti_syncnow.offset;
|
||||
cts->bus_width = 0;/*HN2*/
|
||||
|
||||
cts->valid = CCB_TRANS_SYNC_RATE_VALID
|
||||
| CCB_TRANS_SYNC_OFFSET_VALID
|
||||
| CCB_TRANS_BUS_WIDTH_VALID
|
||||
| CCB_TRANS_DISC_VALID
|
||||
| CCB_TRANS_TQ_VALID;
|
||||
ccb->ccb_h.status = CAM_REQ_CMP;
|
||||
} else
|
||||
ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
|
||||
|
||||
/*splx(s);*/
|
||||
xpt_done(ccb);
|
||||
break;
|
||||
}
|
||||
case XPT_CALC_GEOMETRY: { /* not yet HN2 */
|
||||
struct ccb_calc_geometry *ccg;
|
||||
u_int32_t size_mb;
|
||||
u_int32_t secs_per_cylinder;
|
||||
|
||||
bs_scsi_cmd_poll(ti, cb);
|
||||
splx(s);
|
||||
ccg = &ccb->ccg;
|
||||
size_mb = ccg->volume_size
|
||||
/ ((1024L * 1024L) / ccg->block_size);
|
||||
|
||||
ccg->heads = 8;
|
||||
ccg->secs_per_track = 34;
|
||||
|
||||
return COMPLETE;
|
||||
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;
|
||||
}
|
||||
case XPT_RESET_BUS: /* Reset the specified SCSI bus */
|
||||
bshw_chip_reset(bsc); /* XXX need perfect RESET? */
|
||||
ccb->ccb_h.status = CAM_REQ_CMP;
|
||||
xpt_done(ccb);
|
||||
break;
|
||||
case XPT_TERM_IO: /* Terminate the I/O process */
|
||||
/* XXX Implement */
|
||||
ccb->ccb_h.status = CAM_REQ_INVALID;
|
||||
xpt_done(ccb);
|
||||
break;
|
||||
case XPT_PATH_INQ: { /* Path routing inquiry */
|
||||
struct ccb_pathinq *cpi = &ccb->cpi;
|
||||
|
||||
cpi->version_num = 1; /* XXX??? */
|
||||
cpi->hba_inquiry = PI_SDTR_ABLE;
|
||||
cpi->target_sprt = 0;
|
||||
cpi->hba_misc = 0;
|
||||
cpi->hba_eng_cnt = 0;
|
||||
cpi->max_target = NTARGETS - 1;
|
||||
cpi->max_lun = 7;
|
||||
cpi->initiator_id = bsc->sc_hostid;
|
||||
cpi->bus_id = cam_sim_bus(sim);
|
||||
strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
|
||||
strncpy(cpi->hba_vid, "NEC", HBA_IDLEN);
|
||||
strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
|
||||
cpi->unit_number = cam_sim_unit(sim);
|
||||
cpi->ccb_h.status = CAM_REQ_CMP;
|
||||
xpt_done(ccb);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/*printf("bs: non support func_code = %d ", ccb->ccb_h.func_code);*/
|
||||
ccb->ccb_h.status = CAM_REQ_INVALID;
|
||||
xpt_done(ccb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
@ -170,7 +233,7 @@ bscmdstart(ti, flags)
|
||||
struct targ_info *ti;
|
||||
int flags;
|
||||
{
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
struct bs_softc *bsc = ti->ti_bsc;
|
||||
|
||||
if ((cb = ti->ti_ctab.tqh_first) == NULL)
|
||||
@ -186,9 +249,9 @@ bscmdstart(ti, flags)
|
||||
ti->ti_scsp.datalen = cb->datalen;
|
||||
ti->ti_scsp.seglen = 0;
|
||||
if (cb->rcnt)
|
||||
cb->flags &= ~(BSSAT | BSLINK);
|
||||
cb->bsccb_flags &= ~(BSSAT | BSLINK);
|
||||
ti->ti_flags &= ~BSCFLAGSMASK;
|
||||
ti->ti_flags |= cb->flags & BSCFLAGSMASK;
|
||||
ti->ti_flags |= cb->bsccb_flags & BSCFLAGSMASK;
|
||||
cb->tc = cb->tcmax;
|
||||
|
||||
/* GO GO */
|
||||
@ -211,13 +274,13 @@ bscmdstart(ti, flags)
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct ccb *
|
||||
struct bsccb *
|
||||
bscmddone(ti)
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct bs_softc *bsc = ti->ti_bsc;
|
||||
struct ccb *cb = ti->ti_ctab.tqh_first;
|
||||
struct scsi_xfer *xs;
|
||||
struct bsccb *cb = ti->ti_ctab.tqh_first;
|
||||
union ccb *ccb;
|
||||
int error;
|
||||
|
||||
if (ti->ti_state == BS_TARG_SYNCH)
|
||||
@ -233,12 +296,12 @@ bscmddone(ti)
|
||||
|
||||
do
|
||||
{
|
||||
xs = cb->xs;
|
||||
error = XS_NOERROR;
|
||||
ccb = cb->ccb;
|
||||
error = CAM_REQ_CMP;
|
||||
|
||||
if (cb->flags & (BSITSDONE | BSSENSECCB | BSCASTAT))
|
||||
if (cb->bsccb_flags & (BSITSDONE | BSSENSECCB | BSCASTAT))
|
||||
{
|
||||
if (cb->flags & BSSENSECCB)
|
||||
if (cb->bsccb_flags & BSSENSECCB)
|
||||
{
|
||||
cb->error &= ~BSDMAABNORMAL;
|
||||
if (cb->error == 0)
|
||||
@ -246,18 +309,17 @@ bscmddone(ti)
|
||||
|
||||
ti->ti_flags |= BSERROROK;
|
||||
}
|
||||
else if (cb->flags & BSCASTAT)
|
||||
else if (cb->bsccb_flags & BSCASTAT)
|
||||
{
|
||||
if (ti->ti_flags & BSCASTAT)
|
||||
{
|
||||
ti->ti_flags &= ~BSCASTAT;
|
||||
error = XS_SENSE;
|
||||
if (xs)
|
||||
xs->sense = ti->sense;
|
||||
error = CAM_AUTOSNS_VALID|CAM_SCSI_STATUS_ERROR;
|
||||
if (ccb)
|
||||
ccb->csio.sense_data = ti->sense;/* XXX may not be csio.... */
|
||||
}
|
||||
else
|
||||
error = XS_DRIVER_STUFFUP;
|
||||
|
||||
error = CAM_AUTOSENSE_FAIL;
|
||||
ti->ti_flags |= BSERROROK;
|
||||
} else
|
||||
bs_panic(bsc, "internal error");
|
||||
@ -271,11 +333,11 @@ bscmddone(ti)
|
||||
if (cb->rcnt >= bsc->sc_retry || (cb->error & BSFATALIO))
|
||||
{
|
||||
if (cb->error & (BSSELTIMEOUT | BSTIMEOUT))
|
||||
error = XS_TIMEOUT;
|
||||
error = CAM_CMD_TIMEOUT;
|
||||
else if (cb->error & BSTARGETBUSY)
|
||||
error = XS_BUSY;
|
||||
error = CAM_SCSI_STATUS_ERROR;
|
||||
else
|
||||
error = XS_DRIVER_STUFFUP;
|
||||
error = CAM_REQ_CMP_ERR;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -283,7 +345,7 @@ bscmddone(ti)
|
||||
{
|
||||
/* must clear the target's sense state */
|
||||
cb->rcnt++;
|
||||
cb->flags |= (BSITSDONE | BSCASTAT);
|
||||
cb->bsccb_flags |= (BSITSDONE | BSCASTAT);
|
||||
cb->error &= ~BSREQSENSE;
|
||||
return bs_request_sense(ti);
|
||||
}
|
||||
@ -295,16 +357,15 @@ bscmddone(ti)
|
||||
cb->error &= ~BSDMAABNORMAL;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((xs && xs->bp) || (cb->error & BSSELTIMEOUT) == 0)
|
||||
if (/*(xs && xs->bp) || can't know whether bufferd i/o or not */
|
||||
(cb->error & BSSELTIMEOUT) == 0)
|
||||
bs_debug_print(bsc, ti);
|
||||
|
||||
cb->rcnt++;
|
||||
return cb;
|
||||
}
|
||||
|
||||
#ifdef BS_DIAG
|
||||
cb->flags |= BSITSDONE;
|
||||
cb->bsccb_flags |= BSITSDONE;
|
||||
#endif /* BS_DIAG */
|
||||
if (bsc->sc_poll)
|
||||
{
|
||||
@ -315,28 +376,18 @@ bscmddone(ti)
|
||||
|
||||
TAILQ_REMOVE(&ti->ti_ctab, cb, ccb_chain);
|
||||
|
||||
if (xs)
|
||||
if (ccb)
|
||||
{
|
||||
#ifdef BS_ADDRESS_CHECK
|
||||
if (cb->flags & BSALTBUF)
|
||||
{
|
||||
if (xs->flags & SCSI_DATA_IN)
|
||||
bcopy(cb->data, xs->data, cb->datalen);
|
||||
free(cb->data, M_DEVBUF);
|
||||
}
|
||||
#endif /* BS_ADDRESS_CHECK */
|
||||
|
||||
if ((xs->error = error) == XS_NOERROR)
|
||||
xs->resid = 0;
|
||||
xs->flags |= XSBS_ITSDONE;
|
||||
scsi_done(xs);
|
||||
ccb->ccb_h.status = error;
|
||||
ccb->csio.scsi_status = ti->ti_status;/*XXX*/
|
||||
xpt_done(ccb);
|
||||
}
|
||||
|
||||
bs_free_ccb(cb);
|
||||
cb = ti->ti_ctab.tqh_first;
|
||||
|
||||
}
|
||||
while (cb != NULL && (cb->flags & BSITSDONE) != 0);
|
||||
while (cb != NULL && (cb->bsccb_flags & BSITSDONE) != 0);
|
||||
|
||||
/* complete */
|
||||
return NULL;
|
||||
@ -353,7 +404,7 @@ bshoststart(bsc, ti)
|
||||
struct bs_softc *bsc;
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
int s;
|
||||
|
||||
if (bsc->sc_flags & BSINACTIVE)
|
||||
@ -376,7 +427,7 @@ bshoststart(bsc, ti)
|
||||
}
|
||||
|
||||
#ifdef BS_DIAG
|
||||
if (cb->flags & BSITSDONE)
|
||||
if (cb->bsccb_flags & BSITSDONE)
|
||||
bs_panic(bsc, "bshoststart: already done");
|
||||
|
||||
if (bsc->sc_nexus || (ti->ti_flags & BSNEXUS))
|
||||
@ -495,7 +546,7 @@ static BS_INLINE struct targ_info *
|
||||
bs_selected(bsc, ti, cb)
|
||||
struct bs_softc *bsc;
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
|
||||
if (bsc->sc_busstat != BSR_SELECTED)
|
||||
@ -587,7 +638,7 @@ static BS_INLINE void
|
||||
bs_sat_continue(bsc, ti, cb)
|
||||
struct bs_softc *bsc;
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
|
||||
BS_SETUP_PHASE(SATRESEL);
|
||||
@ -720,7 +771,7 @@ static BS_INLINE void
|
||||
bs_commandout(bsc, ti, cb)
|
||||
struct bs_softc *bsc;
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
u_int8_t scsi_cmd[16];
|
||||
int len;
|
||||
@ -780,7 +831,7 @@ bs_quick_abort(ti, msg)
|
||||
struct targ_info *ti;
|
||||
u_int msg;
|
||||
{
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
|
||||
if ((cb = ti->ti_ctab.tqh_first) == NULL)
|
||||
return;
|
||||
@ -816,7 +867,7 @@ bs_msgin_ext(ti)
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct bs_softc *bsc = ti->ti_bsc;
|
||||
struct ccb *cb = ti->ti_ctab.tqh_first;
|
||||
struct bsccb *cb = ti->ti_ctab.tqh_first;
|
||||
int count;
|
||||
u_int reqlen;
|
||||
u_int32_t *ptr;
|
||||
@ -889,14 +940,14 @@ bs_msg_reject(ti)
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct bs_softc *bsc = ti->ti_bsc;
|
||||
struct ccb *cb = ti->ti_ctab.tqh_first;
|
||||
struct bsccb *cb = ti->ti_ctab.tqh_first;
|
||||
char *s = "unexpected msg reject";
|
||||
|
||||
switch (ti->ti_ophase)
|
||||
{
|
||||
case CMDPHASE:
|
||||
s = "cmd rejected";
|
||||
cb->flags &= ~BSLINK;
|
||||
cb->bsccb_flags &= ~BSLINK;
|
||||
BS_SETUP_MSGPHASE(IOCOMPLETED);
|
||||
break;
|
||||
|
||||
@ -904,7 +955,7 @@ bs_msg_reject(ti)
|
||||
if (ti->ti_msgout & 0x80)
|
||||
{
|
||||
s = "identify msg rejected";
|
||||
cb->flags &= ~BSDISC;
|
||||
cb->bsccb_flags &= ~BSDISC;
|
||||
BS_SETUP_MSGPHASE(IOCOMPLETED);
|
||||
}
|
||||
else if (ti->ti_msgout == MSG_EXTEND)
|
||||
@ -1039,7 +1090,7 @@ static BS_INLINE void
|
||||
bs_msgout(bsc, ti, cb)
|
||||
struct bs_softc *bsc;
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
u_int8_t msg[MAXMSGLEN + 1];
|
||||
|
||||
@ -1114,7 +1165,7 @@ static BS_INLINE void
|
||||
bs_disconnect_phase(bsc, ti, cb)
|
||||
struct bs_softc *bsc;
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
|
||||
switch (bsc->sc_msgphase)
|
||||
@ -1186,7 +1237,7 @@ struct bs_err bs_cmderr[] = {
|
||||
static void
|
||||
bs_phase_error(ti, cb)
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
struct bs_softc *bsc = ti->ti_bsc;
|
||||
struct bs_err *pep;
|
||||
@ -1242,13 +1293,13 @@ bs_phase_error(ti, cb)
|
||||
/**************************************************
|
||||
* ### SCSI PHASE SEQUENCER ###
|
||||
**************************************************/
|
||||
static BS_INLINE void bs_ack_wait __P((struct bs_softc *, struct targ_info *, struct ccb *));
|
||||
static BS_INLINE void bs_ack_wait __P((struct bs_softc *, struct targ_info *, struct bsccb *));
|
||||
|
||||
static BS_INLINE void
|
||||
bs_ack_wait(bsc, ti, cb)
|
||||
struct bs_softc *bsc;
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
int wc = bsc->sc_wc;
|
||||
|
||||
@ -1287,7 +1338,7 @@ bs_sequencer(bsc)
|
||||
struct bs_softc *bsc;
|
||||
{
|
||||
register struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
|
||||
/**************************************************
|
||||
* Check reset
|
||||
@ -1372,7 +1423,7 @@ bs_sequencer(bsc)
|
||||
|
||||
default:
|
||||
/* XXX:
|
||||
* check check check for safty !!
|
||||
* check check check for safety !!
|
||||
*/
|
||||
if (bsc->sc_selwait)
|
||||
{
|
||||
@ -1531,7 +1582,7 @@ bs_scsi_cmd_poll_internal(cti)
|
||||
{
|
||||
struct bs_softc *bsc = cti->ti_bsc;
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
int i, waits, delay_count;
|
||||
|
||||
bsc->sc_poll++;
|
||||
@ -1550,7 +1601,7 @@ bs_scsi_cmd_poll_internal(cti)
|
||||
{
|
||||
ti->ti_flags |= BSFORCEIOPOLL;
|
||||
if ((cb = ti->ti_ctab.tqh_first) != NULL)
|
||||
cb->flags |= BSFORCEIOPOLL;
|
||||
cb->bsccb_flags |= BSFORCEIOPOLL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1579,7 +1630,7 @@ bs_scsi_cmd_poll_internal(cti)
|
||||
int
|
||||
bs_scsi_cmd_poll(cti, targetcb)
|
||||
struct targ_info *cti;
|
||||
struct ccb *targetcb;
|
||||
struct bsccb *targetcb;
|
||||
{
|
||||
struct bs_softc *bsc = cti->ti_bsc;
|
||||
struct targ_info *ti;
|
||||
|
@ -51,7 +51,7 @@ int bs_debug_flag = 0;
|
||||
|
||||
static void bs_print_syncmsg __P((struct targ_info *, char*));
|
||||
static void bs_timeout_target __P((struct targ_info *));
|
||||
static void bs_kill_msg __P((struct ccb *cb));
|
||||
static void bs_kill_msg __P((struct bsccb *cb));
|
||||
|
||||
static int bs_start_target __P((struct targ_info *));
|
||||
static int bs_check_target __P((struct targ_info *));
|
||||
@ -59,8 +59,8 @@ static int bs_check_target __P((struct targ_info *));
|
||||
/*************************************************************
|
||||
* CCB
|
||||
************************************************************/
|
||||
GENERIC_CCB_STATIC_ALLOC(bs, ccb)
|
||||
GENERIC_CCB(bs, ccb, ccb_chain)
|
||||
GENERIC_CCB_STATIC_ALLOC(bs, bsccb)
|
||||
GENERIC_CCB(bs, bsccb, ccb_chain)
|
||||
|
||||
/*************************************************************
|
||||
* TIMEOUT
|
||||
@ -87,7 +87,7 @@ bstimeout(arg)
|
||||
{
|
||||
struct bs_softc *bsc = (struct bs_softc *) arg;
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
int s;
|
||||
|
||||
s = splbio();
|
||||
@ -126,7 +126,7 @@ bstimeout(arg)
|
||||
*************************************************/
|
||||
static u_int8_t cmd_unit_ready[6];
|
||||
|
||||
struct ccb *
|
||||
struct bsccb *
|
||||
bs_make_internal_ccb(ti, lun, cmd, cmdlen, data, datalen, flags, timeout)
|
||||
struct targ_info *ti;
|
||||
u_int lun;
|
||||
@ -137,19 +137,19 @@ bs_make_internal_ccb(ti, lun, cmd, cmdlen, data, datalen, flags, timeout)
|
||||
u_int flags;
|
||||
int timeout;
|
||||
{
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
|
||||
if ((cb = bs_get_ccb(XSBS_SCSI_NOSLEEP)) == NULL)
|
||||
if ((cb = bs_get_ccb()) == NULL)
|
||||
bs_panic(ti->ti_bsc, "can not get ccb mem");
|
||||
|
||||
cb->xs = NULL;
|
||||
cb->ccb = NULL;
|
||||
cb->lun = lun;
|
||||
cb->cmd = (cmd ? cmd : cmd_unit_ready);
|
||||
cb->cmdlen = (cmd ? cmdlen : sizeof(cmd_unit_ready));
|
||||
cb->data = data;
|
||||
cb->datalen = (data ? datalen : 0);
|
||||
cb->msgoutlen = 0;
|
||||
cb->flags = flags & BSCFLAGSMASK;
|
||||
cb->bsccb_flags = flags & BSCFLAGSMASK;
|
||||
bs_targ_flags(ti, cb);
|
||||
cb->rcnt = 0;
|
||||
cb->tcmax = (timeout > BS_DEFAULT_TIMEOUT_SECOND ? timeout :
|
||||
@ -160,11 +160,11 @@ bs_make_internal_ccb(ti, lun, cmd, cmdlen, data, datalen, flags, timeout)
|
||||
return cb;
|
||||
}
|
||||
|
||||
struct ccb *
|
||||
struct bsccb *
|
||||
bs_make_msg_ccb(ti, lun, cb, msg, timex)
|
||||
struct targ_info *ti;
|
||||
u_int lun;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
struct msgbase *msg;
|
||||
u_int timex;
|
||||
{
|
||||
@ -175,7 +175,7 @@ bs_make_msg_ccb(ti, lun, cb, msg, timex)
|
||||
cb = bs_make_internal_ccb(ti, lun, NULL, 0, NULL, 0,
|
||||
flags, timex);
|
||||
else
|
||||
cb->flags |= flags & BSCFLAGSMASK;
|
||||
cb->bsccb_flags |= flags & BSCFLAGSMASK;
|
||||
|
||||
cb->msgoutlen = msg->msglen;
|
||||
bcopy(msg->msg, cb->msgout, msg->msglen);
|
||||
@ -189,7 +189,7 @@ bs_send_msg(ti, lun, msg, timex)
|
||||
struct msgbase *msg;
|
||||
int timex;
|
||||
{
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
|
||||
cb = bs_make_msg_ccb(ti, lun, NULL, msg, timex);
|
||||
bscmdstart(ti, BSCMDSTART);
|
||||
@ -198,7 +198,7 @@ bs_send_msg(ti, lun, msg, timex)
|
||||
|
||||
static void
|
||||
bs_kill_msg(cb)
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
cb->msgoutlen = 0;
|
||||
}
|
||||
@ -206,11 +206,11 @@ bs_kill_msg(cb)
|
||||
/**************************************************
|
||||
* MAKE SENSE CCB
|
||||
**************************************************/
|
||||
struct ccb *
|
||||
struct bsccb *
|
||||
bs_request_sense(ti)
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
|
||||
bzero(ti->scsi_cmd, sizeof(struct scsi_sense));
|
||||
bzero(&ti->sense, sizeof(struct scsi_sense_data));
|
||||
@ -223,7 +223,7 @@ bs_request_sense(ti)
|
||||
sizeof(struct scsi_sense_data),
|
||||
BSFORCEIOPOLL,
|
||||
BS_DEFAULT_TIMEOUT_SECOND);
|
||||
cb->flags |= BSSENSECCB;
|
||||
cb->bsccb_flags |= BSSENSECCB;
|
||||
return cb;
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ bs_request_sense(ti)
|
||||
int
|
||||
bs_start_syncmsg(ti, cb, flag)
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
int flag;
|
||||
{
|
||||
struct syncdata *negp, *maxp;
|
||||
@ -308,7 +308,7 @@ bs_print_syncmsg(ti, s)
|
||||
int
|
||||
bs_analyze_syncmsg(ti, cb)
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
struct bs_softc *bsc = ti->ti_bsc;
|
||||
u_int8_t ans = ti->ti_syncnow.state;
|
||||
@ -411,13 +411,13 @@ bs_reset_device(ti)
|
||||
}
|
||||
|
||||
/* send abort msg */
|
||||
struct ccb *
|
||||
struct bsccb *
|
||||
bs_force_abort(ti)
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct bs_softc *bsc = ti->ti_bsc;
|
||||
struct msgbase msg;
|
||||
struct ccb *cb = ti->ti_ctab.tqh_first;
|
||||
struct bsccb *cb = ti->ti_ctab.tqh_first;
|
||||
u_int lun;
|
||||
|
||||
if (cb)
|
||||
@ -523,7 +523,7 @@ bs_reset_nexus(bsc)
|
||||
struct bs_softc *bsc;
|
||||
{
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
|
||||
bsc->sc_flags &= ~(BSRESET | BSUNDERRESET);
|
||||
if (bsc->sc_poll)
|
||||
@ -575,7 +575,7 @@ bs_reset_nexus(bsc)
|
||||
for ( ; cb; cb = cb->ccb_chain.tqe_next)
|
||||
{
|
||||
bs_kill_msg(cb);
|
||||
cb->flags &= ~(BSITSDONE | BSCASTAT);
|
||||
cb->bsccb_flags &= ~(BSITSDONE | BSCASTAT);
|
||||
cb->error = 0;
|
||||
}
|
||||
|
||||
@ -597,19 +597,15 @@ static int
|
||||
bs_start_target(ti)
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct ccb *cb;
|
||||
struct scsi_start_stop cmd;
|
||||
struct bsccb *cb;
|
||||
struct scsi_start_stop_unit cmd;
|
||||
|
||||
bzero(&cmd, sizeof(struct scsi_start_stop));
|
||||
#ifdef __NetBSD__
|
||||
bzero(&cmd, sizeof(struct scsi_start_stop_unit));
|
||||
cmd.opcode = START_STOP;
|
||||
#else
|
||||
cmd.op_code = START_STOP;
|
||||
#endif
|
||||
cmd.how = SSS_START;
|
||||
ti->ti_lun = 0;
|
||||
cb = bs_make_internal_ccb(ti, 0, (u_int8_t *) &cmd,
|
||||
sizeof(struct scsi_start_stop),
|
||||
sizeof(struct scsi_start_stop_unit),
|
||||
NULL, 0, BSFORCEIOPOLL, BS_MOTOR_TIMEOUT);
|
||||
bscmdstart(ti, BSCMDSTART);
|
||||
return bs_scsi_cmd_poll(ti, cb);
|
||||
@ -623,7 +619,7 @@ bs_check_target(ti)
|
||||
struct bs_softc *bsc = ti->ti_bsc;
|
||||
struct scsi_inquiry scsi_cmd;
|
||||
struct scsi_inquiry_data scsi_inquiry_data;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
int count, retry = bsc->sc_retry;
|
||||
int s, error = COMPLETE;
|
||||
|
||||
@ -633,11 +629,7 @@ bs_check_target(ti)
|
||||
|
||||
/* inquiry */
|
||||
bzero(&scsi_cmd, sizeof(scsi_cmd));
|
||||
#ifdef __NetBSD__
|
||||
scsi_cmd.opcode = INQUIRY;
|
||||
#else
|
||||
scsi_cmd.op_code = INQUIRY;
|
||||
#endif
|
||||
scsi_cmd.length = sizeof(struct scsi_inquiry_data);
|
||||
cb = bs_make_internal_ccb(ti, 0,
|
||||
(u_int8_t *) &scsi_cmd, sizeof(scsi_cmd),
|
||||
@ -662,7 +654,7 @@ bs_check_target(ti)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (cb->flags & BSCASTAT)
|
||||
if (cb->bsccb_flags & BSCASTAT)
|
||||
bs_printf(ti, "check", "could not clear CA state");
|
||||
ti->ti_error = 0;
|
||||
|
||||
@ -897,7 +889,7 @@ bs_debug_print(bsc, ti)
|
||||
struct bs_softc *bsc;
|
||||
struct targ_info *ti;
|
||||
{
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
|
||||
/* host stat */
|
||||
printf("%s <DEBUG INFO> nexus %lx bs %lx bus status %lx \n",
|
||||
@ -921,7 +913,7 @@ bs_debug_print(bsc, ti)
|
||||
sp->datalen, (u_long) sp->data, sp->seglen);
|
||||
if (cb)
|
||||
printf("odatalen %x flags %x\n",
|
||||
cb->datalen, cb->flags);
|
||||
cb->datalen, cb->bsccb_flags);
|
||||
else
|
||||
printf("\n");
|
||||
printf("error flags %b\n", ti->ti_error, BSERRORBITS);
|
||||
|
@ -44,22 +44,22 @@ struct targ_info *bs_init_target_info __P((struct bs_softc *, int));
|
||||
|
||||
/* msg op */
|
||||
int bs_send_msg __P((struct targ_info *, u_int, struct msgbase *, int));
|
||||
struct ccb *bs_request_sense __P((struct targ_info *));
|
||||
struct bsccb *bs_request_sense __P((struct targ_info *));
|
||||
|
||||
/* sync msg op */
|
||||
int bs_start_syncmsg __P((struct targ_info *, struct ccb *, int));
|
||||
int bs_start_syncmsg __P((struct targ_info *, struct bsccb *, int));
|
||||
int bs_send_syncmsg __P((struct targ_info *));
|
||||
int bs_analyze_syncmsg __P((struct targ_info *, struct ccb *));
|
||||
int bs_analyze_syncmsg __P((struct targ_info *, struct bsccb *));
|
||||
|
||||
/* reset device */
|
||||
void bs_scsibus_start __P((struct bs_softc *));
|
||||
void bs_reset_nexus __P((struct bs_softc *));
|
||||
struct ccb *bs_force_abort __P((struct targ_info *));
|
||||
struct bsccb *bs_force_abort __P((struct targ_info *));
|
||||
void bs_reset_device __P((struct targ_info *));
|
||||
|
||||
/* ccb */
|
||||
struct ccb *bs_make_internal_ccb __P((struct targ_info *, u_int, u_int8_t *, u_int, u_int8_t *, u_int, u_int, int));
|
||||
struct ccb *bs_make_msg_ccb __P((struct targ_info *, u_int, struct ccb *, struct msgbase *, u_int));
|
||||
struct bsccb *bs_make_internal_ccb __P((struct targ_info *, u_int, u_int8_t *, u_int, u_int8_t *, u_int, u_int, int));
|
||||
struct bsccb *bs_make_msg_ccb __P((struct targ_info *, u_int, struct bsccb *, struct msgbase *, u_int));
|
||||
|
||||
/* misc funcs */
|
||||
void bs_printf __P((struct targ_info *, char *, char *));
|
||||
@ -77,9 +77,9 @@ void bs_debug_print __P((struct bs_softc *, struct targ_info *));
|
||||
static BS_INLINE int bs_check_sat __P((struct targ_info *));
|
||||
static BS_INLINE int bs_check_smit __P((struct targ_info *));
|
||||
static BS_INLINE int bs_check_disc __P((struct targ_info *));
|
||||
static BS_INLINE int bs_check_link __P((struct targ_info *, struct ccb *));
|
||||
static BS_INLINE int bs_check_link __P((struct targ_info *, struct bsccb *));
|
||||
static BS_INLINE u_int8_t bs_identify_msg __P((struct targ_info *));
|
||||
static BS_INLINE void bs_targ_flags __P((struct targ_info *, struct ccb *));
|
||||
static BS_INLINE void bs_targ_flags __P((struct targ_info *, struct bsccb *));
|
||||
|
||||
static BS_INLINE int
|
||||
bs_check_disc(ti)
|
||||
@ -108,13 +108,13 @@ bs_check_smit(ti)
|
||||
static BS_INLINE int
|
||||
bs_check_link(ti, cb)
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
struct ccb *nextcb;
|
||||
struct bsccb *nextcb;
|
||||
|
||||
return ((ti->ti_flags & BSLINK) &&
|
||||
(nextcb = cb->ccb_chain.tqe_next) &&
|
||||
(nextcb->flags & BSLINK));
|
||||
(nextcb->bsccb_flags & BSLINK));
|
||||
}
|
||||
|
||||
static BS_INLINE u_int8_t
|
||||
@ -128,17 +128,17 @@ bs_identify_msg(ti)
|
||||
static BS_INLINE void
|
||||
bs_targ_flags(ti, cb)
|
||||
struct targ_info *ti;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
{
|
||||
u_int cmf = (u_int) bshw_cmd[cb->cmd[0]];
|
||||
|
||||
cb->flags |= ((cmf & (BSSAT | BSSMIT | BSLINK)) | BSDISC);
|
||||
cb->flags &= ti->ti_mflags;
|
||||
cb->bsccb_flags |= ((cmf & (BSSAT | BSSMIT | BSLINK)) | BSDISC);
|
||||
cb->bsccb_flags &= ti->ti_mflags;
|
||||
|
||||
if (cb->datalen < DEV_BSIZE)
|
||||
cb->flags &= ~BSSMIT;
|
||||
if (cb->flags & BSFORCEIOPOLL)
|
||||
cb->flags &= ~(BSLINK | BSSMIT | BSSAT | BSDISC);
|
||||
cb->bsccb_flags &= ~BSSMIT;
|
||||
if (cb->bsccb_flags & BSFORCEIOPOLL)
|
||||
cb->bsccb_flags &= ~(BSLINK | BSSMIT | BSSAT | BSDISC);
|
||||
}
|
||||
|
||||
/**************************************************
|
||||
|
@ -385,7 +385,7 @@ bshw_setup_ctrl_reg(bsc, flags)
|
||||
void
|
||||
bshw_issue_satcmd(bsc, cb, link)
|
||||
struct bs_softc *bsc;
|
||||
struct ccb *cb;
|
||||
struct bsccb *cb;
|
||||
int link;
|
||||
{
|
||||
int i;
|
||||
|
@ -97,7 +97,7 @@ int bshw_board_probe __P((struct bs_softc *, u_int *, u_int *));
|
||||
void bshw_lock __P((struct bs_softc *));
|
||||
void bshw_unlock __P((struct bs_softc *));
|
||||
void bshw_get_syncreg __P((struct bs_softc *));
|
||||
void bshw_issue_satcmd __P((struct bs_softc *, struct ccb *, int));
|
||||
void bshw_issue_satcmd __P((struct bs_softc *, struct bsccb *, int));
|
||||
void bshw_print_port __P((struct bs_softc *));
|
||||
|
||||
void bs_lc_smit_xfer __P((struct targ_info *, u_int));
|
||||
|
@ -101,7 +101,7 @@ bs_dma_xfer(ti, direction)
|
||||
/* setup segaddr */
|
||||
sp->segaddr = (u_int8_t *) phys;
|
||||
/* setup seglen */
|
||||
endva = (vm_offset_t)round_page(sp->data + sp->datalen);
|
||||
endva = (vm_offset_t)round_page((unsigned long)(sp->data + sp->datalen));
|
||||
for (va = (vm_offset_t) sp->data; ; phys = nphys)
|
||||
{
|
||||
if ((va += BSHW_NBPG) >= endva)
|
||||
|
@ -42,6 +42,15 @@
|
||||
#include <i386/isa/bs/bsif.h>
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
#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>
|
||||
|
||||
/**************************************************
|
||||
* DEVICE DECLARE
|
||||
**************************************************/
|
||||
@ -69,8 +78,9 @@ struct scsi_adapter pc98texa55bs = {
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
static int bsprobe __P((struct isa_device *));
|
||||
static int bsattach __P((struct isa_device *));
|
||||
static inthand2_t bsintr;
|
||||
static void bs_poll(struct cam_sim *sim);
|
||||
static int bsattach(struct isa_device *);
|
||||
static ointhand2_t bsintr;
|
||||
static int bsprint __P((void *, const char *));
|
||||
static void bs_scsi_minphys __P((struct buf *));
|
||||
static int bs_dmarangecheck __P((caddr_t, unsigned));
|
||||
@ -80,7 +90,7 @@ struct isa_driver bsdriver = {
|
||||
bsattach,
|
||||
"bs"
|
||||
};
|
||||
|
||||
#if 0
|
||||
struct scsi_device bs_dev = {
|
||||
NULL, /* Use default error handler */
|
||||
NULL, /* have a queue, served by this */
|
||||
@ -89,14 +99,14 @@ struct scsi_device bs_dev = {
|
||||
"bs",
|
||||
0, {0, 0}
|
||||
};
|
||||
|
||||
#endif
|
||||
u_int32_t
|
||||
bs_adapter_info(unit)
|
||||
int unit;
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static struct scsi_adapter pc98texa55bs = {
|
||||
bs_scsi_cmd,
|
||||
bs_scsi_minphys,
|
||||
@ -105,7 +115,7 @@ static struct scsi_adapter pc98texa55bs = {
|
||||
bs_adapter_info,
|
||||
"bs", {0, 0}
|
||||
};
|
||||
|
||||
#endif
|
||||
static u_short pc98_irq_ball[16] = {
|
||||
IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
|
||||
IRQ8, IRQ9, IRQ10, IRQ11, IRQ12, IRQ13, IRQ14, IRQ15
|
||||
@ -213,6 +223,12 @@ bsprint(aux, name)
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
static void
|
||||
bs_poll(struct cam_sim *sim)
|
||||
{
|
||||
bs_sequencer(cam_sim_softc(sim));
|
||||
}
|
||||
|
||||
static int
|
||||
bsattach(dev)
|
||||
struct isa_device *dev;
|
||||
@ -220,28 +236,37 @@ bsattach(dev)
|
||||
int unit = dev->id_unit;
|
||||
struct bs_softc *bsc = bscdata[unit];
|
||||
struct scsibus_data *scbus;
|
||||
struct cam_devq *devq;
|
||||
|
||||
dev->id_ointr = bsintr;
|
||||
bsc->sc_link.adapter_unit = unit;
|
||||
bsc->sc_link.adapter_targ = bsc->sc_hostid;
|
||||
bsc->sc_link.flags = SDEV_BOUNCE;
|
||||
bsc->sc_link.opennings = XSMAX;
|
||||
bsc->sc_link.adapter_softc = bsc;
|
||||
bsc->sc_link.adapter = &pc98texa55bs;
|
||||
bsc->sc_link.device = &bs_dev;
|
||||
|
||||
/*
|
||||
* Prepare the scsibus_data area for the upperlevel
|
||||
* scsi code.
|
||||
* CAM support HN2 MAX_START, MAX_TAGS xxxx
|
||||
*/
|
||||
scbus = scsi_alloc_bus();
|
||||
if (!scbus)
|
||||
devq = cam_simq_alloc(256/*MAX_START*/);
|
||||
if (devq == NULL)
|
||||
return 0;
|
||||
scbus->adapter_link = &bsc->sc_link;
|
||||
/*
|
||||
* ask the adapter what subunits are present
|
||||
*/
|
||||
scsi_attachdevs(scbus);
|
||||
|
||||
bsc->sim = cam_sim_alloc(bs_scsi_cmd, bs_poll, "bs",
|
||||
bsc, unit, 1, 32/*MAX_TAGS*/, devq);
|
||||
if (bsc->sim == NULL) {
|
||||
cam_simq_free(devq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xpt_bus_register(bsc->sim, 0) != CAM_SUCCESS) {
|
||||
free(bsc->sim, M_DEVBUF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xpt_create_path(&bsc->path, /*periph*/NULL,
|
||||
cam_sim_path(bsc->sim), CAM_TARGET_WILDCARD,
|
||||
CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
|
||||
xpt_bus_deregister(cam_sim_path(bsc->sim));
|
||||
cam_sim_free(bsc->sim, /*free_simq*/TRUE);
|
||||
free(bsc->sim, M_DEVBUF);
|
||||
return 0;
|
||||
}
|
||||
bs_start_timeout(bsc);
|
||||
return 1;
|
||||
}
|
||||
@ -278,7 +303,7 @@ bs_scsi_minphys(bp)
|
||||
bp->b_bcount = BSDMABUFSIZ;
|
||||
minphys(bp);
|
||||
}
|
||||
|
||||
#if 0
|
||||
XSBS_INT32T
|
||||
bs_target_open(sc, cf)
|
||||
struct scsi_link *sc;
|
||||
@ -298,7 +323,7 @@ bs_target_open(sc, cf)
|
||||
bs_setup_ctrl(ti, (u_int)sc->quirks, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
/*****************************************************************
|
||||
* BS MEMORY ALLOCATION INTERFACE
|
||||
*****************************************************************/
|
||||
@ -361,7 +386,7 @@ static int bs_dmarangecheck(caddr_t va, unsigned length)
|
||||
{
|
||||
vm_offset_t phys, priorpage = 0, endva;
|
||||
|
||||
endva = (vm_offset_t)round_page(va+length);
|
||||
endva = (vm_offset_t)round_page((unsigned long)(va+length));
|
||||
for (; va < (caddr_t)endva; va += PAGE_SIZE) {
|
||||
phys = trunc_page(pmap_extract(pmap_kernel(), (vm_offset_t)va));
|
||||
if (phys == 0)
|
||||
|
@ -117,9 +117,11 @@
|
||||
#include <machine/ipl.h>
|
||||
#include <machine/dvcfg.h>
|
||||
|
||||
#include <scsi/scsi_all.h>
|
||||
#include <scsi/scsiconf.h>
|
||||
#include <scsi/scsi_disk.h>
|
||||
#include <cam/scsi/scsi_all.h>
|
||||
#if 0
|
||||
#include <cam/scsi/scsiconf.h>
|
||||
#endif
|
||||
#include <cam/scsi/scsi_da.h>
|
||||
|
||||
#include <pc98/pc98/pc98.h>
|
||||
#include <i386/isa/isa_device.h>
|
||||
@ -173,29 +175,26 @@
|
||||
* xs flags's abstraction (all currently used)
|
||||
***************************************************/
|
||||
#define XSBS_ITSDONE ITSDONE
|
||||
#define XSBS_SCSI_NOSLEEP SCSI_NOSLEEP
|
||||
#ifdef __NetBSD__
|
||||
#define XSBS_SCSI_NOSLEEP SCSI_NOSLEEP
|
||||
#define XSBS_SCSI_POLL SCSI_POLL
|
||||
#endif /* __NetBSD__ */
|
||||
#ifdef __FreeBSD__
|
||||
#define XSBS_SCSI_POLL SCSI_NOMASK
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
/***************************************************
|
||||
* Special operations
|
||||
***************************************************/
|
||||
#ifdef __FreeBSD__
|
||||
#define BS_ADDRESS_CHECK
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
/***************************************************
|
||||
* declare
|
||||
***************************************************/
|
||||
/* (I) common declare */
|
||||
void bs_alloc_buf __P((struct targ_info *));
|
||||
#ifdef __NetBSD__
|
||||
XSBS_INT32T bs_target_open __P((struct scsi_link *, struct cfdata *));
|
||||
XSBS_INT32T bs_scsi_cmd __P((struct scsi_xfer *));
|
||||
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
void bs_scsi_cmd(struct cam_sim *sim, union ccb *ccb);
|
||||
#endif
|
||||
extern int delaycount;
|
||||
|
||||
/* (II) os depend declare */
|
||||
|
@ -92,7 +92,7 @@
|
||||
* PARAMETER
|
||||
**************************************************/
|
||||
#define NTARGETS 8
|
||||
#define RETRIES 4 /* number of retries before giving up */
|
||||
#define RETRIES 0 /* number of retries before giving up */
|
||||
#define HARDRETRIES 3
|
||||
#define XSMAX 4
|
||||
#define BSDMABUFSIZ 0x10000
|
||||
@ -240,7 +240,7 @@ struct sc_p {
|
||||
|
||||
#define BSERRORBITS "\020\014busy\013abnormal\012retry\011msgerr\010fatal\007seltimeout\006sense\005timeout\004statuserr\003parity\002cmderr\001dmaerr"
|
||||
|
||||
/* ccb & targ_info flags & cmd flags*/
|
||||
/* bsccb bsccb_flags & targ_info flags & cmd flags*/
|
||||
#define BSREAD 0x0001
|
||||
#define BSSAT 0x0002
|
||||
#define BSLINK 0x0004
|
||||
@ -258,14 +258,14 @@ struct sc_p {
|
||||
|
||||
#define BSCFLAGSMASK (0xffff)
|
||||
|
||||
struct ccb {
|
||||
TAILQ_ENTRY(ccb) ccb_chain;
|
||||
struct bsccb {
|
||||
TAILQ_ENTRY(bsccb) ccb_chain;
|
||||
|
||||
struct scsi_xfer *xs; /* upper drivers info */
|
||||
union ccb *ccb; /* upper drivers info */
|
||||
|
||||
u_int lun; /* lun */
|
||||
|
||||
u_int flags; /* control flags */
|
||||
u_int bsccb_flags; /* control flags */
|
||||
|
||||
int rcnt; /* retry counter of this ccb */
|
||||
|
||||
@ -290,75 +290,75 @@ struct ccb {
|
||||
int tcmax;
|
||||
};
|
||||
|
||||
GENERIC_CCB_ASSERT(bs, ccb)
|
||||
GENERIC_CCB_ASSERT(bs, bsccb)
|
||||
|
||||
/* target info */
|
||||
struct targ_info {
|
||||
TAILQ_ENTRY(targ_info) ti_tchain; /* targ_info link */
|
||||
/*0*/ TAILQ_ENTRY(targ_info) ti_tchain; /* targ_info link */
|
||||
|
||||
TAILQ_ENTRY(targ_info) ti_wchain; /* wait link */
|
||||
/*4*/ TAILQ_ENTRY(targ_info) ti_wchain; /* wait link */
|
||||
|
||||
struct bs_softc *ti_bsc; /* our controller */
|
||||
u_int ti_id; /* scsi id */
|
||||
u_int ti_lun; /* current lun */
|
||||
/*8*/ struct bs_softc *ti_bsc; /* our controller */
|
||||
/*c*/ u_int ti_id; /* scsi id */
|
||||
/*10*/ u_int ti_lun; /* current lun */
|
||||
|
||||
struct ccbtab ti_ctab, ti_bctab; /* ccb */
|
||||
/*14*/ struct bsccbtab ti_ctab, ti_bctab; /* ccb */
|
||||
|
||||
#define BS_TARG_NULL 0
|
||||
#define BS_TARG_CTRL 1
|
||||
#define BS_TARG_START 2
|
||||
#define BS_TARG_SYNCH 3
|
||||
#define BS_TARG_RDY 4
|
||||
int ti_state; /* target state */
|
||||
/*24*/ int ti_state; /* target state */
|
||||
|
||||
u_int ti_cfgflags; /* target cfg flags */
|
||||
/*28*/ u_int ti_cfgflags; /* target cfg flags */
|
||||
|
||||
u_int ti_flags; /* flags */
|
||||
u_int ti_mflags; /* flags masks */
|
||||
/*2c*/ u_int ti_flags; /* flags */
|
||||
/*30*/ u_int ti_mflags; /* flags masks */
|
||||
|
||||
u_int ti_error; /* error flags */
|
||||
u_int ti_herrcnt; /* hardware err retry counter */
|
||||
/*34*/ u_int ti_error; /* error flags */
|
||||
/*38*/ u_int ti_herrcnt; /* hardware err retry counter */
|
||||
|
||||
/*****************************************
|
||||
* scsi phase data
|
||||
*****************************************/
|
||||
struct sc_p ti_scsp; /* saved scsi data pointer */
|
||||
/*3c*/ struct sc_p ti_scsp; /* saved scsi data pointer */
|
||||
|
||||
enum scsi_phase ti_phase; /* scsi phase */
|
||||
enum scsi_phase ti_ophase; /* previous scsi phase */
|
||||
/*50*/ enum scsi_phase ti_phase; /* scsi phase */
|
||||
/*54*/ enum scsi_phase ti_ophase; /* previous scsi phase */
|
||||
|
||||
u_int8_t ti_status; /* status in */
|
||||
/*58*/ u_int8_t ti_status; /* status in */
|
||||
|
||||
u_int8_t ti_msgin[MAXMSGLEN]; /* msgin buffer */
|
||||
int ti_msginptr;
|
||||
/*59*/ u_int8_t ti_msgin[MAXMSGLEN]; /* msgin buffer */
|
||||
/*64*/ int ti_msginptr;
|
||||
|
||||
u_int8_t ti_msgout; /* last msgout byte */
|
||||
u_int8_t ti_emsgout; /* last msgout byte */
|
||||
u_int ti_omsgoutlen; /* for retry msgout */
|
||||
/*68*/ u_int8_t ti_msgout; /* last msgout byte */
|
||||
/*69*/ u_int8_t ti_emsgout; /* last msgout byte */
|
||||
/*6c*/ u_int ti_omsgoutlen; /* for retry msgout */
|
||||
|
||||
struct syncdata ti_syncmax; /* synch data (scsi) */
|
||||
struct syncdata ti_syncnow;
|
||||
u_int8_t ti_sync; /* synch val (chip) */
|
||||
/*70*/ struct syncdata ti_syncmax; /* synch data (scsi) */
|
||||
/*72*/ struct syncdata ti_syncnow;
|
||||
/*74*/ u_int8_t ti_sync; /* synch val (chip) */
|
||||
|
||||
/*****************************************
|
||||
* bounce buffer & smit data pointer
|
||||
*****************************************/
|
||||
u_int8_t *bounce_phys;
|
||||
u_int8_t *bounce_addr;
|
||||
u_int bounce_size;
|
||||
/*75*/ u_int8_t *bounce_phys;
|
||||
/*76*/ u_int8_t *bounce_addr;
|
||||
/*78*/ u_int bounce_size;
|
||||
|
||||
u_long sm_offset;
|
||||
/*7c*/ u_long sm_offset;
|
||||
|
||||
/*****************************************
|
||||
* target inq data
|
||||
*****************************************/
|
||||
u_int8_t targ_type;
|
||||
u_int8_t targ_support;
|
||||
/*79*/ u_int8_t targ_type;
|
||||
/*7a*/ u_int8_t targ_support;
|
||||
|
||||
/*****************************************
|
||||
* generic scsi cmd buffer for this target
|
||||
*****************************************/
|
||||
u_int8_t scsi_cmd[12];
|
||||
/*7b*/ u_int8_t scsi_cmd[12];
|
||||
struct scsi_sense_data sense;
|
||||
};
|
||||
|
||||
@ -371,8 +371,6 @@ struct bs_softc {
|
||||
*****************************************/
|
||||
OS_DEPEND_DEVICE_HEADER
|
||||
|
||||
OS_DEPEND_SCSI_HEADER
|
||||
|
||||
OS_DEPEND_MISC_HEADER
|
||||
|
||||
/*****************************************
|
||||
@ -433,7 +431,7 @@ struct bs_softc {
|
||||
u_int sc_wc; /* weight count */
|
||||
|
||||
int sc_poll;
|
||||
struct ccb *sc_outccb;
|
||||
struct bsccb *sc_outccb;
|
||||
|
||||
/*****************************************
|
||||
* wd33c93 chip depend section
|
||||
@ -462,6 +460,12 @@ struct bs_softc {
|
||||
*****************************************/
|
||||
#define BS_DVNAME_LEN 16
|
||||
u_char sc_dvname[BS_DVNAME_LEN];
|
||||
|
||||
/*****************************************
|
||||
* CAM support
|
||||
*****************************************/
|
||||
struct cam_sim *sim;
|
||||
struct cam_path *path;
|
||||
};
|
||||
|
||||
/*************************************************
|
||||
@ -496,10 +500,10 @@ extern int bs_debug_flag;
|
||||
/*************************************************
|
||||
* Function declare
|
||||
*************************************************/
|
||||
int bs_scsi_cmd_internal __P((struct ccb *, u_int));
|
||||
struct ccb *bscmddone __P((struct targ_info *));
|
||||
int bs_scsi_cmd_internal __P((struct bsccb *, u_int));
|
||||
struct bsccb *bscmddone __P((struct targ_info *));
|
||||
int bscmdstart __P((struct targ_info *, int));
|
||||
int bs_scsi_cmd_poll __P((struct targ_info *, struct ccb *));
|
||||
int bs_scsi_cmd_poll __P((struct targ_info *, struct bsccb *));
|
||||
int bs_sequencer __P((struct bs_softc *));
|
||||
void bs_poll_timeout __P((struct bs_softc *, char *));
|
||||
|
||||
@ -507,8 +511,9 @@ void bs_poll_timeout __P((struct bs_softc *, char *));
|
||||
* XXX
|
||||
*************************************************/
|
||||
/* misc error */
|
||||
#define NOTARGET -2
|
||||
#define HASERROR -1
|
||||
#define COMPLETE 2
|
||||
#define NOTARGET (-2)
|
||||
#define HASERROR (-1)
|
||||
|
||||
/* XXX: use scsi_message.h */
|
||||
/* status */
|
||||
|
@ -36,7 +36,6 @@
|
||||
#define _CCBQUE_H_
|
||||
|
||||
#define CCB_MWANTED 0x01
|
||||
#define CCB_WOK(fl) (((fl) == 0) ? M_WAITOK : M_NOWAIT)
|
||||
|
||||
/* (I) structure and prototype */
|
||||
#define GENERIC_CCB_ASSERT(DEV, CCBTYPE) \
|
||||
@ -49,7 +48,7 @@ struct CCBTYPE##que { \
|
||||
}; \
|
||||
\
|
||||
void DEV##_init_ccbque __P((int)); \
|
||||
struct CCBTYPE *DEV##_get_ccb __P((int)); \
|
||||
struct CCBTYPE *DEV##_get_ccb __P((void)); \
|
||||
void DEV##_free_ccb __P((register struct CCBTYPE *));
|
||||
|
||||
/* (II) static allocated memory */
|
||||
@ -69,8 +68,7 @@ DEV##_init_ccbque(count) \
|
||||
} \
|
||||
\
|
||||
struct CCBTYPE * \
|
||||
DEV##_get_ccb(flags) \
|
||||
int flags; \
|
||||
DEV##_get_ccb() \
|
||||
{ \
|
||||
register struct CCBTYPE *cb; \
|
||||
int s = splbio(); \
|
||||
@ -87,7 +85,7 @@ again: \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
cb = malloc(sizeof(*cb), M_DEVBUF, CCB_WOK(flags));\
|
||||
cb = malloc(sizeof(*cb), M_DEVBUF, M_NOWAIT); \
|
||||
if (cb != NULL) \
|
||||
{ \
|
||||
bzero(cb, sizeof(*cb)); \
|
||||
@ -97,12 +95,6 @@ again: \
|
||||
CCBTYPE##que.count --; \
|
||||
} \
|
||||
\
|
||||
if (flags == 0) \
|
||||
{ \
|
||||
CCBTYPE##que.flags |= CCB_MWANTED; \
|
||||
tsleep((caddr_t) &CCBTYPE##que.count, PRIBIO, "ccbwait", 0);\
|
||||
goto again; \
|
||||
} \
|
||||
cb = NULL; \
|
||||
\
|
||||
out: \
|
||||
|
Loading…
Reference in New Issue
Block a user