Linux 3.12
[linux/fpc-iii.git] / arch / um / kernel / skas / process.c
blob4da11b3c8ddbc31af5b4a360f487769d84fcf60a
1 /*
2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
6 #include <linux/init.h>
7 #include <linux/sched.h>
8 #include <as-layout.h>
9 #include <kern.h>
10 #include <os.h>
11 #include <skas.h>
13 int new_mm(unsigned long stack)
15 int fd, err;
17 fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
18 if (fd < 0)
19 return fd;
21 if (skas_needs_stub) {
22 err = map_stub_pages(fd, STUB_CODE, STUB_DATA, stack);
23 if (err) {
24 os_close_file(fd);
25 return err;
29 return fd;
32 extern void start_kernel(void);
34 static int __init start_kernel_proc(void *unused)
36 int pid;
38 block_signals();
39 pid = os_getpid();
41 cpu_tasks[0].pid = pid;
42 cpu_tasks[0].task = current;
43 #ifdef CONFIG_SMP
44 init_cpu_online(get_cpu_mask(0));
45 #endif
46 start_kernel();
47 return 0;
50 extern int userspace_pid[];
52 extern char cpu0_irqstack[];
54 int __init start_uml(void)
56 stack_protections((unsigned long) &cpu0_irqstack);
57 set_sigstack(cpu0_irqstack, THREAD_SIZE);
58 if (proc_mm) {
59 userspace_pid[0] = start_userspace(0);
60 if (userspace_pid[0] < 0) {
61 printf("start_uml - start_userspace returned %d\n",
62 userspace_pid[0]);
63 exit(1);
67 init_new_thread_signals();
69 init_task.thread.request.u.thread.proc = start_kernel_proc;
70 init_task.thread.request.u.thread.arg = NULL;
71 return start_idle_thread(task_stack_page(&init_task),
72 &init_task.thread.switch_buf);
75 unsigned long current_stub_stack(void)
77 if (current->mm == NULL)
78 return 0;
80 return current->mm->context.id.stack;