#include /* for CONFIG_ARCH_xxxx */ #include #include #include #include #include #include #include #ifndef MODE_SVC #define MODE_SVC 0x13 #endif .macro zero_fp #ifdef CONFIG_FRAME_POINTER mov fp, #0 #endif .endm .text @ Bad Abort numbers @ ----------------- @ #define BAD_PREFETCH 0 #define BAD_DATA 1 #define BAD_ADDREXCPTN 2 #define BAD_IRQ 3 #define BAD_UNDEFINSTR 4 #define PT_TRACESYS 0x00000002 @ OS version number used in SWIs @ RISC OS is 0 @ RISC iX is 8 @ #define OS_NUMBER 9 #define ARMSWI_OFFSET 0x000f0000 @ @ Stack format (ensured by USER_* and SVC_*) @ #ifdef CONFIG_CPU_32 #ifdef CONFIG_CPU_PXA27X #define S_FRAME_SIZE 76 #define S_TSK 72 #else #define S_FRAME_SIZE 72 #endif #define S_OLD_R0 68 #define S_PSR 64 #else #define S_FRAME_SIZE 68 #define S_OLD_R0 64 #define S_PSR 60 #endif #define S_PC 60 #define S_LR 56 #define S_SP 52 #define S_IP 48 #define S_FP 44 #define S_R10 40 #define S_R9 36 #define S_R8 32 #define S_R7 28 #define S_R6 24 #define S_R5 20 #define S_R4 16 #define S_R3 12 #define S_R2 8 #define S_R1 4 #define S_R0 0 #define S_OFF 8 #ifdef CONFIG_CPU_32 .macro set_cpsr_c, reg, mode #if 1 /* broken binutils */ mov \reg, \mode msr cpsr_c, \reg #else msr cpsr_c, \mode #endif .endm .macro disable_irq, temp set_cpsr_c \temp, #I_BIT | MODE_SVC .endm .macro enable_irq, temp set_cpsr_c \temp, #MODE_SVC .endm #ifdef CONFIG_CPU_PXA27X #define MMX_WR0 (0x00) #define MMX_WR1 (0x08) #define MMX_WR2 (0x10) #define MMX_WR3 (0x18) #define MMX_WR4 (0x20) #define MMX_WR5 (0x28) #define MMX_WR6 (0x30) #define MMX_WR7 (0x38) #define MMX_WR8 (0x40) #define MMX_WR9 (0x48) #define MMX_WR10 (0x50) #define MMX_WR11 (0x58) #define MMX_WR12 (0x60) #define MMX_WR13 (0x68) #define MMX_WR14 (0x70) #define MMX_WR15 (0x78) #define MMX_WCSSF (0x00) #define MMX_WCASF (0x04) #define MMX_WCGR0 (0x08) #define MMX_WCGR1 (0x0C) #define MMX_WCGR2 (0x10) #define MMX_WCGR3 (0x14) .macro save_user_iwmmxt stmfd sp!, {r4-r6} get_current_task r6 str r6, [sp, #12+S_TSK] mrc p15, 0, r4, c15, c1, 0 str r4, [r6, #TSS_CPAR] cmp r4, #3 bne 92f @Not Use iWMMXt tmrc r4, wCon tst r4, #1 beq 91f add r5, r6, #TSS_MMXWC @store mmxWC wstrw wCSSF, [r5, #MMX_WCSSF] wstrw wCASF, [r5, #MMX_WCASF] wstrw wCGR0, [r5, #MMX_WCGR0] wstrw wCGR1, [r5, #MMX_WCGR1] wstrw wCGR2, [r5, #MMX_WCGR2] wstrw wCGR3, [r5, #MMX_WCGR3] 91: tst r4, #2 beq 92f add r5, r6, #TSS_MMXWR @store mmxWR wstrd wR0, [r5, #MMX_WR0] wstrd wR1, [r5, #MMX_WR1] wstrd wR2, [r5, #MMX_WR2] wstrd wR3, [r5, #MMX_WR3] wstrd wR4, [r5, #MMX_WR4] wstrd wR5, [r5, #MMX_WR5] wstrd wR6, [r5, #MMX_WR6] wstrd wR7, [r5, #MMX_WR7] wstrd wR8, [r5, #MMX_WR8] wstrd wR9, [r5, #MMX_WR9] wstrd wR10, [r5, #MMX_WR10] wstrd wR11, [r5, #MMX_WR11] wstrd wR12, [r5, #MMX_WR12] wstrd wR13, [r5, #MMX_WR13] wstrd wR14, [r5, #MMX_WR14] wstrd wR15, [r5, #MMX_WR15] mov r4, #1 mcr p15, 0, r4, c15, c1, 0 @CPAR = 1 92: ldmfd sp!, {r4-r6} .endm .macro restore_user_iwmmxt tst r1, #15 bne 99f @ Not From UserMode ldr r5, [sp, #S_TSK-S_PC] @ Get Now Tsk ldr r4, [r5, #TSS_CPAR] mcr p15, 0, r4, c15, c1, 0 cmp r4, #3 bne 99f @ Not Use iWMMXt add r4, r5, #TSS_MMXWR add r5, r5, #TSS_MMXWC wldrd wR0, [r4, #MMX_WR0] wldrd wR1, [r4, #MMX_WR1] wldrd wR2, [r4, #MMX_WR2] wldrd wR3, [r4, #MMX_WR3] wldrd wR4, [r4, #MMX_WR4] wldrd wR5, [r4, #MMX_WR5] wldrd wR6, [r4, #MMX_WR6] wldrd wR7, [r4, #MMX_WR7] wldrd wR8, [r4, #MMX_WR8] wldrd wR9, [r4, #MMX_WR9] wldrd wR10, [r4, #MMX_WR10] wldrd wR11, [r4, #MMX_WR11] wldrd wR12, [r4, #MMX_WR12] wldrd wR13, [r4, #MMX_WR13] wldrd wR14, [r4, #MMX_WR14] wldrd wR15, [r4, #MMX_WR15] wldrw wCSSF, [r5, #MMX_WCSSF] wldrw wCASF, [r5, #MMX_WCASF] wldrw wCGR0, [r5, #MMX_WCGR0] wldrw wCGR1, [r5, #MMX_WCGR1] wldrw wCGR2, [r5, #MMX_WCGR2] wldrw wCGR3, [r5, #MMX_WCGR3] mov r4, #0 tmcr wCon, r4 99: .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 #ifdef CONFIG_CPU_PXA27X tst r8, #15 bne 100f @Not From UserMode save_user_iwmmxt 100: #endif .endm /* * Must be called with IRQs already disabled. */ .macro restore_user_regs ldr r1, [sp, #S_PSR] @ Get calling cpsr ldr lr, [sp, #S_PC]! @ Get PC #ifdef CONFIG_CPU_PXA27X restore_user_iwmmxt #endif 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 #ifdef CONFIG_CPU_PXA27X restore_user_iwmmxt #endif 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 .macro mask_pc, rd, rm .endm .macro get_current_task, rd mov \rd, sp, lsr #13 mov \rd, \rd, lsl #13 .endm /* * Like adr, but force SVC mode (if required) */ .macro adrsvc, cond, reg, label adr\cond \reg, \label .endm .macro alignment_trap, rbase, rtemp, sym #ifdef CONFIG_ALIGNMENT_TRAP #define OFF_CR_ALIGNMENT(x) cr_alignment - x ldr \rtemp, [\rbase, #OFF_CR_ALIGNMENT(\sym)] mcr p15, 0, \rtemp, c1, c0 #endif .endm #else .macro save_user_regs sub sp, sp, #S_FRAME_SIZE str r0, [sp, #S_OLD_R0] str lr, [sp, #S_PC] stmia sp, {r0 - lr}^ mov r0, r0 .endm .macro restore_user_regs ldmia sp, {r0 - lr}^ mov r0, r0 ldr lr, [sp, #S_PC] add sp, sp, #S_FRAME_SIZE movs pc, lr .endm .macro fast_restore_user_regs add sp, sp, #S_OFF + S_PC ldmdb sp, {r1 - lr}^ mov r0, r0 ldr lr, [sp], #S_FRAME_SIZE - S_PC movs pc, lr .endm .macro mask_pc, rd, rm bic \rd, \rm, #PCMASK .endm .macro disable_irq, temp teqp pc, #0x08000003 .endm .macro enable_irq, temp teqp pc, #0x00000003 .endm .macro initialise_traps_extra .endm .macro get_current_task, rd mov \rd, sp, lsr #13 mov \rd, \rd, lsl #13 .endm /* * Like adr, but force SVC mode (if required) */ .macro adrsvc, cond, reg, label adr\cond \reg, \label orr\cond \reg, \reg, #0x08000003 .endm #endif /* * These are the registers used in the syscall handler, and allow us to * have in theory up to 7 arguments to a function - r0 to r6. * * r7 is reserved for the system call number for thumb mode. * * Note that tbl == why is intentional. * * We must set at least "tsk" and "why" when calling ret_with_reschedule. */ scno .req r7 @ syscall number tbl .req r8 @ syscall table pointer why .req r8 @ Linux syscall (!= 0) tsk .req r9 @ current task /* * Get the system call number. */ .macro get_scno #ifdef CONFIG_ARM_THUMB tst r8, #T_BIT @ this is SPSR from save_user_regs addne scno, r7, #OS_NUMBER << 20 @ put OS number in ldreq scno, [lr, #-4] #else mask_pc lr, lr ldr scno, [lr, #-4] @ get SWI instruction #endif .endm