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

📄 media_loopback_bd_rx.uc

📁 开发Inetl IXP2400平台所必须的硬件诊断和测试程序。该软件包支持的功能包括CPU基本功能检测
💻 UC
字号:
/* media_loopback_rx.uc
 *
 * This file receives a POS packet from the media and stores it to DRAM. Then
 * it signals the XScale indicating that it has received a packet.
 *
 *---------------------------------------------------------------------------
 *                                                                      
 *                  I N T E L   P R O P R I E T A R Y                   
 *                                                                      
 *     COPYRIGHT (c)  2002 BY  INTEL  CORPORATION.  ALL RIGHTS          
 *     RESERVED.   NO  PART  OF THIS PROGRAM  OR  PUBLICATION  MAY      
 *     BE  REPRODUCED,   TRANSMITTED,   TRANSCRIBED,   STORED  IN  A    
 *     RETRIEVAL SYSTEM, OR TRANSLATED INTO ANY LANGUAGE OR COMPUTER    
 *     LANGUAGE IN ANY FORM OR BY ANY MEANS, ELECTRONIC, MECHANICAL,    
 *     MAGNETIC,  OPTICAL,  CHEMICAL, MANUAL, OR OTHERWISE,  WITHOUT    
 *     THE PRIOR WRITTEN PERMISSION OF :                                
 *                                                                      
 *                        INTEL  CORPORATION                            
 *                                                                     
 *                     2200 MISSION COLLEGE BLVD                        
 *                                                                      
 *               SANTA  CLARA,  CALIFORNIA  95052-8119                  
 *                                                                      
 *---------------------------------------------------------------------------
 *
 *
 *  system: IXDP2400
 *  subsystem: DIAG
 *  author: dalsraja, April, 2002
 *  revisions: dalsraja, May 8, 2002
 * 
 * 
 * --------------------------------------------------------------------------
 */

#include "common_uc.h"

#define RX_SINGLE_PHY					MSF_SINGLE_PHY
#define RX_WIDTH						MSF_WIDTH_1x32
#define RX_ENABLE_MASK					0x1
#define RX_MODE							MSF_POS_UTOPIA
#define RX_ELEMENTSIZE					MSF_ELEMENTSIZE_128
#define RBUF_ELEM_COUNT					(1 << (7 - RX_ELEMENTSIZE))
#define RBUF_ADDR_SHF					(6 + RX_ELEMENTSIZE)
#define RX_ELEMENT_SIZE_BYTE			(1 << RBUF_ADDR_SHF)

#define ME_NUM_RX						0

#define RX_TRANSFER_THREAD				&$TransferReg00
#define RX_SIGNAL_THREAD				&rx_sig_thd

#define DRAM_PCKT_BASE					0x1000000

.reg $TransferReg00 $TransferReg01
.reg RxThreadList bytecnt elem error
.reg RxConfigData $RxConfigData0 RxConfigData0
.reg rbuf ring_num
.reg MsfAddress MsfAddress0 MsfAddress1
.reg dramPacketBase 
.sig msf_sig sig_dram_xfer1
.sig rx_sig_thd
.xfer_order $TransferReg00 $TransferReg01

.set $TransferReg00

