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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
Dipankar Sarma | badf166 | 2005-09-09 13:04:10 -0700 | [diff] [blame] | 7 | #define INIT_FDTABLE \ |
| 8 | { \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | .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 Sarma | ab2af1f | 2005-09-09 13:04:13 -0700 | [diff] [blame] | 15 | .rcu = RCU_HEAD_INIT, \ |
| 16 | .free_files = NULL, \ |
| 17 | .next = NULL, \ |
Dipankar Sarma | badf166 | 2005-09-09 13:04:10 -0700 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | #define INIT_FILES \ |
| 21 | { \ |
| 22 | .count = ATOMIC_INIT(1), \ |
| 23 | .file_lock = SPIN_LOCK_UNLOCKED, \ |
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, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | .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, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | #define INIT_SIGNALS(sig) { \ |
| 57 | .count = ATOMIC_INIT(1), \ |
| 58 | .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(sig.wait_chldexit),\ |
| 59 | .shared_pending = { \ |
| 60 | .list = LIST_HEAD_INIT(sig.shared_pending.list), \ |
| 61 | .signal = {{0}}}, \ |
| 62 | .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ |
| 63 | .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ |
| 64 | .rlim = INIT_RLIMITS, \ |
| 65 | } |
| 66 | |
| 67 | #define INIT_SIGHAND(sighand) { \ |
| 68 | .count = ATOMIC_INIT(1), \ |
| 69 | .action = { { { .sa_handler = NULL, } }, }, \ |
| 70 | .siglock = SPIN_LOCK_UNLOCKED, \ |
| 71 | } |
| 72 | |
| 73 | extern struct group_info init_groups; |
| 74 | |
| 75 | /* |
| 76 | * INIT_TASK is used to set up the first task table, touch at |
| 77 | * your own risk!. Base=0, limit=0x1fffff (=2MB) |
| 78 | */ |
| 79 | #define INIT_TASK(tsk) \ |
| 80 | { \ |
| 81 | .state = 0, \ |
| 82 | .thread_info = &init_thread_info, \ |
| 83 | .usage = ATOMIC_INIT(2), \ |
| 84 | .flags = 0, \ |
| 85 | .lock_depth = -1, \ |
| 86 | .prio = MAX_PRIO-20, \ |
| 87 | .static_prio = MAX_PRIO-20, \ |
| 88 | .policy = SCHED_NORMAL, \ |
| 89 | .cpus_allowed = CPU_MASK_ALL, \ |
| 90 | .mm = NULL, \ |
| 91 | .active_mm = &init_mm, \ |
| 92 | .run_list = LIST_HEAD_INIT(tsk.run_list), \ |
Jens Axboe | 22e2c50 | 2005-06-27 10:55:12 +0200 | [diff] [blame] | 93 | .ioprio = 0, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | .time_slice = HZ, \ |
| 95 | .tasks = LIST_HEAD_INIT(tsk.tasks), \ |
| 96 | .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \ |
| 97 | .ptrace_list = LIST_HEAD_INIT(tsk.ptrace_list), \ |
| 98 | .real_parent = &tsk, \ |
| 99 | .parent = &tsk, \ |
| 100 | .children = LIST_HEAD_INIT(tsk.children), \ |
| 101 | .sibling = LIST_HEAD_INIT(tsk.sibling), \ |
| 102 | .group_leader = &tsk, \ |
| 103 | .group_info = &init_groups, \ |
| 104 | .cap_effective = CAP_INIT_EFF_SET, \ |
| 105 | .cap_inheritable = CAP_INIT_INH_SET, \ |
| 106 | .cap_permitted = CAP_FULL_SET, \ |
| 107 | .keep_capabilities = 0, \ |
| 108 | .user = INIT_USER, \ |
| 109 | .comm = "swapper", \ |
| 110 | .thread = INIT_THREAD, \ |
| 111 | .fs = &init_fs, \ |
| 112 | .files = &init_files, \ |
| 113 | .signal = &init_signals, \ |
| 114 | .sighand = &init_sighand, \ |
| 115 | .pending = { \ |
| 116 | .list = LIST_HEAD_INIT(tsk.pending.list), \ |
| 117 | .signal = {{0}}}, \ |
| 118 | .blocked = {{0}}, \ |
| 119 | .alloc_lock = SPIN_LOCK_UNLOCKED, \ |
| 120 | .proc_lock = SPIN_LOCK_UNLOCKED, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | .journal_info = NULL, \ |
| 122 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
Jens Axboe | 22e2c50 | 2005-06-27 10:55:12 +0200 | [diff] [blame] | 123 | .fs_excl = ATOMIC_INIT(0), \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | |
| 127 | #define INIT_CPU_TIMERS(cpu_timers) \ |
| 128 | { \ |
| 129 | LIST_HEAD_INIT(cpu_timers[0]), \ |
| 130 | LIST_HEAD_INIT(cpu_timers[1]), \ |
| 131 | LIST_HEAD_INIT(cpu_timers[2]), \ |
| 132 | } |
| 133 | |
| 134 | |
| 135 | #endif |