Rev 3471 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3471 | Rev 4377 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | /** @addtogroup genericconsole |
29 | /** @addtogroup genericconsole |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** |
33 | /** |
34 | * @file cmd.c |
34 | * @file cmd.c |
35 | * @brief Kernel console command wrappers. |
35 | * @brief Kernel console command wrappers. |
36 | * |
36 | * |
37 | * This file is meant to contain all wrapper functions for |
37 | * This file is meant to contain all wrapper functions for |
38 | * all kconsole commands. The point is in separating |
38 | * all kconsole commands. The point is in separating |
39 | * kconsole specific wrappers from kconsole-unaware functions |
39 | * kconsole specific wrappers from kconsole-unaware functions |
40 | * from other subsystems. |
40 | * from other subsystems. |
Line 48... | Line 48... | ||
48 | #include <arch/types.h> |
48 | #include <arch/types.h> |
49 | #include <adt/list.h> |
49 | #include <adt/list.h> |
50 | #include <arch.h> |
50 | #include <arch.h> |
51 | #include <config.h> |
51 | #include <config.h> |
52 | #include <func.h> |
52 | #include <func.h> |
- | 53 | #include <string.h> |
|
53 | #include <macros.h> |
54 | #include <macros.h> |
54 | #include <debug.h> |
55 | #include <debug.h> |
55 | #include <symtab.h> |
- | |
56 | #include <cpu.h> |
56 | #include <cpu.h> |
57 | #include <mm/tlb.h> |
57 | #include <mm/tlb.h> |
58 | #include <arch/mm/tlb.h> |
58 | #include <arch/mm/tlb.h> |
59 | #include <mm/frame.h> |
59 | #include <mm/frame.h> |
60 | #include <main/version.h> |
60 | #include <main/version.h> |
Line 62... | Line 62... | ||
62 | #include <proc/scheduler.h> |
62 | #include <proc/scheduler.h> |
63 | #include <proc/thread.h> |
63 | #include <proc/thread.h> |
64 | #include <proc/task.h> |
64 | #include <proc/task.h> |
65 | #include <ipc/ipc.h> |
65 | #include <ipc/ipc.h> |
66 | #include <ipc/irq.h> |
66 | #include <ipc/irq.h> |
- | 67 | #include <ipc/event.h> |
|
- | 68 | #include <symtab.h> |
|
- | 69 | #include <errno.h> |
|
67 | 70 | ||
68 | #ifdef CONFIG_TEST |
71 | #ifdef CONFIG_TEST |
69 | #include <test.h> |
72 | #include <test.h> |
70 | #endif |
73 | #endif |
71 | 74 | ||
Line 76... | Line 79... | ||
76 | .description = "List of supported commands.", |
79 | .description = "List of supported commands.", |
77 | .func = cmd_help, |
80 | .func = cmd_help, |
78 | .argc = 0 |
81 | .argc = 0 |
79 | }; |
82 | }; |
80 | 83 | ||
81 | static cmd_info_t exit_info = { |
- | |
82 | .name = "exit", |
- | |
83 | .description = "Exit kconsole.", |
- | |
84 | .argc = 0 |
- | |
85 | }; |
- | |
86 | - | ||
87 | static int cmd_reboot(cmd_arg_t *argv); |
84 | static int cmd_reboot(cmd_arg_t *argv); |
88 | static cmd_info_t reboot_info = { |
85 | static cmd_info_t reboot_info = { |
89 | .name = "reboot", |
86 | .name = "reboot", |
90 | .description = "Reboot.", |
87 | .description = "Reboot.", |
91 | .func = cmd_reboot, |
88 | .func = cmd_reboot, |
Line 454... | Line 451... | ||
454 | &call2_info, |
451 | &call2_info, |
455 | &call3_info, |
452 | &call3_info, |
456 | &continue_info, |
453 | &continue_info, |
457 | &cpus_info, |
454 | &cpus_info, |
458 | &desc_info, |
455 | &desc_info, |
459 | &exit_info, |
- | |
460 | &reboot_info, |
456 | &reboot_info, |
461 | &uptime_info, |
457 | &uptime_info, |
462 | &halt_info, |
458 | &halt_info, |
463 | &help_info, |
459 | &help_info, |
464 | &ipc_info, |
460 | &ipc_info, |
Line 499... | Line 495... | ||
499 | unsigned int i; |
495 | unsigned int i; |
500 | 496 | ||
501 | for (i = 0; basic_commands[i]; i++) { |
497 | for (i = 0; basic_commands[i]; i++) { |
502 | cmd_initialize(basic_commands[i]); |
498 | cmd_initialize(basic_commands[i]); |
503 | if (!cmd_register(basic_commands[i])) |
499 | if (!cmd_register(basic_commands[i])) |
504 | panic("could not register command %s\n", basic_commands[i]->name); |
500 | printf("Cannot register command %s\n", basic_commands[i]->name); |
505 | } |
501 | } |
506 | } |
502 | } |
507 | 503 | ||
508 | 504 | ||
509 | /** List supported commands. |
505 | /** List supported commands. |
Line 512... | Line 508... | ||
512 | * |
508 | * |
513 | * @return 0 on failure, 1 on success. |
509 | * @return 0 on failure, 1 on success. |
514 | */ |
510 | */ |
515 | int cmd_help(cmd_arg_t *argv) |
511 | int cmd_help(cmd_arg_t *argv) |
516 | { |
512 | { |
517 | link_t *cur; |
- | |
518 | - | ||
519 | spinlock_lock(&cmd_lock); |
513 | spinlock_lock(&cmd_lock); |
520 | 514 | ||
- | 515 | link_t *cur; |
|
- | 516 | count_t len = 0; |
|
521 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
517 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
522 | cmd_info_t *hlp; |
518 | cmd_info_t *hlp; |
523 | - | ||
524 | hlp = list_get_instance(cur, cmd_info_t, link); |
519 | hlp = list_get_instance(cur, cmd_info_t, link); |
- | 520 | ||
525 | spinlock_lock(&hlp->lock); |
521 | spinlock_lock(&hlp->lock); |
- | 522 | if (str_length(hlp->name) > len) |
|
- | 523 | len = str_length(hlp->name); |
|
- | 524 | spinlock_unlock(&hlp->lock); |
|
- | 525 | } |
|
- | 526 | ||
- | 527 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
|
- | 528 | cmd_info_t *hlp; |
|
- | 529 | hlp = list_get_instance(cur, cmd_info_t, link); |
|
526 | 530 | ||
- | 531 | spinlock_lock(&hlp->lock); |
|
527 | printf("%s - %s\n", hlp->name, hlp->description); |
532 | printf("%-*s %s\n", len, hlp->name, hlp->description); |
528 | - | ||
529 | spinlock_unlock(&hlp->lock); |
533 | spinlock_unlock(&hlp->lock); |
530 | } |
534 | } |
531 | 535 | ||
532 | spinlock_unlock(&cmd_lock); |
536 | spinlock_unlock(&cmd_lock); |
533 | 537 | ||
534 | return 1; |
538 | return 1; |
535 | } |
539 | } |
536 | 540 | ||
537 | 541 | ||
538 | /** Reboot the system. |
542 | /** Reboot the system. |
Line 576... | Line 580... | ||
576 | * @return 0 on failure, 1 on success. |
580 | * @return 0 on failure, 1 on success. |
577 | */ |
581 | */ |
578 | int cmd_desc(cmd_arg_t *argv) |
582 | int cmd_desc(cmd_arg_t *argv) |
579 | { |
583 | { |
580 | link_t *cur; |
584 | link_t *cur; |
581 | 585 | ||
582 | spinlock_lock(&cmd_lock); |
586 | spinlock_lock(&cmd_lock); |
583 | 587 | ||
584 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
588 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
585 | cmd_info_t *hlp; |
589 | cmd_info_t *hlp; |
586 | 590 | ||
587 | hlp = list_get_instance(cur, cmd_info_t, link); |
591 | hlp = list_get_instance(cur, cmd_info_t, link); |
588 | spinlock_lock(&hlp->lock); |
592 | spinlock_lock(&hlp->lock); |
589 | 593 | ||
590 | if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) { |
594 | if (str_lcmp(hlp->name, (const char *) argv->buffer, str_length(hlp->name)) == 0) { |
591 | printf("%s - %s\n", hlp->name, hlp->description); |
595 | printf("%s - %s\n", hlp->name, hlp->description); |
592 | if (hlp->help) |
596 | if (hlp->help) |
593 | hlp->help(); |
597 | hlp->help(); |
594 | spinlock_unlock(&hlp->lock); |
598 | spinlock_unlock(&hlp->lock); |
595 | break; |
599 | break; |
596 | } |
600 | } |
597 | 601 | ||
598 | spinlock_unlock(&hlp->lock); |
602 | spinlock_unlock(&hlp->lock); |
599 | } |
603 | } |
600 | 604 | ||
601 | spinlock_unlock(&cmd_lock); |
605 | spinlock_unlock(&cmd_lock); |
602 | 606 | ||
603 | return 1; |
607 | return 1; |
604 | } |
608 | } |
605 | 609 | ||
606 | /** Search symbol table */ |
610 | /** Search symbol table */ |
607 | int cmd_symaddr(cmd_arg_t *argv) |
611 | int cmd_symaddr(cmd_arg_t *argv) |
Line 614... | Line 618... | ||
614 | /** Call function with zero parameters */ |
618 | /** Call function with zero parameters */ |
615 | int cmd_call0(cmd_arg_t *argv) |
619 | int cmd_call0(cmd_arg_t *argv) |
616 | { |
620 | { |
617 | uintptr_t symaddr; |
621 | uintptr_t symaddr; |
618 | char *symbol; |
622 | char *symbol; |
619 | unative_t (*f)(void); |
623 | unative_t (*fnc)(void); |
620 | #ifdef ia64 |
- | |
621 | struct { |
- | |
622 | unative_t f; |
- | |
623 | unative_t gp; |
624 | fncptr_t fptr; |
624 | } fptr; |
625 | int rc; |
625 | #endif |
- | |
626 | 626 | ||
627 | symaddr = get_symbol_addr((char *) argv->buffer); |
627 | symbol = (char *) argv->buffer; |
- | 628 | rc = symtab_addr_lookup(symbol, &symaddr); |
|
- | 629 | ||
628 | if (!symaddr) |
630 | if (rc == ENOENT) |
629 | printf("Symbol %s not found.\n", argv->buffer); |
631 | printf("Symbol %s not found.\n", symbol); |
630 | else if (symaddr == (uintptr_t) -1) { |
632 | else if (rc == EOVERFLOW) { |
631 | symtab_print_search((char *) argv->buffer); |
633 | symtab_print_search(symbol); |
632 | printf("Duplicate symbol, be more specific.\n"); |
634 | printf("Duplicate symbol, be more specific.\n"); |
633 | } else { |
635 | } else if (rc == EOK) { |
- | 636 | fnc = (unative_t (*)(void)) arch_construct_function(&fptr, |
|
634 | symbol = get_symtab_entry(symaddr); |
637 | (void *) symaddr, (void *) cmd_call0); |
635 | printf("Calling %s() (%p)\n", symbol, symaddr); |
638 | printf("Calling %s() (%p)\n", symbol, symaddr); |
636 | #ifdef ia64 |
- | |
637 | fptr.f = symaddr; |
- | |
638 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
639 | printf("Result: %#" PRIxn "\n", fnc()); |
639 | f = (unative_t (*)(void)) &fptr; |
- | |
640 | #else |
640 | } else { |
641 | f = (unative_t (*)(void)) symaddr; |
- | |
642 | #endif |
- | |
643 | printf("Result: %#" PRIxn "\n", f()); |
641 | printf("No symbol information available.\n"); |
644 | } |
642 | } |
645 | - | ||
646 | return 1; |
643 | return 1; |
647 | } |
644 | } |
648 | 645 | ||
649 | /** Call function with zero parameters on each CPU */ |
646 | /** Call function with zero parameters on each CPU */ |
650 | int cmd_mcall0(cmd_arg_t *argv) |
647 | int cmd_mcall0(cmd_arg_t *argv) |
Line 678... | Line 675... | ||
678 | /** Call function with one parameter */ |
675 | /** Call function with one parameter */ |
679 | int cmd_call1(cmd_arg_t *argv) |
676 | int cmd_call1(cmd_arg_t *argv) |
680 | { |
677 | { |
681 | uintptr_t symaddr; |
678 | uintptr_t symaddr; |
682 | char *symbol; |
679 | char *symbol; |
683 | unative_t (*f)(unative_t,...); |
680 | unative_t (*fnc)(unative_t, ...); |
684 | unative_t arg1 = argv[1].intval; |
681 | unative_t arg1 = argv[1].intval; |
685 | #ifdef ia64 |
- | |
686 | struct { |
- | |
687 | unative_t f; |
- | |
688 | unative_t gp; |
682 | fncptr_t fptr; |
689 | } fptr; |
683 | int rc; |
690 | #endif |
- | |
691 | 684 | ||
692 | symaddr = get_symbol_addr((char *) argv->buffer); |
- | |
693 | if (!symaddr) |
- | |
694 | printf("Symbol %s not found.\n", argv->buffer); |
- | |
695 | else if (symaddr == (uintptr_t) -1) { |
- | |
696 | symtab_print_search((char *) argv->buffer); |
685 | symbol = (char *) argv->buffer; |
697 | printf("Duplicate symbol, be more specific.\n"); |
- | |
698 | } else { |
- | |
699 | symbol = get_symtab_entry(symaddr); |
686 | rc = symtab_addr_lookup(symbol, &symaddr); |
700 | 687 | ||
- | 688 | if (rc == ENOENT) { |
|
- | 689 | printf("Symbol %s not found.\n", symbol); |
|
- | 690 | } else if (rc == EOVERFLOW) { |
|
- | 691 | symtab_print_search(symbol); |
|
- | 692 | printf("Duplicate symbol, be more specific.\n"); |
|
- | 693 | } else if (rc == EOK) { |
|
- | 694 | fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1); |
|
701 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol); |
695 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol); |
702 | #ifdef ia64 |
- | |
703 | fptr.f = symaddr; |
- | |
704 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
- | |
705 | f = (unative_t (*)(unative_t,...)) &fptr; |
696 | printf("Result: %#" PRIxn "\n", fnc(arg1)); |
706 | #else |
697 | } else { |
707 | f = (unative_t (*)(unative_t,...)) symaddr; |
- | |
708 | #endif |
- | |
709 | printf("Result: %#" PRIxn "\n", f(arg1)); |
698 | printf("No symbol information available.\n"); |
710 | } |
699 | } |
711 | 700 | ||
712 | return 1; |
701 | return 1; |
713 | } |
702 | } |
714 | 703 | ||
715 | /** Call function with two parameters */ |
704 | /** Call function with two parameters */ |
716 | int cmd_call2(cmd_arg_t *argv) |
705 | int cmd_call2(cmd_arg_t *argv) |
717 | { |
706 | { |
718 | uintptr_t symaddr; |
707 | uintptr_t symaddr; |
719 | char *symbol; |
708 | char *symbol; |
720 | unative_t (*f)(unative_t,unative_t,...); |
709 | unative_t (*fnc)(unative_t, unative_t, ...); |
721 | unative_t arg1 = argv[1].intval; |
710 | unative_t arg1 = argv[1].intval; |
722 | unative_t arg2 = argv[2].intval; |
711 | unative_t arg2 = argv[2].intval; |
723 | #ifdef ia64 |
- | |
724 | struct { |
- | |
725 | unative_t f; |
- | |
726 | unative_t gp; |
712 | fncptr_t fptr; |
727 | }fptr; |
713 | int rc; |
728 | #endif |
- | |
729 | 714 | ||
730 | symaddr = get_symbol_addr((char *) argv->buffer); |
715 | symbol = (char *) argv->buffer; |
- | 716 | rc = symtab_addr_lookup(symbol, &symaddr); |
|
- | 717 | ||
731 | if (!symaddr) |
718 | if (rc == ENOENT) { |
732 | printf("Symbol %s not found.\n", argv->buffer); |
719 | printf("Symbol %s not found.\n", symbol); |
733 | else if (symaddr == (uintptr_t) -1) { |
720 | } else if (rc == EOVERFLOW) { |
734 | symtab_print_search((char *) argv->buffer); |
721 | symtab_print_search(symbol); |
735 | printf("Duplicate symbol, be more specific.\n"); |
722 | printf("Duplicate symbol, be more specific.\n"); |
736 | } else { |
723 | } else if (rc == EOK) { |
737 | symbol = get_symtab_entry(symaddr); |
724 | fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2); |
738 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
725 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
739 | arg1, arg2, symaddr, symbol); |
726 | arg1, arg2, symaddr, symbol); |
740 | #ifdef ia64 |
- | |
741 | fptr.f = symaddr; |
- | |
742 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
727 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2)); |
743 | f = (unative_t (*)(unative_t,unative_t,...)) &fptr; |
- | |
744 | #else |
728 | } else { |
745 | f = (unative_t (*)(unative_t,unative_t,...)) symaddr; |
- | |
746 | #endif |
- | |
747 | printf("Result: %#" PRIxn "\n", f(arg1, arg2)); |
729 | printf("No symbol information available.\n"); |
748 | } |
730 | } |
749 | - | ||
750 | return 1; |
731 | return 1; |
751 | } |
732 | } |
752 | 733 | ||
753 | /** Call function with three parameters */ |
734 | /** Call function with three parameters */ |
754 | int cmd_call3(cmd_arg_t *argv) |
735 | int cmd_call3(cmd_arg_t *argv) |
755 | { |
736 | { |
756 | uintptr_t symaddr; |
737 | uintptr_t symaddr; |
757 | char *symbol; |
738 | char *symbol; |
758 | unative_t (*f)(unative_t,unative_t,unative_t,...); |
739 | unative_t (*fnc)(unative_t, unative_t, unative_t, ...); |
759 | unative_t arg1 = argv[1].intval; |
740 | unative_t arg1 = argv[1].intval; |
760 | unative_t arg2 = argv[2].intval; |
741 | unative_t arg2 = argv[2].intval; |
761 | unative_t arg3 = argv[3].intval; |
742 | unative_t arg3 = argv[3].intval; |
762 | #ifdef ia64 |
- | |
763 | struct { |
- | |
764 | unative_t f; |
- | |
765 | unative_t gp; |
743 | fncptr_t fptr; |
766 | }fptr; |
744 | int rc; |
767 | #endif |
745 | |
- | 746 | symbol = (char *) argv->buffer; |
|
- | 747 | rc = symtab_addr_lookup(symbol, &symaddr); |
|
768 | 748 | ||
769 | symaddr = get_symbol_addr((char *) argv->buffer); |
- | |
770 | if (!symaddr) |
749 | if (rc == ENOENT) { |
771 | printf("Symbol %s not found.\n", argv->buffer); |
750 | printf("Symbol %s not found.\n", symbol); |
772 | else if (symaddr == (uintptr_t) -1) { |
751 | } else if (rc == EOVERFLOW) { |
773 | symtab_print_search((char *) argv->buffer); |
752 | symtab_print_search(symbol); |
774 | printf("Duplicate symbol, be more specific.\n"); |
753 | printf("Duplicate symbol, be more specific.\n"); |
775 | } else { |
754 | } else if (rc == EOK) { |
776 | symbol = get_symtab_entry(symaddr); |
755 | fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call3); |
777 | printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
756 | printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
778 | arg1, arg2, arg3, symaddr, symbol); |
757 | arg1, arg2, arg3, symaddr, symbol); |
779 | #ifdef ia64 |
- | |
780 | fptr.f = symaddr; |
- | |
781 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
- | |
782 | f = (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr; |
758 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3)); |
783 | #else |
759 | } else { |
784 | f = (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr; |
- | |
785 | #endif |
- | |
786 | printf("Result: %#" PRIxn "\n", f(arg1, arg2, arg3)); |
760 | printf("No symbol information available.\n"); |
787 | } |
761 | } |
788 | - | ||
789 | return 1; |
762 | return 1; |
790 | } |
763 | } |
791 | 764 | ||
792 | 765 | ||
793 | /** Print detailed description of 'describe' command. */ |
766 | /** Print detailed description of 'describe' command. */ |
Line 833... | Line 806... | ||
833 | } |
806 | } |
834 | 807 | ||
835 | /** Write 4 byte value to address */ |
808 | /** Write 4 byte value to address */ |
836 | int cmd_set4(cmd_arg_t *argv) |
809 | int cmd_set4(cmd_arg_t *argv) |
837 | { |
810 | { |
838 | uint32_t *addr; |
811 | uintptr_t addr; |
839 | uint32_t arg1 = argv[1].intval; |
812 | uint32_t arg1 = argv[1].intval; |
840 | bool pointer = false; |
813 | bool pointer = false; |
- | 814 | int rc; |
|
841 | 815 | ||
842 | if (((char *)argv->buffer)[0] == '*') { |
816 | if (((char *)argv->buffer)[0] == '*') { |
843 | addr = (uint32_t *) get_symbol_addr((char *) argv->buffer + 1); |
817 | rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr); |
844 | pointer = true; |
818 | pointer = true; |
845 | } else if (((char *) argv->buffer)[0] >= '0' && |
819 | } else if (((char *) argv->buffer)[0] >= '0' && |
846 | ((char *)argv->buffer)[0] <= '9') |
820 | ((char *)argv->buffer)[0] <= '9') { |
- | 821 | rc = EOK; |
|
847 | addr = (uint32_t *)atoi((char *)argv->buffer); |
822 | addr = atoi((char *)argv->buffer); |
848 | else |
823 | } else { |
849 | addr = (uint32_t *)get_symbol_addr((char *) argv->buffer); |
824 | rc = symtab_addr_lookup((char *) argv->buffer, &addr); |
- | 825 | } |
|
850 | 826 | ||
851 | if (!addr) |
827 | if (rc == ENOENT) |
852 | printf("Symbol %s not found.\n", argv->buffer); |
828 | printf("Symbol %s not found.\n", argv->buffer); |
853 | else if (addr == (uint32_t *) -1) { |
829 | else if (rc == EOVERFLOW) { |
854 | symtab_print_search((char *) argv->buffer); |
830 | symtab_print_search((char *) argv->buffer); |
855 | printf("Duplicate symbol, be more specific.\n"); |
831 | printf("Duplicate symbol, be more specific.\n"); |
856 | } else { |
832 | } else if (rc == EOK) { |
857 | if (pointer) |
833 | if (pointer) |
858 | addr = (uint32_t *)(*(unative_t *)addr); |
834 | addr = *(uintptr_t *) addr; |
859 | printf("Writing %#" PRIx64 " -> %p\n", arg1, addr); |
835 | printf("Writing %#" PRIx64 " -> %p\n", arg1, addr); |
860 | *addr = arg1; |
836 | *(uint32_t *) addr = arg1; |
861 | 837 | } else { |
|
- | 838 | printf("No symbol information available.\n"); |
|
862 | } |
839 | } |
863 | 840 | ||
864 | return 1; |
841 | return 1; |
865 | } |
842 | } |
866 | 843 | ||
Line 974... | Line 951... | ||
974 | * return Always 1. |
951 | * return Always 1. |
975 | */ |
952 | */ |
976 | int cmd_continue(cmd_arg_t *argv) |
953 | int cmd_continue(cmd_arg_t *argv) |
977 | { |
954 | { |
978 | printf("The kernel will now relinquish the console.\n"); |
955 | printf("The kernel will now relinquish the console.\n"); |
979 | printf("Use userspace controls to redraw the screen.\n"); |
- | |
980 | arch_release_console(); |
956 | release_console(); |
- | 957 | ||
- | 958 | event_notify_0(EVENT_KCONSOLE); |
|
- | 959 | indev_pop_character(stdin); |
|
- | 960 | ||
981 | return 1; |
961 | return 1; |
982 | } |
962 | } |
983 | 963 | ||
984 | #ifdef CONFIG_TEST |
964 | #ifdef CONFIG_TEST |
985 | /** Command for printing kernel tests list. |
965 | /** Command for printing kernel tests list. |
Line 988... | Line 968... | ||
988 | * |
968 | * |
989 | * return Always 1. |
969 | * return Always 1. |
990 | */ |
970 | */ |
991 | int cmd_tests(cmd_arg_t *argv) |
971 | int cmd_tests(cmd_arg_t *argv) |
992 | { |
972 | { |
- | 973 | count_t len = 0; |
|
993 | test_t *test; |
974 | test_t *test; |
- | 975 | for (test = tests; test->name != NULL; test++) { |
|
- | 976 | if (str_length(test->name) > len) |
|
- | 977 | len = str_length(test->name); |
|
- | 978 | } |
|
994 | 979 | ||
995 | for (test = tests; test->name != NULL; test++) |
980 | for (test = tests; test->name != NULL; test++) |
996 | printf("%s\t\t%s%s\n", test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
981 | printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
997 | 982 | ||
998 | printf("*\t\tRun all safe tests\n"); |
983 | printf("%-*s Run all safe tests\n", len, "*"); |
999 | return 1; |
984 | return 1; |
1000 | } |
985 | } |
1001 | 986 | ||
1002 | static bool run_test(const test_t *test) |
987 | static bool run_test(const test_t *test) |
1003 | { |
988 | { |
1004 | printf("%s\t\t%s\n", test->name, test->desc); |
989 | printf("%s (%s)\n", test->name, test->desc); |
1005 | 990 | ||
1006 | /* Update and read thread accounting |
991 | /* Update and read thread accounting |
1007 | for benchmarking */ |
992 | for benchmarking */ |
1008 | ipl_t ipl = interrupts_disable(); |
993 | ipl_t ipl = interrupts_disable(); |
1009 | spinlock_lock(&TASK->lock); |
994 | spinlock_lock(&TASK->lock); |
1010 | uint64_t t0 = task_get_accounting(TASK); |
995 | uint64_t t0 = task_get_accounting(TASK); |
1011 | spinlock_unlock(&TASK->lock); |
996 | spinlock_unlock(&TASK->lock); |
1012 | interrupts_restore(ipl); |
997 | interrupts_restore(ipl); |
1013 | 998 | ||
1014 | /* Execute the test */ |
999 | /* Execute the test */ |
- | 1000 | test_quiet = false; |
|
1015 | char * ret = test->entry(false); |
1001 | char *ret = test->entry(); |
1016 | 1002 | ||
1017 | /* Update and read thread accounting */ |
1003 | /* Update and read thread accounting */ |
1018 | ipl = interrupts_disable(); |
1004 | ipl = interrupts_disable(); |
1019 | spinlock_lock(&TASK->lock); |
1005 | spinlock_lock(&TASK->lock); |
1020 | uint64_t dt = task_get_accounting(TASK) - t0; |
1006 | uint64_t dt = task_get_accounting(TASK) - t0; |
Line 1062... | Line 1048... | ||
1062 | uint64_t t0 = task_get_accounting(TASK); |
1048 | uint64_t t0 = task_get_accounting(TASK); |
1063 | spinlock_unlock(&TASK->lock); |
1049 | spinlock_unlock(&TASK->lock); |
1064 | interrupts_restore(ipl); |
1050 | interrupts_restore(ipl); |
1065 | 1051 | ||
1066 | /* Execute the test */ |
1052 | /* Execute the test */ |
- | 1053 | test_quiet = true; |
|
1067 | char * ret = test->entry(true); |
1054 | char * ret = test->entry(); |
1068 | 1055 | ||
1069 | /* Update and read thread accounting */ |
1056 | /* Update and read thread accounting */ |
1070 | ipl = interrupts_disable(); |
1057 | ipl = interrupts_disable(); |
1071 | spinlock_lock(&TASK->lock); |
1058 | spinlock_lock(&TASK->lock); |
1072 | uint64_t dt = task_get_accounting(TASK) - t0; |
1059 | uint64_t dt = task_get_accounting(TASK) - t0; |
Line 1110... | Line 1097... | ||
1110 | */ |
1097 | */ |
1111 | int cmd_test(cmd_arg_t *argv) |
1098 | int cmd_test(cmd_arg_t *argv) |
1112 | { |
1099 | { |
1113 | test_t *test; |
1100 | test_t *test; |
1114 | 1101 | ||
1115 | if (strcmp((char *) argv->buffer, "*") == 0) { |
1102 | if (str_cmp((char *) argv->buffer, "*") == 0) { |
1116 | for (test = tests; test->name != NULL; test++) { |
1103 | for (test = tests; test->name != NULL; test++) { |
1117 | if (test->safe) { |
1104 | if (test->safe) { |
1118 | printf("\n"); |
1105 | printf("\n"); |
1119 | if (!run_test(test)) |
1106 | if (!run_test(test)) |
1120 | break; |
1107 | break; |
Line 1122... | Line 1109... | ||
1122 | } |
1109 | } |
1123 | } else { |
1110 | } else { |
1124 | bool fnd = false; |
1111 | bool fnd = false; |
1125 | 1112 | ||
1126 | for (test = tests; test->name != NULL; test++) { |
1113 | for (test = tests; test->name != NULL; test++) { |
1127 | if (strcmp(test->name, (char *) argv->buffer) == 0) { |
1114 | if (str_cmp(test->name, (char *) argv->buffer) == 0) { |
1128 | fnd = true; |
1115 | fnd = true; |
1129 | run_test(test); |
1116 | run_test(test); |
1130 | break; |
1117 | break; |
1131 | } |
1118 | } |
1132 | } |
1119 | } |
Line 1147... | Line 1134... | ||
1147 | int cmd_bench(cmd_arg_t *argv) |
1134 | int cmd_bench(cmd_arg_t *argv) |
1148 | { |
1135 | { |
1149 | test_t *test; |
1136 | test_t *test; |
1150 | uint32_t cnt = argv[1].intval; |
1137 | uint32_t cnt = argv[1].intval; |
1151 | 1138 | ||
1152 | bool fnd = false; |
1139 | if (str_cmp((char *) argv->buffer, "*") == 0) { |
1153 | - | ||
1154 | for (test = tests; test->name != NULL; test++) { |
1140 | for (test = tests; test->name != NULL; test++) { |
1155 | if (strcmp(test->name, (char *) argv->buffer) == 0) { |
- | |
1156 | fnd = true; |
- | |
1157 | - | ||
1158 | if (test->safe) |
1141 | if (test->safe) { |
1159 | run_bench(test, cnt); |
1142 | if (!run_bench(test, cnt)) |
1160 | else |
1143 | break; |
1161 | printf("Unsafe test\n"); |
- | |
1162 | 1144 | } |
|
1163 | break; |
- | |
1164 | } |
1145 | } |
1165 | } |
1146 | } else { |
- | 1147 | bool fnd = false; |
|
1166 | 1148 | ||
- | 1149 | for (test = tests; test->name != NULL; test++) { |
|
- | 1150 | if (str_cmp(test->name, (char *) argv->buffer) == 0) { |
|
- | 1151 | fnd = true; |
|
- | 1152 | ||
- | 1153 | if (test->safe) |
|
- | 1154 | run_bench(test, cnt); |
|
- | 1155 | else |
|
- | 1156 | printf("Unsafe test\n"); |
|
- | 1157 | ||
- | 1158 | break; |
|
- | 1159 | } |
|
- | 1160 | } |
|
- | 1161 | ||
1167 | if (!fnd) |
1162 | if (!fnd) |
1168 | printf("Unknown test\n"); |
1163 | printf("Unknown test\n"); |
- | 1164 | } |
|
1169 | 1165 | ||
1170 | return 1; |
1166 | return 1; |
1171 | } |
1167 | } |
1172 | 1168 | ||
1173 | #endif |
1169 | #endif |
1174 | 1170 |