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

📄 consumer.uc

📁 这是一个intel网络处理器ixp24xx系列中微码例子。用汇编写的。可以参考一下。
💻 UC
字号:
;------------------------------------------------------------------------------------
;                                                                      
;                   I N T E L   P R O P R I E T A R Y                   
;                                                                       
;      COPYRIGHT (c)  2001 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                  
;                                                                       
;------------------------------------------------------------------------------------

// File 			: consume.uc
//
// Description 		: (First see single_producer.uc for complete description.)
//
// This file contains the code for single consumer, illustrating use of scratch rings.
//
// Psuedo Code
// 1. Wait (for signal) until Initialisation is done by producer.
// 2. Check if the ring is empty.
// 3. If not empty get an item from the ring.
// 4. Keep doing it again and again. (goto step 2)


#include "scratchring.h"
#include "sig_macros.uc"

// register and signal declarations

.reg $rdata, ring
.sig scr_get											; signal for scratch get
.sig volatile wake_prod, wake_cons						; signals waking producer, waking consumer

	// 	We use manual allocation for these signals because we have problems
	//	using "visible" (.sig visible wakeup in single_producer) and "remote" in this file
	// 	Until it is solved, we'll have to use this manual allocation.

	// This is manual allocation of signal

.addr	wake_prod		SIG_WAKE_PROD
.addr	wake_cons		SIG_WAKE_CONS

	// Execute only on thread 0.

.if (ctx() == 0)

	// Do Some initialisation

	alu_shf[ring, --, b, RING_NUMBER, <<2]			; ring number in a register

	// Wait until the prodcuer has initialised the ring and is ready to produce

wait_for_producer#:

	ctx_arb[wake_cons]								; Wait for signal from producer.

	// Get data from ring only after checking if the ring is not empty.
	// Ring is empty if the "get" data returns zero. This has the implication
	// that we should not put a zero on the ring.

poll#:	
	scratch[get, $rdata, 0, ring, 1], ctx_swap[scr_get]	; Get 1 word from ring 0.
	alu[--, $rdata, -, 0]							; Check for 0. i.e check if ring empty
	beq[sig_producer#]								; if empty, signal producer

	// Do something with the data here.
	nop												; set break point and see.

	br[poll#]										; continue getting data


sig_producer#:

	// Signal the ME (ME 0) that is going to produce on the ring.
	// It takes about 4000 cycles (from the beginning) to reach here.

	signal_prev_me[wake_prod]					; Signal producer (prev) ME

	br[wait_for_producer#]							; wait for producer
	
.endif	

	// All other threads are killed.

end_of_program#:
	nop
	nop
	ctx_arb[kill]

⌨️ 快捷键说明

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