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