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

📄 m8260sccend.c

📁 操作系统vxworks平台下end设备的驱动程序,支持多种芯片,支持多种cpu
💻 C
📖 第 1 页 / 共 5 页
字号:
LOCAL STATUS    motSccEndSend (END_CTRL *pDrvCtrl, M_BLK_ID pBuf);LOCAL STATUS    motSccEndMCastAddrAdd (END_CTRL *pDrvCtrl, char* pAddress);LOCAL STATUS    motSccEndMCastAddrDel (END_CTRL *pDrvCtrl, char* pAddress);LOCAL STATUS    motSccEndMCastAddrGet (END_CTRL *pDrvCtrl, MULTI_TABLE *pTable);LOCAL STATUS    motSccEndPollSend (END_CTRL *pDrvCtrl, M_BLK_ID pBuf);LOCAL STATUS    motSccEndPollReceive (END_CTRL *pDrvCtrl, M_BLK_ID pBuf);LOCAL STATUS    motSccEndPollStart (END_CTRL *pDrvCtrl);LOCAL STATUS    motSccEndPollStop (END_CTRL *pDrvCtrl);LOCAL STATUS    motSccEndUnload (END_CTRL *pDrvCtrl);LOCAL STATUS    motSccEndStop (END_CTRL *pDrvCtrl);#else  /* __STDC__ */LOCAL STATUS    motSccInitParse ();LOCAL STATUS    motSccInitMem ();LOCAL void      motSccRecv ();LOCAL void      motSccIntr ();LOCAL void      motSccReset ();LOCAL void      motSccMCastFilterSet ();LOCAL void      motSccMCastConfig ();LOCAL void      motSccTxRestart ();LOCAL void      motSccHandleInt ();LOCAL void      motSccCleanTxBdQueue ();LOCAL STATUS    motSccRestart ();LOCAL void      motSccCleanRxBd ();/* END Specific interfaces. */END_OBJ *       m8260SccEndLoad ();LOCAL STATUS    motSccEndStart ();LOCAL int       motSccEndIoctl ();LOCAL STATUS    motSccEndSend ();LOCAL STATUS    motSccEndMCastAddrAdd ();LOCAL STATUS    motSccEndMCastAddrDel ();LOCAL STATUS    motSccEndMCastAddrGet ();LOCAL STATUS    motSccEndPollSend ();LOCAL STATUS    motSccEndPollReceive ();LOCAL STATUS    motSccEndPollStart ();LOCAL STATUS    motSccEndPollStop ();LOCAL STATUS    motSccEndUnload ();LOCAL STATUS    motSccEndStop ();#endif  /* __STDC__ *//* * Define the device function table.  This is static across all driver * instances. */LOCAL NET_FUNCS netSccFuncs =    {    (FUNCPTR)motSccEndStart,        /* start func. */    (FUNCPTR)motSccEndStop,         /* stop func. */    (FUNCPTR)motSccEndUnload,       /* unload func. */    (FUNCPTR)motSccEndIoctl,        /* ioctl func. */    (FUNCPTR)motSccEndSend,         /* send func. */    (FUNCPTR)motSccEndMCastAddrAdd, /* multicast add func. */    (FUNCPTR)motSccEndMCastAddrDel, /* multicast delete func. */    (FUNCPTR)motSccEndMCastAddrGet, /* multicast get fun. */    (FUNCPTR)motSccEndPollSend,     /* polling send func. */    (FUNCPTR)motSccEndPollReceive,  /* polling receive func.  */    endEtherAddressForm,            /* Put address info into a packet.  */    endEtherPacketDataGet,          /* Get a pointer to packet data. */    endEtherPacketAddrGet           /* Get packet addresses. */    };static UINT32  userFlags;/********************************************************************************* m8260SccEndLoad - initialize the driver and device** This routine initializes the driver and the device to the operational state.* All of the device specific parameters are passed in the <initString>, which* is of the following format:** <unit>:<motCpmAddr>:<ivec>:<sccNum>:<txBdNum>:<rxBdNum>:<txBdBase>:<rxBdBase>:<bufBase> * * The parameters of this string are individually described in the 'motCpmEnd' * man page.** The SCC shares a region of memory with the driver.  The caller of * this routine can specify the address of a non-cacheable memory region with* <bufBase>.  Or, if this parameter is "NONE", the driver obtains this* memory region by making calls to cacheDmaMalloc().  Non-cacheable memory * space is important whenever the host processor uses cache memory.* This is also the case when the MC68EN360 is operating in companion* mode and is attached to a processor with cache memory.** After non-cacheable memory is obtained, this routine divides up the* memory between the various buffer descriptors (BDs).  The number* of BDs can be specified by <txBdNum> and <rxBdNum>, or if "NULL", a* default value of 32 BDs will be used.  An additional number of buffers are* reserved as receive loaner buffers.  The number of loaner buffers is* a default number of 16.** The user must specify the location of the transmit and receive BDs in* the processor's dual ported RAM.  <txBdBase> and <rxBdBase> give the* offsets from <motCpmAddr> for the base of the BD rings.  Each BD uses * 8 bytes. Care must be taken so that the specified locations for Ethernet * BDs do not conflict with other dual ported RAM structures.** Multiple individual device units are supported by this driver.  Device* units can reside on different chips, or could be on different SCCs* within a single processor. The <sccNum> parameter is used to explicitly* state which SCC is being used. SCC1 is most commonly used, thus this* parameter most often equals "1".** Before this routine returns, it connects up the interrupt vector <ivec>.** RETURNS: An END object pointer or NULL on error.** SEE ALSO:* .I "Motorola MPC8260 User's Manual"*/END_OBJ * m8260SccEndLoad    (    char * initString    )    {    END_PARM    endParm;    /* parameters from initString */    END_CTRL    *pDrvCtrl;  /* pointer to END_CTRL structure */    int         scc;    UINT32      motCpmAddr;    u_char      enetAddr[ENET_ADDR_SIZE];    MOTCPMLOGMSG(("m8260SccEndLoad \n", 0, 0, 0, 0, 0, 0));    if (initString == NULL)        return(NULL);    if (initString[0] == 0)        {        bcopy((char *)MOT_DEV_NAME, initString, MOT_DEV_NAME_LEN);        return(0);        }    /* Parse InitString */    if (motSccInitParse (&endParm, initString) == ERROR)        return(NULL);    userFlags = endParm.userFlags;    /* Sanity check -- unit number */    if (endParm.unit < 0 || endParm.unit >= MAX_SCC_CHANNELS)        return(NULL);    /* Sanity check -- scc number */    if ((endParm.sccNum < 1) || (endParm.sccNum > 4))        return(NULL);    if (endParm.txBdBase == endParm.rxBdBase)        return(NULL);    pDrvCtrl = & drvCtrl [endParm.unit];    /* Check if we are already attached */    if (pDrvCtrl->endObject.attached == TRUE)        return(&pDrvCtrl->endObject);    /* use default number of buffer descriptors if user did not specify */    if (endParm.txBdNum == 0)        endParm.txBdNum = TX_BD_DEFAULT;    if (endParm.rxBdNum == 0)        endParm.rxBdNum = RX_BD_DEFAULT;    /* must be at least two transmit and receive buffer descriptors */    endParm.txBdNum = max (TX_BD_MIN, endParm.txBdNum);    endParm.rxBdNum = max (RX_BD_MIN, endParm.rxBdNum);    /* Initialize parameters */    pDrvCtrl->regBase         = endParm.motCpmAddr;    pDrvCtrl->bufBase         = endParm.bufBase;    pDrvCtrl->unit            = endParm.unit;    pDrvCtrl->ivec            = endParm.ivec;    pDrvCtrl->ether.sccNum    = endParm.sccNum;    pDrvCtrl->ether.txBdNum   = endParm.txBdNum;    pDrvCtrl->ether.rxBdNum   = endParm.rxBdNum;    pDrvCtrl->ether.txBdBase  = (SCC_BUF *) (endParm.motCpmAddr + (endParm.txBdBase & 0xffff));    pDrvCtrl->ether.rxBdBase  = (SCC_BUF *) (endParm.motCpmAddr + (endParm.rxBdBase & 0xffff));    pDrvCtrl->ether.txBufSize = FRAME_MAX_AL;    pDrvCtrl->ether.rxBufSize = FRAME_MAX_AL;    pDrvCtrl->txBdIndexC      = 0;    /* derive SCC dependent variables */    scc = pDrvCtrl->ether.sccNum - 1;    motCpmAddr = pDrvCtrl->regBase;    pDrvCtrl->ether.pScc    = (SCC *) ((UINT32) CPM_DPR_SCC1(motCpmAddr) + (scc * 0x100));    pDrvCtrl->ether.pSccReg = (SCC_REG *) ((UINT32) GSMR_L1(motCpmAddr) + (scc * 0x20));    pDrvCtrl->ether.intMask = 0x00100000 << (3 - scc);    /* endObject initializations */    if (END_OBJ_INIT (&pDrvCtrl->endObject, (void *)pDrvCtrl, MOT_DEV_NAME,                      pDrvCtrl->unit, &netSccFuncs,                      END_OBJ_STRING) == ERROR)        return(NULL);    /* memory initialization */    if (motSccInitMem (pDrvCtrl) == ERROR)        return(NULL);    /* reset the chip */    motSccReset (pDrvCtrl);    /* Get our enet addr */    SYS_ENET_ADDR_GET (enetAddr);    MOTCPMLOGMSG(("motSccEndLoad ADDR: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x \n",                   (int) enetAddr[0], (int) enetAddr[1], (int) enetAddr[2],                   (int) enetAddr[3], (int) enetAddr[4], (int) enetAddr[5]));    /* Initialize MIB2 entries */    if (END_MIB_INIT (&pDrvCtrl->endObject, M2_ifType_ethernet_csmacd,                      enetAddr, 6, ETHERMTU,                      SPEED) == ERROR)        return(NULL);    /* Mark the device ready */    /* IFF_SCAT is not defined by default */    END_OBJ_READY (&pDrvCtrl->endObject, IFF_NOTRAILERS | IFF_BROADCAST | IFF_MULTICAST);    /* Successful return */    MOTCPMLOGMSG(("m8260SccEndLoad OK\n", 0, 0, 0, 0, 0, 0));    return(&pDrvCtrl->endObject);    }/********************************************************************************* motSccInitParse - parse parameter values from initString** Parse the input string.  Fill in values in the driver control structure.** The initialization string format is:* .CS*    "unit:motCpmAddr:ivec:sccNum:txBdNum:rxBdNum:txBdBase:rxBdBase:bufBase"* .CE** .IP <unit>* Device unit number, a small integer.* .IP <motCpmAddr>* base address of processor internal mem * .IP <ivec>* Interrupt vector number* .IP <sccNum>* SCC number used.* .IP <txBdNum>* number of transmit buffer descriptors; NULL = default * .IP <rxBdNum>* number of receive buffer descriptors; NULL = default* .IP <txBdBase>* transmit buffer descriptor offset* .IP <rxBdBase>* receive buffer descriptor offset* .IP <bufBase>* address of memory pool; NONE = malloc it* .LP* .IP <userFlags>* user flags.* .LP** RETURNS: OK or ERROR for invalid arguments.*/LOCAL STATUS motSccInitParse    (    END_PARM *  pEndParm,  /* structure to fill in with parameters */    char     *  initString /* init string */    )    {    char *  tok;            /* an initString token */    char *  holder=NULL;    /* points to initString fragment beyond tok */    char *  initStringBuff;    initStringBuff = malloc(strlen(initString) + 1);    if (initStringBuff == NULL)        return(ERROR);    strcpy (initStringBuff, initString);    tok = strtok_r(initStringBuff, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->unit = atoi(tok);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->motCpmAddr = strtoul (tok, NULL, 16);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->ivec = strtoul (tok, NULL, 16);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->sccNum = atoi (tok);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->txBdNum = strtoul (tok, NULL, 16);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->rxBdNum = strtoul (tok, NULL, 16);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->txBdBase = strtoul (tok, NULL, 16);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->rxBdBase = strtoul (tok, NULL, 16);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->bufBase = strtoul (tok, NULL, 16);    tok = strtok_r(NULL, ":", &holder);    if (tok == NULL)        {        free(initStringBuff);        return ERROR;        }    pEndParm->userFlags = strtoul (tok, NULL, 16);    MOTCPMLOGMSG(("unit = %d, motCpmAddr = 0x%x, ivec = 0x%x, sccNum = 0x%x\n",                  pEndParm->unit, pEndParm->motCpmAddr, pEndParm->ivec,                   pEndParm->sccNum, 0, 0));    MOTCPMLOGMSG(("txBdNum = 0x%x, rxBdNum = 0x%x, txBdBase = 0x%x\n",                  pEndParm->txBdNum, pEndParm->rxBdNum, pEndParm->txBdBase,                   0, 0, 0));    MOTCPMLOGMSG(("rxBdBase  = 0x%x, bufBase = %d, userFlags = 0x%x\n", pEndParm->rxBdBase,                   pEndParm->bufBase, pEndParm->userFlags, 0, 0, 0));    free(initStringBuff);    return OK;    }/********************************************************************************* motSccInitMem - initialize memory ** Using data in the control structure, setup and initialize the memory* areas needed.  If the memory address is not already specified, then allocate* cache safe memory.

⌨️ 快捷键说明

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