mbCards = 0; }  if(RdStack(ioport, 0) != 0x00) { if(ChkIfChipInitialized(ioport) == FALSE) 
FPT_mbCards = 0; }  if(FPT_RdStack(ioport, 0) != 0x00) { if(FPT_ChkIfChipInitialized(ioport) == 0) 
int SccbMgr_sense_adapter(PSCCBMGR_INFO pCardInfo){#if defined(DOS)#else   static UCHAR first_time = 1;#endif   UCHAR i,j,id,ScamFlg;   USHORT temp,temp2,temp3,temp4,temp5,temp6;#if defined(DOS)   USHORT ioport;#else   ULONG ioport;#endif	PNVRamInfo pCurrNvRam;#if defined(DOS)   ioport = (USHORT)pCardInfo->si_baseaddr;#else   ioport = pCardInfo->si_baseaddr;#endif   if (RD_HARPOON(ioport+hp_vendor_id_0) != ORION_VEND_0)      return((int)FAILURE);   if ((RD_HARPOON(ioport+hp_vendor_id_1) != ORION_VEND_1))      return((int)FAILURE);   if ((RD_HARPOON(ioport+hp_device_id_0) != ORION_DEV_0))      return((int)FAILURE);   if ((RD_HARPOON(ioport+hp_device_id_1) != ORION_DEV_1))      return((int)FAILURE);   if (RD_HARPOON(ioport+hp_rev_num) != 0x0f){/* For new Harpoon then check for sub_device ID LSB   the bits(0-3) must be all ZERO for compatible with   current version of SCCBMgr, else skip this Harpoon	device. */	   if (RD_HARPOON(ioport+hp_sub_device_id_0) & 0x0f)	      return((int)FAILURE);	}   if (first_time)      {      SccbMgrTableInitAll();      first_time = 0;		mbCards = 0;      }	if(RdStack(ioport, 0) != 0x00) {		if(ChkIfChipInitialized(ioport) == FALSE)		{			pCurrNvRam = NULL;		   WR_HARPOON(ioport+hp_semaphore, 0x00);			XbowInit(ioport, 0);             /*Must Init the SCSI before attempting */			DiagEEPROM(ioport);		}		else		{			if(mbCards < MAX_MB_CARDS) {				pCurrNvRam = &nvRamInfo[mbCards];				mbCards++;				pCurrNvRam->niBaseAddr = ioport;				RNVRamData(pCurrNvRam);			}else				return((int) FAILURE);		}	}else		pCurrNvRam = NULL;#if defined (NO_BIOS_OPTION)	pCurrNvRam = NULL;   XbowInit(ioport, 0);                /*Must Init the SCSI before attempting */   DiagEEPROM(ioport);#endif  /* No BIOS Option */   WR_HARPOON(ioport+hp_clkctrl_0, CLKCTRL_DEFAULT);   WR_HARPOON(ioport+hp_sys_ctrl, 0x00);	if(pCurrNvRam)		pCardInfo->si_id = pCurrNvRam->niAdapId;	else	   pCardInfo->si_id = (UCHAR)(utilEERead(ioport, (ADAPTER_SCSI_ID/2)) &   	   (UCHAR)0x0FF);   pCardInfo->si_lun = 0x00;   pCardInfo->si_fw_revision = ORION_FW_REV;   temp2 = 0x0000;   temp3 = 0x0000;   temp4 = 0x0000;   temp5 = 0x0000;   temp6 = 0x0000;   for (id = 0; id < (16/2); id++) {		if(pCurrNvRam){			temp = (USHORT) pCurrNvRam->niSyncTbl[id];			temp = ((temp & 0x03) + ((temp << 4) & 0xc0)) +					 (((temp << 4) & 0x0300) + ((temp << 8) & 0xc000));		}else	      temp = utilEERead(ioport, (USHORT)((SYNC_RATE_TBL/2)+id));      for (i = 0; i < 2; temp >>=8,i++) {         temp2 >>= 1;         temp3 >>= 1;         temp4 >>= 1;         temp5 >>= 1;         temp6 >>= 1;	 switch (temp & 0x3)	   {	   case AUTO_RATE_20:	/* Synchronous, 20 mega-transfers/second */	     temp6 |= 0x8000;	/* Fall through */	   case AUTO_RATE_10:	/* Synchronous, 10 mega-transfers/second */	     temp5 |= 0x8000;	/* Fall through */	   case AUTO_RATE_05:	/* Synchronous, 5 mega-transfers/second */	     temp2 |= 0x8000;	/* Fall through */	   case AUTO_RATE_00:	/* Asynchronous */	     break;	   }         if (temp & DISC_ENABLE_BIT)	   temp3 |= 0x8000;         if (temp & WIDE_NEGO_BIT)	   temp4 |= 0x8000;         }      }   pCardInfo->si_per_targ_init_sync = temp2;   pCardInfo->si_per_targ_no_disc = temp3;   pCardInfo->si_per_targ_wide_nego = temp4;   pCardInfo->si_per_targ_fast_nego = temp5;   pCardInfo->si_per_targ_ultra_nego = temp6;	if(pCurrNvRam)		i = pCurrNvRam->niSysConf;	else	   i = (UCHAR)(utilEERead(ioport, (SYSTEM_CONFIG/2)));	if(pCurrNvRam)		ScamFlg = pCurrNvRam->niScamConf;	else	   ScamFlg = (UCHAR) utilEERead(ioport, SCAM_CONFIG/2);   pCardInfo->si_flags = 0x0000;   if (i & 0x01)      pCardInfo->si_flags |= SCSI_PARITY_ENA;   if (!(i & 0x02))      pCardInfo->si_flags |= SOFT_RESET;   if (i & 0x10)      pCardInfo->si_flags |= EXTENDED_TRANSLATION;   if (ScamFlg & SCAM_ENABLED)     pCardInfo->si_flags |= FLAG_SCAM_ENABLED;   if (ScamFlg & SCAM_LEVEL2)     pCardInfo->si_flags |= FLAG_SCAM_LEVEL2;   j = (RD_HARPOON(ioport+hp_bm_ctrl) & ~SCSI_TERM_ENA_L);   if (i & 0x04) {      j |= SCSI_TERM_ENA_L;      }   WR_HARPOON(ioport+hp_bm_ctrl, j );   j = (RD_HARPOON(ioport+hp_ee_ctrl) & ~SCSI_TERM_ENA_H);   if (i & 0x08) {      j |= SCSI_TERM_ENA_H;      }   WR_HARPOON(ioport+hp_ee_ctrl, j );   if (!(RD_HARPOON(ioport+hp_page_ctrl) & NARROW_SCSI_CARD))      pCardInfo->si_flags |= SUPPORT_16TAR_32LUN;   pCardInfo->si_card_family = HARPOON_FAMILY;   pCardInfo->si_bustype = BUSTYPE_PCI;	if(pCurrNvRam){   	pCardInfo->si_card_model[0] = '9';		switch(pCurrNvRam->niModel & 0x0f){			case MODEL_LT:		   	pCardInfo->si_card_model[1] = '3';		   	pCardInfo->si_card_model[2] = '0';				break;			case MODEL_LW:		   	pCardInfo->si_card_model[1] = '5';		   	pCardInfo->si_card_model[2] = '0';				break;			case MODEL_DL:		   	pCardInfo->si_card_model[1] = '3';		   	pCardInfo->si_card_model[2] = '2';				break;			case MODEL_DW:		   	pCardInfo->si_card_model[1] = '5';		   	pCardInfo->si_card_model[2] = '2';				break;		}	}else{	   temp = utilEERead(ioport, (MODEL_NUMB_0/2));   	pCardInfo->si_card_model[0] = (UCHAR)(temp >> 8);	   temp = utilEERead(ioport, (MODEL_NUMB_2/2));   	pCardInfo->si_card_model[1] = (UCHAR)(temp & 0x00FF);	   pCardInfo->si_card_model[2] = (UCHAR)(temp >> 8);	}   if (pCardInfo->si_card_model[1] == '3')     {       if (RD_HARPOON(ioport+hp_ee_ctrl) & BIT(7))	 pCardInfo->si_flags |= LOW_BYTE_TERM;     }   else if (pCardInfo->si_card_model[2] == '0')     {       temp = RD_HARPOON(ioport+hp_xfer_pad);       WR_HARPOON(ioport+hp_xfer_pad, (temp & ~BIT(4)));       if (RD_HARPOON(ioport+hp_ee_ctrl) & BIT(7))	 pCardInfo->si_flags |= LOW_BYTE_TERM;       WR_HARPOON(ioport+hp_xfer_pad, (temp | BIT(4)));       if (RD_HARPOON(ioport+hp_ee_ctrl) & BIT(7))	 pCardInfo->si_flags |= HIGH_BYTE_TERM;       WR_HARPOON(ioport+hp_xfer_pad, temp);     }   else     {       temp = RD_HARPOON(ioport+hp_ee_ctrl);       temp2 = RD_HARPOON(ioport+hp_xfer_pad);       WR_HARPOON(ioport+hp_ee_ctrl, (temp | SEE_CS));       WR_HARPOON(ioport+hp_xfer_pad, (temp2 | BIT(4)));       temp3 = 0;       for (i = 0; i < 8; i++)	 {	   temp3 <<= 1;	   if (!(RD_HARPOON(ioport+hp_ee_ctrl) & BIT(7)))	     temp3 |= 1;	   WR_HARPOON(ioport+hp_xfer_pad, (temp2 & ~BIT(4)));	   WR_HARPOON(ioport+hp_xfer_pad, (temp2 | BIT(4)));	 }       WR_HARPOON(ioport+hp_ee_ctrl, temp);       WR_HARPOON(ioport+hp_xfer_pad, temp2);       if (!(temp3 & BIT(7)))	 pCardInfo->si_flags |= LOW_BYTE_TERM;       if (!(temp3 & BIT(6)))	 pCardInfo->si_flags |= HIGH_BYTE_TERM;     }   ARAM_ACCESS(ioport);   for ( i = 0; i < 4; i++ ) {      pCardInfo->si_XlatInfo[i] =         RD_HARPOON(ioport+hp_aramBase+BIOS_DATA_OFFSET+i);      }	/* return with -1 if no sort, else return with	   logical card number sorted by BIOS (zero-based) */	pCardInfo->si_relative_cardnum =	(UCHAR)(RD_HARPOON(ioport+hp_aramBase+BIOS_RELATIVE_CARD)-1);   SGRAM_ACCESS(ioport);   s_PhaseTbl[0] = phaseDataOut;   s_PhaseTbl[1] = phaseDataIn;   s_PhaseTbl[2] = phaseIllegal;   s_PhaseTbl[3] = phaseIllegal;   s_PhaseTbl[4] = phaseCommand;   s_PhaseTbl[5] = phaseStatus;   s_PhaseTbl[6] = phaseMsgOut;   s_PhaseTbl[7] = phaseMsgIn;   pCardInfo->si_present = 0x01;#if defined(BUGBUG)   for (i = 0; i < MAX_CARDS; i++) {      for (id=0; id<debug_size; id++)         debug_int[i][id] =  (UCHAR)0x00;      debug_index[i] = 0;      }#endif   return(0);}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/47b5d69c4aa753fcfc9b2b8d28c0660a1e25c129/FlashPoint.c/buggy/drivers/scsi/FlashPoint.c