Rev 4090 | Rev 4137 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4090 | Rev 4132 | ||
---|---|---|---|
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 64... | Line 63... | ||
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> |
68 | 67 | ||
- | 68 | #ifdef CONFIG_SYMTAB |
|
- | 69 | #include <symtab.h> |
|
- | 70 | #endif |
|
- | 71 | ||
69 | #ifdef CONFIG_TEST |
72 | #ifdef CONFIG_TEST |
70 | #include <test.h> |
73 | #include <test.h> |
71 | #endif |
74 | #endif |
72 | 75 | ||
73 | /* Data and methods for 'help' command. */ |
76 | /* Data and methods for 'help' command. */ |
Line 165... | Line 168... | ||
165 | .func = cmd_desc, |
168 | .func = cmd_desc, |
166 | .argc = 1, |
169 | .argc = 1, |
167 | .argv = &desc_argv |
170 | .argv = &desc_argv |
168 | }; |
171 | }; |
169 | 172 | ||
- | 173 | #ifdef CONFIG_SYMTAB |
|
170 | /* Data and methods for 'symaddr' command. */ |
174 | /* Data and methods for 'symaddr' command. */ |
171 | static int cmd_symaddr(cmd_arg_t *argv); |
175 | static int cmd_symaddr(cmd_arg_t *argv); |
172 | static char symaddr_buf[MAX_CMDLINE+1]; |
176 | static char symaddr_buf[MAX_CMDLINE+1]; |
173 | static cmd_arg_t symaddr_argv = { |
177 | static cmd_arg_t symaddr_argv = { |
174 | .type = ARG_TYPE_STRING, |
178 | .type = ARG_TYPE_STRING, |
Line 180... | Line 184... | ||
180 | .description = "Return symbol address.", |
184 | .description = "Return symbol address.", |
181 | .func = cmd_symaddr, |
185 | .func = cmd_symaddr, |
182 | .argc = 1, |
186 | .argc = 1, |
183 | .argv = &symaddr_argv |
187 | .argv = &symaddr_argv |
184 | }; |
188 | }; |
- | 189 | #endif |
|
185 | 190 | ||
186 | static char set_buf[MAX_CMDLINE+1]; |
191 | static char set_buf[MAX_CMDLINE+1]; |
187 | static int cmd_set4(cmd_arg_t *argv); |
192 | static int cmd_set4(cmd_arg_t *argv); |
188 | static cmd_arg_t set4_argv[] = { |
193 | static cmd_arg_t set4_argv[] = { |
189 | { |
194 | { |
Line 456... | Line 461... | ||
456 | &halt_info, |
461 | &halt_info, |
457 | &help_info, |
462 | &help_info, |
458 | &ipc_info, |
463 | &ipc_info, |
459 | &set4_info, |
464 | &set4_info, |
460 | &slabs_info, |
465 | &slabs_info, |
- | 466 | #ifdef CONFIG_SYMTAB |
|
461 | &symaddr_info, |
467 | &symaddr_info, |
- | 468 | #endif |
|
462 | &sched_info, |
469 | &sched_info, |
463 | &threads_info, |
470 | &threads_info, |
464 | &tasks_info, |
471 | &tasks_info, |
465 | &physmem_info, |
472 | &physmem_info, |
466 | &tlb_info, |
473 | &tlb_info, |
Line 603... | Line 610... | ||
603 | spinlock_unlock(&cmd_lock); |
610 | spinlock_unlock(&cmd_lock); |
604 | 611 | ||
605 | return 1; |
612 | return 1; |
606 | } |
613 | } |
607 | 614 | ||
- | 615 | #ifdef CONFIG_SYMTAB |
|
- | 616 | ||
608 | /** Search symbol table */ |
617 | /** Search symbol table */ |
609 | int cmd_symaddr(cmd_arg_t *argv) |
618 | int cmd_symaddr(cmd_arg_t *argv) |
610 | { |
619 | { |
611 | symtab_print_search((char *) argv->buffer); |
620 | symtab_print_search((char *) argv->buffer); |
612 | 621 | ||
613 | return 1; |
622 | return 1; |
614 | } |
623 | } |
615 | 624 | ||
- | 625 | #endif |
|
- | 626 | ||
616 | /** Call function with zero parameters */ |
627 | /** Call function with zero parameters */ |
617 | int cmd_call0(cmd_arg_t *argv) |
628 | int cmd_call0(cmd_arg_t *argv) |
618 | { |
629 | { |
- | 630 | #ifdef CONFIG_SYMTAB |
|
619 | uintptr_t symaddr; |
631 | uintptr_t symaddr; |
620 | char *symbol; |
- | |
621 | unative_t (*fnc)(void); |
632 | unative_t (*fnc)(void); |
622 | fncptr_t fptr; |
633 | fncptr_t fptr; |
623 | 634 | ||
624 | symaddr = get_symbol_addr((char *) argv->buffer); |
635 | symaddr = get_symbol_addr((char *) argv->buffer); |
625 | if (!symaddr) |
636 | if (!symaddr) |
626 | printf("Symbol %s not found.\n", argv->buffer); |
637 | printf("Symbol %s not found.\n", argv->buffer); |
627 | else if (symaddr == (uintptr_t) -1) { |
638 | else if (symaddr == (uintptr_t) -1) { |
628 | symtab_print_search((char *) argv->buffer); |
639 | symtab_print_search((char *) argv->buffer); |
629 | printf("Duplicate symbol, be more specific.\n"); |
640 | printf("Duplicate symbol, be more specific.\n"); |
630 | } else { |
641 | } else { |
631 | symbol = get_symtab_entry(symaddr); |
- | |
632 | fnc = (unative_t (*)(void)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call0); |
642 | fnc = (unative_t (*)(void)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call0); |
633 | printf("Calling %s() (%p)\n", symbol, symaddr); |
643 | printf("Calling %s() (%p)\n", argv->buffer, symaddr); |
634 | printf("Result: %#" PRIxn "\n", fnc()); |
644 | printf("Result: %#" PRIxn "\n", fnc()); |
635 | } |
645 | } |
636 | 646 | #endif |
|
637 | return 1; |
647 | return 1; |
638 | } |
648 | } |
639 | 649 | ||
640 | /** Call function with zero parameters on each CPU */ |
650 | /** Call function with zero parameters on each CPU */ |
641 | int cmd_mcall0(cmd_arg_t *argv) |
651 | int cmd_mcall0(cmd_arg_t *argv) |
Line 667... | Line 677... | ||
667 | } |
677 | } |
668 | 678 | ||
669 | /** Call function with one parameter */ |
679 | /** Call function with one parameter */ |
670 | int cmd_call1(cmd_arg_t *argv) |
680 | int cmd_call1(cmd_arg_t *argv) |
671 | { |
681 | { |
- | 682 | #ifdef CONFIG_SYMTAB |
|
672 | uintptr_t symaddr; |
683 | uintptr_t symaddr; |
673 | char *symbol; |
684 | char *symbol; |
674 | unative_t (*fnc)(unative_t, ...); |
685 | unative_t (*fnc)(unative_t, ...); |
675 | unative_t arg1 = argv[1].intval; |
686 | unative_t arg1 = argv[1].intval; |
676 | fncptr_t fptr; |
687 | fncptr_t fptr; |
677 | 688 | ||
678 | symaddr = get_symbol_addr((char *) argv->buffer); |
689 | symaddr = get_symbol_addr((char *) argv->buffer); |
- | 690 | ||
679 | if (!symaddr) |
691 | if (!symaddr) |
680 | printf("Symbol %s not found.\n", argv->buffer); |
692 | printf("Symbol %s not found.\n", argv->buffer); |
681 | else if (symaddr == (uintptr_t) -1) { |
693 | else if (symaddr == (uintptr_t) -1) { |
682 | symtab_print_search((char *) argv->buffer); |
694 | symtab_print_search((char *) argv->buffer); |
683 | printf("Duplicate symbol, be more specific.\n"); |
695 | printf("Duplicate symbol, be more specific.\n"); |
Line 685... | Line 697... | ||
685 | symbol = get_symtab_entry(symaddr); |
697 | symbol = get_symtab_entry(symaddr); |
686 | fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1); |
698 | fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1); |
687 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol); |
699 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol); |
688 | printf("Result: %#" PRIxn "\n", fnc(arg1)); |
700 | printf("Result: %#" PRIxn "\n", fnc(arg1)); |
689 | } |
701 | } |
690 | 702 | #endif |
|
691 | return 1; |
703 | return 1; |
692 | } |
704 | } |
693 | 705 | ||
694 | /** Call function with two parameters */ |
706 | /** Call function with two parameters */ |
695 | int cmd_call2(cmd_arg_t *argv) |
707 | int cmd_call2(cmd_arg_t *argv) |
696 | { |
708 | { |
- | 709 | #ifdef CONFIG_SYMTAB |
|
697 | uintptr_t symaddr; |
710 | uintptr_t symaddr; |
698 | char *symbol; |
711 | char *symbol; |
699 | unative_t (*fnc)(unative_t, unative_t, ...); |
712 | unative_t (*fnc)(unative_t, unative_t, ...); |
700 | unative_t arg1 = argv[1].intval; |
713 | unative_t arg1 = argv[1].intval; |
701 | unative_t arg2 = argv[2].intval; |
714 | unative_t arg2 = argv[2].intval; |
Line 711... | Line 724... | ||
711 | symbol = get_symtab_entry(symaddr); |
724 | symbol = get_symtab_entry(symaddr); |
712 | fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2); |
725 | fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2); |
713 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
726 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
714 | arg1, arg2, symaddr, symbol); |
727 | arg1, arg2, symaddr, symbol); |
715 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2)); |
728 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2)); |
716 | } |
729 | } |
717 | 730 | #endif |
|
718 | return 1; |
731 | return 1; |
719 | } |
732 | } |
720 | 733 | ||
721 | /** Call function with three parameters */ |
734 | /** Call function with three parameters */ |
722 | int cmd_call3(cmd_arg_t *argv) |
735 | int cmd_call3(cmd_arg_t *argv) |
723 | { |
736 | { |
- | 737 | #ifdef CONFIG_SYMTAB |
|
724 | uintptr_t symaddr; |
738 | uintptr_t symaddr; |
725 | char *symbol; |
739 | char *symbol; |
726 | unative_t (*fnc)(unative_t, unative_t, unative_t, ...); |
740 | unative_t (*fnc)(unative_t, unative_t, unative_t, ...); |
727 | unative_t arg1 = argv[1].intval; |
741 | unative_t arg1 = argv[1].intval; |
728 | unative_t arg2 = argv[2].intval; |
742 | unative_t arg2 = argv[2].intval; |
Line 740... | Line 754... | ||
740 | 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); |
741 | printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
755 | printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n", |
742 | arg1, arg2, arg3, symaddr, symbol); |
756 | arg1, arg2, arg3, symaddr, symbol); |
743 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3)); |
757 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3)); |
744 | } |
758 | } |
745 | 759 | #endif |
|
746 | return 1; |
760 | return 1; |
747 | } |
761 | } |
748 | 762 | ||
749 | 763 | ||
750 | /** Print detailed description of 'describe' command. */ |
764 | /** Print detailed description of 'describe' command. */ |
Line 795... | Line 809... | ||
795 | uint32_t *addr; |
809 | uint32_t *addr; |
796 | uint32_t arg1 = argv[1].intval; |
810 | uint32_t arg1 = argv[1].intval; |
797 | bool pointer = false; |
811 | bool pointer = false; |
798 | 812 | ||
799 | if (((char *)argv->buffer)[0] == '*') { |
813 | if (((char *)argv->buffer)[0] == '*') { |
- | 814 | #ifdef CONFIG_SYMTAB |
|
800 | addr = (uint32_t *) get_symbol_addr((char *) argv->buffer + 1); |
815 | addr = (uint32_t *) get_symbol_addr((char *) argv->buffer + 1); |
- | 816 | #else |
|
- | 817 | addr = 0; |
|
- | 818 | #endif |
|
801 | pointer = true; |
819 | pointer = true; |
802 | } else if (((char *) argv->buffer)[0] >= '0' && |
820 | } else if (((char *) argv->buffer)[0] >= '0' && |
803 | ((char *)argv->buffer)[0] <= '9') |
821 | ((char *)argv->buffer)[0] <= '9') { |
804 | addr = (uint32_t *)atoi((char *)argv->buffer); |
822 | addr = (uint32_t *)atoi((char *)argv->buffer); |
805 | else |
823 | } else { |
- | 824 | #ifdef CONFIG_SYMTAB |
|
806 | addr = (uint32_t *)get_symbol_addr((char *) argv->buffer); |
825 | addr = (uint32_t *)get_symbol_addr((char *) argv->buffer); |
- | 826 | #else |
|
- | 827 | addr = 0; |
|
- | 828 | #endif |
|
- | 829 | } |
|
807 | 830 | ||
808 | if (!addr) |
831 | if (!addr) |
809 | printf("Symbol %s not found.\n", argv->buffer); |
832 | printf("Symbol %s not found.\n", argv->buffer); |
810 | else if (addr == (uint32_t *) -1) { |
833 | else if (addr == (uint32_t *) -1) { |
- | 834 | #ifdef CONFIG_SYMTAB |
|
811 | symtab_print_search((char *) argv->buffer); |
835 | symtab_print_search((char *) argv->buffer); |
- | 836 | #endif |
|
812 | printf("Duplicate symbol, be more specific.\n"); |
837 | printf("Duplicate symbol, be more specific.\n"); |
813 | } else { |
838 | } else { |
814 | if (pointer) |
839 | if (pointer) |
815 | addr = (uint32_t *)(*(unative_t *)addr); |
840 | addr = (uint32_t *)(*(unative_t *)addr); |
816 | printf("Writing %#" PRIx64 " -> %p\n", arg1, addr); |
841 | printf("Writing %#" PRIx64 " -> %p\n", arg1, addr); |