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

📄 aal2rxrxbyte.c

📁 摩托罗拉Motolola公司网络处理器C3的示范代码.实现了ATM的AAL2层交换功能.想了解网络处理器的可以
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  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 RXBYTE#include <stdio.h>#include <sdpUcode.h>#include <dcpRegisterDefs.h>#include <dcpRegistersCp.h>#include <atm.h>#include <rcSdpAal2RxApiIf.h>#define RXBYTECTL ((int) &((SdpRxCregs*)NULL)->rxCtl.byte)/********************************************************************** * RxByte Functionality * Poll the extract space for its availability. * If its the start of a Cell flag then *     If Partial header length is non-zero then *         Get three bytes of header. *         Write the header to Extract Space. *         Do a CRC5 on the header *         If CRC5 fails then *             Write CRC5 failed to Extract space. *             If partial payload length (OSF) is non-zero then *                 Dump the following payload. *             Else *                 Dump the following data till you get Data9. *             Release the extract space. *             Start reading the header to the new extract space. *         else *             Write CRC5 passed to Extract space. *             Read the payload and send to RC. *     Else *         Read Partial payload length of data and send it to RC. * Else *         Get three bytes of header. *         Write the header to Extract Space. *         Do a CRC5 on the header *         If CRC5 fails then *             Write CRC5 failed to Extract space. *             If payload length (LI) is non-zero then *                 Dump the following payload. *             Else *                 Dump the following data till you get Data9. *             Release the extract space. *             Start reading the header to the new extract space. *         else *             Write CRC5 passed to Extract space. *             Read the payload and send to RC. * * **********************************************************************/voidSDPmain(){    Description = ("AAL2 Rx Ucode for the RxSDP Byte Processor.");LabelDef(START_PROCESSING);    DCPSIM_MESSAGE(Start processing);    Abus(Literal(0x01));    ALU(PassA);    IregsA(NEW_CELL);    Actions(IregsAwrite);    Branch(ALWAYS, Upc+1);                         /* Upc = 0 */    /* Disable the SDP FIFO overrun functionality */    // Abus(Literal(OVERRUNCLR));    // Bbus(IregsB(STATUSreg));    // ALU(XOR);    // IregsA(STATUSreg);    // Actions(IregsAwrite);    // Branch(ALWAYS, Upc+1);/* Poll for the extract space availability */LabelDef(POLL_EXTRACT_SPACE);    DCPSIM_MESSAGE(Poll the extract space);    CregsAddrWrite(RXSTATUS);    Branch(ALWAYS, Upc+1);                         /* Upc = 1 */    Branch(ALWAYS, Upc+1);                         /* Upc = 2 */LabelDef(TEST_EXTRACT_SPACE_AVAIL);    Abus(Creg);    Bbus(Literal(AAL2_RX_RC_OWN_FLG));    ALU(AND);    Branch(ALWAYS, Upc+1);                         /* Upc = 3 */    Branch(ALUneg, Label(TEST_EXTRACT_SPACE_AVAIL)); /* Upc = 4 *//* Reset the CRC5 indicator */LabelDef(RESET_ERROR_INDICATORS);    /* Write the address of extract space CRC5 result to CREG     * and set it to 0.*/    CregsAddrWrite(EXTRACT_SPACE_OFFSET(crc5Indicator));    Branch(ALWAYS, Upc+1);                         /* Upc = 71 */    CregInit(0x00);    Branch(ALWAYS, Upc+1);                         /* Upc = 72 */    /* Write the address of extract space goodCpsPacket to CREG     * and set it to 1 (good packet).*/    CregsAddrWrite(EXTRACT_SPACE_OFFSET(goodCpsPacket));    Branch(ALWAYS, Upc+1);                         /* Upc = 71 */    CregInit(0x01);    Branch(ALWAYS, Upc+1);                         /* Upc = 72 */    /* Extract space is currently not available */    CregsAddrWrite(EXTRACT_SPACE_OFFSET(extractAvailFlag));    Branch(ALWAYS, Upc+1);                         /* Upc = 71 */    CregInit(0x00);    Branch(ALWAYS, Upc+1);                         /* Upc = 72 */    /* Reset the field cpsPckComplete */    CregsAddrWrite(EXTRACT_SPACE_OFFSET(cpsPckComplete));    Branch(ALWAYS, Upc+1);                         /* Upc = 71 */    CregInit(0x00);    Branch(ALWAYS, Upc+1);                         /* Upc = 72 *//* Check if its a new cell */LabelDef(TEST_FOR_NEW_CELL);    Abus(IregsA(NEW_CELL));    ALU(PassA);    Branch(ALWAYS, Upc+1);                         /* Upc = 5 */    Branch(ALUzero, Label(INIT_CPS_IREG));         /* Upc = 6 *//* Its possible that we get Data9 at the beggining * in that case drop it and begin afresh.  */    WAIT_FOR_DATA(Upc+1);    BranchNot(Data9, Label(EXTRACT_CELL_FLAG)); /* Upc = 8 */    Actions(UnloadFIFO);    Branch(ALWAYS, Upc+1);/* Process the Flag byte to find out the   number of header bytes sent or OSF */LabelDef(EXTRACT_CELL_FLAG);    DCPSIM_MESSAGE(Extract the initial flag);    WAIT_FOR_DATA(Upc+1);    /* Store the first byte in TEMP */    Bbus(Payload);    ALU(PassB);    IregsB(TEMP);    Actions(IregsBwrite);    Branch(ALWAYS, Upc+1); /* wait cycle */        /* Upc = 7 */    /* Get the 2 LS bits of the flag and store the result in CPS_HEADER_LEN     * This will give us the no. of partial header bytes following.  */    Abus(Literal(0x03));    Bbus(IregsB(TEMP));    ALU(AND);    IregsA(CPS_HEADER_LEN);    Actions(IregsAwrite);    Branch(ALWAYS, Upc+1);                         /* Upc = 9 */    /* Get the 6 MS bits of the flag and store the result in     * PARTIAL_PAYLOAD_LEN. This will give us the no. of partial     * payload bytes following. Bbus was already initialized in     * the previous block.  */    Abus(Literal(0xFC));    Bbus(IregsB(TEMP));    ALU(AND);    IregsA(PARTIAL_PAYLOAD_LEN);    Actions(IregsAwrite);    Branch(ALWAYS,Upc+1);                          /* Upc = 10 */    Bbus(IregsB(PARTIAL_PAYLOAD_LEN));    ALU(RotateB(2));    IregsA(PARTIAL_PAYLOAD_LEN);    Actions(IregsAwrite);    Branch(ALWAYS,Upc+1);                          /* Upc = 11 */    /* Reset NEW_CELL to zero */    IregInit(NEW_CELL, 0x00, UseBbus);    Branch(ALWAYS, Upc+1);/* Check if partial CPS header length is 0, * If YES then *     Check if partial payload length is 0 *     if YES then *         Go to Read_CPS_HEADER. *     Else *         Go to WRITE_PAYLOAD_TO_RC. * Else *     Go to READ_CPS_HEADER. */LabelDef(TEST_FOR_CPS_HEADER);    DCPSIM_MESSAGE(Test for CPS header);    Abus(IregsA(CPS_HEADER_LEN));    ALU(PassA);    Branch(ALWAYS, Upc+1);                         /* Upc = 12 */    BranchNot(ALUzero, Label(DROP_INITIAL_FLAG));      /* Upc = 13 *//* Test for partial payload length to be 0 */LabelDef(TEST_PARTIAL_PAYLOAD);    DCPSIM_MESSAGE(Test for Partial payload);    Abus(IregsA(PARTIAL_PAYLOAD_LEN));    ALU(PassA);    Branch(ALWAYS, Upc+1);                         /* Upc = 14 */    BranchNot(ALUzero, Label(WRITE_PART_PAYLOAD_TO_RC)); /* Upc = 15 *//* The initial flag has to be dropped before reading the header. */LabelDef(DROP_INITIAL_FLAG);    Actions(UnloadFIFO);    Branch(ALWAYS, Upc+1); /* wait cycle *//* Initialize CPS header IREGs so that incase of a partial header   0s are written in place of unretrieved header bytes */LabelDef(INIT_CPS_IREG);    DCPSIM_MESSAGE(Initialize CPS registers);    /* Reset the header Iregs */    IregInit(CID_IREG, 0x00, UseBbus);    Branch(ALWAYS, Upc+1);                         /* Upc = 16 */    IregInit(LI_IREG, 0x00, UseBbus);    Branch(ALWAYS, Upc+1);                         /* Upc = 17 */    IregInit(UUI_IREG, 0x00, UseBbus);    Branch(ALWAYS, Upc+1);                         /* Upc = 18 */    /* Reset the COUNTER Ireg */    IregInit(COUNTER, 0x00, UseAbus);    Branch(ALWAYS, Upc+1);                         /* Upc =  */    /* Set CPS_HEADER_LEN to 0 so that we can count the no. of header bytes */    IregInit(CPS_HEADER_LEN, 0x00, UseAbus);    Branch(ALWAYS, Upc+1);                         /* Upc = 19 *//* Read the 3 bytes of CPS header and accumulate CRC5. * This needs to be split into READ_CPS_HEADER and WRITE_CPS_HEADER_TO_ES * The CPS header could be partial, this needs to be taken care of. * Also initialize the CRC5 block, start accumulating CRC5 after * unloading data from the FIFO and it is valid. */LabelDef(READ_CPS_HEADER);    DCPSIM_MESSAGE(Init CRC5 block);    Actions(CRC5init);    Branch(ALWAYS, Upc+1); /* wait cycle */    DCPSIM_MESSAGE(Read in the CPS header);    /* Ensure that the data is valid */    WAIT_FOR_DATA(Upc+1)    DCPSIM_MESSAGE(Read in the CID);    Bbus(Payload);    IregsB(CID_IREG);    Actions(CRC5accum + IregsBwrite + IregIncr(CPS_HEADER_LEN));    Branch(ALWAYS, Upc + 1);                       /* Upc = 21*/    /* Its possible that we get Data9 at the beggining */    Branch(Data9, Label(HANDLE_DATA9_IN_HEADER));        /* Upc = 22 */    Actions(UnloadFIFO);    Branch(ALWAYS, Upc+1);                         /* Upc = 23 */    WAIT_FOR_DATA(Upc+1);    /* Read the second byte from FIFO into LI_IREG.     * This is LI + UUI (7:3)*/    DCPSIM_MESSAGE(Read in the LI 7:2 UUI 1:0);    Bbus(Payload);    IregsB(LI_IREG);    Actions(CRC5accum + IregsBwrite + IregIncr(CPS_HEADER_LEN));    Branch(ALWAYS, Upc + 1);                       /* Upc = 24 */    /* store LI_IREG (1:0) which is part of UUI in TEMP */    Abus(Literal(0x03));    Bbus(IregsB(LI_IREG));    ALU(AND);    IregsA(TEMP);    Actions(IregsAwrite);    Branch(ALWAYS,Upc+1);                          /* Upc = 26 */    /* Extract LI which is LI_IREG(7:2) into register LI_IREG */    Abus(IregsA(LI_IREG));    Bbus(Literal(0xFC));    ALU(AND);    Actions(IregsAwrite);  /* writing to LI */    Branch(ALWAYS, Upc+1);                         /* Upc = 27 */    /* Moved LI_IREG bits into place.     * LI_IREG(7:2) to LI_IREG(5:0) */    Bbus(IregsB(LI_IREG));    ALU(RotateB(2));    IregsA(LI_IREG);    Actions(IregsAwrite);    Branch(ALWAYS, Upc+1);                         /* Upc = 28 */    /* Store TEMP in UUI_IREG just in case we hit Data9. UUI_IREG       will then be wirtten to the extract space. */    Bbus(IregsB(TEMP));    ALU(RotateB(5));    IregsA(UUI_IREG);    Actions(IregsAwrite);    Branch(ALWAYS, Upc+1);    /* Its possible that we get Data9 in between the header */    Branch(Data9, Label(HANDLE_DATA9_IN_HEADER));       /* Upc = 25 */    /* The Data9 byte has to be removed from the FIFO */    Actions(UnloadFIFO);    Branch(ALWAYS, Upc+1);                         /* Upc = 28 */    WAIT_FOR_DATA(Upc+1);    /* Read the third byte into Ireg6. This contains uui(7:5) + HEC(4:0) */    DCPSIM_MESSAGE(Read in the UUI 7:5);    Bbus(Payload);    IregsB(UUI_IREG);    Actions(CRC5accum + IregsBwrite + IregIncr(CPS_HEADER_LEN));    Branch(ALWAYS, Upc+1);                         /* Upc = 29 */    /* Get the UUI(7:5) bits into COUNTER */    Abus(Literal(0xE0));    IregsB(UUI_IREG);    ALU(AND);    IregsA(COUNTER);    Actions(IregsAwrite);    Branch(ALWAYS, Upc + 1);                       /* Upc = 31 */    /* Merge TEMP and COUNTER and store in UUI_IREG */    Abus(IregsA(TEMP));    Bbus(IregsB(COUNTER));    ALU(OR);    Actions(IregsAwrite);

⌨️ 快捷键说明

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