Rev 727 | Rev 756 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 727 | Rev 754 | ||
|---|---|---|---|
| Line 69... | Line 69... | ||
| 69 | void kinit(void *arg) |
69 | void kinit(void *arg) |
| 70 | { |
70 | { |
| 71 | thread_t *t; |
71 | thread_t *t; |
| 72 | as_t *as; |
72 | as_t *as; |
| 73 | as_area_t *a; |
73 | as_area_t *a; |
| - | 74 | __address frame; |
|
| 74 | index_t frame, frames; |
75 | count_t frames; |
| 75 | index_t pfn; |
76 | int i; |
| 76 | task_t *u; |
77 | task_t *u; |
| 77 | 78 | ||
| 78 | interrupts_disable(); |
79 | interrupts_disable(); |
| 79 | 80 | ||
| 80 | #ifdef CONFIG_SMP |
81 | #ifdef CONFIG_SMP |
| Line 158... | Line 159... | ||
| 158 | 159 | ||
| 159 | /* |
160 | /* |
| 160 | * Create the text as_area and copy the userspace code there. |
161 | * Create the text as_area and copy the userspace code there. |
| 161 | */ |
162 | */ |
| 162 | 163 | ||
| 163 | frame = KA2PA(config.init_addr) / FRAME_SIZE; |
164 | frame = KA2PA(config.init_addr); |
| 164 | frames = config.init_size / FRAME_SIZE; |
165 | frames = config.init_size / FRAME_SIZE; |
| 165 | if (config.init_size % FRAME_SIZE > 0) |
166 | if (config.init_size % FRAME_SIZE > 0) |
| 166 | frames++; |
167 | frames++; |
| 167 | 168 | ||
| 168 | a = as_area_create(as, AS_AREA_TEXT, frames, UTEXT_ADDRESS); |
169 | a = as_area_create(as, AS_AREA_TEXT, frames, UTEXT_ADDRESS); |
| 169 | if (!a) |
170 | if (!a) |
| 170 | panic("as_area_create: text\n"); |
171 | panic("as_area_create: text\n"); |
| 171 | 172 | ||
| 172 | for (pfn = 0; pfn < frames; pfn++) |
- | |
| 173 | as_area_set_mapping(a, pfn, frame + pfn); |
- | |
| 174 | - | ||
| 175 | /* |
173 | /* |
| 176 | * Create the data as_area. |
174 | * Create the data as_area. |
| 177 | */ |
175 | */ |
| 178 | a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); |
176 | a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); |
| 179 | if (!a) |
177 | if (!a) |
| 180 | panic("as_area_create: stack\n"); |
178 | panic("as_area_create: stack\n"); |
| - | 179 | ||
| - | 180 | /* |
|
| - | 181 | * Initialize text area mapping. |
|
| - | 182 | */ |
|
| - | 183 | for (i = 0; i < frames; i++) |
|
| - | 184 | as_set_mapping(as, UTEXT_ADDRESS + i * PAGE_SIZE, frame + i * FRAME_SIZE); |
|
| - | 185 | ||
| 181 | 186 | ||
| 182 | thread_ready(t); |
187 | thread_ready(t); |
| 183 | } |
188 | } |
| 184 | 189 | ||
| 185 | #ifdef CONFIG_TEST |
190 | #ifdef CONFIG_TEST |