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

📄 m8260fccend.c

📁 Embedded Planet公司的ep8260单板计算机的BSP包(VxWorks)
💻 C
📖 第 1 页 / 共 5 页
字号:
    UINT32 temp1 = 0;							\
    UINT32 temp2 = 0;							\
									\
    temp1 = (UINT32) MOT_FCC_VIRT_TO_PHYS ((bdAddr) + (bdOff));		\
									\
    MOT_FCC_LONG_RD ((UINT32 *) (temp1), (temp2));			\
									\
    bdVal = (char *) MOT_FCC_PHYS_TO_VIRT (temp2);			\
    }									

#define MOT_FCC_NEXT_TBD(pDrvCtrl, pTbd)				\
    (pTbd) = (MOT_FCC_TBD_ID) ((pDrvCtrl)->tbdBase +   			\
			       ((pDrvCtrl)->tbdIndex * MOT_FCC_TBD_SZ))

#define MOT_FCC_USED_TBD(pDrvCtrl, pTbd)				\
    (pTbd) = (MOT_FCC_TBD_ID) ((pDrvCtrl)->tbdBase + 	   		\
			       ((pDrvCtrl)->usedTbdIndex * MOT_FCC_TBD_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_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)
 
/* 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 void	motFccInt (DRV_CTRL * pDrvCtrl);
LOCAL void	motFccHandleRXFrames(DRV_CTRL *pDrvCtrl);
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 STATUS	motFccAddrSet (DRV_CTRL * pDrvCtrl, UCHAR * pAddr,
			       UINT32 offset);
LOCAL void	motFccPhyLSCInt(DRV_CTRL *pDrvCtrl);

/* 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);

/* globals */

FUNCPTR		_func_motFccPhyInit = (FUNCPTR) miiPhyInit;
FUNCPTR		_func_motFccPhyLSCInt = (FUNCPTR) motFccPhyLSCInt;
FUNCPTR		_func_motFccHbFail = (FUNCPTR) NULL;
FUNCPTR		_func_motFccPhyDuplex = (FUNCPTR) NULL;

DRV_CTRL	*global_pDrvCtrl;

#ifdef MOT_FCC_DBG
void motFccIramShow (void);
void motFccPramShow (void);
void motFccRbdShow (int);
void motFccTbdShow (int);
void motFccErrorShow (void);
void motFccDrvShow (void);
void motFccMiiShow (void);
void motFccMibShow (void);
UINT16 motFccMiiRegRead(UINT8 regAddr);
#endif /* MOT_FCC_DBG */

/* 
 * Define the device function table.  This is static across all driver
 * instances.
 */

LOCAL NET_FUNCS netFccFuncs = 
    {
    (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)
{
DRV_CTRL	*pDrvCtrl = NULL;		/* pointer to DRV_CTRL structure */
UCHAR   	enetAddr[MOT_FCC_ADDR_LEN];	/* ethernet address */
BOOT_PARAMS	bootParamStruct;

    
    
    	
       
    MOT_FCC_LOG (MOT_FCC_DBG_LOAD, ("Loading end...\n"), 1, 2, 3, 4, 5, 6);

    if (initString == NULL)
	return NULL;

    if (initString[0] == 0){
	bcopy ((char *)MOT_FCC_DEV_NAME, (void *)initString,MOT_FCC_DEV_NAME_LEN);
	return NULL;
    }

    /* allocate the device structure */

    pDrvCtrl = (DRV_CTRL *) calloc (sizeof (DRV_CTRL), 1);
    if (pDrvCtrl == NULL)
	return NULL;

    global_pDrvCtrl = pDrvCtrl;

    /* get memory for the phyInfo structure */
    if ((pDrvCtrl->phyInfo = calloc (sizeof (PHY_INFO), 1)) == NULL)
	return NULL;

    /* get memory for the drivers stats structure */
    if ((pDrvCtrl->Stats = calloc (sizeof (FCC_DRIVER_STATS), 1)) == NULL)
	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)
	goto errorExit;

    /* 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;

    /* Set zeroBufFlag */
    if(pDrvCtrl->userFlags & MOT_FCC_USR_BUF_LBUS
    || pDrvCtrl->userFlags & MOT_FCC_USR_NO_ZCOPY){
	pDrvCtrl->zeroBufFlag = FALSE;
    }else{
	pDrvCtrl->zeroBufFlag = TRUE;
    }

    /* store the internal ram base address */

    pDrvCtrl->fccIramAddr = (UINT32) M8260_FGMR1 (pDrvCtrl->immrVal) +
			    ((pDrvCtrl->fccNum - 1) * M8260_FCC_IRAM_GAP);

    pDrvCtrl->fccReg = (FCC_REG_T *)pDrvCtrl->fccIramAddr;

    /* 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);

    pDrvCtrl->fccPar = (FCC_PARAM_T *)pDrvCtrl->fccPramAddr;
    pDrvCtrl->fccEthPar = &pDrvCtrl->fccPar->prot.e;

    /* 
     * create the synchronization semaphore for graceful transmit 
     * command interrupts. 
     */

    MOT_FCC_GRA_SEM_CREATE;
    
	/*
	 * Because we create EMPTY semaphore we need to give it here
	 * other wise the only time that it's given back is in the
	 * motFccInt() and if we have two NI in the bootrom like SCC
	 * and FCC the motFccStop() will be spin forever when it will
	 * try to do MOT_FCC_GRA_SEM_TAKE.                            
	 */

	MOT_FCC_GRA_SEM_GIVE;

    /* endObj initializations */

    if (END_OBJ_INIT (&pDrvCtrl->endObj, (DEV_OBJ*) pDrvCtrl,
		      MOT_FCC_DEV_NAME, pDrvCtrl->unit, &netFccFuncs,
		      "Motorola FCC Ethernet Enhanced Network Driver") 
	== ERROR)

⌨️ 快捷键说明

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