blob: 60aac2cea0cf63764b26d09f1f05cbc88b53e7ee [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>
Ingo Molnarde30a2b2006-07-03 00:24:42 -07006#include <linux/irqflags.h>
Ingo Molnarfbb9ce92006-07-03 00:24:50 -07007#include <linux/lockdep.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Dipankar Sarmabadf1662005-09-09 13:04:10 -07009#define INIT_FDTABLE \
10{ \
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 .max_fds = NR_OPEN_DEFAULT, \
Eric Dumazet0c9e63f2006-03-23 03:00:12 -080012 .max_fdset = EMBEDDED_FD_SET_SIZE, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 .fd = &init_files.fd_array[0], \
Eric Dumazet0c9e63f2006-03-23 03:00:12 -080014 .close_on_exec = (fd_set *)&init_files.close_on_exec_init, \
15 .open_fds = (fd_set *)&init_files.open_fds_init, \
Dipankar Sarmaab2af1f2005-09-09 13:04:13 -070016 .rcu = RCU_HEAD_INIT, \
17 .free_files = NULL, \
18 .next = NULL, \
Dipankar Sarmabadf1662005-09-09 13:04:10 -070019}
20
21#define INIT_FILES \
22{ \
23 .count = ATOMIC_INIT(1), \
Dipankar Sarmaab2af1f2005-09-09 13:04:13 -070024 .fdt = &init_files.fdtab, \
Dipankar Sarmabadf1662005-09-09 13:04:10 -070025 .fdtab = INIT_FDTABLE, \
Ingo Molnare4d91912006-07-03 00:24:34 -070026 .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock), \
Eric Dumazet0c9e63f2006-03-23 03:00:12 -080027 .next_fd = 0, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 .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), \
Ingo Molnare4d91912006-07-03 00:24:34 -070041 .ctx_lock = __SPIN_LOCK_UNLOCKED(name.ctx_lock), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 .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), \
Ingo Molnare4d91912006-07-03 00:24:34 -070053 .page_table_lock = __SPIN_LOCK_UNLOCKED(name.page_table_lock), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 .mmlist = LIST_HEAD_INIT(name.mmlist), \
55 .cpu_vm_mask = CPU_MASK_ALL, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070056}
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, \
Oleg Nesterovc7c64642006-03-28 16:11:09 -080067 .pgrp = 1, \
68 .session = 1, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070069}
70
71#define INIT_SIGHAND(sighand) { \
72 .count = ATOMIC_INIT(1), \
73 .action = { { { .sa_handler = NULL, } }, }, \
Ingo Molnare4d91912006-07-03 00:24:34 -070074 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
76
77extern 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, \
Ingo Molnarb29739f2006-06-27 02:54:51 -070092 .normal_prio = MAX_PRIO-20, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 .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), \
Jens Axboe22e2c502005-06-27 10:55:12 +020098 .ioprio = 0, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 .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}}, \
Ingo Molnare4d91912006-07-03 00:24:34 -0700124 .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 .journal_info = NULL, \
126 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
Jens Axboe22e2c502005-06-27 10:55:12 +0200127 .fs_excl = ATOMIC_INIT(0), \
Ingo Molnarb29739f2006-06-27 02:54:51 -0700128 .pi_lock = SPIN_LOCK_UNLOCKED, \
Ingo Molnarde30a2b2006-07-03 00:24:42 -0700129 INIT_TRACE_IRQFLAGS \
Ingo Molnarfbb9ce92006-07-03 00:24:50 -0700130 INIT_LOCKDEP \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131}
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