Rev 703 | Rev 718 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 703 | Rev 717 | ||
---|---|---|---|
Line 67... | Line 67... | ||
67 | * @param arg Not used. |
67 | * @param arg Not used. |
68 | */ |
68 | */ |
69 | void kinit(void *arg) |
69 | void kinit(void *arg) |
70 | { |
70 | { |
71 | thread_t *t; |
71 | thread_t *t; |
72 | #ifdef CONFIG_USERSPACE |
- | |
73 | as_t *as; |
72 | as_t *as; |
74 | as_area_t *a; |
73 | as_area_t *a; |
75 | __address frame; |
74 | __address frame; |
76 | index_t pfn[1]; |
75 | index_t pfn[1]; |
77 | task_t *u; |
76 | task_t *u; |
78 | #endif |
- | |
79 | 77 | ||
80 | interrupts_disable(); |
78 | interrupts_disable(); |
81 | 79 | ||
82 | #ifdef CONFIG_SMP |
80 | #ifdef CONFIG_SMP |
83 | if (config.cpu_count > 1) { |
81 | if (config.cpu_count > 1) { |
Line 137... | Line 135... | ||
137 | thread_ready(t); |
135 | thread_ready(t); |
138 | else panic("thread_create/kconsole\n"); |
136 | else panic("thread_create/kconsole\n"); |
139 | 137 | ||
140 | interrupts_enable(); |
138 | interrupts_enable(); |
141 | 139 | ||
142 | #ifdef CONFIG_USERSPACE |
140 | if (config.init_size > 0) { |
143 | /* |
141 | /* |
144 | * Create the first user task. |
142 | * Create the first user task. |
145 | */ |
143 | */ |
146 | as = as_create(NULL); |
144 | as = as_create(NULL); |
147 | if (!as) |
145 | if (!as) |
Line 158... | Line 156... | ||
158 | */ |
156 | */ |
159 | a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS); |
157 | a = as_area_create(as, AS_AREA_TEXT, 1, UTEXT_ADDRESS); |
160 | if (!a) |
158 | if (!a) |
161 | panic("as_area_create: text\n"); |
159 | panic("as_area_create: text\n"); |
162 | 160 | ||
- | 161 | // FIXME: Better way to initialize static code/data |
|
163 | frame = frame_alloc(0, ONE_FRAME, NULL); |
162 | frame = frame_alloc(0, ONE_FRAME, NULL); |
164 | - | ||
165 | if (config.init_size > 0) |
- | |
166 | memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE); |
163 | memcpy((void *) PA2KA(frame), (void *) config.init_addr, config.init_size < PAGE_SIZE ? config.init_size : PAGE_SIZE); |
167 | else |
- | |
168 | memcpy((void *) PA2KA(frame), (void *) utext, utext_size < PAGE_SIZE ? utext_size : PAGE_SIZE); |
- | |
169 | 164 | ||
170 | pfn[0] = frame / FRAME_SIZE; |
165 | pfn[0] = frame / FRAME_SIZE; |
171 | as_area_load_mapping(a, pfn); |
166 | as_area_load_mapping(a, pfn); |
172 | 167 | ||
173 | /* |
168 | /* |
Line 176... | Line 171... | ||
176 | a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); |
171 | a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); |
177 | if (!a) |
172 | if (!a) |
178 | panic("as_area_create: stack\n"); |
173 | panic("as_area_create: stack\n"); |
179 | 174 | ||
180 | thread_ready(t); |
175 | thread_ready(t); |
181 | #endif /* CONFIG_USERSPACE */ |
- | |
- | 176 | } |
|
182 | 177 | ||
183 | #ifdef CONFIG_TEST |
178 | #ifdef CONFIG_TEST |
184 | test(); |
179 | test(); |
185 | #endif /* CONFIG_TEST */ |
180 | #endif /* CONFIG_TEST */ |
186 | 181 |