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

📄 irq_ven.s

📁 AT91所有开发板的资料 AT91所有开发板的资料
💻 S
字号:
; ********************************************************************************
; *
; * ARM Strategic Support Group
; *
; ********************************************************************************

; ********************************************************************************
; *
; * Module      : irq_ven.s                   
; * Description : Angel IRQ veneer code                     
; *    
; *           This code is written to allow chaining of the
; *           example IRQ code with the Angel IRQ handler      
; *           caring for the registers using the stack.   
; *
; * Tool Chain	: ARM Developer Suite v1.0
; * Platform   	: Efvaluator7T
; * History    	: 
; *
; *     970326 DBrooke
; *     - created example code
; *
; *   	980420 MEchavarria
; * 	- modified for Sharp 77790A
; *     - added timer counter interrupt handler
; *
; *     980429 ASloss
; *    	- added button interrupt handler
; *
; *	  	980727 ASloss
; *	    - added SWI handler	
; *
; *		2000-04-04 Andrew N. Sloss
; *		- port Evaluator7T
; *		
; * Notes      :
; *
; *  The AREA must have 
; *  - the attribute READONLY, otherwise the linker will not
; *   place it in ROM.
; *  - the attribute CODE, otherwise the assembler will not
; *   let us put any code in this AREA
; *
; ********************************************************************************

; ********************************************************************************
; * IMPORT/EXPORT
; ********************************************************************************

	IMPORT irq_buttonpress
	IMPORT swi_chandler

	EXPORT handler_irq
	EXPORT handler_swi
	EXPORT Angel_IRQ_Address
	EXPORT Angel_SWI_Address
	EXPORT SetupSVC			; just a stub

	AREA	irq, CODE, READONLY

; ********************************************************************************
; * DATA
; ********************************************************************************

INTPND		DCD		0x03ff4004		; consult the Samsung KS32C50100 manual

; *********************************************************************************
; * ROUTINES
; *********************************************************************************

; -- handler_swi ------------------------------------------------------------------
;
; Desciption	: handles the SWI interrupt and chaines
;

handler_swi
	STMFD 	sp!,{r0-r12,lr}			;Store registers
	LDR		r0,[lr,#-4]				;Calculate address of SWI instruction
	BIC		r0,r0,#0xff000000		;Mask off top 8 bits of instruction to give SWI 
									;number
	LDR		r2, Angel_SWI_Number	;Get Angel SWI Number
	CMP		r0, r2					;Intercept Angel SWI Early 
	BNE		user_swis	
	LDMFD	sp!,{r0-r12,lr}			;Restore registers for Angel...
	LDR		pc, Angel_SWI_Address	;if eq then branch to the Angel SWI
user_swis							;Non Angel SWI
	MOV		r1,sp					;second parameter to C routine...
									;is pointer to register values.
	MRS		r2,spsr					;move the spsr into gp register
	STMFD	sp!,{r2}				;store spsr onto the stack. This is only really
									;needed in case of nested SWI's
	BL		swi_chandler			;call C routine to handle SWI
	LDMFD	sp!,{r2}				;restore spsr from stack into r2	
	MSR		spsr_cf,r2				;and restore it into spsr.
	LDMFD	sp!,{r0-r12,pc}^		;restore registers and return.

; -- handler_irq -------------------------------------------------------------------
;
; Description	: handles the IRQ interrupt and determines the source and then
;		  vectors to the correct interrupt rountine.
;

handler_irq
	STMFD	sp!, {r0 - r3, LR}		;Maintain Stack using APCS standard
	LDR 	r0, INTPND				;Get address of the IRQ status Reg 
	LDR 	r0, [r0]				;Read the status reg byte
	TST		r0, #0x0001				;Is it a button press ?
	BNE		handler_event_button	;Branch if button is pressed
	LDMFD	sp!, {r0 - r3, lr}		;If not then its an Angel request
	LDR 	pc, Angel_IRQ_Address	;remove the regs from the stack and call 
									;the routine
;
; **********************************************************************************
; EVENT: Button
; **********************************************************************************
;

handler_event_button
	BL		irq_buttonpress			;if this point is reached then the irq is from 
									;the button
	LDMFD   sp!, {r0 - r3,lr}		;return from the irq_buttonpress routine - 
									;restore the registers 
	subs    pc, lr, #4 				;and return from the interrupt
		
SetupSVC
	MOV	pc, lr						; return


	AREA	var, DATA, READWRITE

; *********************************************************************************
; * DATA AREA
; *********************************************************************************


Angel_SWI_Number
	DCD	0x00123456

Angel_IRQ_Address	
	DCD 	0x00000000	; Chained Angel IRQ Handler address

Angel_SWI_Address
	DCD 	0x00000000  ; Chained Angel SWI Interrupt address


	END

; ***********************************************************************************
; * END OF irq_ven.s 
; ***********************************************************************************

⌨️ 快捷键说明

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