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