]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/frv/kernel/process.c
1 /* process.c: FRV specific parts of process handling
3 * Copyright (C) 2003-5 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 * - Derived from arch/m68k/kernel/process.c
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
13 #include <linux/module.h>
14 #include <linux/errno.h>
15 #include <linux/sched.h>
16 #include <linux/sched/debug.h>
17 #include <linux/sched/task.h>
18 #include <linux/kernel.h>
20 #include <linux/smp.h>
21 #include <linux/stddef.h>
22 #include <linux/unistd.h>
23 #include <linux/ptrace.h>
24 #include <linux/slab.h>
25 #include <linux/user.h>
26 #include <linux/elf.h>
27 #include <linux/reboot.h>
28 #include <linux/interrupt.h>
29 #include <linux/pagemap.h>
30 #include <linux/rcupdate.h>
32 #include <asm/asm-offsets.h>
33 #include <linux/uaccess.h>
34 #include <asm/setup.h>
35 #include <asm/pgtable.h>
37 #include <asm/gdb-stub.h>
38 #include <asm/mb-regs.h>
42 asmlinkage
void ret_from_fork(void);
43 asmlinkage
void ret_from_kernel_thread(void);
45 #include <asm/pgalloc.h>
47 void (*pm_power_off
)(void);
48 EXPORT_SYMBOL(pm_power_off
);
50 static void core_sleep_idle(void)
52 #ifdef LED_DEBUG_SLEEP
53 /* Show that we're sleeping... */
57 #ifdef LED_DEBUG_SLEEP
58 /* ... and that we woke up */
64 void arch_cpu_idle(void)
66 if (!frv_dma_inprogress
)
72 void machine_restart(char * __unused
)
74 unsigned long reset_addr
;
79 if (PSR_IMPLE(__get_PSR()) == PSR_IMPLE_FR551
)
80 reset_addr
= 0xfefff500;
82 reset_addr
= 0xfeff0500;
85 asm volatile(" dcef @(gr0,gr0),1 ! membar !"
87 " nop ! nop ! nop ! nop ! nop ! "
88 " nop ! nop ! nop ! nop ! nop ! "
89 " nop ! nop ! nop ! nop ! nop ! "
90 " nop ! nop ! nop ! nop ! nop ! "
91 : : "r" (reset_addr
), "r" (1) );
97 void machine_halt(void)
106 void machine_power_off(void)
108 #ifdef CONFIG_GDBSTUB
115 void flush_thread(void)
120 inline unsigned long user_stack(const struct pt_regs
*regs
)
122 while (regs
->next_frame
)
123 regs
= regs
->next_frame
;
124 return user_mode(regs
) ? regs
->sp
: 0;
128 * set up the kernel stack and exception frames for a new process
130 int copy_thread(unsigned long clone_flags
,
131 unsigned long usp
, unsigned long arg
,
132 struct task_struct
*p
)
134 struct pt_regs
*childregs
;
136 childregs
= (struct pt_regs
*)
137 (task_stack_page(p
) + THREAD_SIZE
- FRV_FRAME0_SIZE
);
139 /* set up the userspace frame (the only place that the USP is stored) */
140 *childregs
= *current_pt_regs();
142 p
->thread
.frame
= childregs
;
144 p
->thread
.sp
= (unsigned long) childregs
;
147 p
->thread
.frame0
= childregs
;
149 if (unlikely(p
->flags
& PF_KTHREAD
)) {
150 childregs
->gr9
= usp
; /* function */
151 childregs
->gr8
= arg
;
152 p
->thread
.pc
= (unsigned long) ret_from_kernel_thread
;
153 save_user_regs(p
->thread
.user
);
158 childregs
->next_frame
= NULL
;
160 p
->thread
.pc
= (unsigned long) ret_from_fork
;
162 /* the new TLS pointer is passed in as arg #5 to sys_clone() */
163 if (clone_flags
& CLONE_SETTLS
)
164 childregs
->gr29
= childregs
->gr12
;
166 save_user_regs(p
->thread
.user
);
169 } /* end copy_thread() */
171 unsigned long get_wchan(struct task_struct
*p
)
173 struct pt_regs
*regs0
;
174 unsigned long fp
, pc
;
175 unsigned long stack_limit
;
177 if (!p
|| p
== current
|| p
->state
== TASK_RUNNING
)
180 stack_limit
= (unsigned long) (p
+ 1);
182 regs0
= p
->thread
.frame0
;
185 if (fp
< stack_limit
|| fp
>= (unsigned long) regs0
|| fp
& 3)
188 pc
= ((unsigned long *) fp
)[2];
190 /* FIXME: This depends on the order of these functions. */
191 if (!in_sched_functions(pc
))
194 fp
= *(unsigned long *) fp
;
195 } while (count
++ < 16);
200 unsigned long thread_saved_pc(struct task_struct
*tsk
)
202 /* Check whether the thread is blocked in resume() */
203 if (in_sched_functions(tsk
->thread
.pc
))
204 return ((unsigned long *)tsk
->thread
.fp
)[2];
206 return tsk
->thread
.pc
;
209 int elf_check_arch(const struct elf32_hdr
*hdr
)
211 unsigned long hsr0
= __get_HSR(0);
212 unsigned long psr
= __get_PSR();
214 if (hdr
->e_machine
!= EM_FRV
)
217 switch (hdr
->e_flags
& EF_FRV_GPR_MASK
) {
219 if ((hsr0
& HSR0_GRN
) == HSR0_GRN_32
)
228 switch (hdr
->e_flags
& EF_FRV_FPR_MASK
) {
230 if ((hsr0
& HSR0_FRN
) == HSR0_FRN_32
)
233 case EF_FRV_FPR_NONE
:
240 if ((hdr
->e_flags
& EF_FRV_MULADD
) == EF_FRV_MULADD
)
241 if (PSR_IMPLE(psr
) != PSR_IMPLE_FR405
&&
242 PSR_IMPLE(psr
) != PSR_IMPLE_FR451
)
245 switch (hdr
->e_flags
& EF_FRV_CPU_MASK
) {
246 case EF_FRV_CPU_GENERIC
:
248 case EF_FRV_CPU_FR300
:
249 case EF_FRV_CPU_SIMPLE
:
250 case EF_FRV_CPU_TOMCAT
:
253 case EF_FRV_CPU_FR400
:
254 if (PSR_IMPLE(psr
) != PSR_IMPLE_FR401
&&
255 PSR_IMPLE(psr
) != PSR_IMPLE_FR405
&&
256 PSR_IMPLE(psr
) != PSR_IMPLE_FR451
&&
257 PSR_IMPLE(psr
) != PSR_IMPLE_FR551
)
260 case EF_FRV_CPU_FR450
:
261 if (PSR_IMPLE(psr
) != PSR_IMPLE_FR451
)
264 case EF_FRV_CPU_FR500
:
265 if (PSR_IMPLE(psr
) != PSR_IMPLE_FR501
)
268 case EF_FRV_CPU_FR550
:
269 if (PSR_IMPLE(psr
) != PSR_IMPLE_FR551
)
277 int dump_fpu(struct pt_regs
*regs
, elf_fpregset_t
*fpregs
)
280 ¤t
->thread
.user
->f
,
281 sizeof(current
->thread
.user
->f
));