The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/arch/score/kernel/process.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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 
   32 void (*pm_power_off)(void);
   33 EXPORT_SYMBOL(pm_power_off);
   34 
   35 /* If or when software machine-restart is implemented, add code here. */
   36 void machine_restart(char *command) {}
   37 
   38 /* If or when software machine-halt is implemented, add code here. */
   39 void machine_halt(void) {}
   40 
   41 /* If or when software machine-power-off is implemented, add code here. */
   42 void machine_power_off(void) {}
   43 
   44 /*
   45  * The idle thread. There's no useful work to be
   46  * done, so just try to conserve power and have a
   47  * low exit latency (ie sit in a loop waiting for
   48  * somebody to say that they'd like to reschedule)
   49  */
   50 void __noreturn cpu_idle(void)
   51 {
   52         /* endless idle loop with no priority at all */
   53         while (1) {
   54                 rcu_idle_enter();
   55                 while (!need_resched())
   56                         barrier();
   57                 rcu_idle_exit();
   58                 schedule_preempt_disabled();
   59         }
   60 }
   61 
   62 void ret_from_fork(void);
   63 void ret_from_kernel_thread(void);
   64 
   65 void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
   66 {
   67         unsigned long status;
   68 
   69         /* New thread loses kernel privileges. */
   70         status = regs->cp0_psr & ~(KU_MASK);
   71         status |= KU_USER;
   72         regs->cp0_psr = status;
   73         regs->cp0_epc = pc;
   74         regs->regs[0] = sp;
   75 }
   76 
   77 void exit_thread(void) {}
   78 
   79 /*
   80  * When a process does an "exec", machine state like FPU and debug
   81  * registers need to be reset.  This is a hook function for that.
   82  * Currently we don't have any such state to reset, so this is empty.
   83  */
   84 void flush_thread(void) {}
   85 
   86 /*
   87  * set up the kernel stack and exception frames for a new process
   88  */
   89 int copy_thread(unsigned long clone_flags, unsigned long usp,
   90                 unsigned long arg, struct task_struct *p)
   91 {
   92         struct thread_info *ti = task_thread_info(p);
   93         struct pt_regs *childregs = task_pt_regs(p);
   94         struct pt_regs *regs = current_pt_regs();
   95 
   96         p->thread.reg0 = (unsigned long) childregs;
   97         if (unlikely(p->flags & PF_KTHREAD)) {
   98                 memset(childregs, 0, sizeof(struct pt_regs));
   99                 p->thread->reg12 = usp;
  100                 p->thread->reg13 = arg;
  101                 p->thread.reg3 = (unsigned long) ret_from_kernel_thread;
  102         } else {
  103                 *childregs = *current_pt_regs();
  104                 childregs->regs[7] = 0;         /* Clear error flag */
  105                 childregs->regs[4] = 0;         /* Child gets zero as return value */
  106                 if (usp)
  107                         childregs->regs[0] = usp;       /* user fork */
  108                 p->thread.reg3 = (unsigned long) ret_from_fork;
  109         }
  110 
  111         p->thread.cp0_psr = 0;
  112 
  113         return 0;
  114 }
  115 
  116 /* Fill in the fpu structure for a core dump. */
  117 int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r)
  118 {
  119         return 1;
  120 }
  121 
  122 unsigned long thread_saved_pc(struct task_struct *tsk)
  123 {
  124         return task_pt_regs(tsk)->cp0_epc;
  125 }
  126 
  127 unsigned long get_wchan(struct task_struct *task)
  128 {
  129         if (!task || task == current || task->state == TASK_RUNNING)
  130                 return 0;
  131 
  132         if (!task_stack_page(task))
  133                 return 0;
  134 
  135         return task_pt_regs(task)->cp0_epc;
  136 }
  137 
  138 unsigned long arch_align_stack(unsigned long sp)
  139 {
  140         return sp;
  141 }

Cache object: e3d0cb90cb7f0d47e4489694fbcc8ab0


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.