diff options
author | Greg Ungerer <gerg@uclinux.org> | 2011-09-02 00:29:34 -0400 |
---|---|---|
committer | Greg Ungerer <gerg@uclinux.org> | 2011-12-24 06:47:56 -0500 |
commit | d25ba98afce7c87afa39f553a3ff8effed87db03 (patch) | |
tree | e7158225d753e7dad7b885116672b4485fb3809e | |
parent | 8d362b0dea1a35bea8d7d281317eb7ccb713edcb (diff) |
m68k: remove thread_info struct from thread struct
Currently on m68k we have a comeplete thread_info structure stored inside
of the thread_struct, and we also have it in the initial part of the kernel
stack. Mostly the code currently uses the one inside of the thread_struct,
only using the "task" pointer from the stack based one.
This is wasteful and confusing, we should only have the single instance of
thread_info inside the stack page. And this is the norm for all other
architectures.
This change makes m68k handle thread_info consistently on both MMU enabled
and non-MMU setups.
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
-rw-r--r-- | arch/m68k/include/asm/processor.h | 2 | ||||
-rw-r--r-- | arch/m68k/include/asm/thread_info.h | 30 | ||||
-rw-r--r-- | arch/m68k/kernel/asm-offsets.c | 2 | ||||
-rw-r--r-- | arch/m68k/kernel/entry_mm.S | 31 |
4 files changed, 22 insertions, 43 deletions
diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h index 568facf30276..7ec06096a6fb 100644 --- a/arch/m68k/include/asm/processor.h +++ b/arch/m68k/include/asm/processor.h | |||
@@ -88,14 +88,12 @@ struct thread_struct { | |||
88 | unsigned long fp[8*3]; | 88 | unsigned long fp[8*3]; |
89 | unsigned long fpcntl[3]; /* fp control regs */ | 89 | unsigned long fpcntl[3]; /* fp control regs */ |
90 | unsigned char fpstate[FPSTATESIZE]; /* floating point state */ | 90 | unsigned char fpstate[FPSTATESIZE]; /* floating point state */ |
91 | struct thread_info info; | ||
92 | }; | 91 | }; |
93 | 92 | ||
94 | #define INIT_THREAD { \ | 93 | #define INIT_THREAD { \ |
95 | .ksp = sizeof(init_stack) + (unsigned long) init_stack, \ | 94 | .ksp = sizeof(init_stack) + (unsigned long) init_stack, \ |
96 | .sr = PS_S, \ | 95 | .sr = PS_S, \ |
97 | .fs = __KERNEL_DS, \ | 96 | .fs = __KERNEL_DS, \ |
98 | .info = INIT_THREAD_INFO(init_task), \ | ||
99 | } | 97 | } |
100 | 98 | ||
101 | #ifdef CONFIG_MMU | 99 | #ifdef CONFIG_MMU |
diff --git a/arch/m68k/include/asm/thread_info.h b/arch/m68k/include/asm/thread_info.h index e4e2159ca6ec..01cef3ceff46 100644 --- a/arch/m68k/include/asm/thread_info.h +++ b/arch/m68k/include/asm/thread_info.h | |||
@@ -47,34 +47,6 @@ struct thread_info { | |||
47 | 47 | ||
48 | #define init_stack (init_thread_union.stack) | 48 | #define init_stack (init_thread_union.stack) |
49 | 49 | ||
50 | #ifdef CONFIG_MMU | ||
51 | |||
52 | #ifndef __ASSEMBLY__ | ||
53 | #include <asm/current.h> | ||
54 | #endif | ||
55 | |||
56 | #ifdef ASM_OFFSETS_C | ||
57 | #define task_thread_info(tsk) ((struct thread_info *) NULL) | ||
58 | #else | ||
59 | #include <asm/asm-offsets.h> | ||
60 | #define task_thread_info(tsk) ((struct thread_info *)((char *)tsk+TASK_INFO)) | ||
61 | #endif | ||
62 | |||
63 | #define init_thread_info (init_task.thread.info) | ||
64 | #define task_stack_page(tsk) ((tsk)->stack) | ||
65 | #define current_thread_info() task_thread_info(current) | ||
66 | |||
67 | #define __HAVE_THREAD_FUNCTIONS | ||
68 | |||
69 | #define setup_thread_stack(p, org) ({ \ | ||
70 | *(struct task_struct **)(p)->stack = (p); \ | ||
71 | task_thread_info(p)->task = (p); \ | ||
72 | }) | ||
73 | |||
74 | #define end_of_stack(p) ((unsigned long *)(p)->stack + 1) | ||
75 | |||
76 | #else /* !CONFIG_MMU */ | ||
77 | |||
78 | #ifndef __ASSEMBLY__ | 50 | #ifndef __ASSEMBLY__ |
79 | /* how to get the thread information struct from C */ | 51 | /* how to get the thread information struct from C */ |
80 | static inline struct thread_info *current_thread_info(void) | 52 | static inline struct thread_info *current_thread_info(void) |
@@ -92,8 +64,6 @@ static inline struct thread_info *current_thread_info(void) | |||
92 | 64 | ||
93 | #define init_thread_info (init_thread_union.thread_info) | 65 | #define init_thread_info (init_thread_union.thread_info) |
94 | 66 | ||
95 | #endif /* CONFIG_MMU */ | ||
96 | |||
97 | /* entry.S relies on these definitions! | 67 | /* entry.S relies on these definitions! |
98 | * bits 0-7 are tested at every exception exit | 68 | * bits 0-7 are tested at every exception exit |
99 | * bits 8-15 are also tested at syscall exit | 69 | * bits 8-15 are also tested at syscall exit |
diff --git a/arch/m68k/kernel/asm-offsets.c b/arch/m68k/kernel/asm-offsets.c index f6a54e203e8e..a972b00cd77d 100644 --- a/arch/m68k/kernel/asm-offsets.c +++ b/arch/m68k/kernel/asm-offsets.c | |||
@@ -24,7 +24,7 @@ int main(void) | |||
24 | /* offsets into the task struct */ | 24 | /* offsets into the task struct */ |
25 | DEFINE(TASK_THREAD, offsetof(struct task_struct, thread)); | 25 | DEFINE(TASK_THREAD, offsetof(struct task_struct, thread)); |
26 | DEFINE(TASK_MM, offsetof(struct task_struct, mm)); | 26 | DEFINE(TASK_MM, offsetof(struct task_struct, mm)); |
27 | DEFINE(TASK_INFO, offsetof(struct task_struct, thread.info)); | 27 | DEFINE(TASK_STACK, offsetof(struct task_struct, stack)); |
28 | 28 | ||
29 | /* offsets into the thread struct */ | 29 | /* offsets into the thread struct */ |
30 | DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp)); | 30 | DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp)); |
diff --git a/arch/m68k/kernel/entry_mm.S b/arch/m68k/kernel/entry_mm.S index c713f514843d..675a854966a6 100644 --- a/arch/m68k/kernel/entry_mm.S +++ b/arch/m68k/kernel/entry_mm.S | |||
@@ -99,7 +99,8 @@ do_trace_exit: | |||
99 | jra .Lret_from_exception | 99 | jra .Lret_from_exception |
100 | 100 | ||
101 | ENTRY(ret_from_signal) | 101 | ENTRY(ret_from_signal) |
102 | tstb %curptr@(TASK_INFO+TINFO_FLAGS+2) | 102 | movel %curptr@(TASK_STACK),%a1 |
103 | tstb %a1@(TINFO_FLAGS+2) | ||
103 | jge 1f | 104 | jge 1f |
104 | jbsr syscall_trace | 105 | jbsr syscall_trace |
105 | 1: RESTORE_SWITCH_STACK | 106 | 1: RESTORE_SWITCH_STACK |
@@ -120,11 +121,13 @@ ENTRY(system_call) | |||
120 | SAVE_ALL_SYS | 121 | SAVE_ALL_SYS |
121 | 122 | ||
122 | GET_CURRENT(%d1) | 123 | GET_CURRENT(%d1) |
124 | movel %d1,%a1 | ||
125 | |||
123 | | save top of frame | 126 | | save top of frame |
124 | movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0) | 127 | movel %sp,%curptr@(TASK_THREAD+THREAD_ESP0) |
125 | 128 | ||
126 | | syscall trace? | 129 | | syscall trace? |
127 | tstb %curptr@(TASK_INFO+TINFO_FLAGS+2) | 130 | tstb %a1@(TINFO_FLAGS+2) |
128 | jmi do_trace_entry | 131 | jmi do_trace_entry |
129 | cmpl #NR_syscalls,%d0 | 132 | cmpl #NR_syscalls,%d0 |
130 | jcc badsys | 133 | jcc badsys |
@@ -133,7 +136,8 @@ syscall: | |||
133 | movel %d0,%sp@(PT_OFF_D0) | save the return value | 136 | movel %d0,%sp@(PT_OFF_D0) | save the return value |
134 | ret_from_syscall: | 137 | ret_from_syscall: |
135 | |oriw #0x0700,%sr | 138 | |oriw #0x0700,%sr |
136 | movew %curptr@(TASK_INFO+TINFO_FLAGS+2),%d0 | 139 | movel %curptr@(TASK_STACK),%a1 |
140 | movew %a1@(TINFO_FLAGS+2),%d0 | ||
137 | jne syscall_exit_work | 141 | jne syscall_exit_work |
138 | 1: RESTORE_ALL | 142 | 1: RESTORE_ALL |
139 | 143 | ||
@@ -159,7 +163,8 @@ ENTRY(ret_from_exception) | |||
159 | andw #ALLOWINT,%sr | 163 | andw #ALLOWINT,%sr |
160 | 164 | ||
161 | resume_userspace: | 165 | resume_userspace: |
162 | moveb %curptr@(TASK_INFO+TINFO_FLAGS+3),%d0 | 166 | movel %curptr@(TASK_STACK),%a1 |
167 | moveb %a1@(TINFO_FLAGS+3),%d0 | ||
163 | jne exit_work | 168 | jne exit_work |
164 | 1: RESTORE_ALL | 169 | 1: RESTORE_ALL |
165 | 170 | ||
@@ -199,7 +204,8 @@ do_delayed_trace: | |||
199 | ENTRY(auto_inthandler) | 204 | ENTRY(auto_inthandler) |
200 | SAVE_ALL_INT | 205 | SAVE_ALL_INT |
201 | GET_CURRENT(%d0) | 206 | GET_CURRENT(%d0) |
202 | addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1) | 207 | movel %d0,%a1 |
208 | addqb #1,%a1@(TINFO_PREEMPT+1) | ||
203 | | put exception # in d0 | 209 | | put exception # in d0 |
204 | bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0 | 210 | bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0 |
205 | subw #VEC_SPUR,%d0 | 211 | subw #VEC_SPUR,%d0 |
@@ -211,7 +217,8 @@ auto_irqhandler_fixup = . + 2 | |||
211 | addql #8,%sp | pop parameters off stack | 217 | addql #8,%sp | pop parameters off stack |
212 | 218 | ||
213 | ret_from_interrupt: | 219 | ret_from_interrupt: |
214 | subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1) | 220 | movel %curptr@(TASK_STACK),%a1 |
221 | subqb #1,%a1@(TINFO_PREEMPT+1) | ||
215 | jeq ret_from_last_interrupt | 222 | jeq ret_from_last_interrupt |
216 | 2: RESTORE_ALL | 223 | 2: RESTORE_ALL |
217 | 224 | ||
@@ -232,7 +239,8 @@ ret_from_last_interrupt: | |||
232 | ENTRY(user_inthandler) | 239 | ENTRY(user_inthandler) |
233 | SAVE_ALL_INT | 240 | SAVE_ALL_INT |
234 | GET_CURRENT(%d0) | 241 | GET_CURRENT(%d0) |
235 | addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1) | 242 | movel %d0,%a1 |
243 | addqb #1,%a1@(TINFO_PREEMPT+1) | ||
236 | | put exception # in d0 | 244 | | put exception # in d0 |
237 | bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0 | 245 | bfextu %sp@(PT_OFF_FORMATVEC){#4,#10},%d0 |
238 | user_irqvec_fixup = . + 2 | 246 | user_irqvec_fixup = . + 2 |
@@ -243,7 +251,8 @@ user_irqvec_fixup = . + 2 | |||
243 | jsr do_IRQ | process the IRQ | 251 | jsr do_IRQ | process the IRQ |
244 | addql #8,%sp | pop parameters off stack | 252 | addql #8,%sp | pop parameters off stack |
245 | 253 | ||
246 | subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1) | 254 | movel %curptr@(TASK_STACK),%a1 |
255 | subqb #1,%a1@(TINFO_PREEMPT+1) | ||
247 | jeq ret_from_last_interrupt | 256 | jeq ret_from_last_interrupt |
248 | RESTORE_ALL | 257 | RESTORE_ALL |
249 | 258 | ||
@@ -252,13 +261,15 @@ user_irqvec_fixup = . + 2 | |||
252 | ENTRY(bad_inthandler) | 261 | ENTRY(bad_inthandler) |
253 | SAVE_ALL_INT | 262 | SAVE_ALL_INT |
254 | GET_CURRENT(%d0) | 263 | GET_CURRENT(%d0) |
255 | addqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1) | 264 | movel %d0,%a1 |
265 | addqb #1,%a1@(TINFO_PREEMPT+1) | ||
256 | 266 | ||
257 | movel %sp,%sp@- | 267 | movel %sp,%sp@- |
258 | jsr handle_badint | 268 | jsr handle_badint |
259 | addql #4,%sp | 269 | addql #4,%sp |
260 | 270 | ||
261 | subqb #1,%curptr@(TASK_INFO+TINFO_PREEMPT+1) | 271 | movel %curptr@(TASK_STACK),%a1 |
272 | subqb #1,%a1@(TINFO_PREEMPT+1) | ||
262 | jeq ret_from_last_interrupt | 273 | jeq ret_from_last_interrupt |
263 | RESTORE_ALL | 274 | RESTORE_ALL |
264 | 275 | ||