Rev 1066 | Rev 1086 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1066 | Rev 1078 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <main/uinit.h> |
29 | #include <main/uinit.h> |
30 | #include <proc/thread.h> |
30 | #include <proc/thread.h> |
31 | #include <proc/task.h> |
31 | #include <proc/task.h> |
- | 32 | #include <proc/uarg.h> |
|
32 | #include <mm/as.h> |
33 | #include <mm/as.h> |
33 | #include <mm/slab.h> |
34 | #include <mm/slab.h> |
34 | - | ||
35 | #include <synch/spinlock.h> |
35 | #include <synch/spinlock.h> |
36 | #include <arch.h> |
36 | #include <arch.h> |
37 | #include <panic.h> |
37 | #include <panic.h> |
38 | #include <adt/list.h> |
38 | #include <adt/list.h> |
39 | #include <ipc/ipc.h> |
39 | #include <ipc/ipc.h> |
40 | #include <memstr.h> |
40 | #include <memstr.h> |
41 | #include <print.h> |
41 | #include <print.h> |
42 | - | ||
43 | #include <elf.h> |
42 | #include <elf.h> |
44 | 43 | ||
45 | SPINLOCK_INITIALIZE(tasks_lock); |
44 | SPINLOCK_INITIALIZE(tasks_lock); |
46 | LIST_INITIALIZE(tasks_head); |
45 | LIST_INITIALIZE(tasks_head); |
47 | static task_id_t task_counter = 0; |
46 | static task_id_t task_counter = 0; |
Line 113... | Line 112... | ||
113 | as_t *as; |
112 | as_t *as; |
114 | as_area_t *a; |
113 | as_area_t *a; |
115 | int rc; |
114 | int rc; |
116 | thread_t *t; |
115 | thread_t *t; |
117 | task_t *task; |
116 | task_t *task; |
118 | uspace_arg_t *uarg; |
117 | uspace_arg_t *kernel_uarg; |
119 | 118 | ||
120 | as = as_create(0); |
119 | as = as_create(0); |
121 | 120 | ||
122 | rc = elf_load((elf_header_t *) program_addr, as); |
121 | rc = elf_load((elf_header_t *) program_addr, as); |
123 | if (rc != EE_OK) { |
122 | if (rc != EE_OK) { |
124 | as_free(as); |
123 | as_free(as); |
125 | return NULL; |
124 | return NULL; |
126 | } |
125 | } |
127 | 126 | ||
128 | uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); |
127 | kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); |
129 | uarg->uspace_entry = (__address) ((elf_header_t *) program_addr)->e_entry; |
128 | kernel_uarg->uspace_entry = (void *) ((elf_header_t *) program_addr)->e_entry; |
130 | uarg->uspace_stack = USTACK_ADDRESS; |
129 | kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS; |
- | 130 | kernel_uarg->uspace_thread_function = NULL; |
|
- | 131 | kernel_uarg->uspace_thread_arg = NULL; |
|
- | 132 | kernel_uarg->uspace_uarg = NULL; |
|
131 | 133 | ||
132 | task = task_create(as, name); |
134 | task = task_create(as, name); |
133 | t = thread_create(uinit, uarg, task, 0, "uinit"); |
135 | t = thread_create(uinit, kernel_uarg, task, 0, "uinit"); |
134 | 136 | ||
135 | /* |
137 | /* |
136 | * Create the data as_area. |
138 | * Create the data as_area. |
137 | */ |
139 | */ |
138 | a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE, PAGE_SIZE, USTACK_ADDRESS); |
140 | a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE, PAGE_SIZE, USTACK_ADDRESS); |