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

📄 bkcompat.c

📁 开发Inetl IXP2400平台所必须的硬件诊断和测试程序。该软件包支持的功能包括CPU基本功能检测
💻 C
📖 第 1 页 / 共 4 页
字号:
*-----------------------------------------------------------------
* Inputs  : pChipData : Validated Chip Data
*				section	 :	Specifies which portion of the chip to 
*								take offline.
* Outputs : None.
*-----------------------------------------------------------------
* Returns : 
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : 
******************************************************************/
bb_Error_e 
Ixf6048SetChipOffline(bb_ChipData_t* pChipData, bb_ChipSegment_t *section)
{
    ixf6048_SetChipOffline(pChipData);
    return bb_NO_ERROR;
}
#endif

/******************************************************************
* Function : Ixf6048SetOhByte
*-----------------------------------------------------------------
* Description  : Set an Overhead Byte: K1,K2, Expected/Tx C2,
*				 HPM RDI in G1
*-----------------------------------------------------------------
* Inputs  : pChipData : Initialized Chip Data
*			section : Determines the section(block) to set the byte
*			SelOhByte : Selects a particular Overhead byte 
*			OhByte : Value of selected Overhead byte
* Outputs : None.
*-----------------------------------------------------------------
* Returns : 
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : 
******************************************************************/
bb_Error_e 
Ixf6048SetOhByte(bb_ChipData_t* pChipData, bb_ChipSegment_t *section,
				bb_SelOhBytes_e SelOhByte, ushort OhByte)
{
    return ixf6048_SetOhByte(pChipData, section->group.channel,
                             SelOhByte, OhByte);
}

/******************************************************************
* Function : Ixf6048GetOhBytes
*-----------------------------------------------------------------
* Description  : Gets Overhead Bytes: Rx MST, Rx HPM
*-----------------------------------------------------------------
* Inputs  : pChipData : Initialized Chip Data
*			section : Determines the section(block) to get the bytes
*			SelOhBytes : Selects the Overhead Bytes 
* Outputs : pOhBytes : place to put Overhead Bytes, of type:
bb_RxMstBytes_t, or ixf6048_RxHpmBytes_t
*-----------------------------------------------------------------
* Returns : 
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : 
******************************************************************/
bb_Error_e
Ixf6048GetOhBytes(bb_ChipData_t* pChipData, bb_ChipSegment_t *section,
				 bb_SelOhBytes_e SelOhBytes, void* pOhBytes)
{
    return ixf6048_GetOhBytes(pChipData, section->group.channel,
                              SelOhBytes, pOhBytes);
}

/******************************************************************
* Function : Ixf6048Reset
*-----------------------------------------------------------------
* Description  : Reset (chip or a section of the chip) and then 
*				 reconfigure it. To restart traffic, the chip or 
*				 section of chip must be set back online
*-----------------------------------------------------------------
* Inputs  : pChipData : Initialized Chip Data
*				section : Determines the section(block) to reset
*				ResetType : Specifies type of Reset
* Outputs : None.
*-----------------------------------------------------------------
* Returns : 
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : 
******************************************************************/
bb_Error_e 
Ixf6048Reset(bb_ChipData_t* pChipData, bb_ChipSegment_t *section,
			 void* ResetType)
{
    return ixf6048_Reset(pChipData, section->group.channel,
                        (ixf6048_ResetType_e) ResetType);
}

#if 0
/******************************************************************
* Function : Ixf6048CfgTest
*-----------------------------------------------------------------
* Description  : Run Tests
*-----------------------------------------------------------------
* Inputs  : pChipData : Validated Chip Data
*				testType : The type of test to run.
* Outputs : None.
*-----------------------------------------------------------------
* Returns : 
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : 
******************************************************************/
bb_Error_e
Ixf6048CfgTest(bb_ChipData_t* pChipData, bb_ChipSegment_t *section, 
               bb_TestType_e testType, void *ptTestCfg)
{
    return bb_INV_TEST_CNFG;
}

/******************************************************************
* Function : Ixf6048SetAlarmCfg
*-----------------------------------------------------------------
* Description  : Edits Interrupt Enabled Masks for a Specific Set
*						of Interrupts.
*-----------------------------------------------------------------
* Inputs  : pChipData : Validated Chip Data
*				section : Determines the section(block) of the alarm(s)
*							 to edit.
*				AlarmType : Specifies the type of Alarm
*				pAlarmCfg : A pointer to the alarm structure.
* Outputs : 
*-----------------------------------------------------------------
* Returns : 
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : 
******************************************************************/
bb_Error_e 
Ixf6048SetAlarmCfg(bb_ChipData_t* pChipData, bb_ChipSegment_t *section,
				  bb_AlarmType_e AlarmType, void* pAlarmCfg)
{
    return ixf6048_SetAlarmCfg(pChipData, section->group.channel,
                               section->block.flow, AlarmType, pAlarmCfg);
}
#endif

