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

📄 xpmain.c

📁 摩托罗拉Motolola公司网络处理器C3的示范代码.实现了ATM的AAL2层交换功能.想了解网络处理器的可以
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  Copyright (c) 2001, 2002 C-Port Corporation *  All Rights Reserved * *  The information contained in this file is confidential and proprietary. *  Any reproduction, use or disclosure, in whole or in part, of this *  program, including any attempt to obtain a human-readable version of this *  program, without the express, prior written consent of C-Port *  Corporation is strictly prohibited. */#include <dcpKernelSvcs.h>#include <dcpTableSvcs.h>#include <dcpBufferSvcs.h>#include <dcpQueueSvcs.h>#include <dcpRegisterDefs.h>#include "atm.h"#include "atmStatus.h"#include "atmPrivate.h"#include "rcSdpAtmApiIf.h"#include "aal2XpIf.h"#include "atmCellDesc.h"#include "aal2Desc.h"#include "sonetMonXpIf.h"#include "sonetMon.h"#include "aal2.h"#include "xpMainInit.h"#include "xpMain.h"#include "rcSdpAal2RxApiIf.h"QsMessage ALIGNED64 cpInitDescStorage;int16u cpBitMask   = AAL2_CP_BIT_MASK;int16u portBitMask = AAL2_PORT_BIT_MASK;static Boolean       payloadEnqueue = FALSE;static BsBufHandle   lastBufferEnqueued = 0;extern TsTableId TABLE_ID_VCC;extern TsTableId KEY_TABLE_ID_ATM;extern TsTableId TABLE_ID_CID;extern     void atmTableCreate(); extern     void atmVccTableSetup();extern     void aal2TableCreate();extern     void aal2CidTableSetup(TsTableId x);int32u xpQmuIrqHandler(void *irqInfo);static inline DcpCregs*ksCpCregs(int32u rc){    ASSERT(rc < MAX_CPS_IN_DCP);    return (DcpCregs*)(DMEM_BASE + CREG_OFFSET + (rc << RC_CPU_ID));}/**************************************************************************** * *  Function:       DCPmain() * *  Description:    Main routine. * *                  Entered with a package handle and the size of memory *                  from the boot rom. If entered from the simulator without *                  being loaded by the boot rom, the arguments are 0 (and *                  the package loader will quietly ignore the call). * *  Arguments:      package - The Package * *  Returns:        FALSE - if terminated abnormally * ***************************************************************************/int DCPmain(KsPackage package){    int               i, poolid=0;    NewCpInitDesc*    cpInitDesc;    KsProcId          procId;    int32u            sdpMask = 0;    int32u            atmPortNum = 0;    /* Variables for CU_Timer functionality */    int32u*           pTimeout;    int32u            aal2TxNumQs;    QsQueueId         aal2TxBaseQ;    volatile int32u*  rxBitCtl;    /* Initialize all of the system services */    ksInitialize(AAL2_MAIN_THREAD_STACK_SIZE); /* DCP kernel services */    tsTableInitialize();                      /* DCP table services */    aal2TableCreate();    aal2CidTableSetup(TABLE_ID_CID);    atmTableCreate();     atmVccTableSetup();    /* ksPrintf("Atm Table id: Hash - %d, Key - %d, Cid Table id - %d", 		    TABLE_ID_VCC, KEY_TABLE_ID_ATM, TABLE_ID_CID); */        /*     * Initialize the RC's with table and queue information.     * Note that all the RC's expect there to be a message waiting for     * for them in their base queue from the XP giving them this     * initialization information.     */    cpInitDesc = (NewCpInitDesc*) qsMessageGetData(&cpInitDescStorage);    /*     * Configure the Timer.     * ---------------------------------------------------------     * Zero the timeout array.     */    pTimeout = (int32u *)timeout;    for (i = 0; i < (NUMBER_OF_TIMERS>>2); i++)        *pTimeout++ = 0;    /*     * Initialize the nqQId arrays and timerPool arrays.     */    for (i=0; i<NUMBER_OF_CPS; i++)    {        if (AAL2_TX_CP(i))        {            qsQueueGet(CPprocID(i), &aal2TxBaseQ, &aal2TxNumQs);            nqQId[i] = aal2TxBaseQ + 1;        }    }    /*     * Start the CP's     * --------------------------------------------------------     */    for (i = 0 ; i < NUMBER_OF_CPS; i++)    {        ksProcStart(CPprocID(i)) ;    }    /*     * Send table and queue information to the CPs     * --------------------------------------------------------     */    for(i = 0; i < NUMBER_OF_CPS; i++) {        QsQueueId cpBaseQueueId;        int32u    num;        KsProcId  atmTxPid;        switch(i) {            /* ATM CP's */            case 4:            case 5:                cpInitDesc->atmParams.poolId =  poolid++;                cpInitDesc->atmParams.tableId = TABLE_ID_VCC;                cpInitDesc->atmParams.atmPortNum =  atmPortNum++;                break;            /* QOS CP's */            case 6:            case 7:                atmTxPid = qmuParams[i - 2].pid;                qsQueueGet(atmTxPid, &cpBaseQueueId, &num);                cpInitDesc->qosParams.tableId = TABLE_ID_VCC;                cpInitDesc->qosParams.atmTxQueue = cpBaseQueueId;                break;            /* AAL2 RX CP's */            case 0:            case 1:            case 2:            case 3:            case 8:            case 9:                cpInitDesc->aal2Params.poolId =  poolid++;                cpInitDesc->aal2Params.tableId = TABLE_ID_CID;                break;            /* AAL2 TX CP's */            case 10:            case 11:            case 12:                cpInitDesc->aal2Params.poolId =  poolid++;                cpInitDesc->aal2Params.destId = ATM_QOS1_RTVBR_QUEUE ;                break;            case 13:            case 14:            case 15:                cpInitDesc->aal2Params.poolId =  poolid++;                cpInitDesc->aal2Params.destId = ATM_QOS2_RTVBR_QUEUE ;                break;            default:                ;        }        qsQueueGet(qmuParams[i].pid, &cpBaseQueueId, &num);        qsMessageSend(cpBaseQueueId, (QsMessage *)&cpInitDescStorage);	    while(!qsMessageSendComplete(cpBaseQueueId));    }    /*     * Start the SDP's     * --------------------------------------------------------     */    for (i = 0 ; i < NUMBER_OF_CPS; i++) {        procId = CPprocID(i);        /* The RC has finished initialization, now start the SDPs */        if (ATM_CP(i)) {            sdpMask = ksSdpRxBit  | ksSdpRxSync | ksSdpRxSonet |                      ksSdpRxByte | ksSdpTxByte | ksSdpTxSonet |                      ksSdpTxBit;        }        else if (AAL2_RX_CP(i) || AAL2_TX_CP(i)) {            sdpMask = ksSdpTxByte | ksSdpRxByte;            ksCpCregs(ksProcIdNum(procId))->sdpMode4 = 0;        }        if ((ATM_CP(i)) || (AAL2_RX_CP(i)) || (AAL2_TX_CP(i))) {            rxBitCtl = (volatile int32u*) ksSdpProcControlGet(procId, ksRxBit);            while (!(((*rxBitCtl)>>16) & 0xff)) {#if !defined(SIM)                /*                  * This delay has been added so as to start the RCs.                 * Only after the RCs are started, the SDPs shall be                 * started.                 */                ksPrintService();#endif            }            ksSdpSequencerEnable(procId, sdpMask) ;        }    }   /*    * Initialize SONET Monitoring variables - for    * monitoring port SONET line status defects and error counts.    * enable port 0-3 for monitoring and send messages to queue 69.    */    sonetMonitorInitialize(portBitMask,         XP_SONET_MONITOR_QUEUE, psSonetPathLabelAtm);   /*    * Set Timer to expire in 500ms.  We need to update the defect    * soak counts to be able to time out and set the defect    * indications.    * At 200MHz, it is 5ns/cycles.  500ms/5ns = 100,000,000 cycles or    * 5f5e100    */    ksEventDeregisterPolled(ksEventIdTimer);    ksEventRegisterPolled(ksEventIdTimer);    ksTimerSet(XP_SONET_SOAK_TIME);    /*     * End of Initialization; Start the AAL2 Core     * --------------------------------------------------------     */    aal2Core();     return FALSE;}/******************************************************************* * *  Function:       qsMessageReceive() * *  Description:    Starts dequeueing the descriptor * *  Arguments:      QsQueueId and QsMessage * *  Returns:        QsStatus * *********************************************************************/SINLINE QsStatus qsMessageReceive(QsQueueId qId, QsMessage* msg){    qsMessageReceiveStart(qId, msg);    while(!qsMessageReceiveComplete(qId, msg));    return qsStatusSuccess;}QsMessage ALIGNED64 timeoutMsg;QsMessage ALIGNED64 incomingMsg;QsMessage ALIGNED64 controlMsg;QsMessage ALIGNED64 aal2ControlMsg;/**************************************************************************** * *  Function:       aal2Core() * *  Description:    ATM/AAL2 Core routine. * *                  This routine is responsible for *                  1) CU Timer functionality *                  2) Handling OAM/Control messages *                  3) AAL2 Control Messages(Res CIDs from 1 to 7) * *  Arguments:      None * *  Returns:        None * ***************************************************************************/   void aal2Core(void){#ifdef XP_TEST    int cellNum=0;    int cpsNum=0;#endif

⌨️ 快捷键说明

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