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);
64 if(current->thread.prev_sched != NULL)
65 schedule_tail(current->thread.prev_sched);
66 current->thread.prev_sched = NULL;
68 /* The return value is 1 if the kernel thread execs a process,
71 n = run_kernel_thread(fn, arg, ¤t->thread.exec_buf);
73 userspace(¤t->thread.regs.regs);
77 void new_thread_proc(void *stack, void (*handler)(int sig))
79 init_new_thread_stack(stack, handler);
80 os_usr1_process(os_getpid());
83 void release_thread_skas(struct task_struct *task)
87 void exit_thread_skas(void)
91 void fork_handler(int sig)
93 change_sig(SIGUSR1, 1);
94 thread_wait(¤t->thread.mode.skas.switch_buf,
95 current->thread.mode.skas.fork_buf);
98 if(current->thread.prev_sched == NULL)
101 schedule_tail(current->thread.prev_sched);
102 current->thread.prev_sched = NULL;
104 userspace(¤t->thread.regs.regs);
107 int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
108 unsigned long stack_top, struct task_struct * p,
109 struct pt_regs *regs)
111 void (*handler)(int);
113 if(current->thread.forking){
114 memcpy(&p->thread.regs.regs.skas,
115 ¤t->thread.regs.regs.skas,
116 sizeof(p->thread.regs.regs.skas));
117 REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0);
118 if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp;
120 handler = fork_handler;
123 memcpy(p->thread.regs.regs.skas.regs, exec_regs,
124 sizeof(p->thread.regs.regs.skas.regs));
125 memcpy(p->thread.regs.regs.skas.fp, exec_fp_regs,
126 sizeof(p->thread.regs.regs.skas.fp));
127 memcpy(p->thread.regs.regs.skas.xfp, exec_fpx_regs,
128 sizeof(p->thread.regs.regs.skas.xfp));
129 p->thread.request.u.thread = current->thread.request.u.thread;
130 handler = new_thread_handler;
133 new_thread((void *) p->thread.kernel_stack,
134 &p->thread.mode.skas.switch_buf,
135 &p->thread.mode.skas.fork_buf, handler);
139 void init_idle_skas(void)
141 cpu_tasks[current_thread->cpu].pid = os_getpid();
145 extern void start_kernel(void);
147 static int start_kernel_proc(void *unused)
154 cpu_tasks[0].pid = pid;
155 cpu_tasks[0].task = current;
157 cpu_online_map = cpumask_of_cpu(0);
163 int start_uml_skas(void)
166 capture_signal_stack();
169 init_new_thread_signals(1);
171 init_task.thread.request.u.thread.proc = start_kernel_proc;
172 init_task.thread.request.u.thread.arg = NULL;
173 return(start_idle_thread((void *) init_task.thread.kernel_stack,
174 &init_task.thread.mode.skas.switch_buf,
175 &init_task.thread.mode.skas.fork_buf));
178 int external_pid_skas(struct task_struct *task)
180 #warning Need to look up userspace_pid by cpu
181 return(userspace_pid[0]);
184 int thread_pid_skas(struct task_struct *task)
186 #warning Need to look up userspace_pid by cpu
187 return(userspace_pid[0]);
191 * Overrides for Emacs so that we follow Linus's tabbing style.
192 * Emacs will notice this stuff at the end of the file and automatically
193 * adjust the settings for this buffer only. This must remain at the end
195 * ---------------------------------------------------------------------------
197 * c-file-style: "linux"