1 #include <lwk/kernel.h>
3 #include <lwk/params.h>
8 * Maximum number of arguments and environment variables that may
9 * be passed to the init_task.
11 #define INIT_MAX_ARGC 32
12 #define INIT_MAX_ENVC 32
15 * Maximum length of the init_argv= and init_envp= strings on the
16 * kernel boot command line.
18 #define INIT_ARGV_LEN 1024
19 #define INIT_ENVP_LEN 1024
22 * Amount of memory to reserve for the init_task's heap.
24 unsigned long init_heap_size = (1024 * 1024 * 4); /* 4 MB */
25 param(init_heap_size, ulong);
28 * Amount of memory to reserve for the init_task's stack.
30 unsigned long init_stack_size = (1024 * 256); /* 256 KB */
31 param(init_stack_size, ulong);
34 * Arguments to pass to the init_task.
36 static char init_argv_str[INIT_ARGV_LEN] = { 0 };
37 param_string(init_argv, init_argv_str, sizeof(init_argv_str));
40 * Environment to pass to the init_task.
42 static char init_envp_str[INIT_ENVP_LEN] = { 0 };
43 param_string(init_envp, init_envp_str, sizeof(init_envp_str));
46 * Creates the init_task.
49 create_init_task(void)
52 start_state_t start_state;
54 if (!init_elf_image) {
55 printk("No init_elf_image found.\n");
59 /* Initialize the start_state fields that we know up-front */
62 start_state.cpu_id = this_cpu;
63 start_state.cpumask = NULL;
65 /* This initializes start_state aspace_id, entry_point, and stack_ptr */
82 printk("Failed to load init_task (status=%d).\n", status);
86 /* This prevents the address space from being deleted by
87 * user-space, since the kernel never releases this reference */
88 if (!aspace_acquire(INIT_ASPACE_ID)) {
89 printk("Failed to acquire INIT_ASPACE_ID.\n");
93 return task_create(INIT_TASK_ID, "init_task", &start_state, NULL);