Changeset 69146b93 in mainline for kernel/generic/src/console/cmd.c
- Timestamp:
- 2012-11-26T19:02:45Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 04552324
- Parents:
- 5d230a30 (diff), 7462674 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
r5d230a30 r69146b93 56 56 #include <cpu.h> 57 57 #include <mm/tlb.h> 58 #include <mm/km.h> 58 59 #include <arch/mm/tlb.h> 59 60 #include <mm/frame.h> … … 83 84 .func = cmd_help, 84 85 .argc = 0 86 }; 87 88 /* Data and methods for pio_read_8 command */ 89 static int cmd_pio_read_8(cmd_arg_t *argv); 90 static cmd_arg_t pio_read_8_argv[] = { { .type = ARG_TYPE_INT } }; 91 static cmd_info_t pio_read_8_info = { 92 .name = "pio_read_8", 93 .description = "pio_read_8 <address> Read 1 byte from memory (or port).", 94 .func = cmd_pio_read_8, 95 .argc = 1, 96 .argv = pio_read_8_argv 97 }; 98 99 /* Data and methods for pio_read_16 command */ 100 static int cmd_pio_read_16(cmd_arg_t *argv); 101 static cmd_arg_t pio_read_16_argv[] = { { .type = ARG_TYPE_INT } }; 102 static cmd_info_t pio_read_16_info = { 103 .name = "pio_read_16", 104 .description = "pio_read_16 <address> Read 2 bytes from memory (or port).", 105 .func = cmd_pio_read_16, 106 .argc = 1, 107 .argv = pio_read_16_argv 108 }; 109 110 /* Data and methods for pio_read_32 command */ 111 static int cmd_pio_read_32(cmd_arg_t *argv); 112 static cmd_arg_t pio_read_32_argv[] = { { .type = ARG_TYPE_INT } }; 113 static cmd_info_t pio_read_32_info = { 114 .name = "pio_read_32", 115 .description = "pio_read_32 <address> Read 4 bytes from memory (or port).", 116 .func = cmd_pio_read_32, 117 .argc = 1, 118 .argv = pio_read_32_argv 119 }; 120 121 /* Data and methods for pio_write_8 command */ 122 static int cmd_pio_write_8(cmd_arg_t *argv); 123 static cmd_arg_t pio_write_8_argv[] = { 124 { .type = ARG_TYPE_INT }, 125 { .type = ARG_TYPE_INT } 126 }; 127 static cmd_info_t pio_write_8_info = { 128 .name = "pio_write_8", 129 .description = "pio_write_8 <address> <value> Write 1 byte to memory (or port).", 130 .func = cmd_pio_write_8, 131 .argc = 2, 132 .argv = pio_write_8_argv 133 }; 134 135 /* Data and methods for pio_write_16 command */ 136 static int cmd_pio_write_16(cmd_arg_t *argv); 137 static cmd_arg_t pio_write_16_argv[] = { 138 { .type = ARG_TYPE_INT }, 139 { .type = ARG_TYPE_INT } 140 }; 141 static cmd_info_t pio_write_16_info = { 142 .name = "pio_write_16", 143 .description = "pio_write_16 <address> <value> Write 2 bytes to memory (or port).", 144 .func = cmd_pio_write_16, 145 .argc = 2, 146 .argv = pio_write_16_argv 147 }; 148 149 /* Data and methods for pio_write_32 command */ 150 static int cmd_pio_write_32(cmd_arg_t *argv); 151 static cmd_arg_t pio_write_32_argv[] = { 152 { .type = ARG_TYPE_INT }, 153 { .type = ARG_TYPE_INT } 154 }; 155 static cmd_info_t pio_write_32_info = { 156 .name = "pio_write_32", 157 .description = "pio_write_32 <address> <value> Write 4 bytes to memory (or port).", 158 .func = cmd_pio_write_32, 159 .argc = 2, 160 .argv = pio_write_32_argv 85 161 }; 86 162 … … 553 629 &btrace_info, 554 630 #endif 631 &pio_read_8_info, 632 &pio_read_16_info, 633 &pio_read_32_info, 634 &pio_write_8_info, 635 &pio_write_16_info, 636 &pio_write_32_info, 555 637 NULL 556 638 }; … … 623 705 spinlock_unlock(&cmd_lock); 624 706 707 return 1; 708 } 709 710 /** Read 1 byte from phys memory or io port. 711 * 712 * @param argv Argument vector. 713 * 714 * @return 0 on failure, 1 on success. 715 */ 716 static int cmd_pio_read_8(cmd_arg_t *argv) 717 { 718 uint8_t *ptr = NULL; 719 720 #ifdef IO_SPACE_BOUNDARY 721 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 722 ptr = (void *) argv[0].intval; 723 else 724 #endif 725 ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t), 726 PAGE_NOT_CACHEABLE); 727 728 const uint8_t val = pio_read_8(ptr); 729 printf("read %" PRIxn ": %" PRIx8 "\n", argv[0].intval, val); 730 731 #ifdef IO_SPACE_BOUNDARY 732 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 733 return 1; 734 #endif 735 736 km_unmap((uintptr_t) ptr, sizeof(uint8_t)); 737 return 1; 738 } 739 740 /** Read 2 bytes from phys memory or io port. 741 * 742 * @param argv Argument vector. 743 * 744 * @return 0 on failure, 1 on success. 745 */ 746 static int cmd_pio_read_16(cmd_arg_t *argv) 747 { 748 uint16_t *ptr = NULL; 749 750 #ifdef IO_SPACE_BOUNDARY 751 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 752 ptr = (void *) argv[0].intval; 753 else 754 #endif 755 ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t), 756 PAGE_NOT_CACHEABLE); 757 758 const uint16_t val = pio_read_16(ptr); 759 printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val); 760 761 #ifdef IO_SPACE_BOUNDARY 762 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 763 return 1; 764 #endif 765 766 km_unmap((uintptr_t) ptr, sizeof(uint16_t)); 767 return 1; 768 } 769 770 /** Read 4 bytes from phys memory or io port. 771 * 772 * @param argv Argument vector. 773 * 774 * @return 0 on failure, 1 on success. 775 */ 776 static int cmd_pio_read_32(cmd_arg_t *argv) 777 { 778 uint32_t *ptr = NULL; 779 780 #ifdef IO_SPACE_BOUNDARY 781 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 782 ptr = (void *) argv[0].intval; 783 else 784 #endif 785 ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t), 786 PAGE_NOT_CACHEABLE); 787 788 const uint32_t val = pio_read_32(ptr); 789 printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val); 790 791 #ifdef IO_SPACE_BOUNDARY 792 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 793 return 1; 794 #endif 795 796 km_unmap((uintptr_t) ptr, sizeof(uint32_t)); 797 return 1; 798 } 799 800 /** Write 1 byte to phys memory or io port. 801 * 802 * @param argv Argument vector. 803 * 804 * @return 0 on failure, 1 on success. 805 */ 806 static int cmd_pio_write_8(cmd_arg_t *argv) 807 { 808 uint8_t *ptr = NULL; 809 810 #ifdef IO_SPACE_BOUNDARY 811 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 812 ptr = (void *) argv[0].intval; 813 else 814 #endif 815 ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t), 816 PAGE_NOT_CACHEABLE); 817 818 printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval, 819 (uint8_t) argv[1].intval); 820 pio_write_8(ptr, (uint8_t) argv[1].intval); 821 822 #ifdef IO_SPACE_BOUNDARY 823 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 824 return 1; 825 #endif 826 827 km_unmap((uintptr_t) ptr, sizeof(uint8_t)); 828 return 1; 829 } 830 831 /** Write 2 bytes to phys memory or io port. 832 * 833 * @param argv Argument vector. 834 * 835 * @return 0 on failure, 1 on success. 836 */ 837 static int cmd_pio_write_16(cmd_arg_t *argv) 838 { 839 uint16_t *ptr = NULL; 840 841 #ifdef IO_SPACE_BOUNDARY 842 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 843 ptr = (void *) argv[0].intval; 844 else 845 #endif 846 ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t), 847 PAGE_NOT_CACHEABLE); 848 849 printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval, 850 (uint16_t) argv[1].intval); 851 pio_write_16(ptr, (uint16_t) argv[1].intval); 852 853 #ifdef IO_SPACE_BOUNDARY 854 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 855 return 1; 856 #endif 857 858 km_unmap((uintptr_t) ptr, sizeof(uint16_t)); 859 return 1; 860 } 861 862 /** Write 4 bytes to phys memory or io port. 863 * 864 * @param argv Argument vector. 865 * 866 * @return 0 on failure, 1 on success. 867 */ 868 static int cmd_pio_write_32(cmd_arg_t *argv) 869 { 870 uint32_t *ptr = NULL; 871 872 #ifdef IO_SPACE_BOUNDARY 873 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 874 ptr = (void *) argv[0].intval; 875 else 876 #endif 877 ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t), 878 PAGE_NOT_CACHEABLE); 879 880 printf("write %" PRIxn ": %" PRIx32 "\n", argv[0].intval, 881 (uint32_t) argv[1].intval); 882 pio_write_32(ptr, (uint32_t) argv[1].intval); 883 884 #ifdef IO_SPACE_BOUNDARY 885 if ((void *) argv->intval < IO_SPACE_BOUNDARY) 886 return 1; 887 #endif 888 889 km_unmap((uintptr_t) ptr, sizeof(uint32_t)); 625 890 return 1; 626 891 }
Note:
See TracChangeset
for help on using the changeset viewer.