/******************************************************************
* Function : Ixf6048Read
*-----------------------------------------------------------------
* Description  :
* This routine will read starting at a particular 
*						location and read for N number of words.
*-----------------------------------------------------------------
* Inputs  : pChipData : Validated Chip Data
*				wordSize : Identifies the size of a word.
*				address : Location where to start reading from.
*				length : Number of words to read.
* Outputs : buffer : The buffer to contain the read data.
*-----------------------------------------------------------------
* Returns : 
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : 
******************************************************************/
bb_Error_e 
Ixf6048Read(bb_ChipData_t* pChipData, bb_Word_Size_t wordSize,
            ulong address, ushort length, void *buffer)
{
    bb_RegPointer_type BaseAddress = pChipData->BaseAddress;
    uint ndx;
    uchar *oneBytePtr;
    ushort *twoBytePtr;
    ulong *fourBytePtr;
    ulong temp;    

#ifdef DBG	
    printf("IxfApiGenericRead pCD = %08x WS = %d addr =\
        %08x len = %d b[0] = %x\n",
        pChipData, wordSize, address, length, ((uchar *) buffer)[0]);
#endif
    
    switch (wordSize)
    {
        
    case ONE_BYTE:		
        oneBytePtr = (uchar*) buffer;
        for(ndx=0; ndx < length; ndx++, oneBytePtr++)
        {
            *oneBytePtr = 
                (uchar) READ_FROM_HW((bb_RegPointer_type)(BaseAddress + 
                                                    (ushort) address + ndx));
#ifdef DBG	
    		printf("Reading address %p contents = %04x\n", ((bb_RegPointer_type)(BaseAddress + 
                                                    (ushort) address + ndx)), *oneBytePtr);
#endif
         }
        break;
     
    case TWO_BYTES:
        twoBytePtr = (ushort*) buffer;
        for(ndx=0; ndx < length; ndx++, twoBytePtr++)
        {
            *twoBytePtr = READ_FROM_HW((bb_RegPointer_type)(BaseAddress +
                                                    (ushort) address + ndx));
#ifdef DBG	
    		printf("Reading address %p contents = %04x\n", ((bb_RegPointer_type)(BaseAddress + 
                                                    (ushort) address + ndx)), *twoBytePtr);
#endif
        }
        break;

case FOUR_BYTES:
        fourBytePtr = (ulong*) buffer;
        
        for(ndx=0; ndx < length; ndx++, fourBytePtr++)
        {
            temp = (ulong) (READ_FROM_HW((bb_RegPointer_type)(BaseAddress + (ushort) address + (ndx * 2))));
            *fourBytePtr = READ_FROM_HW((bb_RegPointer_type)(BaseAddress +
                           (ushort) address + ((ndx* 2) + 1))) << 16 | temp;


#ifdef DBG	
    		printf("Reading address %p contents = %08x\n", ((bb_RegPointer_type)(BaseAddress + 
                                                    (ushort) address + ndx)), *fourBytePtr);
#endif
        }
        
        break;
    case EIGHT_BYTES:
    default:
        return bb_WORD_SIZE_UNSUPPORTED;
        break;
    }
    
    return bb_NO_ERROR;
}


/******************************************************************
* Function : Ixf6048Write
*-----------------------------------------------------------------
* Description  : This routine will write starting at a particular 
*						location and write for N number of words.
*-----------------------------------------------------------------
* Inputs  : pChipData : Validated Chip Data
*				wordSize : Identifies the size of a word.
*				address : Location where to start writing to.
*				length : Number of words to write.
*				buffer : The buffer to contain the read data.
* Outputs : None.
*-----------------------------------------------------------------
* Returns : 
*-----------------------------------------------------------------
* Access Globals : None.
*-----------------------------------------------------------------
* Comments : 
******************************************************************/
bb_Error_e 
Ixf6048Write(bb_ChipData_t* pChipData, bb_Word_Size_t wordSize,
             ulong address, ushort length, void *buffer)
{
    bb_RegPointer_type BaseAddress = pChipData->BaseAddress;
    uint ndx;
    uchar *oneBytePtr;
    ushort *twoBytePtr;
    ulong *fourBytePtr;
    
#ifdef DBG	
    printf("IxfApiGenericWrite pCD = %08x WS = %d addr =\
        %08x len = %d b[0] = %x",
        pChipData, wordSize, address, length, ((uchar *) buffer)[0]);
#endif
    
    switch (wordSize)
    {
    case ONE_BYTE:		
        oneBytePtr = (uchar*) buffer;
        for(ndx=0; ndx < length; ndx++, oneBytePtr++)
        {
#ifdef DBG	
    	printf("Writing to address %p\n", (BaseAddress + ((ushort) address + ndx)));
#endif
            WRITE_TO_HW(BaseAddress + ((ushort) address + ndx), *oneBytePtr);
        }
        break;
    case TWO_BYTES:
        twoBytePtr = (ushort*) buffer;
        for(ndx=0; ndx < length; ndx++, twoBytePtr++)

⌨️ 快捷键说明

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