⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wd33c93lib1.c

📁 vxworks源码源码解读是学习vxworks的最佳途径
💻 C
📖 第 1 页 / 共 3 页
字号:
    return (OK);    }/********************************************************************************* sbicXferCountGet - fetch the SBIC transfer count** The value of the transfer counter is copied to *pCount.** RETURNS: N/A.** NOMANUAL*/void sbicXferCountGet    (    FAST SBIC *pSbic,   /* ptr to SBIC info      */    FAST int  *pCount   /* ptr to returned value */    )    {    FAST UINT tempCount = (UINT) 0;    *pSbic->pAdrsReg = SBIC_REG_XFER_COUNT_MSB;    tempCount |= ((UINT) *pSbic->pRegFile) << 16;    tempCount |= ((UINT) *pSbic->pRegFile) << 8;    tempCount |=  (UINT) *pSbic->pRegFile;    *pCount = (int) tempCount;    }/********************************************************************************* sbicCommand - write a command code to the SBIC Command Register** RETURNS: N/A.** NOMANUAL*/void sbicCommand    (    SBIC *pSbic,        /* ptr to SBIC info */    UINT8 cmdCode       /* new command code */    )    {    /* delay until previous command has been interpretted */    while (*pSbic->pAuxStatReg & SBIC_AUX_STAT_CMD_IN_PROG)	;    /* load new command */    *pSbic->pAdrsReg = SBIC_REG_COMMAND;    *pSbic->pRegFile = cmdCode;    }/********************************************************************************* sbicScsiBusReset - assert the RST line on the SCSI bus** This routine asserts the RST line on the SCSI bus, which should cause* all connected devices to return to a known quiescent state.** RETURNS: N/A.*/LOCAL void sbicScsiBusReset    (    FAST SBIC *pSbic    /* ptr to SBIC info */    )    {    (*pSbic->sbicScsiReset) (pSbic);    }/********************************************************************************* sbicIntr - interrupt service routine for the SBIC** RETURNS: N/A.** NOMANUAL*/LOCAL void sbicIntr    (    SBIC *pSbic          /* ptr to SBIC info */    )    {    FAST UINT8 scsiStatus;    FAST UINT8 statusGroup;    /* read 'SCSI Status' Reg. and determine status group and code */    *pSbic->pAdrsReg = SBIC_REG_SCSI_STATUS;    scsiStatus = pSbic->scsiStatusCode = *pSbic->pRegFile;    statusGroup = STAT_GROUP(scsiStatus);    SCSI_INT_DEBUG_MSG ("*** SBIC INTERRUPT *** ", 0, 0, 0, 0, 0, 0);    switch (statusGroup)	{	case STAT_GROUP_RESET:	    SCSI_INT_DEBUG_MSG ("SBIC Reset interrupt, Code = 0x%x\n",				scsiStatus, 0, 0, 0, 0, 0);	    break;	case STAT_GROUP_SUCCESSFUL:	    SCSI_INT_DEBUG_MSG ("SBIC Successful Completion interrupt, \				Code = 0x%x\n", scsiStatus, 0, 0, 0, 0, 0);	    switch (scsiStatus)		{		case STAT_SUCC_SELECT:		    pSbic->pDevToSelect->devStatus = SELECT_SUCCESSFUL;		    semGive (&pSbic->pDevToSelect->devSyncSem);		    break;		}	    break;	case STAT_GROUP_PAUSE_ABORTED:	    SCSI_INT_DEBUG_MSG ("SBIC Aborted interrupt, Code = 0x%x\n",				scsiStatus, 0, 0, 0, 0, 0);	    switch (scsiStatus)		{		case STAT_PAUSE_MSG_IN:		    semGive (&pSbic->scsiCtrl.ctrlSyncSem);		    break;		}	    break;	case STAT_GROUP_TERMINATED:	    SCSI_INT_DEBUG_MSG ("SBIC Terminated interrupt, Code = 0x%x\n",				scsiStatus, 0, 0, 0, 0, 0);	    switch (scsiStatus)		{		case STAT_TERM_TIMEOUT:		    pSbic->pDevToSelect->devStatus = SELECT_TIMEOUT;		    semGive (&pSbic->pDevToSelect->devSyncSem);		    break;		}	    break;	case STAT_GROUP_SERVICE_REQ:	    SCSI_INT_DEBUG_MSG ("SBIC Serv. Req. interrupt, Code = 0x%x\n",				scsiStatus, 0, 0, 0, 0, 0);	    switch (scsiStatus)		{		case STAT_SERV_REQ_DISCON:		    pSbic->scsiCtrl.scsiBusPhase = SCSI_BUS_FREE_PHASE;		    semGive (&pSbic->scsiCtrl.ctrlSyncSem);		    break;		}	    break;	default:	    SCSI_INT_DEBUG_MSG ("SBIC << Unrecognized >> interrupt, \				Code = 0x%x\n", scsiStatus, 0, 0, 0, 0, 0);	}    if (scsiStatus & STAT_PHASE_REQ)	{	pSbic->scsiCtrl.scsiBusPhase = (int) (scsiStatus & STAT_MCI_BITS);	semGive (&pSbic->scsiCtrl.ctrlSyncSem);	}    }/********************************************************************************* sbicHwInit - initialize the SBIC to a known state** This routine puts the SBIC into a known quiescent state and issues a reset* to the SCSI bus if any signals are active, thus putting target devices in* some presumably known state.  Currently the initial state is not configurable* and does not enable reselection.** RETURNS: N/A.*/LOCAL void sbicHwInit    (    SBIC *pSbic                 /* ptr to an SBIC structure */    )    {    int tempOwnIdReg = 0;	/* where to form value for "own ID" reg */    if (pSbic->devType == SBIC_WD33C93A)	{	if (pSbic->scsiCtrl.clkPeriod >= 100)	    tempOwnIdReg = SBIC_FREQ_SELECT_LOW;	else if (pSbic->scsiCtrl.clkPeriod >= 66)	    tempOwnIdReg = SBIC_FREQ_SELECT_MID;	else	    tempOwnIdReg = SBIC_FREQ_SELECT_HIGH;	}    tempOwnIdReg |= pSbic->scsiCtrl.scsiCtrlBusId;    sbicScsiBusReset (pSbic);    sbicRegWrite(pSbic, SBIC_REG_OWN_ID, (UINT8) tempOwnIdReg);    sbicCommand (pSbic, SBIC_CMD_RESET);    }/********************************************************************************* sbicRegRead - Get the contents of a specified SBIC register** RETURNS: N/A.** NOMANUAL*/LOCAL void sbicRegRead    (    SBIC *pSbic,         /* ptr to an SBIC structure */    UINT8 regAdrs,       /* register to read         */    int  *pDatum         /* put data here            */    )    {    *pSbic->pAdrsReg = regAdrs;    *pDatum = (int) *pSbic->pRegFile;    }/********************************************************************************* sbicRegWrite - write a value to a specified SBIC register** RETURNS: N/A.** NOMANUAL*/LOCAL void sbicRegWrite    (    SBIC *pSbic,         /* ptr to an SBIC structure */    UINT8 regAdrs,       /* register to write        */    UINT8 datum          /* data to write            */    )    {    *pSbic->pAdrsReg = regAdrs;    *pSbic->pRegFile = datum;    }/********************************************************************************* wd33c93Show - display the values of all readable WD33C93 chip registers** This routine displays the state of the SBIC registers in a user-friendly* manner.  It is useful primarily for debugging.  It should not be invoked * while another running process is accessing the SCSI controller.** EXAMPLE:* .CS*     -> sbicShow*     REG #00 (Own ID         ) = 0x07*     REG #01 (Control        ) = 0x00*     REG #02 (Timeout Period ) = 0x20*     REG #03 (Sectors        ) = 0x00*     REG #04 (Heads          ) = 0x00*     REG #05 (Cylinders MSB  ) = 0x00 *     REG #06 (Cylinders LSB  ) = 0x00*     REG #07 (Log. Addr. MSB ) = 0x00*     REG #08 (Log. Addr. 2SB ) = 0x00*     REG #09 (Log. Addr. 3SB ) = 0x00*     REG #0a (Log. Addr. LSB ) = 0x00*     REG #0b (Sector Number  ) = 0x00*     REG #0c (Head Number    ) = 0x00 *     REG #0d (Cyl. Number MSB) = 0x00*     REG #0e (Cyl. Number LSB) = 0x00*     REG #0f (Target LUN     ) = 0x00*     REG #10 (Command Phase  ) = 0x00*     REG #11 (Synch. Transfer) = 0x00*     REG #12 (Xfer Count MSB ) = 0x00*     REG #13 (Xfer Count 2SB ) = 0x00*     REG #14 (Xfer Count LSB ) = 0x00*     REG #15 (Destination ID ) = 0x03*     REG #16 (Source ID      ) = 0x00*     REG #17 (SCSI Status    ) = 0x42*     REG #18 (Command        ) = 0x07* .CE** RETURNS: OK, or ERROR if <pScsiCtrl> and <pSysScsiCtrl> are both NULL.*/LOCAL STATUS wd33c93Show    (    FAST SCSI_CTRL *pScsiCtrl   /* ptr to SCSI controller info */    )    {    FAST int ix;    FAST SBIC *pSbic;		/* ptr to SBIC info */    LOCAL char * regName [] =	{	"Own ID	        ",	"Control        ",	"Timeout Period ",	"Sectors        ",	"Heads          ",	"Cylinders MSB  ",	"Cylinders LSB  ",	"Log. Addr. MSB ",	"Log. Addr. 2SB ",	"Log. Addr. 3SB ",	"Log. Addr. LSB ",	"Sector Number  ",	"Head Number    ",	"Cyl. Number MSB",	"Cyl. Number LSB",	"Target LUN     ",	"Command Phase  ",	"Synch. Transfer",	"Xfer Count MSB ",	"Xfer Count 2SB ",	"Xfer Count LSB ",	"Destination ID ",	"Source ID      ",	"SCSI Status    ",	"Command        "	};    if (pScsiCtrl == NULL)        {	if (pSysScsiCtrl == NULL)	    {	    printErr ("No SCSI controller specified.\n");	    return (ERROR);	    }        pScsiCtrl = pSysScsiCtrl;        }    pSbic = (SBIC *) pScsiCtrl;    for (ix = SBIC_REG_OWN_ID; ix <= SBIC_REG_COMMAND; ix++)	{        *pSbic->pAdrsReg = (UINT8) ix;	printf ("REG #%02x (%s) = 0x%02x\n", ix, regName [ix],		*pSbic->pRegFile);	}    return (OK);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -