2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
6 #include "linux/sched.h"
7 #include "linux/slab.h"
8 #include "linux/ptrace.h"
10 #include "time_user.h"
11 #include "signal_user.h"
14 #include "user_util.h"
20 int singlestepping_skas(void)
22 int ret = current->ptrace & PT_DTRACE;
24 current->ptrace &= ~PT_DTRACE;
28 void *switch_to_skas(void *prev, void *next)
30 struct task_struct *from, *to;
35 /* XXX need to check runqueues[cpu].idle */
39 to->thread.prev_sched = from;
42 switch_threads(&from->thread.mode.skas.switch_buf,
43 to->thread.mode.skas.switch_buf);
48 return(current->thread.prev_sched);
51 extern void schedule_tail(struct task_struct *prev);
53 void new_thread_handler(int sig)
58 fn = current->thread.request.u.thread.proc;
59 arg = current->thread.request.u.thread.arg;
60 change_sig(SIGUSR1, 1);
61 thread_wait(¤t->thread.mode.skas.switch_buf,
62 current->thread.mode.skas.fork_buf);
67 current->thread.prev_sched = NULL;
69 n = run_kernel_thread(fn, arg, ¤t->thread.exec_buf);
71 userspace(¤t->thread.regs.regs);
75 void new_thread_proc(void *stack, void (*handler)(int sig))
77 init_new_thread_stack(stack, handler);
78 os_usr1_process(os_getpid());
81 void release_thread_skas(struct task_struct *task)
85 void exit_thread_skas(void)
89 void fork_handler(int sig)
91 change_sig(SIGUSR1, 1);
92 thread_wait(¤t->thread.mode.skas.switch_buf,
93 current->thread.mode.skas.fork_buf);
97 schedule_tail(current->thread.prev_sched);
99 current->thread.prev_sched = NULL;
102 userspace(¤t->thread.regs.regs);
105 int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
106 unsigned long stack_top, struct task_struct * p,
107 struct pt_regs *regs)
109 void (*handler)(int);
111 if(current->thread.forking){
112 memcpy(&p->thread.regs.regs.skas,
113 ¤t->thread.regs.regs.skas,
114 sizeof(p->thread.regs.regs.skas));
115 REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0);
116 if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp;
118 handler = fork_handler;
121 memcpy(p->thread.regs.regs.skas.regs, exec_regs,
122 sizeof(p->thread.regs.regs.skas.regs));
123 memcpy(p->thread.regs.regs.skas.fp, exec_fp_regs,
124 sizeof(p->thread.regs.regs.skas.fp));
125 memcpy(p->thread.regs.regs.skas.xfp, exec_fpx_regs,
126 sizeof(p->thread.regs.regs.skas.xfp));
127 p->thread.request.u.thread = current->thread.request.u.thread;
128 handler = new_thread_handler;
131 new_thread((void *) p->thread.kernel_stack,
132 &p->thread.mode.skas.switch_buf,
133 &p->thread.mode.skas.fork_buf, handler);
137 void init_idle_skas(void)
139 cpu_tasks[current->thread_info->cpu].pid = os_getpid();
143 extern void start_kernel(void);
145 static int start_kernel_proc(void *unused)
152 cpu_tasks[0].pid = pid;
153 cpu_tasks[0].task = current;
155 cpu_online_map = cpumask_of_cpu(0);
161 int start_uml_skas(void)
164 capture_signal_stack();
166 init_new_thread_signals(1);
169 init_task.thread.request.u.thread.proc = start_kernel_proc;
170 init_task.thread.request.u.thread.arg = NULL;
171 return(start_idle_thread((void *) init_task.thread.kernel_stack,
172 &init_task.thread.mode.skas.switch_buf,
173 &init_task.thread.mode.skas.fork_buf));
176 int external_pid_skas(struct task_struct *task)
178 return(userspace_pid);
181 int thread_pid_skas(struct task_struct *task)
183 return(userspace_pid);
187 * Overrides for Emacs so that we follow Linus's tabbing style.
188 * Emacs will notice this stuff at the end of the file and automatically
189 * adjust the settings for this buffer only. This must remain at the end
191 * ---------------------------------------------------------------------------
193 * c-file-style: "linux"