-
- if (bestmatch == (struct scsidevs *)0)
- printf(" No explicit device driver match for \"%s %s\".\n",
- manu, model);
-
- return(bestmatch);
-}
-
-static int recurse = 0;
-/***********************************************\
-* Do a scsi operation asking a device if it is *
-* ready. Use the scsi_cmd routine in the switch *
-* table. *
-\***********************************************/
-scsi_ready(unit,target,lu,scsi_switch, flags)
-struct scsi_switch *scsi_switch;
-{
- struct scsi_test_unit_ready scsi_cmd;
- struct scsi_xfer scsi_xfer;
- volatile int rval;
- int key;
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- bzero(&scsi_xfer, sizeof(scsi_xfer));
- scsi_cmd.op_code = TEST_UNIT_READY;
-
- scsi_xfer.flags=flags | INUSE;
- scsi_xfer.adapter=unit;
- scsi_xfer.targ=target;
- scsi_xfer.lu=lu;
- scsi_xfer.cmd=(struct scsi_generic *)&scsi_cmd;
- scsi_xfer.retries=8;
- scsi_xfer.timeout=10000;
- scsi_xfer.cmdlen=sizeof(scsi_cmd);
- scsi_xfer.data=0;
- scsi_xfer.datalen=0;
- scsi_xfer.resid=0;
- scsi_xfer.when_done=0;
- scsi_xfer.done_arg=0;
-retry: scsi_xfer.error=0;
- /*******************************************************\
- * do not use interrupts *
- \*******************************************************/
- rval = (*(scsi_switch->scsi_cmd))(&scsi_xfer);
- if (rval != COMPLETE)
- {
- if(scsi_debug)
- {
- printf("scsi error, rval = 0x%x\n",rval);
- printf("code from driver: 0x%x\n",scsi_xfer.error);
- }
- switch(scsi_xfer.error)
- {
- case XS_SENSE:
- /*******************************************************\
- * Any sense value is illegal except UNIT ATTENTION *
- * In which case we need to check again to get the *
- * correct response. *
- *( especially exabytes) *
- \*******************************************************/
- if(scsi_xfer.sense.error_class == 7 )
- {
- key = scsi_xfer.sense.ext.extended.sense_key ;
- switch(key)
- {
- case 2: /* not ready BUT PRESENT! */
- return(COMPLETE);
- case 6:
- spinwait(1000);
- if(scsi_xfer.retries--)
- {
- scsi_xfer.flags &= ~ITSDONE;
- goto retry;
- }
- return(COMPLETE);
- default:
- if(scsi_debug)
- printf("%d:%d,key=%x.",
- target,lu,key);
- }
- }
- return(HAD_ERROR);
- case XS_BUSY:
- spinwait(1000);
- if(scsi_xfer.retries--)
- {
- scsi_xfer.flags &= ~ITSDONE;
- goto retry;
- }
- return(COMPLETE); /* it's busy so it's there */
- case XS_TIMEOUT:
- default:
- return(HAD_ERROR);
- }
- }
- return(COMPLETE);
-}
-/***********************************************\
-* Do a scsi operation asking a device what it is*
-* Use the scsi_cmd routine in the switch table. *
-\***********************************************/
-scsi_inquire(unit,target,lu,scsi_switch,inqbuf, flags)
-struct scsi_switch *scsi_switch;
-u_char *inqbuf;
-{
- struct scsi_inquiry scsi_cmd;
- struct scsi_xfer scsi_xfer;
- volatile int rval;
-
- bzero(&scsi_cmd, sizeof(scsi_cmd));
- bzero(&scsi_xfer, sizeof(scsi_xfer));
- scsi_cmd.op_code = INQUIRY;
- scsi_cmd.length = sizeof(struct scsi_inquiry_data);
-
- scsi_xfer.flags=flags | SCSI_DATA_IN | INUSE;
- scsi_xfer.adapter=unit;
- scsi_xfer.targ=target;
- scsi_xfer.lu=lu;
- scsi_xfer.retries=8;
- scsi_xfer.timeout=10000;
- scsi_xfer.cmd=(struct scsi_generic *)&scsi_cmd;
- scsi_xfer.cmdlen= sizeof(struct scsi_inquiry);
- scsi_xfer.data=inqbuf;
- scsi_xfer.datalen=sizeof(struct scsi_inquiry_data);
- scsi_xfer.resid=sizeof(struct scsi_inquiry_data);
- scsi_xfer.when_done=0;
- scsi_xfer.done_arg=0;
-retry: scsi_xfer.error=0;
- /*******************************************************\
- * do not use interrupts *
- \*******************************************************/
- if ((*(scsi_switch->scsi_cmd))(&scsi_xfer) != COMPLETE)
- {
- if(scsi_debug) printf("inquiry had error(0x%x) ",scsi_xfer.error);
- switch(scsi_xfer.error)
- {
- case XS_NOERROR:
- break;
- case XS_SENSE:
- /*******************************************************\
- * Any sense value is illegal except UNIT ATTENTION *
- * In which case we need to check again to get the *
- * correct response. *
- *( especially exabytes) *
- \*******************************************************/
- if((scsi_xfer.sense.error_class == 7 )
- && (scsi_xfer.sense.ext.extended.sense_key == 6))
- { /* it's changed so it's there */
- spinwait(1000);
- {
- if(scsi_xfer.retries--)
- {
- scsi_xfer.flags &= ~ITSDONE;
- goto retry;
- }
- }
- return( COMPLETE);
- }
- return(HAD_ERROR);
- case XS_BUSY:
- spinwait(1000);
- if(scsi_xfer.retries--)
- {
- scsi_xfer.flags &= ~ITSDONE;
- goto retry;
- }
- case XS_TIMEOUT:
- default:
- return(HAD_ERROR);
- }