📄 irq.s
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; File: irq.s
;
; Purpose: Assembly language support functions for
; interrupt control and dispatching.
;
; By: Lee Dunbar
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; The following are indirect pointers to IRQ handling routines.
;
.data
.extern IRQStartFunc
addr_StartIRQFunc:
.long IRQStartFunc
.extern IRQFinishFunc
addr_FinishIRQFunc:
.long IRQFinishFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Function name: irq
;
; Purpose: Handle an interrupt request exception.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.data
.global irq
.type irq, @function
.align 8
irq:
;
; The address at which execution should resume after servicing
; this interrupt is lr - 4.
;
sub lr, lr, #4
;
; We have been called to service an IRQ interrupt. IRQ is
; disabled by the CPU, but FIQ might be enabled.
;
; Save the non-banked registers r0-r12 and lr to the IRQ stack.
;
stmfd r13!, {r0-r12, lr}
;
; The status of the interrupted program is in spsr. Push it
; to the IRQ stack as well.
;
mrs r1, spsr
stmfd r13!, {r1}
;
;
; Check for StartIRQ routine
;
ldr a3, addr_StartIRQFunc ; Indirect pointer to StartIRQ
ldr a2, [a3]
cmp a2, #0
movne lr, pc ; arrange for a save return here
movne pc, a2
;
; Do interrupt processing
;
; <Product specific code goes here>
;
; Check for FinishIRQ routine.
;
ldr a3, addr_FinishIRQFunc ; Indirect pointer to FinishIRQ
ldr a1, [a3] ; Check for a FinishIRQ routine
cmp a1, #0
movne lr, pc ; arrange for a save return here
movne pc, a1
;
; If FinishIRQ does not return 0, jump to the returned adddress.
;
cmp a1, #0 ; r1 is non-zero for IRQs which need
movne pc, a1 ; to do further processing
;
; Recover SPSR value from stack and restore value
;
ldmfd r13!, {r1}
msreq spsr_c, r1
;
; Pop the address to return to from the IRQ stack and the saved
; general registers and return from the interrupt.
;
ldmfd r13!, {r0-r12, pc}^
.ltorg
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -