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

📄 sysibmemacend.c

📁 WINDRIVER SBC405 BSP
💻 C
字号:
/* sysIbmEmacEnd.c - system configuration module for ibmEmac driver */ /* Copyright 1984-2002 Wind River Systems, Inc. *//*modification history--------------------01d,29jan02,g_h  Add #ifdef INCLUDE_VWARE_LAUNCH before calling                 sysCheckIfVware()01c,18jan02,g_h  Change NvRAM logic to work with visionWARE01b,17sep01,g_h  update to reflect the changes done in T2CP401a,22apr01,g_h  created*/ /*DESCRIPTIONThis is the WRS-supplied configuration module for the VxWorksmotFccEnd END driver.It performs the dynamic parameterization of the motFccEnd driver.This technique of 'just-in-time' parameterization allows driverparameter values to be declared as any other defined constants ratherthan as static strings.*/#ifdef INCLUDE_EMAC_NETWORK#include "vxWorks.h"#include "config.h" #include "vmLib.h"#include "stdio.h"#include "sysLib.h"#include "logLib.h"#include "stdlib.h"#include "string.h"#include "end.h"#include "intLib.h"#include "ibmEmacEnd.h"#include "ibmEmacEnd.c"/* globals */char       sysEmacLoadString[100];       /* load string for ibmEmacLoad  */MAL_DATA * pMalData;/* locals */char enetAddr[MAC_ADRS_LEN];/* Forward declarations */STATUS sysIbmEmacEndBldLoadStr (void);/**************************************************************************** sysIbmEmacEndBldLoadStr - builds the ibmEmacEndLoad parameter string** This routine build the EMAC loading string.** RETURNS: N/A**/STATUS sysIbmEmacEndBldLoadStr    (    void    )    {    UINT flags;    flags = 0;    /*     * The following flags can be used to make the ibmEmacEnd driver work in     * different modes.  If EMAC_INPUT_UNCACHED_BUF is specified then     * EMAC_INPUT_TX_COPY must also be, but not vice-versa.     */    flags |= EMAC_INPUT_TX_2_CHANNEL;    /* use 2 TX channels       */    /*     * Build the initialization string.  It looks like this:     *     * <baseAdrs>:<malTxChn0>:<malTxChn1>:<malRxCh0>:<intVec>:<intLvl>:     * <memAdrs>:<memSize>:<flags>:<phyAdrs>:<cacheLineSize>:<pMalData>:     * <opbSpeedMhz>     *     * The unit number will be tacked onto the beginning by muxEndLoad     */    sprintf(sysEmacLoadString, "0x%X:%d:%d:%d:%d:%d:0x%X:0x%X:0x%X:%d:%d:0x%X:%d",                                EMAC0_BASE,                                EMAC0_TX_CHN_0_CPUCORE,                                EMAC0_TX_CHN_1_CPUCORE,                                EMAC0_RX_CHN_0_CPUCORE,                                INT_VEC_ENET_0,                                INT_LVL_ENET_0,                                NONE,                                0,                                flags,                                EMAC_PHY_ADRS,                                _CACHE_ALIGN_SIZE,                                (UINT)pMalData,                                systemInfo.freqPLB/systemInfo.pllOpbDiv/1000000);    return(OK);    }/**************************************************************************** sysIbmEmacInit - prepare LAN adapter for IBM EMAC initialization** This routine is expected to perform any adapter-specific or target-specific* initialization that must be done prior to initializing the IBM EMAC.** sysNet.c calls this routine from sysNetHwInit2() routine.*** RETURNS: N/A*/void sysIbmEmacInit    (    void    )    {    MAL_INIT  malInitData;    /*     * If the native EMAC Ethernet controller is being used, the Memory Access     * Layer must be initialized.     */    malInitData.dcrBaseReg = MAL0_DCR_BASE;    malInitData.validChannels[MAL_TX_TYPE] = MAL_CHN_TX_CPUCORE;    malInitData.validChannels[MAL_RX_TYPE] = MAL_CHN_RX_CPUCORE;    malInitData.intLvlTxeob = INT_VEC_MAL_TXEOB;    malInitData.intVecTxeob = INT_LVL_MAL_TXEOB;    malInitData.intLvlRxeob = INT_VEC_MAL_RXEOB;    malInitData.intVecRxeob = INT_LVL_MAL_RXEOB;    malInitData.intLvlTxde =  INT_VEC_MAL_TXDE;    malInitData.intVecTxde =  INT_LVL_MAL_TXDE;    malInitData.intLvlRxde =  INT_VEC_MAL_RXDE;    malInitData.intVecRxde =  INT_LVL_MAL_RXDE;    malInitData.intLvlSerr =  INT_VEC_MAL_SERR;    malInitData.intVecSerr =  INT_LVL_MAL_SERR;    /* Initialize MAL and get pointer to MAL driver control structure */    pMalData = malInit(&malInitData);    /*     * Build the load string for the IBM EMAC Ethernet core.     */    sysIbmEmacEndBldLoadStr();    return;    }/**************************************************************************** sysLanIbmEmacEnable - enable the LAN interrupt** This routine enables the interrupt in the UIC corresponding to the PCI * slot where the Ethernet card was found** RETURNS: N/A**/void sysLanIbmEmacIntEnable    (    UINT intlvl    )    {    intEnable (intlvl);    }/**************************************************************************** sysLanIbmEmacIntDisable - disable the LAN interrupt** This routine disables the interrupt in the UIC corresponding to the PCI * slot where the Ethernet card was found** RETURNS: N/A**/void sysLanIbmEmacIntDisable    (    UINT intlvl    )    {    intDisable (intlvl);    }/**************************************************************************** sysLanIbmEmacEnetAddrGet - get the IBM EMAC Ethernet controller's MAC *                            address** This routine returns the Ethernet controller's MAC address to the END * driver.** RETURNS: OK, or ERROR**/STATUS sysLanIbmEmacEnetAddrGet    (    EMAC_DRV_CTRL * pDrvCtrl,    UINT8         * enetAdrs    )    {    UINT    enetFixed = ENET_DEFAULT;    UINT8 * pEnetFixed = (UINT8 *) &enetFixed;    if (pDrvCtrl->unit != 0)        return (ERROR);    /*      * If we don't come from visionWARE, set the fixed      * manufacturer's address bytes, otherwise use      * visionWARE MAC address.     */    if (!sysCheckIfVware ())        {        bcopy (pEnetFixed, enetAdrs, (MAC_ADRS_LEN / 2));        }    else        {        bcopy (enetAddr, enetAdrs, (MAC_ADRS_LEN / 2));        }            /*      * Set the user address bytes, if we are using NvRAM      * this bytes will be over writen.     */    bcopy ((enetAddr + 3), (enetAdrs + 3), (MAC_ADRS_LEN / 2));#if (NV_RAM_SIZE != NONE)    /*      * If we come from visionWARE we don't need to get the     * MAC address from the NvRAM, otherwise we need.     */    #ifdef INCLUDE_VWARE_LAUNCH    if (!sysCheckIfVware ())    #endif /* INCLUDE_VWARE_LAUNCH */    	{        /*          * We didn't come from visionWARE, so get MAC address         * from NvRAM, so read and append the variable address          * bytes from NVRAM          */        sysNvRamGet (enetAdrs+3, (MAC_ADRS_LEN / 2), (NV_ENET_OFFSET + (MAC_ADRS_LEN / 2)));        }#endif /* (NV_RAM_SIZE != NONE) */    return (OK);    }/**************************************************************************** sysLanIbmEmacBootromEnetAddrGet - get the IBM EMAC Ethernet controller's *                                   MAC address** This routine returns the Ethernet controller's MAC address to the END * driver.** RETURNS: OK, or ERROR**/STATUS sysLanIbmEmacBootromEnetAddrGet    (    int       unit,    UINT8 *   enetAdrs    )    {    UINT      enetFixed = ENET_DEFAULT;    UINT8 *   pEnetFixed = (UINT8 *) &enetFixed;    /*      * If we don't come from visionWARE, set the fixed      * manufacturer's address bytes, otherwise use      * visionWARE MAC address.     */    if (!sysCheckIfVware ())        {        bcopy (pEnetFixed, enetAdrs, (MAC_ADRS_LEN / 2));        }    else        {        bcopy (enetAddr, enetAdrs, (MAC_ADRS_LEN / 2));        }#if (NV_RAM_SIZE != NONE)    /*      * If we come from visionWARE we don't need to get the     * MAC address from the NvRAM, otherwise we need.     */    #ifdef INCLUDE_VWARE_LAUNCH    if (!sysCheckIfVware ())    #endif /* INCLUDE_VWARE_LAUNCH */    	{        /*          * We didn't come from visionWARE, so get MAC address         * from NvRAM, so read and append the variable address          * bytes from NVRAM          */        sysNvRamGet (enetAdrs+3, (MAC_ADRS_LEN / 2), (NV_ENET_OFFSET + (MAC_ADRS_LEN / 2)));        }#endif /* (NV_RAM_SIZE != NONE) */    return (OK);    }/**************************************************************************** sysLanIbmEmacEnetAddrSet - set the Ethernet address for this board** This routine sets the variable portion of the Ethernet address, the first* three bytes contain a fixed manufacturer's code, while the last 3 bytes are* set locally, to generate a unique Ethernet address on the local network.** RETURN: OK, always.** NOMANUAL*/STATUS sysLanIbmEmacEnetAddrSet    (    char byte5,                 /* Ethernet address high order byte */    char byte4,    char byte3,    char byte2,    char byte1,    char byte0                  /* Ethernet address low order byte */    )    {    enetAddr[0] = byte5;    enetAddr[1] = byte4;    enetAddr[2] = byte3;    enetAddr[3] = byte2;    enetAddr[4] = byte1;    enetAddr[5] = byte0;#if (NV_RAM_SIZE != NONE)    /*      * If we come from visionWARE we don't need to save the     * MAC address in the NvRAM, otherwise we need.     */    if (!sysCheckIfVware ())        {        /* We didn't come from visionWARE, so save MAC address in NvRAM. */        sysNvRamSet ((char *)&enetAddr[0], MAC_ADRS_LEN, NV_ENET_OFFSET);        }#endif /* (NV_RAM_SIZE != NONE) */    return (OK);    }/**************************************************************************** sysEnetAddrGet - get the IBM EMAC Ethernet controller's MAC address** This routine returns the Ethernet controller's MAC address to the END * driver.** RETURNS: OK, or ERROR**/STATUS sysEnetAddrGet    (    int  unit ,    UINT8 *  addr     /* LOcation address is returned in                 */    )    {    STATUS retVal;    retVal = sysLanIbmEmacBootromEnetAddrGet(unit, addr);    return (retVal) ;    }/**************************************************************************** sysEnetAddrSet - set the Ethernet address for this board** This routine sets the variable portion of the Ethernet address.** RETURN: None** NOMANUAL*/void  sysEnetAddrSet       (      unsigned char byte5,      unsigned char byte4,      unsigned char byte3,      unsigned char byte2,      unsigned char byte1,      unsigned char byte0      )      {      sysLanIbmEmacEnetAddrSet(byte5, byte4, byte3, byte2, byte1, byte0);      }#endif /* INCLUDE_EMAC_NETWORK */

⌨️ 快捷键说明

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