📄 xsintctrla.s
字号:
;----------------------------------------------------------------------
; Copyright (C) 2001 Intel Corp.
;
; filename XsIntCtrla.s
;
; LAST MODIFIED: $Modtime: 6/29/01 8:46p $
;
AREA TopIRQHandler, CODE ; name this block of code
; EXPORT XsIcFiqWrapper
EXPORT XsIcIrqWrapper
EXPORT XsIcDisableInterruptsIrq
EXPORT XsIcEnableInterruptsIrq
EXPORT XsIcRestoreInterruptsIrq
EXPORT XsIcFiqChain
EXPORT XsIcIrqChain
EXPORT IRQ_DisableInterrupts
EXPORT IRQ_EnableInterrupts
EXPORT XsIcGetCpsr
; IMPORT XsIcInterruptHandlerCFiq
IMPORT XsIcInterruptHandlerCIrq
;----------------------------
;
; void XsIcFiqWrapper (void);
;
; Entry point for FIQ interrupt handling. If DM used the FIQ
; interrupt, this would be installed as the first code to execute as
; the result of an FIQ interrupt.
;
; Input: None
; Returns: None
; Side Effects: Calls the C-level FIQ handler. In the case of a non-zero
; return indicator in R0, it then jumps to the chained
; predecessor FIQ handler.
;
; Note XsIcFiqWrapper is only example code. It is not linked in to the
; runnable DM!!
;XsIcFiqWrapper
; STMFD r13!,{r0-r7,r14} ; store registers
; BL XsIcInterruptHandlerCFiq ; Call C routine to handle FIQ
; CMP r0, #0 ; Has C routine handled FIQ ?
; LDMFD r13!,{r0-r7,r14} ; Restore original registers
;
; ; Decide whether to return from handler or to call
; ; the next handler in the chain (the debugger's).
; ; Note that there is no error handling for calling a null link. A production
; ; system would need to address that.
;
; SUBEQS pc,lr,#4 ; return from handler if FIQ handled (return = 0)
; LDR pc, XsIcFiqChain ; else jump to pre-existing handler
;----------------------------
;
; void XsIcFiqWrapper (void);
;
; Entry point for IRQ interrupt handling in the DM. DM assumes that it
; "owns" the IRQ interrupt vector, whether or not in debug mode. This is
; installed as the first code to execute as the result of an IRQ interrupt.
;
; Input: None
; Returns: None
; Side Effects: Calls the C-level IRQ handler. There is no provision in
; the DM for chaining the IRQ.
;
XsIcIrqWrapper
STMFD r13!,{r0-r12,r14} ; store registers
BL XsIcInterruptHandlerCIrq ; Call C routine to handle IRQ
LDMFD r13!,{r0-r12,r14} ; Restore original registers
SUBS pc,lr,#4 ; return from handler
; Note that xsIcInterruptHandlerCIrq is assumed to deal with the
; problem of an IRQ interrupt source with no handler at the application
; level, because we know that there's really no linked code for it.
XsIcFiqChain ; Location to contain address of debugger's FIQ handler.
DCD 0
XsIcIrqChain ; Location to contain address of predecessor's IRQ handler.
DCD 0 ; Not used in DM.
;=========================================================================
;
; Global IRQ Enabling Control via the CPSR
;
; Note that FIQ interrupt enabling and disabling could easily be handled in
; a similar fashion, but they are not used by the DM.
;----------------------------
;
; Constants used in interrupt control subroutines
;
XS_CPSR_F_SHFT EQU 6
XS_CPSR_I_SHFT EQU 7
XS_CPSR_F_MSK EQU 1:SHL:XS_CPSR_F_SHFT
XS_CPSR_I_MSK EQU 1:SHL:XS_CPSR_I_SHFT
XS_CPSR_INTS_MSK EQU 3:SHL:6
;----------------------------
;
; UINT32 XsIcDisableInterruptsIrq (void);
;
; Disables IRQ interrupts in Current Program Status Register
;
; Input: None
; Returns (in R0): pre-existing setting of IRQ interrupt enable (I) bit,
; in position. (0 = enabled, \<<7 (0x80) disabled)
; Note: I bit is set to 1 to disable IRQ interrupts,
; 0 to permit them.
; Side Effects: R1 undefined
;
XsIcDisableInterruptsIrq
MRS r0,cpsr ; Get value of CPSR
ORR r1,r0,#XS_CPSR_I_MSK ; Set IRQ-disabling bit
MSR cpsr_c,r1 ; Disable the IRQ
BIC r0,r0,#:NOT:XS_CPSR_I_MSK ; Clear irrelevant bits in return
MOV pc,lr
;----------------------------
;
; void XsIcEnableInterruptsIrq (void);
;
; Enables IRQ interrupts in Current Program Status Register
;
; Input: None
; Returns: none
; Side Effects: R0 undefined
;
XsIcEnableInterruptsIrq
MRS r0,cpsr ; Get value of CPSR
BIC r0,r0,#XS_CPSR_I_MSK ; Clear IRQ-disabling bit
MSR cpsr_c,r0 ; Enable the IRQ
MOV pc,lr
;----------------------------
;
; void XsIcRestoreInterruptsIrq (UINT32);
;
; Enables or disables IRQ interrupts in Current Program Status Register
;
; Input (in R0): the return value from a previously invoked
; XsIcDisableInterruptsIrq(). If that value is modified in any
; way, the result of this operation is undefined.
; Returns: None
; Side Effects: R0, R1 undefined
;
XsIcRestoreInterruptsIrq
BIC r0,r0,#:NOT:XS_CPSR_I_MSK ; Clear irrelevant bits in param
MRS r1,cpsr ; Get value of CPSR
BIC r1,r1,#XS_CPSR_I_MSK ; Clear target bit in status temp reg.
ORR r1,r1,r0 ; Set enable/disable from param
MSR cpsr_c,r1 ; Control the IRQ
MOV pc,lr
;------------------------ Legacy, but can also touch FIQ interrupt ------------
; Returns existing state of IRQ, FIQ disable flag bits before operation
IRQ_DisableInterrupts
mrs r1,cpsr
orr r0,r0,r1
msr cpsr_c,r0
mov r0,#0xc0
bic r0,r0,r1
mov pc,lr
; Parameter contains the IRQ, FIQ disable flag bits in desired state.
; - Use the return value from IRQ_DisableInterrupts in disable-restore
; situation
IRQ_EnableInterrupts
mrs r1,cpsr
bic r0,r1,r0
msr cpsr_c,r0
mov pc,lr
;----------------------------
;
; UINT32 XsIcGetCpsr (void);
;
; Returns the Current Program Status Word
;
; Input: None
; Returns (in R0): The Current Program Status Word
; Side Effects: None
;
XsIcGetCpsr
MRS r0,cpsr ; Get value of CPSR
MOV pc,lr
END ; mark end of this file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -