#endif /* !DOS */ 
void sres(ULONG port, UCHAR p_card, PSCCBcard pCurrCard)#endif{#if defined(V302)#ifdef DOS   UCHAR our_target,message, msgRetryCount;   extern UCHAR lun, tag;#else   UCHAR our_target,message,lun,tag, msgRetryCount;#endif#else  /* V302 */   UCHAR our_target, message, lun = 0, tag, msgRetryCount;#endif /* V302 */   PSCCBMgr_tar_info currTar_Info;	PSCCB currSCCB;	if(pCurrCard->currentSCCB != NULL)	{		currTar_Info = &sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID];		DISABLE_AUTO(port);		WR_HARPOON((port+hp_scsictrl_0),(ENA_RESEL | ENA_SCAM_SEL));		currSCCB = pCurrCard->currentSCCB;		if(currSCCB->Sccb_scsistat == SELECT_WN_ST)		{			currTar_Info->TarStatus &= ~TAR_WIDE_MASK;			currSCCB->Sccb_scsistat = BUS_FREE_ST;		}		if(currSCCB->Sccb_scsistat == SELECT_SN_ST)		{			currTar_Info->TarStatus &= ~TAR_SYNC_MASK;			currSCCB->Sccb_scsistat = BUS_FREE_ST;		}		if(((pCurrCard->globalFlags & F_CONLUN_IO) &&			((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)))		{      	currTar_Info->TarLUNBusy[currSCCB->Lun] = FALSE;			if(currSCCB->Sccb_scsistat != ABORT_ST)			{				pCurrCard->discQCount--;				pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[currSCCB->Lun]] 													= NULL;			}		}		else		{	      currTar_Info->TarLUNBusy[0] = FALSE;			if(currSCCB->Sccb_tag)			{				if(currSCCB->Sccb_scsistat != ABORT_ST)				{					pCurrCard->discQCount--;					pCurrCard->discQ_Tbl[currSCCB->Sccb_tag] = NULL;				}			}else			{				if(currSCCB->Sccb_scsistat != ABORT_ST)				{					pCurrCard->discQCount--;					pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]] = NULL;				}			}		}      queueSelectFail(&BL_Card[p_card],p_card);	}#if defined(WIDE_SCSI)	WRW_HARPOON((port+hp_fiforead), (USHORT) 0x00);#endif	our_target = (UCHAR)(RD_HARPOON(port+hp_select_id) >> 4);	currTar_Info = &sccbMgrTbl[p_card][our_target];	msgRetryCount = 0;	do	{#if defined(V302)		message = GetTarLun(port, p_card, our_target, pCurrCard, &tag, &lun);#else /* V302 */		currTar_Info = &sccbMgrTbl[p_card][our_target];		tag = 0;		while(!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ))		{			if (! (RD_HARPOON(port+hp_scsisig) & SCSI_BSY))			{				WRW_HARPOON((port+hp_intstat), PHASE);				return;			}		}		WRW_HARPOON((port+hp_intstat), PHASE);		if ((RD_HARPOON(port+hp_scsisig) & S_SCSI_PHZ) == S_MSGI_PH)		{			message = sfm(port,pCurrCard->currentSCCB);			if (message)			{				if (message <= (0x80 | LUN_MASK))				{					lun = message & (UCHAR)LUN_MASK;#if !defined(DOS)					if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_TRYING)					{						if (currTar_Info->TarTagQ_Cnt != 0)						{							if (!(currTar_Info->TarLUN_CA))							{								ACCEPT_MSG(port);    /*Release the ACK for ID msg. */								message = sfm(port,pCurrCard->currentSCCB);								if (message)								{									ACCEPT_MSG(port);								}								else   								message = FALSE;								if(message != FALSE)								{									tag = sfm(port,pCurrCard->currentSCCB);									if (!(tag)) 										message = FALSE;								}							} /*C.A. exists! */						} /*End Q cnt != 0 */					} /*End Tag cmds supported! */#endif /* !DOS */				} /*End valid ID message.  */				else				{					ACCEPT_MSG_ATN(port);				}			} /* End good id message. */			else			{				message = FALSE;			}		}		else		{			ACCEPT_MSG_ATN(port);		   while (!(RDW_HARPOON((port+hp_intstat)) & (PHASE | RESET)) &&			  !(RD_HARPOON(port+hp_scsisig) & SCSI_REQ) &&			  (RD_HARPOON(port+hp_scsisig) & SCSI_BSY)) ;			return;		}	#endif /* V302 */		if(message == FALSE)		{			msgRetryCount++;			if(msgRetryCount == 1)			{				SendMsg(port, SMPARITY);			}			else			{				SendMsg(port, SMDEV_RESET);				sssyncv(port, our_target, NARROW_SCSI,currTar_Info);				if (sccbMgrTbl[p_card][our_target].TarEEValue & EE_SYNC_MASK) 				{								sccbMgrTbl[p_card][our_target].TarStatus &= ~TAR_SYNC_MASK;				}				if (sccbMgrTbl[p_card][our_target].TarEEValue & EE_WIDE_SCSI) 				{					sccbMgrTbl[p_card][our_target].TarStatus &= ~TAR_WIDE_MASK;				}				queueFlushTargSccb(p_card, our_target, SCCB_COMPLETE);				SccbMgrTableInitTarget(p_card,our_target);				return;			}		}	}while(message == FALSE);	if(((pCurrCard->globalFlags & F_CONLUN_IO) &&		((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)))	{		currTar_Info->TarLUNBusy[lun] = TRUE;		pCurrCard->currentSCCB = pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[lun]];		if(pCurrCard->currentSCCB != NULL)		{			ACCEPT_MSG(port);		}		else 		{			ACCEPT_MSG_ATN(port);		}	}	else	{		currTar_Info->TarLUNBusy[0] = TRUE;		if (tag)		{			if (pCurrCard->discQ_Tbl[tag] != NULL)			{				pCurrCard->currentSCCB = pCurrCard->discQ_Tbl[tag];		 		currTar_Info->TarTagQ_Cnt--;				ACCEPT_MSG(port);			}			else			{			ACCEPT_MSG_ATN(port);			}		}else		{			pCurrCard->currentSCCB = pCurrCard->discQ_Tbl[currTar_Info->LunDiscQ_Idx[0]];			if(pCurrCard->currentSCCB != NULL)			{				ACCEPT_MSG(port);			}			else 			{				ACCEPT_MSG_ATN(port);			}		}	}	if(pCurrCard->currentSCCB != NULL)	{		if(pCurrCard->currentSCCB->Sccb_scsistat == ABORT_ST)		{		/* During Abort Tag command, the target could have got re-selected			and completed the command. Check the select Q and remove the CCB			if it is in the Select Q */			queueFindSccb(pCurrCard->currentSCCB, p_card);		}	}   while (!(RDW_HARPOON((port+hp_intstat)) & (PHASE | RESET)) &&	  !(RD_HARPOON(port+hp_scsisig) & SCSI_REQ) &&	  (RD_HARPOON(port+hp_scsisig) & SCSI_BSY)) ;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/47b5d69c4aa753fcfc9b2b8d28c0660a1e25c129/FlashPoint.c/buggy/drivers/scsi/FlashPoint.c