📄 ini910u.c
字号:
0x03, /* 0x8: BIOSConfig1*/
0, /* 0x9: BIOSConfig2*/
0, /* 0xA: BIOSConfig3*/
0, /* 0xB: BIOSConfig4*/
/* ----SCSI channel 0 and target Structure ---- */
7, /* 0xC: SCSIid */
0x13, /* 0xD: SCSIconfig1*/
0, /* 0xE: SCSIconfig2*/
0x8, /* 0xF: NumSCSItarget */
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
0x68, 0x68, 0x68, 0x68,
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
/* ---------- CheckSum ---------- */
0, 0 }; /* ox3E, 0x3F checksum */
int i;
ULONG chksum = 0;
USHORT * np, *np1;
/* Calculate checksum first */
np = (USHORT * )dftNvRam;
for ( i = 0; i < 31; i++)
chksum += *np++;
*np = (USHORT)chksum;
se2_ew_en(hcsp); /* Enable write */
np = (USHORT * )dftNvRam;
np1 = (USHORT * )nvramp;
for ( i = 0; i < 32; i++, np++, np1++) {
if (*np != *np1 ) {
se2_wr( hcsp, i, *np );
}
}
se2_ew_ds(hcsp); /* Disable write */
return 1;
}
/*************************************************************************
Function name : read_eeprom
**************************************************************************/
void read_eeprom( hcsp, nvramp )
HCS *hcsp;
NVRAM *nvramp;
{
UCHAR gctrl;
/*------Enable EEProm programming ---*/
gctrl = TUL_RD( hcsp->Base, TUL_GCTRL );
TUL_WR( hcsp->Base + TUL_GCTRL, gctrl | EEPRG );
if ( se2_rd_all(hcsp, nvramp) != 1 ) {
se2_update_all( hcsp, nvramp); /* setup default pattern */
se2_rd_all(hcsp, nvramp); /* load again */
}
/*------ Disable EEProm programming ---*/
gctrl = TUL_RD( hcsp->Base, TUL_GCTRL );
TUL_WR( hcsp->Base + TUL_GCTRL, gctrl & ~EEPRG );
} /* read_eeprom */
/***************************************************************************/
int init_tulip(hcsp)
register HCS *hcsp;
{
NVRAM nvram, *nvramp = &nvram;
UCHAR xfrPeriod[8] = { /* fast 20 */
/* nanosecond devide by 4 */
12, /* 50ns, 20M */
18, /* 75ns, 13.3M */
25, /* 100ns, 10M */
31, /* 125ns, 8M */
37, /* 150ns, 6.6M */
43, /* 175ns, 5.7M */
50, /* 200ns, 5M */
62 /* 250ns, 4M */
};
register TCS *tcsp;
UBYTE readByte, *readBytep;
ULONG i, j;
ULONG_PTR TulSCmd;
TulSCmd = hcsp->Base + TUL_SCmd;
hcsp->SCSIFunc = tulip_scsi;
hcsp->semaph = 1;
hcsp->JSStatus0 = 0;
hcsp->JSStatus1 = 0;
hcsp->Scb = 0;
hcsp->ScbEnd = 0;
hcsp->NxtPend = 0;
hcsp->NxtContig = -1;
hcsp->ActScb = NULL;
hcsp->ActTcs = NULL;
hcsp->FirstPend = NULL;
hcsp->LastPend = NULL;
hcsp->FirstBusy = NULL;
hcsp->LastBusy = NULL;
hcsp->FirstDone = NULL;
hcsp->LastDone = NULL;
TUL_WR(hcsp->Base + TUL_Mask, 0x0f);
/*------------- get serial EEProm settting -------*/
read_eeprom( hcsp, nvramp );
if (nvramp->Signature != INI_SIGNATURE)
return (-1);
if ((nvramp->ModelByte0 != 0x95) && (nvramp->ModelByte0 != 0x94))
return (-1);
if (nvramp->Revision != 1)
return (-1);
/*----------- get H/A configuration --------------*/
hcsp->HaId = nvramp->SCSIid;
/* program HBA's SCSI ID */
TUL_WR( hcsp->Base + TUL_SScsiId, hcsp->HaId << 4);
hcsp->Config = nvramp->SCSIconfig1;
/* mask all the interrupt */
TUL_WR(hcsp->Base + TUL_Mask, 0x1F);
/*--- Initialize the tulip ---*/
TUL_WR( hcsp->Base + TUL_SCtrl0, TSC_RST_CHIP);
/* program HBA's SCSI ID */
TUL_WR( hcsp->Base + TUL_SScsiId, hcsp->HaId << 4);
if (hcsp->Config & HCC_EN_PAR)
TUL_WR(hcsp->Base + TUL_SConfig, TSC_INITDEFAULT | TSC_EN_SCSI_PAR);
else
TUL_WR(hcsp->Base + TUL_SConfig, TSC_INITDEFAULT );
/* Enable HW reselect */
TUL_WR(hcsp->Base + TUL_SCtrl1, TSC_HW_RESELECT );
TUL_WR(hcsp->Base + TUL_SPeriodOffset, 0x0);
/* selection time out = 250 ms */
TUL_WR(hcsp->Base + TUL_STimeOut, 153);
/*--------- Enable SCSI terminator -----*/
readByte = TUL_RD(hcsp->Base, TUL_XCtrl);
readByte |= (hcsp->Config & (HCC_ACT_TERM1 | HCC_ACT_TERM2) );
TUL_WR(hcsp->Base + TUL_XCtrl, readByte & 0xFE);
/*----------- set auto termination ------*/
readByte = TUL_RD(hcsp->Base, TUL_GCTRLH) & 0xFE;
readByte |= (hcsp->Config & HCC_AUTO_TERM) >> 4;
TUL_WR(hcsp->Base + TUL_GCTRLH, readByte );
if (nvramp->NumSCSItarget != 8 ) {
hcsp->wide_scsi_card = 1;
} else
{
hcsp->wide_scsi_card = 0;
}
readBytep = (UCHAR * ) & (nvramp->Target0Config);
tcsp = &hcsp->Tcs[0];
for (i = 0; i < 16; tcsp++, readBytep++, i++) {
tcsp->Flags = (USHORT) * readBytep;
tcsp->xfrPeriodIdx = (tcsp->Flags & TCF_SCSI_RATE );
tcsp->Flags = (*readBytep) & ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
tcsp->Flags |= TCF_EN_TAG;
if (hcsp->wide_scsi_card == 0)
tcsp->Flags |= TCF_NO_WDTR;
TUL_WR(hcsp->Base + TUL_SPeriodOffset, 0x0);
if (hcsp->Config & HCC_EN_PAR)
tcsp->sConfig = TSC_INITDEFAULT_ALT0 | TSC_EN_SCSI_PAR;
else
tcsp->sConfig = TSC_INITDEFAULT;
tcsp->MaximumTags = TAG_NUMBER;
} /* for */
readByte = TUL_RD(hcsp->Base, TUL_DCtrl);
TUL_WR(hcsp->Base + TUL_DCtrl, readByte | 0x80);
readByte = TUL_RD(hcsp->Base, TUL_GCTRLH); /* 12/09/97 */
TUL_WR(hcsp->Base + TUL_GCTRLH, readByte | 0x02); /* 12/09/97 */
TUL_WR(hcsp->Base + TUL_SConf1, 0x17); /* 12/09/97 */
return (0);
}
/***************************************************************************/
void AbortXPend(hcsp)
register HCS *hcsp;
{
UCHAR readByte;
if (TUL_RD(hcsp->Base, TUL_XStatus) & XPEND) {
readByte = TUL_RD(hcsp->Base, TUL_XCmd);
TUL_WR(hcsp->Base + TUL_XCmd, readByte | TAX_X_ABT | TAX_X_CLR_FIFO);
while (!( TUL_RD(hcsp->Base, TUL_Int) & XABT )) {
}
}
}
/***************************************************************************/
void reset_tulip(hcsp)
register HCS *hcsp;
{
register TCS *tcsp;
UBYTE readByte;
int i;
/* mask all the interrupt */
TUL_WR(hcsp->Base + TUL_Mask, 0x1F);
TUL_WR( hcsp->Base + TUL_SIntEnable, 0xFF);
/* reset tulip chip */
TUL_WR( hcsp->Base + TUL_SCtrl0, TSC_RST_CHIP);
/* program HBA's SCSI ID */
TUL_WR( hcsp->Base + TUL_SScsiId, hcsp->HaId << 4);
if (hcsp->Config & HCC_EN_PAR)
TUL_WR(hcsp->Base + TUL_SConfig, TSC_INITDEFAULT | TSC_EN_SCSI_PAR);
else
TUL_WR(hcsp->Base + TUL_SConfig, TSC_INITDEFAULT );
TUL_WR(hcsp->Base + TUL_SPeriodOffset, 0x0);
/* selection time out = 250 ms */
TUL_WR(hcsp->Base + TUL_STimeOut, 153);
tcsp = &hcsp->Tcs[0];
for (i = 0; i < 16; tcsp++, i++) {
tcsp->Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
TUL_WR(hcsp->Base + TUL_SPeriodOffset, 0x0);
} /* for */
/* Enable HW reselect */
TUL_WR(hcsp->Base + TUL_SCtrl1, TSC_HW_RESELECT );
/*--------- Enable SCSI terminator -----*/
readByte = TUL_RD(hcsp->Base, TUL_XCtrl);
readByte |= (hcsp->Config & (HCC_ACT_TERM1 | HCC_ACT_TERM2) );
TUL_WR(hcsp->Base + TUL_XCtrl, readByte & 0xFE);
}
/***************************************************************************/
int tul_abort_srb(hcsp, srbp)
HCS *hcsp;
PSCSI_REQUEST_BLOCK srbp;
{
register TULSCB *scbp;
ULONG i;
uint find = 0;
TULSCB * pTmpScb;
pTmpScb = hcsp->FirstPend;
while (pTmpScb != NULL) {
if (srbp == pTmpScb->Srb) {
if (pTmpScb->Status != 0) {
pTmpScb->Status = 0;
ll_unlink_pend_scb(hcsp, pTmpScb);
return (1);
}
}
pTmpScb = (PTULSCB)(pTmpScb->NextScb);
}
pTmpScb = hcsp->FirstBusy;
while (pTmpScb != NULL) {
if (srbp == pTmpScb->Srb) {
pTmpScb->Status = 0;
ll_unlink_busy_scb(hcsp, pTmpScb);
return (11);
}
pTmpScb = (PTULSCB)(pTmpScb->NextScb);
}
return (0);
}
/***************************************************************************/
int tul_exec_scb(hcsp, scbp)
HCS *hcsp;
TULSCB *scbp;
{
scbp->Status = TULSCB_PEND;
scbp->Mode = 0;
scbp->SGIdx = 0;
scbp->SGMax = scbp->SGLen;
if (scbp->Opcode == AbortCmd )
ll_push_pend_scb(hcsp, scbp);
else
ll_append_pend_scb(hcsp, scbp);
if (hcsp->semaph == 1) {
tul_dis_sint(hcsp); /* disable Tulmin SCSI Int */
hcsp->semaph = 0;
tulip_main(hcsp);
hcsp->semaph = 1;
tul_en_sint(hcsp); /* Enable tulip SCSI Int */
}
return 1;
}
/***************************************************************************/
int tul_isr(hcsp)
HCS *hcsp;
{
UBYTE stat, rtn;
/* enter critical section */
stat = TUL_RD(hcsp->Base, TUL_SStatus0 );
if (stat & TSS_INT_PENDING) {
if (hcsp->semaph == 1) {
tul_dis_sint(hcsp); /* disable Tulmin SCSI Int */
hcsp->semaph = 0;
hcsp->JSStatus0 = stat;
tulip_main(hcsp);
hcsp->semaph = 1;
tul_en_sint(hcsp); /* Enable tulip SCSI Int */
return 1;
}
return 0;
}
return 0;
}
/***************************************************************************/
int tulip_main(hcsp)
register HCS *hcsp;
{
register TULSCB *scbp;
register TCS *tcsp;
int rtn;
for (; ; ) {
(*(hcsp->SCSIFunc))(hcsp);
while (scbp = ll_pop_done_scb(hcsp)) {
tcsp = &hcsp->Tcs[scbp->Target];
if (!(scbp->Mode & SCM_RSENS)) {
if (scbp->TaStat == 2) {
if (scbp->HaStat == HOST_DO_DU)
scbp->HaStat = 0;
tcsp->Flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
if (scbp->Flags & SCF_SENSE) {
UBYTE len;
len = scbp->SenseLen;
if (len == 0)
len = 1;
scbp->BufLen = scbp->SenseLen;
scbp->BufPtr = scbp->SensePtr;
scbp->TagMsg = 0;
scbp->Ident &= ~DISC_ALLOW;
scbp->Flags &= ~(SCF_SG | SCF_DIR);
scbp->Mode = SCM_RSENS;
scbp->TaStat = 0;
scbp->CDBLen = 6;
scbp->CDB[0] = SCSICMD_RequestSense;
scbp->CDB[1] = 0;
scbp->CDB[2] = 0;
scbp->CDB[3] = 0;
scbp->CDB[4] = len;
scbp->CDB[5] = 0;
scbp->Status = TULSCB_PEND | TULSCB_CONTIG;
ll_push_pend_scb(hcsp, scbp);
break;
}
}
} else { /* in request sense mode */
if (scbp->TaStat == 2) {
/* check contition status again after sending
requset sense cmd 0x3*/
scbp->HaStat = HOST_BAD_PHAS;
}
scbp->TaStat = 2;
}
scbp->Flags |= SCF_DONE;
if (scbp->Flags & SCF_POST) {
(*scbp->Post)(hcsp, scbp);
}
} /* while */
/* find_active: */
hcsp->JSStatus0 = TUL_RD(hcsp->Base, TUL_SStatus0);
if ((hcsp->JSStatus0 & TSS_INT_PENDING)) {
continue;
}
if (hcsp->ActScb) {
/* return to OS and wait for xfer_done_ISR/Selected_ISR */
return 1; /* return to OS, enable interrupt */
} else {
if ((scbp = hcsp->FirstPend ) == NULL) {
return 1; /* return to OS, enable interrupt */
}
}
} /* for */
}
/***************************** mod_ALTPD ****************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -