Rev 820 | Rev 955 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 820 | Rev 938 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | #include <print.h> |
44 | #include <print.h> |
45 | #include <memstr.h> |
45 | #include <memstr.h> |
46 | #include <console/console.h> |
46 | #include <console/console.h> |
47 | #include <interrupt.h> |
47 | #include <interrupt.h> |
48 | #include <console/kconsole.h> |
48 | #include <console/kconsole.h> |
- | 49 | #include <elf.h> |
|
49 | 50 | ||
50 | #ifdef CONFIG_SMP |
51 | #ifdef CONFIG_SMP |
51 | #include <arch/smp/mps.h> |
52 | #include <arch/smp/mps.h> |
52 | #endif /* CONFIG_SMP */ |
53 | #endif /* CONFIG_SMP */ |
53 | 54 | ||
Line 69... | Line 70... | ||
69 | void kinit(void *arg) |
70 | void kinit(void *arg) |
70 | { |
71 | { |
71 | thread_t *t; |
72 | thread_t *t; |
72 | as_t *as; |
73 | as_t *as; |
73 | as_area_t *a; |
74 | as_area_t *a; |
74 | __address frame; |
- | |
75 | count_t frames; |
- | |
76 | int i; |
75 | int rc; |
77 | task_t *u; |
76 | task_t *u; |
78 | 77 | ||
79 | interrupts_disable(); |
78 | interrupts_disable(); |
80 | 79 | ||
81 | #ifdef CONFIG_SMP |
80 | #ifdef CONFIG_SMP |
Line 148... | Line 147... | ||
148 | panic("config.init_addr is not frame aligned"); |
147 | panic("config.init_addr is not frame aligned"); |
149 | 148 | ||
150 | as = as_create(0); |
149 | as = as_create(0); |
151 | if (!as) |
150 | if (!as) |
152 | panic("as_create\n"); |
151 | panic("as_create\n"); |
153 | u = task_create(as); |
- | |
154 | if (!u) |
- | |
155 | panic("task_create\n"); |
- | |
156 | t = thread_create(uinit, NULL, u, THREAD_USER_STACK); |
- | |
157 | if (!t) |
- | |
158 | panic("thread_create\n"); |
- | |
159 | - | ||
160 | /* |
- | |
161 | * Create the text as_area and initialize its mapping. |
- | |
162 | */ |
- | |
163 | - | ||
164 | frame = config.init_addr; |
- | |
165 | if (IS_KA(frame)) |
- | |
166 | frame = KA2PA(frame); |
- | |
167 | - | ||
168 | frames = SIZE2FRAMES(config.init_size); |
- | |
169 | - | ||
170 | a = as_area_create(as, AS_AREA_TEXT, frames, UTEXT_ADDRESS); |
- | |
171 | if (!a) |
- | |
172 | panic("as_area_create: text\n"); |
- | |
173 | 152 | ||
- | 153 | rc = elf_load((elf_header_t *) config.init_addr, as); |
|
- | 154 | if (rc != EE_OK) { |
|
- | 155 | printf("elf_load failed: %s\n", elf_error(rc)); |
|
- | 156 | } else { |
|
- | 157 | u = task_create(as); |
|
- | 158 | if (!u) |
|
- | 159 | panic("task_create\n"); |
|
- | 160 | t = thread_create(uinit, (void *)((elf_header_t *) config.init_addr)->e_entry, u, THREAD_USER_STACK); |
|
- | 161 | if (!t) |
|
- | 162 | panic("thread_create\n"); |
|
- | 163 | ||
- | 164 | /* |
|
174 | for (i = 0; i < frames; i++) |
165 | * Create the data as_area. |
- | 166 | */ |
|
175 | as_set_mapping(as, UTEXT_ADDRESS + i * PAGE_SIZE, frame + i * FRAME_SIZE); |
167 | a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); |
- | 168 | if (!a) |
|
- | 169 | panic("as_area_create: stack\n"); |
|
176 | 170 | ||
177 | /* |
- | |
178 | * Create the data as_area. |
171 | thread_ready(t); |
179 | */ |
172 | } |
180 | a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); |
- | |
181 | if (!a) |
- | |
182 | panic("as_area_create: stack\n"); |
- | |
183 | - | ||
184 | thread_ready(t); |
- | |
185 | } |
173 | } |
186 | 174 | ||
187 | #ifdef CONFIG_TEST |
175 | #ifdef CONFIG_TEST |
188 | test(); |
176 | test(); |
189 | #endif /* CONFIG_TEST */ |
177 | #endif /* CONFIG_TEST */ |