0001
0002
0003
0004 #include <linux/module.h>
0005 #include <linux/sched.h>
0006 #include <linux/sched/task_stack.h>
0007 #include <linux/sched/debug.h>
0008 #include <linux/delay.h>
0009 #include <linux/kallsyms.h>
0010 #include <linux/uaccess.h>
0011 #include <linux/ptrace.h>
0012
0013 #include <asm/elf.h>
0014 #include <abi/reg_ops.h>
0015
0016 struct cpuinfo_csky cpu_data[NR_CPUS];
0017
0018 #ifdef CONFIG_STACKPROTECTOR
0019 #include <linux/stackprotector.h>
0020 unsigned long __stack_chk_guard __read_mostly;
0021 EXPORT_SYMBOL(__stack_chk_guard);
0022 #endif
0023
0024 asmlinkage void ret_from_fork(void);
0025 asmlinkage void ret_from_kernel_thread(void);
0026
0027
0028
0029
0030 void flush_thread(void){}
0031
0032 int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
0033 {
0034 unsigned long clone_flags = args->flags;
0035 unsigned long usp = args->stack;
0036 unsigned long tls = args->tls;
0037 struct switch_stack *childstack;
0038 struct pt_regs *childregs = task_pt_regs(p);
0039
0040 #ifdef CONFIG_CPU_HAS_FPU
0041 save_to_user_fp(&p->thread.user_fp);
0042 #endif
0043
0044 childstack = ((struct switch_stack *) childregs) - 1;
0045 memset(childstack, 0, sizeof(struct switch_stack));
0046
0047
0048 p->thread.sp = (unsigned long)childstack;
0049
0050 if (unlikely(args->fn)) {
0051 memset(childregs, 0, sizeof(struct pt_regs));
0052 childstack->r15 = (unsigned long) ret_from_kernel_thread;
0053 childstack->r10 = (unsigned long) args->fn_arg;
0054 childstack->r9 = (unsigned long) args->fn;
0055 childregs->sr = mfcr("psr");
0056 } else {
0057 *childregs = *(current_pt_regs());
0058 if (usp)
0059 childregs->usp = usp;
0060 if (clone_flags & CLONE_SETTLS)
0061 task_thread_info(p)->tp_value = childregs->tls
0062 = tls;
0063
0064 childregs->a0 = 0;
0065 childstack->r15 = (unsigned long) ret_from_fork;
0066 }
0067
0068 return 0;
0069 }
0070
0071
0072 int dump_fpu(struct pt_regs *regs, struct user_fp *fpu)
0073 {
0074 memcpy(fpu, ¤t->thread.user_fp, sizeof(*fpu));
0075 return 1;
0076 }
0077 EXPORT_SYMBOL(dump_fpu);
0078
0079 int dump_task_regs(struct task_struct *tsk, elf_gregset_t *pr_regs)
0080 {
0081 struct pt_regs *regs = task_pt_regs(tsk);
0082
0083
0084 ELF_CORE_COPY_REGS((*pr_regs), regs)
0085
0086 return 1;
0087 }
0088
0089 #ifndef CONFIG_CPU_PM_NONE
0090 void arch_cpu_idle(void)
0091 {
0092 #ifdef CONFIG_CPU_PM_WAIT
0093 asm volatile("wait\n");
0094 #endif
0095
0096 #ifdef CONFIG_CPU_PM_DOZE
0097 asm volatile("doze\n");
0098 #endif
0099
0100 #ifdef CONFIG_CPU_PM_STOP
0101 asm volatile("stop\n");
0102 #endif
0103 raw_local_irq_enable();
0104 }
0105 #endif