br=ctx[0, Init_Value#]
ctx_arb[kill]

Init_Value#:
	alu[ring_num, --, B, RING_0, <<2]			// ring number in a register
	
	immed[dramPacketBase, (DRAM_PCKT_BASE & MASK_16BIT)]
	immed_w1[dramPacketBase, ((DRAM_PCKT_BASE >> 16) & MASK_16BIT)]


//****************************************************
// Configure RX/TX Control
//****************************************************
	immed[RxConfigData0, ((0<<9) | (RX_ELEMENTSIZE << 2))]
	immed_w1[RxConfigData0, ((RX_MODE << 6) | (RX_WIDTH << 4) | (RX_SINGLE_PHY << 3) | (0<<1)|(0<<0))]
	alu[$RxConfigData0, --, B, RxConfigData0]
	immed[MsfAddress, MSF_RX_CONTROL]
	msf[write, $RxConfigData0, MsfAddress, 0, 1], ctx_swap[msf_sig]


//******************************************************
// Initialize RBUF Freelist to add elements to the list
//******************************************************
.begin
	.reg temp_reg temp

	immed[temp_reg, 0]

init_RBUF#:
	alu[temp, --, B, temp_reg, <<16]
	msf[fast_wr, --, temp, RBUF_ELEMENT_DONE]
	alu[temp_reg, temp_reg, +, 1]
	alu[--, RBUF_ELEM_COUNT, -, temp_reg]
	bne[init_RBUF#]
.end


//******************************************************
// Configure RX UP Control CSRs 
//******************************************************
.begin
	.reg RxUPControl0

	immed[RxUPControl0, (UP_CTRL_PP_MODE | UP_CTRL_CP_MODE | UP_CTRL_PARITY | UP_CTRL_CELLSIZE | UP_CTRL_DRTIME)]
	alu[$RxConfigData0, --, B, RxUPControl0]
	immed[MsfAddress, RX_UP_CONTROL_0]
	msf[write, $RxConfigData0, MsfAddress, 0, 1], ctx_swap[msf_sig]
.end


//****************************************************
// Configure RX/TX Control
//****************************************************
	immed[RxConfigData0, ((0<<9) | (RX_ELEMENTSIZE << 2))]
	immed_w1[RxConfigData0, ((RX_ENABLE_MASK << 12) | (RX_MODE << 6) | (RX_WIDTH << 4) | (RX_SINGLE_PHY << 3) | (0<<1)|(0<<0))]
	alu[$RxConfigData0, --, B, RxConfigData0]
	immed[MsfAddress, MSF_RX_CONTROL]
	msf[write, $RxConfigData0, MsfAddress, 0, 1], ctx_swap[msf_sig]


//**************************************************
// Configure Scratch Ring
//**************************************************
.begin
	.reg $scratch_base $scratch_head $scratch_tail
	.sig scratch_sig1 scratch_sig2 scratch_sig3

	immed[$scratch_head,0]
	immed[$scratch_tail,0]

	alu[$scratch_base, --, B, 0]	// Use ring size of 128 lw and base 0x0
	cap[write,$scratch_base,SCRATCH_RING_BASE_0],sig_done[scratch_sig1]
	cap[write,$scratch_head,SCRATCH_RING_HEAD_0],sig_done[scratch_sig2]
	cap[write,$scratch_tail,SCRATCH_RING_TAIL_0],sig_done[scratch_sig3]
	ctx_arb[scratch_sig1, scratch_sig2, scratch_sig3]
.end


	immed[MsfAddress0, RX_THREAD_FREELIST_0]
	immed[MsfAddress1, RBUF_ELEMENT_DONE]
	immed[rbuf, RBUF_TBUF ]
	immed[RxThreadList, ((RX_SIGNAL_THREAD << 12) | (ME_NUM_RX << 7) | (0 << 4))]
	alu[RxConfigData, RxThreadList,  OR , RX_TRANSFER_THREAD]
	alu[RxConfigData, --,  B, RxConfigData, <<16]	


//*****************************************************************
//  Write to MAILBOX3 register to indicate init complete
//*****************************************************************
#ifndef WORKBENCH_SIM
.begin
	.reg pci_base pci_offset $pci_rw
	.sig pci_sig

	immed[pci_base, (PCI_LOCAL_CSR_BASE & MASK_16BIT)]
	immed_w1[pci_base, ((PCI_LOCAL_CSR_BASE >> 16) & MASK_16BIT)]
	immed[pci_offset, MAILBOX3_OFFSET]
	immed[$pci_rw, INIT_COMPLETE]
	pci[write, $pci_rw, pci_base, pci_offset, 1], ctx_swap[pci_sig]
.end
#endif


//********************************************************
// Start of Test	
//********************************************************
ReceivePacket#:
	.set_sig rx_sig_thd
	msf[fast_wr, --, MsfAddress0, RxConfigData] // add thread to freelist
	ctx_arb[rx_sig_thd]
	

// RSW should be in xfer register
// Transfer RBUF data to sram_in transfer registers
//***************************************
// Extract RSW   7 cycles 
//****************************************
RSW#:
	alu[elem, --, B, $TransferReg00, >>24]	// Get element number
	alu[bytecnt, 0xFF, AND, $TransferReg00, >>16]	// Extract byte count
	alu[error, 0xF, AND, $TransferReg00, >>10]	// Extract error information
//	alu[sopbit, 0x1, AND, $TransferReg00, >>15]	// Check SOP
//	alu[eopbit, 0x1, AND, $TransferReg00, >>14]	// Check EOP
//	alu[L2Port, 0xf, AND, $TransferReg00]		// Extract channel
//	alu[null, 1, AND, $TransferReg00, >>9]		// Extract null
//	bne[NULL#]									// If null=0, result=0(eq)
	

//*********************************
// Transfer from ME to DRAM
//*********************************	
.begin
	.reg pkt_buff_addr rel RBufOffset refcnt temp 

	alu[refcnt, --, B, bytecnt, >>3]
	alu[--, bytecnt, AND, 0x7]
	beq[cont1#]
	alu[refcnt, refcnt, +, 1]
	alu[refcnt, refcnt, OR, 1, <<4]		// Set the overwrite bit for refcnt

cont1#:
#ifdef MSF_WORKAROUND
	.local tmp_elem tmp_rbuf_addr $tmp_xfer0 $tmp_xfer1
	.xfer_order $tmp_xfer0 $tmp_xfer1
	alu[tmp_elem, elem, +, 1]
	alu[tmp_elem, tmp_elem, AND, (RBUF_ELEM_COUNT - 1)]
	alu[tmp_rbuf_addr, rbuf, OR, tmp_elem, <<RBUF_ADDR_SHF]
	msf[read, $tmp_xfer0, tmp_rbuf_addr, 0, 1], ctx_swap[msf_sig]
	.endlocal
#endif

	alu[RBufOffset, --, B, elem, <<7]	// 128B
	alu[temp, RBuf, +, RBufOffset]
	alu[temp, 16, OR, temp, <<5]		// shift rbuf addr and set the overwrite bit
	alu[temp, temp, OR, refcnt, <<21]	// shift refcnt and add for indirect ref

	dram[rbuf_rd, --, dramPacketBase, 0, 8], indirect_ref, sig_done[sig_dram_xfer1]

	ctx_arb[sig_dram_xfer1]
.end


//**************************************************************
//  Free up Element by writing to RBUF_Element_Done{Channel} 3 (48)
//**************************************************************
.begin
	.reg $temp0
	alu[$temp0, --, B, elem]
	msf[write, $temp0, MsfAddress1,0, 1], ctx_swap[msf_sig]
.end


//*****************************************************************
//  Write to MAILBOX0 register to signal completion to XScale code
//*****************************************************************
#ifndef WORKBENCH_SIM
.begin
	.reg $scratch_data
	.sig scratch_sig

	alu[$scratch_data, bytecnt, OR, error, <<16]
	scratch[put, $scratch_data, ring_num, 0, 1], ctx_swap[scratch_sig]
.end
#endif

	br[ReceivePacket#]	

⌨️ 快捷键说明

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