Merge master.kernel.org:/home/rmk/linux-2.6-serial
[pandora-kernel.git] / arch / um / kernel / tt / exec_kern.c
1 /* 
2  * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #include "linux/kernel.h"
7 #include "linux/mm.h"
8 #include "asm/signal.h"
9 #include "asm/ptrace.h"
10 #include "asm/uaccess.h"
11 #include "asm/pgalloc.h"
12 #include "asm/tlbflush.h"
13 #include "user_util.h"
14 #include "kern_util.h"
15 #include "irq_user.h"
16 #include "mem_user.h"
17 #include "os.h"
18 #include "tlb.h"
19 #include "mode.h"
20
21 static int exec_tramp(void *sig_stack)
22 {
23         init_new_thread_stack(sig_stack, NULL);
24         init_new_thread_signals();
25         os_stop_process(os_getpid());
26         return(0);
27 }
28
29 void flush_thread_tt(void)
30 {
31         unsigned long stack;
32         int new_pid;
33
34         stack = alloc_stack(0, 0);
35         if(stack == 0){
36                 printk(KERN_ERR 
37                        "flush_thread : failed to allocate temporary stack\n");
38                 do_exit(SIGKILL);
39         }
40                 
41         new_pid = start_fork_tramp(task_stack_page(current), stack, 0, exec_tramp);
42         if(new_pid < 0){
43                 printk(KERN_ERR 
44                        "flush_thread : new thread failed, errno = %d\n",
45                        -new_pid);
46                 do_exit(SIGKILL);
47         }
48
49         if(current_thread->cpu == 0)
50                 forward_interrupts(new_pid);
51         current->thread.request.op = OP_EXEC;
52         current->thread.request.u.exec.pid = new_pid;
53         unprotect_stack((unsigned long) current_thread);
54         os_usr1_process(os_getpid());
55         change_sig(SIGUSR1, 1);
56
57         change_sig(SIGUSR1, 0);
58         enable_timer();
59         free_page(stack);
60         protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1);
61         task_protections((unsigned long) current_thread);
62         force_flush_all();
63         unblock_signals();
64 }
65
66 void start_thread_tt(struct pt_regs *regs, unsigned long eip, 
67                      unsigned long esp)
68 {
69         set_fs(USER_DS);
70         flush_tlb_mm(current->mm);
71         PT_REGS_IP(regs) = eip;
72         PT_REGS_SP(regs) = esp;
73         PT_FIX_EXEC_STACK(esp);
74 }
75
76 /*
77  * Overrides for Emacs so that we follow Linus's tabbing style.
78  * Emacs will notice this stuff at the end of the file and automatically
79  * adjust the settings for this buffer only.  This must remain at the end
80  * of the file.
81  * ---------------------------------------------------------------------------
82  * Local variables:
83  * c-file-style: "linux"
84  * End:
85  */