]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/score/kernel/process.c
sched/headers: Prepare for new header dependencies before moving code to <linux/sched...
[mirror_ubuntu-bionic-kernel.git] / arch / score / kernel / process.c
CommitLineData
6bc9a396
CL
1/*
2 * arch/score/kernel/process.c
3 *
4 * Score Processor version.
5 *
6 * Copyright (C) 2009 Sunplus Core Technology Co., Ltd.
7 * Chen Liqin <liqin.chen@sunplusct.com>
8 * Lennox Wu <lennox.wu@sunplusct.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, see the file COPYING, or write
22 * to the Free Software Foundation, Inc.,
23 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26#include <linux/module.h>
9fb24cc5
AB
27#include <linux/reboot.h>
28#include <linux/elfcore.h>
29#include <linux/pm.h>
0ee23fda 30#include <linux/rcupdate.h>
29930025 31#include <linux/sched/task.h>
6bc9a396
CL
32
33void (*pm_power_off)(void);
34EXPORT_SYMBOL(pm_power_off);
35
36/* If or when software machine-restart is implemented, add code here. */
37void machine_restart(char *command) {}
38
39/* If or when software machine-halt is implemented, add code here. */
40void machine_halt(void) {}
41
42/* If or when software machine-power-off is implemented, add code here. */
43void machine_power_off(void) {}
44
0402c91a 45void ret_from_fork(void);
1856ab6d 46void ret_from_kernel_thread(void);
6bc9a396
CL
47
48void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
49{
50 unsigned long status;
51
52 /* New thread loses kernel privileges. */
53 status = regs->cp0_psr & ~(KU_MASK);
54 status |= KU_USER;
55 regs->cp0_psr = status;
56 regs->cp0_epc = pc;
57 regs->regs[0] = sp;
58}
59
6bc9a396
CL
60/*
61 * When a process does an "exec", machine state like FPU and debug
62 * registers need to be reset. This is a hook function for that.
63 * Currently we don't have any such state to reset, so this is empty.
64 */
65void flush_thread(void) {}
66
67/*
68 * set up the kernel stack and exception frames for a new process
69 */
70int copy_thread(unsigned long clone_flags, unsigned long usp,
afa86fc4 71 unsigned long arg, struct task_struct *p)
6bc9a396
CL
72{
73 struct thread_info *ti = task_thread_info(p);
74 struct pt_regs *childregs = task_pt_regs(p);
afa86fc4 75 struct pt_regs *regs = current_pt_regs();
6bc9a396 76
1856ab6d 77 p->thread.reg0 = (unsigned long) childregs;
eda96977 78 if (unlikely(p->flags & PF_KTHREAD)) {
1856ab6d 79 memset(childregs, 0, sizeof(struct pt_regs));
5fbbf8a1
LW
80 p->thread.reg12 = usp;
81 p->thread.reg13 = arg;
1856ab6d 82 p->thread.reg3 = (unsigned long) ret_from_kernel_thread;
6bc9a396 83 } else {
eda96977 84 *childregs = *current_pt_regs();
1856ab6d
AV
85 childregs->regs[7] = 0; /* Clear error flag */
86 childregs->regs[4] = 0; /* Child gets zero as return value */
eda96977
AV
87 if (usp)
88 childregs->regs[0] = usp; /* user fork */
1856ab6d 89 p->thread.reg3 = (unsigned long) ret_from_fork;
6bc9a396
CL
90 }
91
6bc9a396
CL
92 p->thread.cp0_psr = 0;
93
94 return 0;
95}
96
97/* Fill in the fpu structure for a core dump. */
98int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r)
99{
100 return 1;
101}
102
6bc9a396
CL
103unsigned long thread_saved_pc(struct task_struct *tsk)
104{
105 return task_pt_regs(tsk)->cp0_epc;
106}
107
108unsigned long get_wchan(struct task_struct *task)
109{
110 if (!task || task == current || task->state == TASK_RUNNING)
111 return 0;
112
113 if (!task_stack_page(task))
114 return 0;
115
116 return task_pt_regs(task)->cp0_epc;
117}
118
119unsigned long arch_align_stack(unsigned long sp)
120{
121 return sp;
122}