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

📄 sysdec21x40end.c

📁 cpc-1631的BSP包for VxWorks操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
     * The following code tries to automatically detect the first instance
     * of a DEC21143, DEC21140 or DEC21040 Ethernet based PCI board.
     */

    for (sysDecBoardTypeNo = 0; sysDecBoardTypeNo < BOARD_TYPE_NB; 
	 sysDecBoardTypeNo++)
        {
        if (pciFindDevice (sysDecBoardRsrc[sysDecBoardTypeNo].vendorId,
                               sysDecBoardRsrc[sysDecBoardTypeNo].deviceId,
                               0, &pciBus, &pciDevice, &pciFunc) == OK)
            {
            /* board detected */

            found = TRUE;

            boardType = sysDecBoardRsrc[sysDecBoardTypeNo].type;

            /* select the media function */

            _func_dec21x40MediaSelect = 
		sysDecBoardRsrc[sysDecBoardTypeNo].mediaSelectFunc;

            break;
            }
        }

    if (!found || (pciDevice > PCI_MAX_DEV))
        {
        return (ERROR);
        }

    /* we found the right one */

    sysDecPciDevNo = pciDevice;

    sysDecPciRsrcs[sysDecPciDevNo].boardType = boardType;

    pRsrc = &(sysDecPciRsrcs[sysDecPciDevNo]);
    pRsrc->pciBus    = pciBus;
    pRsrc->pciDevice = pciDevice;
    pRsrc->pciFunc   = pciFunc;

#ifdef PCI_CONFIG_FORCE
    if (sysPciMstrCfgAdrs == PCI_MSTR_CNFG_ADRS_A) /* map A */
	{
        membaseCsr = DEC_PCI_MEMBASE_MAP_A;
        iobaseCsr = DEC_DEVADDR_MAP_A;  
	}
    else /* map B */
	{
        membaseCsr = DEC_PCI_MEMBASE_MAP_B;
        iobaseCsr = DEC_DEVADDR_MAP_B;  
	}
    irq = pciIntToIrq(pciDevice, INTA);

    pciDevConfig(pRsrc->pciBus, pRsrc->pciDevice, pRsrc->pciFunc,
                 iobaseCsr, membaseCsr,
            PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE | PCI_CMD_MASTER_ENABLE);
#endif
    /* get memory base address and IO base address */

    pciConfigInLong (pRsrc->pciBus, pRsrc->pciDevice, pRsrc->pciFunc,
                            PCI_CFG_BASE_ADDRESS_0, &iobaseCsr);
    pciConfigInLong (pRsrc->pciBus, pRsrc->pciDevice, pRsrc->pciFunc,
                            PCI_CFG_BASE_ADDRESS_1, &membaseCsr);
    pciConfigInByte (pRsrc->pciBus, pRsrc->pciDevice, pRsrc->pciFunc,
                            PCI_CFG_DEV_INT_LINE, &irq);

    membaseCsr   &= PCI_MEMBASE_MASK;
    iobaseCsr    &= PCI_IOBASE_MASK;

    /* overwrite the resource table with read value */
 
    pRsrc->membaseCsr   = membaseCsr;
    pRsrc->iobaseCsr    = iobaseCsr;
    pRsrc->irq          = irq;
    pRsrc->irqvec       = IVEC_TO_INUM(irq);

    /* 
     * enable mapped memory and IO addresses.
     */

    pciConfigOutWord (pciBus, pciDevice, pciFunc, PCI_CFG_COMMAND,
                      PCI_CMD_MEM_ENABLE | 
		      PCI_CMD_IO_ENABLE  | 
		      PCI_CMD_MASTER_ENABLE);

    /* disable sleep mode */

    pciConfigOutByte (pciBus, pciDevice, pciFunc, PCI_CFG_MODE, 
		      SLEEP_MODE_DIS);

    return (OK);
    }

/*******************************************************************************
*
* sysDec21x40Init - prepare LAN adapter for dec21X4X initialization
*
* This routine is expected to perform any adapter-specific or target-specific
* initialization that must be done prior to initializing the dec21X4X.
*
* The dec21X4X driver calls this routine from the driver endLoad routine before
* any other routines in this library.
*
* This routine determines the base address, the main memory address over 
* the PCI bus, the interrupt level and the interrupt vector parameter.
*
* RETURNS: OK or ERROR if the adapter could not be prepared for initialization.
*/
 
