- .macro set_cpsr_c, reg, mode
- msr cpsr_c, \mode
- .endm
-
-#if __LINUX_ARM_ARCH__ >= 6
- .macro disable_irq, temp
- cpsid i
- .endm
-
- .macro enable_irq, temp
- cpsie i
- .endm
-#else
- .macro disable_irq, temp
- set_cpsr_c \temp, #PSR_I_BIT | MODE_SVC
- .endm
-
- .macro enable_irq, temp
- set_cpsr_c \temp, #MODE_SVC
- .endm
-#endif
-
- .macro save_user_regs
- sub sp, sp, #S_FRAME_SIZE
- stmia sp, {r0 - r12} @ Calling r0 - r12
- add r8, sp, #S_PC
- stmdb r8, {sp, lr}^ @ Calling sp, lr
- mrs r8, spsr @ called from non-FIQ mode, so ok.
- str lr, [sp, #S_PC] @ Save calling PC
- str r8, [sp, #S_PSR] @ Save CPSR
- str r0, [sp, #S_OLD_R0] @ Save OLD_R0
- .endm
-
- .macro restore_user_regs
- ldr r1, [sp, #S_PSR] @ Get calling cpsr
- disable_irq ip @ disable IRQs
- ldr lr, [sp, #S_PC]! @ Get PC
- msr spsr, r1 @ save in spsr_svc
- ldmdb sp, {r0 - lr}^ @ Get calling r0 - lr
- mov r0, r0
- add sp, sp, #S_FRAME_SIZE - S_PC
- movs pc, lr @ return & move spsr_svc into cpsr
- .endm
-
-/*
- * Must be called with IRQs already disabled.
- */
- .macro fast_restore_user_regs
- ldr r1, [sp, #S_OFF + S_PSR] @ get calling cpsr
- ldr lr, [sp, #S_OFF + S_PC]! @ get pc
- msr spsr, r1 @ save in spsr_svc
- ldmdb sp, {r1 - lr}^ @ get calling r1 - lr
- mov r0, r0
- add sp, sp, #S_FRAME_SIZE - S_PC
- movs pc, lr @ return & move spsr_svc into cpsr
- .endm
-
-/*
- * Must be called with IRQs already disabled.