Rev 754 | Rev 794 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 754 | Rev 756 | ||
|---|---|---|---|
| Line 145... | Line 145... | ||
| 145 | */ |
145 | */ |
| 146 | 146 | ||
| 147 | if (KA2PA(config.init_addr) % FRAME_SIZE) |
147 | if (KA2PA(config.init_addr) % FRAME_SIZE) |
| 148 | panic("config.init_addr is not frame aligned"); |
148 | panic("config.init_addr is not frame aligned"); |
| 149 | 149 | ||
| 150 | as = as_create(NULL, 0); |
150 | as = as_create(0); |
| 151 | if (!as) |
151 | if (!as) |
| 152 | panic("as_create\n"); |
152 | panic("as_create\n"); |
| 153 | u = task_create(as); |
153 | u = task_create(as); |
| 154 | if (!u) |
154 | if (!u) |
| 155 | panic("task_create\n"); |
155 | panic("task_create\n"); |
| 156 | t = thread_create(uinit, NULL, u, THREAD_USER_STACK); |
156 | t = thread_create(uinit, NULL, u, THREAD_USER_STACK); |
| 157 | if (!t) |
157 | if (!t) |
| 158 | panic("thread_create\n"); |
158 | panic("thread_create\n"); |
| 159 | 159 | ||
| 160 | /* |
160 | /* |
| 161 | * Create the text as_area and copy the userspace code there. |
161 | * Create the text as_area and initialize its mapping. |
| 162 | */ |
162 | */ |
| 163 | 163 | ||
| 164 | frame = KA2PA(config.init_addr); |
164 | frame = KA2PA(config.init_addr); |
| 165 | frames = config.init_size / FRAME_SIZE; |
165 | frames = config.init_size / FRAME_SIZE; |
| 166 | if (config.init_size % FRAME_SIZE > 0) |
166 | if (config.init_size % FRAME_SIZE > 0) |
| 167 | frames++; |
167 | frames++; |
| 168 | 168 | ||
| 169 | a = as_area_create(as, AS_AREA_TEXT, frames, UTEXT_ADDRESS); |
169 | a = as_area_create(as, AS_AREA_TEXT, frames, UTEXT_ADDRESS); |
| 170 | if (!a) |
170 | if (!a) |
| 171 | panic("as_area_create: text\n"); |
171 | panic("as_area_create: text\n"); |
| - | 172 | ||
| - | 173 | for (i = 0; i < frames; i++) |
|
| - | 174 | as_set_mapping(as, UTEXT_ADDRESS + i * PAGE_SIZE, frame + i * FRAME_SIZE); |
|
| 172 | 175 | ||
| 173 | /* |
176 | /* |
| 174 | * Create the data as_area. |
177 | * Create the data as_area. |
| 175 | */ |
178 | */ |
| 176 | a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); |
179 | a = as_area_create(as, AS_AREA_STACK, 1, USTACK_ADDRESS); |
| 177 | if (!a) |
180 | if (!a) |
| 178 | panic("as_area_create: stack\n"); |
181 | panic("as_area_create: stack\n"); |
| 179 | 182 | ||
| 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 | - | ||
| 186 | - | ||
| 187 | thread_ready(t); |
183 | thread_ready(t); |
| 188 | } |
184 | } |
| 189 | 185 | ||
| 190 | #ifdef CONFIG_TEST |
186 | #ifdef CONFIG_TEST |
| 191 | test(); |
187 | test(); |