Commit 77bf4400 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds
Browse files

uml: remove code made redundant by CHOOSE_MODE removal



This patch makes a number of simplifications enabled by the removal of
CHOOSE_MODE.  There were lots of functions that looked like

	int foo(args){
		foo_skas(args);
	}

The bodies of foo_skas are now folded into foo, and their declarations (and
sometimes entire header files) are deleted.

In addition, the union uml_pt_regs, which was a union between the tt and skas
register formats, is now a struct, with the tt-mode arm of the union being
removed.

It turns out that usr2_handler was unused, so it is gone.
Signed-off-by: default avatarJeff Dike <jdike@linux.intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ae2587e4
......@@ -9,7 +9,6 @@
#include "user.h"
#include "mconsole.h"
#include "os.h"
#include "mode.h"
struct dog_data {
int stdin;
......
......@@ -9,7 +9,7 @@
#include "sysdep/ptrace.h"
extern void arch_check_bugs(void);
extern int arch_fixup(unsigned long address, union uml_pt_regs *regs);
extern int arch_handle_signal(int sig, union uml_pt_regs *regs);
extern int arch_fixup(unsigned long address, struct uml_pt_regs *regs);
extern int arch_handle_signal(int sig, struct uml_pt_regs *regs);
#endif
......@@ -29,6 +29,6 @@ extern unsigned long brk_start;
extern int linux_main(int argc, char **argv);
extern void (*sig_info[])(int, union uml_pt_regs *);
extern void (*sig_info[])(int, struct uml_pt_regs *);
#endif
......@@ -21,7 +21,7 @@ struct irq_fd {
enum { IRQ_READ, IRQ_WRITE };
extern void sigio_handler(int sig, union uml_pt_regs *regs);
extern void sigio_handler(int sig, struct uml_pt_regs *regs);
extern int activate_fd(int irq, int fd, int type, void *dev_id);
extern void free_irq_by_irq_and_dev(unsigned int irq, void *dev_id);
extern void free_irq_by_fd(int fd);
......
......@@ -10,7 +10,7 @@
#include "sysdep/faultinfo.h"
#include "uml-config.h"
typedef void (*kern_hndl)(int, union uml_pt_regs *);
typedef void (*kern_hndl)(int, struct uml_pt_regs *);
struct kern_handlers {
kern_hndl relay_signal;
......@@ -41,7 +41,7 @@ extern unsigned long alloc_stack(int order, int atomic);
extern int do_signal(void);
extern int is_stack_fault(unsigned long sp);
extern unsigned long segv(struct faultinfo fi, unsigned long ip,
int is_user, union uml_pt_regs *regs);
int is_user, struct uml_pt_regs *regs);
extern int handle_page_fault(unsigned long address, unsigned long ip,
int is_write, int is_user, int *code_out);
extern void syscall_ready(void);
......@@ -54,7 +54,7 @@ extern int need_finish_fork(void);
extern void free_stack(unsigned long stack, int order);
extern void add_input_request(int op, void (*proc)(int), void *arg);
extern char *current_cmd(void);
extern void timer_handler(int sig, union uml_pt_regs *regs);
extern void timer_handler(int sig, struct uml_pt_regs *regs);
extern int set_signals(int enable);
extern int pid_to_processor_id(int pid);
extern void deliver_signals(void *t);
......@@ -64,9 +64,9 @@ extern void finish_fork(void);
extern void paging_init(void);
extern void init_flush_vm(void);
extern void *syscall_sp(void *t);
extern void syscall_trace(union uml_pt_regs *regs, int entryexit);
extern void syscall_trace(struct uml_pt_regs *regs, int entryexit);
extern int hz(void);
extern unsigned int do_IRQ(int irq, union uml_pt_regs *regs);
extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs);
extern void interrupt_end(void);
extern void initial_thread_cb(void (*proc)(void *), void *arg);
extern int debugger_signal(int status, int pid);
......@@ -76,9 +76,9 @@ extern int init_ptrace_proxy(int idle_pid, int startup, int stop);
extern int init_parent_proxy(int pid);
extern int singlestepping(void *t);
extern void check_stack_overflow(void *ptr);
extern void relay_signal(int sig, union uml_pt_regs *regs);
extern void relay_signal(int sig, struct uml_pt_regs *regs);
extern int user_context(unsigned long sp);
extern void timer_irq(union uml_pt_regs *regs);
extern void timer_irq(struct uml_pt_regs *regs);
extern void do_uml_exitcalls(void);
extern int attach_debugger(int idle_pid, int pid, int stop);
extern int config_gdb(char *str);
......@@ -109,11 +109,9 @@ extern void time_init_kern(void);
/* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */
extern int __cant_sleep(void);
extern void sigio_handler(int sig, union uml_pt_regs *regs);
extern void copy_sc(union uml_pt_regs *regs, void *from);
extern void sigio_handler(int sig, struct uml_pt_regs *regs);
extern void copy_sc(struct uml_pt_regs *regs, void *from);
extern unsigned long to_irq_stack(unsigned long *mask_out);
unsigned long from_irq_stack(int nested);
extern int start_uml(void);
#endif
......@@ -63,7 +63,7 @@ struct mc_request
struct mconsole_request request;
struct mconsole_command *cmd;
union uml_pt_regs regs;
struct uml_pt_regs regs;
};
extern char mconsole_socket_name[];
......
/*
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
#ifndef __MODE_H__
#define __MODE_H__
#include "mode-skas.h"
#endif
/*
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
#ifndef __MODE_KERN_H__
#define __MODE_KERN_H__
#include "mode_kern_skas.h"
#endif
......@@ -281,9 +281,9 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr,
extern int is_skas_winch(int pid, int fd, void *data);
extern int start_userspace(unsigned long stub_stack);
extern int copy_context_skas0(unsigned long stack, int pid);
extern void save_registers(int pid, union uml_pt_regs *regs);
extern void restore_registers(int pid, union uml_pt_regs *regs);
extern void userspace(union uml_pt_regs *regs);
extern void save_registers(int pid, struct uml_pt_regs *regs);
extern void restore_registers(int pid, struct uml_pt_regs *regs);
extern void userspace(struct uml_pt_regs *regs);
extern void map_stub_pages(int fd, unsigned long code,
unsigned long data, unsigned long stack);
extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void));
......
......@@ -9,11 +9,11 @@
#include "sysdep/ptrace.h"
#include "sysdep/archsetjmp.h"
extern void init_thread_registers(union uml_pt_regs *to);
extern void init_thread_registers(struct uml_pt_regs *to);
extern int save_fp_registers(int pid, unsigned long *fp_regs);
extern int restore_fp_registers(int pid, unsigned long *fp_regs);
extern void save_registers(int pid, union uml_pt_regs *regs);
extern void restore_registers(int pid, union uml_pt_regs *regs);
extern void save_registers(int pid, struct uml_pt_regs *regs);
extern void restore_registers(int pid, struct uml_pt_regs *regs);
extern void init_registers(int pid);
extern void get_safe_registers(unsigned long *regs);
extern unsigned long get_thread_reg(int reg, jmp_buf *buf);
......
......@@ -18,6 +18,6 @@ struct mmu_context_skas {
uml_ldt_t ldt;
};
extern void switch_mm_skas(struct mm_id * mm_idp);
extern void __switch_mm(struct mm_id * mm_idp);
#endif
/*
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
* Licensed under the GPL
*/
#ifndef __SKAS_MODE_KERN_H__
#define __SKAS_MODE_KERN_H__
#include "linux/sched.h"
#include "asm/page.h"
#include "asm/ptrace.h"
#include "mem_user.h"
extern void flush_thread_skas(void);
extern void switch_to_skas(void *prev, void *next);
extern void start_thread_skas(struct pt_regs *regs, unsigned long eip,
unsigned long esp);
extern int copy_thread_skas(int nr, unsigned long clone_flags,
unsigned long sp, unsigned long stack_top,
struct task_struct *p, struct pt_regs *regs);
extern void release_thread_skas(struct task_struct *task);
extern void init_idle_skas(void);
extern void flush_tlb_kernel_range_skas(unsigned long start,
unsigned long end);
extern void flush_tlb_kernel_vm_skas(void);
extern void __flush_tlb_one_skas(unsigned long addr);
extern void flush_tlb_range_skas(struct vm_area_struct *vma,
unsigned long start, unsigned long end);
extern void flush_tlb_mm_skas(struct mm_struct *mm);
extern void force_flush_all_skas(void);
extern long execute_syscall_skas(void *r);
extern void before_mem_skas(unsigned long unused);
extern unsigned long set_task_sizes_skas(unsigned long *task_size_out);
extern int start_uml_skas(void);
extern int external_pid_skas(struct task_struct *task);
extern int thread_pid_skas(struct task_struct *task);
extern void flush_tlb_page_skas(struct vm_area_struct *vma,
unsigned long address);
#define kmem_end_skas (host_task_size - 1024 * 1024)
#endif
......@@ -15,7 +15,7 @@ extern int skas_needs_stub;
extern int user_thread(unsigned long stack, int flags);
extern void new_thread_handler(void);
extern void handle_syscall(union uml_pt_regs *regs);
extern void handle_syscall(struct uml_pt_regs *regs);
extern int new_mm(unsigned long stack);
extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
extern long execute_syscall_skas(void *r);
......
......@@ -52,37 +52,34 @@ extern int sysemu_supported;
#define PTRACE_SYSEMU_SINGLESTEP 32
#endif
union uml_pt_regs {
struct skas_regs {
unsigned long regs[MAX_REG_NR];
unsigned long fp[HOST_FP_SIZE];
unsigned long xfp[HOST_XFP_SIZE];
struct faultinfo faultinfo;
long syscall;
int is_user;
} skas;
struct uml_pt_regs {
unsigned long regs[MAX_REG_NR];
unsigned long fp[HOST_FP_SIZE];
unsigned long xfp[HOST_XFP_SIZE];
struct faultinfo faultinfo;
long syscall;
int is_user;
};
#define EMPTY_UML_PT_REGS { }
#define UPT_SC(r) ((r)->tt.sc)
#define UPT_IP(r) REGS_IP((r)->skas.regs)
#define UPT_SP(r) REGS_SP((r)->skas.regs)
#define UPT_EFLAGS(r) REGS_EFLAGS((r)->skas.regs)
#define UPT_EAX(r) REGS_EAX((r)->skas.regs)
#define UPT_EBX(r) REGS_EBX((r)->skas.regs)
#define UPT_ECX(r) REGS_ECX((r)->skas.regs)
#define UPT_EDX(r) REGS_EDX((r)->skas.regs)
#define UPT_ESI(r) REGS_ESI((r)->skas.regs)
#define UPT_EDI(r) REGS_EDI((r)->skas.regs)
#define UPT_EBP(r) REGS_EBP((r)->skas.regs)
#define UPT_ORIG_EAX(r) ((r)->skas.syscall)
#define UPT_CS(r) REGS_CS((r)->skas.regs)
#define UPT_SS(r) REGS_SS((r)->skas.regs)
#define UPT_DS(r) REGS_DS((r)->skas.regs)
#define UPT_ES(r) REGS_ES((r)->skas.regs)
#define UPT_FS(r) REGS_FS((r)->skas.regs)
#define UPT_GS(r) REGS_GS((r)->skas.regs)
#define UPT_IP(r) REGS_IP((r)->regs)
#define UPT_SP(r) REGS_SP((r)->regs)
#define UPT_EFLAGS(r) REGS_EFLAGS((r)->regs)
#define UPT_EAX(r) REGS_EAX((r)->regs)
#define UPT_EBX(r) REGS_EBX((r)->regs)
#define UPT_ECX(r) REGS_ECX((r)->regs)
#define UPT_EDX(r) REGS_EDX((r)->regs)
#define UPT_ESI(r) REGS_ESI((r)->regs)
#define UPT_EDI(r) REGS_EDI((r)->regs)
#define UPT_EBP(r) REGS_EBP((r)->regs)
#define UPT_ORIG_EAX(r) ((r)->syscall)
#define UPT_CS(r) REGS_CS((r)->regs)
#define UPT_SS(r) REGS_SS((r)->regs)
#define UPT_DS(r) REGS_DS((r)->regs)
#define UPT_ES(r) REGS_ES((r)->regs)
#define UPT_FS(r) REGS_FS((r)->regs)
#define UPT_GS(r) REGS_GS((r)->regs)
#define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
#define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
......@@ -93,7 +90,7 @@ union uml_pt_regs {
extern int user_context(unsigned long sp);
#define UPT_IS_USER(r) ((r)->skas.is_user)
#define UPT_IS_USER(r) ((r)->is_user)
struct syscall_args {
unsigned long args[6];
......@@ -162,14 +159,14 @@ struct syscall_args {
} while (0)
#define UPT_SET_SYSCALL_RETURN(r, res) \
REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res))
REGS_SET_SYSCALL_RETURN((r)->regs, (res))
#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->skas.regs)
#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->regs)
#define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
#define UPT_SYSCALL_RET(r) UPT_EAX(r)
#define UPT_FAULTINFO(r) (&(r)->skas.faultinfo)
#define UPT_FAULTINFO(r) (&(r)->faultinfo)
#endif
......@@ -84,58 +84,52 @@
#define REGS_ERR(r) ((r)->fault_type)
/* XXX */
union uml_pt_regs {
struct skas_regs {
unsigned long regs[MAX_REG_NR];
unsigned long fp[HOST_FP_SIZE];
struct faultinfo faultinfo;
long syscall;
int is_user;
} skas;
struct uml_pt_regs {
unsigned long regs[MAX_REG_NR];
unsigned long fp[HOST_FP_SIZE];
struct faultinfo faultinfo;
long syscall;
int is_user;
};
#define EMPTY_UML_PT_REGS { }
#define UPT_RBX(r) REGS_RBX((r)->skas.regs)
#define UPT_RCX(r) REGS_RCX((r)->skas.regs)
#define UPT_RDX(r) REGS_RDX((r)->skas.regs)
#define UPT_RSI(r) REGS_RSI((r)->skas.regs)
#define UPT_RDI(r) REGS_RDI((r)->skas.regs)
#define UPT_RBP(r) REGS_RBP((r)->skas.regs)
#define UPT_RAX(r) REGS_RAX((r)->skas.regs)
#define UPT_R8(r) REGS_R8((r)->skas.regs)
#define UPT_R9(r) REGS_R9((r)->skas.regs)
#define UPT_R10(r) REGS_R10((r)->skas.regs)
#define UPT_R11(r) REGS_R11((r)->skas.regs)
#define UPT_R12(r) REGS_R12((r)->skas.regs)
#define UPT_R13(r) REGS_R13((r)->skas.regs)
#define UPT_R14(r) REGS_R14((r)->skas.regs)
#define UPT_R15(r) REGS_R15((r)->skas.regs)
#define UPT_CS(r) REGS_CS((r)->skas.regs)
#define UPT_FS_BASE(r) \
REGS_FS_BASE((r)->skas.regs)
#define UPT_FS(r) REGS_FS((r)->skas.regs)
#define UPT_GS_BASE(r) \
REGS_GS_BASE((r)->skas.regs)
#define UPT_GS(r) REGS_GS((r)->skas.regs)
#define UPT_DS(r) REGS_DS((r)->skas.regs)
#define UPT_ES(r) REGS_ES((r)->skas.regs)
#define UPT_CS(r) REGS_CS((r)->skas.regs)
#define UPT_SS(r) REGS_SS((r)->skas.regs)
#define UPT_ORIG_RAX(r) REGS_ORIG_RAX((r)->skas.regs)
#define UPT_IP(r) REGS_IP((r)->skas.regs)
#define UPT_SP(r) REGS_SP((r)->skas.regs)
#define UPT_EFLAGS(r) REGS_EFLAGS((r)->skas.regs)
#define UPT_SC(r) ((r)->tt.sc)
#define UPT_SYSCALL_NR(r) ((r)->skas.syscall)
#define UPT_RBX(r) REGS_RBX((r)->regs)
#define UPT_RCX(r) REGS_RCX((r)->regs)
#define UPT_RDX(r) REGS_RDX((r)->regs)
#define UPT_RSI(r) REGS_RSI((r)->regs)
#define UPT_RDI(r) REGS_RDI((r)->regs)
#define UPT_RBP(r) REGS_RBP((r)->regs)
#define UPT_RAX(r) REGS_RAX((r)->regs)
#define UPT_R8(r) REGS_R8((r)->regs)
#define UPT_R9(r) REGS_R9((r)->regs)
#define UPT_R10(r) REGS_R10((r)->regs)
#define UPT_R11(r) REGS_R11((r)->regs)
#define UPT_R12(r) REGS_R12((r)->regs)
#define UPT_R13(r) REGS_R13((r)->regs)
#define UPT_R14(r) REGS_R14((r)->regs)
#define UPT_R15(r) REGS_R15((r)->regs)
#define UPT_CS(r) REGS_CS((r)->regs)
#define UPT_FS_BASE(r) REGS_FS_BASE((r)->regs)
#define UPT_FS(r) REGS_FS((r)->regs)
#define UPT_GS_BASE(r) REGS_GS_BASE((r)->regs)
#define UPT_GS(r) REGS_GS((r)->regs)
#define UPT_DS(r) REGS_DS((r)->regs)
#define UPT_ES(r) REGS_ES((r)->regs)
#define UPT_CS(r) REGS_CS((r)->regs)
#define UPT_SS(r) REGS_SS((r)->regs)
#define UPT_ORIG_RAX(r) REGS_ORIG_RAX((r)->regs)
#define UPT_IP(r) REGS_IP((r)->regs)
#define UPT_SP(r) REGS_SP((r)->regs)
#define UPT_EFLAGS(r) REGS_EFLAGS((r)->regs)
#define UPT_SYSCALL_NR(r) ((r)->syscall)
#define UPT_SYSCALL_RET(r) UPT_RAX(r)
extern int user_context(unsigned long sp);
#define UPT_IS_USER(r) ((r)->skas.is_user)
#define UPT_IS_USER(r) ((r)->is_user)
#define UPT_SYSCALL_ARG1(r) UPT_RDI(r)
#define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
......@@ -232,12 +226,12 @@ struct syscall_args {
})
#define UPT_SET_SYSCALL_RETURN(r, res) \
REGS_SET_SYSCALL_RETURN((r)->skas.regs, (res))
REGS_SET_SYSCALL_RETURN((r)->regs, (res))
#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->skas.regs)
#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->regs)
#define UPT_SEGV_IS_FIXABLE(r) REGS_SEGV_IS_FIXABLE(&r->skas)
#define UPT_FAULTINFO(r) (&(r)->skas.faultinfo)
#define UPT_FAULTINFO(r) (&(r)->faultinfo)
#endif
......@@ -3,7 +3,7 @@
#include <kern_constants.h>
#define TASK_REGS(task) ((union uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS]))
#define TASK_REGS(task) ((struct uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS]))
#define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID]))
#endif
......@@ -18,17 +18,31 @@
#include "irq_user.h"
#include "tlb.h"
#include "os.h"
#include "mode_kern.h"
#include "skas/skas.h"
void flush_thread(void)
{
void *data = NULL;
unsigned long end = proc_mm ? task_size : CONFIG_STUB_START;
int ret;
arch_flush_thread(&current->thread.arch);
flush_thread_skas();
ret = unmap(&current->mm->context.skas.id, 0, end, 1, &data);
if(ret){
printk("flush_thread - clearing address space failed, "
"err = %d\n", ret);
force_sig(SIGKILL, current);
}
__switch_mm(&current->mm->context.skas.id);
}
void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
{
start_thread_skas(regs, eip, esp);
set_fs(USER_DS);
PT_REGS_IP(regs) = eip;
PT_REGS_SP(regs) = esp;
}
#ifdef CONFIG_TTY_LOG
......
......@@ -91,7 +91,7 @@ static struct irq_fd **last_irq_ptr = &active_fds;
extern void free_irqs(void);
void sigio_handler(int sig, union uml_pt_regs *regs)
void sigio_handler(int sig, struct uml_pt_regs *regs)
{
struct irq_fd *irq_fd;
int n;
......@@ -344,7 +344,7 @@ int deactivate_all_fds(void)
* SMP cross-CPU interrupts have their own specific
* handlers).
*/
unsigned int do_IRQ(int irq, union uml_pt_regs *regs)
unsigned int do_IRQ(int irq, struct uml_pt_regs *regs)
{
struct pt_regs *old_regs = set_irq_regs((struct pt_regs *)regs);
irq_enter();
......
......@@ -10,7 +10,7 @@
#include "as-layout.h"
#include "init.h"
#include "kern.h"
#include "mode_kern.h"
#include "mem_user.h"
#include "os.h"
static int physmem_fd = -1;
......@@ -61,7 +61,7 @@ static unsigned long kmem_top = 0;
unsigned long get_kmem_end(void)
{
if (kmem_top == 0)
kmem_top = kmem_end_skas;
kmem_top = host_task_size - 1024 * 1024;
return kmem_top;
}
......
......@@ -43,8 +43,7 @@
#include "frame_kern.h"
#include "sigcontext.h"
#include "os.h"
#include "mode.h"
#include "mode_kern.h"
#include "skas.h"
/* This is a per-cpu array. A processor only modifies its entry and it only
* cares about its entry, so it's OK if another processor is modifying its
......@@ -54,7 +53,8 @@ struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } };
static inline int external_pid(struct task_struct *task)
{
return external_pid_skas(task);
/* FIXME: Need to look up userspace_pid by cpu */
return(userspace_pid[0]);
}
int pid_to_processor_id(int pid)
......@@ -104,6 +104,8 @@ static inline void set_current(struct task_struct *task)
{ external_pid(task), task });
}
extern void arch_switch_to(struct task_struct *from, struct task_struct *to);
void *_switch_to(void *prev, void *next, void *last)
{
struct task_struct *from = prev;
......@@ -114,7 +116,19 @@ void *_switch_to(void *prev, void *next, void *last)
do {
current->thread.saved_task = NULL;
switch_to_skas(prev, next);
/* XXX need to check runqueues[cpu].idle */
if(current->pid == 0)
switch_timers(0);
switch_threads(&from->thread.switch_buf,
&to->thread.switch_buf);
arch_switch_to(current->thread.prev_sched, current);
if(current->pid == 0)
switch_timers(1);
if(current->thread.saved_task)
show_regs(&(current->thread.regs));
next= current->thread.saved_task;
......@@ -133,11 +147,6 @@ void interrupt_end(void)
do_signal();
}
void release_thread(struct task_struct *task)
{
release_thread_skas(task);
}
void exit_thread(void)
{
}
......@@ -147,27 +156,95 @@ void *get_current(void)
return current;
}
extern void schedule_tail(struct task_struct *prev);
/* This is called magically, by its address being stuffed in a jmp_buf
* and being longjmp-d to.
*/
void new_thread_handler(void)
{
int (*fn)(void *), n;
void *arg;
if(current->thread.prev_sched != NULL)
schedule_tail(current->thread.prev_sched);
current->thread.prev_sched = NULL;
fn = current->thread.request.u.thread.proc;
arg = current->thread.request.u.thread.arg;
/* The return value is 1 if the kernel thread execs a process,
* 0 if it just exits
*/
n = run_kernel_thread(fn, arg, &current->thread.exec_buf);
if(n == 1){
/* Handle any immediate reschedules or signals */
interrupt_end();
userspace(&current->thread.regs.regs);
}
else do_exit(0);
}
/* Called magically, see new_thread_handler above */
void fork_handler(void)
{
force_flush_all();
if(current->thread.prev_sched == NULL)
panic("blech");
schedule_tail(current->thread.prev_sched);
/* XXX: if interrupt_end() calls schedule, this call to
* arch_switch_to isn't needed. We could want to apply this to
* improve performance. -bb */
arch_switch_to(current->thread.prev_sched, current);