STATUS sysDec21x40Init
    (
    DEC21X40_DRV_CTRL * pDrvCtrl
    )
    {
    SYS_DEC_PCI_RSRC * pRsrc = &(sysDecPciRsrcs [sysDecPciDevNo]);
 
    /* locate the dec21X4X based adapter. */

    switch (pRsrc->boardType)
        {

        case EB143 :
        case DC140 :
        case DC040 :
            /* set the device control structure */
 
            pDrvCtrl->devAdrs = PCI_MEMIO2LOCAL (pRsrc->membaseCsr);
            pDrvCtrl->pciMemBase = PCI_SLV_MEM_LOCAL;
            pDrvCtrl->ilevel = pRsrc->irq;
            pDrvCtrl->ivec = pRsrc->irqvec;
            break;

        default :
            return (ERROR);
        }
 
    return (OK);
    }
 

/*******************************************************************************
*
* sysDec21x40EnetAddrGet - get Ethernet address
*
* This routine provides a target-specific interface for accessing a
* device Ethernet address.
*
* RETURNS: OK or ERROR if could not be obtained.
*/

STATUS  sysDec21x40EnetAddrGet
    (
    int         unit,
    char *      enetAdrs
    )
    {
    /*
     * There isn't a target-specific interface for accessing a
     * device Ethernet address.
     */

    return (ERROR);
    }

/*******************************************************************************
*
* sysDec21143MediaSelect - hook routine for dec21x40Start
*
* This is hook routine for dec21x40Start(). This routine selects a media for
* dec21143 board.
*
* RETURNS: OK, always.
*/
 
STATUS sysDec21143MediaSelect
    (
    DEC21X40_DRV_CTRL *      pDrvCtrl,   /* Driver control */
    UINT *                   pCsr6Val    /* CSR6 return value */
    )
    {
    ULONG *     csrReg;
    ULONG       csrData;

    /* set CSR6 value */
 
    *pCsr6Val |= CSR6_21140_MB1;

    /* Led/Control selection */
 
    csrReg   = (ULONG *)(pDrvCtrl->devAdrs + (CSR15 * DECPCI_REG_OFFSET));
    csrData  = (CSR15_21143_CWE | CSR15_21143_LG3 | CSR15_21143_LG1
                                                         | CSR15_MD_MSK);
    *csrReg  = PCISWAP (csrData);

    csrData = (CSR15_21143_LG3 | CSR15_21143_LG1 | CSR15_MODE_10);
    *csrReg  = PCISWAP (csrData);

    /* force 10Base-T halh duplex configuration */
 
    /* set SIA registers */
 
    csrReg   = (ULONG *)(pDrvCtrl->devAdrs + (CSR14 * DECPCI_REG_OFFSET));
    csrData  = PCISWAP (*csrReg);
    csrData &= ~(CSR14_21143_T4 | CSR14_21143_TXF| CSR14_21143_TXH |
                        CSR14_21143_TAS | CSR14_21143_TH | CSR14_21143_ANE);
    *csrReg = PCISWAP(csrData);
 
    csrReg   = (ULONG *)(pDrvCtrl->devAdrs + (CSR13 * DECPCI_REG_OFFSET));
    csrData  = PCISWAP (*csrReg);
    csrData |= CSR13_SRL_SIA;
    *csrReg  = PCISWAP (csrData);
 
    return (OK);
    }

/*******************************************************************************
*
* sysDec21140MediaSelect - hook routine for dec21x40Start
*
* This is hook routine for dec21x40Start(). This routine selects a media for
* dec21140 board.
*
* RETURNS: OK, always.
*/

STATUS sysDec21140MediaSelect
    (
    DEC21X40_DRV_CTRL *      pDrvCtrl,   /* Driver control */
    UINT *                   pCsr6Val    /* CSR6 return value */
    )
    {

    /* set CSR6 value */
    *pCsr6Val = CSR6_21140_PS;
    return (OK);
    }

#endif /* defined(INCLUDE_NETWORK) && defined(INCLUDE_DC_END) */

⌨️ 快捷键说明

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