]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/mn10300/include/asm/frame.inc
MN10300: And Panasonic AM34 subarch and implement SMP
[mirror_ubuntu-artful-kernel.git] / arch / mn10300 / include / asm / frame.inc
1 /* MN10300 Microcontroller core system register definitions -*- asm -*-
2 *
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11 #ifndef _ASM_FRAME_INC
12 #define _ASM_FRAME_INC
13
14 #ifndef __ASSEMBLY__
15 #error not for use in C files
16 #endif
17
18 #ifndef __ASM_OFFSETS_H__
19 #include <asm/asm-offsets.h>
20 #endif
21 #ifdef CONFIG_SMP
22 #include <proc/smp-regs.h>
23 #endif
24
25 #define pi break
26
27 #define fp a3
28
29 ###############################################################################
30 #
31 # build a stack frame from the registers
32 # - the caller has subtracted 4 from SP before coming here
33 #
34 ###############################################################################
35 .macro SAVE_ALL
36 add -4,sp # next exception frame ptr save area
37 movm [other],(sp)
38 mov usp,a1
39 mov a1,(sp) # USP in MOVM[other] dummy slot
40 movm [d2,d3,a2,a3,exreg0,exreg1,exother],(sp)
41 mov sp,fp # FRAME pointer in A3
42 add -12,sp # allow for calls to be made
43 #ifdef CONFIG_SMP
44 #ifdef CONFIG_PREEMPT /* FIXME */
45 mov epsw,d2
46 and ~EPSW_IE,epsw
47 #endif
48 mov (CPUID),a0
49 add a0,a0
50 add a0,a0
51 mov (___frame,a0),a1
52 mov a1,(REG_NEXT,fp)
53 mov fp,(___frame,a0)
54 #ifdef CONFIG_PREEMPT /* FIXME */
55 mov d2,epsw
56 #endif
57 #else /* CONFIG_SMP */
58 mov (__frame),a1
59 mov a1,(REG_NEXT,fp)
60 mov fp,(__frame)
61 #endif /* CONFIG_SMP */
62
63 and ~EPSW_FE,epsw # disable the FPU inside the kernel
64
65 # we may be holding current in E2
66 #ifdef CONFIG_MN10300_CURRENT_IN_E2
67 mov (__current),e2
68 #endif
69 .endm
70
71 ###############################################################################
72 #
73 # restore the registers from a stack frame
74 #
75 ###############################################################################
76 .macro RESTORE_ALL
77 # peel back the stack to the calling frame
78 # - this permits execve() to discard extra frames due to kernel syscalls
79 #ifdef CONFIG_SMP
80 #ifdef CONFIG_PREEMPT /* FIXME */
81 mov epsw,d2
82 and ~EPSW_IE,epsw
83 #endif
84 mov (CPUID),a0
85 add a0,a0
86 add a0,a0
87 mov (___frame,a0),fp
88 mov fp,sp
89 mov (REG_NEXT,fp),d0 # userspace has regs->next == 0
90 mov d0,(___frame,a0)
91 #ifdef CONFIG_PREEMPT /* FIXME */
92 mov d2,epsw
93 #endif
94 #else /* CONFIG_SMP */
95 mov (__frame),fp
96 mov fp,sp
97 mov (REG_NEXT,fp),d0 # userspace has regs->next == 0
98 mov d0,(__frame)
99 #endif /* CONFIG_SMP */
100
101 #ifndef CONFIG_MN10300_USING_JTAG
102 mov (REG_EPSW,fp),d0
103 btst EPSW_T,d0
104 beq 99f
105
106 or EPSW_NMID,epsw
107 movhu (DCR),d1
108 or 0x0001, d1
109 movhu d1,(DCR)
110
111 99:
112 #endif
113 movm (sp),[d2,d3,a2,a3,exreg0,exreg1,exother]
114
115 # must restore usp even if returning to kernel space,
116 # when CONFIG_PREEMPT is enabled.
117 mov (sp),a1 # USP in MOVM[other] dummy slot
118 mov a1,usp
119
120 movm (sp),[other]
121 add 8,sp
122 rti
123
124 .endm
125
126
127 #endif /* _ASM_FRAME_INC */