Merge branch 'drm-forlinus' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied...
[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 "time_user.h"
17 #include "mem_user.h"
18 #include "os.h"
19 #include "tlb.h"
20 #include "mode.h"
21
22 static int exec_tramp(void *sig_stack)
23 {
24         init_new_thread_stack(sig_stack, NULL);
25         init_new_thread_signals(1);
26         os_stop_process(os_getpid());
27         return(0);
28 }
29
30 void flush_thread_tt(void)
31 {
32         unsigned long stack;
33         int new_pid;
34
35         stack = alloc_stack(0, 0);
36         if(stack == 0){
37                 printk(KERN_ERR 
38                        "flush_thread : failed to allocate temporary stack\n");
39                 do_exit(SIGKILL);
40         }
41                 
42         new_pid = start_fork_tramp(task_stack_page(current), stack, 0, exec_tramp);
43         if(new_pid < 0){
44                 printk(KERN_ERR 
45                        "flush_thread : new thread failed, errno = %d\n",
46                        -new_pid);
47                 do_exit(SIGKILL);
48         }
49
50         if(current_thread->cpu == 0)
51                 forward_interrupts(new_pid);
52         current->thread.request.op = OP_EXEC;
53         current->thread.request.u.exec.pid = new_pid;
54         unprotect_stack((unsigned long) current_thread);
55         os_usr1_process(os_getpid());
56         change_sig(SIGUSR1, 1);
57
58         change_sig(SIGUSR1, 0);
59         enable_timer();
60         free_page(stack);
61         protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1);
62         task_protections((unsigned long) current_thread);
63         force_flush_all();
64         unblock_signals();
65 }
66
67 void start_thread_tt(struct pt_regs *regs, unsigned long eip, 
68                      unsigned long esp)
69 {
70         set_fs(USER_DS);
71         flush_tlb_mm(current->mm);
72         PT_REGS_IP(regs) = eip;
73         PT_REGS_SP(regs) = esp;
74         PT_FIX_EXEC_STACK(esp);
75 }
76
77 /*
78  * Overrides for Emacs so that we follow Linus's tabbing style.
79  * Emacs will notice this stuff at the end of the file and automatically
80  * adjust the settings for this buffer only.  This must remain at the end
81  * of the file.
82  * ---------------------------------------------------------------------------
83  * Local variables:
84  * c-file-style: "linux"
85  * End:
86  */