Rev 4055 | Rev 4201 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4055 | Rev 4156 | ||
---|---|---|---|
Line 51... | Line 51... | ||
51 | #include <config.h> |
51 | #include <config.h> |
52 | #include <func.h> |
52 | #include <func.h> |
53 | #include <string.h> |
53 | #include <string.h> |
54 | #include <macros.h> |
54 | #include <macros.h> |
55 | #include <debug.h> |
55 | #include <debug.h> |
56 | #include <symtab.h> |
- | |
57 | #include <cpu.h> |
56 | #include <cpu.h> |
58 | #include <mm/tlb.h> |
57 | #include <mm/tlb.h> |
59 | #include <arch/mm/tlb.h> |
58 | #include <arch/mm/tlb.h> |
60 | #include <mm/frame.h> |
59 | #include <mm/frame.h> |
61 | #include <main/version.h> |
60 | #include <main/version.h> |
Line 63... | Line 62... | ||
63 | #include <proc/scheduler.h> |
62 | #include <proc/scheduler.h> |
64 | #include <proc/thread.h> |
63 | #include <proc/thread.h> |
65 | #include <proc/task.h> |
64 | #include <proc/task.h> |
66 | #include <ipc/ipc.h> |
65 | #include <ipc/ipc.h> |
67 | #include <ipc/irq.h> |
66 | #include <ipc/irq.h> |
- | 67 | #include <symtab.h> |
|
- | 68 | #include <errno.h> |
|
68 | 69 | ||
69 | #ifdef CONFIG_TEST |
70 | #ifdef CONFIG_TEST |
70 | #include <test.h> |
71 | #include <test.h> |
71 | #endif |
72 | #endif |
72 | 73 | ||
Line 77... | Line 78... | ||
77 | .description = "List of supported commands.", |
78 | .description = "List of supported commands.", |
78 | .func = cmd_help, |
79 | .func = cmd_help, |
79 | .argc = 0 |
80 | .argc = 0 |
80 | }; |
81 | }; |
81 | 82 | ||
82 | static cmd_info_t exit_info = { |
- | |
83 | .name = "exit", |
- | |
84 | .description = "Exit kconsole.", |
- | |
85 | .argc = 0 |
- | |
86 | }; |
- | |
87 | - | ||
88 | static int cmd_reboot(cmd_arg_t *argv); |
83 | static int cmd_reboot(cmd_arg_t *argv); |
89 | static cmd_info_t reboot_info = { |
84 | static cmd_info_t reboot_info = { |
90 | .name = "reboot", |
85 | .name = "reboot", |
91 | .description = "Reboot.", |
86 | .description = "Reboot.", |
92 | .func = cmd_reboot, |
87 | .func = cmd_reboot, |
Line 455... | Line 450... | ||
455 | &call2_info, |
450 | &call2_info, |
456 | &call3_info, |
451 | &call3_info, |
457 | &continue_info, |
452 | &continue_info, |
458 | &cpus_info, |
453 | &cpus_info, |
459 | &desc_info, |
454 | &desc_info, |
460 | &exit_info, |
- | |
461 | &reboot_info, |
455 | &reboot_info, |
462 | &uptime_info, |
456 | &uptime_info, |
463 | &halt_info, |
457 | &halt_info, |
464 | &help_info, |
458 | &help_info, |
465 | &ipc_info, |
459 | &ipc_info, |
Line 625... | Line 619... | ||
625 | { |
619 | { |
626 | uintptr_t symaddr; |
620 | uintptr_t symaddr; |
627 | char *symbol; |
621 | char *symbol; |
628 | unative_t (*fnc)(void); |
622 | unative_t (*fnc)(void); |
629 | fncptr_t fptr; |
623 | fncptr_t fptr; |
- | 624 | int rc; |
|
630 | 625 | ||
631 | symaddr = get_symbol_addr((char *) argv->buffer); |
626 | symbol = (char *) argv->buffer; |
- | 627 | rc = symtab_addr_lookup(symbol, &symaddr); |
|
- | 628 | ||
632 | if (!symaddr) |
629 | if (rc == ENOENT) |
633 | printf("Symbol %s not found.\n", argv->buffer); |
630 | printf("Symbol %s not found.\n", symbol); |
634 | else if (symaddr == (uintptr_t) -1) { |
631 | else if (rc == EOVERFLOW) { |
635 | symtab_print_search((char *) argv->buffer); |
632 | symtab_print_search(symbol); |
636 | printf("Duplicate symbol, be more specific.\n"); |
633 | printf("Duplicate symbol, be more specific.\n"); |
637 | } else { |
634 | } else if (rc == EOK) { |
638 | symbol = get_symtab_entry(symaddr); |
635 | fnc = (unative_t (*)(void)) arch_construct_function(&fptr, |
639 | fnc = (unative_t (*)(void)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call0); |
636 | (void *) symaddr, (void *) cmd_call0); |
640 | printf("Calling %s() (%p)\n", symbol, symaddr); |
637 | printf("Calling %s() (%p)\n", symbol, symaddr); |
641 | printf("Result: %#" PRIxn "\n", fnc()); |
638 | printf("Result: %#" PRIxn "\n", fnc()); |
- | 639 | } else { |
|
- | 640 | printf("No symbol information available.\n"); |
|
642 | } |
641 | } |
643 | - | ||
644 | return 1; |
642 | return 1; |
645 | } |
643 | } |
646 | 644 | ||
647 | /** Call function with zero parameters on each CPU */ |
645 | /** Call function with zero parameters on each CPU */ |
648 | int cmd_mcall0(cmd_arg_t *argv) |
646 | int cmd_mcall0(cmd_arg_t *argv) |
Line 679... | Line 677... | ||
679 | uintptr_t symaddr; |
677 | uintptr_t symaddr; |
680 | char *symbol; |
678 | char *symbol; |
681 | unative_t (*fnc)(unative_t, ...); |
679 | unative_t (*fnc)(unative_t, ...); |
682 | unative_t arg1 = argv[1].intval; |
680 | unative_t arg1 = argv[1].intval; |
683 | fncptr_t fptr; |
681 | fncptr_t fptr; |
- | 682 | int rc; |
|
684 | 683 | ||
685 | symaddr = get_symbol_addr((char *) argv->buffer); |
684 | symbol = (char *) argv->buffer; |
- | 685 | rc = symtab_addr_lookup(symbol, &symaddr); |
|
- | 686 | ||
686 | if (!symaddr) |
687 | if (rc == ENOENT) { |
687 | printf("Symbol %s not found.\n", argv->buffer); |
688 | printf("Symbol %s not found.\n", symbol); |
688 | else if (symaddr == (uintptr_t) -1) { |
689 | } else if (rc == EOVERFLOW) { |
689 | symtab_print_search((char *) argv->buffer); |
690 | symtab_print_search(symbol); |
690 | printf("Duplicate symbol, be more specific.\n"); |
691 | printf("Duplicate symbol, be more specific.\n"); |
691 | } else { |
692 | } else if (rc == EOK) { |
692 | symbol = get_symtab_entry(symaddr); |
- | |
693 | fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1); |
693 | fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1); |
694 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol); |
694 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol); |
695 | printf("Result: %#" PRIxn "\n", fnc(arg1)); |
695 | printf("Result: %#" PRIxn "\n", fnc(arg1)); |
- | 696 | } else { |
|
- | 697 | printf("No symbol information available.\n"); |
|
696 | } |
698 | } |
697 | 699 | ||
698 | return 1; |
700 | return 1; |
699 | } |
701 | } |
700 | 702 | ||
701 | /** Call function with two parameters */ |
703 | /** Call function with two parameters */ |
702 | int cmd_call2(cmd_arg_t *argv) |
704 | int cmd_call2(cmd_arg_t *argv) |
Line 705... | Line 707... | ||
705 | char *symbol; |
707 | char *symbol; |
706 | unative_t (*fnc)(unative_t, unative_t, ...); |
708 | unative_t (*fnc)(unative_t, unative_t, ...); |
707 | unative_t arg1 = argv[1].intval; |
709 | unative_t arg1 = argv[1].intval; |
708 | unative_t arg2 = argv[2].intval; |
710 | unative_t arg2 = argv[2].intval; |
709 | fncptr_t fptr; |
711 | fncptr_t fptr; |
- | 712 | int rc; |
|
710 | 713 | ||
711 | symaddr = get_symbol_addr((char *) argv->buffer); |
714 | symbol = (char *) argv->buffer; |
- | 715 | rc = symtab_addr_lookup(symbol, &symaddr); |
|
- | 716 | ||
712 | if (!symaddr) |
717 | if (rc == ENOENT) { |
713 | printf("Symbol %s not found.\n", argv->buffer); |
718 | printf("Symbol %s not found.\n", symbol); |
714 | else if (symaddr == (uintptr_t) -1) { |
719 | } else if (rc == EOVERFLOW) { |
715 | symtab_print_search((char *) argv->buffer); |
720 | symtab_print_search(symbol); |
716 | printf("Duplicate symbol, be more specific.\n"); |
721 | printf("Duplicate symbol, be more specific.\n"); |
717 | } else { |
722 | } else if (rc == EOK) { |
718 | symbol = get_symtab_entry(symaddr); |
- | |
719 | fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2); |
723 | fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2); |
720 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
724 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
721 | arg1, arg2, symaddr, symbol); |
725 | arg1, arg2, symaddr, symbol); |
722 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2)); |
726 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2)); |
- | 727 | } else { |
|
- | 728 | printf("No symbol information available.\n"); |
|
723 | } |
729 | } |
724 | - | ||
725 | return 1; |
730 | return 1; |
726 | } |
731 | } |
727 | 732 | ||
728 | /** Call function with three parameters */ |
733 | /** Call function with three parameters */ |
729 | int cmd_call3(cmd_arg_t *argv) |
734 | int cmd_call3(cmd_arg_t *argv) |
Line 733... | Line 738... | ||
733 | unative_t (*fnc)(unative_t, unative_t, unative_t, ...); |
738 | unative_t (*fnc)(unative_t, unative_t, unative_t, ...); |
734 | unative_t arg1 = argv[1].intval; |
739 | unative_t arg1 = argv[1].intval; |
735 | unative_t arg2 = argv[2].intval; |
740 | unative_t arg2 = argv[2].intval; |
736 | unative_t arg3 = argv[3].intval; |
741 | unative_t arg3 = argv[3].intval; |
737 | fncptr_t fptr; |
742 | fncptr_t fptr; |
- | 743 | int rc; |
|
738 | 744 | ||
739 | symaddr = get_symbol_addr((char *) argv->buffer); |
745 | symbol = (char *) argv->buffer; |
- | 746 | rc = symtab_addr_lookup(symbol, &symaddr); |
|
- | 747 | ||
740 | if (!symaddr) |
748 | if (rc == ENOENT) { |
741 | printf("Symbol %s not found.\n", argv->buffer); |
749 | printf("Symbol %s not found.\n", symbol); |
742 | else if (symaddr == (uintptr_t) -1) { |
750 | } else if (rc == EOVERFLOW) { |
743 | symtab_print_search((char *) argv->buffer); |
751 | symtab_print_search(symbol); |
744 | printf("Duplicate symbol, be more specific.\n"); |
752 | printf("Duplicate symbol, be more specific.\n"); |
745 | } else { |
753 | } else if (rc == EOK) { |
746 | symbol = get_symtab_entry(symaddr); |
- | |
747 | fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call3); |
754 | fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call3); |
748 | printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
755 | printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
749 | arg1, arg2, arg3, symaddr, symbol); |
756 | arg1, arg2, arg3, symaddr, symbol); |
750 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3)); |
757 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3)); |
- | 758 | } else { |
|
- | 759 | printf("No symbol information available.\n"); |
|
751 | } |
760 | } |
752 | - | ||
753 | return 1; |
761 | return 1; |
754 | } |
762 | } |
755 | 763 | ||
756 | 764 | ||
757 | /** Print detailed description of 'describe' command. */ |
765 | /** Print detailed description of 'describe' command. */ |
Line 797... | Line 805... | ||
797 | } |
805 | } |
798 | 806 | ||
799 | /** Write 4 byte value to address */ |
807 | /** Write 4 byte value to address */ |
800 | int cmd_set4(cmd_arg_t *argv) |
808 | int cmd_set4(cmd_arg_t *argv) |
801 | { |
809 | { |
802 | uint32_t *addr; |
810 | uintptr_t addr; |
803 | uint32_t arg1 = argv[1].intval; |
811 | uint32_t arg1 = argv[1].intval; |
804 | bool pointer = false; |
812 | bool pointer = false; |
- | 813 | int rc; |
|
805 | 814 | ||
806 | if (((char *)argv->buffer)[0] == '*') { |
815 | if (((char *)argv->buffer)[0] == '*') { |
807 | addr = (uint32_t *) get_symbol_addr((char *) argv->buffer + 1); |
816 | rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr); |
808 | pointer = true; |
817 | pointer = true; |
809 | } else if (((char *) argv->buffer)[0] >= '0' && |
818 | } else if (((char *) argv->buffer)[0] >= '0' && |
810 | ((char *)argv->buffer)[0] <= '9') |
819 | ((char *)argv->buffer)[0] <= '9') { |
- | 820 | rc = EOK; |
|
811 | addr = (uint32_t *)atoi((char *)argv->buffer); |
821 | addr = atoi((char *)argv->buffer); |
812 | else |
822 | } else { |
813 | addr = (uint32_t *)get_symbol_addr((char *) argv->buffer); |
823 | rc = symtab_addr_lookup((char *) argv->buffer, &addr); |
- | 824 | } |
|
814 | 825 | ||
815 | if (!addr) |
826 | if (rc == ENOENT) |
816 | printf("Symbol %s not found.\n", argv->buffer); |
827 | printf("Symbol %s not found.\n", argv->buffer); |
817 | else if (addr == (uint32_t *) -1) { |
828 | else if (rc == EOVERFLOW) { |
818 | symtab_print_search((char *) argv->buffer); |
829 | symtab_print_search((char *) argv->buffer); |
819 | printf("Duplicate symbol, be more specific.\n"); |
830 | printf("Duplicate symbol, be more specific.\n"); |
820 | } else { |
831 | } else if (rc == EOK) { |
821 | if (pointer) |
832 | if (pointer) |
822 | addr = (uint32_t *)(*(unative_t *)addr); |
833 | addr = *(uintptr_t *) addr; |
823 | printf("Writing %#" PRIx64 " -> %p\n", arg1, addr); |
834 | printf("Writing %#" PRIx64 " -> %p\n", arg1, addr); |
824 | *addr = arg1; |
835 | *(uint32_t *) addr = arg1; |
825 | 836 | } else { |
|
- | 837 | printf("No symbol information available.\n"); |
|
826 | } |
838 | } |
827 | 839 | ||
828 | return 1; |
840 | return 1; |
829 | } |
841 | } |
830 | 842 |