TI C66x DSP 系统events及其应用 - 5.12(vector的创建)

下面的创建中断向量表的代码,可以将段vecs(存储中段向量表的段)重定位到某个地址,如DSP的L2起始地址(对于core1,是0x10800000),同时要将ISTP指向这个地址,这样中断发生时,就可以通过ISTP指针来定位相应的vector了。

;create interrupt vector table for C6000 DSP
;--------------------------------------------------------------
;This file can be modified to add Interrupt Service Routine(ISR) 
;for an interrupt, the steps are:
;1,reference to the externally defined ISR, for example
;	.ref EDMA_ISR
;2,modify the corresponding entry in the interrupt vector table.
;  For example, if interrupt 8 is used for EDMA, then you should
;  modify the entry number 8 like below:
;	VEC_ENTRY EDMA_ISR     	;interrupt 8 
;reference to the externally defined ISR
	.ref _c_int00
	.ref Exception_service_routine
	.ref Nested_Exception_service_routine
	.ref LL2_EDC_ISR
	.ref SL2_EDC_ISR
	.ref Timer_ISR
	.ref exception_record
	.global vectors 
;--------------------------------------------------------------
	.sect ".text"      ;NMI_ISR代码将保存在.text段中  
;interrupt vector for NMI
NMI_ISR:                        
	STW 	B1,*-B15[1]

	;save some key registers when exception happens
	MVKL  exception_record,B1
	MVKH  exception_record,B1

	STW 	B3, *+B1[0]
	STW 	A4, *+B1[1]
	STW 	B4, *+B1[2]
	STW 	B14, *+B1[3]
	STW 	B15, *+B1[4]
	
	;jump to exception service routine
	MVKL  	Exception_service_routine, B1
	MVKH  	Exception_service_routine, B1
	B 	B1

	LDW 	*-B15[1],B1
	NOP 	4

;--------------------------------------------------------------
;create interrupt vector for reset (interrupt 0),".macro .endm"为定义汇编语句的宏,类似于C中的#define,调用时可用用宏,如:VEC_RESET NMI_ISR, 参数addr就等于NMI_ISR。 
VEC_RESET .macro addr
	MVKL  addr,B0
	MVKH  addr,B0
	B     B0
	MVC   PCE1,B0
	NOP   4
	.align 32
	.endm

;create interrupt vector for other used interrupts	
VEC_ENTRY .macro addr
	STW   B0,*--B15
	MVKL  addr,B0
	MVKH  addr,B0
	B     B0
	LDW   *B15++,B0
	NOP   4
	.align 32
	.endm

;create interrupt vector for unused interrupts ,不带参数的宏,使用时直接使用宏名:VEC_DUMMY。	
VEC_DUMMY .macro
unused_int?:
	B    unused_int?   ;dead loop for unused interrupts,如果代码进入没有使用的中断vector中,将执行死循环。
	NOP  5
	.align 32
	.endm
	
;--------------------------------------------------------------------;interrupt vector table
	.sect "vecs"    ;作用是创建vecs段,下面的中断向量代码vectors将存储在vecs段中。
	.align 1024     ;.align伪汇编的作用是告诉汇编程序,本伪指令下面的内存变量必须从下一个能被1024整除的地址开始分配。如果下一个地址正好能被1024整除,那么,该伪指令不起作用,否则,汇编程序将空出若干个字节,直到下一个地址能被1024整除为止。	
vectors:
	VEC_ENTRY Nested_Exception_service_routine             ;RESET 
	VEC_ENTRY NMI_ISR			    ;NMI/Exception	
	VEC_DUMMY   					;RSVD
	VEC_DUMMY   					;RSVD
 	VEC_ENTRY LL2_EDC_ISR           ;interrupt 4
	VEC_ENTRY SL2_EDC_ISR     	    ;interrupt 5
	VEC_DUMMY   					;interrupt 6
	VEC_DUMMY   					;interrupt 7
	VEC_DUMMY     					;interrupt 8 
	VEC_DUMMY   					;interrupt 9
	VEC_DUMMY   					;interrupt 10
	VEC_DUMMY   					;interrupt 11
	VEC_DUMMY   					;interrupt 12
	VEC_DUMMY   					;interrupt 13
	VEC_ENTRY Timer_ISR   		    ;interrupt 14
	VEC_DUMMY   					;interrupt 15
	
	.end

代码来自网络,注释为本作者所加。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值