?? motfccend.c
字號:
(pRbd) = (MOT_FCC_RBD_ID) ((pDrvCtrl)->rbdBase + \ (((pDrvCtrl)->rbdIndex) * MOT_FCC_RBD_SZ))#define MOT_FCC_RX_ACTIVATE \ { \ UINT32 tmp = 0; \ \ MOT_FCC_REG_LONG_RD (pDrvCtrl->fccIramAddr, tmp); \ MOT_FCC_REG_LONG_WR (pDrvCtrl->fccIramAddr, \ (tmp | M8260_GFMR_ENR)); \ }#define MOT_FCC_TX_ACTIVATE \ { \ UINT32 tmp = 0; \ \ MOT_FCC_REG_LONG_RD (pDrvCtrl->fccIramAddr, tmp); \ MOT_FCC_REG_LONG_WR (pDrvCtrl->fccIramAddr, \ (tmp | M8260_GFMR_ENT)); \ }#define MOT_FCC_INT_DISABLE \ { \ MOT_FCC_REG_WORD_WR ((UINT32) M8260_FGMR1 (pDrvCtrl->immrVal) + \ ((pDrvCtrl->fccNum - 1) * M8260_FCC_IRAM_GAP), \ MOT_FCC_CLEAR_VAL); \ }#define MOT_FCC_INT_ENABLE \ { \ MOT_FCC_REG_WORD_WR ((UINT32) M8260_FGMR1 (pDrvCtrl->immrVal) + \ ((pDrvCtrl->fccNum - 1) * M8260_FCC_IRAM_GAP), \ (pDrvCtrl->intMask)); \ }/* more shortcuts */#define MOT_FCC_GRA_SEM_CREATE \ if ((pDrvCtrl->graSem = semBCreate (SEM_Q_FIFO, SEM_EMPTY)) \ == NULL) \ goto errorExit#define MOT_FCC_GRA_SEM_DELETE \ if ((pDrvCtrl->graSem) != NULL) \ semDelete (pDrvCtrl->graSem)#define MOT_FCC_GRA_SEM_GIVE \ (semGive (pDrvCtrl->graSem))#define MOT_FCC_GRA_SEM_TAKE \ (semTake (pDrvCtrl->graSem, WAIT_FOREVER))#define NET_BUF_ALLOC() \ netClusterGet (pDrvCtrl->endObj.pNetPool, pDrvCtrl->pClPoolId) \#define NET_TO_MOT_FCC_BUF(netBuf) \ (((UINT32) (netBuf) + MOT_FCC_BUF_ALIGN - 1) \ & ~(MOT_FCC_BUF_ALIGN - 1))#define NET_BUF_FREE(pBuffer) \ netClFree (pDrvCtrl->endObj.pNetPool, (pBuffer)) #define NET_MBLK_ALLOC() \ netMblkGet (pDrvCtrl->endObj.pNetPool, M_DONTWAIT, MT_DATA) #define NET_MBLK_FREE(pMblock) \ netMblkFree (pDrvCtrl->endObj.pNetPool, (M_BLK_ID) (pMblock)) #define NET_CL_BLK_ALLOC() \ netClBlkGet (pDrvCtrl->endObj.pNetPool, M_DONTWAIT) #define NET_CL_BLK_FREE(pClBlock) \ netClBlkFree (pDrvCtrl->endObj.pNetPool, (CL_BLK_ID) (pClBlock)) #define NET_MBLK_BUF_FREE(pMblock) \ netMblkClFree ((M_BLK_ID) (pMblock)) #define NET_MBLK_CL_JOIN(pMblock, pClBlock, ret) \ ret = netMblkClJoin ((pMblock), (pClBlock)) #define NET_CL_BLK_JOIN(pClBlock, pBuffer, length, ret) \ ret = netClBlkJoin ((pClBlock), (pBuffer), (length), NULL, 0, 0, 0) /* globals *//* locals *//* Function declarations not in any header files *//* forward function declarations */LOCAL STATUS motFccInitParse (DRV_CTRL * pDrvCtrl, char *initString);LOCAL STATUS motFccInitMem (DRV_CTRL *pDrvCtrl);LOCAL STATUS motFccSend (DRV_CTRL *pDrvCtrl, M_BLK *pMblk);LOCAL STATUS motFccPhyPreInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccBdFree (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccRbdInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccTbdInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccFpsmrValSet (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccHashTblPopulate (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccHashTblAdd (DRV_CTRL * pDrvCtrl, UCHAR * pAddr);LOCAL STATUS motFccInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccPramInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccIramInit (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccCpcrCommand (DRV_CTRL * pDrvCtrl, UINT8 command);LOCAL STATUS motFccMblkWalk (M_BLK * pMblk, UINT8 * pFragNum, UINT16 * pPktType);#ifdef MOT_FCC_ZERO_COPYLOCAL STATUS motFccPktTransmit (DRV_CTRL * pDrvCtrl, M_BLK * pMblk, UINT8 fragNum, UINT16 pktType);#endif /* MOT_FCC_ZERO_COPY */LOCAL STATUS motFccPktCopyTransmit (DRV_CTRL * pDrvCtrl, M_BLK * pMblk, UINT8 fragNum, UINT16 pktType);LOCAL void motFccTbdClean (DRV_CTRL * pDrvCtrl);LOCAL UINT32 motFccTbdCheck (DRV_CTRL * pDrvCtrl, MOT_FCC_TBD_ID pUsedTbd);LOCAL MOT_FCC_TBD_LIST_ID motFccTbdListSet (DRV_CTRL * pDrvCtrl, UINT8 tbdNum);LOCAL MOT_FCC_TBD_ID motFccTbdGet (DRV_CTRL * pDrvCtrl);LOCAL void motFccInt (DRV_CTRL * pDrvCtrl);LOCAL void motFccRxTxHandle (DRV_CTRL * pDrvCtrl);LOCAL void motFccHandleRecvInt (DRV_CTRL * pDrvCtrl);LOCAL void motFccReceive (DRV_CTRL * pDrvCtrl, MOT_FCC_RBD_ID pRfd);LOCAL STATUS motFccMiiRead (DRV_CTRL * pDrvCtrl, UINT8 phyAddr, UINT8 regAddr, UINT16 *retVal);LOCAL STATUS motFccMiiWrite (DRV_CTRL * pDrvCtrl, UINT8 phyAddr, UINT8 regAddr, UINT16 writeData);LOCAL void motFccRbdClean (DRV_CTRL * pDrvCtrl, volatile MOT_FCC_RBD_ID pRBDNew);LOCAL STATUS motFccAddrSet (DRV_CTRL * pDrvCtrl, UCHAR * pAddr, UINT32 offset);/* END Specific interfaces. */END_OBJ * motFccEndLoad (char *initString); LOCAL STATUS motFccStart (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccUnload (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccStop (DRV_CTRL * pDrvCtrl);LOCAL int motFccIoctl (DRV_CTRL * pDrvCtrl, int cmd, caddr_t data);LOCAL STATUS motFccSend (DRV_CTRL * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS motFccMCastAddrAdd (DRV_CTRL * pDrvCtrl, UCHAR * pAddress);LOCAL STATUS motFccMCastAddrDel (DRV_CTRL * pDrvCtrl, UCHAR * pAddress);LOCAL STATUS motFccMCastAddrGet (DRV_CTRL * pDrvCtrl, MULTI_TABLE *pTable);LOCAL STATUS motFccPollSend (DRV_CTRL * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS motFccPollReceive (DRV_CTRL * pDrvCtrl, M_BLK_ID pMblk);LOCAL STATUS motFccPollStart (DRV_CTRL * pDrvCtrl);LOCAL STATUS motFccPollStop (DRV_CTRL * pDrvCtrl);extern UINT32 vxImmrGet (void);#ifdef BSP_INLUDE_NET_LOOPBACK/* dengzhe */STATUS Loop_motFccSend(int FccNum);void SetNetLoopMode(UINT8 mode);extern UINT8 NetLoopCheck(void);/* dengzhe */#define NET_LOOP_CHECK_OFF 1#define NET_LOOP_CHECK_ON 0#define NET_LOOP_CHECK_SUCCESS 0#define NET_LOOP_CHECK_FAILED 1DRV_CTRL * FCC_pDrvCtrl[3];UINT8 NetLoopCheckPacket[64]= \{ 0xff,0xff,0xff,0xff,0xff,0xff,0x08,0x00,0x3e,0x03,0x02,0xfa,0xff,0xff,0xff,0xff, 0x4E,0x65,0x74,0x50,0x6f,0x72,0x74,0x20,0x54,0x65,0x73,0x74,0x20,0x50,0x61,0x63, 0x6b,0x65,0x74,0xaa,0x55,0x55,0x55,0x55,0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55, 0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55,0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55};UINT8 NetLoopCheckMode = NET_LOOP_CHECK_OFF ;UINT8 DebugNetStatus = NET_LOOP_CHECK_FAILED;#endif /* BSP_INLUDE_NET_LOOPBACK *//* globals */#if 0 /*niubq*/FUNCPTR _func_motFccPhyInit = (FUNCPTR) miiPhyInit;#endifFUNCPTR _func_motFccHbFail = (FUNCPTR) NULL;#ifdef MOT_FCC_DBGvoid motFccIramShow (void);void motFccPramShow (void);void motFccRbdShow (int);void motFccTbdShow (int);void motFccErrorShow (void);void motFccDrvShow (void);void motFccMiiShow (void);void motFccMibShow (void);#endif /* MOT_FCC_DBG *//* * Define the device function table. This is static across all driver * instances. */LOCAL NET_FUNCS netFuncs = { (FUNCPTR) motFccStart, /* start func. */ (FUNCPTR) motFccStop, /* stop func. */ (FUNCPTR) motFccUnload, /* unload func. */ (FUNCPTR) motFccIoctl, /* ioctl func. */ (FUNCPTR) motFccSend, /* send func. */ (FUNCPTR) motFccMCastAddrAdd, /* multicast add func. */ (FUNCPTR) motFccMCastAddrDel, /* multicast delete func. */ (FUNCPTR) motFccMCastAddrGet, /* multicast get fun. */ (FUNCPTR) motFccPollSend, /* polling send func. */ (FUNCPTR) motFccPollReceive, /* 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 */ }; /********************************************************************************* motFccEndLoad - 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:** "<immrVal>:<ivec>:<bufBase>:<bufSize>:<fifoTxBase>:<fifoRxBase>* :<tbdNum>:<rbdNum>:<phyAddr>:<phyDefMode>:<pAnOrderTbl>:<userFlags>"** The FCC 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 "MPC8260 Power QUICC II User's Manual"*/END_OBJ* motFccEndLoad ( char *initString /* parameter string */ ) { DRV_CTRL * pDrvCtrl = NULL; /* pointer to DRV_CTRL structure */ UCHAR enetAddr[MOT_FCC_ADDR_LEN]; /* ethernet address */ MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("Loading end...\n"), 1, 2, 3, 4, 5, 6); if (initString == NULL) return (NULL); if (initString[0] == NULL) { bcopy ((char *)MOT_FCC_DEV_NAME, (void *)initString, MOT_FCC_DEV_NAME_LEN); return (0); } /* allocate the device structure */ pDrvCtrl = (DRV_CTRL *) calloc (sizeof (DRV_CTRL), 1); if (pDrvCtrl == NULL) return (NULL); /* get memory for the phyInfo structure */ if ((pDrvCtrl->phyInfo = calloc (sizeof (PHY_INFO), 1)) == NULL) { cfree ((char *) pDrvCtrl); /* zzh 2001.05.02 */ return (NULL); }#ifdef MOT_FCC_DBG pDrvCtrlDbg = pDrvCtrl;#endif /* MOT_FCC_DBG */ /* Parse InitString */ if (motFccInitParse (pDrvCtrl, initString) == ERROR) goto errorExit; /* sanity check the unit number */ if (pDrvCtrl->unit < 0 ) goto errorExit; /* memory initialization */ if (motFccInitMem (pDrvCtrl) == ERROR) /* get our ethernet hardware address */ SYS_FCC_ENET_ADDR_GET (enetAddr); MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("motFccEndLoad: 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; /* store the internal ram base address */ pDrvCtrl->fccIramAddr = (UINT32) M8260_FGMR1 (pDrvCtrl->immrVal) + ((pDrvCtrl->fccNum - 1) * M8260_FCC_IRAM_GAP); /* store the parameter ram base address */ pDrvCtrl->fccPramAddr = (UINT32) M8260_FCC1_BASE (pDrvCtrl->immrVal) + ((pDrvCtrl->fccNum - 1) * M8260_FCC_DPRAM_GAP); MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("motFccEndLoad: pram=0x%x iram=0x%x \n "), pDrvCtrl->fccPramAddr, pDrvCtrl->fccIramAddr, 0, 0, 0, 0); /* * create the synchronization semaphore for graceful transmit * command interrupts. */ MOT_FCC_GRA_SEM_CREATE; /* endObj initializations */ if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*) pDrvCtrl, MOT_FCC_DEV_NAME, pDrvCtrl->unit, &netFuncs, "Motorola FCC Ethernet Enhanced Network Driver") == ERROR) goto errorExit; pDrvCtrl->phyInfo->phySpeed = MOT_FCC_10MBS; if (END_MIB_INIT (&pDrvCtrl->endObj, M2_ifType_ethernet_csmacd, (u_char *) &enetAddr[0], MOT_FCC_ADDR_LEN, ETHERMTU, pDrvCtrl->phyInfo->phySpeed) == ERROR) goto errorExit; /* Mark the device ready */ END_OBJ_READY (&pDrvCtrl->endObj, IFF_NOTRAILERS | IFF_MULTICAST | IFF_BROADCAST); MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("motFccEndLoad... Done \n"), 1, 2, 3, 4, 5, 6); #ifdef BSP_INLUDE_NET_LOOPBACK FCC_pDrvCtrl[pDrvCtrl->fccNum-1] = pDrvCtrl; /* dengzhe */ #endif /* BSP_INLUDE_NET_LOOPBACK */ return (&pDrvCtrl->endObj);errorExit: motFccUnload (pDrvCtrl); return NULL; }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -