Rev 3063 | Rev 3186 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3063 | Rev 3137 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | #include <mm/slab.h> |
43 | #include <mm/slab.h> |
44 | #include <atomic.h> |
44 | #include <atomic.h> |
45 | #include <synch/spinlock.h> |
45 | #include <synch/spinlock.h> |
46 | #include <synch/waitq.h> |
46 | #include <synch/waitq.h> |
47 | #include <arch.h> |
47 | #include <arch.h> |
- | 48 | #include <arch/barrier.h> |
|
48 | #include <panic.h> |
49 | #include <panic.h> |
49 | #include <adt/avl.h> |
50 | #include <adt/avl.h> |
50 | #include <adt/btree.h> |
51 | #include <adt/btree.h> |
51 | #include <adt/list.h> |
52 | #include <adt/list.h> |
52 | #include <ipc/ipc.h> |
53 | #include <ipc/ipc.h> |
Line 257... | Line 258... | ||
257 | return ENOMEM; |
258 | return ENOMEM; |
258 | 259 | ||
259 | int rc = copy_from_uspace(kimage, image, size); |
260 | int rc = copy_from_uspace(kimage, image, size); |
260 | if (rc != EOK) |
261 | if (rc != EOK) |
261 | return rc; |
262 | return rc; |
- | 263 | ||
- | 264 | /* |
|
- | 265 | * Not very efficient and it would be better to call it on code only, |
|
- | 266 | * but this whole function is a temporary hack anyway and one day it |
|
- | 267 | * will go in favor of the userspace dynamic loader. |
|
- | 268 | */ |
|
- | 269 | smc_coherence_block(kimage, size); |
|
262 | 270 | ||
- | 271 | uspace_arg_t *kernel_uarg; |
|
263 | uspace_arg_t *kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); |
272 | kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); |
264 | if (kernel_uarg == NULL) { |
273 | if (kernel_uarg == NULL) { |
265 | free(kimage); |
274 | free(kimage); |
266 | return ENOMEM; |
275 | return ENOMEM; |
267 | } |
276 | } |
268 | 277 | ||
Line 287... | Line 296... | ||
287 | free(kimage); |
296 | free(kimage); |
288 | return ENOENT; |
297 | return ENOENT; |
289 | } |
298 | } |
290 | 299 | ||
291 | as_area_t *area = as_area_create(as, |
300 | as_area_t *area = as_area_create(as, |
292 | AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, |
301 | AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, |
293 | LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS, |
302 | LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS, |
294 | AS_AREA_ATTR_NONE, &anon_backend, NULL); |
303 | AS_AREA_ATTR_NONE, &anon_backend, NULL); |
295 | if (area == NULL) { |
304 | if (area == NULL) { |
296 | as_destroy(as); |
305 | as_destroy(as); |
297 | free(kernel_uarg); |
306 | free(kernel_uarg); |
298 | free(kimage); |
307 | free(kimage); |
299 | return ENOMEM; |
308 | return ENOMEM; |
Line 309... | Line 318... | ||
309 | 318 | ||
310 | // FIXME: control the capabilities |
319 | // FIXME: control the capabilities |
311 | cap_set(task, cap_get(TASK)); |
320 | cap_set(task, cap_get(TASK)); |
312 | 321 | ||
313 | thread_t *thread = thread_create(uinit, kernel_uarg, task, |
322 | thread_t *thread = thread_create(uinit, kernel_uarg, task, |
314 | THREAD_FLAG_USPACE, "user", false); |
323 | THREAD_FLAG_USPACE, "user", false); |
315 | if (thread == NULL) { |
324 | if (thread == NULL) { |
316 | task_destroy(task); |
325 | task_destroy(task); |
317 | as_destroy(as); |
326 | as_destroy(as); |
318 | free(kernel_uarg); |
327 | free(kernel_uarg); |
319 | free(kimage); |
328 | free(kimage); |
Line 440... | Line 449... | ||
440 | uint64_t cycles; |
449 | uint64_t cycles; |
441 | char suffix; |
450 | char suffix; |
442 | order(task_get_accounting(t), &cycles, &suffix); |
451 | order(task_get_accounting(t), &cycles, &suffix); |
443 | 452 | ||
444 | #ifdef __32_BITS__ |
453 | #ifdef __32_BITS__ |
445 | printf("%-6" PRIu64 " %-10s %-3" PRIu32 " %10p %10p %9" PRIu64 "%c %7ld %6ld", |
454 | printf("%-6" PRIu64 " %-10s %-3" PRIu32 " %10p %10p %9" PRIu64 |
446 | t->taskid, t->name, t->context, t, t->as, cycles, suffix, |
455 | "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles, |
447 | atomic_get(&t->refcount), atomic_get(&t->active_calls)); |
456 | suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls)); |
448 | #endif |
457 | #endif |
449 | 458 | ||
450 | #ifdef __64_BITS__ |
459 | #ifdef __64_BITS__ |
451 | printf("%-6" PRIu64 " %-10s %-3" PRIu32 " %18p %18p %9" PRIu64 "%c %7ld %6ld", |
460 | printf("%-6" PRIu64 " %-10s %-3" PRIu32 " %18p %18p %9" PRIu64 |
452 | t->taskid, t->name, t->context, t, t->as, cycles, suffix, |
461 | "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles, |
453 | atomic_get(&t->refcount), atomic_get(&t->active_calls)); |
462 | suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls)); |
454 | #endif |
463 | #endif |
455 | 464 | ||
456 | for (j = 0; j < IPC_MAX_PHONES; j++) { |
465 | for (j = 0; j < IPC_MAX_PHONES; j++) { |
457 | if (t->phones[j].callee) |
466 | if (t->phones[j].callee) |
458 | printf(" %d:%p", j, t->phones[j].callee); |
467 | printf(" %d:%p", j, t->phones[j].callee); |
Line 472... | Line 481... | ||
472 | ipl = interrupts_disable(); |
481 | ipl = interrupts_disable(); |
473 | spinlock_lock(&tasks_lock); |
482 | spinlock_lock(&tasks_lock); |
474 | 483 | ||
475 | #ifdef __32_BITS__ |
484 | #ifdef __32_BITS__ |
476 | printf("taskid name ctx address as " |
485 | printf("taskid name ctx address as " |
477 | "cycles threads calls callee\n"); |
486 | "cycles threads calls callee\n"); |
478 | printf("------ ---------- --- ---------- ---------- " |
487 | printf("------ ---------- --- ---------- ---------- " |
479 | "---------- ------- ------ ------>\n"); |
488 | "---------- ------- ------ ------>\n"); |
480 | #endif |
489 | #endif |
481 | 490 | ||
482 | #ifdef __64_BITS__ |
491 | #ifdef __64_BITS__ |
483 | printf("taskid name ctx address as " |
492 | printf("taskid name ctx address as " |
484 | "cycles threads calls callee\n"); |
493 | "cycles threads calls callee\n"); |
485 | printf("------ ---------- --- ------------------ ------------------ " |
494 | printf("------ ---------- --- ------------------ ------------------ " |
486 | "---------- ------- ------ ------>\n"); |
495 | "---------- ------- ------ ------>\n"); |
487 | #endif |
496 | #endif |
488 | 497 | ||
489 | avltree_walk(&tasks_tree, task_print_walker, NULL); |
498 | avltree_walk(&tasks_tree, task_print_walker, NULL); |
490 | 499 | ||
491 | spinlock_unlock(&tasks_lock); |
500 | spinlock_unlock(&tasks_lock); |