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

📄 gei82543init.c

📁 intel 82543 千兆网卡 vxworks驱动源码
💻 C
📖 第 1 页 / 共 2 页
字号:
    gPort= Ros_GlobalPort(slot,1,0);    /* config only one device */    if(OK!=gei82545EndIoctl(gPort, cmd, (char *)data))    {        return ERROR;    }    return OK;}/******************************************************************************* sys543IntAck - acknowledge an 82543 interrupt** This routine performs any 82543 interrupt acknowledge that may be* required.  This typically involves an operation to some interrupt* control hardware.** This routine gets called from the 82543 driver's interrupt handler.** This routine assumes that the PCI configuration information has already* been setup.** RETURNS: OK, or ERROR if the interrupt could not be acknowledged.*/LOCAL STATUS sys543IntAck    (    int    slot     /* unit number */    ){    GEI_RESOURCE *pReso = (GEI_RESOURCE *)NULL;    if((slot<1)||(slot>MAX_IF_CARD_NUM))    {        return ERROR;    }    pReso=&geiResources[slot];    switch (pReso->boardType)    {        case TYPE_PRO1000F_PCI:        /* handle PRO1000F/T LAN Adapter */        case TYPE_PRO1000T_PCI:           /* no addition work necessary for the PRO1000F/T */            break;        default:            return (ERROR);    }    return (OK);}/******************************************************************************** sys543LocalToPciBusAdrs - convert a local address to a bus address** This routine returns a PCIbus address for the LOCAL bus address.**/LOCAL UINT32 sys543LocalToPciBusAdrs    (    int slot,    UINT32      adrs    /* Local Address */    ){    return (GEI_LOCAL2PCI_MEMIO(adrs));}/******************************************************************************** sys543PciBusToLocalAdrs - convert a bus address to a local address** This routine returns a local address that is used to access the PCIbus.* The bus address that is passed into this routine is the PCIbus address* as it would be seen on the local bus.**/LOCAL UINT32 sys543PciBusToLocalAdrs    (    int slot,    UINT32      adrs    /* PCI Address */    ){    return(GEI_PCI_MEMIO2LOCAL(adrs));}/******************************************************************************* sys543IntEnable - enable 82543 interrupts** This routine enables 82543 interrupts.  This may involve operations on* interrupt control hardware.** The 82543 driver calls this routine throughout normal operation to terminate* critical sections of code.** This routine assumes that the PCI configuration information has already* been setup.** RETURNS: OK, or ERROR if interrupts could not be enabled.*/LOCAL STATUS sys543IntEnable    (    int    slot  /* local unit number */    ){    if((slot<1)||(slot>MAX_IF_CARD_NUM))    {        return ERROR;    }    if (b_pciIntEnable(geiResources[slot].irq) != OK)    {        printf("sysgeiIntEnable(): Enable slot %d int error.\n", slot);        return ERROR;    }    return OK;}/******************************************************************************* sys543IntDisable - disable 82543 interrupts** This routine disables 82543 interrupts.  This may involve operations on* interrupt control hardware.** The 82543 driver calls this routine throughout normal operation to enter* critical sections of code.** This routine assumes that the PCI configuration information has already* been setup.** RETURNS: OK, or ERROR if interrupts could not be disabled.*/LOCAL STATUS sys543IntDisable    (    int   slot   /* local unit number */    ){    if((slot<1)||(slot>MAX_IF_CARD_NUM))    {        return ERROR;    }    if (b_pciIntDisable(geiResources[slot].irq) != OK)    {        printf("sysgeiIntDisable(): Disable slot %d int error.\n", slot);        return ERROR;    }    return OK;}/*************************************************************************** gei82543HwInit - Initialize 82543 MAC chip** This routine initializes MAC and set up link** RETURN: OK if success*/ STATUS gei82543HwInit    (    END_DEVICE * pDrvCtrl    ){    /* clean up all receive address */    gei82543AllRxAdrClean (pDrvCtrl);    /* clean up all MTA registers */    gei82543AllMtaAdrClean (pDrvCtrl);    /* clean up VLAN stuff */    gei82543AllVlanClean (pDrvCtrl);    /* set up the IA for receive */    gei82543EtherRxAdrSet (pDrvCtrl, pDrvCtrl->adaptor.enetAddr, 0);    return (gei82543linkInit (pDrvCtrl));}/*************************************************************************** gei82543linkInit - set up link for device operation** This routine gets the configuration parameters from eeprom and configure* device for linking** RETURNS: OK if setup success*/ STATUS gei82543linkInit    (    END_DEVICE *pDrvCtrl    ){    static int initflag = 0;    STATUS status = OK;    UINT32 tclRegVal;    UINT32 staReg;    /* check copper or fiber based adapter */    GEI_READ_REG(INTEL_82543GC_STATUS, staReg);    if (staReg & STATUS_TBIMODE_BIT)    {        pDrvCtrl->cableType = GEI_FIBER_MEDIA;    }    else    {        pDrvCtrl->cableType = GEI_COPPER_MEDIA;    }    pDrvCtrl->devCtrlRegVal = 0;    if(pDrvCtrl->cableType==GEI_FIBER_MEDIA)    {        pDrvCtrl->devCtrlRegVal |= CTRL_ILOS_BIT;    }    /* program the transmit control register */    GEI_READ_REG(INTEL_82543GC_TCTL, tclRegVal);    tclRegVal |= (FDX_COLLISION_DISTANCE << TCTL_COLD_SHIFT);    GEI_WRITE_REG(INTEL_82543GC_TCTL, tclRegVal);    /*establish a link */    if (pDrvCtrl->cableType == GEI_FIBER_MEDIA)    {        /*the first time setup link,use the default value*/        if(0 == initflag)        {            status= gei82543linkTBISetup(pDrvCtrl,TRUE);            DRV_LOG (DRV_DEBUG_LOAD, "gei82543linkTBISetup:First establish link value:%d\n",                                  status, 2, 3, 4, 5, 6);            initflag = 1;        }        /*put the link setup task in the fwdjob to avoid the system busy alarm*/        else        {           fwdJobAdd(gei82543linkTBISetup, (int)pDrvCtrl, (int)TRUE, 0, 0, 0);        }        DRV_LOG (DRV_DEBUG_LOAD, "gei82543linkTBISetup:establish link value:%d\n",                                  status, 2, 3, 4, 5, 6);    }    else if (pDrvCtrl->cableType == GEI_COPPER_MEDIA)    {        status = gei82543linkGMIISetup (pDrvCtrl);    }    else    {        DRV_LOG (DRV_DEBUG_LOAD, "Do not recognize media type\n",                                  1, 2, 3, 4, 5, 6);        return ERROR;    }    pDrvCtrl->linkStatus= (volatile UINT32)status;    if (pDrvCtrl->linkStatus != OK)    {        DRV_LOG (DRV_DEBUG_LOAD, ("gei82543EndStart: link setup fails\n"),                                   1, 2, 3, 4, 5, 6);        LOGMSG("link fails\n", 1, 2, 3, 4, 5, 6);    }    return status;}/*************************************************************************** gei82543linkGMIIPreInit - pre-init PHY for GMII link setup** This routine resets PHY devices through 82543 chip, set up PHY_INFO* structure** RETURN: OK or ERROR*/STATUS gei82543linkGMIIPreInit    (    END_DEVICE * pDrvCtrl   /* device to do GMII pre-init */    ){    /*     * We will establish a link through PHY, and then manually     * configure the 82543 chip based on PHY's negotiation results*/    pDrvCtrl->devCtrlRegVal |= CTRL_SLU_BIT;    GEI_WRITE_REG(INTEL_82543GC_CTRL, pDrvCtrl->devCtrlRegVal);    /* allocate memory for PHY_INFO structure */    if ((PHY_INFO *)NULL == (pDrvCtrl->pPhyInfo = (PHY_INFO *)calloc (sizeof (PHY_INFO), 1)))    {        return (ERROR);    }    /* clean up PHY_INFO structure */    memset (pDrvCtrl->pPhyInfo, 0, sizeof (PHY_INFO));    /* set up phyInfo structure */    pDrvCtrl->pPhyInfo->pDrvCtrl = (void *) pDrvCtrl;    pDrvCtrl->pPhyInfo->phyAddr = 1;  /*82545 intergrated the mac and phy togther ,so the phyaddress is always 1*/    pDrvCtrl->pPhyInfo->phySpeed=1000;    /* PHY's read/write operation routine */    pDrvCtrl->pPhyInfo->phyWriteRtn = (FUNCPTR) gei82544PhyWrite;    pDrvCtrl->pPhyInfo->phyReadRtn = (FUNCPTR) gei82544PhyRead;    /*phy's delay operation routine and parameters*/    pDrvCtrl->pPhyInfo->phyDelayRtn = (FUNCPTR) taskDelay;    pDrvCtrl->pPhyInfo->phyMaxDelay = 8 * (UINT32)sysClkRateGet() / 5; /* 8 sec */    pDrvCtrl->pPhyInfo->phyDelayParm = 5;    pDrvCtrl->pPhyInfo->phyFlags = GEI_MII_PHY_CAP_FLAGS ;    if (pDrvCtrl->adaptor.phyType == GEI_PHY_GMII_TYPE)    {        pDrvCtrl->pPhyInfo->phyFlags |= MII_PHY_GMII_TYPE; /* GMII type */    }    else    {        pDrvCtrl->pPhyInfo->phyFlags &= ~MII_PHY_GMII_TYPE;    }    pDrvCtrl->pPhyInfo->phyFlags |= MII_PHY_AUTO; /* allow auto-negotiation */    /* mark phyflags to indicated pre-initialization */    pDrvCtrl->pPhyInfo->phyFlags |= MII_PHY_PRE_INIT;    /* save flags for later reference */    pDrvCtrl->phyInitFlags = pDrvCtrl->pPhyInfo->phyFlags;    return OK;}BOOL gei82545IsFx(UINT8 slot){    UINT8 attVal;    UINT8 cardVal;    UINT32 baseAddr;    if (slot<1||slot>MAX_IF_CARD_NUM)    {        printf("Invalid slot number!\n");        return FALSE;    }    baseAddr = b_infBaseAddrGet(slot);    cardVal = *(volatile UINT8 *)(baseAddr + IF_SUBTYPE_REG);    attVal = *(volatile UINT8 *)(baseAddr + IF_ATT_REG);    /*read the IF_ATT_REG,if attVal=0x0,the port is electric,               if attVal=0x1,the port is fiber*/    if((cardVal==0x13)&&(attVal==0x1))    {        return TRUE;    }    else    {        return FALSE;    }}

⌨️ 快捷键说明

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