2 * Copyright (C) 2004-2006 Atmel Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 #ifndef __ASM_AVR32_ASM_H__
9 #define __ASM_AVR32_ASM_H__
11 #include <asm/sysreg.h>
12 #include <asm/asm-offsets.h>
13 #include <asm/thread_info.h>
15 #define mask_interrupts ssrf SR_GM_BIT
16 #define mask_exceptions ssrf SR_EM_BIT
17 #define unmask_interrupts csrf SR_GM_BIT
18 #define unmask_exceptions csrf SR_EM_BIT
20 #ifdef CONFIG_FRAME_POINTER
38 .macro get_thread_info reg
40 andl \reg, ~(THREAD_SIZE - 1) & 0xffff
43 /* Save and restore registers */
44 .macro save_min sr, tmp=lr
51 .macro restore_min sr, tmp=lr
57 .macro save_half sr, tmp=lr
59 pushm r8-r9,r10,r11,r12,lr
65 .macro restore_half sr, tmp=lr
68 popm r8-r9,r10,r11,r12,lr
72 .macro save_full_user sr, tmp=lr
73 stmts --sp, r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,sp,lr
80 .macro restore_full_user sr, tmp=lr
84 ldmts sp++, r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,sp,lr
88 .macro branch_if_kernel scratch, label
89 get_thread_info \scratch
90 ld.w \scratch, \scratch[TI_flags]
91 bld \scratch, TIF_USERSPACE
95 .macro ret_if_privileged scratch, addr, size, ret
96 sub \scratch, \size, 1
102 #endif /* __ASM_AVR32_ASM_H__ */