lin
2025-06-05 ed3dd9d3e7519a82bb871d5eedb24a2fa0c91f47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Copyright (C) 2004-2006 Atmel Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#ifndef __ASM_AVR32_ASM_H__
#define __ASM_AVR32_ASM_H__
 
#include <asm/sysreg.h>
#include <asm/asm-offsets.h>
#include <asm/thread_info.h>
 
#define mask_interrupts        ssrf    SYSREG_GM_OFFSET
#define mask_exceptions        ssrf    SYSREG_EM_OFFSET
#define unmask_interrupts    csrf    SYSREG_GM_OFFSET
#define unmask_exceptions    csrf    SYSREG_EM_OFFSET
 
#ifdef CONFIG_FRAME_POINTER
   .macro    save_fp
   st.w    --sp, r7
   .endm
   .macro    restore_fp
   ld.w    r7, sp++
   .endm
   .macro    zero_fp
   mov    r7, 0
   .endm
#else
   .macro    save_fp
   .endm
   .macro    restore_fp
   .endm
   .macro    zero_fp
   .endm
#endif
   .macro    get_thread_info reg
   mov    \reg, sp
   andl    \reg, ~(THREAD_SIZE - 1) & 0xffff
   .endm
 
   /* Save and restore registers */
   .macro    save_min sr, tmp=lr
   pushm    lr
   mfsr    \tmp, \sr
   zero_fp
   st.w    --sp, \tmp
   .endm
 
   .macro    restore_min sr, tmp=lr
   ld.w    \tmp, sp++
   mtsr    \sr, \tmp
   popm    lr
   .endm
 
   .macro    save_half sr, tmp=lr
   save_fp
   pushm    r8-r9,r10,r11,r12,lr
   zero_fp
   mfsr    \tmp, \sr
   st.w    --sp, \tmp
   .endm
 
   .macro    restore_half sr, tmp=lr
   ld.w    \tmp, sp++
   mtsr    \sr, \tmp
   popm    r8-r9,r10,r11,r12,lr
   restore_fp
   .endm
 
   .macro    save_full_user sr, tmp=lr
   stmts    --sp, r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,sp,lr
   st.w    --sp, lr
   zero_fp
   mfsr    \tmp, \sr
   st.w    --sp, \tmp
   .endm
 
   .macro    restore_full_user sr, tmp=lr
   ld.w    \tmp, sp++
   mtsr    \sr, \tmp
   ld.w    lr, sp++
   ldmts    sp++, r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,sp,lr
   .endm
 
   /* uaccess macros */
   .macro branch_if_kernel scratch, label
   get_thread_info \scratch
   ld.w    \scratch, \scratch[TI_flags]
   bld    \scratch, TIF_USERSPACE
   brcc    \label
   .endm
 
   .macro ret_if_privileged scratch, addr, size, ret
   sub    \scratch, \size, 1
   add    \scratch, \addr
   retcs    \ret
   retmi    \ret
   .endm
 
#endif /* __ASM_AVR32_ASM_H__ */