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

📄 m5200fecend.c

📁 MPC5200 BSP 支持ATA,USB, I2C,扩展网口
💻 C
📖 第 1 页 / 共 5 页
字号:
LOCAL void      motFecHandleRecvInt (DRV_CTRL *pDrvCtrl);LOCAL void      motFecReceive (DRV_CTRL *pDrvCtrl, MOT_FEC_RBD_ID pRfd);LOCAL STATUS    motFecMiiRead (DRV_CTRL *pDrvCtrl, UINT8 phyAddr,                   UINT8 regAddr, UINT16 *retVal);LOCAL STATUS    motFecMiiWrite (DRV_CTRL *pDrvCtrl, UINT8 phyAddr,                UINT8 regAddr, UINT16 writeData);LOCAL STATUS    motFecMiiDiag (DRV_CTRL *pDrvCtrl, UINT8 phyAddr);LOCAL STATUS    motFecMiiIsolate (DRV_CTRL *pDrvCtrl, UINT8 isoPhyAddr);LOCAL STATUS    motFecMiiAnRun (DRV_CTRL *pDrvCtrl, UINT8 phyAddr);LOCAL STATUS    motFecMiiAnStart (DRV_CTRL *pDrvCtrl, UINT8 phyAddr);LOCAL STATUS    motFecMiiModeForce (DRV_CTRL *pDrvCtrl, UINT8 phyAddr);LOCAL STATUS    motFecMiiDefForce (DRV_CTRL *pDrvCtrl, UINT8 phyAddr);LOCAL STATUS    motFecMiiAnCheck (DRV_CTRL *pDrvCtrl, UINT8 phyAddr);LOCAL STATUS    motFecMiiProbe (DRV_CTRL *pDrvCtrl, UINT8 phyAddr);LOCAL void      motFecRbdClean (DRV_CTRL *pDrvCtrl, volatile MOT_FEC_RBD_ID pRBDNew);/* END Specific interfaces. */END_OBJ *       m5200FecEndLoad (char *initString);LOCAL STATUS    motFecStart (DRV_CTRL *pDrvCtrl);LOCAL STATUS    motFecUnload (DRV_CTRL *pDrvCtrl);LOCAL STATUS    motFecStop (DRV_CTRL *pDrvCtrl);LOCAL int       motFecIoctl (DRV_CTRL *pDrvCtrl, int cmd, caddr_t data);LOCAL STATUS    motFecSend (DRV_CTRL *pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS    motFecMCastAddrAdd (DRV_CTRL *pDrvCtrl, char* pAddress);LOCAL STATUS    motFecMCastAddrDel (DRV_CTRL *pDrvCtrl, char* pAddress);LOCAL STATUS    motFecMCastAddrGet (DRV_CTRL *pDrvCtrl,                                        MULTI_TABLE *pTable);LOCAL STATUS    motFecPollSend (DRV_CTRL *pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS    motFecPollReceive (DRV_CTRL *pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS    motFecPollStart (DRV_CTRL *pDrvCtrl);LOCAL STATUS    motFecPollStop (DRV_CTRL *pDrvCtrl);LOCAL void mpc5200_sdma_task_setup(DRV_CTRL *pDrvCtrl);LOCAL void mpc5200_eth_addr_filter_set(DRV_CTRL *pDrvCtrl);/* globals */FUNCPTR _func_motFecPhyInit = (FUNCPTR) motFecPhyInit;FUNCPTR _func_motFecHbFail = (FUNCPTR) NULL;#ifdef MOT_FEC_DBGvoid motFecCsrShow (void);void motFecRbdShow (int);void motFecTbdShow (int);void motFecErrorShow (void);void motFecDrvShow (void);void motFecMiiShow (void);void motFecMibShow (void);#endif /* MOT_FEC_DBG *//* * Define the device function table.  This is static across all driver * instances. */LOCAL NET_FUNCS netFuncs =    {    (FUNCPTR) motFecStart,        /* start func. */            (FUNCPTR) motFecStop,        /* stop func. */    (FUNCPTR) motFecUnload,        /* unload func. */            (FUNCPTR) motFecIoctl,        /* ioctl func. */            (FUNCPTR) motFecSend,        /* send func. */            (FUNCPTR) motFecMCastAddrAdd,        /* multicast add func. */        (FUNCPTR) motFecMCastAddrDel,        /* multicast delete func. */    (FUNCPTR) motFecMCastAddrGet,        /* multicast get fun. */        (FUNCPTR) motFecPollSend,        /* polling send func. */        (FUNCPTR) motFecPollReceive,        /* polling receive func. */    endEtherAddressForm,           /* put address info into a NET_BUFFER */    (FUNCPTR) endEtherPacketDataGet,     /* get pointer to data in NET_BUFFER */    (FUNCPTR) endEtherPacketAddrGet      /* Get packet addresses */    };        /********************************************************************************* m5200FecEndLoad - initialize the driver and device** This routine initializes both driver and device to an operational state* using device specific parameters specified by <initString>.** The parameter string, <initString>, is an ordered list of parameters each* separated by a colon. The format of <initString> is:** "<MBARAddr>:<ivec>:<bufBase>:<bufSize>:<fifoTxBase>:<fifoRxBase>* :<tbdNum>:<rbdNum>:<phyAddr>:<isoPhyAddr>:<phyDefMode>:<userFlags>"** The FEC shares a region of memory with the driver.  The caller of this* routine can specify the address of this memory region, or can specify that* the driver must obtain this memory region from the system resources.** A default number of transmit/receive buffer descriptors of 32 can be* selected by passing zero in the parameters <tbdNum> and <rbdNum>.* In other cases, the number of buffers selected should be greater than two.** The <bufBase> parameter is used to inform the driver about the shared* memory region.  If this parameter is set to the constant "NONE," then this* routine will attempt to allocate the shared memory from the system.  Any* other value for this parameter is interpreted by this routine as the address* of the shared memory region to be used. The <bufSize> parameter is used* to check that this region is large enough with respect to the provided* values of both transmit/receive buffer descriptors.** If the caller provides the shared memory region, then the driver assumes* that this region does not require cache coherency operations, nor does it* require conversions between virtual and physical addresses.** If the caller indicates that this routine must allocate the shared memory* region, then this routine will use cacheDmaMalloc() to obtain* some  cache-safe memory.  The attributes of this memory will be checked,* and if the memory is not write coherent, this routine will abort and* return NULL.** RETURNS: an END object pointer, or NULL on error.** SEE ALSO: ifLib,* .I "MPC860T Fast Ethernet Controller (Supplement to MPC860 User's Manual)"*/END_OBJ* m5200FecEndLoad    (    char *initString      /* parameter string */    )    {    DRV_CTRL *    pDrvCtrl = NULL;    /* pointer to DRV_CTRL structure */    UCHAR       enetAddr[6];        /* ethernet address */		        MOT_FEC_LOG (MOT_FEC_DBG_LOAD, ("Loading end...\n"), 1, 2, 3, 4, 5, 6);            if (initString == NULL)        return (NULL);    if (initString[0] == 0)        {        bcopy ((char *)MOT_FEC_DEV_NAME, (void *)initString,               MOT_FEC_DEV_NAME_LEN);        return (NULL);        }    /* allocate the device structure */    pDrvCtrl = (DRV_CTRL *) calloc (sizeof (DRV_CTRL), 1);    if (pDrvCtrl == NULL)        return (NULL);    pDrvCtrl->phyInfo = (PHY_INFO *) calloc (sizeof (PHY_INFO), 1);    if (pDrvCtrl->phyInfo == NULL)        {        free ((char *)pDrvCtrl);        return (NULL);        }/*#ifdef MOT_FEC_DBG*/  /*jxl remmed for power down phy*/    pDrvCtrlDbg = pDrvCtrl;/*#endif*/ /* MOT_FEC_DBG */    /* Parse InitString */    if (motFecInitParse (pDrvCtrl, initString) == ERROR)        goto errorExit;        pDrvCtrl->ivec = (int) INUM_TO_IVEC (pDrvCtrl->ilevel);    /* sanity check the unit number */    if (pDrvCtrl->unit < 0 )        goto errorExit;    /* memory initialization */    if (motFecInitMem (pDrvCtrl) == ERROR)        goto errorExit;    /* get our ethernet hardware address */    SYS_FEC_ENET_ADDR_GET (enetAddr);    MOT_FEC_LOG (MOT_FEC_DBG_LOAD, ("m5200FecEndLoad: enetAddr=                    0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \n "),                    enetAddr[0],                    enetAddr[1],                    enetAddr[2],                    enetAddr[3],                    enetAddr[4],                    enetAddr[5]);    /* initialize some flags */    pDrvCtrl->loaded = TRUE;    pDrvCtrl->intrConnect = FALSE;    /*     * create the synchronization semaphores for mii intr handling     * and for graceful transmit command interrupts.     */    MOT_FEC_MII_SEM_CREATE;    MOT_FEC_GRA_SEM_CREATE;    /* endObj initializations */    if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*) pDrvCtrl,              MOT_FEC_DEV_NAME, pDrvCtrl->unit, &netFuncs,              "Motorola FEC Ethernet Enhanced Network Driver")        == ERROR)        goto errorExit;    pDrvCtrl->phyInfo->phySpeed = MOT_FEC_10MBS;    if (END_MIB_INIT (&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd,              (u_char *) &enetAddr[0], MOT_FEC_ADDR_LEN,              ETHERMTU, pDrvCtrl->phyInfo->phySpeed) == ERROR)        goto errorExit;    /* Mark the device ready */    END_OBJ_READY (&pDrvCtrl->endObj,                   IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST);		mpc5200_sdma_task_setup(pDrvCtrl);		pDrvCtrl->tbdBase = TaskGetBDRing( txTaskId );		pDrvCtrl->pBufBase = pDrvCtrl->tbdBase ;		pDrvCtrl->rbdBase = TaskGetBDRing( rxTaskId );    MOT_FEC_LOG (MOT_FEC_DBG_LOAD, ("m5200FecEndLoad... Done \n"),                    1, 2, 3, 4, 5, 6);		MOT_FEC_LOG (MOT_FEC_DBG_LOAD, ("pDrvCtrl: tbdBase=                    0x%x rbdBase= 0x%x \n "),                    pDrvCtrl->tbdBase,                    pDrvCtrl->rbdBase,                    3,                    4,                    5,                    6);    return (&pDrvCtrl->endObj);errorExit:    motFecUnload (pDrvCtrl);    free ((char *) pDrvCtrl);    return NULL;    }/********************************************************************************* motFecUnload - unload a driver from the system** This routine unloads the driver pointed to by <pDrvCtrl> from the system.** RETURNS: OK, always.** SEE ALSO: motFecLoad()*/LOCAL STATUS motFecUnload    (    DRV_CTRL    *pDrvCtrl       /* pointer to DRV_CTRL structure */    )    {    int        ix = 0;        /* a counter */		int        retVal;        /* convenient holder for return value */				UINT32 		 status = 0;		    MOT_FEC_LOG (MOT_FEC_DBG_LOAD, ("Unloading end..."), 1, 2, 3, 4, 5, 6);    if (pDrvCtrl == NULL)        return (ERROR);    /* issue a graceful transmit command */		MOT_FEC_CSR_RD (MOT_FEC_TX_CTRL_OFF, status);    MOT_FEC_CSR_WR (MOT_FEC_TX_CTRL_OFF, status | MOT_FEC_TX_CTRL_GRA);    /* wait for the related interrupt */    MOT_FEC_GRA_SEM_TAKE;    /* mask chip interrupts */    MOT_FEC_INT_DISABLE;            /* disable system interrupt: reset relevant bit in SIMASK */    SYS_FEC_INT_DISABLE (pDrvCtrl, retVal);    if (retVal == ERROR)        return (ERROR);    /* disconnect the interrupt handler */    SYS_FEC_INT_DISCONNECT (pDrvCtrl, motFecInt, (int)pDrvCtrl, retVal);    if (retVal == ERROR)        return (ERROR);            /*   * Disable the SmartDMA transmit and receive tasks.   */  	TaskStop( rxTaskId );  	TaskStop( txTaskId ); 		 		/*  * Disable transmit / receive interrupts  */  	  	intDisable(INUM_SDMA_TASK2);  	intDisable(INUM_SDMA_TASK3);			/* disable the Ethernet Controller */    MOT_FEC_ETH_DISABLE; 				    pDrvCtrl->loaded = FALSE;        /* free lists */    for (ix = 0; ix < pDrvCtrl->tbdNum; ix++)        {        cfree ((char *) pDrvCtrl->pTbdList [ix]);        }    END_OBJECT_UNLOAD (&pDrvCtrl->endObj);    /* free allocated memory if necessary */    if ((pDrvCtrl->pMBlkArea) != NULL)        free (pDrvCtrl->pMBlkArea);    /* free the semaphores if necessary */    MOT_FEC_MII_SEM_DELETE;    MOT_FEC_GRA_SEM_DELETE;    free (pDrvCtrl->phyInfo);    MOT_FEC_LOG (MOT_FEC_DBG_LOAD, ("motFecUnload... Done\n"),                    1, 2, 3, 4, 5, 6);    return (OK);    }/********************************************************************************* motFecInitParse - parse parameter values from initString** This routine parses parameter values from initString and stores them in* the related fiels of the driver control structure.** RETURNS: OK or ERROR*/LOCAL STATUS motFecInitParse    (    DRV_CTRL *    pDrvCtrl,              /* pointer to DRV_CTRL structure */    char *    initString        /* parameter string */    )    {    char *  tok;        /* an initString token */    char *  holder = NULL;    /* points to initString fragment beyond tok */    tok = strtok_r (initString, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->unit = atoi (tok);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->MBARAddr = (UINT32) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->ilevel = (int) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->pBufBase = (char *) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->bufSize = strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->fifoTxBase = (UINT32) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->fifoRxBase = (UINT32) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->tbdNum = (UINT16) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->rbdNum = (UINT16) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->phyInfo->phyAddr = (UINT8) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->phyInfo->isoPhyAddr = (UINT8) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->phyInfo->phyDefMode = (UINT8) strtoul (tok, NULL, 16);    tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)        return ERROR;    pDrvCtrl->userFlags = strtoul (tok, NULL, 16);   /* tok = strtok_r (NULL, ":", &holder);    if (tok == NULL)    return ERROR;    pDrvCtrl->RevD = strtoul (tok, NULL, 10);*/

⌨️ 快捷键说明

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