scsi_to_pci_dma_dir(SCpnt->sc_data_direction)); 
SCpnt->sc_data_direction); 
int Pci2000_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))	{	UCHAR		   *cdb = (UCHAR *)SCpnt->cmnd;					// Pointer to SCSI CDB	PADAPTER2000	padapter = HOSTDATA(SCpnt->device->host);			// Pointer to adapter control structure	int				rc		 = -1;								// command return code	UCHAR			bus		 = SCpnt->device->channel;	UCHAR			pun		 = SCpnt->device->id;	UCHAR			lun		 = SCpnt->device->lun;	UCHAR			cmd;	PDEV2000		pdev	 = &padapter->dev[bus][pun];	if ( !done )		{		printk("pci2000_queuecommand: %02X: done can't be NULL\n", *cdb);		return 0;		}	SCpnt->scsi_done = done;	SCpnt->SCp.have_data_in = 0;	pdev->SCpnt = SCpnt;  									// Save this command data	if ( WaitReady (padapter) )		{		rc = DID_ERROR;		goto finished;		}	outw_p (pun | (lun << 8), padapter->mb0);	if ( bus )		{		DEB (if(*cdb) printk ("\nCDB: %X-  %X %X %X %X %X %X %X %X %X %X ", SCpnt->cmd_len, cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6], cdb[7], cdb[8], cdb[9]));		DEB (if(*cdb) printk ("\ntimeout_per_command: %d, timeout_total: %d, timeout: %d", SCpnt->timeout_per_command,							  SCpnt->timeout_total, SCpnt->timeout));		outl (SCpnt->timeout_per_command, padapter->mb1);		outb_p (CMD_SCSI_TIMEOUT, padapter->cmd);		if ( WaitReady (padapter) )			{			rc = DID_ERROR;			goto finished;			}		outw_p (pun | (lun << 8), padapter->mb0);		outw_p (SCpnt->cmd_len << 8, padapter->mb0 + 2);		memcpy (pdev->cdb, cdb, MAX_COMMAND_SIZE);		outl (pdev->cdbDma, padapter->mb1);		if ( BuildSgList (SCpnt, padapter, pdev) )			cmd = CMD_SCSI_THRU;		else			cmd = CMD_SCSI_THRU_SG;		if ( (pdev->tag = Command (padapter, cmd)) == 0 )			rc = DID_TIME_OUT;		goto finished;		}	else		{		if ( lun )			{			rc = DID_BAD_TARGET;			goto finished;			}		}	switch ( *cdb )		{		case SCSIOP_INQUIRY:   					// inquiry CDB			if ( cdb[2] == SC_MY_RAID )				{				switch ( cdb[3] ) 					{					case MY_SCSI_REBUILD:						OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_REBUILD) << 16);						return 0;					case MY_SCSI_ALARMMUTE:						OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_MUTE) << 16);						return 0;					case MY_SCSI_DEMOFAIL:						OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_FAIL) << 16);						return 0;					default:						if ( SCpnt->use_sg )							{							rc = DID_ERROR;							goto finished;							}						else							{							SCpnt->SCp.have_data_in = pci_map_single (padapter->pdev, SCpnt->request_buffer, SCpnt->request_bufflen,													  scsi_to_pci_dma_dir(SCpnt->sc_data_direction));							outl (SCpnt->SCp.have_data_in, padapter->mb2);							}						outl (cdb[5], padapter->mb0);						outl (cdb[3], padapter->mb3);						cmd = CMD_DASD_RAID_RQ;						break;					}				break;				}						if ( SCpnt->use_sg )				{				SCpnt->SCp.have_data_in = pci_map_single (padapter->pdev,									  ((struct scatterlist *)SCpnt->request_buffer)->address,									  SCpnt->request_bufflen,									  scsi_to_pci_dma_dir (SCpnt->sc_data_direction));				}			else				{				SCpnt->SCp.have_data_in = pci_map_single (padapter->pdev, SCpnt->request_buffer,									  SCpnt->request_bufflen,									  scsi_to_pci_dma_dir (SCpnt->sc_data_direction));				}			outl (SCpnt->SCp.have_data_in, padapter->mb2);			outl (SCpnt->request_bufflen, padapter->mb3);			cmd = CMD_DASD_SCSI_INQ;			break;		case SCSIOP_TEST_UNIT_READY:			// test unit ready CDB			SCpnt->SCp.have_data_in = pci_map_single (padapter->pdev, SCpnt->sense_buffer, sizeof (SCpnt->sense_buffer), PCI_DMA_FROMDEVICE);			outl (SCpnt->SCp.have_data_in, padapter->mb2);			outl (sizeof (SCpnt->sense_buffer), padapter->mb3);			cmd = CMD_TEST_READY;			break;		case SCSIOP_READ_CAPACITY:			  	// read capacity CDB			if ( SCpnt->use_sg )				{				SCpnt->SCp.have_data_in = pci_map_single (padapter->pdev, ((struct scatterlist *)(SCpnt->request_buffer))->address,										  8, PCI_DMA_FROMDEVICE);				}			else				SCpnt->SCp.have_data_in = pci_map_single (padapter->pdev, SCpnt->request_buffer, 8, PCI_DMA_FROMDEVICE);			outl (SCpnt->SCp.have_data_in, padapter->mb2);			outl (8, padapter->mb3);			cmd = CMD_DASD_CAP;			break;		case SCSIOP_VERIFY:						// verify CDB			outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2);			outl (XSCSI2LONG (&cdb[2]), padapter->mb1);			cmd = CMD_READ_SG;			break;		case SCSIOP_READ:						// read10 CDB			outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2);			outl (XSCSI2LONG (&cdb[2]), padapter->mb1);			if ( BuildSgList (SCpnt, padapter, pdev) )				cmd = CMD_READ;			else				cmd = CMD_READ_SG;			break;		case SCSIOP_READ6:						// read6  CDB			outw_p (cdb[4], padapter->mb0 + 2);			outl ((SCSI2LONG (&cdb[1])) & 0x001FFFFF, padapter->mb1);			if ( BuildSgList (SCpnt, padapter, pdev) )				cmd = CMD_READ;			else				cmd = CMD_READ_SG;			break;		case SCSIOP_WRITE:						// write10 CDB			outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2);			outl (XSCSI2LONG (&cdb[2]), padapter->mb1);			if ( BuildSgList (SCpnt, padapter, pdev) )				cmd = CMD_WRITE;			else				cmd = CMD_WRITE_SG;			break;		case SCSIOP_WRITE6:						// write6  CDB			outw_p (cdb[4], padapter->mb0 + 2);			outl ((SCSI2LONG (&cdb[1])) & 0x001FFFFF, padapter->mb1);			if ( BuildSgList (SCpnt, padapter, pdev) )				cmd = CMD_WRITE;			else				cmd = CMD_WRITE_SG;			break;		case SCSIOP_START_STOP_UNIT:			cmd = CMD_EJECT_MEDIA;			break;		case SCSIOP_MEDIUM_REMOVAL:			switch ( cdb[4] )				{				case 0:					cmd = CMD_UNLOCK_DOOR;					break;				case 1:					cmd = CMD_LOCK_DOOR;					break;				default:					cmd = 0;					break;				}			if ( cmd )				break;		default:			DEB (printk ("pci2000_queuecommand: Unsupported command %02X\n", *cdb));			OpDone (SCpnt, DID_ERROR << 16);			return 0;		}	if ( (pdev->tag = Command (padapter, cmd)) == 0 )		rc = DID_TIME_OUT;finished:;	if ( rc != -1 )		OpDone (SCpnt, rc << 16);	return 0;	}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/be7db055dd7261522557046370f49160728e3847/pci2000.c/buggy/drivers/scsi/pci2000.c