FlashPoint.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:308k
- #endif /* (FW_TYPE==_UCB_MGR_) */
- #ifndef NO_IOCTLS
- #if (FW_TYPE==_UCB_MGR_)
- void SccbMgr_unload_card(CARD_HANDLE pCurrCard)
- #else
- #if defined(DOS)
- void SccbMgr_unload_card(USHORT pCurrCard)
- #else
- void SccbMgr_unload_card(ULONG pCurrCard)
- #endif
- #endif
- {
- UCHAR i;
- #if defined(DOS)
- USHORT portBase;
- USHORT regOffset;
- #else
- ULONG portBase;
- ULONG regOffset;
- #endif
- ULONG scamData;
- #if defined(OS2)
- ULONG far *pScamTbl;
- #else
- ULONG *pScamTbl;
- #endif
- PNVRamInfo pCurrNvRam;
- pCurrNvRam = ((PSCCBcard)pCurrCard)->pNvRamInfo;
- if(pCurrNvRam){
- WrStack(pCurrNvRam->niBaseAddr, 0, pCurrNvRam->niModel);
- WrStack(pCurrNvRam->niBaseAddr, 1, pCurrNvRam->niSysConf);
- WrStack(pCurrNvRam->niBaseAddr, 2, pCurrNvRam->niScsiConf);
- WrStack(pCurrNvRam->niBaseAddr, 3, pCurrNvRam->niScamConf);
- WrStack(pCurrNvRam->niBaseAddr, 4, pCurrNvRam->niAdapId);
- for(i = 0; i < MAX_SCSI_TAR / 2; i++)
- WrStack(pCurrNvRam->niBaseAddr, (UCHAR)(i+5), pCurrNvRam->niSyncTbl[i]);
- portBase = pCurrNvRam->niBaseAddr;
- for(i = 0; i < MAX_SCSI_TAR; i++){
- regOffset = hp_aramBase + 64 + i*4;
- #if defined(OS2)
- pScamTbl = (ULONG far *) &pCurrNvRam->niScamTbl[i];
- #else
- pScamTbl = (ULONG *) &pCurrNvRam->niScamTbl[i];
- #endif
- scamData = *pScamTbl;
- WR_HARP32(portBase, regOffset, scamData);
- }
- }else{
- WrStack(((PSCCBcard)pCurrCard)->ioPort, 0, 0);
- }
- }
- #endif /* NO_IOCTLS */
- void RNVRamData(PNVRamInfo pNvRamInfo)
- {
- UCHAR i;
- #if defined(DOS)
- USHORT portBase;
- USHORT regOffset;
- #else
- ULONG portBase;
- ULONG regOffset;
- #endif
- ULONG scamData;
- #if defined (OS2)
- ULONG far *pScamTbl;
- #else
- ULONG *pScamTbl;
- #endif
- pNvRamInfo->niModel = RdStack(pNvRamInfo->niBaseAddr, 0);
- pNvRamInfo->niSysConf = RdStack(pNvRamInfo->niBaseAddr, 1);
- pNvRamInfo->niScsiConf = RdStack(pNvRamInfo->niBaseAddr, 2);
- pNvRamInfo->niScamConf = RdStack(pNvRamInfo->niBaseAddr, 3);
- pNvRamInfo->niAdapId = RdStack(pNvRamInfo->niBaseAddr, 4);
- for(i = 0; i < MAX_SCSI_TAR / 2; i++)
- pNvRamInfo->niSyncTbl[i] = RdStack(pNvRamInfo->niBaseAddr, (UCHAR)(i+5));
- portBase = pNvRamInfo->niBaseAddr;
- for(i = 0; i < MAX_SCSI_TAR; i++){
- regOffset = hp_aramBase + 64 + i*4;
- RD_HARP32(portBase, regOffset, scamData);
- #if defined(OS2)
- pScamTbl = (ULONG far *) &pNvRamInfo->niScamTbl[i];
- #else
- pScamTbl = (ULONG *) &pNvRamInfo->niScamTbl[i];
- #endif
- *pScamTbl = scamData;
- }
- }
- #if defined(DOS)
- UCHAR RdStack(USHORT portBase, UCHAR index)
- #else
- UCHAR RdStack(ULONG portBase, UCHAR index)
- #endif
- {
- WR_HARPOON(portBase + hp_stack_addr, index);
- return(RD_HARPOON(portBase + hp_stack_data));
- }
- #if defined(DOS)
- void WrStack(USHORT portBase, UCHAR index, UCHAR data)
- #else
- void WrStack(ULONG portBase, UCHAR index, UCHAR data)
- #endif
- {
- WR_HARPOON(portBase + hp_stack_addr, index);
- WR_HARPOON(portBase + hp_stack_data, data);
- }
- #if (FW_TYPE==_UCB_MGR_)
- u08bits ChkIfChipInitialized(BASE_PORT ioPort)
- #else
- #if defined(DOS)
- UCHAR ChkIfChipInitialized(USHORT ioPort)
- #else
- UCHAR ChkIfChipInitialized(ULONG ioPort)
- #endif
- #endif
- {
- if((RD_HARPOON(ioPort + hp_arb_id) & 0x0f) != RdStack(ioPort, 4))
- return(FALSE);
- if((RD_HARPOON(ioPort + hp_clkctrl_0) & CLKCTRL_DEFAULT)
- != CLKCTRL_DEFAULT)
- return(FALSE);
- if((RD_HARPOON(ioPort + hp_seltimeout) == TO_250ms) ||
- (RD_HARPOON(ioPort + hp_seltimeout) == TO_290ms))
- return(TRUE);
- return(FALSE);
- }
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgr_start_sccb
- *
- * Description: Start a command pointed to by p_Sccb. When the
- * command is completed it will be returned via the
- * callback function.
- *
- *---------------------------------------------------------------------*/
- #if (FW_TYPE==_UCB_MGR_)
- void SccbMgr_start_sccb(CARD_HANDLE pCurrCard, PUCB p_ucb)
- #else
- #if defined(DOS)
- void SccbMgr_start_sccb(USHORT pCurrCard, PSCCB p_Sccb)
- #else
- void SccbMgr_start_sccb(ULONG pCurrCard, PSCCB p_Sccb)
- #endif
- #endif
- {
- #if defined(DOS)
- USHORT ioport;
- #else
- ULONG ioport;
- #endif
- UCHAR thisCard, lun;
- PSCCB pSaveSccb;
- CALL_BK_FN callback;
- #if (FW_TYPE==_UCB_MGR_)
- PSCCB p_Sccb;
- #endif
- mOS_Lock((PSCCBcard)pCurrCard);
- thisCard = ((PSCCBcard) pCurrCard)->cardIndex;
- ioport = ((PSCCBcard) pCurrCard)->ioPort;
- #if (FW_TYPE==_UCB_MGR_)
- p_Sccb = (PSCCB)p_ucb->UCB_MgrPrivatePtr;
- #endif
- if((p_Sccb->TargID > MAX_SCSI_TAR) || (p_Sccb->Lun > MAX_LUN))
- {
- #if (FW_TYPE==_UCB_MGR_)
- p_ucb->UCB_hbastat = SCCB_COMPLETE;
- p_ucb->UCB_status=SCCB_ERROR;
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- #endif
- #if (FW_TYPE==_SCCB_MGR_)
- p_Sccb->HostStatus = SCCB_COMPLETE;
- p_Sccb->SccbStatus = SCCB_ERROR;
- callback = (CALL_BK_FN)p_Sccb->SccbCallback;
- if (callback)
- callback(p_Sccb);
- #endif
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- }
- #if (FW_TYPE==_SCCB_MGR_)
- sinits(p_Sccb,thisCard);
- #endif
- #if (FW_TYPE==_UCB_MGR_)
- #ifndef NO_IOCTLS
- if (p_ucb->UCB_opcode & OPC_IOCTL)
- {
- switch (p_ucb->UCB_IOCTLCommand)
- {
- case READ_NVRAM:
- ReadNVRam((PSCCBcard)pCurrCard,p_ucb);
- p_ucb->UCB_status=UCB_SUCCESS;
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- case WRITE_NVRAM:
- WriteNVRam((PSCCBcard)pCurrCard,p_ucb);
- p_ucb->UCB_status=UCB_SUCCESS;
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- case SEND_SCSI_PASSTHRU:
- #if (FW_TYPE != _SCCB_MGR_)
- if( p_ucb->UCB_targid >=
- ((PSCCBcard)pCurrCard)->cardInfo->ai_MaxTarg )
- {
- p_ucb->UCB_status = UCB_ERROR;
- p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- }
- #endif
- break;
- case HARD_RESET:
- p_ucb->UCB_status = UCB_INVALID;
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- case GET_DEVICE_SYNCRATE:
- if( !GetDevSyncRate((PSCCBcard)pCurrCard,p_ucb) )
- {
- p_ucb->UCB_status = UCB_SUCCESS;
- }
- else
- {
- p_ucb->UCB_status = UCB_ERROR;
- p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
- }
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- case SET_DEVICE_SYNCRATE:
- if( !SetDevSyncRate((PSCCBcard)pCurrCard,p_ucb) )
- {
- p_ucb->UCB_status = UCB_SUCCESS;
- }
- else
- {
- p_ucb->UCB_status = UCB_ERROR;
- p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
- }
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- case GET_WIDE_MODE:
- if( !GetDevWideMode((PSCCBcard)pCurrCard,p_ucb) )
- {
- p_ucb->UCB_status = UCB_SUCCESS;
- }
- else
- {
- p_ucb->UCB_status = UCB_ERROR;
- p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
- }
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- case SET_WIDE_MODE:
- if( !SetDevWideMode((PSCCBcard)pCurrCard,p_ucb) )
- {
- p_ucb->UCB_status = UCB_SUCCESS;
- }
- else
- {
- p_ucb->UCB_status = UCB_ERROR;
- p_ucb->UCB_hbastat = HASTAT_HW_ERROR;
- }
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- default:
- p_ucb->UCB_status=UCB_INVALID;
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- if (callback)
- callback(p_ucb);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return;
- }
- }
- #endif /* NO_IOCTLS */
- #endif /* (FW_TYPE==_UCB_MGR_) */
- if (!((PSCCBcard) pCurrCard)->cmdCounter)
- {
- WR_HARPOON(ioport+hp_semaphore, (RD_HARPOON(ioport+hp_semaphore)
- | SCCB_MGR_ACTIVE));
- if (((PSCCBcard) pCurrCard)->globalFlags & F_GREEN_PC)
- {
- WR_HARPOON(ioport+hp_clkctrl_0, CLKCTRL_DEFAULT);
- WR_HARPOON(ioport+hp_sys_ctrl, 0x00);
- }
- }
- ((PSCCBcard)pCurrCard)->cmdCounter++;
- if (RD_HARPOON(ioport+hp_semaphore) & BIOS_IN_USE) {
- WR_HARPOON(ioport+hp_semaphore, (RD_HARPOON(ioport+hp_semaphore)
- | TICKLE_ME));
- if(p_Sccb->OperationCode == RESET_COMMAND)
- {
- pSaveSccb = ((PSCCBcard) pCurrCard)->currentSCCB;
- ((PSCCBcard) pCurrCard)->currentSCCB = p_Sccb;
- queueSelectFail(&BL_Card[thisCard], thisCard);
- ((PSCCBcard) pCurrCard)->currentSCCB = pSaveSccb;
- }
- else
- {
- queueAddSccb(p_Sccb,thisCard);
- }
- }
- else if ((RD_HARPOON(ioport+hp_page_ctrl) & G_INT_DISABLE)) {
- if(p_Sccb->OperationCode == RESET_COMMAND)
- {
- pSaveSccb = ((PSCCBcard) pCurrCard)->currentSCCB;
- ((PSCCBcard) pCurrCard)->currentSCCB = p_Sccb;
- queueSelectFail(&BL_Card[thisCard], thisCard);
- ((PSCCBcard) pCurrCard)->currentSCCB = pSaveSccb;
- }
- else
- {
- queueAddSccb(p_Sccb,thisCard);
- }
- }
- else {
- MDISABLE_INT(ioport);
- if((((PSCCBcard) pCurrCard)->globalFlags & F_CONLUN_IO) &&
- ((sccbMgrTbl[thisCard][p_Sccb->TargID].TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))
- lun = p_Sccb->Lun;
- else
- lun = 0;
- if ((((PSCCBcard) pCurrCard)->currentSCCB == NULL) &&
- (sccbMgrTbl[thisCard][p_Sccb->TargID].TarSelQ_Cnt == 0) &&
- (sccbMgrTbl[thisCard][p_Sccb->TargID].TarLUNBusy[lun]
- == FALSE)) {
- ((PSCCBcard) pCurrCard)->currentSCCB = p_Sccb;
- mOS_UnLock((PSCCBcard)pCurrCard);
- #if defined(DOS)
- ssel((USHORT)p_Sccb->SccbIOPort,thisCard);
- #else
- ssel(p_Sccb->SccbIOPort,thisCard);
- #endif
- mOS_Lock((PSCCBcard)pCurrCard);
- }
- else {
- if(p_Sccb->OperationCode == RESET_COMMAND)
- {
- pSaveSccb = ((PSCCBcard) pCurrCard)->currentSCCB;
- ((PSCCBcard) pCurrCard)->currentSCCB = p_Sccb;
- queueSelectFail(&BL_Card[thisCard], thisCard);
- ((PSCCBcard) pCurrCard)->currentSCCB = pSaveSccb;
- }
- else
- {
- queueAddSccb(p_Sccb,thisCard);
- }
- }
- MENABLE_INT(ioport);
- }
- mOS_UnLock((PSCCBcard)pCurrCard);
- }
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgr_abort_sccb
- *
- * Description: Abort the command pointed to by p_Sccb. When the
- * command is completed it will be returned via the
- * callback function.
- *
- *---------------------------------------------------------------------*/
- #if (FW_TYPE==_UCB_MGR_)
- s32bits SccbMgr_abort_sccb(CARD_HANDLE pCurrCard, PUCB p_ucb)
- #else
- #if defined(DOS)
- int SccbMgr_abort_sccb(USHORT pCurrCard, PSCCB p_Sccb)
- #else
- int SccbMgr_abort_sccb(ULONG pCurrCard, PSCCB p_Sccb)
- #endif
- #endif
- {
- #if defined(DOS)
- USHORT ioport;
- #else
- ULONG ioport;
- #endif
- UCHAR thisCard;
- CALL_BK_FN callback;
- UCHAR TID;
- PSCCB pSaveSCCB;
- PSCCBMgr_tar_info currTar_Info;
- #if (FW_TYPE==_UCB_MGR_)
- PSCCB p_Sccb;
- p_Sccb=(PSCCB)p_ucb->UCB_MgrPrivatePtr;
- #endif
- ioport = ((PSCCBcard) pCurrCard)->ioPort;
- thisCard = ((PSCCBcard)pCurrCard)->cardIndex;
- mOS_Lock((PSCCBcard)pCurrCard);
- if (RD_HARPOON(ioport+hp_page_ctrl) & G_INT_DISABLE)
- {
- mOS_UnLock((PSCCBcard)pCurrCard);
- }
- else
- {
- if (queueFindSccb(p_Sccb,thisCard))
- {
- mOS_UnLock((PSCCBcard)pCurrCard);
- ((PSCCBcard)pCurrCard)->cmdCounter--;
- if (!((PSCCBcard)pCurrCard)->cmdCounter)
- WR_HARPOON(ioport+hp_semaphore,(RD_HARPOON(ioport+hp_semaphore)
- & (UCHAR)(~(SCCB_MGR_ACTIVE | TICKLE_ME)) ));
- #if (FW_TYPE==_SCCB_MGR_)
- p_Sccb->SccbStatus = SCCB_ABORT;
- callback = p_Sccb->SccbCallback;
- callback(p_Sccb);
- #else
- p_ucb->UCB_status=SCCB_ABORT;
- callback = (CALL_BK_FN)p_ucb->UCB_callback;
- callback(p_ucb);
- #endif
- return(0);
- }
- else
- {
- mOS_UnLock((PSCCBcard)pCurrCard);
- if (((PSCCBcard)pCurrCard)->currentSCCB == p_Sccb)
- {
- p_Sccb->SccbStatus = SCCB_ABORT;
- return(0);
- }
- else
- {
- TID = p_Sccb->TargID;
- if(p_Sccb->Sccb_tag)
- {
- MDISABLE_INT(ioport);
- if (((PSCCBcard) pCurrCard)->discQ_Tbl[p_Sccb->Sccb_tag]==p_Sccb)
- {
- p_Sccb->SccbStatus = SCCB_ABORT;
- p_Sccb->Sccb_scsistat = ABORT_ST;
- #if (FW_TYPE==_UCB_MGR_)
- p_ucb->UCB_status=SCCB_ABORT;
- #endif
- p_Sccb->Sccb_scsimsg = SMABORT_TAG;
- if(((PSCCBcard) pCurrCard)->currentSCCB == NULL)
- {
- ((PSCCBcard) pCurrCard)->currentSCCB = p_Sccb;
- ssel(ioport, thisCard);
- }
- else
- {
- pSaveSCCB = ((PSCCBcard) pCurrCard)->currentSCCB;
- ((PSCCBcard) pCurrCard)->currentSCCB = p_Sccb;
- queueSelectFail((PSCCBcard) pCurrCard, thisCard);
- ((PSCCBcard) pCurrCard)->currentSCCB = pSaveSCCB;
- }
- }
- MENABLE_INT(ioport);
- return(0);
- }
- else
- {
- currTar_Info = &sccbMgrTbl[thisCard][p_Sccb->TargID];
- if(BL_Card[thisCard].discQ_Tbl[currTar_Info->LunDiscQ_Idx[p_Sccb->Lun]]
- == p_Sccb)
- {
- p_Sccb->SccbStatus = SCCB_ABORT;
- return(0);
- }
- }
- }
- }
- }
- return(-1);
- }
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgr_my_int
- *
- * Description: Do a quick check to determine if there is a pending
- * interrupt for this card and disable the IRQ Pin if so.
- *
- *---------------------------------------------------------------------*/
- #if (FW_TYPE==_UCB_MGR_)
- u08bits SccbMgr_my_int(CARD_HANDLE pCurrCard)
- #else
- #if defined(DOS)
- UCHAR SccbMgr_my_int(USHORT pCurrCard)
- #else
- UCHAR SccbMgr_my_int(ULONG pCurrCard)
- #endif
- #endif
- {
- #if defined(DOS)
- USHORT ioport;
- #else
- ULONG ioport;
- #endif
- ioport = ((PSCCBcard)pCurrCard)->ioPort;
- if (RD_HARPOON(ioport+hp_int_status) & INT_ASSERTED)
- {
- #if defined(DOS)
- MDISABLE_INT(ioport);
- #endif
- return(TRUE);
- }
- else
- return(FALSE);
- }
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgr_isr
- *
- * Description: This is our entry point when an interrupt is generated
- * by the card and the upper level driver passes it on to
- * us.
- *
- *---------------------------------------------------------------------*/
- #if (FW_TYPE==_UCB_MGR_)
- s32bits SccbMgr_isr(CARD_HANDLE pCurrCard)
- #else
- #if defined(DOS)
- int SccbMgr_isr(USHORT pCurrCard)
- #else
- int SccbMgr_isr(ULONG pCurrCard)
- #endif
- #endif
- {
- PSCCB currSCCB;
- UCHAR thisCard,result,bm_status, bm_int_st;
- USHORT hp_int;
- UCHAR i, target;
- #if defined(DOS)
- USHORT ioport;
- #else
- ULONG ioport;
- #endif
- mOS_Lock((PSCCBcard)pCurrCard);
- thisCard = ((PSCCBcard)pCurrCard)->cardIndex;
- ioport = ((PSCCBcard)pCurrCard)->ioPort;
- MDISABLE_INT(ioport);
- #if defined(BUGBUG)
- WR_HARPOON(ioport+hp_user_defined_D, RD_HARPOON(ioport+hp_int_status));
- #endif
- if ((bm_int_st=RD_HARPOON(ioport+hp_int_status)) & EXT_STATUS_ON)
- bm_status = RD_HARPOON(ioport+hp_ext_status) & (UCHAR)BAD_EXT_STATUS;
- else
- bm_status = 0;
- WR_HARPOON(ioport+hp_int_mask, (INT_CMD_COMPL | SCSI_INTERRUPT));
- mOS_UnLock((PSCCBcard)pCurrCard);
- while ((hp_int = RDW_HARPOON((ioport+hp_intstat)) & default_intena) |
- bm_status)
- {
- currSCCB = ((PSCCBcard)pCurrCard)->currentSCCB;
- #if defined(BUGBUG)
- Debug_Load(thisCard,(UCHAR) 0XFF);
- Debug_Load(thisCard,bm_int_st);
- Debug_Load(thisCard,hp_int_0);
- Debug_Load(thisCard,hp_int_1);
- #endif
- if (hp_int & (FIFO | TIMEOUT | RESET | SCAM_SEL) || bm_status) {
- result = SccbMgr_bad_isr(ioport,thisCard,((PSCCBcard)pCurrCard),hp_int);
- WRW_HARPOON((ioport+hp_intstat), (FIFO | TIMEOUT | RESET | SCAM_SEL));
- bm_status = 0;
- if (result) {
- mOS_Lock((PSCCBcard)pCurrCard);
- MENABLE_INT(ioport);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return(result);
- }
- }
- else if (hp_int & ICMD_COMP) {
- if ( !(hp_int & BUS_FREE) ) {
- /* Wait for the BusFree before starting a new command. We
- must also check for being reselected since the BusFree
- may not show up if another device reselects us in 1.5us or
- less. SRR Wednesday, 3/8/1995.
- */
- while (!(RDW_HARPOON((ioport+hp_intstat)) & (BUS_FREE | RSEL))) ;
- }
- if (((PSCCBcard)pCurrCard)->globalFlags & F_HOST_XFER_ACT)
- phaseChkFifo(ioport, thisCard);
- /* WRW_HARPOON((ioport+hp_intstat),
- (BUS_FREE | ICMD_COMP | ITAR_DISC | XFER_CNT_0));
- */
- WRW_HARPOON((ioport+hp_intstat), CLR_ALL_INT_1);
- autoCmdCmplt(ioport,thisCard);
- }
- else if (hp_int & ITAR_DISC)
- {
- if (((PSCCBcard)pCurrCard)->globalFlags & F_HOST_XFER_ACT) {
- phaseChkFifo(ioport, thisCard);
- }
- if (RD_HARPOON(ioport+hp_gp_reg_1) == SMSAVE_DATA_PTR) {
- WR_HARPOON(ioport+hp_gp_reg_1, 0x00);
- currSCCB->Sccb_XferState |= F_NO_DATA_YET;
- currSCCB->Sccb_savedATC = currSCCB->Sccb_ATC;
- }
- currSCCB->Sccb_scsistat = DISCONNECT_ST;
- queueDisconnect(currSCCB,thisCard);
- /* Wait for the BusFree before starting a new command. We
- must also check for being reselected since the BusFree
- may not show up if another device reselects us in 1.5us or
- less. SRR Wednesday, 3/8/1995.
- */
- while (!(RDW_HARPOON((ioport+hp_intstat)) & (BUS_FREE | RSEL)) &&
- !((RDW_HARPOON((ioport+hp_intstat)) & PHASE) &&
- RD_HARPOON((ioport+hp_scsisig)) ==
- (SCSI_BSY | SCSI_REQ | SCSI_CD | SCSI_MSG | SCSI_IOBIT))) ;
- /*
- The additional loop exit condition above detects a timing problem
- with the revision D/E harpoon chips. The caller should reset the
- host adapter to recover when 0xFE is returned.
- */
- if (!(RDW_HARPOON((ioport+hp_intstat)) & (BUS_FREE | RSEL)))
- {
- mOS_Lock((PSCCBcard)pCurrCard);
- MENABLE_INT(ioport);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return 0xFE;
- }
- WRW_HARPOON((ioport+hp_intstat), (BUS_FREE | ITAR_DISC));
- ((PSCCBcard)pCurrCard)->globalFlags |= F_NEW_SCCB_CMD;
- }
- else if (hp_int & RSEL) {
- WRW_HARPOON((ioport+hp_intstat), (PROG_HLT | RSEL | PHASE | BUS_FREE));
- if (RDW_HARPOON((ioport+hp_intstat)) & ITAR_DISC)
- {
- if (((PSCCBcard)pCurrCard)->globalFlags & F_HOST_XFER_ACT)
- {
- phaseChkFifo(ioport, thisCard);
- }
- if (RD_HARPOON(ioport+hp_gp_reg_1) == SMSAVE_DATA_PTR)
- {
- WR_HARPOON(ioport+hp_gp_reg_1, 0x00);
- currSCCB->Sccb_XferState |= F_NO_DATA_YET;
- currSCCB->Sccb_savedATC = currSCCB->Sccb_ATC;
- }
- WRW_HARPOON((ioport+hp_intstat), (BUS_FREE | ITAR_DISC));
- currSCCB->Sccb_scsistat = DISCONNECT_ST;
- queueDisconnect(currSCCB,thisCard);
- }
- sres(ioport,thisCard,((PSCCBcard)pCurrCard));
- phaseDecode(ioport,thisCard);
- }
- else if ((hp_int & IDO_STRT) && (!(hp_int & BUS_FREE)))
- {
- WRW_HARPOON((ioport+hp_intstat), (IDO_STRT | XFER_CNT_0));
- phaseDecode(ioport,thisCard);
- }
- else if ( (hp_int & IUNKWN) || (hp_int & PROG_HLT) )
- {
- WRW_HARPOON((ioport+hp_intstat), (PHASE | IUNKWN | PROG_HLT));
- if ((RD_HARPOON(ioport+hp_prgmcnt_0) & (UCHAR)0x3f)< (UCHAR)SELCHK)
- {
- phaseDecode(ioport,thisCard);
- }
- else
- {
- /* Harpoon problem some SCSI target device respond to selection
- with short BUSY pulse (<400ns) this will make the Harpoon is not able
- to latch the correct Target ID into reg. x53.
- The work around require to correct this reg. But when write to this
- reg. (0x53) also increment the FIFO write addr reg (0x6f), thus we
- need to read this reg first then restore it later. After update to 0x53 */
- i = (UCHAR)(RD_HARPOON(ioport+hp_fifowrite));
- target = (UCHAR)(RD_HARPOON(ioport+hp_gp_reg_3));
- WR_HARPOON(ioport+hp_xfer_pad, (UCHAR) ID_UNLOCK);
- WR_HARPOON(ioport+hp_select_id, (UCHAR)(target | target<<4));
- WR_HARPOON(ioport+hp_xfer_pad, (UCHAR) 0x00);
- WR_HARPOON(ioport+hp_fifowrite, i);
- WR_HARPOON(ioport+hp_autostart_3, (AUTO_IMMED+TAG_STRT));
- }
- }
- else if (hp_int & XFER_CNT_0) {
- WRW_HARPOON((ioport+hp_intstat), XFER_CNT_0);
- schkdd(ioport,thisCard);
- }
- else if (hp_int & BUS_FREE) {
- WRW_HARPOON((ioport+hp_intstat), BUS_FREE);
- if (((PSCCBcard)pCurrCard)->globalFlags & F_HOST_XFER_ACT) {
- hostDataXferAbort(ioport,thisCard,currSCCB);
- }
- phaseBusFree(ioport,thisCard);
- }
- else if (hp_int & ITICKLE) {
- WRW_HARPOON((ioport+hp_intstat), ITICKLE);
- ((PSCCBcard)pCurrCard)->globalFlags |= F_NEW_SCCB_CMD;
- }
- if (((PSCCBcard)pCurrCard)->globalFlags & F_NEW_SCCB_CMD) {
- ((PSCCBcard)pCurrCard)->globalFlags &= ~F_NEW_SCCB_CMD;
- if (((PSCCBcard)pCurrCard)->currentSCCB == NULL) {
- queueSearchSelect(((PSCCBcard)pCurrCard),thisCard);
- }
- if (((PSCCBcard)pCurrCard)->currentSCCB != NULL) {
- ((PSCCBcard)pCurrCard)->globalFlags &= ~F_NEW_SCCB_CMD;
- ssel(ioport,thisCard);
- }
- break;
- }
- } /*end while */
- mOS_Lock((PSCCBcard)pCurrCard);
- MENABLE_INT(ioport);
- mOS_UnLock((PSCCBcard)pCurrCard);
- return(0);
- }
- /*---------------------------------------------------------------------
- *
- * Function: Sccb_bad_isr
- *
- * Description: Some type of interrupt has occurred which is slightly
- * out of the ordinary. We will now decode it fully, in
- * this routine. This is broken up in an attempt to save
- * processing time.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- UCHAR SccbMgr_bad_isr(USHORT p_port, UCHAR p_card, PSCCBcard pCurrCard, USHORT p_int)
- #else
- UCHAR SccbMgr_bad_isr(ULONG p_port, UCHAR p_card, PSCCBcard pCurrCard, USHORT p_int)
- #endif
- {
- #if defined(HARP_REVX)
- ULONG timer;
- #endif
- UCHAR temp, ScamFlg;
- PSCCBMgr_tar_info currTar_Info;
- PNVRamInfo pCurrNvRam;
- if (RD_HARPOON(p_port+hp_ext_status) &
- (BM_FORCE_OFF | PCI_DEV_TMOUT | BM_PARITY_ERR | PIO_OVERRUN) )
- {
- if (pCurrCard->globalFlags & F_HOST_XFER_ACT)
- {
- hostDataXferAbort(p_port,p_card, pCurrCard->currentSCCB);
- }
- if (RD_HARPOON(p_port+hp_pci_stat_cfg) & REC_MASTER_ABORT)
- {
- WR_HARPOON(p_port+hp_pci_stat_cfg,
- (RD_HARPOON(p_port+hp_pci_stat_cfg) & ~REC_MASTER_ABORT));
- WR_HARPOON(p_port+hp_host_blk_cnt, 0x00);
- }
- if (pCurrCard->currentSCCB != NULL)
- {
- if (!pCurrCard->currentSCCB->HostStatus)
- pCurrCard->currentSCCB->HostStatus = SCCB_BM_ERR;
- sxfrp(p_port,p_card);
- temp = (UCHAR)(RD_HARPOON(p_port+hp_ee_ctrl) &
- (EXT_ARB_ACK | SCSI_TERM_ENA_H));
- WR_HARPOON(p_port+hp_ee_ctrl, ((UCHAR)temp | SEE_MS | SEE_CS));
- WR_HARPOON(p_port+hp_ee_ctrl, temp);
- if (!(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RESET)))
- {
- phaseDecode(p_port,p_card);
- }
- }
- }
- else if (p_int & RESET)
- {
- WR_HARPOON(p_port+hp_clkctrl_0, CLKCTRL_DEFAULT);
- WR_HARPOON(p_port+hp_sys_ctrl, 0x00);
- if (pCurrCard->currentSCCB != NULL) {
- if (pCurrCard->globalFlags & F_HOST_XFER_ACT)
- hostDataXferAbort(p_port,p_card, pCurrCard->currentSCCB);
- }
- DISABLE_AUTO(p_port);
- sresb(p_port,p_card);
- while(RD_HARPOON(p_port+hp_scsictrl_0) & SCSI_RST) {}
- pCurrNvRam = pCurrCard->pNvRamInfo;
- if(pCurrNvRam){
- ScamFlg = pCurrNvRam->niScamConf;
- }
- else{
- ScamFlg = (UCHAR) utilEERead(p_port, SCAM_CONFIG/2);
- }
- XbowInit(p_port, ScamFlg);
- scini(p_card, pCurrCard->ourId, 0);
- return(0xFF);
- }
- else if (p_int & FIFO) {
- WRW_HARPOON((p_port+hp_intstat), FIFO);
- #if defined(HARP_REVX)
- for (timer=0x00FFFFFFL; timer != 0x00000000L; timer--) {
- if (RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY)
- break;
- if (RDW_HARPOON((p_port+hp_intstat)) & BUS_FREE)
- break;
- }
- if ( (RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY) &&
- (RD_HARPOON(p_port+hp_fiforead) !=
- RD_HARPOON(p_port+hp_fifowrite)) &&
- (RD_HARPOON(p_port+hp_xfercnt_0))
- )
- WR_HARPOON((p_port+hp_xferstat), 0x01);
- /* else
- */
- /* sxfrp(p_port,p_card);
- */
- #else
- if (pCurrCard->currentSCCB != NULL)
- sxfrp(p_port,p_card);
- #endif
- }
- else if (p_int & TIMEOUT)
- {
- DISABLE_AUTO(p_port);
- WRW_HARPOON((p_port+hp_intstat),
- (PROG_HLT | TIMEOUT | SEL |BUS_FREE | PHASE | IUNKWN));
- pCurrCard->currentSCCB->HostStatus = SCCB_SELECTION_TIMEOUT;
- currTar_Info = &sccbMgrTbl[p_card][pCurrCard->currentSCCB->TargID];
- if((pCurrCard->globalFlags & F_CONLUN_IO) &&
- ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))
- currTar_Info->TarLUNBusy[pCurrCard->currentSCCB->Lun] = FALSE;
- else
- currTar_Info->TarLUNBusy[0] = FALSE;
- if (currTar_Info->TarEEValue & EE_SYNC_MASK)
- {
- currTar_Info->TarSyncCtrl = 0;
- currTar_Info->TarStatus &= ~TAR_SYNC_MASK;
- }
- if (currTar_Info->TarEEValue & EE_WIDE_SCSI)
- {
- currTar_Info->TarStatus &= ~TAR_WIDE_MASK;
- }
- sssyncv(p_port, pCurrCard->currentSCCB->TargID, NARROW_SCSI,currTar_Info);
- queueCmdComplete(pCurrCard, pCurrCard->currentSCCB, p_card);
- }
- #if defined(SCAM_LEV_2)
- else if (p_int & SCAM_SEL)
- {
- scarb(p_port,LEVEL2_TAR);
- scsel(p_port);
- scasid(p_card, p_port);
- scbusf(p_port);
- WRW_HARPOON((p_port+hp_intstat), SCAM_SEL);
- }
- #endif
- return(0x00);
- }
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgr_scsi_reset
- *
- * Description: A SCSI bus reset will be generated and all outstanding
- * Sccbs will be returned via the callback.
- *
- *---------------------------------------------------------------------*/
- #if (FW_TYPE==_UCB_MGR_)
- void SccbMgr_scsi_reset(CARD_HANDLE pCurrCard)
- #else
- #if defined(DOS)
- void SccbMgr_scsi_reset(USHORT pCurrCard)
- #else
- void SccbMgr_scsi_reset(ULONG pCurrCard)
- #endif
- #endif
- {
- UCHAR thisCard;
- thisCard = ((PSCCBcard)pCurrCard)->cardIndex;
- mOS_Lock((PSCCBcard)pCurrCard);
- if (((PSCCBcard) pCurrCard)->globalFlags & F_GREEN_PC)
- {
- WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_clkctrl_0, CLKCTRL_DEFAULT);
- WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_sys_ctrl, 0x00);
- }
- sresb(((PSCCBcard)pCurrCard)->ioPort,thisCard);
- if (RD_HARPOON(((PSCCBcard)pCurrCard)->ioPort+hp_ext_status) & BM_CMD_BUSY)
- {
- WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_page_ctrl,
- (RD_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_page_ctrl)
- & ~SCATTER_EN));
- WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_sg_addr,0x00);
- ((PSCCBcard) pCurrCard)->globalFlags &= ~F_HOST_XFER_ACT;
- busMstrTimeOut(((PSCCBcard) pCurrCard)->ioPort);
- WR_HARPOON(((PSCCBcard) pCurrCard)->ioPort+hp_int_mask,
- (INT_CMD_COMPL | SCSI_INTERRUPT));
- }
- /*
- if (utilEERead(((PSCCBcard)pCurrCard)->ioPort, (SCAM_CONFIG/2))
- & SCAM_ENABLED)
- */
- scini(thisCard, ((PSCCBcard)pCurrCard)->ourId, 0);
- #if (FW_TYPE==_UCB_MGR_)
- ((PSCCBcard)pCurrCard)->cardInfo->ai_AEN_routine(0x01,pCurrCard,0,0,0,0);
- #endif
- mOS_UnLock((PSCCBcard)pCurrCard);
- }
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgr_timer_expired
- *
- * Description: This function allow me to kill my own job that has not
- * yet completed, and has cause a timeout to occur. This
- * timeout has caused the upper level driver to call this
- * function.
- *
- *---------------------------------------------------------------------*/
- #if (FW_TYPE==_UCB_MGR_)
- void SccbMgr_timer_expired(CARD_HANDLE pCurrCard)
- #else
- #if defined(DOS)
- void SccbMgr_timer_expired(USHORT pCurrCard)
- #else
- void SccbMgr_timer_expired(ULONG pCurrCard)
- #endif
- #endif
- {
- }
- #if defined(DOS)
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgr_status
- *
- * Description: This function returns the number of outstanding SCCB's.
- * This is specific to the DOS enviroment, which needs this
- * to help them keep protected and real mode commands staight.
- *
- *---------------------------------------------------------------------*/
- USHORT SccbMgr_status(USHORT pCurrCard)
- {
- return(BL_Card[pCurrCard].cmdCounter);
- }
- #endif
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgrTableInit
- *
- * Description: Initialize all Sccb manager data structures.
- *
- *---------------------------------------------------------------------*/
- void SccbMgrTableInitAll()
- {
- UCHAR thisCard;
- for (thisCard = 0; thisCard < MAX_CARDS; thisCard++)
- {
- SccbMgrTableInitCard(&BL_Card[thisCard],thisCard);
- BL_Card[thisCard].ioPort = 0x00;
- BL_Card[thisCard].cardInfo = NULL;
- BL_Card[thisCard].cardIndex = 0xFF;
- BL_Card[thisCard].ourId = 0x00;
- BL_Card[thisCard].pNvRamInfo = NULL;
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgrTableInit
- *
- * Description: Initialize all Sccb manager data structures.
- *
- *---------------------------------------------------------------------*/
- void SccbMgrTableInitCard(PSCCBcard pCurrCard, UCHAR p_card)
- {
- UCHAR scsiID, qtag;
- for (qtag = 0; qtag < QUEUE_DEPTH; qtag++)
- {
- BL_Card[p_card].discQ_Tbl[qtag] = NULL;
- }
- for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++)
- {
- sccbMgrTbl[p_card][scsiID].TarStatus = 0;
- sccbMgrTbl[p_card][scsiID].TarEEValue = 0;
- SccbMgrTableInitTarget(p_card, scsiID);
- }
- pCurrCard->scanIndex = 0x00;
- pCurrCard->currentSCCB = NULL;
- pCurrCard->globalFlags = 0x00;
- pCurrCard->cmdCounter = 0x00;
- pCurrCard->tagQ_Lst = 0x01;
- pCurrCard->discQCount = 0;
- }
- /*---------------------------------------------------------------------
- *
- * Function: SccbMgrTableInit
- *
- * Description: Initialize all Sccb manager data structures.
- *
- *---------------------------------------------------------------------*/
- void SccbMgrTableInitTarget(UCHAR p_card, UCHAR target)
- {
- UCHAR lun, qtag;
- PSCCBMgr_tar_info currTar_Info;
- currTar_Info = &sccbMgrTbl[p_card][target];
- currTar_Info->TarSelQ_Cnt = 0;
- currTar_Info->TarSyncCtrl = 0;
- currTar_Info->TarSelQ_Head = NULL;
- currTar_Info->TarSelQ_Tail = NULL;
- currTar_Info->TarTagQ_Cnt = 0;
- currTar_Info->TarLUN_CA = FALSE;
- for (lun = 0; lun < MAX_LUN; lun++)
- {
- currTar_Info->TarLUNBusy[lun] = FALSE;
- currTar_Info->LunDiscQ_Idx[lun] = 0;
- }
- for (qtag = 0; qtag < QUEUE_DEPTH; qtag++)
- {
- if(BL_Card[p_card].discQ_Tbl[qtag] != NULL)
- {
- if(BL_Card[p_card].discQ_Tbl[qtag]->TargID == target)
- {
- BL_Card[p_card].discQ_Tbl[qtag] = NULL;
- BL_Card[p_card].discQCount--;
- }
- }
- }
- }
- #if defined(BUGBUG)
- /*****************************************************************
- * Save the current byte in the debug array
- *****************************************************************/
- void Debug_Load(UCHAR p_card, UCHAR p_bug_data)
- {
- debug_int[p_card][debug_index[p_card]] = p_bug_data;
- debug_index[p_card]++;
- if (debug_index[p_card] == debug_size)
- debug_index[p_card] = 0;
- }
- #endif
- #ident "$Id: sccb_dat.c 1.10 1997/02/22 03:16:02 awin Exp $"
- /*----------------------------------------------------------------------
- *
- *
- * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
- *
- * This file is available under both the GNU General Public License
- * and a BSD-style copyright; see LICENSE.FlashPoint for details.
- *
- * $Workfile: sccb_dat.c $
- *
- * Description: Functions relating to handling of the SCCB interface
- * between the device driver and the HARPOON.
- *
- * $Date: 1997/02/22 03:16:02 $
- *
- * $Revision: 1.10 $
- *
- *----------------------------------------------------------------------*/
- /*#include <globals.h>*/
- #if (FW_TYPE==_UCB_MGR_)
- /*#include <budi.h>*/
- #endif
- /*#include <sccbmgr.h>*/
- /*#include <blx30.h>*/
- /*#include <target.h>*/
- /*#include <harpoon.h>*/
- /*
- ** IMPORTANT NOTE!!!
- **
- ** You MUST preassign all data to a valid value or zero. This is
- ** required due to the MS compiler bug under OS/2 and Solaris Real-Mode
- ** driver environment.
- */
- SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR] = { { { 0 } } };
- SCCBCARD BL_Card[MAX_CARDS] = { { 0 } };
- SCCBSCAM_INFO scamInfo[MAX_SCSI_TAR] = { { { 0 } } };
- NVRAMINFO nvRamInfo[MAX_MB_CARDS] = { { 0 } };
- #if defined(OS2)
- void (far *s_PhaseTbl[8]) (ULONG, UCHAR) = { 0 };
- UCHAR temp_id_string[ID_STRING_LENGTH] = { 0 };
- #elif defined(SOLARIS_REAL_MODE) || defined(__STDC__)
- void (*s_PhaseTbl[8]) (ULONG, UCHAR) = { 0 };
- #else
- void (*s_PhaseTbl[8]) ();
- #endif
- #if defined(DOS)
- UCHAR first_time = 0;
- #endif
- UCHAR mbCards = 0;
- UCHAR scamHAString[] = {0x63, 0x07, 'B', 'U', 'S', 'L', 'O', 'G', 'I', 'C',
- ' ', 'B', 'T', '-', '9', '3', '0',
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
- USHORT default_intena = 0;
- #if defined(BUGBUG)
- UCHAR debug_int[MAX_CARDS][debug_size] = { 0 };
- UCHAR debug_index[MAX_CARDS] = { 0 };
- UCHAR reserved_1[3] = { 0 };
- #endif
- #ident "$Id: scsi.c 1.23 1997/07/09 21:42:54 mohan Exp $"
- /*----------------------------------------------------------------------
- *
- *
- * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
- *
- * This file is available under both the GNU General Public License
- * and a BSD-style copyright; see LICENSE.FlashPoint for details.
- *
- * $Workfile: scsi.c $
- *
- * Description: Functions for handling SCSI bus functions such as
- * selection/reselection, sync negotiation, message-in
- * decoding.
- *
- * $Date: 1997/07/09 21:42:54 $
- *
- * $Revision: 1.23 $
- *
- *----------------------------------------------------------------------*/
- /*#include <globals.h>*/
- #if (FW_TYPE==_UCB_MGR_)
- /*#include <budi.h>*/
- #endif
- /*#include <sccbmgr.h>*/
- /*#include <blx30.h>*/
- /*#include <target.h>*/
- /*#include <scsi2.h>*/
- /*#include <eeprom.h>*/
- /*#include <harpoon.h>*/
- /*
- extern SCCBCARD BL_Card[MAX_CARDS];
- extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
- #if defined(BUGBUG)
- void Debug_Load(UCHAR p_card, UCHAR p_bug_data);
- #endif
- */
- /*---------------------------------------------------------------------
- *
- * Function: sfetm
- *
- * Description: Read in a message byte from the SCSI bus, and check
- * for a parity error.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- UCHAR sfm(USHORT port, PSCCB pCurrSCCB)
- #else
- UCHAR sfm(ULONG port, PSCCB pCurrSCCB)
- #endif
- {
- UCHAR message;
- USHORT TimeOutLoop;
- TimeOutLoop = 0;
- while( (!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ)) &&
- (TimeOutLoop++ < 20000) ){}
- WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
- message = RD_HARPOON(port+hp_scsidata_0);
- WR_HARPOON(port+hp_scsisig, SCSI_ACK + S_MSGI_PH);
- if (TimeOutLoop > 20000)
- message = 0x00; /* force message byte = 0 if Time Out on Req */
- if ((RDW_HARPOON((port+hp_intstat)) & PARITY) &&
- (RD_HARPOON(port+hp_addstat) & SCSI_PAR_ERR))
- {
- WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
- WR_HARPOON(port+hp_xferstat, 0);
- WR_HARPOON(port+hp_fiforead, 0);
- WR_HARPOON(port+hp_fifowrite, 0);
- if (pCurrSCCB != NULL)
- {
- pCurrSCCB->Sccb_scsimsg = SMPARITY;
- }
- message = 0x00;
- do
- {
- ACCEPT_MSG_ATN(port);
- TimeOutLoop = 0;
- while( (!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ)) &&
- (TimeOutLoop++ < 20000) ){}
- if (TimeOutLoop > 20000)
- {
- WRW_HARPOON((port+hp_intstat), PARITY);
- return(message);
- }
- if ((RD_HARPOON(port+hp_scsisig) & S_SCSI_PHZ) != S_MSGI_PH)
- {
- WRW_HARPOON((port+hp_intstat), PARITY);
- return(message);
- }
- WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
- RD_HARPOON(port+hp_scsidata_0);
- WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
- }while(1);
- }
- WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
- WR_HARPOON(port+hp_xferstat, 0);
- WR_HARPOON(port+hp_fiforead, 0);
- WR_HARPOON(port+hp_fifowrite, 0);
- return(message);
- }
- /*---------------------------------------------------------------------
- *
- * Function: ssel
- *
- * Description: Load up automation and select target device.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void ssel(USHORT port, UCHAR p_card)
- #else
- void ssel(ULONG port, UCHAR p_card)
- #endif
- {
- #if defined(DOS)
- UCHAR auto_loaded, i, target, *theCCB;
- #elif defined(OS2)
- UCHAR auto_loaded, i, target;
- UCHAR far *theCCB;
- #else
- UCHAR auto_loaded, i, target, *theCCB;
- #endif
- #if defined(DOS)
- USHORT cdb_reg;
- #else
- ULONG cdb_reg;
- #endif
- PSCCBcard CurrCard;
- PSCCB currSCCB;
- PSCCBMgr_tar_info currTar_Info;
- UCHAR lastTag, lun;
- CurrCard = &BL_Card[p_card];
- currSCCB = CurrCard->currentSCCB;
- target = currSCCB->TargID;
- currTar_Info = &sccbMgrTbl[p_card][target];
- lastTag = CurrCard->tagQ_Lst;
- ARAM_ACCESS(port);
- if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT)
- currSCCB->ControlByte &= ~F_USE_CMD_Q;
- if(((CurrCard->globalFlags & F_CONLUN_IO) &&
- ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING)))
- lun = currSCCB->Lun;
- else
- lun = 0;
- #if defined(DOS)
- currTar_Info->TarLUNBusy[lun] = TRUE;
- #else
- if (CurrCard->globalFlags & F_TAG_STARTED)
- {
- if (!(currSCCB->ControlByte & F_USE_CMD_Q))
- {
- if ((currTar_Info->TarLUN_CA == FALSE)
- && ((currTar_Info->TarStatus & TAR_TAG_Q_MASK)
- == TAG_Q_TRYING))
- {
- if (currTar_Info->TarTagQ_Cnt !=0)
- {
- currTar_Info->TarLUNBusy[lun] = TRUE;
- queueSelectFail(CurrCard,p_card);
- SGRAM_ACCESS(port);
- return;
- }
- else {
- currTar_Info->TarLUNBusy[lun] = TRUE;
- }
- } /*End non-tagged */
- else {
- currTar_Info->TarLUNBusy[lun] = TRUE;
- }
- } /*!Use cmd Q Tagged */
- else {
- if (currTar_Info->TarLUN_CA == TRUE)
- {
- queueSelectFail(CurrCard,p_card);
- SGRAM_ACCESS(port);
- return;
- }
- currTar_Info->TarLUNBusy[lun] = TRUE;
- } /*else use cmd Q tagged */
- } /*if glob tagged started */
- else {
- currTar_Info->TarLUNBusy[lun] = TRUE;
- }
- #endif /* DOS */
- if((((CurrCard->globalFlags & F_CONLUN_IO) &&
- ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))
- || (!(currSCCB->ControlByte & F_USE_CMD_Q))))
- {
- if(CurrCard->discQCount >= QUEUE_DEPTH)
- {
- currTar_Info->TarLUNBusy[lun] = TRUE;
- queueSelectFail(CurrCard,p_card);
- SGRAM_ACCESS(port);
- return;
- }
- for (i = 1; i < QUEUE_DEPTH; i++)
- {
- if (++lastTag >= QUEUE_DEPTH) lastTag = 1;
- if (CurrCard->discQ_Tbl[lastTag] == NULL)
- {
- CurrCard->tagQ_Lst = lastTag;
- currTar_Info->LunDiscQ_Idx[lun] = lastTag;
- CurrCard->discQ_Tbl[lastTag] = currSCCB;
- CurrCard->discQCount++;
- break;
- }
- }
- if(i == QUEUE_DEPTH)
- {
- currTar_Info->TarLUNBusy[lun] = TRUE;
- queueSelectFail(CurrCard,p_card);
- SGRAM_ACCESS(port);
- return;
- }
- }
- auto_loaded = FALSE;
- WR_HARPOON(port+hp_select_id, target);
- WR_HARPOON(port+hp_gp_reg_3, target); /* Use by new automation logic */
- if (currSCCB->OperationCode == RESET_COMMAND) {
- WRW_HARPOON((port+ID_MSG_STRT), (MPM_OP+AMSG_OUT+
- (currSCCB->Sccb_idmsg & ~DISC_PRIV)));
- WRW_HARPOON((port+ID_MSG_STRT+2),BRH_OP+ALWAYS+NP);
- currSCCB->Sccb_scsimsg = SMDEV_RESET;
- WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
- auto_loaded = TRUE;
- currSCCB->Sccb_scsistat = SELECT_BDR_ST;
- if (currTar_Info->TarEEValue & EE_SYNC_MASK)
- {
- currTar_Info->TarSyncCtrl = 0;
- currTar_Info->TarStatus &= ~TAR_SYNC_MASK;
- }
- #if defined(WIDE_SCSI)
- if (currTar_Info->TarEEValue & EE_WIDE_SCSI)
- {
- currTar_Info->TarStatus &= ~TAR_WIDE_MASK;
- }
- #endif
- sssyncv(port, target, NARROW_SCSI,currTar_Info);
- SccbMgrTableInitTarget(p_card, target);
- }
- else if(currSCCB->Sccb_scsistat == ABORT_ST)
- {
- WRW_HARPOON((port+ID_MSG_STRT), (MPM_OP+AMSG_OUT+
- (currSCCB->Sccb_idmsg & ~DISC_PRIV)));
- WRW_HARPOON((port+ID_MSG_STRT+2),BRH_OP+ALWAYS+CMDPZ);
- WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+
- (((UCHAR)(currSCCB->ControlByte & TAG_TYPE_MASK)
- >> 6) | (UCHAR)0x20)));
- WRW_HARPOON((port+SYNC_MSGS+2),
- (MPM_OP+AMSG_OUT+currSCCB->Sccb_tag));
- WRW_HARPOON((port+SYNC_MSGS+4), (BRH_OP+ALWAYS+NP ));
- WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
- auto_loaded = TRUE;
-
- }
- #if defined(WIDE_SCSI)
- else if (!(currTar_Info->TarStatus & WIDE_NEGOCIATED)) {
- auto_loaded = siwidn(port,p_card);
- currSCCB->Sccb_scsistat = SELECT_WN_ST;
- }
- #endif
- else if (!((currTar_Info->TarStatus & TAR_SYNC_MASK)
- == SYNC_SUPPORTED)) {
- auto_loaded = sisyncn(port,p_card, FALSE);
- currSCCB->Sccb_scsistat = SELECT_SN_ST;
- }
- if (!auto_loaded)
- {
- #if !defined(DOS)
- if (currSCCB->ControlByte & F_USE_CMD_Q)
- {
- CurrCard->globalFlags |= F_TAG_STARTED;
- if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK)
- == TAG_Q_REJECT)
- {
- currSCCB->ControlByte &= ~F_USE_CMD_Q;
- /* Fix up the start instruction with a jump to
- Non-Tag-CMD handling */
- WRW_HARPOON((port+ID_MSG_STRT),BRH_OP+ALWAYS+NTCMD);
- WRW_HARPOON((port+NON_TAG_ID_MSG),
- (MPM_OP+AMSG_OUT+currSCCB->Sccb_idmsg));
- WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
- /* Setup our STATE so we know what happend when
- the wheels fall off. */
- currSCCB->Sccb_scsistat = SELECT_ST;
- currTar_Info->TarLUNBusy[lun] = TRUE;
- }
- else
- {
- WRW_HARPOON((port+ID_MSG_STRT), (MPM_OP+AMSG_OUT+currSCCB->Sccb_idmsg));
- WRW_HARPOON((port+ID_MSG_STRT+2), (MPM_OP+AMSG_OUT+
- (((UCHAR)(currSCCB->ControlByte & TAG_TYPE_MASK)
- >> 6) | (UCHAR)0x20)));
- for (i = 1; i < QUEUE_DEPTH; i++)
- {
- if (++lastTag >= QUEUE_DEPTH) lastTag = 1;
- if (CurrCard->discQ_Tbl[lastTag] == NULL)
- {
- WRW_HARPOON((port+ID_MSG_STRT+6),
- (MPM_OP+AMSG_OUT+lastTag));
- CurrCard->tagQ_Lst = lastTag;
- currSCCB->Sccb_tag = lastTag;
- CurrCard->discQ_Tbl[lastTag] = currSCCB;
- CurrCard->discQCount++;
- break;
- }
- }
- if ( i == QUEUE_DEPTH )
- {
- currTar_Info->TarLUNBusy[lun] = TRUE;
- queueSelectFail(CurrCard,p_card);
- SGRAM_ACCESS(port);
- return;
- }
- currSCCB->Sccb_scsistat = SELECT_Q_ST;
- WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
- }
- }
- else
- {
- #endif /* !DOS */
- WRW_HARPOON((port+ID_MSG_STRT),BRH_OP+ALWAYS+NTCMD);
- WRW_HARPOON((port+NON_TAG_ID_MSG),
- (MPM_OP+AMSG_OUT+currSCCB->Sccb_idmsg));
- currSCCB->Sccb_scsistat = SELECT_ST;
- WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
- #if !defined(DOS)
- }
- #endif
- #if defined(OS2)
- theCCB = (UCHAR far *)&currSCCB->Cdb[0];
- #else
- theCCB = (UCHAR *)&currSCCB->Cdb[0];
- #endif
- cdb_reg = port + CMD_STRT;
- for (i=0; i < currSCCB->CdbLength; i++)
- {
- WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + *theCCB));
- cdb_reg +=2;
- theCCB++;
- }
- if (currSCCB->CdbLength != TWELVE_BYTE_CMD)
- WRW_HARPOON(cdb_reg, (BRH_OP+ALWAYS+ NP));
- } /* auto_loaded */
- #if defined(WIDE_SCSI)
- WRW_HARPOON((port+hp_fiforead), (USHORT) 0x00);
- WR_HARPOON(port+hp_xferstat, 0x00);
- #endif
- WRW_HARPOON((port+hp_intstat), (PROG_HLT | TIMEOUT | SEL | BUS_FREE));
- WR_HARPOON(port+hp_portctrl_0,(SCSI_PORT));
- if (!(currSCCB->Sccb_MGRFlags & F_DEV_SELECTED))
- {
- WR_HARPOON(port+hp_scsictrl_0, (SEL_TAR | ENA_ATN | ENA_RESEL | ENA_SCAM_SEL));
- }
- else
- {
- /* auto_loaded = (RD_HARPOON(port+hp_autostart_3) & (UCHAR)0x1F);
- auto_loaded |= AUTO_IMMED; */
- auto_loaded = AUTO_IMMED;
- DISABLE_AUTO(port);
- WR_HARPOON(port+hp_autostart_3, auto_loaded);
- }
- SGRAM_ACCESS(port);
- }
- /*---------------------------------------------------------------------
- *
- * Function: sres
- *
- * Description: Hookup the correct CCB and handle the incoming messages.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void sres(USHORT port, UCHAR p_card, PSCCBcard pCurrCard)
- #else
- 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)) ;
- }
- #if defined(V302)
- #if defined(DOS)
- UCHAR GetTarLun(USHORT port, UCHAR p_card, UCHAR our_target, PSCCBcard pCurrCard, PUCHAR tag, PUCHAR lun)
- #else
- UCHAR GetTarLun(ULONG port, UCHAR p_card, UCHAR our_target, PSCCBcard pCurrCard, PUCHAR tag, PUCHAR lun)
- #endif
- {
- UCHAR message;
- PSCCBMgr_tar_info currTar_Info;
- 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(TRUE);
- }
- }
- 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
- return(FALSE);
- *tag = sfm(port,pCurrCard->currentSCCB);
- if (!(*tag)) return(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
- {
- return(FALSE);
- }
- }
- else
- {
- ACCEPT_MSG_ATN(port);
- return(TRUE);
- }
- return(TRUE);
- }
- #endif /* V302 */
- #if defined(DOS)
- void SendMsg(USHORT port, UCHAR message)
- #else
- void SendMsg(ULONG port, UCHAR message)
- #endif
- {
- 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_MSGO_PH)
- {
- WRW_HARPOON((port+hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0));
- WR_HARPOON(port+hp_portctrl_0, SCSI_BUS_EN);
- WR_HARPOON(port+hp_scsidata_0,message);
- WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
- ACCEPT_MSG(port);
- WR_HARPOON(port+hp_portctrl_0, 0x00);
- if ((message == SMABORT) || (message == SMDEV_RESET) ||
- (message == SMABORT_TAG) )
- {
- while(!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | PHASE))) {}
- if (RDW_HARPOON((port+hp_intstat)) & BUS_FREE)
- {
- WRW_HARPOON((port+hp_intstat), BUS_FREE);
- }
- }
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: sdecm
- *
- * Description: Determine the proper responce to the message from the
- * target device.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void sdecm(UCHAR message, USHORT port, UCHAR p_card)
- #else
- void sdecm(UCHAR message, ULONG port, UCHAR p_card)
- #endif
- {
- PSCCB currSCCB;
- PSCCBcard CurrCard;
- PSCCBMgr_tar_info currTar_Info;
- CurrCard = &BL_Card[p_card];
- currSCCB = CurrCard->currentSCCB;
- currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
- if (message == SMREST_DATA_PTR)
- {
- if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET))
- {
- currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC;
- hostDataXferRestart(currSCCB);
- }
- ACCEPT_MSG(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- else if (message == SMCMD_COMP)
- {
- if (currSCCB->Sccb_scsistat == SELECT_Q_ST)
- {
- currTar_Info->TarStatus &= ~(UCHAR)TAR_TAG_Q_MASK;
- currTar_Info->TarStatus |= (UCHAR)TAG_Q_REJECT;
- }
- ACCEPT_MSG(port);
- }
- else if ((message == SMNO_OP) || (message >= SMIDENT)
- || (message == SMINIT_RECOVERY) || (message == SMREL_RECOVERY))
- {
- ACCEPT_MSG(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- else if (message == SMREJECT)
- {
- if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) ||
- (currSCCB->Sccb_scsistat == SELECT_WN_ST) ||
- ((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING ) ||
- ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_TRYING ) )
- {
- WRW_HARPOON((port+hp_intstat), BUS_FREE);
- ACCEPT_MSG(port);
- while ((!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ)) &&
- (!(RDW_HARPOON((port+hp_intstat)) & BUS_FREE))) {}
- if(currSCCB->Lun == 0x00)
- {
- if ((currSCCB->Sccb_scsistat == SELECT_SN_ST))
- {
- currTar_Info->TarStatus |= (UCHAR)SYNC_SUPPORTED;
- currTar_Info->TarEEValue &= ~EE_SYNC_MASK;
- }
- #if defined(WIDE_SCSI)
- else if ((currSCCB->Sccb_scsistat == SELECT_WN_ST))
- {
- currTar_Info->TarStatus = (currTar_Info->TarStatus &
- ~WIDE_ENABLED) | WIDE_NEGOCIATED;
- currTar_Info->TarEEValue &= ~EE_WIDE_SCSI;
- }
- #endif
- else if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_TRYING )
- {
- currTar_Info->TarStatus = (currTar_Info->TarStatus &
- ~(UCHAR)TAR_TAG_Q_MASK) | TAG_Q_REJECT;
- currSCCB->ControlByte &= ~F_USE_CMD_Q;
- CurrCard->discQCount--;
- CurrCard->discQ_Tbl[currSCCB->Sccb_tag] = NULL;
- currSCCB->Sccb_tag = 0x00;
- }
- }
- if (RDW_HARPOON((port+hp_intstat)) & BUS_FREE)
- {
- if(currSCCB->Lun == 0x00)
- {
- WRW_HARPOON((port+hp_intstat), BUS_FREE);
- CurrCard->globalFlags |= F_NEW_SCCB_CMD;
- }
- }
- else
- {
- if((CurrCard->globalFlags & F_CONLUN_IO) &&
- ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))
- currTar_Info->TarLUNBusy[currSCCB->Lun] = TRUE;
- else
- currTar_Info->TarLUNBusy[0] = TRUE;
- currSCCB->ControlByte &= ~(UCHAR)F_USE_CMD_Q;
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }
- else
- {
- ACCEPT_MSG(port);
- while ((!(RD_HARPOON(port+hp_scsisig) & SCSI_REQ)) &&
- (!(RDW_HARPOON((port+hp_intstat)) & BUS_FREE))) {}
-
- if (!(RDW_HARPOON((port+hp_intstat)) & BUS_FREE))
- {
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }
- }
- else if (message == SMEXT)
- {
- ACCEPT_MSG(port);
- shandem(port,p_card,currSCCB);
- }
- else if (message == SMIGNORWR)
- {
- ACCEPT_MSG(port); /* ACK the RESIDUE MSG */
- message = sfm(port,currSCCB);
- if(currSCCB->Sccb_scsimsg != SMPARITY)
- ACCEPT_MSG(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- else
- {
- currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL;
- currSCCB->Sccb_scsimsg = SMREJECT;
- ACCEPT_MSG_ATN(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: shandem
- *
- * Description: Decide what to do with the extended message.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void shandem(USHORT port, UCHAR p_card, PSCCB pCurrSCCB)
- #else
- void shandem(ULONG port, UCHAR p_card, PSCCB pCurrSCCB)
- #endif
- {
- UCHAR length,message;
- length = sfm(port,pCurrSCCB);
- if (length)
- {
- ACCEPT_MSG(port);
- message = sfm(port,pCurrSCCB);
- if (message)
- {
- if (message == SMSYNC)
- {
- if (length == 0x03)
- {
- ACCEPT_MSG(port);
- stsyncn(port,p_card);
- }
- else
- {
- pCurrSCCB->Sccb_scsimsg = SMREJECT;
- ACCEPT_MSG_ATN(port);
- }
- }
- #if defined(WIDE_SCSI)
- else if (message == SMWDTR)
- {
- if (length == 0x02)
- {
- ACCEPT_MSG(port);
- stwidn(port,p_card);
- }
- else
- {
- pCurrSCCB->Sccb_scsimsg = SMREJECT;
- ACCEPT_MSG_ATN(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }
- #endif
- else
- {
- pCurrSCCB->Sccb_scsimsg = SMREJECT;
- ACCEPT_MSG_ATN(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }
- else
- {
- if(pCurrSCCB->Sccb_scsimsg != SMPARITY)
- ACCEPT_MSG(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }else
- {
- if(pCurrSCCB->Sccb_scsimsg == SMPARITY)
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: sisyncn
- *
- * Description: Read in a message byte from the SCSI bus, and check
- * for a parity error.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- UCHAR sisyncn(USHORT port, UCHAR p_card, UCHAR syncFlag)
- #else
- UCHAR sisyncn(ULONG port, UCHAR p_card, UCHAR syncFlag)
- #endif
- {
- PSCCB currSCCB;
- PSCCBMgr_tar_info currTar_Info;
- currSCCB = BL_Card[p_card].currentSCCB;
- currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
- if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_TRYING)) {
- WRW_HARPOON((port+ID_MSG_STRT),
- (MPM_OP+AMSG_OUT+(currSCCB->Sccb_idmsg & ~(UCHAR)DISC_PRIV)));
- WRW_HARPOON((port+ID_MSG_STRT+2),BRH_OP+ALWAYS+CMDPZ);
- WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+SMEXT ));
- WRW_HARPOON((port+SYNC_MSGS+2), (MPM_OP+AMSG_OUT+0x03 ));
- WRW_HARPOON((port+SYNC_MSGS+4), (MPM_OP+AMSG_OUT+SMSYNC));
- if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB)
- WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+ 12));
- else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_10MB)
- WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+ 25));
- else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_5MB)
- WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+ 50));
- else
- WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+ 00));
- WRW_HARPOON((port+SYNC_MSGS+8), (RAT_OP ));
- WRW_HARPOON((port+SYNC_MSGS+10),(MPM_OP+AMSG_OUT+DEFAULT_OFFSET));
- WRW_HARPOON((port+SYNC_MSGS+12),(BRH_OP+ALWAYS+NP ));
- if(syncFlag == FALSE)
- {
- WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
- currTar_Info->TarStatus = ((currTar_Info->TarStatus &
- ~(UCHAR)TAR_SYNC_MASK) | (UCHAR)SYNC_TRYING);
- }
- else
- {
- WR_HARPOON(port+hp_autostart_3, (AUTO_IMMED + CMD_ONLY_STRT));
- }
- return(TRUE);
- }
- else {
- currTar_Info->TarStatus |= (UCHAR)SYNC_SUPPORTED;
- currTar_Info->TarEEValue &= ~EE_SYNC_MASK;
- return(FALSE);
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: stsyncn
- *
- * Description: The has sent us a Sync Nego message so handle it as
- * necessary.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void stsyncn(USHORT port, UCHAR p_card)
- #else
- void stsyncn(ULONG port, UCHAR p_card)
- #endif
- {
- UCHAR sync_msg,offset,sync_reg,our_sync_msg;
- PSCCB currSCCB;
- PSCCBMgr_tar_info currTar_Info;
- currSCCB = BL_Card[p_card].currentSCCB;
- currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
- sync_msg = sfm(port,currSCCB);
- if((sync_msg == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY))
- {
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- return;
- }
- ACCEPT_MSG(port);
- offset = sfm(port,currSCCB);
- if((offset == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY))
- {
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- return;
- }
- if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_20MB)
- our_sync_msg = 12; /* Setup our Message to 20mb/s */
- else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_10MB)
- our_sync_msg = 25; /* Setup our Message to 10mb/s */
- else if ((currTar_Info->TarEEValue & EE_SYNC_MASK) == EE_SYNC_5MB)
- our_sync_msg = 50; /* Setup our Message to 5mb/s */
- else
- our_sync_msg = 0; /* Message = Async */
- if (sync_msg < our_sync_msg) {
- sync_msg = our_sync_msg; /*if faster, then set to max. */
- }
- if (offset == ASYNC)
- sync_msg = ASYNC;
- if (offset > MAX_OFFSET)
- offset = MAX_OFFSET;
- sync_reg = 0x00;
- if (sync_msg > 12)
- sync_reg = 0x20; /* Use 10MB/s */
- if (sync_msg > 25)
- sync_reg = 0x40; /* Use 6.6MB/s */
- if (sync_msg > 38)
- sync_reg = 0x60; /* Use 5MB/s */
- if (sync_msg > 50)
- sync_reg = 0x80; /* Use 4MB/s */
- if (sync_msg > 62)
- sync_reg = 0xA0; /* Use 3.33MB/s */
- if (sync_msg > 75)
- sync_reg = 0xC0; /* Use 2.85MB/s */
- if (sync_msg > 87)
- sync_reg = 0xE0; /* Use 2.5MB/s */
- if (sync_msg > 100) {
- sync_reg = 0x00; /* Use ASYNC */
- offset = 0x00;
- }
- #if defined(WIDE_SCSI)
- if (currTar_Info->TarStatus & WIDE_ENABLED)
- sync_reg |= offset;
- else
- sync_reg |= (offset | NARROW_SCSI);
- #else
- sync_reg |= (offset | NARROW_SCSI);
- #endif
- sssyncv(port,currSCCB->TargID,sync_reg,currTar_Info);
- if (currSCCB->Sccb_scsistat == SELECT_SN_ST) {
- ACCEPT_MSG(port);
- currTar_Info->TarStatus = ((currTar_Info->TarStatus &
- ~(UCHAR)TAR_SYNC_MASK) | (UCHAR)SYNC_SUPPORTED);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- else {
- ACCEPT_MSG_ATN(port);
- sisyncr(port,sync_msg,offset);
- currTar_Info->TarStatus = ((currTar_Info->TarStatus &
- ~(UCHAR)TAR_SYNC_MASK) | (UCHAR)SYNC_SUPPORTED);
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: sisyncr
- *
- * Description: Answer the targets sync message.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void sisyncr(USHORT port,UCHAR sync_pulse, UCHAR offset)
- #else
- void sisyncr(ULONG port,UCHAR sync_pulse, UCHAR offset)
- #endif
- {
- ARAM_ACCESS(port);
- WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+SMEXT ));
- WRW_HARPOON((port+SYNC_MSGS+2), (MPM_OP+AMSG_OUT+0x03 ));
- WRW_HARPOON((port+SYNC_MSGS+4), (MPM_OP+AMSG_OUT+SMSYNC));
- WRW_HARPOON((port+SYNC_MSGS+6), (MPM_OP+AMSG_OUT+sync_pulse));
- WRW_HARPOON((port+SYNC_MSGS+8), (RAT_OP ));
- WRW_HARPOON((port+SYNC_MSGS+10),(MPM_OP+AMSG_OUT+offset));
- WRW_HARPOON((port+SYNC_MSGS+12),(BRH_OP+ALWAYS+NP ));
- SGRAM_ACCESS(port);
- WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
- WRW_HARPOON((port+hp_intstat), CLR_ALL_INT_1);
- WR_HARPOON(port+hp_autostart_3, (AUTO_IMMED+CMD_ONLY_STRT));
- while (!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | AUTO_INT))) {}
- }
- #if defined(WIDE_SCSI)
- /*---------------------------------------------------------------------
- *
- * Function: siwidn
- *
- * Description: Read in a message byte from the SCSI bus, and check
- * for a parity error.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- UCHAR siwidn(USHORT port, UCHAR p_card)
- #else
- UCHAR siwidn(ULONG port, UCHAR p_card)
- #endif
- {
- PSCCB currSCCB;
- PSCCBMgr_tar_info currTar_Info;
- currSCCB = BL_Card[p_card].currentSCCB;
- currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
- if (!((currTar_Info->TarStatus & TAR_WIDE_MASK) == WIDE_NEGOCIATED)) {
- WRW_HARPOON((port+ID_MSG_STRT),
- (MPM_OP+AMSG_OUT+(currSCCB->Sccb_idmsg & ~(UCHAR)DISC_PRIV)));
- WRW_HARPOON((port+ID_MSG_STRT+2),BRH_OP+ALWAYS+CMDPZ);
- WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+SMEXT ));
- WRW_HARPOON((port+SYNC_MSGS+2), (MPM_OP+AMSG_OUT+0x02 ));
- WRW_HARPOON((port+SYNC_MSGS+4), (MPM_OP+AMSG_OUT+SMWDTR));
- WRW_HARPOON((port+SYNC_MSGS+6), (RAT_OP ));
- WRW_HARPOON((port+SYNC_MSGS+8), (MPM_OP+AMSG_OUT+ SM16BIT));
- WRW_HARPOON((port+SYNC_MSGS+10),(BRH_OP+ALWAYS+NP ));
- WR_HARPOON(port+hp_autostart_3, (SELECT+SELCHK_STRT));
- currTar_Info->TarStatus = ((currTar_Info->TarStatus &
- ~(UCHAR)TAR_WIDE_MASK) | (UCHAR)WIDE_ENABLED);
- return(TRUE);
- }
- else {
- currTar_Info->TarStatus = ((currTar_Info->TarStatus &
- ~(UCHAR)TAR_WIDE_MASK) | WIDE_NEGOCIATED);
- currTar_Info->TarEEValue &= ~EE_WIDE_SCSI;
- return(FALSE);
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: stwidn
- *
- * Description: The has sent us a Wide Nego message so handle it as
- * necessary.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void stwidn(USHORT port, UCHAR p_card)
- #else
- void stwidn(ULONG port, UCHAR p_card)
- #endif
- {
- UCHAR width;
- PSCCB currSCCB;
- PSCCBMgr_tar_info currTar_Info;
- currSCCB = BL_Card[p_card].currentSCCB;
- currTar_Info = &sccbMgrTbl[p_card][currSCCB->TargID];
- width = sfm(port,currSCCB);
- if((width == 0x00) && (currSCCB->Sccb_scsimsg == SMPARITY))
- {
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- return;
- }
- if (!(currTar_Info->TarEEValue & EE_WIDE_SCSI))
- width = 0;
- if (width) {
- currTar_Info->TarStatus |= WIDE_ENABLED;
- width = 0;
- }
- else {
- width = NARROW_SCSI;
- currTar_Info->TarStatus &= ~WIDE_ENABLED;
- }
- sssyncv(port,currSCCB->TargID,width,currTar_Info);
- if (currSCCB->Sccb_scsistat == SELECT_WN_ST)
- {
- currTar_Info->TarStatus |= WIDE_NEGOCIATED;
- if (!((currTar_Info->TarStatus & TAR_SYNC_MASK) == SYNC_SUPPORTED))
- {
- ACCEPT_MSG_ATN(port);
- ARAM_ACCESS(port);
- sisyncn(port,p_card, TRUE);
- currSCCB->Sccb_scsistat = SELECT_SN_ST;
- SGRAM_ACCESS(port);
- }
- else
- {
- ACCEPT_MSG(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }
- else {
- ACCEPT_MSG_ATN(port);
- if (currTar_Info->TarEEValue & EE_WIDE_SCSI)
- width = SM16BIT;
- else
- width = SM8BIT;
- siwidr(port,width);
- currTar_Info->TarStatus |= (WIDE_NEGOCIATED | WIDE_ENABLED);
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: siwidr
- *
- * Description: Answer the targets Wide nego message.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void siwidr(USHORT port, UCHAR width)
- #else
- void siwidr(ULONG port, UCHAR width)
- #endif
- {
- ARAM_ACCESS(port);
- WRW_HARPOON((port+SYNC_MSGS+0), (MPM_OP+AMSG_OUT+SMEXT ));
- WRW_HARPOON((port+SYNC_MSGS+2), (MPM_OP+AMSG_OUT+0x02 ));
- WRW_HARPOON((port+SYNC_MSGS+4), (MPM_OP+AMSG_OUT+SMWDTR));
- WRW_HARPOON((port+SYNC_MSGS+6), (RAT_OP ));
- WRW_HARPOON((port+SYNC_MSGS+8),(MPM_OP+AMSG_OUT+width));
- WRW_HARPOON((port+SYNC_MSGS+10),(BRH_OP+ALWAYS+NP ));
- SGRAM_ACCESS(port);
- WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
- WRW_HARPOON((port+hp_intstat), CLR_ALL_INT_1);
- WR_HARPOON(port+hp_autostart_3, (AUTO_IMMED+CMD_ONLY_STRT));
- while (!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | AUTO_INT))) {}
- }
- #endif
- /*---------------------------------------------------------------------
- *
- * Function: sssyncv
- *
- * Description: Write the desired value to the Sync Register for the
- * ID specified.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void sssyncv(USHORT p_port, UCHAR p_id, UCHAR p_sync_value,PSCCBMgr_tar_info currTar_Info)
- #else
- void sssyncv(ULONG p_port, UCHAR p_id, UCHAR p_sync_value,PSCCBMgr_tar_info currTar_Info)
- #endif
- {
- UCHAR index;
- index = p_id;
- switch (index) {
- case 0:
- index = 12; /* hp_synctarg_0 */
- break;
- case 1:
- index = 13; /* hp_synctarg_1 */
- break;
- case 2:
- index = 14; /* hp_synctarg_2 */
- break;
- case 3:
- index = 15; /* hp_synctarg_3 */
- break;
- case 4:
- index = 8; /* hp_synctarg_4 */
- break;
- case 5:
- index = 9; /* hp_synctarg_5 */
- break;
- case 6:
- index = 10; /* hp_synctarg_6 */
- break;
- case 7:
- index = 11; /* hp_synctarg_7 */
- break;
- case 8:
- index = 4; /* hp_synctarg_8 */
- break;
- case 9:
- index = 5; /* hp_synctarg_9 */
- break;
- case 10:
- index = 6; /* hp_synctarg_10 */
- break;
- case 11:
- index = 7; /* hp_synctarg_11 */
- break;
- case 12:
- index = 0; /* hp_synctarg_12 */
- break;
- case 13:
- index = 1; /* hp_synctarg_13 */
- break;
- case 14:
- index = 2; /* hp_synctarg_14 */
- break;
- case 15:
- index = 3; /* hp_synctarg_15 */
- }
- WR_HARPOON(p_port+hp_synctarg_base+index, p_sync_value);
- currTar_Info->TarSyncCtrl = p_sync_value;
- }
- /*---------------------------------------------------------------------
- *
- * Function: sresb
- *
- * Description: Reset the desired card's SCSI bus.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void sresb(USHORT port, UCHAR p_card)
- #else
- void sresb(ULONG port, UCHAR p_card)
- #endif
- {
- UCHAR scsiID, i;
- PSCCBMgr_tar_info currTar_Info;
- WR_HARPOON(port+hp_page_ctrl,
- (RD_HARPOON(port+hp_page_ctrl) | G_INT_DISABLE));
- WRW_HARPOON((port+hp_intstat), CLR_ALL_INT);
- WR_HARPOON(port+hp_scsictrl_0, SCSI_RST);
- scsiID = RD_HARPOON(port+hp_seltimeout);
- WR_HARPOON(port+hp_seltimeout,TO_5ms);
- WRW_HARPOON((port+hp_intstat), TIMEOUT);
- WR_HARPOON(port+hp_portctrl_0,(SCSI_PORT | START_TO));
- while (!(RDW_HARPOON((port+hp_intstat)) & TIMEOUT)) {}
- WR_HARPOON(port+hp_seltimeout,scsiID);
- WR_HARPOON(port+hp_scsictrl_0, ENA_SCAM_SEL);
- Wait(port, TO_5ms);
- WRW_HARPOON((port+hp_intstat), CLR_ALL_INT);
- WR_HARPOON(port+hp_int_mask, (RD_HARPOON(port+hp_int_mask) | 0x00));
- for (scsiID = 0; scsiID < MAX_SCSI_TAR; scsiID++)
- {
- currTar_Info = &sccbMgrTbl[p_card][scsiID];
- if (currTar_Info->TarEEValue & EE_SYNC_MASK)
- {
- currTar_Info->TarSyncCtrl = 0;
- currTar_Info->TarStatus &= ~TAR_SYNC_MASK;
- }
- if (currTar_Info->TarEEValue & EE_WIDE_SCSI)
- {
- currTar_Info->TarStatus &= ~TAR_WIDE_MASK;
- }
- sssyncv(port, scsiID, NARROW_SCSI,currTar_Info);
- SccbMgrTableInitTarget(p_card, scsiID);
- }
- BL_Card[p_card].scanIndex = 0x00;
- BL_Card[p_card].currentSCCB = NULL;
- BL_Card[p_card].globalFlags &= ~(F_TAG_STARTED | F_HOST_XFER_ACT
- | F_NEW_SCCB_CMD);
- BL_Card[p_card].cmdCounter = 0x00;
- BL_Card[p_card].discQCount = 0x00;
- BL_Card[p_card].tagQ_Lst = 0x01;
- for(i = 0; i < QUEUE_DEPTH; i++)
- BL_Card[p_card].discQ_Tbl[i] = NULL;
- WR_HARPOON(port+hp_page_ctrl,
- (RD_HARPOON(port+hp_page_ctrl) & ~G_INT_DISABLE));
- }
- /*---------------------------------------------------------------------
- *
- * Function: ssenss
- *
- * Description: Setup for the Auto Sense command.
- *
- *---------------------------------------------------------------------*/
- void ssenss(PSCCBcard pCurrCard)
- {
- UCHAR i;
- PSCCB currSCCB;
- currSCCB = pCurrCard->currentSCCB;
- currSCCB->Save_CdbLen = currSCCB->CdbLength;
- for (i = 0; i < 6; i++) {
- currSCCB->Save_Cdb[i] = currSCCB->Cdb[i];
- }
- currSCCB->CdbLength = SIX_BYTE_CMD;
- currSCCB->Cdb[0] = SCSI_REQUEST_SENSE;
- currSCCB->Cdb[1] = currSCCB->Cdb[1] & (UCHAR)0xE0; /*Keep LUN. */
- currSCCB->Cdb[2] = 0x00;
- currSCCB->Cdb[3] = 0x00;
- currSCCB->Cdb[4] = currSCCB->RequestSenseLength;
- currSCCB->Cdb[5] = 0x00;
- currSCCB->Sccb_XferCnt = (unsigned long)currSCCB->RequestSenseLength;
- currSCCB->Sccb_ATC = 0x00;
- currSCCB->Sccb_XferState |= F_AUTO_SENSE;
- currSCCB->Sccb_XferState &= ~F_SG_XFER;
- currSCCB->Sccb_idmsg = currSCCB->Sccb_idmsg & ~(UCHAR)DISC_PRIV;
- currSCCB->ControlByte = 0x00;
- currSCCB->Sccb_MGRFlags &= F_STATUSLOADED;
- }
- /*---------------------------------------------------------------------
- *
- * Function: sxfrp
- *
- * Description: Transfer data into the bit bucket until the device
- * decides to switch phase.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void sxfrp(USHORT p_port, UCHAR p_card)
- #else
- void sxfrp(ULONG p_port, UCHAR p_card)
- #endif
- {
- UCHAR curr_phz;
- DISABLE_AUTO(p_port);
- if (BL_Card[p_card].globalFlags & F_HOST_XFER_ACT) {
- hostDataXferAbort(p_port,p_card,BL_Card[p_card].currentSCCB);
- }
- /* If the Automation handled the end of the transfer then do not
- match the phase or we will get out of sync with the ISR. */
- if (RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | XFER_CNT_0 | AUTO_INT))
- return;
- WR_HARPOON(p_port+hp_xfercnt_0, 0x00);
- curr_phz = RD_HARPOON(p_port+hp_scsisig) & (UCHAR)S_SCSI_PHZ;
- WRW_HARPOON((p_port+hp_intstat), XFER_CNT_0);
- WR_HARPOON(p_port+hp_scsisig, curr_phz);
- while ( !(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RESET)) &&
- (curr_phz == (RD_HARPOON(p_port+hp_scsisig) & (UCHAR)S_SCSI_PHZ)) )
- {
- if (curr_phz & (UCHAR)SCSI_IOBIT)
- {
- WR_HARPOON(p_port+hp_portctrl_0, (SCSI_PORT | HOST_PORT | SCSI_INBIT));
- if (!(RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY))
- {
- RD_HARPOON(p_port+hp_fifodata_0);
- }
- }
- else
- {
- WR_HARPOON(p_port+hp_portctrl_0, (SCSI_PORT | HOST_PORT | HOST_WRT));
- if (RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY)
- {
- WR_HARPOON(p_port+hp_fifodata_0,0xFA);
- }
- }
- } /* End of While loop for padding data I/O phase */
- while ( !(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RESET)))
- {
- if (RD_HARPOON(p_port+hp_scsisig) & SCSI_REQ)
- break;
- }
- WR_HARPOON(p_port+hp_portctrl_0, (SCSI_PORT | HOST_PORT | SCSI_INBIT));
- while (!(RD_HARPOON(p_port+hp_xferstat) & FIFO_EMPTY))
- {
- RD_HARPOON(p_port+hp_fifodata_0);
- }
- if ( !(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RESET)))
- {
- WR_HARPOON(p_port+hp_autostart_0, (AUTO_IMMED+DISCONNECT_START));
- while (!(RDW_HARPOON((p_port+hp_intstat)) & AUTO_INT)) {}
- if (RDW_HARPOON((p_port+hp_intstat)) & (ICMD_COMP | ITAR_DISC))
- while (!(RDW_HARPOON((p_port+hp_intstat)) & (BUS_FREE | RSEL))) ;
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: schkdd
- *
- * Description: Make sure data has been flushed from both FIFOs and abort
- * the operations if necessary.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void schkdd(USHORT port, UCHAR p_card)
- #else
- void schkdd(ULONG port, UCHAR p_card)
- #endif
- {
- USHORT TimeOutLoop;
- UCHAR sPhase;
- PSCCB currSCCB;
- currSCCB = BL_Card[p_card].currentSCCB;
- if ((currSCCB->Sccb_scsistat != DATA_OUT_ST) &&
- (currSCCB->Sccb_scsistat != DATA_IN_ST)) {
- return;
- }
- if (currSCCB->Sccb_XferState & F_ODD_BALL_CNT)
- {
- currSCCB->Sccb_ATC += (currSCCB->Sccb_XferCnt-1);
- currSCCB->Sccb_XferCnt = 1;
- currSCCB->Sccb_XferState &= ~F_ODD_BALL_CNT;
- WRW_HARPOON((port+hp_fiforead), (USHORT) 0x00);
- WR_HARPOON(port+hp_xferstat, 0x00);
- }
- else
- {
- currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt;
- currSCCB->Sccb_XferCnt = 0;
- }
- if ((RDW_HARPOON((port+hp_intstat)) & PARITY) &&
- (currSCCB->HostStatus == SCCB_COMPLETE)) {
- currSCCB->HostStatus = SCCB_PARITY_ERR;
- WRW_HARPOON((port+hp_intstat), PARITY);
- }
- hostDataXferAbort(port,p_card,currSCCB);
- while (RD_HARPOON(port+hp_scsisig) & SCSI_ACK) {}
- TimeOutLoop = 0;
- while(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY)
- {
- if (RDW_HARPOON((port+hp_intstat)) & BUS_FREE) {
- return;
- }
- if (RD_HARPOON(port+hp_offsetctr) & (UCHAR)0x1F) {
- break;
- }
- if (RDW_HARPOON((port+hp_intstat)) & RESET) {
- return;
- }
- if ((RD_HARPOON(port+hp_scsisig) & SCSI_REQ) || (TimeOutLoop++>0x3000) )
- break;
- }
- sPhase = RD_HARPOON(port+hp_scsisig) & (SCSI_BSY | S_SCSI_PHZ);
- if ((!(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY)) ||
- (RD_HARPOON(port+hp_offsetctr) & (UCHAR)0x1F) ||
- (sPhase == (SCSI_BSY | S_DATAO_PH)) ||
- (sPhase == (SCSI_BSY | S_DATAI_PH)))
- {
- WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
- if (!(currSCCB->Sccb_XferState & F_ALL_XFERRED))
- {
- if (currSCCB->Sccb_XferState & F_HOST_XFER_DIR) {
- phaseDataIn(port,p_card);
- }
- else {
- phaseDataOut(port,p_card);
- }
- }
- else
- {
- sxfrp(port,p_card);
- if (!(RDW_HARPOON((port+hp_intstat)) &
- (BUS_FREE | ICMD_COMP | ITAR_DISC | RESET)))
- {
- WRW_HARPOON((port+hp_intstat), AUTO_INT);
- phaseDecode(port,p_card);
- }
- }
- }
- else {
- WR_HARPOON(port+hp_portctrl_0, 0x00);
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: sinits
- *
- * Description: Setup SCCB manager fields in this SCCB.
- *
- *---------------------------------------------------------------------*/
- void sinits(PSCCB p_sccb, UCHAR p_card)
- {
- PSCCBMgr_tar_info currTar_Info;
- if((p_sccb->TargID > MAX_SCSI_TAR) || (p_sccb->Lun > MAX_LUN))
- {
- return;
- }
- currTar_Info = &sccbMgrTbl[p_card][p_sccb->TargID];
- p_sccb->Sccb_XferState = 0x00;
- p_sccb->Sccb_XferCnt = p_sccb->DataLength;
- if ((p_sccb->OperationCode == SCATTER_GATHER_COMMAND) ||
- (p_sccb->OperationCode == RESIDUAL_SG_COMMAND)) {
- p_sccb->Sccb_SGoffset = 0;
- p_sccb->Sccb_XferState = F_SG_XFER;
- p_sccb->Sccb_XferCnt = 0x00;
- }
- if (p_sccb->DataLength == 0x00)
- p_sccb->Sccb_XferState |= F_ALL_XFERRED;
- if (p_sccb->ControlByte & F_USE_CMD_Q)
- {
- if ((currTar_Info->TarStatus & TAR_TAG_Q_MASK) == TAG_Q_REJECT)
- p_sccb->ControlByte &= ~F_USE_CMD_Q;
- else
- currTar_Info->TarStatus |= TAG_Q_TRYING;
- }
- /* For !single SCSI device in system & device allow Disconnect
- or command is tag_q type then send Cmd with Disconnect Enable
- else send Cmd with Disconnect Disable */
- /*
- if (((!(BL_Card[p_card].globalFlags & F_SINGLE_DEVICE)) &&
- (currTar_Info->TarStatus & TAR_ALLOW_DISC)) ||
- (currTar_Info->TarStatus & TAG_Q_TRYING)) {
- */
- if ((currTar_Info->TarStatus & TAR_ALLOW_DISC) ||
- (currTar_Info->TarStatus & TAG_Q_TRYING)) {
- p_sccb->Sccb_idmsg = (UCHAR)(SMIDENT | DISC_PRIV) | p_sccb->Lun;
- }
- else {
- p_sccb->Sccb_idmsg = (UCHAR)SMIDENT | p_sccb->Lun;
- }
- p_sccb->HostStatus = 0x00;
- p_sccb->TargetStatus = 0x00;
- p_sccb->Sccb_tag = 0x00;
- p_sccb->Sccb_MGRFlags = 0x00;
- p_sccb->Sccb_sgseg = 0x00;
- p_sccb->Sccb_ATC = 0x00;
- p_sccb->Sccb_savedATC = 0x00;
- /*
- p_sccb->SccbVirtDataPtr = 0x00;
- p_sccb->Sccb_forwardlink = NULL;
- p_sccb->Sccb_backlink = NULL;
- */
- p_sccb->Sccb_scsistat = BUS_FREE_ST;
- p_sccb->SccbStatus = SCCB_IN_PROCESS;
- p_sccb->Sccb_scsimsg = SMNO_OP;
- }
- #ident "$Id: phase.c 1.11 1997/01/31 02:08:49 mohan Exp $"
- /*----------------------------------------------------------------------
- *
- *
- * Copyright 1995-1996 by Mylex Corporation. All Rights Reserved
- *
- * This file is available under both the GNU General Public License
- * and a BSD-style copyright; see LICENSE.FlashPoint for details.
- *
- * $Workfile: phase.c $
- *
- * Description: Functions to intially handle the SCSI bus phase when
- * the target asserts request (and the automation is not
- * enabled to handle the situation).
- *
- * $Date: 1997/01/31 02:08:49 $
- *
- * $Revision: 1.11 $
- *
- *----------------------------------------------------------------------*/
- /*#include <globals.h>*/
- #if (FW_TYPE==_UCB_MGR_)
- /*#include <budi.h>*/
- #endif
- /*#include <sccbmgr.h>*/
- /*#include <blx30.h>*/
- /*#include <target.h>*/
- /*#include <scsi2.h>*/
- /*#include <harpoon.h>*/
- /*
- extern SCCBCARD BL_Card[MAX_CARDS];
- extern SCCBMGR_TAR_INFO sccbMgrTbl[MAX_CARDS][MAX_SCSI_TAR];
- #if defined(OS2)
- extern void (far *s_PhaseTbl[8]) (ULONG, UCHAR);
- #else
- #if defined(DOS)
- extern void (*s_PhaseTbl[8]) (USHORT, UCHAR);
- #else
- extern void (*s_PhaseTbl[8]) (ULONG, UCHAR);
- #endif
- #endif
- */
- /*---------------------------------------------------------------------
- *
- * Function: Phase Decode
- *
- * Description: Determine the phase and call the appropriate function.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void phaseDecode(USHORT p_port, UCHAR p_card)
- #else
- void phaseDecode(ULONG p_port, UCHAR p_card)
- #endif
- {
- unsigned char phase_ref;
- #if defined(OS2)
- void (far *phase) (ULONG, UCHAR);
- #else
- #if defined(DOS)
- void (*phase) (USHORT, UCHAR);
- #else
- void (*phase) (ULONG, UCHAR);
- #endif
- #endif
- DISABLE_AUTO(p_port);
- phase_ref = (UCHAR) (RD_HARPOON(p_port+hp_scsisig) & S_SCSI_PHZ);
- phase = s_PhaseTbl[phase_ref];
- (*phase)(p_port, p_card); /* Call the correct phase func */
- }
- /*---------------------------------------------------------------------
- *
- * Function: Data Out Phase
- *
- * Description: Start up both the BusMaster and Xbow.
- *
- *---------------------------------------------------------------------*/
- #if defined(OS2)
- void far phaseDataOut(ULONG port, UCHAR p_card)
- #else
- #if defined(DOS)
- void phaseDataOut(USHORT port, UCHAR p_card)
- #else
- void phaseDataOut(ULONG port, UCHAR p_card)
- #endif
- #endif
- {
- PSCCB currSCCB;
- currSCCB = BL_Card[p_card].currentSCCB;
- if (currSCCB == NULL)
- {
- return; /* Exit if No SCCB record */
- }
- currSCCB->Sccb_scsistat = DATA_OUT_ST;
- currSCCB->Sccb_XferState &= ~(F_HOST_XFER_DIR | F_NO_DATA_YET);
- WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
- WRW_HARPOON((port+hp_intstat), XFER_CNT_0);
- WR_HARPOON(port+hp_autostart_0, (END_DATA+END_DATA_START));
- dataXferProcessor(port, &BL_Card[p_card]);
- #if defined(NOBUGBUG)
- if (RDW_HARPOON((port+hp_intstat)) & XFER_CNT_0)
- WRW_HARPOON((port+hp_intstat), XFER_CNT_0);
- #endif
- if (currSCCB->Sccb_XferCnt == 0) {
- if ((currSCCB->ControlByte & SCCB_DATA_XFER_OUT) &&
- (currSCCB->HostStatus == SCCB_COMPLETE))
- currSCCB->HostStatus = SCCB_DATA_OVER_RUN;
- sxfrp(port,p_card);
- if (!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | RESET)))
- phaseDecode(port,p_card);
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: Data In Phase
- *
- * Description: Startup the BusMaster and the XBOW.
- *
- *---------------------------------------------------------------------*/
- #if defined(OS2)
- void far phaseDataIn(ULONG port, UCHAR p_card)
- #else
- #if defined(DOS)
- void phaseDataIn(USHORT port, UCHAR p_card)
- #else
- void phaseDataIn(ULONG port, UCHAR p_card)
- #endif
- #endif
- {
- PSCCB currSCCB;
- currSCCB = BL_Card[p_card].currentSCCB;
- if (currSCCB == NULL)
- {
- return; /* Exit if No SCCB record */
- }
- currSCCB->Sccb_scsistat = DATA_IN_ST;
- currSCCB->Sccb_XferState |= F_HOST_XFER_DIR;
- currSCCB->Sccb_XferState &= ~F_NO_DATA_YET;
- WR_HARPOON(port+hp_portctrl_0, SCSI_PORT);
- WRW_HARPOON((port+hp_intstat), XFER_CNT_0);
- WR_HARPOON(port+hp_autostart_0, (END_DATA+END_DATA_START));
- dataXferProcessor(port, &BL_Card[p_card]);
- if (currSCCB->Sccb_XferCnt == 0) {
- if ((currSCCB->ControlByte & SCCB_DATA_XFER_IN) &&
- (currSCCB->HostStatus == SCCB_COMPLETE))
- currSCCB->HostStatus = SCCB_DATA_OVER_RUN;
- sxfrp(port,p_card);
- if (!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | RESET)))
- phaseDecode(port,p_card);
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: Command Phase
- *
- * Description: Load the CDB into the automation and start it up.
- *
- *---------------------------------------------------------------------*/
- #if defined(OS2)
- void far phaseCommand(ULONG p_port, UCHAR p_card)
- #else
- #if defined(DOS)
- void phaseCommand(USHORT p_port, UCHAR p_card)
- #else
- void phaseCommand(ULONG p_port, UCHAR p_card)
- #endif
- #endif
- {
- PSCCB currSCCB;
- #if defined(DOS)
- USHORT cdb_reg;
- #else
- ULONG cdb_reg;
- #endif
- UCHAR i;
- currSCCB = BL_Card[p_card].currentSCCB;
- if (currSCCB->OperationCode == RESET_COMMAND) {
- currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL;
- currSCCB->CdbLength = SIX_BYTE_CMD;
- }
- WR_HARPOON(p_port+hp_scsisig, 0x00);
- ARAM_ACCESS(p_port);
- cdb_reg = p_port + CMD_STRT;
- for (i=0; i < currSCCB->CdbLength; i++) {
- if (currSCCB->OperationCode == RESET_COMMAND)
- WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + 0x00));
- else
- WRW_HARPOON(cdb_reg, (MPM_OP + ACOMMAND + currSCCB->Cdb[i]));
- cdb_reg +=2;
- }
- if (currSCCB->CdbLength != TWELVE_BYTE_CMD)
- WRW_HARPOON(cdb_reg, (BRH_OP+ALWAYS+ NP));
- WR_HARPOON(p_port+hp_portctrl_0,(SCSI_PORT));
- currSCCB->Sccb_scsistat = COMMAND_ST;
- WR_HARPOON(p_port+hp_autostart_3, (AUTO_IMMED | CMD_ONLY_STRT));
- SGRAM_ACCESS(p_port);
- }
- /*---------------------------------------------------------------------
- *
- * Function: Status phase
- *
- * Description: Bring in the status and command complete message bytes
- *
- *---------------------------------------------------------------------*/
- #if defined(OS2)
- void far phaseStatus(ULONG port, UCHAR p_card)
- #else
- #if defined(DOS)
- void phaseStatus(USHORT port, UCHAR p_card)
- #else
- void phaseStatus(ULONG port, UCHAR p_card)
- #endif
- #endif
- {
- /* Start-up the automation to finish off this command and let the
- isr handle the interrupt for command complete when it comes in.
- We could wait here for the interrupt to be generated?
- */
- WR_HARPOON(port+hp_scsisig, 0x00);
- WR_HARPOON(port+hp_autostart_0, (AUTO_IMMED+END_DATA_START));
- }
- /*---------------------------------------------------------------------
- *
- * Function: Phase Message Out
- *
- * Description: Send out our message (if we have one) and handle whatever
- * else is involed.
- *
- *---------------------------------------------------------------------*/
- #if defined(OS2)
- void far phaseMsgOut(ULONG port, UCHAR p_card)
- #else
- #if defined(DOS)
- void phaseMsgOut(USHORT port, UCHAR p_card)
- #else
- void phaseMsgOut(ULONG port, UCHAR p_card)
- #endif
- #endif
- {
- UCHAR message,scsiID;
- PSCCB currSCCB;
- PSCCBMgr_tar_info currTar_Info;
- currSCCB = BL_Card[p_card].currentSCCB;
- if (currSCCB != NULL) {
- message = currSCCB->Sccb_scsimsg;
- scsiID = currSCCB->TargID;
- if (message == SMDEV_RESET)
- {
- currTar_Info = &sccbMgrTbl[p_card][scsiID];
- currTar_Info->TarSyncCtrl = 0;
- sssyncv(port, scsiID, NARROW_SCSI,currTar_Info);
- if (sccbMgrTbl[p_card][scsiID].TarEEValue & EE_SYNC_MASK)
- {
- sccbMgrTbl[p_card][scsiID].TarStatus &= ~TAR_SYNC_MASK;
- }
- if (sccbMgrTbl[p_card][scsiID].TarEEValue & EE_WIDE_SCSI)
- {
- sccbMgrTbl[p_card][scsiID].TarStatus &= ~TAR_WIDE_MASK;
- }
- queueFlushSccb(p_card,SCCB_COMPLETE);
- SccbMgrTableInitTarget(p_card,scsiID);
- }
- else if (currSCCB->Sccb_scsistat == ABORT_ST)
- {
- currSCCB->HostStatus = SCCB_COMPLETE;
- if(BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] != NULL)
- {
- BL_Card[p_card].discQ_Tbl[currSCCB->Sccb_tag] = NULL;
- sccbMgrTbl[p_card][scsiID].TarTagQ_Cnt--;
- }
-
- }
- else if (currSCCB->Sccb_scsistat < COMMAND_ST)
- {
- if(message == SMNO_OP)
- {
- currSCCB->Sccb_MGRFlags |= F_DEV_SELECTED;
-
- ssel(port,p_card);
- return;
- }
- }
- else
- {
- if (message == SMABORT)
- queueFlushSccb(p_card,SCCB_COMPLETE);
- }
- }
- else
- {
- message = SMABORT;
- }
- WRW_HARPOON((port+hp_intstat), (BUS_FREE | PHASE | XFER_CNT_0));
- WR_HARPOON(port+hp_portctrl_0, SCSI_BUS_EN);
- WR_HARPOON(port+hp_scsidata_0,message);
- WR_HARPOON(port+hp_scsisig, (SCSI_ACK + S_ILL_PH));
- ACCEPT_MSG(port);
- WR_HARPOON(port+hp_portctrl_0, 0x00);
- if ((message == SMABORT) || (message == SMDEV_RESET) ||
- (message == SMABORT_TAG) )
- {
- while(!(RDW_HARPOON((port+hp_intstat)) & (BUS_FREE | PHASE))) {}
- if (RDW_HARPOON((port+hp_intstat)) & BUS_FREE)
- {
- WRW_HARPOON((port+hp_intstat), BUS_FREE);
- if (currSCCB != NULL)
- {
- if((BL_Card[p_card].globalFlags & F_CONLUN_IO) &&
- ((sccbMgrTbl[p_card][currSCCB->TargID].TarStatus & TAR_TAG_Q_MASK) != TAG_Q_TRYING))
- sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[currSCCB->Lun] = FALSE;
- else
- sccbMgrTbl[p_card][currSCCB->TargID].TarLUNBusy[0] = FALSE;
- queueCmdComplete(&BL_Card[p_card],currSCCB, p_card);
- }
- else
- {
- BL_Card[p_card].globalFlags |= F_NEW_SCCB_CMD;
- }
- }
- else
- {
- sxfrp(port,p_card);
- }
- }
- else
- {
- if(message == SMPARITY)
- {
- currSCCB->Sccb_scsimsg = SMNO_OP;
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- else
- {
- sxfrp(port,p_card);
- }
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: Message In phase
- *
- * Description: Bring in the message and determine what to do with it.
- *
- *---------------------------------------------------------------------*/
- #if defined(OS2)
- void far phaseMsgIn(ULONG port, UCHAR p_card)
- #else
- #if defined(DOS)
- void phaseMsgIn(USHORT port, UCHAR p_card)
- #else
- void phaseMsgIn(ULONG port, UCHAR p_card)
- #endif
- #endif
- {
- UCHAR message;
- PSCCB currSCCB;
- currSCCB = BL_Card[p_card].currentSCCB;
- if (BL_Card[p_card].globalFlags & F_HOST_XFER_ACT)
- {
- phaseChkFifo(port, p_card);
- }
- message = RD_HARPOON(port+hp_scsidata_0);
- if ((message == SMDISC) || (message == SMSAVE_DATA_PTR))
- {
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+END_DATA_START));
- }
- else
- {
- message = sfm(port,currSCCB);
- if (message)
- {
- sdecm(message,port,p_card);
- }
- else
- {
- if(currSCCB->Sccb_scsimsg != SMPARITY)
- ACCEPT_MSG(port);
- WR_HARPOON(port+hp_autostart_1, (AUTO_IMMED+DISCONNECT_START));
- }
- }
- }
- /*---------------------------------------------------------------------
- *
- * Function: Illegal phase
- *
- * Description: Target switched to some illegal phase, so all we can do
- * is report an error back to the host (if that is possible)
- * and send an ABORT message to the misbehaving target.
- *
- *---------------------------------------------------------------------*/
- #if defined(OS2)
- void far phaseIllegal(ULONG port, UCHAR p_card)
- #else
- #if defined(DOS)
- void phaseIllegal(USHORT port, UCHAR p_card)
- #else
- void phaseIllegal(ULONG port, UCHAR p_card)
- #endif
- #endif
- {
- PSCCB currSCCB;
- currSCCB = BL_Card[p_card].currentSCCB;
- WR_HARPOON(port+hp_scsisig, RD_HARPOON(port+hp_scsisig));
- if (currSCCB != NULL) {
- currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL;
- currSCCB->Sccb_scsistat = ABORT_ST;
- currSCCB->Sccb_scsimsg = SMABORT;
- }
- ACCEPT_MSG_ATN(port);
- }
- /*---------------------------------------------------------------------
- *
- * Function: Phase Check FIFO
- *
- * Description: Make sure data has been flushed from both FIFOs and abort
- * the operations if necessary.
- *
- *---------------------------------------------------------------------*/
- #if defined(DOS)
- void phaseChkFifo(USHORT port, UCHAR p_card)
- #else
- void phaseChkFifo(ULONG port, UCHAR p_card)
- #endif
- {
- ULONG xfercnt;
- PSCCB currSCCB;
- currSCCB = BL_Card[p_card].currentSCCB;
- if (currSCCB->Sccb_scsistat == DATA_IN_ST)
- {
- while((!(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY)) &&
- (RD_HARPOON(port+hp_ext_status) & BM_CMD_BUSY)) {}
- if (!(RD_HARPOON(port+hp_xferstat) & FIFO_EMPTY))
- {
- currSCCB->Sccb_ATC += currSCCB->Sccb_XferCnt;
- currSCCB->Sccb_XferCnt = 0;
- if ((RDW_HARPOON((port+hp_intstat)) & PARITY) &&
- (currSCCB->HostStatus == SCCB_COMPLETE))
- {
- currSCCB->HostStatus = SCCB_PARITY_ERR;
- WRW_HARPOON((port+hp_intstat), PARITY);
- }
- hostDataXferAbort(port,p_card,currSCCB);