Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX__INIT_TASK_H |
| 2 | #define _LINUX__INIT_TASK_H |
| 3 | |
| 4 | #include <linux/file.h> |
Dipankar Sarma | ab2af1f | 2005-09-09 13:04:13 -0700 | [diff] [blame] | 5 | #include <linux/rcupdate.h> |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 6 | #include <linux/irqflags.h> |
Ingo Molnar | fbb9ce9 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 7 | #include <linux/lockdep.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Dipankar Sarma | badf166 | 2005-09-09 13:04:10 -0700 | [diff] [blame] | 9 | #define INIT_FDTABLE \ |
| 10 | { \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | .max_fds = NR_OPEN_DEFAULT, \ |
Eric Dumazet | 0c9e63f | 2006-03-23 03:00:12 -0800 | [diff] [blame] | 12 | .max_fdset = EMBEDDED_FD_SET_SIZE, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | .fd = &init_files.fd_array[0], \ |
Eric Dumazet | 0c9e63f | 2006-03-23 03:00:12 -0800 | [diff] [blame] | 14 | .close_on_exec = (fd_set *)&init_files.close_on_exec_init, \ |
| 15 | .open_fds = (fd_set *)&init_files.open_fds_init, \ |
Dipankar Sarma | ab2af1f | 2005-09-09 13:04:13 -0700 | [diff] [blame] | 16 | .rcu = RCU_HEAD_INIT, \ |
| 17 | .free_files = NULL, \ |
| 18 | .next = NULL, \ |
Dipankar Sarma | badf166 | 2005-09-09 13:04:10 -0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | #define INIT_FILES \ |
| 22 | { \ |
| 23 | .count = ATOMIC_INIT(1), \ |
Dipankar Sarma | ab2af1f | 2005-09-09 13:04:13 -0700 | [diff] [blame] | 24 | .fdt = &init_files.fdtab, \ |
Dipankar Sarma | badf166 | 2005-09-09 13:04:10 -0700 | [diff] [blame] | 25 | .fdtab = INIT_FDTABLE, \ |
Ingo Molnar | e4d9191 | 2006-07-03 00:24:34 -0700 | [diff] [blame] | 26 | .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock), \ |
Eric Dumazet | 0c9e63f | 2006-03-23 03:00:12 -0800 | [diff] [blame] | 27 | .next_fd = 0, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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), \ |
Ingo Molnar | e4d9191 | 2006-07-03 00:24:34 -0700 | [diff] [blame] | 41 | .ctx_lock = __SPIN_LOCK_UNLOCKED(name.ctx_lock), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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), \ |
Ingo Molnar | e4d9191 | 2006-07-03 00:24:34 -0700 | [diff] [blame] | 53 | .page_table_lock = __SPIN_LOCK_UNLOCKED(name.page_table_lock), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | .mmlist = LIST_HEAD_INIT(name.mmlist), \ |
| 55 | .cpu_vm_mask = CPU_MASK_ALL, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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, \ |
Oleg Nesterov | c7c6464 | 2006-03-28 16:11:09 -0800 | [diff] [blame] | 67 | .pgrp = 1, \ |
| 68 | .session = 1, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | #define INIT_SIGHAND(sighand) { \ |
| 72 | .count = ATOMIC_INIT(1), \ |
| 73 | .action = { { { .sa_handler = NULL, } }, }, \ |
Ingo Molnar | e4d9191 | 2006-07-03 00:24:34 -0700 | [diff] [blame] | 74 | .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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, \ |
Ingo Molnar | b29739f | 2006-06-27 02:54:51 -0700 | [diff] [blame] | 92 | .normal_prio = MAX_PRIO-20, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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), \ |
Jens Axboe | 22e2c50 | 2005-06-27 10:55:12 +0200 | [diff] [blame] | 98 | .ioprio = 0, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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}}, \ |
Ingo Molnar | e4d9191 | 2006-07-03 00:24:34 -0700 | [diff] [blame] | 124 | .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | .journal_info = NULL, \ |
| 126 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
Jens Axboe | 22e2c50 | 2005-06-27 10:55:12 +0200 | [diff] [blame] | 127 | .fs_excl = ATOMIC_INIT(0), \ |
Ingo Molnar | b29739f | 2006-06-27 02:54:51 -0700 | [diff] [blame] | 128 | .pi_lock = SPIN_LOCK_UNLOCKED, \ |
Ingo Molnar | de30a2b | 2006-07-03 00:24:42 -0700 | [diff] [blame] | 129 | INIT_TRACE_IRQFLAGS \ |
Ingo Molnar | fbb9ce9 | 2006-07-03 00:24:50 -0700 | [diff] [blame] | 130 | INIT_LOCKDEP \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |