Changeset 0ab362c in mainline for kernel/generic/src/console/cmd.c
- Timestamp:
- 2012-11-22T14:36:04Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e32720ff
- Parents:
- 1f7753a (diff), 0f2c80a (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
r1f7753a r0ab362c 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> … … 81 82 .func = cmd_help, 82 83 .argc = 0 84 }; 85 86 /* Data and methods for pio_read_8 command */ 87 static int cmd_pio_read_8(cmd_arg_t *argv); 88 static cmd_arg_t pio_read_8_argv[] = { { .type = ARG_TYPE_INT } }; 89 static cmd_info_t pio_read_8_info = { 90 .name = "pio_read_8", 91 .description = "pio_read_8 <address> Read 1 byte from memory (or port).", 92 .func = cmd_pio_read_8, 93 .argc = 1, 94 .argv = pio_read_8_argv 95 }; 96 97 /* Data and methods for pio_read_16 command */ 98 static int cmd_pio_read_16(cmd_arg_t *argv); 99 static cmd_arg_t pio_read_16_argv[] = { { .type = ARG_TYPE_INT } }; 100 static cmd_info_t pio_read_16_info = { 101 .name = "pio_read_16", 102 .description = "pio_read_16 <address> Read 2 bytes from memory (or port).", 103 .func = cmd_pio_read_16, 104 .argc = 1, 105 .argv = pio_read_16_argv 106 }; 107 108 /* Data and methods for pio_read_32 command */ 109 static int cmd_pio_read_32(cmd_arg_t *argv); 110 static cmd_arg_t pio_read_32_argv[] = { { .type = ARG_TYPE_INT } }; 111 static cmd_info_t pio_read_32_info = { 112 .name = "pio_read_32", 113 .description = "pio_read_32 <address> Read 4 bytes from memory (or port).", 114 .func = cmd_pio_read_32, 115 .argc = 1, 116 .argv = pio_read_32_argv 117 }; 118 119 /* Data and methods for pio_write_8 command */ 120 static int cmd_pio_write_8(cmd_arg_t *argv); 121 static cmd_arg_t pio_write_8_argv[] = { 122 { .type = ARG_TYPE_INT }, 123 { .type = ARG_TYPE_INT } 124 }; 125 static cmd_info_t pio_write_8_info = { 126 .name = "pio_write_8", 127 .description = "pio_write_8 <address> <value> Write 1 byte to memory (or port).", 128 .func = cmd_pio_write_8, 129 .argc = 2, 130 .argv = pio_write_8_argv 131 }; 132 133 /* Data and methods for pio_write_16 command */ 134 static int cmd_pio_write_16(cmd_arg_t *argv); 135 static cmd_arg_t pio_write_16_argv[] = { 136 { .type = ARG_TYPE_INT }, 137 { .type = ARG_TYPE_INT } 138 }; 139 static cmd_info_t pio_write_16_info = { 140 .name = "pio_write_16", 141 .description = "pio_write_16 <address> <value> Write 2 bytes to memory (or port).", 142 .func = cmd_pio_write_16, 143 .argc = 2, 144 .argv = pio_write_16_argv 145 }; 146 147 /* Data and methods for pio_write_32 command */ 148 static int cmd_pio_write_32(cmd_arg_t *argv); 149 static cmd_arg_t pio_write_32_argv[] = { 150 { .type = ARG_TYPE_INT }, 151 { .type = ARG_TYPE_INT } 152 }; 153 static cmd_info_t pio_write_32_info = { 154 .name = "pio_write_32", 155 .description = "pio_write_32 <address> <value> Write 4 bytes to memory (or port).", 156 .func = cmd_pio_write_32, 157 .argc = 2, 158 .argv = pio_write_32_argv 83 159 }; 84 160 … … 531 607 &btrace_info, 532 608 #endif 609 &pio_read_8_info, 610 &pio_read_16_info, 611 &pio_read_32_info, 612 &pio_write_8_info, 613 &pio_write_16_info, 614 &pio_write_32_info, 533 615 NULL 534 616 }; … … 601 683 spinlock_unlock(&cmd_lock); 602 684 685 return 1; 686 } 687 688 /** Read 1 byte from phys memory or io port. 689 * 690 * @param argv Argument vector. 691 * 692 * @return 0 on failure, 1 on success. 693 */ 694 static int cmd_pio_read_8(cmd_arg_t *argv) 695 { 696 uint8_t *ptr = NULL; 697 #ifdef IO_SPACE_BOUNDARY 698 if (argv->intval < IO_SPACE_BOUNDARY) 699 ptr = argv[0].intval; 700 else 701 #endif 702 ptr = (uint8_t*)km_map(argv[0].intval, sizeof(uint8_t), PAGE_NOT_CACHEABLE); 703 const uint8_t val = pio_read_8(ptr); 704 printf("read %x: %"PRIx8"\n", argv[0].intval, val); 705 #ifdef IO_SPACE_BOUNDARY 706 if (argv->intval < IO_SPACE_BOUNDARY) 707 return 1; 708 #endif 709 km_unmap((uintptr_t)ptr, sizeof(uint8_t)); 710 return 1; 711 } 712 713 /** Read 2 bytes from phys memory or io port. 714 * 715 * @param argv Argument vector. 716 * 717 * @return 0 on failure, 1 on success. 718 */ 719 static int cmd_pio_read_16(cmd_arg_t *argv) 720 { 721 uint16_t *ptr = NULL; 722 #ifdef IO_SPACE_BOUNDARY 723 if (argv->intval < IO_SPACE_BOUNDARY) 724 ptr = argv[0].intval; 725 else 726 #endif 727 ptr = (uint16_t*)km_map(argv[0].intval, sizeof(uint16_t), PAGE_NOT_CACHEABLE); 728 const uint16_t val = pio_read_16(ptr); 729 printf("read %x: %"PRIx16"\n", argv[0].intval, val); 730 #ifdef IO_SPACE_BOUNDARY 731 if (argv->intval < IO_SPACE_BOUNDARY) 732 return 1; 733 #endif 734 km_unmap((uintptr_t)ptr, sizeof(uint16_t)); 735 return 1; 736 } 737 738 /** Read 4 bytes from phys memory or io port. 739 * 740 * @param argv Argument vector. 741 * 742 * @return 0 on failure, 1 on success. 743 */ 744 static int cmd_pio_read_32(cmd_arg_t *argv) 745 { 746 uint32_t *ptr = NULL; 747 #ifdef IO_SPACE_BOUNDARY 748 if (argv->intval < IO_SPACE_BOUNDARY) 749 ptr = argv[0].intval; 750 else 751 #endif 752 ptr = (uint32_t*)km_map(argv[0].intval, sizeof(uint32_t), PAGE_NOT_CACHEABLE); 753 const uint32_t val = pio_read_32(ptr); 754 printf("read %#x: %#"PRIx32"\n", argv[0].intval, val); 755 #ifdef IO_SPACE_BOUNDARY 756 if (argv->intval < IO_SPACE_BOUNDARY) 757 return 1; 758 #endif 759 km_unmap((uintptr_t)ptr, sizeof(uint32_t)); 760 return 1; 761 } 762 763 /** Write 1 byte to phys memory or io port. 764 * 765 * @param argv Argument vector. 766 * 767 * @return 0 on failure, 1 on success. 768 */ 769 static int cmd_pio_write_8(cmd_arg_t *argv) 770 { 771 uint8_t *ptr = NULL; 772 #ifdef IO_SPACE_BOUNDARY 773 if (argv->intval < IO_SPACE_BOUNDARY) 774 ptr = argv[0].intval; 775 else 776 #endif 777 ptr = (uint8_t*)km_map(argv[0].intval, sizeof(uint8_t), PAGE_NOT_CACHEABLE); 778 printf("write %x: %"PRIx8"\n", argv[0].intval, (uint8_t)argv[1].intval); 779 pio_write_8(ptr, (uint8_t)argv[1].intval); 780 #ifdef IO_SPACE_BOUNDARY 781 if (argv->intval < IO_SPACE_BOUNDARY) 782 return 1; 783 #endif 784 km_unmap((uintptr_t)ptr, sizeof(uint8_t)); 785 return 1; 786 } 787 788 /** Write 2 bytes to phys memory or io port. 789 * 790 * @param argv Argument vector. 791 * 792 * @return 0 on failure, 1 on success. 793 */ 794 static int cmd_pio_write_16(cmd_arg_t *argv) 795 { 796 uint16_t *ptr = NULL; 797 #ifdef IO_SPACE_BOUNDARY 798 if (argv->intval < IO_SPACE_BOUNDARY) 799 ptr = argv[0].intval; 800 else 801 #endif 802 ptr = (uint16_t*)km_map(argv[0].intval, sizeof(uint16_t), PAGE_NOT_CACHEABLE); 803 printf("write %x: %"PRIx16"\n", argv[0].intval, (uint16_t)argv[1].intval); 804 pio_write_16(ptr, (uint16_t)argv[1].intval); 805 #ifdef IO_SPACE_BOUNDARY 806 if (argv->intval < IO_SPACE_BOUNDARY) 807 return 1; 808 #endif 809 km_unmap((uintptr_t)ptr, sizeof(uint16_t)); 810 return 1; 811 } 812 813 /** Write 4 bytes to phys memory or io port. 814 * 815 * @param argv Argument vector. 816 * 817 * @return 0 on failure, 1 on success. 818 */ 819 static int cmd_pio_write_32(cmd_arg_t *argv) 820 { 821 uint32_t *ptr = NULL; 822 #ifdef IO_SPACE_BOUNDARY 823 if (argv->intval < IO_SPACE_BOUNDARY) 824 ptr = argv[0].intval; 825 else 826 #endif 827 ptr = (uint32_t*)km_map(argv[0].intval, sizeof(uint32_t), PAGE_NOT_CACHEABLE); 828 printf("write %x: %"PRIx32"\n", argv[0].intval, (uint32_t)argv[1].intval); 829 pio_write_32(ptr, (uint32_t)argv[1].intval); 830 #ifdef IO_SPACE_BOUNDARY 831 if (argv->intval < IO_SPACE_BOUNDARY) 832 return 1; 833 #endif 834 km_unmap((uintptr_t)ptr, sizeof(uint32_t)); 603 835 return 1; 604 836 }
Note:
See TracChangeset
for help on using the changeset viewer.