This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / asm-m32r / assembler.h
1 #ifndef _ASM_M32R_ASSEMBLER_H
2 #define _ASM_M32R_ASSEMBLER_H
3
4 /* $Id$ */
5
6 /*
7  * linux/asm-m32r/assembler.h
8  *
9  * This file contains M32R architecture specific defines.
10  *
11  * Do not include any C declarations in this file - it is included by
12  * assembler source.
13  */
14
15 #include <linux/config.h>
16
17
18 #undef ENTRY
19 #define ENTRY(name) ENTRY_M name
20         .macro  ENTRY_M name
21         .global \name
22         ALIGN
23 \name:
24         .endm
25
26 /*
27  * LDIMM: load immediate value
28  *
29  * STI: enable interruption
30  * CLI: disable interruption
31  */
32
33 #ifdef __ASSEMBLY__
34
35 #define LDIMM(reg,x) LDIMM reg x
36         .macro LDIMM reg x
37         seth    \reg, #high(\x)
38         or3     \reg, \reg, #low(\x)
39         .endm
40
41 #if !defined(CONFIG_CHIP_M32102)
42 #define STI(reg) STI_M reg
43         .macro STI_M reg
44         setpsw  #0x40       ->  nop
45         ; WORKAROUND: "-> nop" is a workaround for the M32700(TS1).
46         .endm
47
48 #define CLI(reg) CLI_M reg
49         .macro CLI_M reg
50         clrpsw  #0x40       ->  nop
51         ; WORKAROUND: "-> nop" is a workaround for the M32700(TS1).
52         .endm
53 #else   /* CONFIG_CHIP_M32102 */
54 #define STI(reg) STI_M reg
55         .macro STI_M reg
56         mvfc    \reg, psw
57         or3     \reg, \reg, #0x0040
58         mvtc    \reg, psw
59         .endm
60
61 #define CLI(reg) CLI_M reg
62         .macro CLI_M reg
63         mvfc    \reg, psw
64         and3    \reg, \reg, #0xffbf
65         mvtc    \reg, psw
66         .endm
67 #endif  /* CONFIG_CHIP_M32102 */
68
69         .macro  SAVE_ALL
70         push    r0              ; orig_r0
71         push    sp              ; spi (r15)
72         push    lr              ; r14
73         push    r13
74         mvfc    r13, cr3        ; spu
75         push    r13
76         mvfc    r13, bbpc
77         push    r13
78         mvfc    r13, bbpsw
79         push    r13
80         mvfc    r13, bpc
81         push    r13
82         mvfc    r13, psw
83         push    r13
84 #if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
85         mvfaclo r13, a1
86         push    r13
87         mvfachi r13, a1
88         push    r13
89         mvfaclo r13, a0
90         push    r13
91         mvfachi r13, a0
92         push    r13
93 #elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
94         mvfaclo r13
95         push    r13
96         mvfachi r13
97         push    r13
98 #else
99 #error unknown isa configuration
100 #endif
101         ldi     r13, #-1
102         push    r13             ; syscall_nr (default: -1)
103         push    r12
104         push    r11
105         push    r10
106         push    r9
107         push    r8
108         push    r7
109         push    r3
110         push    r2
111         push    r1
112         push    r0
113         addi    sp, #-4         ; room for implicit pt_regs parameter
114         push    r6
115         push    r5
116         push    r4
117         .endm
118
119         .macro  RESTORE_ALL
120         pop     r4
121         pop     r5
122         pop     r6
123         addi    sp, #4
124         pop     r0
125         pop     r1
126         pop     r2
127         pop     r3
128         pop     r7
129         pop     r8
130         pop     r9
131         pop     r10
132         pop     r11
133         pop     r12
134         addi    r15, #4         ; Skip syscall number
135 #if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
136         pop     r13
137         mvtachi r13, a0
138         pop     r13
139         mvtaclo r13, a0
140         pop     r13
141         mvtachi r13, a1
142         pop     r13
143         mvtaclo r13, a1
144 #elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
145         pop     r13
146         mvtachi r13
147         pop     r13
148         mvtaclo r13
149 #else
150 #error unknown isa configuration
151 #endif
152         pop     r14
153         mvtc    r14, psw
154         pop     r14
155         mvtc    r14, bpc
156         addi    sp, #8          ; Skip bbpsw, bbpc
157         pop     r14
158         mvtc    r14, cr3        ; spu
159         pop     r13
160         pop     lr              ; r14
161         pop     sp              ; spi (r15)
162         addi    sp, #4          ; Skip orig_r0
163         .fillinsn
164 1:      rte
165         .section .fixup,"ax"
166 2:      bl      do_exit
167         .previous
168         .section __ex_table,"a"
169         ALIGN
170         .long   1b, 2b
171         .previous
172         .endm
173
174 #define GET_CURRENT(reg)  get_current reg
175         .macro get_current reg
176         ldi  \reg, #-8192
177         and  \reg, sp
178         .endm
179
180 #if !defined(CONFIG_CHIP_M32102)
181         .macro  SWITCH_TO_KERNEL_STACK
182         ; switch to kernel stack (spi)
183         clrpsw  #0x80       ->  nop
184         .endm
185 #else   /* CONFIG_CHIP_M32102 */
186         .macro  SWITCH_TO_KERNEL_STACK
187         push    r0              ; save r0 for working
188         mvfc    r0, psw
189         and3    r0, r0, #0x00ff7f
190         mvtc    r0, psw
191         slli    r0, #16
192         bltz    r0, 1f          ; check BSM-bit
193 ;
194         ;; called from kernel context: previous stack = spi
195         pop     r0              ; retrieve r0
196         bra     2f
197         .fillinsn
198 1:
199         ;; called from user context: previous stack = spu
200         mvfc    r0, cr3         ; spu
201         addi    r0, #4
202         mvtc    r0, cr3         ; spu
203         ld      r0, @(-4,r0)    ; retrieve r0
204         .fillinsn
205 2:
206         .endm
207 #endif  /* CONFIG_CHIP_M32102 */
208
209 #endif  /* __ASSEMBLY__ */
210
211 #endif  /* _ASM_M32R_ASSEMBLER_H */
212