📄 aal2cpmain.c
字号:
/* * FILENAME : aal2Main.c * * COMMENTS : This file contains functions which does initialization for the * AAL2 Rx and Tx CPs. The DCPmain function in this file will be * called when the XP calls KsProcStart after basic initialization. * For CPs 4 to 9 AAL2 Rx module is created and for CPs 10 to 15 * AAL2 Tx module is created. The buffer pool, table, * AAL2_RX_CONTEXT and AAL2_TX_CONTEXT are initialized here. *//* * Copyright (c) 2000, 2001, 2002 C-Port Corporation, a Motorola Company * All Rights Reserved * * The information contained in this file is C-Port Corporation 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 or Motorola Incorporated is strictly prohibited. */#define AAL2_MAIN/* #define CPRC_INIT_SDP *//* necessary header files */#include <dcpKernelSvcs.h>#include <dcpBufferSvcs.h>#include <dcpQueueSvcs.h>#include <dcpTableSvcs.h>#include <dcpHostSvcs.h>#include <dcpDiagSvcs.h>/* Header files with definitions for ATM */#include <atm.h>#include <atmCellDesc.h>/* Header files with definitions for AAL2 */#include <aal2.h>#include <aal2Desc.h>/* Header files with definitions for AAL2 Rx */#include <aal2Rx.h>#include <aal2RxIf.h>#include <aal2Tx.h>#include <aal2TxIf.h>#include <aal2Init.h>#ifndef SIM#define AAL2_STATISTICS #endif/* Sizes of the AAL2 Init, Rx and Tx context stacks */#define AAL2_INIT_THREAD_STACK_SIZE 256/*************************************************** * Global variable declarations **************************************************//* Buffer for reading the Initialization parameters from XP */QsMessage ALIGNED64 cpInitDescStorage;/* Initialize AAL2 PARITY TABLE */int8u gAal2ParityTable[] = { 1, 2, 4, 7, 8, 11, 13, 14, 16, 19, 21, 22, 25, 26, 28, 31, 32, 35, 37, 38, 41, 42, 44, 47, 49, 50, 52, 55, 56, 59, 61, 62, 64, 67, 69, 70, 73, 74, 76, 79, 81, 82, 84, 87, 88, 91, 93, 94, 97, 98, 100, 103, 104, 107, 109, 110, 112, 115, 117, 118, 121, 122, 124, 127, 128, 131, 133, 134, 137, 138, 140, 143, 145, 146, 148, 151, 152, 155, 157, 158, 161, 162, 164, 167, 168, 171, 173, 174, 176, 179, 181, 182, 185, 186, 188, 191, 193, 194, 196, 199, 200, 203, 205, 206, 208, 211, 213, 214, 217, 218, 220, 223, 224, 227, 229, 230, 233, 234, 236, 239, 241, 242, 244, 247, 248, 251, 253, 254};PDU ALIGNED64 rxTempPdu[MAX_SCOPES]; /* DMEM for payload transfer from SDP to DMEM */PDU ALIGNED64 txTempPdu[MAX_SCOPES]; /* DMEM for payload transfer from DMEM to SDP */QsMessage ALIGNED64 cellDescMsg; /* Queue descriptor for ATM cells */CellDescriptor *cellDescPtr; /* Pointer to ATM cell descriptor */BsPoolId poolId; /* AAL2 CP pool Id */QsQueueId baseQueueId; /* Input queue Id of the AAL2 CP */KsContext aal2HdlrContext; /* KsContext of the AAL2 Hdlr thread */KsContext aal2FwdrContext; /* KsContext of the AAL2 Fwdr thread */#ifdef AAL2_STATISTICS/* Variable declared for storing the statistics regarding AAL2 Rx. */int32u rxAal2LengthErr = 0;int32u rxAal2Pdus = 0;int32u Aal2ParityErr = 0;int32u Aal2SNErr = 0;int32u rxInvalidCid = 0;int32u Aal2Crc5Err = 0;int32u rxSent = 0;int32u txCells = 0;int32u txAal2Pdus = 0;int32u aal2EnqueueFail = 0;#endifBsBufHandle lastBufferEnqueued;Boolean payloadEnqueue = FALSE;/* Irq handler for QMU errors. */int32u aal2CpQmuIrqHandler(void *);/**************************************************************************** * Function : DCPmain * * Description : This function does the initializes AAL2 Rx in CPs 4 to 9 * and AAL2 Tx in CPs 10 to 15. * Initialization will be done by reading the base queue for * each of the CPs * * Parameters : PARAMETERS * * Returns : RETURNS * * Traceability : TRACEABILITY * ***************************************************************************/int DCPmain(KsPackage package){ NewCpInitDesc *aal2CpInitDesc; int32u cpId, procId; int32u num; volatile int8u *rxBitCtl;#ifdef CPRC_INIT_SDP volatile int32u* txByteCtrl; volatile int32u* rxByteCtrl;#endif /* Initialize all of the system services */ ksInitialize(AAL2_INIT_THREAD_STACK_SIZE); tsTableInitialize(); bsInitialize(); qsInitialize(0); ksEventDeregisterInterrupt(ksEventIdQmuError); cpId = ksCpGetId(); /* Get the Base queue Id of the CP */ procId = ksProcIdGet(); qsQueueGet(procId, &baseQueueId, &num); /* XP will sent the poolId and table Id via the base queue. Check the * queue and retrieve the first message. Extract the pool id, initialize * the buffer services. */ while (!qsQueueGetLength(baseQueueId)); qsMessageReceiveStart(baseQueueId, &cpInitDescStorage); while (!qsMessageReceiveComplete(baseQueueId, &cpInitDescStorage)); aal2CpInitDesc = (NewCpInitDesc *) qsMessageGetData (&cpInitDescStorage); /* Store buffer pool in the AAL2 Rx context */ poolId = (BsPoolId) aal2CpInitDesc->aal2Params.poolId; /* Initialize the buffer pool for the coresponding pool Id */ bsPoolInitialize(poolId); /* Allocating cell descriptor */ cellDescPtr = (CellDescriptor *) qsMessageGetData(&cellDescMsg); /* To avoid the DMEM read before write warnings */ memset(cellDescPtr, 0, sizeof(CellDescriptor)); /* Initialize the DMEM buffer areas to avoid read before write warnings */ memset(rxTempPdu[0], 0, 64); memset(rxTempPdu[1], 0, 64); memset(txTempPdu[0], 0, 64); memset(txTempPdu[1], 0, 64); /* Initialisation of SDPs */#ifdef CPRC_INIT_SDP /* * Write cpId in reserved[0] of RxByteCtrlSpc and * TxByteCtrlSpc of ATM, AAL2 Rx and AAL2 Tx CPs. */ txByteCtrl = (int32u*)ksSdpProcControlGet(procId, ksTxByte); *txByteCtrl = (int32u)cpId; rxByteCtrl = (int32u*)ksSdpProcControlGet(procId, ksRxByte); *rxByteCtrl = (int32u)cpId; ksSdpByteLoopbackConfigure(procId);#endif if (AAL2_RX_CP(cpId)) { aal2RxInit(&(aal2CpInitDesc->aal2Params)); /* * As Xp is waiting to start the SDPs,set rxBitCtl Information. */ rxBitCtl = (volatile int8u*)ksSdpProcControlGet(procId,ksRxBit); rxBitCtl[1] = 0x1; } else if (AAL2_TX_CP(cpId)) { /* * As Xp is waiting to start the SDPs,set rxBitCtl Information. */ rxBitCtl = (volatile int8u*)ksSdpProcControlGet(procId,ksRxBit); rxBitCtl[1] = 0x1; /* aal2TxInit(cpId, procId, baseQueueId, xpQueueId, aal2CpInitDesc); */ aal2TxInit( &(aal2CpInitDesc->aal2Params)); } ksContextExit(); return (FALSE);}/* * Function: aal2CpQmuIrqHandler() * * Description: This function is interrupt handler for QMU errors. It is typically * called under normal congestion conditions when an enqueue fails * to succeed due to the target queue being full. When this occurs * this irq handler must free the buffer associated with the last * enqueue. * * Arguments: An eventInfo block passed in by kernel services. * * Returns: */int32u aal2CpQmuIrqHandler(void *irqInfo){ KsEventInfo *eventInfo = (KsEventInfo *)irqInfo; if(eventInfo->eventId == ksEventIdQmuError) { dcpTrace1(("Queue irq, queue %d", eventInfo->address)); /* Free the buffer associated with the last enqueue. */ if(payloadEnqueue == TRUE ) {#ifdef AAL2_STATISTICS rxInvalidCid++; aal2EnqueueFail++;#endif /* Save any context before doing an operation. */ ksEventContextSave(); /* Free the buffer associated with the last enqueue. */ bsBufferFree(lastBufferEnqueued); /* Wait until operation is done and then restore any context. */ while(!bsBufferWriteComplete()); ksEventContextRestore(); payloadEnqueue = FALSE; } // else { // Aal2OtherEnqueueFail++; // } } return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -