Rev 3150 | Rev 3155 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3150 | Rev 3153 | ||
|---|---|---|---|
| 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 445... | Line 446... | ||
| 445 | return ENOMEM; |
446 | return ENOMEM; |
| 446 | 447 | ||
| 447 | int rc = copy_from_uspace(kimage, image, size); |
448 | int rc = copy_from_uspace(kimage, image, size); |
| 448 | if (rc != EOK) |
449 | if (rc != EOK) |
| 449 | return rc; |
450 | return rc; |
| - | 451 | ||
| - | 452 | /* |
|
| - | 453 | * Not very efficient and it would be better to call it on code only, |
|
| - | 454 | * but this whole function is a temporary hack anyway and one day it |
|
| - | 455 | * will go in favor of the userspace dynamic loader. |
|
| - | 456 | */ |
|
| - | 457 | smc_coherence_block(kimage, size); |
|
| 450 | 458 | ||
| - | 459 | uspace_arg_t *kernel_uarg; |
|
| 451 | uspace_arg_t *kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); |
460 | kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); |
| 452 | if (kernel_uarg == NULL) { |
461 | if (kernel_uarg == NULL) { |
| 453 | free(kimage); |
462 | free(kimage); |
| 454 | return ENOMEM; |
463 | return ENOMEM; |
| 455 | } |
464 | } |
| 456 | 465 | ||
| Line 475... | Line 484... | ||
| 475 | free(kimage); |
484 | free(kimage); |
| 476 | return ENOENT; |
485 | return ENOENT; |
| 477 | } |
486 | } |
| 478 | 487 | ||
| 479 | as_area_t *area = as_area_create(as, |
488 | as_area_t *area = as_area_create(as, |
| 480 | AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, |
489 | AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, |
| 481 | LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS, |
490 | LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS, |
| 482 | AS_AREA_ATTR_NONE, &anon_backend, NULL); |
491 | AS_AREA_ATTR_NONE, &anon_backend, NULL); |
| 483 | if (area == NULL) { |
492 | if (area == NULL) { |
| 484 | as_destroy(as); |
493 | as_destroy(as); |
| 485 | free(kernel_uarg); |
494 | free(kernel_uarg); |
| 486 | free(kimage); |
495 | free(kimage); |
| 487 | return ENOMEM; |
496 | return ENOMEM; |
| Line 497... | Line 506... | ||
| 497 | 506 | ||
| 498 | // FIXME: control the capabilities |
507 | // FIXME: control the capabilities |
| 499 | cap_set(task, cap_get(TASK)); |
508 | cap_set(task, cap_get(TASK)); |
| 500 | 509 | ||
| 501 | thread_t *thread = thread_create(uinit, kernel_uarg, task, |
510 | thread_t *thread = thread_create(uinit, kernel_uarg, task, |
| 502 | THREAD_FLAG_USPACE, "user", false); |
511 | THREAD_FLAG_USPACE, "user", false); |
| 503 | if (thread == NULL) { |
512 | if (thread == NULL) { |
| 504 | task_destroy(task); |
513 | task_destroy(task); |
| 505 | as_destroy(as); |
514 | as_destroy(as); |
| 506 | free(kernel_uarg); |
515 | free(kernel_uarg); |
| 507 | free(kimage); |
516 | free(kimage); |
| Line 628... | Line 637... | ||
| 628 | uint64_t cycles; |
637 | uint64_t cycles; |
| 629 | char suffix; |
638 | char suffix; |
| 630 | order(task_get_accounting(t), &cycles, &suffix); |
639 | order(task_get_accounting(t), &cycles, &suffix); |
| 631 | 640 | ||
| 632 | #ifdef __32_BITS__ |
641 | #ifdef __32_BITS__ |
| 633 | printf("%-6" PRIu64 " %-10s %-3" PRIu32 " %10p %10p %9" PRIu64 "%c %7ld %6ld", |
642 | printf("%-6" PRIu64 " %-10s %-3" PRIu32 " %10p %10p %9" PRIu64 |
| 634 | t->taskid, t->name, t->context, t, t->as, cycles, suffix, |
643 | "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles, |
| 635 | atomic_get(&t->refcount), atomic_get(&t->active_calls)); |
644 | suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls)); |
| 636 | #endif |
645 | #endif |
| 637 | 646 | ||
| 638 | #ifdef __64_BITS__ |
647 | #ifdef __64_BITS__ |
| 639 | printf("%-6" PRIu64 " %-10s %-3" PRIu32 " %18p %18p %9" PRIu64 "%c %7ld %6ld", |
648 | printf("%-6" PRIu64 " %-10s %-3" PRIu32 " %18p %18p %9" PRIu64 |
| 640 | t->taskid, t->name, t->context, t, t->as, cycles, suffix, |
649 | "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles, |
| 641 | atomic_get(&t->refcount), atomic_get(&t->active_calls)); |
650 | suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls)); |
| 642 | #endif |
651 | #endif |
| 643 | 652 | ||
| 644 | for (j = 0; j < IPC_MAX_PHONES; j++) { |
653 | for (j = 0; j < IPC_MAX_PHONES; j++) { |
| 645 | if (t->phones[j].callee) |
654 | if (t->phones[j].callee) |
| 646 | printf(" %d:%p", j, t->phones[j].callee); |
655 | printf(" %d:%p", j, t->phones[j].callee); |
| Line 660... | Line 669... | ||
| 660 | ipl = interrupts_disable(); |
669 | ipl = interrupts_disable(); |
| 661 | spinlock_lock(&tasks_lock); |
670 | spinlock_lock(&tasks_lock); |
| 662 | 671 | ||
| 663 | #ifdef __32_BITS__ |
672 | #ifdef __32_BITS__ |
| 664 | printf("taskid name ctx address as " |
673 | printf("taskid name ctx address as " |
| 665 | "cycles threads calls callee\n"); |
674 | "cycles threads calls callee\n"); |
| 666 | printf("------ ---------- --- ---------- ---------- " |
675 | printf("------ ---------- --- ---------- ---------- " |
| 667 | "---------- ------- ------ ------>\n"); |
676 | "---------- ------- ------ ------>\n"); |
| 668 | #endif |
677 | #endif |
| 669 | 678 | ||
| 670 | #ifdef __64_BITS__ |
679 | #ifdef __64_BITS__ |
| 671 | printf("taskid name ctx address as " |
680 | printf("taskid name ctx address as " |
| 672 | "cycles threads calls callee\n"); |
681 | "cycles threads calls callee\n"); |
| 673 | printf("------ ---------- --- ------------------ ------------------ " |
682 | printf("------ ---------- --- ------------------ ------------------ " |
| 674 | "---------- ------- ------ ------>\n"); |
683 | "---------- ------- ------ ------>\n"); |
| 675 | #endif |
684 | #endif |
| 676 | 685 | ||
| 677 | avltree_walk(&tasks_tree, task_print_walker, NULL); |
686 | avltree_walk(&tasks_tree, task_print_walker, NULL); |
| 678 | 687 | ||
| 679 | spinlock_unlock(&tasks_lock); |
688 | spinlock_unlock(&tasks_lock); |