linux/arch/score/kernel/process.c
<<
>>
Prefs
   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>
  27#include <linux/reboot.h>
  28#include <linux/elfcore.h>
  29#include <linux/pm.h>
  30#include <linux/rcupdate.h>
  31#include <linux/sched/task.h>
  32#include <linux/sched/task_stack.h>
  33
  34void (*pm_power_off)(void);
  35EXPORT_SYMBOL(pm_power_off);
  36
  37/* If or when software machine-restart is implemented, add code here. */
  38void machine_restart(char *command) {}
  39
  40/* If or when software machine-halt is implemented, add code here. */
  41void machine_halt(void) {}
  42
  43/* If or when software machine-power-off is implemented, add code here. */
  44void machine_power_off(void) {}
  45
  46void ret_from_fork(void);
  47void ret_from_kernel_thread(void);
  48
  49void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
  50{
  51        unsigned long status;
  52
  53        /* New thread loses kernel privileges. */
  54        status = regs->cp0_psr & ~(KU_MASK);
  55        status |= KU_USER;
  56        regs->cp0_psr = status;
  57        regs->cp0_epc = pc;
  58        regs->regs[0] = sp;
  59}
  60
  61/*
  62 * When a process does an "exec", machine state like FPU and debug
  63 * registers need to be reset.  This is a hook function for that.
  64 * Currently we don't have any such state to reset, so this is empty.
  65 */
  66void flush_thread(void) {}
  67
  68/*
  69 * set up the kernel stack and exception frames for a new process
  70 */
  71int copy_thread(unsigned long clone_flags, unsigned long usp,
  72                unsigned long arg, struct task_struct *p)
  73{
  74        struct thread_info *ti = task_thread_info(p);
  75        struct pt_regs *childregs = task_pt_regs(p);
  76        struct pt_regs *regs = current_pt_regs();
  77
  78        p->thread.reg0 = (unsigned long) childregs;
  79        if (unlikely(p->flags & PF_KTHREAD)) {
  80                memset(childregs, 0, sizeof(struct pt_regs));
  81                p->thread.reg12 = usp;
  82                p->thread.reg13 = arg;
  83                p->thread.reg3 = (unsigned long) ret_from_kernel_thread;
  84        } else {
  85                *childregs = *current_pt_regs();
  86                childregs->regs[7] = 0;         /* Clear error flag */
  87                childregs->regs[4] = 0;         /* Child gets zero as return value */
  88                if (usp)
  89                        childregs->regs[0] = usp;       /* user fork */
  90                p->thread.reg3 = (unsigned long) ret_from_fork;
  91        }
  92
  93        p->thread.cp0_psr = 0;
  94
  95        return 0;
  96}
  97
  98/* Fill in the fpu structure for a core dump. */
  99int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r)
 100{
 101        return 1;
 102}
 103
 104unsigned long get_wchan(struct task_struct *task)
 105{
 106        if (!task || task == current || task->state == TASK_RUNNING)
 107                return 0;
 108
 109        if (!task_stack_page(task))
 110                return 0;
 111
 112        return task_pt_regs(task)->cp0_epc;
 113}
 114
 115unsigned long arch_align_stack(unsigned long sp)
 116{
 117        return sp;
 118}
 119