94aefa54a1b5f7b78f07c893806dade4b47ed3a7
[linux-3.10.git] / include / linux / init_task.h
1 #ifndef _LINUX__INIT_TASK_H
2 #define _LINUX__INIT_TASK_H
3
4 #include <linux/file.h>
5
6 #define INIT_FDTABLE \
7 {                                                       \
8         .max_fds        = NR_OPEN_DEFAULT,              \
9         .max_fdset      = __FD_SETSIZE,                 \
10         .next_fd        = 0,                            \
11         .fd             = &init_files.fd_array[0],      \
12         .close_on_exec  = &init_files.close_on_exec_init, \
13         .open_fds       = &init_files.open_fds_init,    \
14 }
15
16 #define INIT_FILES \
17 {                                                       \
18         .count          = ATOMIC_INIT(1),               \
19         .file_lock      = SPIN_LOCK_UNLOCKED,           \
20         .fdtab          = INIT_FDTABLE,                 \
21         .close_on_exec_init = { { 0, } },               \
22         .open_fds_init  = { { 0, } },                   \
23         .fd_array       = { NULL, }                     \
24 }
25
26 #define INIT_KIOCTX(name, which_mm) \
27 {                                                       \
28         .users          = ATOMIC_INIT(1),               \
29         .dead           = 0,                            \
30         .mm             = &which_mm,                    \
31         .user_id        = 0,                            \
32         .next           = NULL,                         \
33         .wait           = __WAIT_QUEUE_HEAD_INITIALIZER(name.wait), \
34         .ctx_lock       = SPIN_LOCK_UNLOCKED,           \
35         .reqs_active    = 0U,                           \
36         .max_reqs       = ~0U,                          \
37 }
38
39 #define INIT_MM(name) \
40 {                                                               \
41         .mm_rb          = RB_ROOT,                              \
42         .pgd            = swapper_pg_dir,                       \
43         .mm_users       = ATOMIC_INIT(2),                       \
44         .mm_count       = ATOMIC_INIT(1),                       \
45         .mmap_sem       = __RWSEM_INITIALIZER(name.mmap_sem),   \
46         .page_table_lock =  SPIN_LOCK_UNLOCKED,                 \
47         .mmlist         = LIST_HEAD_INIT(name.mmlist),          \
48         .cpu_vm_mask    = CPU_MASK_ALL,                         \
49         .default_kioctx = INIT_KIOCTX(name.default_kioctx, name),       \
50 }
51
52 #define INIT_SIGNALS(sig) {     \
53         .count          = ATOMIC_INIT(1),               \
54         .wait_chldexit  = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\
55         .shared_pending = {                             \
56                 .list = LIST_HEAD_INIT(sig.shared_pending.list),        \
57                 .signal =  {{0}}}, \
58         .posix_timers    = LIST_HEAD_INIT(sig.posix_timers),            \
59         .cpu_timers     = INIT_CPU_TIMERS(sig.cpu_timers),              \
60         .rlim           = INIT_RLIMITS,                                 \
61 }
62
63 #define INIT_SIGHAND(sighand) {                                         \
64         .count          = ATOMIC_INIT(1),                               \
65         .action         = { { { .sa_handler = NULL, } }, },             \
66         .siglock        = SPIN_LOCK_UNLOCKED,                           \
67 }
68
69 extern struct group_info init_groups;
70
71 /*
72  *  INIT_TASK is used to set up the first task table, touch at
73  * your own risk!. Base=0, limit=0x1fffff (=2MB)
74  */
75 #define INIT_TASK(tsk)  \
76 {                                                                       \
77         .state          = 0,                                            \
78         .thread_info    = &init_thread_info,                            \
79         .usage          = ATOMIC_INIT(2),                               \
80         .flags          = 0,                                            \
81         .lock_depth     = -1,                                           \
82         .prio           = MAX_PRIO-20,                                  \
83         .static_prio    = MAX_PRIO-20,                                  \
84         .policy         = SCHED_NORMAL,                                 \
85         .cpus_allowed   = CPU_MASK_ALL,                                 \
86         .mm             = NULL,                                         \
87         .active_mm      = &init_mm,                                     \
88         .run_list       = LIST_HEAD_INIT(tsk.run_list),                 \
89         .ioprio         = 0,                                            \
90         .time_slice     = HZ,                                           \
91         .tasks          = LIST_HEAD_INIT(tsk.tasks),                    \
92         .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children),          \
93         .ptrace_list    = LIST_HEAD_INIT(tsk.ptrace_list),              \
94         .real_parent    = &tsk,                                         \
95         .parent         = &tsk,                                         \
96         .children       = LIST_HEAD_INIT(tsk.children),                 \
97         .sibling        = LIST_HEAD_INIT(tsk.sibling),                  \
98         .group_leader   = &tsk,                                         \
99         .group_info     = &init_groups,                                 \
100         .cap_effective  = CAP_INIT_EFF_SET,                             \
101         .cap_inheritable = CAP_INIT_INH_SET,                            \
102         .cap_permitted  = CAP_FULL_SET,                                 \
103         .keep_capabilities = 0,                                         \
104         .user           = INIT_USER,                                    \
105         .comm           = "swapper",                                    \
106         .thread         = INIT_THREAD,                                  \
107         .fs             = &init_fs,                                     \
108         .files          = &init_files,                                  \
109         .signal         = &init_signals,                                \
110         .sighand        = &init_sighand,                                \
111         .pending        = {                                             \
112                 .list = LIST_HEAD_INIT(tsk.pending.list),               \
113                 .signal = {{0}}},                                       \
114         .blocked        = {{0}},                                        \
115         .alloc_lock     = SPIN_LOCK_UNLOCKED,                           \
116         .proc_lock      = SPIN_LOCK_UNLOCKED,                           \
117         .journal_info   = NULL,                                         \
118         .cpu_timers     = INIT_CPU_TIMERS(tsk.cpu_timers),              \
119         .fs_excl        = ATOMIC_INIT(0),                               \
120 }
121
122
123 #define INIT_CPU_TIMERS(cpu_timers)                                     \
124 {                                                                       \
125         LIST_HEAD_INIT(cpu_timers[0]),                                  \
126         LIST_HEAD_INIT(cpu_timers[1]),                                  \
127         LIST_HEAD_INIT(cpu_timers[2]),                                  \
128 }
129
130
131 #endif